πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #21978

Re: [PATCH net-next 12/15] batman-adv: tt: extract removal of pending local entry

#21978
From: netdev-bot+sashiko
Date: Tue, 24 Nov 2026 17:20
117 lines
12473 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The kernel-docs of batadv_tt_local_unhash() and
  batadv_tt_local_unhash_pending() disagree about who checks that the…

--

batman-adv: tt: extract removal of pending local entry

This moves the removal of a single pending entry out of
batadv_tt_local_purge_pending_clients() into a new helper,
batadv_tt_local_unhash_pending(). The helper calls a lower level
batadv_tt_local_unhash(), which does the actual unhash steps. There is
no functional change.

> diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
> index 0c5e21f3ba756..2a7f50de70fc8 100644
> --- a/net/batman-adv/translation-table.c
> +++ b/net/batman-adv/translation-table.c
> @@ -1760,6 +1760,44 @@ int batadv_tt_local_dump(struct sk_buff *msg, struct netlink_callback *cb)
>  	return ret;
>  }
>  
> +/**
> + * batadv_tt_local_unhash() - remove an entry from the local table
> + * @bat_priv: the bat priv with all the mesh interface information
> + * @tt_local: the local TT entry to remove
> + * @message: message to append to the log on deletion
> + *
> + * The caller must hold the hash bucket list_lock and the flags_lock of the
> + * entry. It must have checked that the entry is still part of the local table
> + * and has to drop the reference of the hash after it released the flags_lock.
> + */

[ ... ]

> @@ -4550,6 +4588,43 @@ static void batadv_tt_local_transition_new(struct batadv_priv *bat_priv)
>  	}
>  }
>  
> +/**
> + * batadv_tt_local_unhash_pending() - remove a pending entry from the local table
> + * @bat_priv: the bat priv with all the mesh interface information
> + * @tt_local: the local TT entry to remove
> + *
> + * Only an entry which is marked as BATADV_TT_CLIENT_PENDING and whose DEL was
> + * queued is removed. An entry which still waits for its DEL (del_unqueued) must
> + * stay in the local table until batadv_tt_local_purge_list() was able to queue
> + * it.
> + *
> + * The caller must hold the hash bucket list_lock and the flags_lock of the
> + * entry.
> + *
> + * Return: true if the entry was unhashed and the caller has to drop the
> + * reference of the hash, false otherwise.
> + */
> +static bool
> +batadv_tt_local_unhash_pending(struct batadv_priv *bat_priv,
> +			       struct batadv_tt_local_entry *tt_local)
> +	__must_hold(&tt_local->common.flags_lock)
> +{
> +	struct batadv_tt_common_entry *tt_common = &tt_local->common;
> +
> +	lockdep_assert_held(&tt_common->flags_lock);
> +
> +	if (!(tt_common->flags & BATADV_TT_CLIENT_PENDING))
> +		return false;
> +
> +	/* the removal must be announced first */
> +	if (tt_local->del_unqueued)
> +		return false;
> +
> +	batadv_tt_local_unhash(bat_priv, tt_local, "pending");
> +
> +	return true;
> +}

[Severity: Low]
This isn't a bug, but the kernel-doc of batadv_tt_local_unhash_pending()
seems to leave out a requirement it inherits from batadv_tt_local_unhash().

The kernel-doc of batadv_tt_local_unhash() says the caller "must have
checked that the entry is still part of the local table". That function
does not check hlist_unhashed() itself. It always calls
hlist_del_init_rcu(), increments hash->generation and calls
batadv_tt_local_size_dec() for entries without BATADV_TT_CLIENT_NEW.

batadv_tt_local_unhash_pending() checks only BATADV_TT_CLIENT_PENDING and
del_unqueued before it calls batadv_tt_local_unhash(). Its kernel-doc asks
callers only to hold the bucket list_lock and the flags_lock. It still
says that a true return means the caller must drop the hash reference.

batadv_tt_local_unhash() does not clear the flags. So an entry that was
already unhashed can still have BATADV_TT_CLIENT_PENDING set with
del_unqueued false.

A caller that relied only on the documented contract of the wrapper could
pass such an entry and get true back. The per-VID size would then be
decremented twice and the hash reference put twice.

There is no such caller now. Both batadv_tt_local_purge_pending_clients()
and the batadv_tt_local_commit_change() caller added later in the series
find the entry by walking the bucket under list_lock.

Could the kernel-doc of batadv_tt_local_unhash_pending() state the same
membership requirement as batadv_tt_local_unhash()? Another option would
be an hlist_unhashed() check inside the wrapper.

[ ... ]

-- 
Sashiko AI review Β· https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123171827.3294525-2-sw%40simonwunderlich.de
Technical Details
Message-ID: <179554084613.3135.2138652598368843379@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370613-linux-kernel-netdev=dewy.ru
References: <20261123171827.3294525-13-sw@simonwunderlich.de>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370613-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next 12/15] batman-adv: tt: extract removal of pending
 local entry
