net/mlx5e: Drop XFRM state lock when modifying flow steering
authorLeon Romanovsky <leonro@nvidia.com>
Mon, 5 Jun 2023 08:09:51 +0000 (11:09 +0300)
committerSaeed Mahameed <saeedm@nvidia.com>
Fri, 16 Jun 2023 19:59:20 +0000 (12:59 -0700)
XFRM state which is changed to be XFRM_STATE_EXPIRED doesn't really
need to hold lock while modifying flow steering rules to drop traffic.

That state can be deleted only and as such mlx5e_ipsec_handle_tx_limit()
work will be canceled anyway and won't run in parallel.

Fixes: b2f7b01d36a9 ("net/mlx5e: Simulate missing IPsec TX limits hardware functionality")
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c

index d1c801723d35aeb478ee9d6a93b71b7b0bdd0343..891d39b4bfd4f77fc68357990ce36ecf54cb1ff4 100644 (file)
@@ -61,16 +61,19 @@ static void mlx5e_ipsec_handle_tx_limit(struct work_struct *_work)
        struct mlx5e_ipsec_sa_entry *sa_entry = dwork->sa_entry;
        struct xfrm_state *x = sa_entry->x;
 
-       spin_lock(&x->lock);
+       if (sa_entry->attrs.drop)
+               return;
+
+       spin_lock_bh(&x->lock);
        xfrm_state_check_expire(x);
        if (x->km.state == XFRM_STATE_EXPIRED) {
                sa_entry->attrs.drop = true;
-               mlx5e_accel_ipsec_fs_modify(sa_entry);
-       }
-       spin_unlock(&x->lock);
+               spin_unlock_bh(&x->lock);
 
-       if (sa_entry->attrs.drop)
+               mlx5e_accel_ipsec_fs_modify(sa_entry);
                return;
+       }
+       spin_unlock_bh(&x->lock);
 
        queue_delayed_work(sa_entry->ipsec->wq, &dwork->dwork,
                           MLX5_IPSEC_RESCHED);