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