From patchwork Wed Mar 2 17:18:41 2011 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: 840 Return-Path: Received: from ascomax.hasler.ascom.ch (ascomax.hasler.ascom.ch [139.79.135.1]) by open-mesh.org (Postfix) with ESMTPS id 9198715420E for ; Wed, 2 Mar 2011 18:18:48 +0100 (CET) Received: from eiger.ma.tech.ascom.ch (eiger.ma.tech.ascom.ch [139.79.100.1]) by ascomax.hasler.ascom.ch (8.14.4/8.14.4) with ESMTP id p22HIkW2017499; Wed, 2 Mar 2011 18:18:46 +0100 (MET) Received: from [139.79.100.104] (helo=localhost) by eiger.ma.tech.ascom.ch with esmtp (Exim 3.16 #1) id 1PuphE-00048D-00; Wed, 02 Mar 2011 18:18:44 +0100 From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: b.a.t.m.a.n@lists.open-mesh.org Date: Wed, 2 Mar 2011 18:18:41 +0100 Message-Id: <1299086321-25116-13-git-send-email-linus.luessing@ascom.ch> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1299086321-25116-1-git-send-email-linus.luessing@ascom.ch> References: <1299086321-25116-1-git-send-email-linus.luessing@ascom.ch> MIME-Version: 1.0 Cc: =?UTF-8?q?Linus=20L=C3=BCssing?= Subject: [B.A.T.M.A.N.] [PATCH 12/12] batman-adv: Add sequence number and duplicate checks for unicasts_safe X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.13 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: Wed, 02 Mar 2011 17:18:49 -0000 With the new redundant bonding mode a node might receive a unicast_safe packet more than once. Therefore duplicate checks on any unicast_safe packet need to be performed before further processing. Signed-off-by: Linus Lüssing --- originator.c | 3 +++ routing.c | 14 +++++++++++++- types.h | 2 ++ 3 files changed, 18 insertions(+), 1 deletions(-) diff --git a/originator.c b/originator.c index 57cb5c9..3be8460 100644 --- a/originator.c +++ b/originator.c @@ -198,6 +198,7 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr) INIT_LIST_HEAD(&orig_node->bond_list); spin_lock_init(&orig_node->ogm_cnt_lock); spin_lock_init(&orig_node->bcast_seqno_lock); + spin_lock_init(&orig_node->ucast_safe_seqno_lock); spin_lock_init(&orig_node->neigh_list_lock); /* extra reference for return */ @@ -209,6 +210,8 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr) orig_node->hna_buff = NULL; orig_node->bcast_seqno_state.seqno_reset = jiffies - 1 - msecs_to_jiffies(RESET_PROTECTION_MS); + orig_node->ucast_safe_seqno_state.seqno_reset = jiffies - 1 + - msecs_to_jiffies(RESET_PROTECTION_MS); orig_node->batman_seqno_reset = jiffies - 1 - msecs_to_jiffies(RESET_PROTECTION_MS); diff --git a/routing.c b/routing.c index a2c55fd..d19eb77 100644 --- a/routing.c +++ b/routing.c @@ -1440,13 +1440,25 @@ int recv_ucast_safe_packet(struct sk_buff *skb, struct hard_iface *recv_if) struct unicast_packet_safe *unicast_packet; struct orig_node *orig_node; int hdr_size = sizeof(struct unicast_packet); - int bonding_mode; + int ret, bonding_mode; if (check_unicast_packet(skb, hdr_size) < 0) return NET_RX_DROP; unicast_packet = (struct unicast_packet_safe *)skb->data; + orig_node = orig_hash_find(bat_priv, unicast_packet->orig); + if (!orig_node) + return NET_RX_DROP; + + ret = check_duplicate(bat_priv, ntohl(unicast_packet->seqno), + &orig_node->ucast_safe_seqno_state, + &orig_node->ucast_safe_seqno_lock); + + orig_node_free_ref(orig_node); + if (ret == NET_RX_DROP) + return NET_RX_DROP; + /* packet for me */ if (is_my_mac(unicast_packet->dest)) { unicast_safe_to_unicast(skb); diff --git a/types.h b/types.h index cceff07..bfab0c7 100644 --- a/types.h +++ b/types.h @@ -93,11 +93,13 @@ struct orig_node { struct bat_priv *bat_priv; unsigned long last_frag_packet; struct seqno_state bcast_seqno_state; + struct seqno_state ucast_safe_seqno_state; spinlock_t ogm_cnt_lock; /* protects: bcast_own, bcast_own_sum, * neigh_node->real_bits, * neigh_node->real_packet_count */ spinlock_t bcast_seqno_lock; /* protects bcast_bits, * last_bcast_seqno */ + spinlock_t ucast_safe_seqno_lock; /* protects ucast_safe_seqno_state */ atomic_t bond_candidates; struct list_head bond_list; };