From patchwork Thu Mar 11 16:38:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Linus_L=C3=BCssing?= X-Patchwork-Id: 20 Return-Path: Received: from fmmailgate01.web.de (fmmailgate01.web.de [217.72.192.221]) by open-mesh.net (Postfix) with ESMTP id D6CCF154311 for ; Thu, 11 Mar 2010 17:39:38 +0100 (CET) Received: from smtp07.web.de (fmsmtp07.dlan.cinetic.de [172.20.5.215]) by fmmailgate01.web.de (Postfix) with ESMTP id DB83214C9343A for ; Thu, 11 Mar 2010 17:39:37 +0100 (CET) Received: from [92.224.147.159] (helo=localhost) by smtp07.web.de with asmtp (TLSv1:AES128-SHA:128) (WEB.DE 4.110 #314) id 1NplQ9-0000Q8-00; Thu, 11 Mar 2010 17:39:37 +0100 From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: b.a.t.m.a.n@lists.open-mesh.org Date: Thu, 11 Mar 2010 17:38:49 +0100 Message-Id: <1268325529-10998-1-git-send-email-linus.luessing@web.de> X-Mailer: git-send-email 1.7.0 In-Reply-To: <20100309230308.GB30949@Linus-Debian> References: <20100309230308.GB30949@Linus-Debian> MIME-Version: 1.0 Sender: linus.luessing@web.de X-Sender: linus.luessing@web.de X-Provags-ID: V01U2FsdGVkX19R69b5FivHdiTCjAYtCVr32ocbhHafA0kvuFFS LIVFDRZBzIlF2V/a5LSegnlGRrAVBYKO8lNpgjBm5+WX+g5P4w hGwHdGCAWOTLVwpdhTUQ== Subject: [B.A.T.M.A.N.] [PATCH] batman-adv: Fixing wrap-around bug in vis X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.11 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Mar 2010 16:39:39 -0000 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 --- 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);