DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] build: fix libpcap detection with unusable header
@ 2026-07-07 13:30 Maayan Kashani
  2026-07-07 14:16 ` Bruce Richardson
  0 siblings, 1 reply; 6+ messages in thread
From: Maayan Kashani @ 2026-07-07 13:30 UTC (permalink / raw)
  To: dev
  Cc: mkashani, rasland, stable, Bruce Richardson, David Marchand,
	Stephen Hemminger

The libpcap detection only checked that the library was present, that
<pcap.h> could be included, and that a trivial program links. None of
these fail when a distribution ships a libpcap-devel package whose
<pcap.h> is empty (present but declaring nothing) while libpcap.so is
installed: has_header() passes on an empty file and the link test does
not reference any pcap symbol. RTE_HAS_LIBPCAP was then set and the
pcap-dependent code (bpf_convert.c, port source/sink, dumpcap) failed
to build with errors such as:

  bpf_convert.c: error: invalid use of undefined type
                 'const struct bpf_insn'

Require an actual pcap declaration (pcap_create) to be visible in the
header before enabling libpcap support, so a broken or empty header
disables the optional pcap features instead of breaking the build.

Fixes: d6024c0a6757 ("build: cleanup libpcap dependent components")
Cc: stable@dpdk.org

Signed-off-by: Maayan Kashani <mkashani@nvidia.com>
---
 config/meson.build | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/config/meson.build b/config/meson.build
index d7f5e55c18f..4bfb8535781 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -290,7 +290,10 @@ if not pcap_dep.found()
     # pcap got a pkg-config file only in 1.9.0
     pcap_dep = cc.find_library(pcap_lib, required: false)
 endif
-if (pcap_dep.found() and cc.has_header('pcap.h', dependencies: pcap_dep)
+# has_header() passes even when pcap.h is empty; require a real declaration.
+if (pcap_dep.found()
+        and cc.has_header_symbol('pcap.h', 'pcap_create', dependencies: pcap_dep,
+                args: '-D_GNU_SOURCE')
         and cc.links(min_c_code, dependencies: pcap_dep))
     dpdk_conf.set('RTE_HAS_LIBPCAP', 1)
     dpdk_extra_ldflags += '-l@0@'.format(pcap_lib)
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-07-08  8:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-07 13:30 [PATCH] build: fix libpcap detection with unusable header Maayan Kashani
2026-07-07 14:16 ` Bruce Richardson
2026-07-08  6:37   ` Maayan Kashani
2026-07-08  7:11     ` Stephen Hemminger
2026-07-08  8:09       ` Maayan Kashani
2026-07-08  7:54     ` Bruce Richardson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox