* [PATCH iproute2-next v2 2/3] configure: remove dead ipset compat block and IP_CONFIG_SETNS
2026-11-30 17:57 [PATCH iproute2-next v2 1/3] configure: drop leftovers from removed iptables action Stephen Hemminger
@ 2026-11-30 17:57 ` Stephen Hemminger
2026-11-30 17:57 ` [PATCH iproute2-next v2 3/3] configure: use pkg-config instead of hand-rolled probes Stephen Hemminger
1 sibling, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2026-11-30 17:57 UTC (permalink / raw)
To: netdev; +Cc: dsahern, jhs, Stephen Hemminger
check_ipset() had a fallback guarded by #ifndef IP_SET_INVALID. No
released header has ever defined that macro; ip_set.h spells it
IPSET_INVALID_ID. The guard therefore always fired, defining
IPSET_DIM_MAX as 3 where the header says 6 and ip_set_id_t as unsigned
short where it is __u16. The test only kept working because ip_set.h is
included first and defines both itself.
check_setns() also wrote IP_CONFIG_SETNS, which no makefile reads. The
-DHAVE_SETNS on the next line is what gates the fallback in
include/namespace.h.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
configure | 5 -----
1 file changed, 5 deletions(-)
diff --git a/configure b/configure
index d81a6a81..ef155ab3 100755
--- a/configure
+++ b/configure
@@ -84,7 +84,6 @@ int main(int argc, char **argv)
}
EOF
if $CC -I$INCLUDE -o $TMPDIR/setnstest $TMPDIR/setnstest.c >/dev/null 2>&1; then
- echo "IP_CONFIG_SETNS:=y" >>$CONFIG
echo "yes"
echo "CFLAGS += -DHAVE_SETNS" >>$CONFIG
else
@@ -121,10 +120,6 @@ check_ipset()
{
cat >$TMPDIR/ipsettest.c <<EOF
#include <linux/netfilter/ipset/ip_set.h>
-#ifndef IP_SET_INVALID
-#define IPSET_DIM_MAX 3
-typedef unsigned short ip_set_id_t;
-#endif
#include <linux/netfilter/xt_set.h>
struct xt_set_info info;
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH iproute2-next v2 3/3] configure: use pkg-config instead of hand-rolled probes
2026-11-30 17:57 [PATCH iproute2-next v2 1/3] configure: drop leftovers from removed iptables action Stephen Hemminger
2026-11-30 17:57 ` [PATCH iproute2-next v2 2/3] configure: remove dead ipset compat block and IP_CONFIG_SETNS Stephen Hemminger
@ 2026-11-30 17:57 ` Stephen Hemminger
1 sibling, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2026-11-30 17:57 UTC (permalink / raw)
To: netdev; +Cc: dsahern, jhs, Stephen Hemminger
libselinux, libtirpc, libmnl and libcap each had their own copy of the
same pkg-config block, and the copies had drifted: two wrote LDLIBS
before CFLAGS, two after. Add check_pkg() and use it for all four.
The libbpf version test compiled a program that only existed to fail on
LIBBPF_MAJOR_VERSION < 1. pkg-config --atleast-version=1.0 answers that
without running the compiler.
check_xtables() wrote TC_CONFIG_NO_XT so the caller could grep config.mk
to decide whether to run check_xt(). The symbol never changed anything:
tc/Makefile tested it as the outer guard around an inner TC_CONFIG_XT
test, and without the .pc file the compile test cannot set TC_CONFIG_XT
anyway. Fold the existence test into check_xt(), which now also prints
yes/no like the other probes.
The setns, name_to_handle_at and strlcpy probes stay as compile tests
since libc has no .pc file, check_ipset() reads kernel headers, and
mnl_attr_get_uint() is in no released libmnl so there is no version to
compare against.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
configure | 146 ++++++++++++++++++----------------------------------
tc/Makefile | 10 ++--
2 files changed, 53 insertions(+), 103 deletions(-)
diff --git a/configure b/configure
index ef155ab3..bb965538 100755
--- a/configure
+++ b/configure
@@ -26,16 +26,15 @@ check_toolchain()
echo "YACC:=${YACC}" >>$CONFIG
}
-check_xtables()
-{
- if ! ${PKG_CONFIG} xtables --exists; then
- echo "TC_CONFIG_NO_XT:=y" >>$CONFIG
- fi
-}
-
check_xt()
{
- #check that the xtables library is usable
+ # The xtables .pc file can be present while the headers are not
+ # usable, so compile against it rather than trusting --exists.
+ if ! ${PKG_CONFIG} xtables --exists; then
+ echo "no"
+ return
+ fi
+
cat >$TMPDIR/ipttest.c <<EOF
#include <xtables.h>
#include <linux/netfilter.h>
@@ -58,7 +57,9 @@ EOF
if $CC -I$INCLUDE -o $TMPDIR/ipttest $TMPDIR/ipttest.c \
$(${PKG_CONFIG} xtables --cflags --libs) -ldl >/dev/null 2>&1; then
echo "TC_CONFIG_XT:=y" >>$CONFIG
- echo "using xtables"
+ echo "yes"
+ else
+ echo "no"
fi
rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
}
@@ -72,6 +73,26 @@ check_lib_dir()
echo "LIBDIR:=$LIBDIR" >> $CONFIG
}
+# check_pkg <pkg-config module> <make variable> <cpp define>
+#
+# Most optional libraries follow the same shape: if pkg-config knows the
+# module, export a HAVE_ make variable for the Makefiles, add -DHAVE_ for
+# the sources, and append the module's cflags and libs.
+check_pkg()
+{
+ local mod="$1" var="$2" def="$3"
+
+ if ! ${PKG_CONFIG} "$mod" --exists; then
+ echo "no"
+ return 1
+ fi
+
+ echo "yes"
+ echo "$var:=y" >>$CONFIG
+ echo "CFLAGS += -D$def" "$(${PKG_CONFIG} "$mod" --cflags)" >>$CONFIG
+ echo 'LDLIBS +=' "$(${PKG_CONFIG} "$mod" --libs)" >>$CONFIG
+}
+
check_setns()
{
cat >$TMPDIR/setnstest.c <<EOF
@@ -144,36 +165,15 @@ EOF
check_elf()
{
- if ${PKG_CONFIG} libelf --exists; then
- echo "yes"
-
- echo 'CFLAGS += ' "$(${PKG_CONFIG} libelf --cflags)" >> $CONFIG
- echo 'LDLIBS += ' "$(${PKG_CONFIG} libelf --libs)" >>$CONFIG
- else
+ if ! ${PKG_CONFIG} libelf --exists; then
echo "no"
echo " libelf is required, install libelf-dev or elfutils-libelf-devel"
exit 1
fi
-}
-have_libbpf_basic()
-{
- cat >$TMPDIR/libbpf_test.c <<EOF
-#include <bpf/libbpf.h>
-#if LIBBPF_MAJOR_VERSION < 1
-#error libbpf 1.0 or later is required
-#endif
-int main(int argc, char **argv) {
- bpf_object__open_file(NULL, NULL);
- return 0;
-}
-EOF
-
- $CC -o $TMPDIR/libbpf_test $TMPDIR/libbpf_test.c $LIBBPF_CFLAGS $LIBBPF_LDLIBS >/dev/null 2>&1
- local ret=$?
-
- rm -f $TMPDIR/libbpf_test.c $TMPDIR/libbpf_test
- return $ret
+ echo "yes"
+ echo 'CFLAGS += ' "$(${PKG_CONFIG} libelf --cflags)" >> $CONFIG
+ echo 'LDLIBS += ' "$(${PKG_CONFIG} libelf --libs)" >>$CONFIG
}
check_libbpf()
@@ -185,51 +185,22 @@ check_libbpf()
exit 1
fi
- LIBBPF_CFLAGS=$(${PKG_CONFIG} libbpf --cflags)
- LIBBPF_LDLIBS=$(${PKG_CONFIG} libbpf --libs)
LIBBPF_VERSION=$(${PKG_CONFIG} libbpf --modversion)
- if ! have_libbpf_basic; then
+ if ! ${PKG_CONFIG} libbpf --atleast-version=1.0; then
echo "no"
echo " libbpf version $LIBBPF_VERSION is too low, please update it to at least 1.0"
exit 1
fi
- echo 'CFLAGS += ' $LIBBPF_CFLAGS >> $CONFIG
+ echo 'CFLAGS += ' "$(${PKG_CONFIG} libbpf --cflags)" >> $CONFIG
echo "CFLAGS += -DLIBBPF_VERSION=\\\"$LIBBPF_VERSION\\\"" >> $CONFIG
- echo 'LDLIBS += ' $LIBBPF_LDLIBS >> $CONFIG
+ echo 'LDLIBS += ' "$(${PKG_CONFIG} libbpf --libs)" >> $CONFIG
echo "yes"
echo " libbpf version $LIBBPF_VERSION"
}
-check_selinux()
-# SELinux is a compile time option in the ss utility
-{
- if ${PKG_CONFIG} libselinux --exists; then
- echo "HAVE_SELINUX:=y" >>$CONFIG
- echo "yes"
-
- echo 'LDLIBS +=' "$(${PKG_CONFIG} --libs libselinux)" >>$CONFIG
- echo 'CFLAGS += -DHAVE_SELINUX' "$(${PKG_CONFIG} --cflags libselinux)" >>$CONFIG
- else
- echo "no"
- fi
-}
-
-check_tirpc()
-{
- if ${PKG_CONFIG} libtirpc --exists; then
- echo "HAVE_RPC:=y" >>$CONFIG
- echo "yes"
-
- echo 'LDLIBS +=' "$(${PKG_CONFIG} --libs libtirpc)" >>$CONFIG
- echo 'CFLAGS += -DHAVE_RPC' "$(${PKG_CONFIG} --cflags libtirpc)" >>$CONFIG
- else
- echo "no"
- fi
-}
-
have_mnl_attr_get_uint()
{
cat >$TMPDIR/mnl_attr_get_uint_test.c <<EOF
@@ -250,18 +221,12 @@ EOF
check_mnl()
{
- if ${PKG_CONFIG} libmnl --exists; then
- echo "HAVE_MNL:=y" >>$CONFIG
- echo "yes"
-
- echo 'CFLAGS += -DHAVE_LIBMNL' "$(${PKG_CONFIG} libmnl --cflags)" >>$CONFIG
- echo 'LDLIBS +=' "$(${PKG_CONFIG} libmnl --libs)" >> $CONFIG
+ check_pkg libmnl HAVE_MNL HAVE_LIBMNL || return
- if have_mnl_attr_get_uint; then
- echo "CFLAGS += -DHAVE_MNL_ATTR_GET_UINT" >>$CONFIG
- fi
- else
- echo "no"
+ # mnl_attr_get_uint() is not in any released libmnl, so there is no
+ # version to test for; lib/mnl_utils.c carries a fallback.
+ if have_mnl_attr_get_uint; then
+ echo "CFLAGS += -DHAVE_MNL_ATTR_GET_UINT" >>$CONFIG
fi
}
@@ -291,19 +256,6 @@ EOF
rm -f $TMPDIR/strtest.c $TMPDIR/strtest
}
-check_cap()
-{
- if ${PKG_CONFIG} libcap --exists; then
- echo "HAVE_CAP:=y" >>$CONFIG
- echo "yes"
-
- echo 'CFLAGS += -DHAVE_LIBCAP' "$(${PKG_CONFIG} libcap --cflags)" >>$CONFIG
- echo 'LDLIBS +=' "$(${PKG_CONFIG} libcap --libs)" >> $CONFIG
- else
- echo "no"
- fi
-}
-
check_color()
{
case "$COLOR" in
@@ -424,11 +376,10 @@ check_toolchain
echo "TC schedulers"
-check_xtables
-if ! grep -q TC_CONFIG_NO_XT $CONFIG; then
- echo -n " IPT "
- check_xt
+echo -n " IPT "
+check_xt
+if grep -q TC_CONFIG_XT $CONFIG; then
echo -n " IPSET "
check_ipset
fi
@@ -442,11 +393,12 @@ check_setns
echo -n "libc has name_to_handle_at: "
check_name_to_handle_at
+# SELinux is a compile time option in the ss utility
echo -n "SELinux support: "
-check_selinux
+check_pkg libselinux HAVE_SELINUX HAVE_SELINUX
echo -n "libtirpc support: "
-check_tirpc
+check_pkg libtirpc HAVE_RPC HAVE_RPC
echo -n "libbpf support: "
check_libbpf
@@ -461,7 +413,7 @@ echo -n "need for strlcpy: "
check_strlcpy
echo -n "libcap support: "
-check_cap
+check_pkg libcap HAVE_CAP HAVE_LIBCAP
echo -n "color output: "
check_color
diff --git a/tc/Makefile b/tc/Makefile
index 0e48ba38..062a5102 100644
--- a/tc/Makefile
+++ b/tc/Makefile
@@ -81,12 +81,10 @@ TCMODULES += q_ets.o
TCSO :=
-ifneq ($(TC_CONFIG_NO_XT),y)
- ifeq ($(TC_CONFIG_XT),y)
- TCMODULES += em_ipt.o
- ifeq ($(TC_CONFIG_IPSET),y)
- TCMODULES += em_ipset.o
- endif
+ifeq ($(TC_CONFIG_XT),y)
+ TCMODULES += em_ipt.o
+ ifeq ($(TC_CONFIG_IPSET),y)
+ TCMODULES += em_ipset.o
endif
endif
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread