]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
bonding: fix xfrm offload feature setup on active-backup mode
authorHangbin Liu <liuhangbin@gmail.com>
Thu, 25 Sep 2025 02:33:03 +0000 (02:33 +0000)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 30 Sep 2025 07:55:11 +0000 (09:55 +0200)
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: 007ab5345545 ("bonding: fix feature flag setting at init time")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Link: https://patch.msgid.link/20250925023304.472186-1-liuhangbin@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/bonding/bond_main.c
drivers/net/bonding/bond_netlink.c
include/net/bonding.h

index 57be04f6cb11a89382debbf05b71541ac4911820..f4f0feddd9fa0839d19a3dcdc6d15875e331e824 100644 (file)
@@ -4411,7 +4411,7 @@ void bond_work_init_all(struct bonding *bond)
        INIT_DELAYED_WORK(&bond->slave_arr_work, bond_slave_arr_handler);
 }
 
-static void bond_work_cancel_all(struct bonding *bond)
+void bond_work_cancel_all(struct bonding *bond)
 {
        cancel_delayed_work_sync(&bond->mii_work);
        cancel_delayed_work_sync(&bond->arp_work);
index 57fff2421f1b587de3dfb535867b31091b0c8940..7a9d73ec8e91cd1d49bbc406b055070c4b61b446 100644 (file)
@@ -579,20 +579,22 @@ static int bond_newlink(struct net_device *bond_dev,
                        struct rtnl_newlink_params *params,
                        struct netlink_ext_ack *extack)
 {
+       struct bonding *bond = netdev_priv(bond_dev);
        struct nlattr **data = params->data;
        struct nlattr **tb = params->tb;
        int err;
 
-       err = bond_changelink(bond_dev, tb, data, extack);
-       if (err < 0)
+       err = register_netdevice(bond_dev);
+       if (err)
                return err;
 
-       err = register_netdevice(bond_dev);
-       if (!err) {
-               struct bonding *bond = netdev_priv(bond_dev);
+       netif_carrier_off(bond_dev);
+       bond_work_init_all(bond);
 
-               netif_carrier_off(bond_dev);
-               bond_work_init_all(bond);
+       err = bond_changelink(bond_dev, tb, data, extack);
+       if (err) {
+               bond_work_cancel_all(bond);
+               unregister_netdevice(bond_dev);
        }
 
        return err;
index e06f0d63b2c176ffe569d0ff2879a19eb39005ef..bd56ad976cfb021e5a06b0afacec0e3974e737ec 100644 (file)
@@ -711,6 +711,7 @@ struct bond_vlan_tag *bond_verify_device_path(struct net_device *start_dev,
 int bond_update_slave_arr(struct bonding *bond, struct slave *skipslave);
 void bond_slave_arr_work_rearm(struct bonding *bond, unsigned long delay);
 void bond_work_init_all(struct bonding *bond);
+void bond_work_cancel_all(struct bonding *bond);
 
 #ifdef CONFIG_PROC_FS
 void bond_create_proc_entry(struct bonding *bond);