[PATCH] net/af_packet: fix build with old kernel headers

Stephen Hemminger stephen at networkplumber.org
Sun Nov 8 17:22:11 CET 2026


On Sat, 7 Nov 2026 11:11:54 +0000
Frank Dressler <frank at dressler.pro> wrote:

> On 11/6/26 14:27, Bing Zhao wrote:
> 
>  > 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):  
> 
> On 11/6/26 16:06, Frank Dressler wrote:
>  > If RHEL 8 uses Linux 4.18, [...]
>  > If DPDK needs to stay compatible with RHEL 8, [...]  
> 
> Short version: RHEL itself does't seem to ship any DPDK that is too
> new for its kernel. The RHEL 8 compatibility requirement may instead
> come from NVIDIA's DOCA, which ships DPDK 26.03 on RHEL 8. If so, the
> question is whether upstream DPDK should support that combination, or
> whether it is better handled on the DOCA side. Details below.
> 
> Bing Zhao, is that the use case behind the patch?
> 
> Details:
> I read too much into Bing Zhao's statement that the new code does not
> build with the RHEL 8 kernel. That statement is true.I incorrectly
> assumed RHEL itself ships a DPDK version that is too new for its
> kernel, which is not the case.

The important parts that were missed here.
 - flag should not be accepted if underlying kernel does not support it.
 - failure should be at compile time not runtime.

Either remove this part:

diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index 44f82c0309..ecd4a9801e 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -32,11 +32,6 @@
 #include <unistd.h>
 #include <poll.h>
 
-/* Added in Linux 6.2. Older kernels ignore it. */
-#ifndef PACKET_FANOUT_FLAG_IGNORE_OUTGOING
-#define PACKET_FANOUT_FLAG_IGNORE_OUTGOING 0x4000
-#endif
-
 #define ETH_AF_PACKET_IFACE_ARG                "iface"
 #define ETH_AF_PACKET_NUM_Q_ARG                "qpairs"
 #define ETH_AF_PACKET_BLOCKSIZE_ARG    "blocksz"


Or add a bunch of #ifdef like this.

diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index 44f82c0309..6ffdfd8524 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -32,11 +32,6 @@
 #include <unistd.h>
 #include <poll.h>
 
-/* Added in Linux 6.2. Older kernels ignore it. */
-#ifndef PACKET_FANOUT_FLAG_IGNORE_OUTGOING
-#define PACKET_FANOUT_FLAG_IGNORE_OUTGOING 0x4000
-#endif
-
 #define ETH_AF_PACKET_IFACE_ARG		"iface"
 #define ETH_AF_PACKET_NUM_Q_ARG		"qpairs"
 #define ETH_AF_PACKET_BLOCKSIZE_ARG	"blocksz"
@@ -44,7 +39,10 @@
 #define ETH_AF_PACKET_FRAMECOUNT_ARG	"framecnt"
 #define ETH_AF_PACKET_QDISC_BYPASS_ARG	"qdisc_bypass"
 #define ETH_AF_PACKET_FANOUT_MODE_ARG	"fanout_mode"
-#define ETH_AF_PACKET_IGNORE_OUTGOING_ARG	"ignore_outgoing"
+
+#ifdef PACKET_FANOUT_FLAG_IGNORE_OUTGOING
+#define ETH_AF_PACKET_IGNORE_OUTGOING_ARG "ignore_outgoing"
+#endif
 
 #define DFLT_FRAME_SIZE		(1 << 11)
 #define DFLT_FRAME_COUNT	(1 << 9)
@@ -110,7 +108,9 @@ static const char *valid_arguments[] = {
 	ETH_AF_PACKET_FRAMECOUNT_ARG,
 	ETH_AF_PACKET_QDISC_BYPASS_ARG,
 	ETH_AF_PACKET_FANOUT_MODE_ARG,
+#ifdef ETH_AF_PACKET_IGNORE_OUTGOING_ARG
 	ETH_AF_PACKET_IGNORE_OUTGOING_ARG,
+#endif
 	NULL
 };
 
@@ -1002,6 +1002,7 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
 		goto error;
 	}
 
+#ifdef PACKET_FANOUT_FLAG_IGNORE_OUTGOING
 	/*
 	 * Set the flag opportunistically if multiple queues are requested.
 	 * It takes effect from Linux 6.2. Older kernels ignore it and the
@@ -1009,6 +1010,7 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
 	 */
 	if (ignore_outgoing != 0 && nb_queues > 1)
 		fanout_arg |= PACKET_FANOUT_FLAG_IGNORE_OUTGOING << 16;
+#endif
 
 	for (q = 0; q < nb_queues; q++) {
 		/* Open an AF_PACKET socket for this queue... */
@@ -1053,6 +1055,7 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
 #endif
 		}
 
+#ifdef PACKET_IGNORE_OUTGOING
 		if (ignore_outgoing != 0 && nb_queues == 1) {
 			rc = setsockopt(qsockfd, SOL_PACKET, PACKET_IGNORE_OUTGOING,
 					&ignore_outgoing, sizeof(ignore_outgoing));
@@ -1064,6 +1067,7 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
 				goto error;
 			}
 		}
+#endif
 
 		rc = setsockopt(qsockfd, SOL_PACKET, PACKET_RX_RING, req, sizeof(*req));
 		if (rc == -1) {
@@ -1314,11 +1318,14 @@ rte_eth_from_packet(struct rte_vdev_device *dev,
 			fanout_mode = pair->value;
 			continue;
 		}
+
+#ifdef ETH_AF_PACKET_IGNORE_OUTGOING_ARG
 		if (strstr(pair->key, ETH_AF_PACKET_IGNORE_OUTGOING_ARG) != NULL) {
 			if (parse_uint(pair->key, pair->value, &ignore_outgoing, 1) < 0)
 				return -1;
 			continue;
 		}
+#endif
 	}
 
 	if (framesize > blocksize) {




More information about the dev mailing list