* [PATCH] pcapng: allow any protocol link type for the interface block
@ 2025-05-29 17:16 Schneide
2025-05-29 19:31 ` Stephen Hemminger
2025-05-29 19:57 ` Stephen Hemminger
0 siblings, 2 replies; 3+ messages in thread
From: Schneide @ 2025-05-29 17:16 UTC (permalink / raw)
To: Thomas Monjalon, Reshma Pattan, Stephen Hemminger, Jerin Jacob,
Kiran Kumar K, Nithin Dabilpuram, Zhirun Yan
Cc: dev, Dylan Schneider
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
---
diff --git a/.mailmap b/.mailmap
index d9423aa..7ef0964 100644
--- a/.mailmap
+++ b/.mailmap
@@ -388,6 +388,7 @@
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 3d3c0db..e0e2b26 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 8f2cff3..bcf9972 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/lib/graph/graph_pcap.c b/lib/graph/graph_pcap.c
index 89525f1..46fab8c 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/rte_pcapng.c b/lib/pcapng/rte_pcapng.c
index 16485b2..bed1e14 100644
--- a/lib/pcapng/rte_pcapng.c
+++ b/lib/pcapng/rte_pcapng.c
@@ -205,7 +205,7 @@ 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,
+rte_pcapng_add_interface(rte_pcapng_t *self, uint16_t port, uint16_t link_type,
const char *ifname, const char *ifdescr,
const char *filter)
{
@@ -277,7 +277,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,
};
diff --git a/lib/pcapng/rte_pcapng.h b/lib/pcapng/rte_pcapng.h
index 48f2b57..0a35ec9 100644
--- a/lib/pcapng/rte_pcapng.h
+++ b/lib/pcapng/rte_pcapng.h
@@ -71,6 +71,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 protocol link type of the packets
* @param ifname (optional)
* Interface name to record in the file.
* If not specified, name will be constructed from port
@@ -84,7 +86,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);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] pcapng: allow any protocol link type for the interface block
2025-05-29 17:16 [PATCH] pcapng: allow any protocol link type for the interface block Schneide
@ 2025-05-29 19:31 ` Stephen Hemminger
2025-05-29 19:57 ` Stephen Hemminger
1 sibling, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2025-05-29 19:31 UTC (permalink / raw)
To: Schneide
Cc: Thomas Monjalon, Reshma Pattan, Jerin Jacob, Kiran Kumar K,
Nithin Dabilpuram, Zhirun Yan, dev
[-- Attachment #1: Type: text/plain, Size: 6558 bytes --]
What other packet types would a DPDK app use. The possible type fields are
quite limited see the spec.
Plus it would be an ABI breakage would require versioning.
On Thu, May 29, 2025, 10:16 Schneide <schneide@qti.qualcomm.com> wrote:
> 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
> ---
>
> diff --git a/.mailmap b/.mailmap
> index d9423aa..7ef0964 100644
> --- a/.mailmap
> +++ b/.mailmap
> @@ -388,6 +388,7 @@
> 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 3d3c0db..e0e2b26 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 8f2cff3..bcf9972 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/lib/graph/graph_pcap.c b/lib/graph/graph_pcap.c
> index 89525f1..46fab8c 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/rte_pcapng.c b/lib/pcapng/rte_pcapng.c
> index 16485b2..bed1e14 100644
> --- a/lib/pcapng/rte_pcapng.c
> +++ b/lib/pcapng/rte_pcapng.c
> @@ -205,7 +205,7 @@ 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,
> +rte_pcapng_add_interface(rte_pcapng_t *self, uint16_t port, uint16_t
> link_type,
> const char *ifname, const char *ifdescr,
> const char *filter)
> {
> @@ -277,7 +277,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,
> };
>
> diff --git a/lib/pcapng/rte_pcapng.h b/lib/pcapng/rte_pcapng.h
> index 48f2b57..0a35ec9 100644
> --- a/lib/pcapng/rte_pcapng.h
> +++ b/lib/pcapng/rte_pcapng.h
> @@ -71,6 +71,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 protocol link type of the packets
> * @param ifname (optional)
> * Interface name to record in the file.
> * If not specified, name will be constructed from port
> @@ -84,7 +86,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);
>
>
[-- Attachment #2: Type: text/html, Size: 8889 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] pcapng: allow any protocol link type for the interface block
2025-05-29 17:16 [PATCH] pcapng: allow any protocol link type for the interface block Schneide
2025-05-29 19:31 ` Stephen Hemminger
@ 2025-05-29 19:57 ` Stephen Hemminger
1 sibling, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2025-05-29 19:57 UTC (permalink / raw)
To: Schneide
Cc: Thomas Monjalon, Reshma Pattan, Jerin Jacob, Kiran Kumar K,
Nithin Dabilpuram, Zhirun Yan, dev
[-- Attachment #1: Type: text/plain, Size: 6461 bytes --]
Full list of types is here
https://www.tcpdump.org/linktypes.html
On Thu, May 29, 2025, 10:16 Schneide <schneide@qti.qualcomm.com> wrote:
> 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
> ---
>
> diff --git a/.mailmap b/.mailmap
> index d9423aa..7ef0964 100644
> --- a/.mailmap
> +++ b/.mailmap
> @@ -388,6 +388,7 @@
> 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 3d3c0db..e0e2b26 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 8f2cff3..bcf9972 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/lib/graph/graph_pcap.c b/lib/graph/graph_pcap.c
> index 89525f1..46fab8c 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/rte_pcapng.c b/lib/pcapng/rte_pcapng.c
> index 16485b2..bed1e14 100644
> --- a/lib/pcapng/rte_pcapng.c
> +++ b/lib/pcapng/rte_pcapng.c
> @@ -205,7 +205,7 @@ 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,
> +rte_pcapng_add_interface(rte_pcapng_t *self, uint16_t port, uint16_t
> link_type,
> const char *ifname, const char *ifdescr,
> const char *filter)
> {
> @@ -277,7 +277,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,
> };
>
> diff --git a/lib/pcapng/rte_pcapng.h b/lib/pcapng/rte_pcapng.h
> index 48f2b57..0a35ec9 100644
> --- a/lib/pcapng/rte_pcapng.h
> +++ b/lib/pcapng/rte_pcapng.h
> @@ -71,6 +71,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 protocol link type of the packets
> * @param ifname (optional)
> * Interface name to record in the file.
> * If not specified, name will be constructed from port
> @@ -84,7 +86,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);
>
>
[-- Attachment #2: Type: text/html, Size: 8822 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-05-30 7:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-29 17:16 [PATCH] pcapng: allow any protocol link type for the interface block Schneide
2025-05-29 19:31 ` Stephen Hemminger
2025-05-29 19:57 ` Stephen Hemminger
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).