Skip to contentSkip to conversation

remove support for iptables action

RFC Superseded Stephen Hemminger 4 participants 6 messages Dec 22, 2023 – Dec 25, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

RFC 1/1 remove support for iptables action

This is a trial ballon to see how wide the impact would be. Also, removes the actions-general doc because it is very out of date and has lots of grammar issues.

Do we want to go this far and kill all of tc-xt?

---
 configure                            | 181 ----------
 doc/actions/actions-general          | 256 --------------
 include/ip6tables.h                  |  21 --
 include/iptables.h                   |  26 --
 include/iptables/internal.h          |  14 -
 include/libiptc/ipt_kernel_headers.h |  16 -
 include/libiptc/libip6tc.h           | 162 ---------
 include/libiptc/libiptc.h            | 173 ---------
 include/libiptc/libxtc.h             |  34 --
 include/libiptc/xtcshared.h          |  21 --
 man/man8/tc-xt.8                     |  42 ---
 tc/Makefile                          |  24 --
 tc/em_ipset.c                        | 260 --------------
 tc/em_ipt.c                          | 207 -----------
 tc/m_ipt.c                           | 511 ---------------------------
 tc/m_xt.c                            | 400 ---------------------
 tc/m_xt_old.c                        | 432 ----------------------
 17 files changed, 2780 deletions(-)
 delete mode 100644 doc/actions/actions-general
 delete mode 100644 include/ip6tables.h
 delete mode 100644 include/iptables.h
 delete mode 100644 include/iptables/internal.h
 delete mode 100644 include/libiptc/ipt_kernel_headers.h
 delete mode 100644 include/libiptc/libip6tc.h
 delete mode 100644 include/libiptc/libiptc.h
 delete mode 100644 include/libiptc/libxtc.h
 delete mode 100644 include/libiptc/xtcshared.h
 delete mode 100644 man/man8/tc-xt.8
 delete mode 100644 tc/em_ipset.c
 delete mode 100644 tc/em_ipt.c
 delete mode 100644 tc/m_ipt.c
 delete mode 100644 tc/m_xt.c
 delete mode 100644 tc/m_xt_old.c
configure +0 -181
index 78bc52c008f8..2a7579e0dbc8 100755
@@ -53,142 +53,6 @@ check_xtables()
 	fi
 }
 
