Skip to content

Commit 8e8d703

Browse files
josh8551021gregkh
authored andcommitted
gve: guard XSK operations on the existence of queues
commit 40338d7 upstream. 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]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c8a8334 commit 8e8d703

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
@@ -1631,8 +1631,8 @@ static int gve_xsk_pool_enable(struct net_device *dev,
16311631
if (err)
16321632
return err;
16331633

1634-
/* If XDP prog is not installed, return */
1635-
if (!priv->xdp_prog)
1634+
/* If XDP prog is not installed or interface is down, return. */
1635+
if (!priv->xdp_prog || !netif_running(dev))
16361636
return 0;
16371637

16381638
rx = &priv->rx[qid];
@@ -1677,21 +1677,16 @@ static int gve_xsk_pool_disable(struct net_device *dev,
16771677
if (qid >= priv->rx_cfg.num_queues)
16781678
return -EINVAL;
16791679

1680-
/* If XDP prog is not installed, unmap DMA and return */
1681-
if (!priv->xdp_prog)
1680+
/* If XDP prog is not installed or interface is down, unmap DMA and
1681+
* return.
1682+
*/
1683+
if (!priv->xdp_prog || !netif_running(dev))
16821684
goto done;
16831685

1684-
tx_qid = gve_xdp_tx_queue_id(priv, qid);
1685-
if (!netif_running(dev)) {
1686-
priv->rx[qid].xsk_pool = NULL;
1687-
xdp_rxq_info_unreg(&priv->rx[qid].xsk_rxq);
1688-
priv->tx[tx_qid].xsk_pool = NULL;
1689-
goto done;
1690-
}
1691-
16921686
napi_rx = &priv->ntfy_blocks[priv->rx[qid].ntfy_id].napi;
16931687
napi_disable(napi_rx); /* make sure current rx poll is done */
16941688

1689+
tx_qid = gve_xdp_tx_queue_id(priv, qid);
16951690
napi_tx = &priv->ntfy_blocks[priv->tx[tx_qid].ntfy_id].napi;
16961691
napi_disable(napi_tx); /* make sure current tx poll is done */
16971692

@@ -1719,6 +1714,9 @@ static int gve_xsk_wakeup(struct net_device *dev, u32 queue_id, u32 flags)
17191714
struct gve_priv *priv = netdev_priv(dev);
17201715
int tx_queue_id = gve_xdp_tx_queue_id(priv, queue_id);
17211716

1717+
if (!gve_get_napi_enabled(priv))
1718+
return -ENETDOWN;
1719+
17221720
if (queue_id >= priv->rx_cfg.num_queues || !priv->xdp_prog)
17231721
return -EINVAL;
17241722

0 commit comments

Comments
 (0)