DPDK patches and discussions
 help / color / mirror / Atom feed
* [RFT] graph: fix pcapng file support
@ 2023-05-30 19:08 Stephen Hemminger
  2023-05-31  8:27 ` [EXT] " Amit Prakash Shukla
  2023-05-31 17:27 ` [PATCH v2] " Stephen Hemminger
  0 siblings, 2 replies; 5+ messages in thread
From: Stephen Hemminger @ 2023-05-30 19:08 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Jerin Jacob, Kiran Kumar K, Nithin Dabilpuram

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.

Fixes: d1da6d0d04c7 ("pcapng: require per-interface information")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/graph/graph_pcap.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/lib/graph/graph_pcap.c b/lib/graph/graph_pcap.c
index 6c433300290b..eff7b2d060ed 100644
--- a/lib/graph/graph_pcap.c
+++ b/lib/graph/graph_pcap.c
@@ -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;
 }
-- 
2.39.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-06-12 20:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-30 19:08 [RFT] graph: fix pcapng file support Stephen Hemminger
2023-05-31  8:27 ` [EXT] " Amit Prakash Shukla
2023-05-31 17:27 ` [PATCH v2] " Stephen Hemminger
2023-06-01 11:22   ` [EXT] " Amit Prakash Shukla
2023-06-12 20:25     ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).