small fixes suggested by Coverity scan
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
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
--- lib/pcapng/rte_pcapng.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/pcapng/rte_pcapng.c +2 -2
@@ -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
PATCH 2/3 app/test_bpf: don't print eBPF program if NULL
In reply to Stephen HemmingerIf conversion of cBPF to eBPF fails (in rte_bpf_convert) then the test should not try and print the result.
Coverity issue: 373661
--- app/test/test_bpf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
app/test/test_bpf.c +4 -2
@@ -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
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")Signed-off-by Stephen Hemminger <[email protected]>--- app/test/test_bpf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)app/test/test_bpf.c +0
-0@@ -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
PATCH 3/3 app/dumpcap: check for failure to set promiscious
In reply to Stephen HemmingerIf the rte_eth_promiscious_enable() fails, then log the error and continue.
Coverity issue: 373662
--- app/dumpcap/main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
app/dumpcap/main.c +7 -2
@@ -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
11/02/2022 00:09, Stephen Hemminger:
Quoted 6 lines
Fix some simple bugs.
Stephen Hemminger (3):
pcapng: handlerte_ethlink_getfailing app/test_bpf: don't print eBPF program if NULL app/dumpcap: check for failure to set promiscious
Improved titles and applied, thanks.