From: Schneide <schneide@qti.qualcomm.com>
To: dev@dpdk.org, Thomas Monjalon <thomas@monjalon.net>,
Reshma Pattan <reshma.pattan@intel.com>,
Stephen Hemminger <stephen@networkplumber.org>,
Jerin Jacob <jerinj@marvell.com>,
Kiran Kumar K <kirankumark@marvell.com>,
Nithin Dabilpuram <ndabilpuram@marvell.com>,
Zhirun Yan <yanzhirun_163@163.com>
Cc: Dylan Schneider <schneide@qti.qualcomm.com>
Subject: [PATCH v3] pcapng: allow any protocol link type for the interface block
Date: Tue, 8 Jul 2025 15:02:45 -0600 [thread overview]
Message-ID: <20250708210245.3967578-1-schneide@qti.qualcomm.com> (raw)
In-Reply-To: <20250609211937.345620-1-schneide@qti.qualcomm.com>
From: Dylan Schneider <schneide@qti.qualcomm.com>
Allow the user to specify protocol link type when creating pcapng files.
This change is needed to specify the protocol type in the pcapng file,
DLT_EN10MB specifies ethernet packets only. This will allow dissectors
for other protocols to be used on files generated by pcapng.
Includes a breaking change to rte_pcapng_add_interface to add link_type
parameter. Existing calls to the function have been updated to pass
DLT_EN10MB for the link type argument.
Fixes: d1da6d0d04c7 ("pcapng: require per-interface information")
Signed-off-by: Dylan Schneider <schneide@qti.qualcomm.com>
Cc: stephen@networkplumber.org
---
.mailmap | 1 +
app/dumpcap/main.c | 4 +--
app/test/test_pcapng.c | 8 +++---
doc/guides/rel_notes/release_25_07.rst | 4 +++
lib/graph/graph_pcap.c | 2 +-
lib/pcapng/meson.build | 2 ++
lib/pcapng/rte_pcapng.c | 22 +++++++++++-----
lib/pcapng/rte_pcapng.h | 35 +++++++++++++++++++++++++-
8 files changed, 64 insertions(+), 14 deletions(-)
diff --git a/.mailmap b/.mailmap
index 37655f4a57..ee0743fdd8 100644
--- a/.mailmap
+++ b/.mailmap
@@ -393,6 +393,7 @@ Dukai Yuan <dukaix.yuan@intel.com>
Dumitru Ceara <dceara@redhat.com> <dumitru.ceara@gmail.com>
Duncan Bellamy <dunk@denkimushi.com>
Dustin Lundquist <dustin@null-ptr.net>
+Dylan Schneider <schneide@qti.qualcomm.com>
Dzmitry Sautsa <dzmitryx.sautsa@intel.com>
Ed Czeck <ed.czeck@atomicrules.com>
Eduard Serra <eserra@vmware.com>
diff --git a/app/dumpcap/main.c b/app/dumpcap/main.c
index 3d3c0dbc66..e0e2b26269 100644
--- a/app/dumpcap/main.c
+++ b/app/dumpcap/main.c
@@ -800,8 +800,8 @@ static dumpcap_out_t create_output(void)
free(os);
TAILQ_FOREACH(intf, &interfaces, next) {
- if (rte_pcapng_add_interface(ret.pcapng, intf->port, intf->ifname,
- intf->ifdescr, intf->opts.filter) < 0)
+ if (rte_pcapng_add_interface(ret.pcapng, intf->port, DLT_EN10MB,
+ intf->ifname, intf->ifdescr, intf->opts.filter) < 0)
rte_exit(EXIT_FAILURE, "rte_pcapng_add_interface %u failed\n",
intf->port);
}
diff --git a/app/test/test_pcapng.c b/app/test/test_pcapng.c
index 8f2cff36c3..bcf99724fa 100644
--- a/app/test/test_pcapng.c
+++ b/app/test/test_pcapng.c
@@ -345,7 +345,7 @@ test_add_interface(void)
}
/* Add interface to the file */
- ret = rte_pcapng_add_interface(pcapng, port_id,
+ ret = rte_pcapng_add_interface(pcapng, port_id, DLT_EN10MB,
NULL, NULL, NULL);
if (ret < 0) {
fprintf(stderr, "can not add port %u\n", port_id);
@@ -353,7 +353,7 @@ test_add_interface(void)
}
/* Add interface with ifname and ifdescr */
- ret = rte_pcapng_add_interface(pcapng, port_id,
+ ret = rte_pcapng_add_interface(pcapng, port_id, DLT_EN10MB,
"myeth", "Some long description", NULL);
if (ret < 0) {
fprintf(stderr, "can not add port %u with ifname\n", port_id);
@@ -361,7 +361,7 @@ test_add_interface(void)
}
/* Add interface with filter */
- ret = rte_pcapng_add_interface(pcapng, port_id,
+ ret = rte_pcapng_add_interface(pcapng, port_id, DLT_EN10MB,
NULL, NULL, "tcp port 8080");
if (ret < 0) {
fprintf(stderr, "can not add port %u with filter\n", port_id);
@@ -406,7 +406,7 @@ test_write_packets(void)
}
/* Add interface to the file */
- ret = rte_pcapng_add_interface(pcapng, port_id,
+ ret = rte_pcapng_add_interface(pcapng, port_id, DLT_EN10MB,
NULL, NULL, NULL);
if (ret < 0) {
fprintf(stderr, "can not add port %u\n", port_id);
diff --git a/doc/guides/rel_notes/release_25_07.rst b/doc/guides/rel_notes/release_25_07.rst
index 6f49bf8f90..5dc19c2b8c 100644
--- a/doc/guides/rel_notes/release_25_07.rst
+++ b/doc/guides/rel_notes/release_25_07.rst
@@ -215,6 +215,10 @@ API Changes
* argparse: The ``rte_argparse_arg`` structure used for defining arguments has been updated.
See ABI changes in the next section for details.
+* pcapng: Changed the API for adding interfaces to include a link type argument.
+ The link type was previously hardcoded to the ethernet link type in the API.
+ This argument is added to ``rte_pcapng_add_interface``.
+ These functions are versioned to retain binary compatibility until the next LTS release.
ABI Changes
-----------
diff --git a/lib/graph/graph_pcap.c b/lib/graph/graph_pcap.c
index 89525f1220..08dcda0d28 100644
--- a/lib/graph/graph_pcap.c
+++ b/lib/graph/graph_pcap.c
@@ -117,7 +117,7 @@ graph_pcap_file_open(const char *filename)
/* Add the configured interfaces as possible capture ports */
RTE_ETH_FOREACH_DEV(portid) {
- ret = rte_pcapng_add_interface(pcapng_fd, portid,
+ ret = rte_pcapng_add_interface(pcapng_fd, portid, DLT_EN10MB,
NULL, NULL, NULL);
if (ret < 0) {
graph_err("Graph rte_pcapng_add_interface port %u failed: %d",
diff --git a/lib/pcapng/meson.build b/lib/pcapng/meson.build
index 4549925d41..3aa7ba5155 100644
--- a/lib/pcapng/meson.build
+++ b/lib/pcapng/meson.build
@@ -5,3 +5,5 @@ sources = files('rte_pcapng.c')
headers = files('rte_pcapng.h')
deps += ['ethdev']
+
+use_function_versioning = true
diff --git a/lib/pcapng/rte_pcapng.c b/lib/pcapng/rte_pcapng.c
index 2a07b4c1f5..22a9917173 100644
--- a/lib/pcapng/rte_pcapng.c
+++ b/lib/pcapng/rte_pcapng.c
@@ -200,11 +200,10 @@ pcapng_section_block(rte_pcapng_t *self,
}
/* Write an interface block for a DPDK port */
-RTE_EXPORT_SYMBOL(rte_pcapng_add_interface)
-int
-rte_pcapng_add_interface(rte_pcapng_t *self, uint16_t port,
- const char *ifname, const char *ifdescr,
- const char *filter)
+RTE_DEFAULT_SYMBOL(26, int, rte_pcapng_add_interface,
+ (rte_pcapng_t *self, uint16_t port, uint16_t link_type,
+ const char *ifname, const char *ifdescr,
+ const char *filter))
{
struct pcapng_interface_block *hdr;
struct rte_eth_dev_info dev_info;
@@ -274,7 +273,7 @@ rte_pcapng_add_interface(rte_pcapng_t *self, uint16_t port,
hdr = (struct pcapng_interface_block *)buf;
*hdr = (struct pcapng_interface_block) {
.block_type = PCAPNG_INTERFACE_BLOCK,
- .link_type = 1, /* DLT_EN10MB - Ethernet */
+ .link_type = link_type,
.block_length = len,
};
@@ -319,6 +318,17 @@ rte_pcapng_add_interface(rte_pcapng_t *self, uint16_t port,
return write(self->outfd, buf, len);
}
+RTE_VERSION_SYMBOL(25, int, rte_pcapng_add_interface,
+ (rte_pcapng_t *self, uint16_t port,
+ const char *ifname, const char *ifdescr,
+ const char *filter))
+{
+ /* Call the new version with a default link_type (Ethernet) */
+ return rte_pcapng_add_interface(self, port, DLT_EN10MB,
+ ifname, ifdescr, filter);
+}
+
+
/*
* Write an Interface statistics block at the end of capture.
*/
diff --git a/lib/pcapng/rte_pcapng.h b/lib/pcapng/rte_pcapng.h
index 48f2b57564..382268ea4a 100644
--- a/lib/pcapng/rte_pcapng.h
+++ b/lib/pcapng/rte_pcapng.h
@@ -28,6 +28,37 @@
extern "C" {
#endif
+/* pcap link types */
+#define DLT_NULL 0 /* BSD loopback encapsulation */
+#define DLT_EN10MB 1 /* Ethernet (10Mb) */
+#define DLT_EN3MB 2 /* Experimental Ethernet (3Mb) */
+#define DLT_AX25 3 /* Amateur Radio AX.25 */
+#define DLT_PRONET 4 /* Proteon ProNET Token Ring */
+#define DLT_CHAOS 5 /* Chaos */
+#define DLT_IEEE802 6 /* 802.5 Token Ring */
+#define DLT_ARCNET 7 /* ARCNET, with BSD-style header */
+#define DLT_SLIP 8 /* Serial Line IP */
+#define DLT_PPP 9 /* Point-to-point Protocol */
+#define DLT_FDDI 10 /* FDDI */
+
+/* User-defined link types */
+#define DLT_USER0 147
+#define DLT_USER1 148
+#define DLT_USER2 149
+#define DLT_USER3 150
+#define DLT_USER4 151
+#define DLT_USER5 152
+#define DLT_USER6 153
+#define DLT_USER7 154
+#define DLT_USER8 155
+#define DLT_USER9 156
+#define DLT_USER10 157
+#define DLT_USER11 158
+#define DLT_USER12 159
+#define DLT_USER13 160
+#define DLT_USER14 161
+#define DLT_USER15 162
+
/* Opaque handle used for functions in this library. */
typedef struct rte_pcapng rte_pcapng_t;
@@ -71,6 +102,8 @@ rte_pcapng_close(rte_pcapng_t *self);
* The handle to the packet capture file
* @param port
* The Ethernet port to report stats on.
+ * @param link_type
+ * The link type (e.g., DLT_EN10MB).
* @param ifname (optional)
* Interface name to record in the file.
* If not specified, name will be constructed from port
@@ -84,7 +117,7 @@ rte_pcapng_close(rte_pcapng_t *self);
* must be added.
*/
int
-rte_pcapng_add_interface(rte_pcapng_t *self, uint16_t port,
+rte_pcapng_add_interface(rte_pcapng_t *self, uint16_t port, uint16_t link_type,
const char *ifname, const char *ifdescr,
const char *filter);
--
2.27.0
next prev parent reply other threads:[~2025-07-08 21:03 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-29 17:16 [PATCH] " Schneide
2025-05-29 19:31 ` Stephen Hemminger
2025-05-29 19:57 ` Stephen Hemminger
2025-06-05 23:02 ` [PATCH v2] " Schneide
2025-06-06 15:13 ` Stephen Hemminger
2025-06-06 21:52 ` Schneide
2025-06-08 22:16 ` Stephen Hemminger
2025-06-08 22:19 ` Stephen Hemminger
2025-06-08 22:23 ` Stephen Hemminger
2025-06-08 22:30 ` Stephen Hemminger
2025-06-08 22:34 ` Stephen Hemminger
2025-06-09 15:51 ` Dylan Schneider
2025-06-09 16:24 ` Stephen Hemminger
2025-06-16 14:29 ` Dylan Schneider
2025-06-24 15:15 ` Dylan Schneider
2025-06-09 21:19 ` Schneide
2025-06-16 18:05 ` Stephen Hemminger
2025-06-26 13:57 ` Stephen Hemminger
2025-06-27 16:05 ` Thomas Monjalon
2025-06-27 17:39 ` Thomas Monjalon
2025-06-27 17:46 ` Dylan Schneider
2025-06-27 18:27 ` Thomas Monjalon
2025-06-30 13:50 ` Dylan Schneider
2025-06-30 14:28 ` Thomas Monjalon
2025-07-02 19:30 ` Dylan Schneider
2025-07-03 13:27 ` Thomas Monjalon
2025-07-03 16:29 ` Dylan Schneider
2025-07-03 16:41 ` Thomas Monjalon
2025-07-08 21:02 ` Schneide [this message]
2025-07-08 21:56 ` [PATCH v3] " Stephen Hemminger
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=20250708210245.3967578-1-schneide@qti.qualcomm.com \
--to=schneide@qti.qualcomm.com \
--cc=dev@dpdk.org \
--cc=jerinj@marvell.com \
--cc=kirankumark@marvell.com \
--cc=ndabilpuram@marvell.com \
--cc=reshma.pattan@intel.com \
--cc=stephen@networkplumber.org \
--cc=thomas@monjalon.net \
--cc=yanzhirun_163@163.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).