mlx5en: Fix TLS worker thread race.
Create a dedicated free state, in case the taskqueue worker is still pending, to avoid re-activation of a freed send tag. MFC after: 1 week Sponsored by: NVIDIA Networking
This commit is contained in:
parent
ebdb700649
commit
015f22f5d0
@ -55,7 +55,8 @@ struct mlx5e_tls_tag {
|
||||
#define MLX5E_TLS_ST_INIT 0
|
||||
#define MLX5E_TLS_ST_SETUP 1
|
||||
#define MLX5E_TLS_ST_TXRDY 2
|
||||
#define MLX5E_TLS_ST_FREED 3
|
||||
#define MLX5E_TLS_ST_RELEASE 3
|
||||
#define MLX5E_TLS_ST_FREED 4
|
||||
struct work_struct work;
|
||||
|
||||
uint32_t dek_index_ok:1;
|
||||
|
@ -70,7 +70,8 @@ struct mlx5e_tls_rx_tag {
|
||||
#define MLX5E_TLS_RX_ST_INIT 0
|
||||
#define MLX5E_TLS_RX_ST_SETUP 1
|
||||
#define MLX5E_TLS_RX_ST_READY 2
|
||||
#define MLX5E_TLS_RX_ST_FREED 3
|
||||
#define MLX5E_TLS_RX_ST_RELEASE 3
|
||||
#define MLX5E_TLS_RX_ST_FREED 4
|
||||
|
||||
/*
|
||||
* The following fields are used to store the TCP starting
|
||||
|
@ -127,9 +127,10 @@ mlx5e_tls_tag_release(void *arg, void **store, int cnt)
|
||||
static void
|
||||
mlx5e_tls_tag_zfree(struct mlx5e_tls_tag *ptag)
|
||||
{
|
||||
/* make sure any unhandled taskqueue events are ignored */
|
||||
ptag->state = MLX5E_TLS_ST_FREED;
|
||||
|
||||
/* reset some variables */
|
||||
ptag->state = MLX5E_TLS_ST_INIT;
|
||||
ptag->dek_index = 0;
|
||||
ptag->dek_index_ok = 0;
|
||||
|
||||
@ -256,7 +257,7 @@ mlx5e_tls_work(struct work_struct *work)
|
||||
MLX5E_TLS_TAG_UNLOCK(ptag);
|
||||
break;
|
||||
|
||||
case MLX5E_TLS_ST_FREED:
|
||||
case MLX5E_TLS_ST_RELEASE:
|
||||
/* try to destroy DEK context by ID */
|
||||
if (ptag->dek_index_ok)
|
||||
err = mlx5_encryption_key_destroy(priv->mdev, ptag->dek_index);
|
||||
@ -330,7 +331,6 @@ mlx5e_tls_snd_tag_alloc(struct ifnet *ifp,
|
||||
return (ENOMEM);
|
||||
|
||||
/* sanity check default values */
|
||||
MPASS(ptag->state == MLX5E_TLS_ST_INIT);
|
||||
MPASS(ptag->dek_index == 0);
|
||||
MPASS(ptag->dek_index_ok == 0);
|
||||
|
||||
@ -438,6 +438,9 @@ mlx5e_tls_snd_tag_alloc(struct ifnet *ifp,
|
||||
m_snd_tag_init(&ptag->tag, ifp, snd_tag_sw);
|
||||
*ppmt = &ptag->tag;
|
||||
|
||||
/* reset state */
|
||||
ptag->state = MLX5E_TLS_ST_INIT;
|
||||
|
||||
queue_work(priv->tls.wq, &ptag->work);
|
||||
flush_work(&ptag->work);
|
||||
|
||||
@ -483,7 +486,7 @@ mlx5e_tls_snd_tag_free(struct m_snd_tag *pmt)
|
||||
m_snd_tag_rele(ptag->rl_tag);
|
||||
|
||||
MLX5E_TLS_TAG_LOCK(ptag);
|
||||
ptag->state = MLX5E_TLS_ST_FREED;
|
||||
ptag->state = MLX5E_TLS_ST_RELEASE;
|
||||
MLX5E_TLS_TAG_UNLOCK(ptag);
|
||||
|
||||
priv = ptag->tag.ifp->if_softc;
|
||||
|
@ -427,8 +427,10 @@ mlx5e_tls_rx_tag_release(void *arg, void **store, int cnt)
|
||||
static void
|
||||
mlx5e_tls_rx_tag_zfree(struct mlx5e_tls_rx_tag *ptag)
|
||||
{
|
||||
/* make sure any unhandled taskqueue events are ignored */
|
||||
ptag->state = MLX5E_TLS_RX_ST_FREED;
|
||||
|
||||
/* reset some variables */
|
||||
ptag->state = MLX5E_TLS_RX_ST_INIT;
|
||||
ptag->dek_index = 0;
|
||||
ptag->dek_index_ok = 0;
|
||||
ptag->tirn = 0;
|
||||
@ -569,7 +571,7 @@ mlx5e_tls_rx_work(struct work_struct *work)
|
||||
MLX5E_TLS_RX_TAG_UNLOCK(ptag);
|
||||
break;
|
||||
|
||||
case MLX5E_TLS_RX_ST_FREED:
|
||||
case MLX5E_TLS_RX_ST_RELEASE:
|
||||
/* remove flow rule for incoming traffic, if any */
|
||||
if (ptag->flow_rule != NULL)
|
||||
mlx5e_accel_fs_del_inpcb(ptag->flow_rule);
|
||||
@ -676,7 +678,6 @@ mlx5e_tls_rx_snd_tag_alloc(struct ifnet *ifp,
|
||||
return (ENOMEM);
|
||||
|
||||
/* sanity check default values */
|
||||
MPASS(ptag->state == MLX5E_TLS_RX_ST_INIT);
|
||||
MPASS(ptag->dek_index == 0);
|
||||
MPASS(ptag->dek_index_ok == 0);
|
||||
|
||||
@ -760,6 +761,9 @@ mlx5e_tls_rx_snd_tag_alloc(struct ifnet *ifp,
|
||||
m_snd_tag_init(&ptag->tag, ifp, &mlx5e_tls_rx_snd_tag_sw);
|
||||
*ppmt = &ptag->tag;
|
||||
|
||||
/* reset state */
|
||||
ptag->state = MLX5E_TLS_RX_ST_INIT;
|
||||
|
||||
queue_work(priv->tls_rx.wq, &ptag->work);
|
||||
flush_work(&ptag->work);
|
||||
|
||||
@ -989,7 +993,7 @@ mlx5e_tls_rx_snd_tag_free(struct m_snd_tag *pmt)
|
||||
struct mlx5e_priv *priv;
|
||||
|
||||
MLX5E_TLS_RX_TAG_LOCK(ptag);
|
||||
ptag->state = MLX5E_TLS_RX_ST_FREED;
|
||||
ptag->state = MLX5E_TLS_RX_ST_RELEASE;
|
||||
MLX5E_TLS_RX_TAG_UNLOCK(ptag);
|
||||
|
||||
priv = ptag->tag.ifp->if_softc;
|
||||
|
Loading…
Reference in New Issue
Block a user