Skip to content

Commit 3f10b14

Browse files
committed
Merge: bonding: check xdp prog when set bond mode
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/1042 JIRA: https://issues.redhat.com/browse/RHEL-96600 Fixes a warning when set xdp program with unsupported bond mode. Signed-off-by: Hangbin Liu <haliu@redhat.com> Approved-by: Xin Long <lxin@redhat.com> Merged-by: Julio Faracco <jfaracco@redhat.com>
2 parents 82a4124 + 07f780f commit 3f10b14

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

drivers/net/bonding/bond_main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,9 @@ static bool bond_sk_check(struct bonding *bond)
322322
}
323323
}
324324

325-
static bool bond_xdp_check(struct bonding *bond)
325+
bool bond_xdp_check(struct bonding *bond, int mode)
326326
{
327-
switch (BOND_MODE(bond)) {
327+
switch (mode) {
328328
case BOND_MODE_ROUNDROBIN:
329329
case BOND_MODE_ACTIVEBACKUP:
330330
return true;
@@ -1925,7 +1925,7 @@ void bond_xdp_set_features(struct net_device *bond_dev)
19251925

19261926
ASSERT_RTNL();
19271927

1928-
if (!bond_xdp_check(bond) || !bond_has_slaves(bond)) {
1928+
if (!bond_xdp_check(bond, BOND_MODE(bond)) || !bond_has_slaves(bond)) {
19291929
xdp_clear_features_flag(bond_dev);
19301930
return;
19311931
}
@@ -5698,7 +5698,7 @@ static int bond_xdp_set(struct net_device *dev, struct bpf_prog *prog,
56985698

56995699
ASSERT_RTNL();
57005700

5701-
if (!bond_xdp_check(bond)) {
5701+
if (!bond_xdp_check(bond, BOND_MODE(bond))) {
57025702
BOND_NL_ERR(dev, extack,
57035703
"No native XDP support for the current bonding mode");
57045704
return -EOPNOTSUPP;

drivers/net/bonding/bond_options.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,9 @@ static bool bond_set_xfrm_features(struct bonding *bond)
868868
static int bond_option_mode_set(struct bonding *bond,
869869
const struct bond_opt_value *newval)
870870
{
871+
if (bond->xdp_prog && !bond_xdp_check(bond, newval->value))
872+
return -EOPNOTSUPP;
873+
871874
if (!bond_mode_uses_arp(newval->value)) {
872875
if (bond->params.arp_interval) {
873876
netdev_dbg(bond->dev, "%s mode is incompatible with arp monitoring, start mii monitoring\n",

include/net/bonding.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,7 @@ void bond_debug_register(struct bonding *bond);
695695
void bond_debug_unregister(struct bonding *bond);
696696
void bond_debug_reregister(struct bonding *bond);
697697
const char *bond_mode_name(int mode);
698+
bool bond_xdp_check(struct bonding *bond, int mode);
698699
void bond_setup(struct net_device *bond_dev);
699700
unsigned int bond_get_num_tx_queues(void);
700701
int bond_netlink_init(void);

0 commit comments

Comments
 (0)