From: Bing Zhao <bingz@nvidia.com>
To: <dev@dpdk.org>
Cc: <stephen@networkplumber.org>, <frank@dressler.pro>,
<thomas@monjalon.net>, <david.marchand@redhat.com>
Subject: [PATCH] net/af_packet: fix build with old kernel headers
Date: Fri, 6 Nov 2026 16:27:56 +0200 [thread overview]
Message-ID: <20261106142756.241131-1-bingz@nvidia.com> (raw)
The PACKET_IGNORE_OUTGOING socket option is used unconditionally,
but it was only added to the uapi headers in Linux 4.20. The build
fails on distributions shipping older kernel headers, like RHEL 8
(kernel-headers-4.18.0-193.el8, gcc 8.5.0):
../drivers/net/af_packet/rte_eth_af_packet.c:
In function 'rte_pmd_init_internals':
../drivers/net/af_packet/rte_eth_af_packet.c:1057:41:
error: 'PACKET_IGNORE_OUTGOING' undeclared
(first use in this function); did you mean 'PACKET_OUTGOING'?
rc = setsockopt(qsockfd, SOL_PACKET, PACKET_IGNORE_OUTGOING,
^~~~~~~~~~~~~~~~~~~~~~
PACKET_OUTGOING
../drivers/net/af_packet/rte_eth_af_packet.c:1057:41:
note: each undeclared identifier is reported only once
for each function it appears in
Define the constant when the headers lack it, as is already done for
PACKET_FANOUT_FLAG_IGNORE_OUTGOING.
Kernels older than 4.20 also reject the option with ENOPROTOOPT,
which makes the probe of a single-queue port fail when
ignore_outgoing is enabled. In this case, fall back to filtering
outgoing packets in the PMD, as already done for multi-queue ports
on kernels without PACKET_FANOUT_FLAG_IGNORE_OUTGOING support.
DPDK documents Linux 5.4 as the minimum kernel, but the PMD already
tolerates older kernels for multi-queue ports. Do the same here
instead of failing the probe, for example on the 4.18 kernel of
RHEL 8.
Fixes: 3db7aa7868b2 ("net/af_packet: use kernel to filter single-queue Rx")
Signed-off-by: Bing Zhao <bingz@nvidia.com>
---
doc/guides/nics/af_packet.rst | 1 +
drivers/net/af_packet/rte_eth_af_packet.c | 16 ++++++++++++++--
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/doc/guides/nics/af_packet.rst b/doc/guides/nics/af_packet.rst
index 6282f1e18b..09e79ff392 100644
--- a/doc/guides/nics/af_packet.rst
+++ b/doc/guides/nics/af_packet.rst
@@ -45,6 +45,7 @@ of AF_PACKET for frame reception.
When ``ignore_outgoing`` is set, ``PACKET_IGNORE_OUTGOING`` is set for single-queue ports,
which moves the filtering from the PMD to the kernel.
+This option requires Linux 4.20; on older kernels the PMD does the filtering.
For multi-queue ports ``PACKET_FANOUT_FLAG_IGNORE_OUTGOING`` is set
to achieve the same but this only works from Linux 6.2.
For earlier Linux versions, the PMD does the filtering for multi-queue ports.
diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index 44f82c0309..fbaea57615 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -32,6 +32,11 @@
#include <unistd.h>
#include <poll.h>
+/* Added in Linux 4.20. Older kernels reject it with ENOPROTOOPT. */
+#ifndef PACKET_IGNORE_OUTGOING
+#define PACKET_IGNORE_OUTGOING 23
+#endif
+
/* Added in Linux 6.2. Older kernels ignore it. */
#ifndef PACKET_FANOUT_FLAG_IGNORE_OUTGOING
#define PACKET_FANOUT_FLAG_IGNORE_OUTGOING 0x4000
@@ -916,6 +921,7 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
int qsockfd = -1;
unsigned int i, q, rdsize;
int fanout_arg;
+ bool pmd_filter;
for (k_idx = 0; k_idx < kvlist->count; k_idx++) {
pair = &kvlist->pairs[k_idx];
@@ -1053,10 +1059,16 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
#endif
}
+ pmd_filter = ignore_outgoing != 0 && nb_queues > 1;
if (ignore_outgoing != 0 && nb_queues == 1) {
rc = setsockopt(qsockfd, SOL_PACKET, PACKET_IGNORE_OUTGOING,
&ignore_outgoing, sizeof(ignore_outgoing));
- if (rc == -1) {
+ if (rc == -1 && errno == ENOPROTOOPT) {
+ PMD_LOG(INFO,
+ "%s: PACKET_IGNORE_OUTGOING not supported by kernel, filtering in PMD",
+ name);
+ pmd_filter = true;
+ } else if (rc == -1) {
PMD_LOG_ERRNO(ERR,
"%s: could not set PACKET_IGNORE_OUTGOING "
"on AF_PACKET socket for %s",
@@ -1083,7 +1095,7 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
rx_queue = &((*internals)->rx_queue[q]);
rx_queue->framecount = req->tp_frame_nr;
- rx_queue->ignore_outgoing = ignore_outgoing != 0 && nb_queues > 1;
+ rx_queue->ignore_outgoing = pmd_filter;
rx_queue->map = mmap(NULL, 2 * req->tp_block_size * req->tp_block_nr,
PROT_READ | PROT_WRITE, MAP_SHARED | MAP_LOCKED,
--
2.27.0
next reply other threads:[~2026-11-06 14:28 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 14:27 Bing Zhao [this message]
2026-11-06 14:46 ` [PATCH] net/af_packet: fix build with old kernel headers Thomas Monjalon
2026-11-06 16:06 ` Frank Dressler
2026-11-07 11:11 ` Frank Dressler
2026-11-08 16:22 ` Stephen Hemminger
2026-11-08 18:51 ` Frank Dressler
2026-11-08 20:29 ` Stephen Hemminger
2026-11-09 15:47 ` [PATCH v2] " Bing Zhao
2026-11-09 17:47 ` Stephen Hemminger
2026-11-10 10:39 ` Thomas Monjalon
2026-11-10 12:52 ` Frank Dressler
2026-11-10 13:56 ` Thomas Monjalon
2026-11-10 14:23 ` Frank Dressler
2026-11-10 16:51 ` 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=20261106142756.241131-1-bingz@nvidia.com \
--to=bingz@nvidia.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=frank@dressler.pro \
--cc=stephen@networkplumber.org \
--cc=thomas@monjalon.net \
/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