From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
Jerin Jacob <jerinj@marvell.com>,
Kiran Kumar K <kirankumark@marvell.com>,
Nithin Dabilpuram <ndabilpuram@marvell.com>
Subject: [PATCH v2] graph: fix pcapng file support
Date: Wed, 31 May 2023 10:27:53 -0700 [thread overview]
Message-ID: <20230531172753.65074-1-stephen@networkplumber.org> (raw)
In-Reply-To: <20230530190834.142932-1-stephen@networkplumber.org>
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.
Fixes: d1da6d0d04c7 ("pcapng: require per-interface information")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/graph/graph_pcap.c | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/lib/graph/graph_pcap.c b/lib/graph/graph_pcap.c
index 6c433300290b..db722c375fa7 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;
@@ -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;
}
int
--
2.39.2
next prev parent reply other threads:[~2023-05-31 17:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-30 19:08 [RFT] " Stephen Hemminger
2023-05-31 8:27 ` [EXT] " Amit Prakash Shukla
2023-05-31 17:27 ` Stephen Hemminger [this message]
2023-06-01 11:22 ` [EXT] [PATCH v2] " Amit Prakash Shukla
2023-06-12 20:25 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230531172753.65074-1-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=jerinj@marvell.com \
--cc=kirankumark@marvell.com \
--cc=ndabilpuram@marvell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).