Received: from diktynna.open-mesh.org (diktynna.open-mesh.org [136.243.236.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE846606A31C for ; Sat, 28 Nov 2026 16:07:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=narfation.org header.i=@narfation.org header.a=rsa-sha256 header.s=20121 header.b=ly3v3JxY Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id 5906284280 for ; Sat, 28 Nov 2026 17:07:11 +0100 (CET) ARC-Seal: i=2; cv=pass; a=rsa-sha256; d=open-mesh.org; s=20121; t=1795882031; b=knNAGUBu8g2uTxk4WeSEVXcsRI/p2DW4LWbAzKGmbz7vmEGLi7AIDM5/VahyljoKKsks1 8r6jWeyrjqqofmeczbIDb4HQxAsnRYJyqT3otIK5LYCcPNKg6hiO6/qF1+PfIftGexMgbdO NwssZ9VRTyIfPjbabny5p0/C+NJljcE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1795882031; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=BFlpxlNBXSXE52dF/JokgTI6PcUrdf7cKlCrKb8qNGI=; b=M+z9UgnF0lL1eJwfDTHYgW690yoaQwNxY4p+L5TE3xfCsPr8+ZJ3EWmyBWdMeXZXjVpau 3Unja4Ec7BEV/pyxRz8WopNOwoP8J3g549y1h3HNxnMVOlHwnY1VI5byaCpfyqLhfMT0VL1 0tynEmbAuehOa/bM00KHw2atnGgp4s4= ARC-Authentication-Results: i=2; open-mesh.org; dkim=pass header.d=narfation.org; arc=pass; dmarc=pass header.from=narfation.org policy.dmarc=none Authentication-Results: open-mesh.org; dkim=pass header.d=narfation.org; arc=pass; dmarc=pass (Used From Domain Record) header.from=narfation.org policy.dmarc=none Received: from dvalin.narfation.org (dvalin.narfation.org [213.160.73.56]) by diktynna.open-mesh.org (Postfix) with UTF8SMTPS id 02AF580E76 for ; Sat, 28 Nov 2026 17:06:52 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; d=open-mesh.org; s=20121; cv=none; t=1795882023; b=ABZulX49jU/O3Q/jV72mbrYF3ZQKy+rssM4fd05j1Gtt4ZJZYZTU4zOaavCqjev6C2q7Gq eg8OoDkvWI1c6HDpNScSt20hjLfCnSvdnStof3S+TLLVJozAOD3W1hd/L6nT95Brcj5Dqv rHfanXyF7xcCaa8+C8QLr5jugcPba2M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1795882023; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding:dkim-signature; bh=BFlpxlNBXSXE52dF/JokgTI6PcUrdf7cKlCrKb8qNGI=; b=V3CxxGQQBjlP4rOcIuvpcOwZbBnDs2uAQTEOY+v8BZHFjP/yxBIT87oBZ0/hh6LgaAsQVq 74CaxhsvdQvq6rXgN6pDTSYgnIZ5It+IcdYkj6OzfxTRdU6g27VWOMyTqIzbMkxABRrY7e G8Sh5fkW0dSRqS78sxfLrypYSshjI8g= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=pass header.d=narfation.org header.s=20121 header.b=ly3v3JxY; spf=pass (diktynna.open-mesh.org: domain of sven@narfation.org designates 213.160.73.56 as permitted sender) smtp.mailfrom=sven@narfation.org; dmarc=pass (policy=none) header.from=narfation.org Received: by dvalin.narfation.org (Postfix) id 2BAA420462; Sat, 28 Nov 2026 16:06:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=narfation.org; s=20121; t=1795882012; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=BFlpxlNBXSXE52dF/JokgTI6PcUrdf7cKlCrKb8qNGI=; b=ly3v3JxYNEXtfgGp+S5Lga/WghwHLsgCnuObmA6Yg/SGxCmfVAuUz3yPfH8dMcr89gtzxb Guo/tw3mvdYe7oZKq/R5cGN9tsNrnPn9z7akph48fEER6I+fU01NSe4R9jmne1jr6a5SqJ iie/tXBMeqM26MePVe2a0obO2UYy8as= From: Sven Eckelmann Date: Sat, 28 Nov 2026 17:06:35 +0100 Subject: [PATCH batadv] batman-adv: tt: commit sync flags of local entries with their ADD X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261128-tt-local-sync-flags-commit-v1-1-cfb00491d224@narfation.org> X-B4-Tracking: v=1; b=H4sIAAr8CmsC/y2NQQ6CMBBFr0Jm7SQWUiBexbAo7RRrSqudQjSEu 1vF5ft5eX8DpuSI4VJtkGh17GIoIE4V6JsKE6EzhaE+160QdY85o49aeeR30Gi9mhh1nGeXsZP S9iSbrjUGSuCRyLrXL36FUWVlVhiOnZfxTjp/y38z0XMp7/nQh33/AL7MfxWbAAAA X-Change-ID: 20261128-tt-local-sync-flags-commit-755f8e5376dd To: b.a.t.m.a.n@lists.open-mesh.org Cc: Sashiko , Sven Eckelmann X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=9695; i=sven@narfation.org; h=from:subject:message-id; bh=wonDS992AYssA6YkaicCEsfTpQBqotQmNAWQ6FM2eGk=; b=owGbwMvMwCXmy1+ufVnk62nG02pJDNlcf3h8wt5NP62/rKLlRB2bjH5QRo337SdHnvOeyVxUv UbC4u23jlIWBjEuBlkxRZY9V/LPb2Z/K/952sejMHNYmUCGMHBxCsBEJmox/E/MdFkk+br3hrxp 9uU0QcO6qzxRG/2eLpmi7rYnMJ75gwfDP5VfumyWxsqrdu/lKdyzKmnHxoMNATMOs/yNkz3/4Qz 3XBYA X-Developer-Key: i=sven@narfation.org; a=openpgp; fpr=522D7163831C73A635D12FE5EC371482956781AF Message-ID-Hash: OB26ASNBPTZJ4BVDHSFPQN3YUY2UHATZ X-Message-ID-Hash: OB26ASNBPTZJ4BVDHSFPQN3YUY2UHATZ X-MailFrom: sven@narfation.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; header-match-b.a.t.m.a.n.lists.open-mesh.org-2; header-match-b.a.t.m.a.n.lists.open-mesh.org-3; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_NONE,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 batadv_tt_local_refresh() stores a changed WIFI or ISOLA flag in an already announced local entry right away. The other nodes only learn about it when the queued ADD is committed. But the CRC and the full table responses use the current flags of the entry: CPU0 (commit) CPU1 (tx) batadv_tt_local_commit_changes_nolock() |-takes the queued changes | batadv_tt_local_add() | \-batadv_tt_local_refresh() | |-queues ADD for next ttvn | \-stores the new flags in | the entry |-batadv_tt_local_update_crc() | CRC contains the new flags \-batadv_tt_tvlv_container_update() Announced changes don't contain the new flags The CRC of the new ttvn doesn't match the announced changes. The other nodes detect the mismatch and have to request the full table. A full table response has the same problem without the race. It contains the new flags when it is sent before the ADD is committed. But its CRC is the one of the last commit. Store the sync flags of the last committed ADD in the local entry. They are updated by batadv_tt_local_commit_change() and are the only flags used for the CRC and the full table responses. The current flags of the entry are still used for everything else. Reported-by: Sashiko Closes: https://sashiko.dev/#/bug/linux-36084f3a-b64c-48d0-b7ff-888c96ca5cce Signed-off-by: Sven Eckelmann --- net/batman-adv/translation-table.c | 89 ++++++++++++++++++++++++-------------- net/batman-adv/types.h | 7 +++ 2 files changed, 64 insertions(+), 32 deletions(-) diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 6102bdf6..05894b01 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -1017,6 +1017,7 @@ batadv_tt_local_create(struct net_device *mesh_iface, const u8 *addr, last_seen = jiffies; WRITE_ONCE(tt_local->last_seen, last_seen); tt_local->del_unqueued = false; + tt_local->committed_flags = 0; tt_local->common.added_at = last_seen; tt_local->vlan = vlan; spin_lock_init(&tt_local->common.flags_lock); @@ -3473,6 +3474,39 @@ static u32 batadv_tt_global_crc(struct batadv_priv *bat_priv, return crc; } +/** + * batadv_tt_local_announced() - check if local entry is announced and get its + * committed sync flags + * @tt_common: local TT entry to check + * @flags: a pointer to store the committed BATADV_TT_SYNC_MASK flags to + * (optional). No other flags of the entry are returned + * + * The flags of an entry can be modified at any time by + * batadv_tt_local_refresh(). The other nodes only learn about it when the + * queued ADD is committed. The CRC and the full table responses must therefore + * use the flags of the last committed ADD and not the current ones. + * + * Return: true if the entry is part of the announced local table, false if it + * is still waiting for the commit of its ADD. + */ +static bool batadv_tt_local_announced(struct batadv_tt_common_entry *tt_common, + u8 *flags) +{ + struct batadv_tt_local_entry *tt_local; + bool announced; + + tt_local = container_of(tt_common, struct batadv_tt_local_entry, + common); + + scoped_guard(spinlock_bh, &tt_common->flags_lock) { + announced = !(tt_common->flags & BATADV_TT_CLIENT_NEW); + if (announced && flags) + *flags = tt_local->committed_flags; + } + + return announced; +} + /** * batadv_tt_local_crc() - calculates the checksum of the local table * @bat_priv: the bat priv with all the mesh interface information @@ -3500,24 +3534,18 @@ static u32 batadv_tt_local_crc(struct batadv_priv *bat_priv, rcu_read_lock(); hlist_for_each_entry_rcu(tt_common, head, hash_entry) { - u16 tt_flags; - /* compute the CRC only for entries belonging to the * VLAN identified by vid */ if (tt_common->key.vid != vid) continue; - tt_flags = batadv_tt_flags_get(tt_common); - /* not yet committed clients have not to be taken into * account while computing the CRC */ - if (tt_flags & BATADV_TT_CLIENT_NEW) + if (!batadv_tt_local_announced(tt_common, &flags)) continue; - flags = tt_flags & BATADV_TT_SYNC_MASK; - /* use network order to read the VID: this ensures that * every node reads the bytes in the same order. */ @@ -3675,10 +3703,11 @@ batadv_tt_req_node_new(struct batadv_priv *bat_priv, } /** - * batadv_tt_local_valid() - verify local tt entry and get flags + * batadv_tt_local_valid() - verify local tt entry and get committed sync flags * @entry_ptr: to be checked local tt entry * @data_ptr: not used but definition required to satisfy the callback prototype - * @flags: a pointer to store TT flags for this client to + * @flags: a pointer to store the committed BATADV_TT_SYNC_MASK flags of this + * client to. No other flags of the entry are returned * * Checks the validity of the given local TT entry. If it is, then the provided * flags pointer is updated. @@ -3690,20 +3719,8 @@ static bool batadv_tt_local_valid(void *entry_ptr, u8 *flags) { struct batadv_tt_common_entry *tt_common_entry = entry_ptr; - u16 tt_flags; - tt_flags = batadv_tt_flags_get(tt_common_entry); - if (tt_flags & BATADV_TT_CLIENT_NEW) - return false; - - /* the entry is (still) announced. A ROAM flag of an entry which is - * pending to be removed must not be transmitted. Otherwise, the - * receiver would handle it like a roaming advertisement - */ - if (flags) - *flags = tt_flags & ~BATADV_TT_CLIENT_ROAM; - - return true; + return batadv_tt_local_announced(tt_common_entry, flags); } /** @@ -3747,7 +3764,8 @@ static bool batadv_tt_global_valid(void *entry_ptr, * @hash: hash table containing the tt entries * @tt_len: expected tvlv tt data buffer length in number of bytes * @tvlv_buff: pointer to the buffer to fill with the TT data - * @valid_cb: function to filter tt change entries and to return TT flags + * @valid_cb: function to filter tt change entries and to return committed + * BATADV_TT_SYNC_MASK flags of this client * @cb_data: data passed to the filter function as argument * * Fills the tvlv buff with the tt entries from the specified hash. If valid_cb @@ -4715,8 +4733,9 @@ batadv_tt_local_unhash_pending(struct batadv_priv *bat_priv, * committed with a later ttvn. * * An ADD finishes the BATADV_TT_CLIENT_NEW state of the entry and it is counted - * as part of the local table from now on. A DEL removes the entry which is - * marked as BATADV_TT_CLIENT_PENDING from the local table. + * as part of the local table from now on. Its sync flags are stored as the + * ones known by the other nodes. A DEL removes the entry which is marked as + * BATADV_TT_CLIENT_PENDING from the local table. * * The entry is not protected by bat_priv->tt.commit_lock against a concurrent * refresh and removal. The client of a committed DEL can therefore be detected @@ -4742,7 +4761,9 @@ batadv_tt_local_commit_change(struct batadv_priv *bat_priv, struct batadv_tt_common_entry_key key; struct hlist_head *head; bool committed = false; + bool unhashed = false; bool del_op; + u8 flags; u32 i; lockdep_assert_held(&bat_priv->tt.commit_lock); @@ -4764,8 +4785,14 @@ batadv_tt_local_commit_change(struct batadv_priv *bat_priv, if (!batadv_compare_tt(&tt_common->hash_entry, &key)) continue; + tt_local = container_of(tt_common, struct batadv_tt_local_entry, + common); + scoped_guard(spinlock_bh, &tt_common->flags_lock) { if (!del_op) { + flags = change->flags & BATADV_TT_SYNC_MASK; + tt_local->committed_flags = flags; + /* an ADD of an already committed entry only * announces new flags or cancels its removal */ @@ -4777,14 +4804,11 @@ batadv_tt_local_commit_change(struct batadv_priv *bat_priv, break; } - tt_local = container_of(tt_common, - struct batadv_tt_local_entry, - common); - if (batadv_tt_local_unhash_pending(bat_priv, tt_local)) + unhashed = batadv_tt_local_unhash_pending(bat_priv, + tt_local); + if (unhashed) break; - tt_local = NULL; - /* The client was detected again after its DEL was * taken. The other nodes remove it with this ttvn and * only add it again with the still queued ADD. The @@ -4806,7 +4830,8 @@ batadv_tt_local_commit_change(struct batadv_priv *bat_priv, spin_unlock_bh(list_lock); /* drop reference of removed hash entry */ - batadv_tt_local_entry_put(tt_local); + if (unhashed) + batadv_tt_local_entry_put(tt_local); } /** diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index d443143f..aa678ac8 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h @@ -1946,6 +1946,13 @@ struct batadv_tt_local_entry { */ bool del_unqueued; + /** + * @committed_flags: BATADV_TT_SYNC_MASK flags of the last committed + * ADD. The other nodes know the client with these flags. Protected by + * common.flags_lock + */ + u8 committed_flags; + /** @vlan: mesh-interface vlan of the entry */ struct batadv_meshif_vlan *vlan; }; --- base-commit: d0395afd7a33fd0fcf7d71795fec9a5204d9e6bc change-id: 20261128-tt-local-sync-flags-commit-755f8e5376dd Best regards, -- Sven Eckelmann