@@ -581,6 +581,8 @@ static void bond_ipsec_del_sa_all(struct bonding *bond)
__func__);
} else {
slave->dev->xfrmdev_ops->xdo_dev_state_delete(ipsec->xs);
+ if (slave->dev->xfrmdev_ops->xdo_dev_state_free)
+ slave->dev->xfrmdev_ops->xdo_dev_state_free(ipsec->xs);
}
ipsec->xs->xso.real_dev = NULL;
}
@@ -588,6 +590,33 @@ static void bond_ipsec_del_sa_all(struct bonding *bond)
rcu_read_unlock();
}
+static void bond_ipsec_free_sa(struct xfrm_state *xs)
+{
+ struct net_device *bond_dev = xs->xso.dev;
+ struct net_device *real_dev;
+ struct bonding *bond;
+ struct slave *slave;
+
+ if (!bond_dev)
+ return;
+
+ bond = netdev_priv(bond_dev);
+ slave = rcu_dereference(bond->curr_active_slave);
+ real_dev = slave ? slave->dev : NULL;
+
+ if (!slave)
+ return;
+
+ if (!xs->xso.real_dev)
+ return;
+
+ WARN_ON(xs->xso.real_dev != real_dev);
+
+ if (real_dev && real_dev->xfrmdev_ops &&
+ real_dev->xfrmdev_ops->xdo_dev_state_free)
+ real_dev->xfrmdev_ops->xdo_dev_state_free(xs);
+}
+
/**
* bond_ipsec_offload_ok - can this packet use the xfrm hw offload
* @skb: current data packet
@@ -632,6 +661,7 @@ static bool bond_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *xs)
static const struct xfrmdev_ops bond_xfrmdev_ops = {
.xdo_dev_state_add = bond_ipsec_add_sa,
.xdo_dev_state_delete = bond_ipsec_del_sa,
+ .xdo_dev_state_free = bond_ipsec_free_sa,
.xdo_dev_offload_ok = bond_ipsec_offload_ok,
};
#endif /* CONFIG_XFRM_OFFLOAD */