graph: fix pcapng file support
The interface to rte_pcapng changed in last release so that the interfaces used need to be added to the pcapng file via the API. If this step is missing the pcapng file will not be valid and can't be read by wireshark etc.
I don't have setup to test graph, so needs a validation test.
--- lib/graph/graph_pcap.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
lib/graph/graph_pcap.c +15 -1
@@ -7,6 +7,7 @@#include <stdlib.h> #include <unistd.h> +#include <rte_ethdev.h> #include <rte_mbuf.h> #include <rte_pcapng.h>
@@ -80,7 +81,8 @@ graph_pcap_default_path_get(char **dir_path)int graph_pcap_file_open (const char *filename) { -int fd; +int fd, ret; +uint16_t portid;char file_name[RTE_GRAPH_PCAP_FILE_SZ ];char *pcap_dir;
@@ -114,6 +116,18 @@ graph_pcap_file_open(const char *filename)return -1 ; } +/* Add the configured interfaces as possible capture ports */ +RTE_ETH_FOREACH_DEV (portid) { + ret =rte_pcapng_add_interface (pcapng_fd, portid, +NULL ,NULL ,NULL ); +if (ret <0 ) { +graph_err ("Graph rte_pcapng_add_interface failed: %d" , + ret); +close (fd); +return -1 ; + } + } + done:return 0 ; }
Signature · 1 line
2.39.2
Amit Prakash Shukla
Acked-byQuoted 49 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Wednesday, May 31, 2023 12:39 AM
To: [email protected]
Cc: Stephen Hemminger <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Kiran Kumar Kokkilagadda <[email protected]>; Nithin Kumar Dabilpuram <[email protected]>
Subject: [EXT] [RFT] graph: fix pcapng file supportExternal Email
----------------------------------------------------------------------
The interface torte_pcapngchanged in last release so that the interfaces used need to be added to the pcapng file via the API. If this step is missing the pcapng file will not be valid and can't be read by wireshark etc.I don't have setup to test graph, so needs a validation test.
Fixes d1da6d0d04c7 ("pcapng: require per-interface information")Signed-off-by Stephen Hemminger <[email protected]>--- lib/graph/graph_pcap.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)lib/graph/graph_pcap.c index renamed from lib/graph/graph_pcap.c +0
-0
6c433300290b..eff7b2d060ed100644lib/graph/graph_pcap.c +3
-1@@ -7,6 +7,7 @@#include <stdlib.h> #include <unistd.h> +#include <rte_ethdev.h> #include <rte_mbuf.h> #include <rte_pcapng.h> @@ -80,7 +81,8 @@ graph_pcap_default_path_get(char **dir_path) int graph_pcap_file_open(const char *filename) { -int fd; +int fd, ret; +uint16_t portid;char file_name[RTE_GRAPH_PCAP_FILE_SZ ];char *pcap_dir;@@ -114,6 +116,18 @@ graph_pcap_file_open(const char *filename)return -1 ;
lib/graph/graph_pcap.c graph_pcap_file_open(const char *filename) · line 126
Quoted 10 lines
lib/graph/graph_pcap.c +7
-0} +/* Add the configured interfaces as possible capture ports */ +RTE_ETH_FOREACH_DEV (portid) { + ret =rte_pcapng_add_interface (pcapng_fd, portid, +NULL ,NULL ,NULL ); +if (ret <0 ) { + graph_err("Graph rte_pcapng_add_interface failed: %d", + ret);
In error case, pcapng_fd shall be closed. rte_pcapng_close(pcapng_fd).
Quoted 10 lines
lib/graph/graph_pcap.c +5
-0+close (fd); +return -1 ; + } + } + done:return 0 ;}
--
2.39.2
with above change, looks good to me.
Amit Prakash Shukla
Acked-byQuoted 80 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Wednesday, May 31, 2023 10:58 PM
To: [email protected]
Cc: Stephen Hemminger <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Kiran Kumar Kokkilagadda <[email protected]>; Nithin Kumar Dabilpuram <[email protected]>
Subject: [EXT] [PATCH v2] graph: fix pcapng file supportExternal Email
----------------------------------------------------------------------
The interface torte_pcapngchanged in last release so that the interfaces used need to be added to the pcapng file via the API. If this step is missing the pcapng file will not be valid and can't be read by wireshark etc.Fixes d1da6d0d04c7 ("pcapng: require per-interface information")Signed-off-by Stephen Hemminger <[email protected]>--- lib/graph/graph_pcap.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)lib/graph/graph_pcap.c +22
-3@@ -7,6 +7,7 @@#include <stdlib.h> #include <unistd.h> +#include <rte_ethdev.h> #include <rte_mbuf.h> #include <rte_pcapng.h> @@ -80,7 +81,8 @@ graph_pcap_default_path_get(char **dir_path)int graph_pcap_file_open (const char *filename) { -int fd; +int fd, ret; +uint16_t portid;char file_name[RTE_GRAPH_PCAP_FILE_SZ ];char *pcap_dir;@@ -110,12 +112,29 @@ graph_pcap_file_open(const char *filename) NULL);if (pcapng_fd ==NULL ) {graph_err ("Graph rte_pcapng_fdopen failed." ); -close (fd); -return -1 ; + goto error; + } + +/* Add the configured interfaces as possible capture ports */ +RTE_ETH_FOREACH_DEV (portid) { + ret =rte_pcapng_add_interface (pcapng_fd, portid, +NULL ,NULL ,NULL ); +if (ret <0 ) { + graph_err("Graph rte_pcapng_add_interface port %u failed: %d", + portid, ret); + goto error; + } } done:return 0 ; +error: +if (pcapng_fd !=NULL ) { +rte_pcapng_close (pcapng_fd); + pcapng_fd =NULL ; + } +close (fd); +return -1 ; }
Quoted 3 lines
int
--
2.39.2
Looks good to me. Thanks.
Thomas Monjalon
AppliedQuoted 11 lines
Quoted 7 lines
The interface to
rte_pcapngchanged in last release so that the interfaces used need to be added to the pcapng file via the API. If this step is missing the pcapng file will not be valid and can't be read by wireshark etc.Fixes d1da6d0d04c7 ("pcapng: require per-interface information")Signed-off-by Stephen Hemminger <[email protected]>Looks good to me. Thanks.
Applied, thanks.