Skip to content

Commit 5b66169

Browse files
liuhangbinPaolo Abeni
authored andcommitted
bonding: fix xfrm offload feature setup on active-backup mode
The active-backup bonding mode supports XFRM ESP offload. However, when a bond is added using command like `ip link add bond0 type bond mode 1 miimon 100`, the `ethtool -k` command shows that the XFRM ESP offload is disabled. This occurs because, in bond_newlink(), we change bond link first and register bond device later. So the XFRM feature update in bond_option_mode_set() is not called as the bond device is not yet registered, leading to the offload feature not being set successfully. To resolve this issue, we can modify the code order in bond_newlink() to ensure that the bond device is registered first before changing the bond link parameters. This change will allow the XFRM ESP offload feature to be correctly enabled. Fixes: 007ab53 ("bonding: fix feature flag setting at init time") Signed-off-by: Hangbin Liu <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent eb11f02 commit 5b66169

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

drivers/net/bonding/bond_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4411,7 +4411,7 @@ void bond_work_init_all(struct bonding *bond)
44114411
INIT_DELAYED_WORK(&bond->slave_arr_work, bond_slave_arr_handler);
44124412
}
44134413

4414-
static void bond_work_cancel_all(struct bonding *bond)
4414+
void bond_work_cancel_all(struct bonding *bond)
44154415
{
44164416
cancel_delayed_work_sync(&bond->mii_work);
44174417
cancel_delayed_work_sync(&bond->arp_work);

drivers/net/bonding/bond_netlink.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -579,20 +579,22 @@ static int bond_newlink(struct net_device *bond_dev,
579579
struct rtnl_newlink_params *params,
580580
struct netlink_ext_ack *extack)
581581
{
582+
struct bonding *bond = netdev_priv(bond_dev);
582583
struct nlattr **data = params->data;
583584
struct nlattr **tb = params->tb;
584585
int err;
585586

586-
err = bond_changelink(bond_dev, tb, data, extack);
587-
if (err < 0)
587+
err = register_netdevice(bond_dev);
588+
if (err)
588589
return err;
589590

590-
err = register_netdevice(bond_dev);
591-
if (!err) {
592-
struct bonding *bond = netdev_priv(bond_dev);
591+
netif_carrier_off(bond_dev);
592+
bond_work_init_all(bond);
593593

594-
netif_carrier_off(bond_dev);
595-
bond_work_init_all(bond);
594+
err = bond_changelink(bond_dev, tb, data, extack);
595+
if (err) {
596+
bond_work_cancel_all(bond);
597+
unregister_netdevice(bond_dev);
596598
}
597599

598600
return err;

include/net/bonding.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,7 @@ struct bond_vlan_tag *bond_verify_device_path(struct net_device *start_dev,
711711
int bond_update_slave_arr(struct bonding *bond, struct slave *skipslave);
712712
void bond_slave_arr_work_rearm(struct bonding *bond, unsigned long delay);
713713
void bond_work_init_all(struct bonding *bond);
714+
void bond_work_cancel_all(struct bonding *bond);
714715

715716
#ifdef CONFIG_PROC_FS
716717
void bond_create_proc_entry(struct bonding *bond);

0 commit comments

Comments
 (0)