Date: Tue, 24 Nov 2026 17:20:46 +0000
Organization: Usenet Network
Message-ID: <179554084613.3135.2138652598368843379@kernel.org>
References: <20261123171827.3294525-13-sw@simonwunderlich.de>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="4188894"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:esqYLQqCsp4PYWSmujPWZz+hOj8= sha256:x0tDOSSbltD9M/H6jxpVJ1dh+SKA07HMIOZ7jw5Yc4I=
	sha1:humhVAeqaFkL6Uj8T8FhGyha0d0= sha256:fij361r/ZNCwDHKPw9KMu0aIE+fUYs907rSOZvK9I4w=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 4AAB6125E2A; Tue, 24 Nov 2026 20:21:18 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 8wY5NR56dfUd;
	Tue, 24 Nov 2026 20:21:14 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-370613-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 4DF03125E22; Tue, 24 Nov 2026 20:21:06 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id B052B368E7; Tue, 24 Nov 2026 17:20:50 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795540848;
	b=mDRw7YOe0yb33eYy+fvYTVKd9OsX+gJVNyzBVDrDZeuZTKwCn95rR56Vw2MQb5lnnpzc
	 VD2S/oWHz8oNvlZXFPV8QHR9yTs9NB981u3eRpXpEhz7x4kuG0FvNeeeYGB5NovFYn8SH
	 Beoe/g+Ktrt0yqrQaYsNxwdqxb76Pkq92ueBIcuVgjOkOUb1DbzGrr1LSIc9tdydGrGUQ
	 skzApgJp7ak+yHwXPwrZzLlo4CwllPGDJ3igSCnVHK15jTa8bjB5xzltwXska4NsjS9KK
	 zKMM92Nfuf9B2Rsru86vOfLiqAx/IMfQEncaHZ2aSUJAnXSbp2aDZ0bTTd9kmHz4mAQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795540848;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=3AaHa7wUvfXbgjXKSaJH9L1BQGA+L/wa6rMO4rpmjeI=;
	b=X1r7kuDyaxMdfMA+sCMm+qoH492AdvMlEyFxHXaxiyPa3EAnQWCODCfyJaL64kqu7Lbv
	 Rf1fBWa3I/avEYtXwtC88Agmxr8Mg3So4xq4phkGlQXUmQQ1OFe/YUBjnbKRVQ9y2FcQU
	 uYIrchr2dwvO91wh4zmo68R7LRzk+r+3W7dkWDw6wZCpSB2clqO1eSbEeKHvYWlmg0MrO
	 AgRRZ8tyt0Qb4zeXdlcugOVxXk9vgkD0lnpILSFyNvQVXv9Q1WBKFqzMhLZC4yfWMun9c
	 3Ck1feg2LMyz8gGHsJhe/Bl4EB6Y3ln4I7PaaeMenU52/6j5DADftI07P/C7p+C4J1A==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=cCa2s9rw;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 26CEE606A330;
	Tue, 24 Nov 2026 17:20:48 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=cCa2s9rw
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795540847;
	b=xCvKA1gBak3S1J47XRegOdBQPzyQ9OOHINuHilZq4f3dgzYOjVuVqLtoM936mRFIRiaR
	 MrFzTfyQn7tO09UGiKw6+3HBYI+ehR5quM5vQylSEim0HH8k209x23Hr9Uogvgf0cYCwX
	 skR4jamrknvy8UPuwtGu4/aPJTY3QT8Rhlw04Lreae+gmEv7a0gidrGfP4ZNfK/uIMXTO
	 iRvI6pqvHVHZc6oVbSctEDq7djzdpOKytJF5PwY6pBYqxRO7NWwGkQJivNCkwdgfPPgiH
	 RioQTSyhXsos4hhk/As5Xm94FADAA9XEzKi80/e4YqkjTS+vEmawV7xaE6SAlubv39w==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795540847;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=3AaHa7wUvfXbgjXKSaJH9L1BQGA+L/wa6rMO4rpmjeI=;
	b=vqUJAUzt8GjhVZVvYk9vqJ0qTdu6ThFcX0Kg1PquDfb3ZRuL+mmnzJSB8v/QxCSltyeY
	 iM9k4kWpNSltXTe8bL/fV1IwwMCKzSxaqWA4bU+bx3CfvtTGrz04Z0MOAqrlP8jYlWn5X
	 eTIqXqbSMuAp1m2dLEuYV1fY6AgLBSism7UjCJLAvv4hfhjgY+c7YRA09Mcd9s0nXqlnB
	 STn9ugSdgX5l6WnclGf4+ZUM62xFIE8ZGPZ2BcUv0lNvZhWCMXB2PnzPGS+0tXNmmVfg4
	 VL+UDmr5MyH8dxQ3VAZdda0f78gXk2DRLk3XEKrIDIbSSmTBXDTihQyQ+IkQMFPOSJQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=cCa2s9rw;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48F79606A33D
	for <netdev@vger.kernel.org>; Tue, 24 Nov 2026 17:20:47 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 914811F000D3;
	Tue, 24 Nov 2026 17:20:46 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795540847;
	bh=3AaHa7wUvfXbgjXKSaJH9L1BQGA+L/wa6rMO4rpmjeI=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=cCa2s9rw9bd5FmH+j5Jo8eJUhcAvO3VZ/gLWj4PN10g6F1viGQS5VrgFfZxCGeRja
	 6pnvQqn1alJ5mDRc6RX4vpFvJhwh1z6z5k2fgteCqh4S51YcR56PAditcDNzuhPjlS
	 TWnICZ0EqpHAEgOboB3jHvVFBxuSup8J2oNDp3ySj7UXowz+KX7S2YT+743o+NV+q/
	 k+54UBHgcRA2KtHptucm2UIFXkVEFQRH8EVqF2hVCc7Epii25iOBrQjunDvObCDQ3K
	 U68ZeEBpmExuAWy7EGoqCdG2Plsqks0+ig8b2fr4wjb0Zvhuwzq9RE+Cf79LYrvsdF
	 p66LMN3dWNmiQ==
X-Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com,
 kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
 b.a.t.m.a.n@lists.open-mesh.org, sven@narfation.org
X-In-Reply-To: <20261123171827.3294525-13-sw@simonwunderlich.de>
X-sashiko-severity: Low
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list