Skip to content

Commit 771d66f

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 9b07157 commit 771d66f

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
@@ -1528,8 +1528,8 @@ static int gve_xsk_pool_enable(struct net_device *dev,
15281528
if (err)
15291529
return err;
15301530

1531-
/* If XDP prog is not installed, return */
1532-
if (!priv->xdp_prog)
1531+
/* If XDP prog is not installed or interface is down, return. */
1532+
if (!priv->xdp_prog || !netif_running(dev))
15331533
return 0;
15341534

15351535
rx = &priv->rx[qid];
@@ -1574,21 +1574,16 @@ static int gve_xsk_pool_disable(struct net_device *dev,
15741574
if (qid >= priv->rx_cfg.num_queues)
15751575
return -EINVAL;
15761576

1577-
/* If XDP prog is not installed, unmap DMA and return */
1578-
if (!priv->xdp_prog)
1577+
/* If XDP prog is not installed or interface is down, unmap DMA and
1578+
* return.
1579+
*/
1580+
if (!priv->xdp_prog || !netif_running(dev))
15791581
goto done;
15801582

1581-
tx_qid = gve_xdp_tx_queue_id(priv, qid);
1582-
if (!netif_running(dev)) {
1583-
priv->rx[qid].xsk_pool = NULL;
1584-
xdp_rxq_info_unreg(&priv->rx[qid].xsk_rxq);
1585-
priv->tx[tx_qid].xsk_pool = NULL;
1586-
goto done;
1587-
}
1588-
15891583
napi_rx = &priv->ntfy_blocks[priv->rx[qid].ntfy_id].napi;
15901584
napi_disable(napi_rx); /* make sure current rx poll is done */
15911585

1586+
tx_qid = gve_xdp_tx_queue_id(priv, qid);
15921587
napi_tx = &priv->ntfy_blocks[priv->tx[tx_qid].ntfy_id].napi;
15931588
napi_disable(napi_tx); /* make sure current tx poll is done */
15941589

@@ -1616,6 +1611,9 @@ static int gve_xsk_wakeup(struct net_device *dev, u32 queue_id, u32 flags)
16161611
struct gve_priv *priv = netdev_priv(dev);
16171612
int tx_queue_id = gve_xdp_tx_queue_id(priv, queue_id);
16181613

1614+
if (!gve_get_napi_enabled(priv))
1615+
return -ENETDOWN;
1616+
16191617
if (queue_id >= priv->rx_cfg.num_queues || !priv->xdp_prog)
16201618
return -EINVAL;
16211619

0 commit comments

Comments
 (0)