Browse Source

MT#56420 fix incorrect local socket switching

When a receiving socket doesn't match the socket we were expecting, make
sure that the receiving socket is actually one of the sockets we want to
use at this point before blindly switching the socket.

This fixes a race condition after a re-invite: A new set of sockets has
been opened, but an old/delayed RTP packet still arrives on one of the
old ports. In this case we don't want to switch the local socket.

Change-Id: I4e2b87ad608b1a9c6a0bb2eae5c305fd79be70d5
(cherry picked from commit 304a1b11ef)
pull/1611/head
Richard Fuchs 3 years ago
parent
commit
deb676e009
1 changed files with 16 additions and 5 deletions
  1. +16
    -5
      daemon/media_socket.c

+ 16
- 5
daemon/media_socket.c View File

@ -2211,11 +2211,22 @@ update_addr:
/* check the destination address of the received packet against what we think our /* check the destination address of the received packet against what we think our
* local interface to use is */ * local interface to use is */
if (phc->mp.stream->selected_sfd && phc->mp.sfd != phc->mp.stream->selected_sfd) { if (phc->mp.stream->selected_sfd && phc->mp.sfd != phc->mp.stream->selected_sfd) {
ilog(LOG_INFO, "Switching local interface to %s", endpoint_print_buf(&phc->mp.sfd->socket.local));
phc->mp.stream->selected_sfd = phc->mp.sfd;
phc->unkernelize = true;
phc->update = true;
phc->unkernelize_subscriptions = true;
// make sure the new interface/socket is actually one from the list of sockets
// that we intend to use, and not an old one from a previous negotiation
GList *contains = g_queue_find(&phc->mp.stream->sfds, phc->mp.sfd);
if (!contains)
ilog(LOG_INFO | LOG_FLAG_LIMIT, "Not switching from local socket %s to %s (not in list)",
endpoint_print_buf(&phc->mp.stream->selected_sfd->socket.local),
endpoint_print_buf(&phc->mp.sfd->socket.local));
else {
ilog(LOG_INFO | LOG_FLAG_LIMIT, "Switching local socket from %s to %s",
endpoint_print_buf(&phc->mp.stream->selected_sfd->socket.local),
endpoint_print_buf(&phc->mp.sfd->socket.local));
phc->mp.stream->selected_sfd = phc->mp.sfd;
phc->unkernelize = true;
phc->update = true;
phc->unkernelize_subscriptions = true;
}
} }
out: out:


Loading…
Cancel
Save