[1/3] pcapng: handle rte_ethlink_get failing

Message ID 20220210230906.833163-2-stephen@networkplumber.org (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series small fixes suggested by Coverity scan |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger Feb. 10, 2022, 11:09 p.m. UTC
  If rte_ethlink_get fails, the code can just not add speed
to the pcap file.

Coverity issue: 373664
Fixes: 8d23ce8f5ee9 ("pcapng: add new library for writing pcapng files")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/pcapng/rte_pcapng.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Patch

diff --git a/lib/pcapng/rte_pcapng.c b/lib/pcapng/rte_pcapng.c
index 03edabe73e96..9db058fe422b 100644
--- a/lib/pcapng/rte_pcapng.c
+++ b/lib/pcapng/rte_pcapng.c
@@ -177,8 +177,8 @@  pcapng_add_interface(rte_pcapng_t *self, uint16_t port)
 			 "%s-%s", dev->bus->name, dev->name);
 
 	/* DPDK reports in units of Mbps */
-	rte_eth_link_get(port, &link);
-	if (link.link_status == RTE_ETH_LINK_UP)
+	if (rte_eth_link_get(port, &link) == 0 &&
+	    link.link_status == RTE_ETH_LINK_UP)
 		speed = link.link_speed * PCAPNG_MBPS_SPEED;
 
 	if (rte_eth_macaddr_get(port, &macaddr) < 0)