Skip to content

Commit 40338d7

Browse files
josh8551021davem330
authored andcommitted
gve: guard XSK operations on the existence of queues
This patch predicates the enabling and disabling of XSK pools on the existence of queues. As it stands, if the interface is down, disabling or enabling XSK pools would result in a crash, as the RX queue pointer would be NULL. XSK pool registration will occur as part of the next interface up. Similarly, xsk_wakeup needs be guarded against queues disappearing while the function is executing, so a check against the GVE_PRIV_FLAGS_NAPI_ENABLED flag is added to synchronize with the disabling of the bit and the synchronize_net() in gve_turndown. Fixes: fd8e403 ("gve: Add AF_XDP zero-copy support for GQI-QPL format") Cc: [email protected] Signed-off-by: Joshua Washington <[email protected]> Signed-off-by: Praveen Kaligineedi <[email protected]> Reviewed-by: Praveen Kaligineedi <[email protected]> Reviewed-by: Shailend Chand <[email protected]> Reviewed-by: Willem de Bruijn <[email protected]> Reviewed-by: Larysa Zaremba <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ff7c2de commit 40338d7

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

drivers/net/ethernet/google/gve/gve_main.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,8 +1623,8 @@ static int gve_xsk_pool_enable(struct net_device *dev,
16231623
if (err)
16241624
return err;
16251625

1626-
/* If XDP prog is not installed, return */
1627-
if (!priv->xdp_prog)
1626+
/* If XDP prog is not installed or interface is down, return. */
1627+
if (!priv->xdp_prog || !netif_running(dev))
16281628
return 0;
16291629

16301630
rx = &priv->rx[qid];
@@ -1669,21 +1669,16 @@ static int gve_xsk_pool_disable(struct net_device *dev,
16691669
if (qid >= priv->rx_cfg.num_queues)
16701670
return -EINVAL;
16711671

1672-
/* If XDP prog is not installed, unmap DMA and return */
1673-
if (!priv->xdp_prog)
1672+
/* If XDP prog is not installed or interface is down, unmap DMA and
1673+
* return.
1674+
*/
1675+
if (!priv->xdp_prog || !netif_running(dev))
16741676
goto done;
16751677

1676-
tx_qid = gve_xdp_tx_queue_id(priv, qid);
1677-
if (!netif_running(dev)) {
1678-
priv->rx[qid].xsk_pool = NULL;
1679-
xdp_rxq_info_unreg(&priv->rx[qid].xsk_rxq);
1680-
priv->tx[tx_qid].xsk_pool = NULL;
1681-
goto done;
1682-
}
1683-
16841678
napi_rx = &priv->ntfy_blocks[priv->rx[qid].ntfy_id].napi;
16851679
napi_disable(napi_rx); /* make sure current rx poll is done */
16861680

1681+
tx_qid = gve_xdp_tx_queue_id(priv, qid);
16871682
napi_tx = &priv->ntfy_blocks[priv->tx[tx_qid].ntfy_id].napi;
16881683
napi_disable(napi_tx); /* make sure current tx poll is done */
16891684

@@ -1711,6 +1706,9 @@ static int gve_xsk_wakeup(struct net_device *dev, u32 queue_id, u32 flags)
17111706
struct gve_priv *priv = netdev_priv(dev);
17121707
int tx_queue_id = gve_xdp_tx_queue_id(priv, queue_id);
17131708

1709+
if (!gve_get_napi_enabled(priv))
1710+
return -ENETDOWN;
1711+
17141712
if (queue_id >= priv->rx_cfg.num_queues || !priv->xdp_prog)
17151713
return -EINVAL;
17161714

0 commit comments

Comments
 (0)