ethdev: fix UAF in rte_eth_tx_burst with filtering
RFC 1/1 ethdev: fix UAF in rte_eth_tx_burst with filtering
When packets are filtered by Tx callback, they return value needs to include those packets; otherwise the application will do a duplicate free of those mbufs.
The example would be application that sent a burst of 8 packets, and 2 were filtered but the PMD was busy and could not send any. The result should be a return value of 2 and mbufs 0..1 should be freed and 2..7 should be untouched and up to application to resend or drop.
Original buggy code would return 0 and 0..1 would be freed 2..7 would be unused. Application would then try and drop or resend an already freed mbuf.
Bugzilla ID: 1816
--- lib/ethdev/rte_ethdev.h | 47 ++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 12 deletions(-)
lib/ethdev/rte_ethdev.h +35 -12
@@ -6714,6 +6714,10 @@ rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id, }#endif +uint16_t requested_pkts = nb_pkts; +uint16_t filtered_pkts =0 ; +rte_mbuf_history_mark_bulk (tx_pkts, nb_pkts,RTE_MBUF_HISTORY_OP_TX ); +#ifdef RTE_ETHDEV_RXTX_CALLBACKS {void *cb;
@@ -6727,22 +6731,41 @@ rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id, cb =rte_atomic_load_explicit (&p->txq.clbk[queue_id], rte_memory_order_relaxed);if (unlikely (cb !=NULL )) - nb_pkts =rte_eth_call_tx_callbacks (port_id, queue_id, - tx_pkts, nb_pkts, cb); + filtered_pkts = nb_pkts - + rte_eth_call_tx_callbacks(port_id, queue_id, tx_pkts, nb_pkts, cb); }#endif -uint16_t requested_pkts = nb_pkts; -rte_mbuf_history_mark_bulk (tx_pkts, nb_pkts,RTE_MBUF_HISTORY_OP_TX ); - - nb_pkts = p->tx_pkt_burst (qd, tx_pkts, nb_pkts); - -if (requested_pkts > nb_pkts) -rte_mbuf_history_mark_bulk (tx_pkts + nb_pkts, - requested_pkts - nb_pkts,RTE_MBUF_HISTORY_OP_TX_BUSY ); +uint16_t sent_pkts = p->tx_pkt_burst (qd, tx_pkts, nb_pkts - filtered_pkts); +uint16_t result_pkts = sent_pkts + filtered_pkts; + +if (unlikely (result_pkts < requested_pkts)) { +uint16_t unsent_pkts = requested_pkts - result_pkts; + +if (unlikely (filtered_pkts >0 )) { +/* Need to reshuffle packet list so that unsent packets are +* after the return value +* +* Original: MMMMMM +* Filter: MMMMMF filtered = 1 +* Tx_burst: SSSUUF sent = 3 unsent = 2 +* +* Return: SSSFUU +* return from tx_burst is 4 +*/ +memmove (tx_pkts + result_pkts, tx_pkts + sent_pkts, + unsent_pkts *sizeof (struct rte_mbuf *)); + +/* Tx filter process does not drop the packets until here */ +rte_pktmbuf_free_bulk (tx_pkts + sent_pkts, filtered_pkts); + } + +rte_mbuf_history_mark_bulk (tx_pkts + result_pkts, unsent_pkts, +RTE_MBUF_HISTORY_OP_TX_BUSY ); + } -rte_ethdev_trace_tx_burst (port_id, queue_id, (void **)tx_pkts, nb_pkts); -return nb_pkts; +rte_ethdev_trace_tx_burst (port_id, queue_id, (void **)tx_pkts, result_pkts); +return result_pkts; }/**
Signature · 1 line
2.51.0
If I remember correctly we should avoid function names in summary.
(I'm really surprised that callbacks and rte_eth_tx_burst() are supposed to reorder mbufs in tx_pkts array, but it looks like it the only sensible option.)
Quoted 50 lines · Stephen Hemminger
When packets are filtered by Tx callback, they return value needs to include those packets; otherwise the application will do a duplicate free of those mbufs.
The example would be application that sent a burst of 8 packets, and 2 were filtered but the PMD was busy and could not send any. The result should be a return value of 2 and mbufs 0..1 should be freed and 2..7 should be untouched and up to application to resend or drop.
Original buggy code would return 0 and 0..1 would be freed 2..7 would be unused. Application would then try and drop or resend an already freed mbuf.
Bugzilla ID: 1816
Fixes 4dc294158cac ("ethdev: support optional Rx and Tx callbacks")Signed-off-by Stephen Hemminger <[email protected]>--- lib/ethdev/rte_ethdev.h | 47 ++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 12 deletions(-)lib/ethdev/rte_ethdev.h +6
-4@@ -6714,6 +6714,10 @@ rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id, }#endif +uint16_t requested_pkts = nb_pkts; +uint16_t filtered_pkts =0 ; +rte_mbuf_history_mark_bulk (tx_pkts, nb_pkts,RTE_MBUF_HISTORY_OP_TX ); +#ifdef RTE_ETHDEV_RXTX_CALLBACKS {void *cb;@@ -6727,22 +6731,41 @@ rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id, cb =rte_atomic_load_explicit (&p->txq.clbk[queue_id], rte_memory_order_relaxed);if (unlikely (cb !=NULL )) - nb_pkts =rte_eth_call_tx_callbacks (port_id, queue_id, - tx_pkts, nb_pkts, cb); + filtered_pkts = nb_pkts - + rte_eth_call_tx_callbacks(port_id, queue_id, tx_pkts, nb_pkts, cb); }#endif -uint16_t requested_pkts = nb_pkts; -rte_mbuf_history_mark_bulk (tx_pkts, nb_pkts,RTE_MBUF_HISTORY_OP_TX );
lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id, · line 6742
Quoted 10 lines
lib/ethdev/rte_ethdev.h +4
-6- - nb_pkts = p->tx_pkt_burst (qd, tx_pkts, nb_pkts); - -if (requested_pkts > nb_pkts) -rte_mbuf_history_mark_bulk (tx_pkts + nb_pkts, - requested_pkts - nb_pkts,RTE_MBUF_HISTORY_OP_TX_BUSY ); +uint16_t sent_pkts = p->tx_pkt_burst (qd, tx_pkts, nb_pkts - filtered_pkts); +uint16_t result_pkts = sent_pkts + filtered_pkts; + +if (unlikely (result_pkts < requested_pkts)) {
First of all unlikely() is wrong here. It is not an error path. It is OK when not everything is sent and it should not cost too much as unlikely does.
Second, I'd remove the condition completely. It is not a big deal to calculate unsent_pkts and call trace (if enabled) with zero unsent_pkts.
lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id, · line 6745
Quoted 3 lines
lib/ethdev/rte_ethdev.h +3
-0+uint16_t unsent_pkts = requested_pkts - result_pkts; + +if (unlikely (filtered_pkts >0 )) {
Same here for unlikely().
Also since filtered_pkts appear in RTE_ETHDEV_RXTX_CALLBACKS case, I'd put it under corresponding conditional compilation to be consistent. Yes, code with conditional compilation is hard to read, but consistency is more important here.
Quoted 28 lines
lib/ethdev/rte_ethdev.h +22
-2+/* Need to reshuffle packet list so that unsent packets are +* after the return value +* +* Original: MMMMMM +* Filter: MMMMMF filtered = 1 +* Tx_burst: SSSUUF sent = 3 unsent = 2 +* +* Return: SSSFUU +* return from tx_burst is 4 +*/ +memmove (tx_pkts + result_pkts, tx_pkts + sent_pkts, + unsent_pkts *sizeof (struct rte_mbuf *)); + +/* Tx filter process does not drop the packets until here */ +rte_pktmbuf_free_bulk (tx_pkts + sent_pkts, filtered_pkts); + } + +rte_mbuf_history_mark_bulk (tx_pkts + result_pkts, unsent_pkts, +RTE_MBUF_HISTORY_OP_TX_BUSY ); + } -rte_ethdev_trace_tx_burst (port_id, queue_id, (void **)tx_pkts, nb_pkts); -return nb_pkts; +rte_ethdev_trace_tx_burst (port_id, queue_id, (void **)tx_pkts, result_pkts); +return result_pkts; }/**
Morten Brørup
NAK+TO: Konstantin, regarding Stage Ordered Ring.
Quoted 8 lines
From: Andrew Rybchenko [mailto:[email protected]]
Sent: Sunday, 9 November 2025 16.23If I remember correctly we should avoid function names in summary.
(I'm really surprised that callbacks and
rte_eth_tx_burst()are supposed to reorder mbufs intx_pktsarray, but it looks like it the only sensible option.)
Reordering the packets is incompatible with the Stage Ordered Ring.
When the transmit function returns e.g. 2 non-consumed packets, the metadata will be associated with the 2 last packets in the original burst passed to the transmit function, not the 2 packets moved to the last position in the array.
Quoted 107 lines · Stephen Hemminger
Quoted 14 lines
When packets are filtered by Tx callback, they return value needs to include those packets; otherwise the application will do a duplicate free of those mbufs.
The example would be application that sent a burst of 8 packets, and 2 were filtered but the PMD was busy and could not send any. The result should be a return value of 2 and mbufs 0..1 should be freed and 2..7 should be untouched and up to application to resend or drop.
Original buggy code would return 0 and 0..1 would be freed 2..7 would be unused. Application would then try and drop or resend an already freed mbuf.
Quoted 6 lines
Bugzilla ID: 1816
Fixes 4dc294158cac ("ethdev: support optional Rx and Tx callbacks")Signed-off-by Stephen Hemminger <[email protected]>--- lib/ethdev/rte_ethdev.h | 47 ++++++++++++++++++++++++++++++-----------
lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t
Quoted 7 lines
1 file changed, 35 insertions(+), 12 deletions(-)lib/ethdev/rte_ethdev.h +0
-0@@ -6714,6 +6714,10 @@ rte_eth_tx_burst(uint16_t port_id, uint16_t
queue_id,lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id,
Quoted 6 lines
lib/ethdev/rte_ethdev.h +3
-0}#endif +uint16_t requested_pkts = nb_pkts; +uint16_t filtered_pkts =0 ; + rte_mbuf_history_mark_bulk(tx_pkts, nb_pkts,
RTE_MBUF_HISTORY_OP_TX);lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t
Quoted 5 lines
lib/ethdev/rte_ethdev.h +1
-0+#ifdef RTE_ETHDEV_RXTX_CALLBACKS {void *cb;@@ -6727,22 +6731,41 @@ rte_eth_tx_burst(uint16_t port_id, uint16_t
queue_id,lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id,
Quoted 4 lines
lib/ethdev/rte_ethdev.h +0
-1cb =rte_atomic_load_explicit (&p->txq.clbk[queue_id], rte_memory_order_relaxed);if (unlikely (cb !=NULL )) - nb_pkts = rte_eth_call_tx_callbacks(port_id,
queue_id,lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id,
Quoted 3 lines
lib/ethdev/rte_ethdev.h +2
-1- tx_pkts, nb_pkts, cb); + filtered_pkts = nb_pkts - + rte_eth_call_tx_callbacks(port_id, queue_id,
tx_pkts,nb_pkts, cb);lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id,
Quoted 5 lines
lib/ethdev/rte_ethdev.h +0
-2}#endif -uint16_t requested_pkts = nb_pkts; - rte_mbuf_history_mark_bulk(tx_pkts, nb_pkts,
RTE_MBUF_HISTORY_OP_TX);lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id,
Quoted 6 lines
lib/ethdev/rte_ethdev.h +0
-6- - nb_pkts = p->tx_pkt_burst (qd, tx_pkts, nb_pkts); - -if (requested_pkts > nb_pkts) - rte_mbuf_history_mark_bulk(tx_pkts + nb_pkts, - requested_pkts - nb_pkts,
RTE_MBUF_HISTORY_OP_TX_BUSY);lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t · line 6739
Quoted 1 line
lib/ethdev/rte_ethdev.h +1
-0+ uint16_t sent_pkts = p->tx_pkt_burst(qd, tx_pkts, nb_pkts -
filtered_pkts);lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id, · line 6742
Quoted 3 lines
lib/ethdev/rte_ethdev.h +3
-0+uint16_t result_pkts = sent_pkts + filtered_pkts; + +if (unlikely (result_pkts < requested_pkts)) {First of all
unlikely()is wrong here. It is not an error path. It is OK
when not everything is sent and it should not cost too much as unlikely does.
Second, I'd remove the condition completely. It is not a big deal to calculateunsent_pktsand call trace (if enabled) with zerounsent_pkts.lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id, · line 6745
Quoted 3 lines
lib/ethdev/rte_ethdev.h +3
-0+uint16_t unsent_pkts = requested_pkts - result_pkts; + +if (unlikely (filtered_pkts >0 )) {Same here for
unlikely().
Also sincefiltered_pktsappear inRTE_ETHDEV_RXTX_CALLBACKScase, I'd put it under corresponding conditional compilation to be consistent.
Yes, code with conditional compilation is hard to read, but consistency is more important here.lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t · line 6746
Quoted 1 line
lib/ethdev/rte_ethdev.h +1
-0+/* Need to reshuffle packet list so that unsent packets are
lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id,
Quoted 13 lines
lib/ethdev/rte_ethdev.h +13
-0+* after the return value +* +* Original: MMMMMM +* Filter: MMMMMF filtered = 1 +* Tx_burst: SSSUUF sent = 3 unsent = 2 +* +* Return: SSSFUU +* return from tx_burst is 4 +*/ +memmove (tx_pkts + result_pkts, tx_pkts + sent_pkts, + unsent_pkts *sizeof (struct rte_mbuf *)); + +/* Tx filter process does not drop the packets until here */
Quoted 2 lines
lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t · line 6760
Quoted 1 line
lib/ethdev/rte_ethdev.h +1
-0+ rte_pktmbuf_free_bulk(tx_pkts + sent_pkts,
filtered_pkts);
NAK.
If the callback consumes the packet, the callback must free it too. The callback could consume the packet for other purposes, e.g. redirection, so freeing it here would introduce use-after-free bugs.
Quoted 9 lines
lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id,
Quoted 3 lines
lib/ethdev/rte_ethdev.h +3
-0+ } + + rte_mbuf_history_mark_bulk(tx_pkts + result_pkts,
unsent_pkts,lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id,
Quoted 4 lines
lib/ethdev/rte_ethdev.h +2
-1+ RTE_MBUF_HISTORY_OP_TX_BUSY); + } - rte_ethdev_trace_tx_burst(port_id, queue_id, (void **)tx_pkts,
nb_pkts);
Quoted 7 lines
lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t · line 6767
Quoted 2 lines
lib/ethdev/rte_ethdev.h +1
-1-return nb_pkts; + rte_ethdev_trace_tx_burst(port_id, queue_id, (void **)tx_pkts,
result_pkts);lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id, · line 6771
Quoted 4 lines
lib/ethdev/rte_ethdev.h +1
-0+return result_pkts; }/**
IMO, letting a Tx callback change the number of packets to actually transmit has too many side effects. E.g. port packet counters are not updated accordingly if a callback consumes a packet and silently drops it.
The Ethdev Tx API is not designed for the ethdev layer to handle any of retransmit-or-drop (when insufficient descriptors), redirect, mirror, drop (redirect/mirror/drop of all packets or selectively based on e.g. VLAN or BPF filter).
IMO, we should update the callback API to reflect this, by changing the callback return type to void.
Quoted 5 lines · Morten Brørup
+TO: Konstantin, regarding Stage Ordered Ring.
Quoted 3 lines
From: Andrew Rybchenko [mailto:[email protected]]
Sent: Sunday, 9 November 2025 16.23
Quoted 8 lines
Quoted 5 lines
If I remember correctly we should avoid function names in summary.
(I'm really surprised that callbacks and
rte_eth_tx_burst()are supposed to reorder mbufs intx_pktsarray, but it looks like it the only sensible option.)Reordering the packets is incompatible with the Stage Ordered Ring.
When the transmit function returns e.g. 2 non-consumed packets, the metadata will be associated with the 2 last packets in the original burst passed to the transmit function, not the 2 packets moved to the last position in the array.
Good point.
Quoted 108 lines
Quoted 108 lines · Stephen Hemminger
Quoted 14 lines
When packets are filtered by Tx callback, they return value needs to include those packets; otherwise the application will do a duplicate free of those mbufs.
The example would be application that sent a burst of 8 packets, and 2 were filtered but the PMD was busy and could not send any. The result should be a return value of 2 and mbufs 0..1 should be freed and 2..7 should be untouched and up to application to resend or drop.
Original buggy code would return 0 and 0..1 would be freed 2..7 would be unused. Application would then try and drop or resend an already freed mbuf.
Quoted 6 lines
Bugzilla ID: 1816
Fixes 4dc294158cac ("ethdev: support optional Rx and Tx callbacks")Signed-off-by Stephen Hemminger <[email protected]>--- lib/ethdev/rte_ethdev.h | 47 ++++++++++++++++++++++++++++++-----------
lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t
Quoted 7 lines
1 file changed, 35 insertions(+), 12 deletions(-)lib/ethdev/rte_ethdev.h +0
-0@@ -6714,6 +6714,10 @@ rte_eth_tx_burst(uint16_t port_id, uint16_t
queue_id,lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id,
Quoted 6 lines
lib/ethdev/rte_ethdev.h +3
-0}#endif +uint16_t requested_pkts = nb_pkts; +uint16_t filtered_pkts =0 ; + rte_mbuf_history_mark_bulk(tx_pkts, nb_pkts,
RTE_MBUF_HISTORY_OP_TX);lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t
Quoted 5 lines
lib/ethdev/rte_ethdev.h +1
-0+#ifdef RTE_ETHDEV_RXTX_CALLBACKS {void *cb;@@ -6727,22 +6731,41 @@ rte_eth_tx_burst(uint16_t port_id, uint16_t
queue_id,lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id,
Quoted 4 lines
lib/ethdev/rte_ethdev.h +0
-1cb =rte_atomic_load_explicit (&p->txq.clbk[queue_id], rte_memory_order_relaxed);if (unlikely (cb !=NULL )) - nb_pkts = rte_eth_call_tx_callbacks(port_id,
queue_id,lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id,
Quoted 3 lines
lib/ethdev/rte_ethdev.h +2
-1- tx_pkts, nb_pkts, cb); + filtered_pkts = nb_pkts - + rte_eth_call_tx_callbacks(port_id, queue_id,
tx_pkts,nb_pkts, cb);lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id,
Quoted 5 lines
lib/ethdev/rte_ethdev.h +0
-2}#endif -uint16_t requested_pkts = nb_pkts; - rte_mbuf_history_mark_bulk(tx_pkts, nb_pkts,
RTE_MBUF_HISTORY_OP_TX);lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id,
Quoted 6 lines
lib/ethdev/rte_ethdev.h +0
-6- - nb_pkts = p->tx_pkt_burst (qd, tx_pkts, nb_pkts); - -if (requested_pkts > nb_pkts) - rte_mbuf_history_mark_bulk(tx_pkts + nb_pkts, - requested_pkts - nb_pkts,
RTE_MBUF_HISTORY_OP_TX_BUSY);lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t · line 6739
Quoted 1 line
lib/ethdev/rte_ethdev.h +1
-0+ uint16_t sent_pkts = p->tx_pkt_burst(qd, tx_pkts, nb_pkts -
filtered_pkts);lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id, · line 6742
Quoted 3 lines
lib/ethdev/rte_ethdev.h +3
-0+uint16_t result_pkts = sent_pkts + filtered_pkts; + +if (unlikely (result_pkts < requested_pkts)) {First of all
unlikely()is wrong here. It is not an error path. It is OK
when not everything is sent and it should not cost too much as unlikely does.
Second, I'd remove the condition completely. It is not a big deal to calculateunsent_pktsand call trace (if enabled) with zerounsent_pkts.lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id, · line 6745
Quoted 3 lines
lib/ethdev/rte_ethdev.h +3
-0+uint16_t unsent_pkts = requested_pkts - result_pkts; + +if (unlikely (filtered_pkts >0 )) {Same here for
unlikely().
Also sincefiltered_pktsappear inRTE_ETHDEV_RXTX_CALLBACKScase, I'd put it under corresponding conditional compilation to be consistent.
Yes, code with conditional compilation is hard to read, but consistency is more important here.lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t · line 6746
Quoted 1 line
lib/ethdev/rte_ethdev.h +1
-0+/* Need to reshuffle packet list so that unsent packets are
lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id,
Quoted 13 lines
lib/ethdev/rte_ethdev.h +13
-0+* after the return value +* +* Original: MMMMMM +* Filter: MMMMMF filtered = 1 +* Tx_burst: SSSUUF sent = 3 unsent = 2 +* +* Return: SSSFUU +* return from tx_burst is 4 +*/ +memmove (tx_pkts + result_pkts, tx_pkts + sent_pkts, + unsent_pkts *sizeof (struct rte_mbuf *)); + +/* Tx filter process does not drop the packets until here */
Quoted 5 lines
Quoted 2 lines
lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t · line 6760
Quoted 1 line
lib/ethdev/rte_ethdev.h +1
-0+ rte_pktmbuf_free_bulk(tx_pkts + sent_pkts,
filtered_pkts);NAK.
If the callback consumes the packet, the callback must free it too. The callback could consume the packet for other purposes, e.g. redirection, so freeing it here would introduce use-after-free bugs.
Good point as well. However, it still requires reordering which has problem mentioned above.
Quoted 25 lines
Quoted 10 lines
lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id,
Quoted 4 lines
lib/ethdev/rte_ethdev.h +3
-0+ } + + rte_mbuf_history_mark_bulk(tx_pkts + result_pkts,
unsent_pkts,lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id,
Quoted 4 lines
lib/ethdev/rte_ethdev.h +2
-1+ RTE_MBUF_HISTORY_OP_TX_BUSY); + } - rte_ethdev_trace_tx_burst(port_id, queue_id, (void **)tx_pkts,
nb_pkts);Quoted 7 lines
lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t · line 6767
Quoted 2 lines
lib/ethdev/rte_ethdev.h +1
-1-return nb_pkts; + rte_ethdev_trace_tx_burst(port_id, queue_id, (void **)tx_pkts,
result_pkts);lib/ethdev/rte_ethdev.h rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id, · line 6771
Quoted 4 lines
lib/ethdev/rte_ethdev.h +1
-0+return result_pkts; }/** IMO, letting a Tx callback change the number of packets to actually transmit has too many side effects. E.g. port packet counters are not updated accordingly if a callback consumes a packet and silently drops it.
The Ethdev Tx API is not designed for the ethdev layer to handle any of retransmit-or-drop (when insufficient descriptors), redirect, mirror, drop (redirect/mirror/drop of all packets or selectively based on e.g. VLAN or BPF filter).
IMO, we should update the callback API to reflect this, by changing the callback return type to void.