[Asterisk-code-review] main/udptl.c: correctly handle udptl sequence wrap around (...asterisk[17.0])
George Joseph
asteriskteam at digium.com
Tue Aug 6 09:47:35 CDT 2019
George Joseph has submitted this change and it was merged. ( https://gerrit.asterisk.org/c/asterisk/+/11649 )
Change subject: main/udptl.c: correctly handle udptl sequence wrap around
......................................................................
main/udptl.c: correctly handle udptl sequence wrap around
incorrect handling of UDPTL squence number wrap arounds causes
loss of packets every time the wrap around occurs
ASTERISK-28483 #close
Change-Id: I33caeb2bf13c574a1ebb81714b58907091d64234
---
M main/udptl.c
1 file changed, 18 insertions(+), 0 deletions(-)
Approvals:
Kevin Harwell: Looks good to me, but someone else must approve; Verified
George Joseph: Looks good to me, approved; Approved for Submit
diff --git a/main/udptl.c b/main/udptl.c
index 99a9c74..555ae69 100644
--- a/main/udptl.c
+++ b/main/udptl.c
@@ -405,6 +405,24 @@
seq_no = (buf[0] << 8) | buf[1];
ptr += 2;
+ /* UDPTL sequence numbers are 16 bit so after 0xFFFF comes
+ 0 which breaks all packet recovery logic. To fix this
+ if we see that next expected packet (rx_seq_no) is close
+ to or beyond the wrap around limit & the received packet
+ is still near zero, then we 'unwrap' the received seqno
+ so it has the value it would have had. After a 16
+ packet grace period (there shouldn't be more than
+ that many recovery packets) we wrap the expected
+ sequence number around and things can return back
+ to normal */
+ if (seq_no < 0x000F && s->rx_seq_no > 0xFFF0) {
+ /* received seq_no has wrapped adjust it */
+ seq_no += 0x10000;
+ } else {
+ /* otherwise make sure expected rx_seq_no is properly wrapped */
+ s->rx_seq_no &= 0xFFFF;
+ }
+
/* Break out the primary packet */
if ((stat1 = decode_open_type(buf, len, &ptr, &ifp, &ifp_len)) != 0)
return -1;
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/11649
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 17.0
Gerrit-Change-Id: I33caeb2bf13c574a1ebb81714b58907091d64234
Gerrit-Change-Number: 11649
Gerrit-PatchSet: 1
Gerrit-Owner: Torrey Searle <tsearle at gmail.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190806/6f98c129/attachment.html>
More information about the asterisk-code-review
mailing list