Skip to content

Commit 6d5f1ef

Browse files
joamakidavem330
authored andcommitted
bonding: Fix negative jump label count on nested bonding
With nested bonding devices the nested bond device's ndo_bpf was called without a program causing it to decrement the static key without a prior increment leading to negative count. Fix the issue by 1) only calling slave's ndo_bpf when there's a program to be loaded and 2) only decrement the count when a program is unloaded. Fixes: 9e2ee5c ("net, bonding: Add XDP support to the bonding driver") Reported-by: [email protected] Signed-off-by: Jussi Maki <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e0b6417 commit 6d5f1ef

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

drivers/net/bonding/bond_main.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2169,7 +2169,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
21692169
res = -EOPNOTSUPP;
21702170
goto err_sysfs_del;
21712171
}
2172-
} else {
2172+
} else if (bond->xdp_prog) {
21732173
struct netdev_bpf xdp = {
21742174
.command = XDP_SETUP_PROG,
21752175
.flags = 0,
@@ -5224,13 +5224,12 @@ static int bond_xdp_set(struct net_device *dev, struct bpf_prog *prog,
52245224
bpf_prog_inc(prog);
52255225
}
52265226

5227-
if (old_prog)
5228-
bpf_prog_put(old_prog);
5229-
5230-
if (prog)
5227+
if (prog) {
52315228
static_branch_inc(&bpf_master_redirect_enabled_key);
5232-
else
5229+
} else if (old_prog) {
5230+
bpf_prog_put(old_prog);
52335231
static_branch_dec(&bpf_master_redirect_enabled_key);
5232+
}
52345233

52355234
return 0;
52365235

0 commit comments

Comments
 (0)