Skip to contentSkip to conversation

small fixes suggested by Coverity scan

PATCH In review Stephen Hemminger 3 participants 6 messages Feb 10, 2022 – Mar 8, 2022

lore
Share & tools
lore
#0 lore raw

cover small fixes suggested by Coverity scan

Fix some simple bugs.

Stephen Hemminger (3):
pcapng: handle rte_ethlink_get failing app/test_bpf: don't print eBPF program if NULL app/dumpcap: check for failure to set promiscious

 app/dumpcap/main.c      | 9 +++++++--
 app/test/test_bpf.c     | 6 ++++--
 lib/pcapng/rte_pcapng.c | 4 ++--
 3 files changed, 13 insertions(+), 6 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/3 pcapng: handle rte_ethlink_get failing

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")
---
 lib/pcapng/rte_pcapng.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/pcapng/rte_pcapng.c +2 -2
index 03edabe73e96..9db058fe422b 100644
@@ -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)
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/3 app/test_bpf: don't print eBPF program if NULL

In reply to Stephen Hemminger

If conversion of cBPF to eBPF fails (in rte_bpf_convert) then the test should not try and print the result.

Coverity issue: 373661

Fixes 2eccf6afbea9 ("bpf: add function to convert classic BPF to DPDK BPF")
---
 app/test/test_bpf.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
app/test/test_bpf.c +4 -2
index d1e10adab545..805cce640667 100644
@@ -3273,8 +3273,10 @@ test_bpf_dump(struct bpf_program *cbf, const struct rte_bpf_prm *prm)
 	printf("cBPF program (%u insns)\n", cbf->bf_len);
 	bpf_dump(cbf, 1);
 
-	printf("\neBPF program (%u insns)\n", prm->nb_ins);
-	rte_bpf_dump(stdout, prm->ins, prm->nb_ins);
+	if (prm != NULL) {
+		printf("\neBPF program (%u insns)\n", prm->nb_ins);
+		rte_bpf_dump(stdout, prm->ins, prm->nb_ins);
+	}
 }
 
 static int
Signature · 1 line
2.34.1
Acked-by on v1 2/3
#3 lore raw

RE: [PATCH 2/3] app/test_bpf: don't print eBPF program if NULL

Quoted 19 lines

If conversion of cBPF to eBPF fails (in rte_bpf_convert) then the test should not try and print the result.

Coverity issue: 373661

Fixes 2eccf6afbea9 ("bpf: add function to convert classic BPF to DPDK BPF")
---
 app/test/test_bpf.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
app/test/test_bpf.c +0 -0
index d1e10adab545..805cce640667 100644
@@ -3273,8 +3273,10 @@ test_bpf_dump(struct bpf_program *cbf, const struct rte_bpf_prm *prm)
 	printf("cBPF program (%u insns)\n", cbf->bf_len);
 	bpf_dump(cbf, 1);
 

app/test/test_bpf.c test_bpf_dump(struct bpf_program *cbf, const struct rte_bpf_prm *prm)

Quoted 10 lines
app/test/test_bpf.c +4 -3
-	printf("\neBPF program (%u insns)\n", prm->nb_ins);
-	rte_bpf_dump(stdout, prm->ins, prm->nb_ins);
+	if (prm != NULL) {
+		printf("\neBPF program (%u insns)\n", prm->nb_ins);
+		rte_bpf_dump(stdout, prm->ins, prm->nb_ins);
+	}
 }
 
 static int
--
Quoted 1 line

2.34.1

#4 lore raw

PATCH 3/3 app/dumpcap: check for failure to set promiscious

In reply to Stephen Hemminger

If the rte_eth_promiscious_enable() fails, then log the error and continue.

Coverity issue: 373662

Fixes cbb44143be74 ("app/dumpcap: add new packet capture application")
---
 app/dumpcap/main.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
app/dumpcap/main.c +7 -2
index c5fe4403028a..21cb2810a48f 100644
@@ -679,8 +679,13 @@ static void enable_pdump(struct rte_ring *r, struct rte_mempool *mp)
 		flags |= RTE_PDUMP_FLAG_PCAPNG;
 
 	TAILQ_FOREACH(intf, &interfaces, next) {
-		if (promiscuous_mode)
-			rte_eth_promiscuous_enable(intf->port);
+		if (promiscuous_mode) {
+			ret = rte_eth_promiscuous_enable(intf->port);
+			if (ret != 0)
+				fprintf(stderr,
+					"port %u set promicious enable faile: %d\n",
+					intf->port, ret);
+		}
 
 		ret = rte_pdump_enable_bpf(intf->port, RTE_PDUMP_ALL_QUEUES,
 					   flags, snaplen,
Signature · 1 line
2.34.1
#5 lore raw
In reply to Stephen Hemminger

11/02/2022 00:09, Stephen Hemminger:

Quoted 6 lines

Fix some simple bugs.

Stephen Hemminger (3):
pcapng: handle rte_ethlink_get failing app/test_bpf: don't print eBPF program if NULL app/dumpcap: check for failure to set promiscious

Improved titles and applied, thanks.