🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
3 messages
3 total messages Started by Stephen Hemminger Mon, 30 Nov 2026 17:57
[PATCH iproute2-next v2 1/3] configure: drop leftovers from removed iptables action
#24731
Author: Stephen Hemminger
Date: Mon, 30 Nov 2026 17:57
231 lines
17279 bytes
Commit 45dc10463dd5 ("remove support for iptables action") deleted
tc/m_ipt.c and tc/m_xt.c but left the build glue for them behind.

check_xt_old() and check_xt_old_internal_h() probed for xtables older
than iptables 1.4.5 (2009); nothing has read TC_CONFIG_XT_OLD or
TC_CONFIG_XT_OLD_H since. include/xt-internal.h was the private header
they looked for and is now unused. $IPTC and $IPTL in check_xt() were
never assigned. tc/Makefile still had rules to build m_xt.so and
m_xt_old.so from the deleted sources.

No change to the generated config.mk.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 configure             | 74 ++-----------------------------------------
 include/xt-internal.h | 67 ---------------------------------------
 tc/Makefile           | 13 --------
 3 files changed, 2 insertions(+), 152 deletions(-)
 delete mode 100644 include/xt-internal.h

diff --git a/configure b/configure
index 4e68dd44..d81a6a81 100755
--- a/configure
+++ b/configure
@@ -35,7 +35,7 @@ check_xtables()
 
 check_xt()
 {
-    #check if we have xtables from iptables >= 1.4.5.
+    #check that the xtables library is usable
     cat >$TMPDIR/ipttest.c <<EOF
 #include <xtables.h>
 #include <linux/netfilter.h>
@@ -55,7 +55,7 @@ int main(int argc, char **argv)
 }
 EOF
 
-    if $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL \
+    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"
@@ -63,74 +63,6 @@ EOF
     rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
 }
 
