BPF List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: hangbin.liu@linux.dev
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
Subject: Re: [PATCH net-next 6/6] bonding: factor out bond_enslave_validate
Date: Tue, 17 Nov 2026 14:40:13 +0000	[thread overview]
Message-ID: <179492641344.3136.5360540192397591551@kernel.org> (raw)
In-Reply-To: <20261113-bond_enslave_restruct-v1-6-364c549e78db@kylinos.cn>

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

  reply	other threads:[~2026-11-17 14:40 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 14:04 [PATCH net-next 0/6] bonding: refactor bond_enslave() to fix XDP ordering and error rollback Hangbin Liu
2026-11-13 14:04 ` [PATCH net-next 1/6] bonding: check XDP support before enslaving changes state Hangbin Liu
2026-11-14 14:06   ` sashiko-bot
2026-11-17 14:40   ` netdev-bot+sashiko
2026-11-13 14:04 ` [PATCH net-next 2/6] bonding: finish XDP setup before publishing the slave Hangbin Liu
2026-11-14 14:06   ` sashiko-bot
2026-11-17 14:40   ` netdev-bot+sashiko
2026-11-13 14:04 ` [PATCH net-next 3/6] bonding: complete rollback of bond_enslave() error paths Hangbin Liu
2026-11-14 14:06   ` sashiko-bot
2026-11-17  5:30     ` Hangbin Liu
2026-11-17 14:40   ` netdev-bot+sashiko
2026-11-13 14:04 ` [PATCH net-next 4/6] bonding: factor out slave publication Hangbin Liu
2026-11-17 14:40   ` netdev-bot+sashiko
2026-11-13 14:04 ` [PATCH net-next 5/6] bonding: factor out XDP slave check Hangbin Liu
2026-11-13 14:04 ` [PATCH net-next 6/6] bonding: factor out bond_enslave_validate Hangbin Liu
2026-11-17 14:40   ` netdev-bot+sashiko [this message]
2026-11-13 14:11 ` [PATCH net-next 0/6] bonding: refactor bond_enslave() to fix XDP ordering and error rollback netdev-bot+sinfo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179492641344.3136.5360540192397591551@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=hangbin.liu@linux.dev \
    --cc=hawk@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=jv@jvosburgh.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox