From patchwork Tue Apr 3 21:50:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 1641 Return-Path: Received: from confino.investici.org (investici.nine.ch [217.150.252.179]) by open-mesh.org (Postfix) with ESMTPS id 32EF4600759 for ; Tue, 3 Apr 2012 23:49:29 +0200 (CEST) Authentication-Results: open-mesh.org; dkim=pass (1024-bit key) header.i=@autistici.org; dkim-adsp=pass Received: from [217.150.252.179] (confino [217.150.252.179]) (Authenticated sender: ordex@autistici.org) by localhost (Postfix) with ESMTPSA id 8CEFAC865D; Tue, 3 Apr 2012 21:49:28 +0000 (UTC) X-DKIM: Sendmail DKIM Filter v2.8.2 confino.investici.org 8CEFAC865D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1333489768; bh=6vHhoxq68+EV/1wczzjZ4WPDhoBp1TmGgUx6huU1J0I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=Bn5lynaH57ViLE3WTU+gEbuhcRuo5Cf9mqUvg5+PO2HSe5g08UdBtGRtkrk52voyT zrjR2GDVEvyQxU4M/wP0+1vAePQA/6Xqoa7Icu3KkJgP2gDz3aO2AKKRbwfJR/6pUu CmMIMXksaa92FhgOjdF3jPQilFMshE/qFH+vR7yU= From: Antonio Quartulli To: b.a.t.m.a.n@lists.open-mesh.org Date: Tue, 3 Apr 2012 23:50:18 +0200 Message-Id: <1333489822-27692-2-git-send-email-ordex@autistici.org> X-Mailer: git-send-email 1.7.9.4 In-Reply-To: <1333489822-27692-1-git-send-email-ordex@autistici.org> References: <1333489822-27692-1-git-send-email-ordex@autistici.org> Subject: [B.A.T.M.A.N.] [PATCH 1/5] batman-adv: clear ADD+DEL (and viceversa) events in the same orig-interval 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: Tue, 03 Apr 2012 21:49:29 -0000 During an OGM-interval (time between two different OGM sendings) the same client could roam away and then roam back to us. In this case the node would add two events to the events list (that is going to be sent appended to the next OGM). A DEL one and an ADD one. Obviously they will only increase the overhead (either in the air and on the receiver side) and eventually trigger wrong states/events without producing any real effect. For this reason we can safely delete any ADD event with its related DEL one. Signed-off-by: Antonio Quartulli --- translation-table.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/translation-table.c b/translation-table.c index 934900d..438b786 100644 --- a/translation-table.c +++ b/translation-table.c @@ -154,23 +154,48 @@ static void tt_orig_list_entry_free_ref(struct tt_orig_list_entry *orig_entry) static void tt_local_event(struct bat_priv *bat_priv, const uint8_t *addr, uint8_t flags) { - struct tt_change_node *tt_change_node; + struct tt_change_node *tt_change_node, *entry, *safe; + bool event_removed = false; tt_change_node = kmalloc(sizeof(*tt_change_node), GFP_ATOMIC); - if (!tt_change_node) return; - tt_change_node->change.flags = flags; memcpy(tt_change_node->change.addr, addr, ETH_ALEN); + /* check for ADD+DEL or DEL+ADD events */ spin_lock_bh(&bat_priv->tt_changes_list_lock); + list_for_each_entry_safe(entry, safe, &bat_priv->tt_changes_list, + list) { + if (!compare_eth(entry->change.addr, addr)) + continue; + if (!(!(flags & TT_CLIENT_DEL) && /* ADD op */ + entry->change.flags & TT_CLIENT_DEL) && + !(flags & TT_CLIENT_DEL && + !(entry->change.flags & TT_CLIENT_DEL))) /* ADD op */ + continue; + /* DEL+ADD in the same orig interval have no effect and can be + * removed to avoid silly behaviour on the receiver side. The + * other way around (ADD+DEL) can happen in case of roaming of + * a client still in the NEW state. Roaming of NEW clients is + * now possible due to automatically recognition of "temporary" + * clients */ + list_del(&entry->list); + kfree(entry); + event_removed = true; + goto unlock; + } + /* track the change in the OGMinterval list */ list_add_tail(&tt_change_node->list, &bat_priv->tt_changes_list); - atomic_inc(&bat_priv->tt_local_changes); + +unlock: spin_unlock_bh(&bat_priv->tt_changes_list_lock); - atomic_set(&bat_priv->tt_ogm_append_cnt, 0); + if (event_removed) + atomic_dec(&bat_priv->tt_local_changes); + else + atomic_inc(&bat_priv->tt_local_changes); } int tt_len(int changes_num)