-check_xt_old()
-{
-    # bail if previous XT checks has already succeeded.
-    grep -q TC_CONFIG_XT $CONFIG && return
-
-    #check if we don't need our internal header ..
-    cat >$TMPDIR/ipttest.c <<EOF
-#include <xtables.h>
-char *lib_dir;
-unsigned int global_option_offset = 0;
-const char *program_version = XTABLES_VERSION;
-const char *program_name = "tc-ipt";
-struct afinfo afinfo = {
-	.libprefix      = "libxt_",
-};
-
-void exit_error(enum exittype status, const char *msg, ...)
-{
-}
-
-int main(int argc, char **argv) {
-
-	return 0;
-}
-
-EOF
-
-    if $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl >/dev/null 2>&1; then
-	echo "TC_CONFIG_XT_OLD:=y" >>$CONFIG
-	echo "using old xtables (no need for xt-internal.h)"
-    fi
-    rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
-}
-
-check_xt_old_internal_h()
-{
-    # bail if previous XT checks has already succeeded.
-    grep -q TC_CONFIG_XT $CONFIG && return
-
-    #check if we need our own internal.h
-    cat >$TMPDIR/ipttest.c <<EOF
-#include <xtables.h>
-#include "xt-internal.h"
-char *lib_dir;
-unsigned int global_option_offset = 0;
-const char *program_version = XTABLES_VERSION;
-const char *program_name = "tc-ipt";
-struct afinfo afinfo = {
-	.libprefix      = "libxt_",
-};
-
-void exit_error(enum exittype status, const char *msg, ...)
-{
-}
-
-int main(int argc, char **argv) {
-
-	return 0;
-}
-
-EOF
-	if $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl >/dev/null 2>&1; then
-	    echo "using old xtables with xt-internal.h"
-	    echo "TC_CONFIG_XT_OLD_H:=y" >>$CONFIG
-	fi
-	rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
-}
-
 check_lib_dir()
 {
 	LIBDIR=$(echo $LIBDIR | sed "s|\${prefix}|$PREFIX|")
@@ -501,8 +433,6 @@ check_xtables
 if ! grep -q TC_CONFIG_NO_XT $CONFIG; then
 	echo -n " IPT	"
 	check_xt
-	check_xt_old
-	check_xt_old_internal_h
 
 	echo -n " IPSET  "
 	check_ipset
diff --git a/include/xt-internal.h b/include/xt-internal.h
deleted file mode 100644
index 07216140..00000000
--- a/include/xt-internal.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _XTABLES_INTERNAL_H
-#define _XTABLES_INTERNAL_H 1
-
-#ifndef XT_LIB_DIR
-#	define XT_LIB_DIR "/lib/xtables"
-#endif
-
-/* protocol family dependent information */
-struct afinfo {
-	/* protocol family */
-	int family;
-
-	/* prefix of library name (ex "libipt_" */
-	char *libprefix;
-
-	/* used by setsockopt (ex IPPROTO_IP */
-	int ipproto;
-
-	/* kernel module (ex "ip_tables" */
-	char *kmod;
-
-	/* optname to check revision support of match */
-	int so_rev_match;
-
-	/* optname to check revision support of match */
-	int so_rev_target;
-};
-
-enum xt_tryload {
-	DONT_LOAD,
-	DURING_LOAD,
-	TRY_LOAD,
-	LOAD_MUST_SUCCEED
-};
-
-struct xtables_rule_match {
-	struct xtables_rule_match *next;
-	struct xtables_match *match;
-	/* Multiple matches of the same type: the ones before
-	   the current one are completed from parsing point of view */
-	unsigned int completed;
-};
-
-extern char *lib_dir;
-
-extern void *fw_calloc(size_t count, size_t size);
-extern void *fw_malloc(size_t size);
-
-extern const char *modprobe_program;
-extern int xtables_insmod(const char *modname, const char *modprobe, int quiet);
-extern int load_xtables_ko(const char *modprobe, int quiet);
-
-/* This is decleared in ip[6]tables.c */
-extern struct afinfo afinfo;
-
-/* Keeping track of external matches and targets: linked lists.  */
-extern struct xtables_match *xtables_matches;
-extern struct xtables_target *xtables_targets;
-
-extern struct xtables_match *find_match(const char *name, enum xt_tryload,
-					struct xtables_rule_match **match);
-extern struct xtables_target *find_target(const char *name, enum xt_tryload);
-
-extern void _init(void);
-
-#endif /* _XTABLES_INTERNAL_H */
diff --git a/tc/Makefile b/tc/Makefile
index 6264a772..0e48ba38 100644
--- a/tc/Makefile
+++ b/tc/Makefile
@@ -132,24 +132,11 @@ install: all
 	for i in $(TCSO); \
 	do install -m 755 $$i $(MODDESTDIR); \
 	done
-	if [ ! -f $(MODDESTDIR)/m_ipt.so ]; then \
-	if [ -f $(MODDESTDIR)/m_xt.so ]; \
-		then ln -s m_xt.so $(MODDESTDIR)/m_ipt.so ; \
-	elif [ -f $(MODDESTDIR)/m_xt_old.so ]; \
-		then ln -s m_xt_old.so $(MODDESTDIR)/m_ipt.so ; \
-	fi; \
-	fi
 
 clean:
 	rm -f $(TCOBJ) $(TCLIB) libtc.a tc *.so emp_ematch.tab.h; \
 	rm -f emp_ematch.tab.*
 
-m_xt.so: m_xt.c
-	$(QUIET_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -shared -fpic -o m_xt.so m_xt.c $$($(PKG_CONFIG) xtables --cflags --libs)
-
-m_xt_old.so: m_xt_old.c
-	$(QUIET_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -shared -fpic -o m_xt_old.so m_xt_old.c $$($(PKG_CONFIG) xtables --cflags --libs)
-
 em_ipset.o: CFLAGS += $$($(PKG_CONFIG) xtables --cflags)
 
 em_ipt.o: CFLAGS += $$($(PKG_CONFIG) xtables --cflags)
-- 
2.53.0
[PATCH iproute2-next v2 2/3] configure: remove dead ipset compat block and IP_CONFIG_SETNS
#24732
Author: Stephen Hemminger
Date: Mon, 30 Nov 2026 17:57
42 lines
12222 bytes
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
[PATCH iproute2-next v2 3/3] configure: use pkg-config instead of hand-rolled probes
#24733
Author: Stephen Hemminger
Date: Mon, 30 Nov 2026 17:57
295 lines
18972 bytes
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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads