Skip to content

Commit

Permalink
MT#55283 rekernelize after DTLS connect
Browse files Browse the repository at this point in the history
Change-Id: I468b6c07df96111ee49a85e36382a692dbeec82b
(cherry picked from commit 7b1557c)
(cherry picked from commit 8864542)
  • Loading branch information
rfuchs committed Sep 26, 2024
1 parent 764baf9 commit 67ba73b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion daemon/call.c
Original file line number Diff line number Diff line change
Expand Up @@ -1039,8 +1039,10 @@ enum call_stream_state call_stream_state_machine(struct packet_stream *ps) {
mutex_lock(&ps->in_lock);
struct dtls_connection *d = dtls_ptr(ps->selected_sfd);
if (d && d->init && !d->connected) {
dtls(ps->selected_sfd, NULL, NULL);
int dret = dtls(ps->selected_sfd, NULL, NULL);
mutex_unlock(&ps->in_lock);
if (dret == 1)
call_media_unkernelize(media, "DTLS connected");
return CSS_DTLS;
}
mutex_unlock(&ps->in_lock);
Expand Down
5 changes: 4 additions & 1 deletion daemon/dtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,8 @@ int dtls(struct stream_fd *sfd, const str *s, const endpoint_t *fsin) {
MEDIA_CLEAR(ps->media, SDES);
}

int dret = 0;

ret = try_connect(d);
if (ret == -1) {
ilogs(srtp, LOG_ERROR, "DTLS error on local port %u", sfd->socket.local.port);
Expand All @@ -834,6 +836,7 @@ int dtls(struct stream_fd *sfd, const str *s, const endpoint_t *fsin) {
}
else if (ret == 1) {
/* connected! */
dret = 1;
mutex_lock(&ps->out_lock); // nested lock!
if (dtls_setup_crypto(ps, d))
{} /* XXX ?? */
Expand Down Expand Up @@ -889,7 +892,7 @@ int dtls(struct stream_fd *sfd, const str *s, const endpoint_t *fsin) {
}
}

return 0;
return dret;
}

/* call must be locked */
Expand Down
5 changes: 5 additions & 0 deletions daemon/media_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -2133,6 +2133,11 @@ static int media_demux_protocols(struct packet_handler_ctx *phc) {

mutex_lock(&phc->mp.stream->in_lock);
int ret = dtls(phc->mp.sfd, &phc->s, &phc->mp.fsin);
if (ret == 1) {
phc->unkernelize = "DTLS connected";
phc->unkernelize_subscriptions = true;
ret = 0;
}
mutex_unlock(&phc->mp.stream->in_lock);
if (!ret)
return 0;
Expand Down

0 comments on commit 67ba73b

Please sign in to comment.