When the seqno for a vis packet had a wrap around from i.e. 255 to 0, add_packet() would falsely claim the older packet with the seqno 255 as newer as the one with the seqno of 0 and would therefore ignore the new packet. This happens with all following vis packets until the old vis packet expires after 180 seconds timeout. This patch fixes this issue and gets rid of these highly undesired 3min. breaks for the vis-server.
Signed-off-by: Linus Lüssing linus.luessing@web.de --- batman-adv-kernelland/packet.h | 3 ++- batman-adv-kernelland/vis.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/batman-adv-kernelland/packet.h b/batman-adv-kernelland/packet.h index c8b973f..df38883 100644 --- a/batman-adv-kernelland/packet.h +++ b/batman-adv-kernelland/packet.h @@ -106,7 +106,8 @@ struct vis_packet { uint8_t packet_type; uint8_t version; /* batman version field */ uint8_t vis_type; /* which type of vis-participant sent this? */ - uint8_t seqno; /* sequence number */ + uint8_t seqno; /* sequence number + * (add_packet() expects uint8_t) */ uint8_t entries; /* number of entries behind this struct */ uint8_t ttl; /* TTL */ uint8_t vis_orig[6]; /* originator that informs about its diff --git a/batman-adv-kernelland/vis.c b/batman-adv-kernelland/vis.c index fa8a487..6cab4ba 100644 --- a/batman-adv-kernelland/vis.c +++ b/batman-adv-kernelland/vis.c @@ -213,7 +213,8 @@ static struct vis_info *add_packet(struct vis_packet *vis_packet, old_info = hash_find(vis_hash, &search_elem);
if (old_info != NULL) { - if (vis_packet->seqno - old_info->packet.seqno <= 0) { + /* seqno is uint8_t, therefore checking for 127 */ + if ((vis_packet->seqno - old_info->packet.seqno) > 127) { if (old_info->packet.seqno == vis_packet->seqno) { recv_list_add(&old_info->recv_list, vis_packet->sender_orig);