MT#55283 fix off-by-one

Treat a packet exactly one ring size ahead across the 65535->0
wrap-around as a seq reset, like the non-wrapped case, instead of
accepting it into the head slot.

Fixes #2220

Change-Id: I94e2fdd3d50d5c8241cfed5da06829097566356e
pull/2222/head
Richard Fuchs 3 weeks ago
parent 1212fd5df0
commit fc703ce91c

@ -629,7 +629,8 @@ int packet_sequencer_insert(packet_sequencer_t *ps, seq_packet_t *p) {
if (G_LIKELY(diff >= 0 && diff < G_N_ELEMENTS(ps->packets)))
goto seq_ok;
// early packet with wrap-around: p->seq = 20, ps->a_seq = 65530, diff = -65510
if (diff < (-0xffff + (signed) G_N_ELEMENTS(ps->packets)))
// (a packet exactly one ring size ahead is a seq reset, same as without wrap-around)
if (diff < (-0x10000 + (signed) G_N_ELEMENTS(ps->packets)))
goto seq_ok;
// recent duplicate: p->seq = 1000, ps->seq = 1080, diff = -80
if (diff < 0 && diff > -(signed) G_N_ELEMENTS(ps->packets)) {

Loading…
Cancel
Save