From 0f8ade7de4b01c7c0d97e5854e59842e2d561542 Mon Sep 17 00:00:00 2001 From: Jorge Leal Date: Fri, 6 Nov 2026 08:48:37 +0100 Subject: [PATCH] MT#55283 Keep the egress index on plain RTP output fed by SRTP or AVPF Closes #2238 Plain RTP output kept the egress index in userspace only when its input was RTP/AVP (__sh_noop_index); from SRTP or AVPF input (__sh_savp2avp, __sh_avpf2avp, __sh_savpf2avp) the output handler was a no-op, so such a leg had no egress counter until the kernel took over. With a fixed egress SSRC, the re-base on a change of source reads that counter (ext_seq), found it empty or stale and made the sequence jump under an SSRC that the next hop cannot see change. With a WebRTC client feeding a plain RTP leg that is bridged back to another WebRTC client, the jump reached the far browser, whose SRTP replay protection then dropped audio. These three handlers now use __shio_noop_index like RTP/AVP input does. The cost is the index arithmetic on userspace-forwarded packets; the kernel already keeps the index. Codec-generated packets on such legs (e.g. an audio player) are indexed too, through the same hook. Change-Id: Iae8c14b77f5a052cbcc918ce3f903b7b9dc18c88 --- daemon/media_socket.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/daemon/media_socket.c b/daemon/media_socket.c index 787c78adb..668e32222 100644 --- a/daemon/media_socket.c +++ b/daemon/media_socket.c @@ -264,13 +264,19 @@ static const struct streamhandler __sh_noop = { .in = &__shio_noop, .out = &__shio_noop, }; +/* Plain RTP output keeps the egress index in userspace (`rtp_update_index`) + * whatever the input: SRTP or AVPF input too, not only RTP/AVP. Otherwise a + * plain leg fed by SRTP or AVPF (e.g. a WebRTC client bridged to plain RTP) has + * no egress counter until the kernel takes over, and a fixed egress SSRC + * re-bases its sequence on that empty or stale counter. Integer arithmetic on + * userspace-forwarded packets only; the kernel already keeps the index. */ static const struct streamhandler __sh_noop_index = { .in = &__shio_noop, .out = &__shio_noop_index, }; static const struct streamhandler __sh_savp2avp = { .in = &__shio_decrypt, - .out = &__shio_noop, + .out = &__shio_noop_index, }; static const struct streamhandler __sh_avp2savp = { .in = &__shio_noop, @@ -278,7 +284,7 @@ static const struct streamhandler __sh_avp2savp = { }; static const struct streamhandler __sh_avpf2avp = { .in = &__shio_avpf_strip, - .out = &__shio_noop, + .out = &__shio_noop_index, }; static const struct streamhandler __sh_avpf2savp = { .in = &__shio_avpf_strip, @@ -286,7 +292,7 @@ static const struct streamhandler __sh_avpf2savp = { }; static const struct streamhandler __sh_savpf2avp = { .in = &__shio_decrypt_avpf_strip, - .out = &__shio_noop, + .out = &__shio_noop_index, }; static const struct streamhandler __sh_savp2savp = { .in = &__shio_decrypt,