[dpdk-dev] rte_eth_af_packet: check return value from sendto call

Message ID 1440697850-11763-1-git-send-email-linville@tuxdriver.com (mailing list archive)
State Accepted, archived
Headers

Commit Message

John W. Linville Aug. 27, 2015, 5:50 p.m. UTC
  Coverity CID # 13200

If sendto fails, the packets will not get transmitted.  Return 0 as
the number of packets transmitted.

Signed-off-by: John W. Linville <linville@tuxdriver.com>
---
 drivers/net/af_packet/rte_eth_af_packet.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Thomas Monjalon Oct. 20, 2015, 4:01 p.m. UTC | #1
2015-08-27 13:50, John W. Linville:
> Coverity CID # 13200
> 
> If sendto fails, the packets will not get transmitted.  Return 0 as
> the number of packets transmitted.
> 
> Signed-off-by: John W. Linville <linville@tuxdriver.com>

Applied, thanks
  

Patch

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