Skip to content

Commit cb9e6e5

Browse files
LorenzoBianconidavem330
authored andcommitted
bonding: add xdp_features support
Introduce xdp_features support for bonding driver according to the slave devices attached to the master one. xdp_features is required whenever we want to xdp_redirect traffic into a bond device and then into selected slaves attached to it. Reviewed-by: Simon Horman <simon.horman@corigine.com> Acked-by: Jay Vosburgh <jay.vosburgh@canonical.com> Fixes: 66c0e13 ("drivers: net: turn on XDP features") Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Reviewed-by: Jussi Maki <joamaki@gmail.com> Tested-by: Jussi Maki <joamaki@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent d7385ba commit cb9e6e5

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

drivers/net/bonding/bond_main.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,6 +1789,26 @@ static void bond_ether_setup(struct net_device *bond_dev)
17891789
bond_dev->priv_flags &= ~IFF_TX_SKB_SHARING;
17901790
}
17911791

1792+
void bond_xdp_set_features(struct net_device *bond_dev)
1793+
{
1794+
struct bonding *bond = netdev_priv(bond_dev);
1795+
xdp_features_t val = NETDEV_XDP_ACT_MASK;
1796+
struct list_head *iter;
1797+
struct slave *slave;
1798+
1799+
ASSERT_RTNL();
1800+
1801+
if (!bond_xdp_check(bond)) {
1802+
xdp_clear_features_flag(bond_dev);
1803+
return;
1804+
}
1805+
1806+
bond_for_each_slave(bond, slave, iter)
1807+
val &= slave->dev->xdp_features;
1808+
1809+
xdp_set_features_flag(bond_dev, val);
1810+
}
1811+
17921812
/* enslave device <slave> to bond device <master> */
17931813
int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
17941814
struct netlink_ext_ack *extack)
@@ -2236,6 +2256,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
22362256
bpf_prog_inc(bond->xdp_prog);
22372257
}
22382258

2259+
bond_xdp_set_features(bond_dev);
2260+
22392261
slave_info(bond_dev, slave_dev, "Enslaving as %s interface with %s link\n",
22402262
bond_is_active_slave(new_slave) ? "an active" : "a backup",
22412263
new_slave->link != BOND_LINK_DOWN ? "an up" : "a down");
@@ -2483,6 +2505,7 @@ static int __bond_release_one(struct net_device *bond_dev,
24832505
if (!netif_is_bond_master(slave_dev))
24842506
slave_dev->priv_flags &= ~IFF_BONDING;
24852507

2508+
bond_xdp_set_features(bond_dev);
24862509
kobject_put(&slave->kobj);
24872510

24882511
return 0;
@@ -3930,6 +3953,9 @@ static int bond_slave_netdev_event(unsigned long event,
39303953
/* Propagate to master device */
39313954
call_netdevice_notifiers(event, slave->bond->dev);
39323955
break;
3956+
case NETDEV_XDP_FEAT_CHANGE:
3957+
bond_xdp_set_features(bond_dev);
3958+
break;
39333959
default:
39343960
break;
39353961
}
@@ -5874,6 +5900,9 @@ void bond_setup(struct net_device *bond_dev)
58745900
if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP)
58755901
bond_dev->features |= BOND_XFRM_FEATURES;
58765902
#endif /* CONFIG_XFRM_OFFLOAD */
5903+
5904+
if (bond_xdp_check(bond))
5905+
bond_dev->xdp_features = NETDEV_XDP_ACT_MASK;
58775906
}
58785907

58795908
/* Destroy a bonding device.

drivers/net/bonding/bond_options.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,8 @@ static int bond_option_mode_set(struct bonding *bond,
877877
netdev_update_features(bond->dev);
878878
}
879879

880+
bond_xdp_set_features(bond->dev);
881+
880882
return 0;
881883
}
882884

include/net/bonding.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,7 @@ void bond_destroy_sysfs(struct bond_net *net);
659659
void bond_prepare_sysfs_group(struct bonding *bond);
660660
int bond_sysfs_slave_add(struct slave *slave);
661661
void bond_sysfs_slave_del(struct slave *slave);
662+
void bond_xdp_set_features(struct net_device *bond_dev);
662663
int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
663664
struct netlink_ext_ack *extack);
664665
int bond_release(struct net_device *bond_dev, struct net_device *slave_dev);

0 commit comments

Comments
 (0)