[PATCH] net/af_packet: move size check to after vlan insert

Stephen Hemminger stephen at networkplumber.org
Wed Oct 28 23:48:07 CET 2026


This fixes a corner case where vlan is insert and the resulting
packet exceeds the TPACKET_V2 ring slot size.

Reported-by: Anthropic OSS scanner
Fixes: 23deeebfcfa8 ("net/af_packet: support 802.1Q VLAN")
Cc: stable at dpdk.org

Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
 drivers/net/af_packet/rte_eth_af_packet.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index ef57719803..6bec12a735 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -318,12 +318,6 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	for (i = 0; i < nb_pkts; i++) {
 		mbuf = *bufs++;
 
-		/* drop oversized packets */
-		if (mbuf->pkt_len > pkt_q->frame_data_size) {
-			rte_pktmbuf_free(mbuf);
-			continue;
-		}
-
 		/* insert vlan info if necessary */
 		if (mbuf->ol_flags & RTE_MBUF_F_TX_VLAN) {
 			if (rte_vlan_insert(&mbuf)) {
@@ -332,6 +326,12 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 			}
 		}
 
+		/* drop oversized packets */
+		if (mbuf->pkt_len > pkt_q->frame_data_size) {
+			rte_pktmbuf_free(mbuf);
+			continue;
+		}
+
 		/* point at the next incoming frame */
 		if (!tx_ring_status_available(ppd->tp_status)) {
 			if (poll(&pfd, 1, -1) < 0)
-- 
2.53.0



More information about the dev mailing list