From patchwork Sat May 5 15:30:20 2018 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: 17336 X-Patchwork-Delegate: a@unstable.cc Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from open-mesh.org (localhost [IPv6:::1]) by open-mesh.org (Postfix) with ESMTP id 9FE9C80D96; Sat, 5 May 2018 17:38:28 +0200 (CEST) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=138.201.29.205; helo=mail.aperture-lab.de; envelope-from=linus.luessing@c0d3.blue; receiver= X-Greylist: delayed 460 seconds by postgrey-1.36 at open-mesh.org; Sat, 05 May 2018 17:38:25 CEST Received: from mail.aperture-lab.de (mail.aperture-lab.de [138.201.29.205]) by open-mesh.org (Postfix) with ESMTPS id C4C64806A5 for ; Sat, 5 May 2018 17:38:25 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.aperture-lab.de (Postfix) with ESMTP id 4DCDBE0860; Sat, 5 May 2018 17:30:45 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at aperture-lab.de Received: from mail.aperture-lab.de ([127.0.0.1]) by localhost (mail.aperture-lab.de [127.0.0.1]) (amavisd-new, port 10025) with ESMTP id nzRXV5xESOHK; Sat, 5 May 2018 17:30:42 +0200 (CEST) Received: from localhost (unknown [IPv6:2a01:170:1112:0:bcd7:94ff:fefd:2ddd]) (Authenticated sender: linus.luessing@c0d3.blue) by mail.aperture-lab.de (Postfix) with ESMTPSA; Sat, 5 May 2018 17:30:42 +0200 (CEST) From: =?utf-8?q?Linus_L=C3=BCssing?= To: b.a.t.m.a.n@lists.open-mesh.org Date: Sat, 5 May 2018 17:30:20 +0200 Message-Id: <20180505153020.29636-1-linus.luessing@c0d3.blue> X-Mailer: git-send-email 2.17.0 MIME-Version: 1.0 Subject: [B.A.T.M.A.N.] [PATCH maint] batman-adv: Fix TT sync flags for intermediate TT responses X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" The previous TT sync fix so far only fixed TT responses issued by the target node directly. So far, TT responses issued by intermediate nodes still lead to the wrong flags being added, leading to CRC mismatches. This behaviour was observed at Freifunk Hannover in a 800 nodes setup where a considerable amount of nodes were still infected with 'WI' TT flags even with (most) nodes having the previous TT sync fix applied. I was able to reproduce the issue with intermediate TT responses in a four node test setup and this patch fixes this issue by ensuring to use the per originator instead of the summarized, OR'd ones. Fixes: fa614fd04692 ("batman-adv: fix tt_global_entries flags update") Signed-off-by: Linus Lüssing --- net/batman-adv/translation-table.c | 42 +++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 0225616d..a95724ea 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -2914,6 +2914,41 @@ static bool batadv_tt_global_valid(const void *entry_ptr, } /** + * batadv_tt_get_flags() - get TT flags for a given entry + * @tt_common_entry: the TT entry to get the flags for + * @orig: for a TT global entry the specific node to get the flags for + * + * Return: -ENOENT on error or the TT flags otherwise. + */ +static int +batadv_tt_get_flags(struct batadv_tt_common_entry *tt_common_entry, + struct batadv_orig_node *orig) +{ + const struct batadv_tt_global_entry *tt_global_entry; + struct batadv_tt_orig_list_entry *orig_entry; + int flags; + + /* a tt-local entry has no 'per orig' entries */ + if (!orig) + return tt_common_entry->flags; + + /* else this is a tt-global entry, get flags for node */ + tt_global_entry = container_of(tt_common_entry, + struct batadv_tt_global_entry, + common); + + orig_entry = batadv_tt_global_orig_entry_find(tt_global_entry, orig); + if (!orig_entry) + return -ENOENT; + + flags = orig_entry->flags; + + batadv_tt_orig_list_entry_put(orig_entry); + + return flags; +} + +/** * batadv_tt_tvlv_generate() - fill the tvlv buff with the tt entries from the * specified tt hash * @bat_priv: the bat priv with all the soft interface information @@ -2934,6 +2969,7 @@ static void batadv_tt_tvlv_generate(struct batadv_priv *bat_priv, struct batadv_tvlv_tt_change *tt_change; struct hlist_head *head; u16 tt_tot, tt_num_entries = 0; + int flags; u32 i; tt_tot = batadv_tt_entries(tt_len); @@ -2951,8 +2987,12 @@ static void batadv_tt_tvlv_generate(struct batadv_priv *bat_priv, if ((valid_cb) && (!valid_cb(tt_common_entry, cb_data))) continue; + flags = batadv_tt_get_flags(tt_common_entry, cb_data); + if (flags < 0) + continue; + ether_addr_copy(tt_change->addr, tt_common_entry->addr); - tt_change->flags = tt_common_entry->flags; + tt_change->flags = flags; tt_change->vid = htons(tt_common_entry->vid); memset(tt_change->reserved, 0, sizeof(tt_change->reserved));