bonding: fix xfrm offload feature setup on active-backup mode
Subsystems (4)
PATCH v3 1/2 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.
---
v3: rebase to latest net, no code update
v2: rebase to latest net, no code update
--- drivers/net/bonding/bond_main.c | 2 +- drivers/net/bonding/bond_netlink.c | 16 +++++++++------- include/net/bonding.h | 1 + 3 files changed, 11 insertions(+), 8 deletions(-)
drivers/net/bonding/bond_main.c +1 -1
@@ -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);
drivers/net/bonding/bond_netlink.c +9 -7
@@ -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;
include/net/bonding.h +1 -0
@@ -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);
Signature · 1 line
2.50.1
PATCH v3 2/2 selftests: bonding: add ipsec offload test
This introduces a test for IPSec offload over bonding, utilizing netdevsim for the testing process, as veth interfaces do not support IPSec offload. The test will ensure that the IPSec offload functionality remains operational even after a failover event occurs in the bonding configuration.
Here is the test result:
TEST: bond_ipsec_offload (active_slave eth0) [ OK ]
TEST: bond_ipsec_offload (active_slave eth1) [ OK ]
---
v3: fix shellcheck errors
v2: rebase to latest net, no code update
--- .../selftests/drivers/net/bonding/Makefile | 3 +- .../drivers/net/bonding/bond_ipsec_offload.sh | 156 ++++++++++++++++++ .../selftests/drivers/net/bonding/config | 4 + 3 files changed, 162 insertions(+), 1 deletion(-) create mode 100755 tools/testing/selftests/drivers/net/bonding/bond_ipsec_offload.sh
tools/testing/selftests/drivers/net/bonding/Makefile +2 -1
@@ -11,7 +11,8 @@ TEST_PROGS := \ bond_options.sh \ bond-eth-type-change.sh \ bond_macvlan_ipvlan.sh \ - bond_passive_lacp.sh + bond_passive_lacp.sh \ + bond_ipsec_offload.sh TEST_FILES := \ lag_lib.sh \
tools/testing/selftests/drivers/net/bonding/bond_ipsec_offload.sh new file +156 -0
156 lines not on this page · raw message
tools/testing/selftests/drivers/net/bonding/config +4 -0
@@ -11,3 +11,7 @@ CONFIG_NET_SCH_INGRESS=y CONFIG_NLMON=y CONFIG_VETH=y CONFIG_VLAN_8021Q=m +CONFIG_INET_ESP=y +CONFIG_INET_ESP_OFFLOAD=y +CONFIG_XFRM_USER=m +CONFIG_NETDEVSIM=m
Signature · 1 line
2.50.1
Re: [PATCHv3 net 2/2] selftests: bonding: add ipsec offload test: manual merge
Hello,
Quoted 27 lines · Hangbin Liu
This introduces a test for IPSec offload over bonding, utilizing netdevsim for the testing process, as veth interfaces do not support IPSec offload. The test will ensure that the IPSec offload functionality remains operational even after a failover event occurs in the bonding configuration.
Here is the test result:
TEST:
bond_ipsec_offload(active_slaveeth0) [ OK ]
TEST:bond_ipsec_offload(active_slaveeth1) [ OK ]Reviewed-by Petr Machata <[email protected]>Signed-off-by Hangbin Liu <[email protected]>---
v3: fix shellcheck errors
v2: rebase to latest net, no code update--- .../selftests/drivers/net/bonding/Makefile | 3 +- .../drivers/net/bonding/bond_ipsec_offload.sh | 156 ++++++++++++++++++ .../selftests/drivers/net/bonding/config | 4 + 3 files changed, 162 insertions(+), 1 deletion(-) create mode 100755 tools/testing/selftests/drivers/net/bonding/bond_ipsec_offload.shtools/testing/selftests/drivers/net/bonding/Makefile +0
-0
tools/testing/selftests/drivers/net/bonding/Makefile TEST_PROGS := \ · line 15
Quoted 6 lines
tools/testing/selftests/drivers/net/bonding/Makefile +2
-1@@ -11,7 +11,8 @@ TEST_PROGS := \ bond_options.sh \ bond-eth-type-change.sh \ bond_macvlan_ipvlan.sh \ - bond_passive_lacp.sh + bond_passive_lacp.sh \ + bond_ipsec_offload.sh
FYI, we got a small conflict when merging 'net' in 'net-next' in the MPTCP tree due to this patch applied in 'net':
99e4c35eada9 ("selftests: bonding: add ipsec offload test")
and this one from 'net-next':
c2377f1763e9 ("selftests: bonding: add test for LACP actor port priority")
----- Generic Message -----
The best is to avoid conflicts between 'net' and 'net-next' trees but if they cannot be avoided when preparing patches, a note about how to fix them is much appreciated.
The conflict has been resolved on our side [1] and the resolution we suggest is attached to this email. Please report any issues linked to this conflict resolution as it might be used by others. If you worked on the mentioned patches, don't hesitate to ACK this conflict resolution.
---------------------------
Regarding this conflict, I simply added the new files from both trees:
bond_passive_lacp.sh \ bond_ipsec_offload.sh \ bond_lacp_prio.sh
Note: A way to reduce such conflicts in the future is to sort each entry by alphabetical order instead of adding new ones at the end. Same in the 'config' file that is also modified in this patch.
Rerere cache is available in [2].
1: https://github.com/multipath-tcp/mptcp_net-next/commit/f6c62892b853
2: https://github.com/multipath-tcp/mptcp-upstream-rr-cache/commit/65a75
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
tools/testing/selftests/drivers/net/bonding/Makefile +0 -0
@@@ -12,7 -12,7 +12,8 @@@ TEST_PROGS := bond-eth-type-change.sh \ bond_macvlan_ipvlan.sh \ bond_passive_lacp.sh \ - bond_ipsec_offload.sh ++ bond_ipsec_offload.sh \ + bond_lacp_prio.sh TEST_FILES := \ lag_lib.sh \
Re: [PATCHv3 net 2/2] selftests: bonding: add ipsec offload test: manual merge
Quoted 3 lines · Matthieu Baerts
Note: A way to reduce such conflicts in the future is to sort each entry by alphabetical order instead of adding new ones at the end. Same in the 'config' file that is also modified in this patch.
Thanks for the suggestion. I will update Makefile and config to use alphabet order next time.
Regards
Hangbin
This series was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:
Quoted 9 lines · On Thu, 25 Sep 2025 02:33:03 +0000 you wrote:
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, theethtool -kcommand shows that the XFRM ESP offload is disabled. This occurs because, inbond_newlink(), we change bond link first and register bond device later. So the XFRM feature update inbond_option_mode_set()is not called as the bond device is not yet registered, leading to the offload feature not being set successfully.[...]
Here is the summary with links:
- [PATCHv3,net,1/2] bonding: fix xfrm offload feature setup on active-backup mode
https://git.kernel.org/netdev/net/c/5b66169f6be4 - [PATCHv3,net,2/2] selftests: bonding: add ipsec offload test https://git.kernel.org/netdev/net/c/99e4c35eada9
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html