Skip to content

Commit 505b1a8

Browse files
davidarinzonkuba-moo
authored andcommitted
net: ena: Fix xdp drops handling due to multibuf packets
Current xdp code drops packets larger than ENA_XDP_MAX_MTU. This is an incorrect condition since the problem is not the size of the packet, rather the number of buffers it contains. This commit: 1. Identifies and drops XDP multi-buffer packets at the beginning of the function. 2. Increases the xdp drop statistic when this drop occurs. 3. Adds a one-time print that such drops are happening to give better indication to the user. Fixes: 838c93d ("net: ena: implement XDP drop support") Signed-off-by: Arthur Kiyanovski <[email protected]> Signed-off-by: David Arinzon <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 41db6f9 commit 505b1a8

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

drivers/net/ethernet/amazon/ena/ena_netdev.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,20 +1672,23 @@ static void ena_set_rx_hash(struct ena_ring *rx_ring,
16721672
}
16731673
}
16741674

1675-
static int ena_xdp_handle_buff(struct ena_ring *rx_ring, struct xdp_buff *xdp)
1675+
static int ena_xdp_handle_buff(struct ena_ring *rx_ring, struct xdp_buff *xdp, u16 num_descs)
16761676
{
16771677
struct ena_rx_buffer *rx_info;
16781678
int ret;
16791679

1680+
/* XDP multi-buffer packets not supported */
1681+
if (unlikely(num_descs > 1)) {
1682+
netdev_err_once(rx_ring->adapter->netdev,
1683+
"xdp: dropped unsupported multi-buffer packets\n");
1684+
ena_increase_stat(&rx_ring->rx_stats.xdp_drop, 1, &rx_ring->syncp);
1685+
return ENA_XDP_DROP;
1686+
}
1687+
16801688
rx_info = &rx_ring->rx_buffer_info[rx_ring->ena_bufs[0].req_id];
16811689
xdp_prepare_buff(xdp, page_address(rx_info->page),
16821690
rx_info->buf_offset,
16831691
rx_ring->ena_bufs[0].len, false);
1684-
/* If for some reason we received a bigger packet than
1685-
* we expect, then we simply drop it
1686-
*/
1687-
if (unlikely(rx_ring->ena_bufs[0].len > ENA_XDP_MAX_MTU))
1688-
return ENA_XDP_DROP;
16891692

16901693
ret = ena_xdp_execute(rx_ring, xdp);
16911694

@@ -1754,7 +1757,7 @@ static int ena_clean_rx_irq(struct ena_ring *rx_ring, struct napi_struct *napi,
17541757
ena_rx_ctx.l4_proto, ena_rx_ctx.hash);
17551758

17561759
if (ena_xdp_present_ring(rx_ring))
1757-
xdp_verdict = ena_xdp_handle_buff(rx_ring, &xdp);
1760+
xdp_verdict = ena_xdp_handle_buff(rx_ring, &xdp, ena_rx_ctx.descs);
17581761

17591762
/* allocate skb and fill it */
17601763
if (xdp_verdict == ENA_XDP_PASS)

0 commit comments

Comments
 (0)