From 7b1557cc1efbc9847c8870575dc9db4f8dd795b5 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 25 Sep 2024 11:58:05 -0400 Subject: [PATCH] MT#55283 rekernelize after DTLS connect Change-Id: I468b6c07df96111ee49a85e36382a692dbeec82b --- daemon/call.c | 4 +++- daemon/dtls.c | 5 ++++- daemon/media_socket.c | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index a088bd5dd9..76bc6295d5 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -1117,8 +1117,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); diff --git a/daemon/dtls.c b/daemon/dtls.c index d6447beb66..04669a29f1 100644 --- a/daemon/dtls.c +++ b/daemon/dtls.c @@ -820,6 +820,8 @@ int dtls(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); @@ -834,6 +836,7 @@ int dtls(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 ?? */ @@ -889,7 +892,7 @@ int dtls(stream_fd *sfd, const str *s, const endpoint_t *fsin) { } } - return 0; + return dret; } /* call must be locked */ diff --git a/daemon/media_socket.c b/daemon/media_socket.c index 0cac639a57..73125e071a 100644 --- a/daemon/media_socket.c +++ b/daemon/media_socket.c @@ -2035,6 +2035,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;