๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #17928

Re: [PATCH net-next 6/6] bonding: factor out bond_enslave_validate

#17928
From: netdev-bot+sashiko
Date: Tue, 17 Nov 2026 14:40
79 lines
10760 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 commit message says the new bond_enslave_validate() helper
  (drivers/net/bonding/bond_main.c) does "all read-only checks".

--

bonding: factor out bond_enslave_validate

This commit moves the fail-fast checks at the top of bond_enslave() into
a new static helper, bond_enslave_validate(), in
drivers/net/bonding/bond_main.c. Behavior does not change. The moved
block runs from the ARPHRD_CAN check through the bond_slave_xdp_check()
call.

> bond_enslave() is a long linear function whose flow is hard to see
> behind the inline blocks. Factor out bond_enslave_validate to do
> all read-only checks.

[Severity: Low]
Is "all read-only checks" accurate here? The patch moves only the checks
that already ran before the first mutation. Several other checks that
only read state are still inline in bond_enslave().

Two of them run before any mutation:

drivers/net/bonding/bond_main.c:bond_enslave() {
    ...
	if (!bond_has_slaves(bond)) {
		if (bond_dev->type != slave_dev->type) {
			if (slave_dev->type != ARPHRD_ETHER &&
			    BOND_MODE(bond) == BOND_MODE_8023AD) {
				SLAVE_NL_ERR(bond_dev, slave_dev, extack,
					     "8023AD mode requires Ethernet devices");
				return -EINVAL;
			}
    ...
	} else if (bond_dev->type != slave_dev->type) {
		SLAVE_NL_ERR(bond_dev, slave_dev, extack,
			     "Device type is different from other slaves");
		return -EINVAL;
	}
    ...
}

The infiniband mode check only reads slave_dev->type and BOND_MODE(bond).
It runs after the first-slave type change block, though, and exits
through err_undo_flags:

	if (slave_dev->type == ARPHRD_INFINIBAND &&
	    BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) {
		SLAVE_NL_ERR(bond_dev, slave_dev, extack,
			     "Only active-backup mode is supported for infiniband slaves");
		res = -EOPNOTSUPP;
		goto err_undo_flags;
	}

For a first slave, the bond has already gone through
NETDEV_PRE/POST_TYPE_CHANGE, dev_uc_flush()/dev_mc_flush() and
bond_setup_by_slave() at that point. err_undo_flags then calls
dev_close(bond_dev) and bond_ether_setup(bond_dev). This behaves the same
before and after the patch.

The fail_over_mac check after it also only reads state.

The helper's own code comment, and the "Failures return directly, no
undo needed at that point" sentence, are accurate for what the helper
contains.

Could the commit message say that the helper holds the checks that run
before the first mutation, rather than all read-only checks?

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113-bond_enslave_restruct-v1-0-364c549e78db%40kylinos.cn
Technical Details
Message-ID: <179492641344.3136.5360540192397591551@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365352-linux-kernel-netdev=dewy.ru
References: <20261113-bond_enslave_restruct-v1-6-364c549e78db@kylinos.cn>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365352-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next 6/6] bonding: factor out bond_enslave_validate
Date: Tue, 17 Nov 2026 14:40:13 +0000
Organization: Usenet Network
Message-ID: <179492641344.3136.5360540192397591551@kernel.org>
References: <20261113-bond_enslave_restruct-v1-6-364c549e78db@kylinos.cn>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2355789"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:NkElT7gUR4hGSSTrvsknlieF7ik= sha256:SALZK0Yw9Uix/zRPqn+72t0QPbC8UvSTwDBS+uzPC3M=
	sha1:/X1MngRibZO7icC4lAxx7/zBZ/k= sha256:9g2mjeaogRTPsf5JBs4+ema/9m+xz19f27GAqriOilY=
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 0C02D114FAC; Tue, 17 Nov 2026 17:44:53 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 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] 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 dzR16tv8lrGr;
	Tue, 17 Nov 2026 17:44:48 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-365352-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 7D9B6114F4F; Tue, 17 Nov 2026 17:44:39 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id C46256509F; Tue, 17 Nov 2026 14:40:27 +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=1794926415;
	b=NtdTR+AbEI7o0/04lGsaplU9oTvJbLB9uHelCIPP1U/NaTnXUUSh1ajqXzYdQQK80fvC
	 G5Ok+JJS5ITB/8OTTWKALcGTR/FPVlwJE8tccxStpT/7D5JekcVdXzs4sT7ePPjSiw7oN
	 ix2+NgRggHwPTpHlzphzzTFfAzJFSag2NhxRp2aHxqDRYnkqY7snv3eBkibtzq5J8O6/U
	 pjZF/46GItjqUKbtr3Nqhthg3MsNpjo7pLwOlw7l1akhhiCHqAu72rJsjVWCwpY21W645
	 v4ptkzxsyhhH/9FuvS5hm1fOniDxSltpfDsH8vWYXfwY34rZydCmrt/HZEfk5hFhx4Q==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794926415;
	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=WthlfORmHr381B6mMH+xwS5vVfrpofwjdyuXKbp+s14=;
	b=MMbIgBD8Hf6VRXirVD4pyS3pSiPPm/PjVEY4DPJL7jkisoFTwabJ8z5F2ZZFQo+uIlDL
	 UdrlyNkUTFyEO+IvlDPNGfJ2jkouLsnl+fj0BlsngwOFlGVLX1MjUaKRjXqKBI4UaDo4A
	 twCm0I7KnY81LsYdsxYI198p4Rf0/IzK235whanMXTnLrM4yfUhD+/Msqr+ZDc18s7Oaa
	 SYzI8Q2JE8vPt+NJSKA1JD7h/qNirVvdNxrsGCJa+K4VtUYiAKVJ7xoFrTpYrA1WH9/CG
	 78vKVr9ZPu1zjNtBWcXPJrvodAhwQQKHYiuaGCcmb0svZ8vyHl0Thi+YiJdPa7owhCw==
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=SF4UFEju;
	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 B843260A2610;
	Tue, 17 Nov 2026 14:40:15 +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=SF4UFEju
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=1794926414;
	b=JfZ3GdlNpMvYMQ9EejZahmNJZYWcTvIX+BrMxPdxpVy5Z4XZRq9ikcyKGNhmnIoo5ebU
	 ocsPraBTLpy+XlVZoqdiOLfBVsiHdyuxE8mGcc8CsKFTd4vstObP74roUFsRnS0/toUsJ
	 XUmnSCyvIuMArneWhegre2N8NviDSCW1EU6yW5R4FBk0uyDZKBGWZgD6Im1+kIN1xzbbW
	 6fJms2HeK8lRL5tQq293Weha/N1N2jPUpBrOcyzBf4hIlJAkcRxRZvqXSwxhA2xe1m3Ix
	 qvmhELteRltSjgdKi7vqtzi2vS4e2hzPtpPNxgI+CecLyhecsYfvIMZ00IfWqINbziw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794926414;
	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=WthlfORmHr381B6mMH+xwS5vVfrpofwjdyuXKbp+s14=;
	b=TzqzKreyeHSrKKVntOvLDSLA/xt4DqKfbkB017ztnNoCmkVL3QpzdAzybJkVYfQ84Hud
	 3UAl7eKEl2MHcCSQ+xcXVidoQWtC9pG91wAbNDHMCgKyCn35GLex3/kj7kkKsUV7hvqZP
	 RjdzKKQlUcOmsWupz1q/zBlSdTMhNJ+09kstKXjbOiBnNxcYsdfUL+aAUaKkaTBoIjVwr
	 vGBDPSsFvAZ1sfNb4vaRcc7Nafrue0KFIHYfwmVOVGnDJO7WNixXsLpc3sxzUz38p1z4y
	 w0TdvLgoH4DeN6heAX6SC4cy85XGA2Vv5WUx8Hgc0O0lIaRR7ebd0qH5Tco7Zd9Rv8Q==
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=SF4UFEju;
	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 D5B55606A88A;
	Tue, 17 Nov 2026 14:40:14 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE5521F000C4;
	Tue, 17 Nov 2026 14:40:13 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794926414;
	bh=WthlfORmHr381B6mMH+xwS5vVfrpofwjdyuXKbp+s14=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=SF4UFEjunxygYzlzdr2ZZ1qyS6uV97tC+HamldVnYUmAo8epAwNKOJDgqQBbjAfgV
	 L5aQ0TFL4OxEnBSZsgmTcDv1QPtFQYjmXZVi1hodepSXmVWd61n/WJ0KaIF0RivKpZ
	 6zxI2uQSs2yO8JuwS9/B93jdORcpp58q9Zl2gPzQPpsm7oBq5AsVQzgaSMKIlIk9uT
	 emuJ1XSy0qwLn4+XGA6U0b+Csph+C+pNjlLW9x+oDOpugQVm0u6jmRfufC6tnuOSQa
	 7ZEDz9TthdcPvEFuvF6ZlfpNU8GkCk269U/R87veEkDsljpyaJOaqRJEaVZmISEprT
	 /ZnHmPNZEyk7g==
X-Cc: jv@jvosburgh.net, andrew+netdev@lunn.ch, davem@davemloft.net,
 edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, ast@kernel.org,
 daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com,
 sdf@fomichev.me, netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
 bpf@vger.kernel.org
X-In-Reply-To: <20261113-bond_enslave_restruct-v1-6-364c549e78db@kylinos.cn>
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