From: Maayan Kashani <mkashani@nvidia.com>
To: <dev@dpdk.org>
Cc: <mkashani@nvidia.com>, <rasland@nvidia.com>, <stable@dpdk.org>,
"Bruce Richardson" <bruce.richardson@intel.com>,
David Marchand <david.marchand@redhat.com>,
Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH] build: fix libpcap detection with unusable header
Date: Tue, 7 Jul 2026 16:30:28 +0300 [thread overview]
Message-ID: <20260707133028.236546-1-mkashani@nvidia.com> (raw)
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
next reply other threads:[~2026-07-07 13:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 13:30 Maayan Kashani [this message]
2026-07-07 14:16 ` [PATCH] build: fix libpcap detection with unusable header 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
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=20260707133028.236546-1-mkashani@nvidia.com \
--to=mkashani@nvidia.com \
--cc=bruce.richardson@intel.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=rasland@nvidia.com \
--cc=stable@dpdk.org \
--cc=stephen@networkplumber.org \
/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