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):

  rte_eth_af_packet.c:1057:41: error: 'PACKET_IGNORE_OUTGOING'
    undeclared (first use in this function)

DPDK requires Linux 5.4, so the driver does not need to support older
kernels. Check for the symbol at configure time and skip the driver
when the headers lack it, instead of failing the whole build.

Fixes: 3db7aa7868b2 ("net/af_packet: use kernel to filter single-queue Rx")

Signed-off-by: Bing Zhao <[email protected]>
---
v2:
- Drop the fallback define and the runtime fallback to PMD filtering.
- Skip the driver in meson when linux/if_packet.h lacks the symbol,
  so the problem is reported at build time (Stephen).

 doc/guides/nics/af_packet.rst     | 2 ++
 drivers/net/af_packet/meson.build | 8 ++++++++
 2 files changed, 10 insertions(+)

diff --git a/doc/guides/nics/af_packet.rst b/doc/guides/nics/af_packet.rst
index 6282f1e18b..44da26854d 100644
--- a/doc/guides/nics/af_packet.rst
+++ b/doc/guides/nics/af_packet.rst
@@ -72,6 +72,8 @@ Prerequisites
 This is a Linux-specific PMD, thus the following prerequisites apply:
 
 *  A Linux Kernel;
+*  Kernel headers defining ``PACKET_IGNORE_OUTGOING`` (Linux 4.20 or later),
+   otherwise the PMD is not built;
 *  A Kernel bound interface to attach to (e.g. a tap interface).
 
 Set up an af_packet interface
diff --git a/drivers/net/af_packet/meson.build 
b/drivers/net/af_packet/meson.build
index f45e4491d4..ce4737010a 100644
--- a/drivers/net/af_packet/meson.build
+++ b/drivers/net/af_packet/meson.build
@@ -4,6 +4,14 @@
 if not is_linux
     build = false
     reason = 'only supported on Linux'
+    subdir_done()
 endif
+
+if not cc.has_header_symbol('linux/if_packet.h', 'PACKET_IGNORE_OUTGOING')
+    build = false
+    reason = 'missing symbol "PACKET_IGNORE_OUTGOING" in "linux/if_packet.h"'
+    subdir_done()
+endif
+
 sources = files('rte_eth_af_packet.c')
 require_iova_in_mbuf = false
-- 
2.34.1

Reply via email to