Skip to content

Commit 7565c39

Browse files
author
Paolo Abeni
committed
Merge branch 'bonding-fix-xfrm-offload-bugs'
Nikolay Aleksandrov says: ==================== bonding: fix xfrm offload bugs I noticed these problems while reviewing a bond xfrm patch recently. The fixes are straight-forward, please review carefully the last one because it has side-effects. This set has passed bond's selftests and my custom bond stress tests which crash without these fixes. Note the first patch is not critical, but it simplifies the next fix. ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents 4b3e33f + c4c5c5d commit 7565c39

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

drivers/net/bonding/bond_main.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,6 @@ static void bond_ipsec_del_sa_all(struct bonding *bond)
582582
} else {
583583
slave->dev->xfrmdev_ops->xdo_dev_state_delete(ipsec->xs);
584584
}
585-
ipsec->xs->xso.real_dev = NULL;
586585
}
587586
spin_unlock_bh(&bond->ipsec_lock);
588587
rcu_read_unlock();
@@ -599,34 +598,30 @@ static bool bond_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *xs)
599598
struct net_device *real_dev;
600599
struct slave *curr_active;
601600
struct bonding *bond;
602-
int err;
601+
bool ok = false;
603602

604603
bond = netdev_priv(bond_dev);
605604
rcu_read_lock();
606605
curr_active = rcu_dereference(bond->curr_active_slave);
606+
if (!curr_active)
607+
goto out;
607608
real_dev = curr_active->dev;
608609

609-
if (BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) {
610-
err = false;
610+
if (BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP)
611611
goto out;
612-
}
613612

614-
if (!xs->xso.real_dev) {
615-
err = false;
613+
if (!xs->xso.real_dev)
616614
goto out;
617-
}
618615

619616
if (!real_dev->xfrmdev_ops ||
620617
!real_dev->xfrmdev_ops->xdo_dev_offload_ok ||
621-
netif_is_bond_master(real_dev)) {
622-
err = false;
618+
netif_is_bond_master(real_dev))
623619
goto out;
624-
}
625620

626-
err = real_dev->xfrmdev_ops->xdo_dev_offload_ok(skb, xs);
621+
ok = real_dev->xfrmdev_ops->xdo_dev_offload_ok(skb, xs);
627622
out:
628623
rcu_read_unlock();
629-
return err;
624+
return ok;
630625
}
631626

632627
static const struct xfrmdev_ops bond_xfrmdev_ops = {

drivers/net/bonding/bond_options.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ static int bond_option_active_slave_set(struct bonding *bond,
936936
/* check to see if we are clearing active */
937937
if (!slave_dev) {
938938
netdev_dbg(bond->dev, "Clearing current active slave\n");
939-
RCU_INIT_POINTER(bond->curr_active_slave, NULL);
939+
bond_change_active_slave(bond, NULL);
940940
bond_select_active_slave(bond);
941941
} else {
942942
struct slave *old_active = rtnl_dereference(bond->curr_active_slave);

0 commit comments

Comments
 (0)