-check_xt()
-{
-    #check if we have xtables from iptables >= 1.4.5.
-    cat >$TMPDIR/ipttest.c <<EOF
-#include <xtables.h>
-#include <linux/netfilter.h>
-static struct xtables_globals test_globals = {
-	.option_offset = 0,
-	.program_name = "tc-ipt",
-	.program_version = XTABLES_VERSION,
-	.orig_opts = NULL,
-	.opts = NULL,
-	.exit_err = NULL,
-};
-
-int main(int argc, char **argv)
-{
-	xtables_init_all(&test_globals, NFPROTO_IPV4);
-	return 0;
-}
-EOF
-
-    if $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL \
-	$(${PKG_CONFIG} xtables --cflags --libs) -ldl >/dev/null 2>&1; then
-	echo "TC_CONFIG_XT:=y" >>$CONFIG
-	echo "using xtables"
-    fi
-    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|")
-
-	echo -n "lib directory: "
-	echo "$LIBDIR"
-	echo "LIBDIR:=$LIBDIR" >> $CONFIG
-}
-
-check_ipt()
-{
-	if ! grep TC_CONFIG_XT $CONFIG > /dev/null; then
-		echo "using iptables"
-	fi
-}
-
-check_ipt_lib_dir()
-{
-	IPT_LIB_DIR=$(${PKG_CONFIG} --variable=xtlibdir xtables)
-	if [ -n "$IPT_LIB_DIR" ]; then
-		echo $IPT_LIB_DIR
-		echo "IPT_LIB_DIR:=$IPT_LIB_DIR" >> $CONFIG
-		return
-	fi
-
-	for dir in /lib /usr/lib /usr/local/lib; do
-		for file in "xtables" "iptables"; do
-			file="$dir/$file/lib*t_*so"
-			if [ -f $file ]; then
-				echo ${file%/*}
-				echo "IPT_LIB_DIR:=${file%/*}" >> $CONFIG
-				return
-			fi
-		done
-	done
-	echo "not found!"
-}
-
 check_setns()
 {
     cat >$TMPDIR/setnstest.c <<EOF
@@ -234,35 +98,6 @@ EOF
     rm -f $TMPDIR/name_to_handle_at_test.c $TMPDIR/name_to_handle_at_test
 }
 
-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;
-#if IPSET_PROTOCOL == 6 || IPSET_PROTOCOL == 7
-int main(void)
-{
-	return IPSET_MAXNAMELEN;
-}
-#else
-#error unknown ipset version
-#endif
-EOF
-
-    if $CC -I$INCLUDE -o $TMPDIR/ipsettest $TMPDIR/ipsettest.c >/dev/null 2>&1; then
-	echo "TC_CONFIG_IPSET:=y" >>$CONFIG
-	echo "yes"
-    else
-	echo "no"
-    fi
-    rm -f $TMPDIR/ipsettest.c $TMPDIR/ipsettest
-}
 
 check_elf()
 {
@@ -620,24 +455,8 @@ echo "TC schedulers"
 echo -n " ATM	"
 check_atm
 
-check_xtables
-if ! grep -q TC_CONFIG_NO_XT $CONFIG; then
-	echo -n " IPT	"
-	check_xt
-	check_xt_old
-	check_xt_old_internal_h
-	check_ipt
-
-	echo -n " IPSET  "
-	check_ipset
-fi
-
 echo
 check_lib_dir
-if ! grep -q TC_CONFIG_NO_XT $CONFIG; then
-	echo -n "iptables modules directory: "
-	check_ipt_lib_dir
-fi
 
 echo -n "libc has setns: "
 check_setns
doc/actions/actions-general deleted +0 -256

256 lines not on this page · raw message

include/ip6tables.h deleted +0 -21
deleted file mode 100644
index bfb286826af5..000000000000
@@ -1,21 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _IP6TABLES_USER_H
-#define _IP6TABLES_USER_H
-
-#include <netinet/ip.h>
-#include <xtables.h>
-#include <libiptc/libip6tc.h>
-#include <iptables/internal.h>
-
-/* Your shared library should call one of these. */
-extern int do_command6(int argc, char *argv[], char **table,
-		       struct xtc_handle **handle, bool restore);
-
-extern int for_each_chain6(int (*fn)(const xt_chainlabel, int, struct xtc_handle *), int verbose, int builtinstoo, struct xtc_handle *handle);
-extern int flush_entries6(const xt_chainlabel chain, int verbose, struct xtc_handle *handle);
-extern int delete_chain6(const xt_chainlabel chain, int verbose, struct xtc_handle *handle);
-void print_rule6(const struct ip6t_entry *e, struct xtc_handle *h, const char *chain, int counters);
-
-extern struct xtables_globals ip6tables_globals;
-
-#endif /*_IP6TABLES_USER_H*/
include/iptables.h deleted +0 -26
deleted file mode 100644
index eb91f2918658..000000000000
@@ -1,26 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _IPTABLES_USER_H
-#define _IPTABLES_USER_H
-
-#include <netinet/ip.h>
-#include <xtables.h>
-#include <libiptc/libiptc.h>
-#include <iptables/internal.h>
-
-/* Your shared library should call one of these. */
-extern int do_command4(int argc, char *argv[], char **table,
-		      struct xtc_handle **handle, bool restore);
-extern int delete_chain4(const xt_chainlabel chain, int verbose,
-			struct xtc_handle *handle);
-extern int flush_entries4(const xt_chainlabel chain, int verbose,
-			struct xtc_handle *handle);
-extern int for_each_chain4(int (*fn)(const xt_chainlabel, int, struct xtc_handle *),
-		int verbose, int builtinstoo, struct xtc_handle *handle);
-extern void print_rule4(const struct ipt_entry *e,
-		struct xtc_handle *handle, const char *chain, int counters);
-
-extern struct xtables_globals iptables_globals;
-
-extern struct xtables_globals xtables_globals;
-
-#endif /*_IPTABLES_USER_H*/
include/iptables/internal.h deleted +0 -14
deleted file mode 100644
index 1fd137250031..000000000000
@@ -1,14 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef IPTABLES_INTERNAL_H
-#define IPTABLES_INTERNAL_H 1
-
-#define IPTABLES_VERSION "1.6.0"
-
-/**
- * Program's own name and version.
- */
-extern const char *program_name, *program_version;
-
-extern int line;
-
-#endif /* IPTABLES_INTERNAL_H */
include/libiptc/ipt_kernel_headers.h deleted +0 -16
deleted file mode 100644
index 3d2a2a3277e9..000000000000
@@ -1,16 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/* This is the userspace/kernel interface for Generic IP Chains,
-   required for libc6. */
-#ifndef _FWCHAINS_KERNEL_HEADERS_H
-#define _FWCHAINS_KERNEL_HEADERS_H
-
-#include <limits.h>
-
-#include <netinet/ip.h>
-#include <netinet/in.h>
-#include <netinet/ip_icmp.h>
-#include <netinet/tcp.h>
-#include <netinet/udp.h>
-#include <net/if.h>
-#include <sys/types.h>
-#endif
include/libiptc/libip6tc.h deleted +0 -162

162 lines not on this page · raw message

include/libiptc/libiptc.h deleted +0 -173

173 lines not on this page · raw message

include/libiptc/libxtc.h deleted +0 -34
deleted file mode 100644
index 1e9596a6e01c..000000000000
@@ -1,34 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _LIBXTC_H
-#define _LIBXTC_H
-/* Library which manipulates filtering rules. */
-
-#include <libiptc/ipt_kernel_headers.h>
-#include <linux/netfilter/x_tables.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef XT_MIN_ALIGN
-/* xt_entry has pointers and u_int64_t's in it, so if you align to
-   it, you'll also align to any crazy matches and targets someone
-   might write */
-#define XT_MIN_ALIGN (__alignof__(struct xt_entry))
-#endif
-
-#ifndef XT_ALIGN
-#define XT_ALIGN(s) (((s) + ((XT_MIN_ALIGN)-1)) & ~((XT_MIN_ALIGN)-1))
-#endif
-
-#define XTC_LABEL_ACCEPT  "ACCEPT"
-#define XTC_LABEL_DROP    "DROP"
-#define XTC_LABEL_QUEUE   "QUEUE"
-#define XTC_LABEL_RETURN  "RETURN"
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _LIBXTC_H */
include/libiptc/xtcshared.h deleted +0 -21
deleted file mode 100644
index 278a58f4eb9f..000000000000
@@ -1,21 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _LIBXTC_SHARED_H
-#define _LIBXTC_SHARED_H 1
-
-typedef char xt_chainlabel[32];
-struct xtc_handle;
-struct xt_counters;
-
-struct xtc_ops {
-	int (*commit)(struct xtc_handle *);
-	void (*free)(struct xtc_handle *);
-	int (*builtin)(const char *, struct xtc_handle *const);
-	int (*is_chain)(const char *, struct xtc_handle *const);
-	int (*flush_entries)(const xt_chainlabel, struct xtc_handle *);
-	int (*create_chain)(const xt_chainlabel, struct xtc_handle *);
-	int (*set_policy)(const xt_chainlabel, const xt_chainlabel,
-			  struct xt_counters *, struct xtc_handle *);
-	const char *(*strerror)(int);
-};
-
-#endif /* _LIBXTC_SHARED_H */
man/man8/tc-xt.8 deleted +0 -42

42 lines not on this page · raw message

tc/Makefile +0 -24
index 9cb0d0edde93..ec98f51f101c 100644
@@ -80,27 +80,6 @@ TCMODULES += q_ets.o
 
 TCSO :=
 
-ifneq ($(TC_CONFIG_NO_XT),y)
-  ifeq ($(TC_CONFIG_XT),y)
-    TCSO += m_xt.so
-    TCMODULES += em_ipt.o
-    ifeq ($(TC_CONFIG_IPSET),y)
-      TCMODULES += em_ipset.o
-    endif
-  else
-    ifeq ($(TC_CONFIG_XT_OLD),y)
-      TCSO += m_xt_old.so
-    else
-      ifeq ($(TC_CONFIG_XT_OLD_H),y)
-        CFLAGS += -DTC_CONFIG_XT_H
-        TCSO += m_xt_old.so
-      else
-        TCMODULES += m_ipt.o
-      endif
-    endif
-  endif
-endif
-
 TCOBJ += $(TCMODULES)
 LDLIBS += -L. -lm
 
@@ -116,9 +95,6 @@ TCLIB += tc_stab.o
 TCLIB += tc_qevent.o
 
 CFLAGS += -DCONFIG_GACT -DCONFIG_GACT_PROB
-ifneq ($(IPT_LIB_DIR),)
-	CFLAGS += -DIPT_LIB_DIR=\"$(IPT_LIB_DIR)\"
-endif
 
 LEX := flex
 CFLAGS += -DYY_NO_INPUT
tc/em_ipset.c deleted +0 -260

260 lines not on this page · raw message

tc/em_ipt.c deleted +0 -207

207 lines not on this page · raw message

tc/m_ipt.c deleted +0 -511

511 lines not on this page · raw message

tc/m_xt.c deleted +0 -400

400 lines not on this page · raw message

tc/m_xt_old.c deleted +0 -432

432 lines not on this page · raw message

Signature · 1 line
2.43.0
#1 lore raw
Quoted 1 line · Stephen Hemminger
 tc/em_ipset.c                        | 260 --------------

Not sure if this is unused, also not related to the iptables/xt action.

#2 lore raw
Quoted 5 lines · Florian Westphal
Quoted 1 line · Stephen Hemminger
 tc/em_ipset.c                        | 260 --------------

Not sure if this is unused, also not related to the iptables/xt action.

Not related, these two files:
tc/em_ipset.c | 260 --------------

 tc/em_ipt.c                          | 207 -----------

Also any changes in configure and Makefile affecting those two.

cheers,
jamal

#3 lore raw
In reply to Florian Westphal
Quoted 4 lines · On Sat, 23 Dec 2023 13:31:03 +0100 Florian Westphal <[email protected]> wrote:
Quoted 1 line · Stephen Hemminger
 tc/em_ipset.c                        | 260 --------------  

Not sure if this is unused, also not related to the iptables/xt action.

There is both the xtables and ematch options to TC. Jamal do you want to remove both, or some subset?

The problematic area for iproute2 seems to be the dependency on libiptables which is not very stable. On the kernel side it is one of the places where lightly tested integration could lead to lots of syszbot errors.

#4 lore raw
Quoted 4 lines · Stephen Hemminger

On Sat, 23 Dec 2023 13:31:03 +0100
Florian Westphal <[email protected]> wrote:

Quoted 8 lines
Quoted 4 lines
Quoted 1 line · Stephen Hemminger
 tc/em_ipset.c                        | 260 --------------

Not sure if this is unused, also not related to the iptables/xt action.

There is both the xtables and ematch options to TC. Jamal do you want to remove both, or some subset?

just the m_ipt/xt (not the em_xxx) which maps to the kernel ipt action (not the em_ipt which is part of a much larger combination of matchers, do "ls net/sched/em*.c", of which matching on ipt is one small part).
There are people still using ematch... (as Eyal just posted to).

Quoted 3 lines

The problematic area for iproute2 seems to be the dependency on libiptables which is not very stable. On the kernel side it is one of the places where lightly tested integration could lead to lots of syszbot errors.

Note: the motivation for removing act_ipt was not syszbot, rather it being overtaken by events. AFAIK, there's never been a syszbot issue with either act_ipt or the ematcher.
I do empathize with your comment on the challenges on the library.

cheers,
jamal

#5 lore raw
In reply to Stephen Hemminger

Hi,

Quoted 7 lines · Stephen Hemminger

This is a trial ballon to see how wide the impact would be. Also, removes the actions-general doc because it is very out of date and has lots of grammar issues.

Do we want to go this far and kill all of tc-xt?

Quoted 15 lines
---
 configure                            | 181 ----------
 doc/actions/actions-general          | 256 --------------
 include/ip6tables.h                  |  21 --
 include/iptables.h                   |  26 --
 include/iptables/internal.h          |  14 -
 include/libiptc/ipt_kernel_headers.h |  16 -
 include/libiptc/libip6tc.h           | 162 ---------
 include/libiptc/libiptc.h            | 173 ---------
 include/libiptc/libxtc.h             |  34 --
 include/libiptc/xtcshared.h          |  21 --
 man/man8/tc-xt.8                     |  42 ---
 tc/Makefile                          |  24 --
 tc/em_ipset.c                        | 260 --------------
 tc/em_ipt.c                          | 207 -----------

FWIW we use em_ipt.

Eyal.