[v2,2/3] net/pcap: fix transmit return count in error conditions
Checks
Commit Message
When a packet cannot be transmitted, the driver is supposed to free this
packet and report it as handled.
This is to prevent the application from retrying to send the same packet
and ending up in a liveloop since the driver will never manage to send
it.
Fixes: 49a0a2ffd5db ("net/pcap: fix possible mbuf double freeing")
Fixes: 6db141c91e1f ("pcap: support jumbo frames")
CC: stable@dpdk.org
Signed-off-by: David Marchand <david.marchand@redhat.com>
---
Changelog since v1:
- restored the original behavior if pcap_sendpacket returns an error
---
drivers/net/pcap/rte_eth_pcap.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
Comments
On 7/25/2019 1:04 PM, David Marchand wrote:
> When a packet cannot be transmitted, the driver is supposed to free this
> packet and report it as handled.
> This is to prevent the application from retrying to send the same packet
> and ending up in a liveloop since the driver will never manage to send
> it.
>
> Fixes: 49a0a2ffd5db ("net/pcap: fix possible mbuf double freeing")
> Fixes: 6db141c91e1f ("pcap: support jumbo frames")
> CC: stable@dpdk.org
>
> Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
@@ -354,7 +354,8 @@ eth_pcap_tx_dumper(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
mbuf->pkt_len,
RTE_ETHER_MAX_JUMBO_FRAME_LEN);
- break;
+ rte_pktmbuf_free(mbuf);
+ continue;
}
}
@@ -373,7 +374,7 @@ eth_pcap_tx_dumper(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
dumper_q->tx_stat.bytes += tx_bytes;
dumper_q->tx_stat.err_pkts += nb_pkts - num_tx;
- return num_tx;
+ return nb_pkts;
}
/*
@@ -439,7 +440,8 @@ eth_pcap_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
mbuf->pkt_len,
RTE_ETHER_MAX_JUMBO_FRAME_LEN);
- break;
+ rte_pktmbuf_free(mbuf);
+ continue;
}
}
@@ -452,9 +454,9 @@ eth_pcap_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
tx_queue->tx_stat.pkts += num_tx;
tx_queue->tx_stat.bytes += tx_bytes;
- tx_queue->tx_stat.err_pkts += nb_pkts - num_tx;
+ tx_queue->tx_stat.err_pkts += i - num_tx;
- return num_tx;
+ return i;
}
/*