Subject: Re: [PATCH net V5 3/3] bonding: change ipsec_lock from spin lock to mutex

From: Jay Vosburgh <[email-masked]>
Date: Thu, 22 Aug 2024 17:17:57 -0700

Jianbo Liu <[email-masked]> wrote:

[...]
>I think it's good solution.
>So I need to add the dev_hold/dev_put as following, for example, for
>bond_ipsec_del_sa, right?
>
>@@ -526,6 +534,7 @@ static void bond_ipsec_del_sa(struct xfrm_state *xs)
>        bond = netdev_priv(bond_dev);
>        slave = rcu_dereference(bond->curr_active_slave);
>        real_dev = slave ? slave->dev : NULL;
>+       dev_hold(real_dev);
>        rcu_read_unlock();
>
>        if (!slave)
>@@ -545,6 +554,7 @@ static void bond_ipsec_del_sa(struct xfrm_state *xs)
>
>        real_dev->xfrmdev_ops->xdo_dev_state_delete(xs);
> out:
>+       dev_put(real_dev);
>        mutex_lock(&bond->ipsec_lock);
>        list_for_each_entry(ipsec, &bond->ipsec_list, list) {
>                if (ipsec->xs == xs) {
>
>If you are ok with that, I will add the same for
>bond_ipsec_add_sa/bond_ipsec_free_sa, and send new version.

	Yes, I think that will work, but please use netdev_hold() as
Jakub requested.

	-J

---
	-Jay Vosburgh, [email-masked]