[dpdk-dev,3/3] net/af_packet: fix packet bytes counting

Message ID 1495044215-16915-3-git-send-email-ciwillia@brocade.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Chas Williams May 17, 2017, 6:03 p.m. UTC
  On error, we also need to zero the bytes transmitted.

Signed-off-by: Charles (Chas) Williams <ciwillia@brocade.com>
---
 drivers/net/af_packet/rte_eth_af_packet.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
  

Patch

diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index 6927f70..e456836 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -269,8 +269,11 @@  eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	}
 
 	/* kick-off transmits */
-	if (sendto(pkt_q->sockfd, NULL, 0, MSG_DONTWAIT, NULL, 0) == -1)
-		num_tx = 0; /* error sending -- no packets transmitted */
+	if (sendto(pkt_q->sockfd, NULL, 0, MSG_DONTWAIT, NULL, 0) == -1) {
+		/* error sending -- no packets transmitted */
+		num_tx = 0;
+		num_tx_bytes = 0;
+	}
 
 	pkt_q->framenum = framenum;
 	pkt_q->tx_pkts += num_tx;