Skip to content

Commit 1e0ee08

Browse files
josh8551021jfvogel
authored andcommitted
gve: guard XDP xmit NDO on existence of xdp queues
commit ff7c2de upstream. In GVE, dedicated XDP queues only exist when an XDP program is installed and the interface is up. As such, the NDO XDP XMIT callback should return early if either of these conditions are false. In the case of no loaded XDP program, priv->num_xdp_queues=0 which can cause a divide-by-zero error, and in the case of interface down, num_xdp_queues remains untouched to persist XDP queue count for the next interface up, but the TX pointer itself would be NULL. The XDP xmit callback also needs to synchronize with a device transitioning from open to close. This synchronization will happen via the GVE_PRIV_FLAGS_NAPI_ENABLED bit along with a synchronize_net() call, which waits for any RCU critical sections at call-time to complete. Fixes: 39a7f4a ("gve: Add XDP REDIRECT 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]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit 35f44eed5828cf1bc7e760d1993ed8549ba41c7b) Signed-off-by: Jack Vogel <[email protected]>
1 parent f85901f commit 1e0ee08

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1904,6 +1904,9 @@ static void gve_turndown(struct gve_priv *priv)
19041904

19051905
gve_clear_napi_enabled(priv);
19061906
gve_clear_report_stats(priv);
1907+
1908+
/* Make sure that all traffic is finished processing. */
1909+
synchronize_net();
19071910
}
19081911

19091912
static void gve_turnup(struct gve_priv *priv)

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,9 +837,12 @@ int gve_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames,
837837
struct gve_tx_ring *tx;
838838
int i, err = 0, qid;
839839

840-
if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK))
840+
if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK) || !priv->xdp_prog)
841841
return -EINVAL;
842842

843+
if (!gve_get_napi_enabled(priv))
844+
return -ENETDOWN;
845+
843846
qid = gve_xdp_tx_queue_id(priv,
844847
smp_processor_id() % priv->num_xdp_queues);
845848

0 commit comments

Comments
 (0)