Skip to contentSkip to conversation

A few more iptables patches

PATCH Applied Jan Engelhardt 3 participants 25 messages Apr 13, 2008 – Apr 14, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Few more patches. The ones you chose not to cherry-pick I have floated upwards in the stg stack, so the following 8 are against svn base r7475.

#1 lore raw

PATCH 1/8 Import iptables-apply

---
 iptables-apply   |  174 ++++++++++++++++++++++++++++++++++++++++++++++
 iptables-apply.8 |   44 ++++++++++++
 2 files changed, 218 insertions(+), 0 deletions(-)
 create mode 100755 iptables-apply
 create mode 100644 iptables-apply.8
iptables-apply new file +174 -0
new file mode 100755
index 0000000..5fec76b
@@ -0,0 +1,174 @@
+#!/bin/bash
+#
+# iptables-apply -- a safer way to update iptables remotely
+#
+# Copyright © Martin F. Krafft <[email protected]>
+# Released under the terms of the Artistic Licence 2.0
+#
+set -eu
+
+PROGNAME="${0##*/}";
+VERSION=1.0
+
+TIMEOUT=10
+DEFAULT_FILE=/etc/network/iptables
+
+function blurb()
+{
+	cat <<-_eof
+	$PROGNAME $VERSION -- a safer way to update iptables remotely
+	_eof
+}
+
+function copyright()
+{
+	cat <<-_eof
+	$PROGNAME is C Martin F. Krafft <[email protected]>.
+
+	The program has been published under the terms of the Artistic Licence 2.0
+	_eof
+}
+
+function about()
+{
+	blurb
+	echo
+	copyright
+}
+
+function usage()
+{
+	cat <<-_eof
+	Usage: $PROGNAME [options] ruleset
+
+	The script will try to apply a new ruleset (as output by iptables-save/read
+	by iptables-restore) to iptables, then prompt the user whether the changes
+	are okay. If the new ruleset cut the existing connection, the user will not
+	be able to answer affirmatively. In this case, the script rolls back to the
+	previous ruleset.
+
+	The following options may be specified, using standard conventions:
+
+	-t | --timeout	Specify the timeout in seconds (default: $TIMEOUT)
+	-V | --version	Display version information
+	-h | --help	Display this help text
+	_eof
+}
+
+SHORTOPTS="t:Vh";
+LONGOPTS="timeout:,version,help";
+
+OPTS=$(getopt -s bash -o "$SHORTOPTS" -l "$LONGOPTS" -n "$PROGNAME" -- "$@") || exit $?
+for opt in $OPTS; do
+	case "$opt" in
+		(-*) unset OPT_STATE;;
+		(*)
+			case "${OPT_STATE:-}" in
+				(SET_TIMEOUT)
+					eval TIMEOUT=$opt
+					case "$TIMEOUT" in
+						([0-9]*) :;;
+						(*)
+							echo "E: non-numeric timeout value." >&2
+							exit 1
+							;;
+					esac
+					;;
+			esac
+			;;
+	esac
+
+	case "$opt" in
+		(-h|--help) usage >&2; exit 0;;
+		(-V|--version) about >&2; exit 0;;
+		(-t|--timeout) OPT_STATE=SET_TIMEOUT;;
+		(--) break;;
+	esac
+	shift
+done
+
+FILE="${1:-$DEFAULT_FILE}";
+
+if [[ -z "$FILE" ]]; then
+	echo "E: missing file argument." >&2
+	exit 1
+fi
+
+if [[ ! -r "$FILE" ]]; then
+	echo "E: cannot read $FILE" >&2
+	exit 2
+fi
+
+case "${0##*/}" in
+	(*6*)
+		SAVE=ip6tables-save
+		RESTORE=ip6tables-restore
+		;;
+	(*)
+		SAVE=iptables-save
+		RESTORE=iptables-restore
+		;;
+esac
+
+COMMANDS=(tempfile "$SAVE" "$RESTORE")
+
+for cmd in "${COMMANDS[@]}"; do
+	if ! command -v $cmd >/dev/null; then
+		echo "E: command not found: $cmd" >&2
+		exit 127
+	fi
+done
+
+umask 0700
+
+TMPFILE=$(tempfile -p iptap)
+trap "rm -f $TMPFILE" EXIT 1 2 3 4 5 6 7 8 10 11 12 13 14 15
+
+if ! "$SAVE" >"$TMPFILE"; then
+	if ! grep -q ipt /proc/modules 2>/dev/null; then
+		echo "E: iptables support lacking from the kernel." >&2
+		exit 3
+	else
+		echo "E: unknown error saving current iptables ruleset." >&2
+		exit 4
+	fi
+fi
+
+[ -x /etc/init.d/fail2ban ] && /etc/init.d/fail2ban stop
+
+echo -n "Applying new ruleset... "
+if ! "$RESTORE" <"$FILE"; then
+	echo "failed."
+	echo "E: unknown error applying new iptables ruleset." >&2
+	exit 5
+else
+	echo done.
+fi
+
+echo -n "Can you establish NEW connections to the machine? (y/N) "
+
+read -n1 -t "${TIMEOUT:-15}" ret 2>&1 || :
+case "${ret:-}" in
+	(y*|Y*)
+		echo
+		echo ... then my job is done. See you next time.
+		;;
+	(*)
+		if [[ -z "${ret:-}" ]]; then
+			echo "apparently not..."
+		else
+			echo
+		fi
+		echo "Timeout. Something happened (or did not). Better play it safe..."
+		echo -n "Reverting to old ruleset... "
+		"$RESTORE" <"$TMPFILE";
+		echo done.
+		exit 255
+		;;
+esac
+
+[ -x /etc/init.d/fail2ban ] && /etc/init.d/fail2ban start
+
+exit 0
+
+# vim:noet:sw=8
iptables-apply.8 new file +44 -0

44 lines not on this page · raw message

Signature · 6 lines
1.5.5.rc3

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw

Re: [PATCH 1/8] Import iptables-apply

Quoted 6 lines · Jan Engelhardt
---
 iptables-apply   |  174 ++++++++++++++++++++++++++++++++++++++++++++++
 iptables-apply.8 |   44 ++++++++++++
 2 files changed, 218 insertions(+), 0 deletions(-)
 create mode 100755 iptables-apply
 create mode 100644 iptables-apply.8

Applied.

#3 lore raw

PATCH 2/8 Add all necessary header files - compilation fix for various cases

In reply to Jan Engelhardt

Allow iptables to compile without a kernel source tree. This implies fixing build for older kernels, such as 2.6.17 which lack xt_SECMARK.h.

---
 Makefile.am                               |    2 +-
 configure.ac                              |   10 ++-
 include/linux/netfilter.h                 |    2 +
 include/linux/netfilter/x_tables.h        |   43 +++++++++++++
 include/linux/netfilter/xt_SECMARK.h      |   26 ++++++++
 include/linux/netfilter_ipv4/ip_tables.h  |   66 +++------------------
 include/linux/netfilter_ipv4/ipt_DSCP.h   |   18 ++++++
 include/linux/netfilter_ipv4/ipt_LOG.h    |   18 ++++++
 include/linux/netfilter_ipv4/ipt_REJECT.h |   20 ++++++
 include/linux/netfilter_ipv4/ipt_TOS.h    |   12 ++++
 include/linux/netfilter_ipv4/ipt_dscp.h   |   21 +++++++
 include/linux/netfilter_ipv4/ipt_owner.h  |   20 ++++++
 include/linux/netfilter_ipv4/ipt_tos.h    |   13 ++++
 include/linux/netfilter_ipv6/ip6_tables.h |   46 +++------------
 include/linux/netfilter_ipv6/ip6t_LOG.h   |   18 ++++++
 libipq/Makefile.am                        |    2 +-
 16 files changed, 238 insertions(+), 99 deletions(-)
 create mode 100644 include/linux/netfilter/xt_SECMARK.h
 create mode 100644 include/linux/netfilter_ipv4/ipt_DSCP.h
 create mode 100644 include/linux/netfilter_ipv4/ipt_LOG.h
 create mode 100644 include/linux/netfilter_ipv4/ipt_REJECT.h
 create mode 100644 include/linux/netfilter_ipv4/ipt_TOS.h
 create mode 100644 include/linux/netfilter_ipv4/ipt_dscp.h
 create mode 100644 include/linux/netfilter_ipv4/ipt_owner.h
 create mode 100644 include/linux/netfilter_ipv4/ipt_tos.h
 create mode 100644 include/linux/netfilter_ipv6/ip6t_LOG.h
Makefile.am +1 -1
index 0a28241..8137c93 100644
@@ -4,7 +4,7 @@ AUTOMAKE_OPTIONS = foreign subdir-objects
 
 regular_CFLAGS  := @regular_CFLAGS@
 kinclude_CFLAGS := @kinclude_CFLAGS@
-AM_CFLAGS        = ${regular_CFLAGS} -I${top_srcdir}/include ${kinclude_CFLAGS}
+AM_CFLAGS        = ${regular_CFLAGS} -I${top_builddir}/include -I${top_srcdir}/include ${kinclude_CFLAGS}
 SUBDIRS         := extensions
 if ENABLE_LIBIPQ
 SUBDIRS         += libipq
configure.ac +7 -3
index 9c42681..10d4380 100644
@@ -8,8 +8,6 @@ AM_PROG_CC_C_O
 AC_DISABLE_STATIC
 AC_PROG_LIBTOOL
 
-kbuilddir="/lib/modules/$(uname -r)/build";
-ksourcedir="/lib/modules/$(uname -r)/source";
 AC_ARG_WITH([kernel],
 	AS_HELP_STRING([--with-kernel=PATH],
 	[Path to kernel source/build directory]),
@@ -45,7 +43,13 @@ regular_CFLAGS="-D_LARGEFILE_SOURCE=1 -D_LARGE_FILES -D_FILE_OFFSET_BITS=64 \
 	-Wmissing-prototypes -Wredundant-decls -Wshadow -Wstrict-prototypes \
 	-Winline -pipe -DIPTABLES_VERSION=\\\"$PACKAGE_VERSION\\\" \
 	-DXTABLES_LIBDIR=\\\"\${xtlibdir}\\\" -DXTABLES_INTERNAL";
-kinclude_CFLAGS="-I\"$kbuilddir/include\" -I\"$ksourcedir/include\"";
+kinclude_CFLAGS="";
+if [[ -n "$kbuilddir" ]]; then
+	kinclude_CFLAGS="$kinclude_CFLAGS -I $kbuilddir/include";
+fi;
+if [[ -n "$ksourcedir" ]]; then
+	kinclude_CFLAGS="$kinclude_CFLAGS -I $ksourcedir/include";
+fi;
 
 AC_SUBST([regular_CFLAGS kinclude_CFLAGS])
 AC_SUBST([kbuilddir])
include/linux/netfilter.h +2 -0
index 3c5b889..6922c7f 100644
@@ -1,6 +1,8 @@
 #ifndef __LINUX_NETFILTER_H
 #define __LINUX_NETFILTER_H
 
+//#include <linux/compiler.h>
+
 /* Responses from hook functions. */
 #define NF_DROP 0
 #define NF_ACCEPT 1
include/linux/netfilter/x_tables.h +43 -0

48 lines not on this page · raw message

include/linux/netfilter/xt_SECMARK.h new file +26 -0
new file mode 100644
index 0000000..c53fbff
@@ -0,0 +1,26 @@
+#ifndef _XT_SECMARK_H_target
+#define _XT_SECMARK_H_target
+
+/*
+ * This is intended for use by various security subsystems (but not
+ * at the same time).
+ *
+ * 'mode' refers to the specific security subsystem which the
+ * packets are being marked for.
+ */
+#define SECMARK_MODE_SEL	0x01		/* SELinux */
+#define SECMARK_SELCTX_MAX	256
+
+struct xt_secmark_target_selinux_info {
+	u_int32_t selsid;
+	char selctx[SECMARK_SELCTX_MAX];
+};
+
+struct xt_secmark_target_info {
+	u_int8_t mode;
+	union {
+		struct xt_secmark_target_selinux_info sel;
+	} u;
+};
+
+#endif /*_XT_SECMARK_H_target */
include/linux/netfilter_ipv4/ip_tables.h +9 -57

95 lines not on this page · raw message

include/linux/netfilter_ipv4/ipt_DSCP.h new file +18 -0
new file mode 100644
index 0000000..3491e52
@@ -0,0 +1,18 @@
+/* iptables module for setting the IPv4 DSCP field
+ *
+ * (C) 2002 Harald Welte <[email protected]>
+ * based on ipt_FTOS.c (C) 2000 by Matthew G. Marsh <[email protected]>
+ * This software is distributed under GNU GPL v2, 1991
+ * 
+ * See RFC2474 for a description of the DSCP field within the IP Header.
+ *
+ * ipt_DSCP.h,v 1.7 2002/03/14 12:03:13 laforge Exp
+*/
+#ifndef _IPT_DSCP_TARGET_H
+#define _IPT_DSCP_TARGET_H
+#include <linux/netfilter_ipv4/ipt_dscp.h>
+#include <linux/netfilter/xt_DSCP.h>
+
+#define ipt_DSCP_info xt_DSCP_info
+
+#endif /* _IPT_DSCP_TARGET_H */
include/linux/netfilter_ipv4/ipt_LOG.h new file +18 -0
new file mode 100644
index 0000000..90fa652
@@ -0,0 +1,18 @@
+#ifndef _IPT_LOG_H
+#define _IPT_LOG_H
+
+/* make sure not to change this without changing netfilter.h:NF_LOG_* (!) */
+#define IPT_LOG_TCPSEQ		0x01	/* Log TCP sequence numbers */
+#define IPT_LOG_TCPOPT		0x02	/* Log TCP options */
+#define IPT_LOG_IPOPT		0x04	/* Log IP options */
+#define IPT_LOG_UID		0x08	/* Log UID owning local socket */
+#define IPT_LOG_NFLOG		0x10	/* Unsupported, don't reuse */
+#define IPT_LOG_MASK		0x1f
+
+struct ipt_log_info {
+	unsigned char level;
+	unsigned char logflags;
+	char prefix[30];
+};
+
+#endif /*_IPT_LOG_H*/
include/linux/netfilter_ipv4/ipt_REJECT.h new file +20 -0
new file mode 100644
index 0000000..4293a1a
@@ -0,0 +1,20 @@
+#ifndef _IPT_REJECT_H
+#define _IPT_REJECT_H
+
+enum ipt_reject_with {
+	IPT_ICMP_NET_UNREACHABLE,
+	IPT_ICMP_HOST_UNREACHABLE,
+	IPT_ICMP_PROT_UNREACHABLE,
+	IPT_ICMP_PORT_UNREACHABLE,
+	IPT_ICMP_ECHOREPLY,
+	IPT_ICMP_NET_PROHIBITED,
+	IPT_ICMP_HOST_PROHIBITED,
+	IPT_TCP_RESET,
+	IPT_ICMP_ADMIN_PROHIBITED
+};
+
+struct ipt_reject_info {
+	enum ipt_reject_with with;      /* reject type */
+};
+
+#endif /*_IPT_REJECT_H*/
include/linux/netfilter_ipv4/ipt_TOS.h new file +12 -0
new file mode 100644
index 0000000..6bf9e1f
@@ -0,0 +1,12 @@
+#ifndef _IPT_TOS_H_target
+#define _IPT_TOS_H_target
+
+#ifndef IPTOS_NORMALSVC
+#define IPTOS_NORMALSVC 0
+#endif
+
+struct ipt_tos_target_info {
+	u_int8_t tos;
+};
+
+#endif /*_IPT_TOS_H_target*/
include/linux/netfilter_ipv4/ipt_dscp.h new file +21 -0
new file mode 100644
index 0000000..4b82ca9
@@ -0,0 +1,21 @@
+/* iptables module for matching the IPv4 DSCP field
+ *
+ * (C) 2002 Harald Welte <[email protected]>
+ * This software is distributed under GNU GPL v2, 1991
+ * 
+ * See RFC2474 for a description of the DSCP field within the IP Header.
+ *
+ * ipt_dscp.h,v 1.3 2002/08/05 19:00:21 laforge Exp
+*/
+#ifndef _IPT_DSCP_H
+#define _IPT_DSCP_H
+
+#include <linux/netfilter/xt_dscp.h>
+
+#define IPT_DSCP_MASK	XT_DSCP_MASK
+#define IPT_DSCP_SHIFT	XT_DSCP_SHIFT
+#define IPT_DSCP_MAX	XT_DSCP_MAX
+
+#define ipt_dscp_info	xt_dscp_info
+
+#endif /* _IPT_DSCP_H */
include/linux/netfilter_ipv4/ipt_owner.h new file +20 -0
new file mode 100644
index 0000000..92f4bda
@@ -0,0 +1,20 @@
+#ifndef _IPT_OWNER_H
+#define _IPT_OWNER_H
+
+/* match and invert flags */
+#define IPT_OWNER_UID	0x01
+#define IPT_OWNER_GID	0x02
+#define IPT_OWNER_PID	0x04
+#define IPT_OWNER_SID	0x08
+#define IPT_OWNER_COMM	0x10
+
+struct ipt_owner_info {
+    uid_t uid;
+    gid_t gid;
+    pid_t pid;
+    pid_t sid;
+    char comm[16];
+    u_int8_t match, invert;	/* flags */
+};
+
+#endif /*_IPT_OWNER_H*/
include/linux/netfilter_ipv4/ipt_tos.h new file +13 -0
new file mode 100644
index 0000000..a21f5df
@@ -0,0 +1,13 @@
+#ifndef _IPT_TOS_H
+#define _IPT_TOS_H
+
+struct ipt_tos_info {
+    u_int8_t tos;
+    u_int8_t invert;
+};
+
+#ifndef IPTOS_NORMALSVC
+#define IPTOS_NORMALSVC 0
+#endif
+
+#endif /*_IPT_TOS_H*/
include/linux/netfilter_ipv6/ip6_tables.h +9 -37

75 lines not on this page · raw message

include/linux/netfilter_ipv6/ip6t_LOG.h new file +18 -0
new file mode 100644
index 0000000..0d0119b
@@ -0,0 +1,18 @@
+#ifndef _IP6T_LOG_H
+#define _IP6T_LOG_H
+
+/* make sure not to change this without changing netfilter.h:NF_LOG_* (!) */
+#define IP6T_LOG_TCPSEQ		0x01	/* Log TCP sequence numbers */
+#define IP6T_LOG_TCPOPT		0x02	/* Log TCP options */
+#define IP6T_LOG_IPOPT		0x04	/* Log IP options */
+#define IP6T_LOG_UID		0x08	/* Log UID owning local socket */
+#define IP6T_LOG_NFLOG		0x10	/* Unsupported, don't use */
+#define IP6T_LOG_MASK		0x1f
+
+struct ip6t_log_info {
+	unsigned char level;
+	unsigned char logflags;
+	char prefix[30];
+};
+
+#endif /*_IPT_LOG_H*/
libipq/Makefile.am +1 -1
index 942a874..d4245e7 100644
@@ -1,6 +1,6 @@
 # -*- Makefile -*-
 
-AM_CFLAGS = ${regular_CFLAGS} -I${top_srcdir}/include
+AM_CFLAGS = ${regular_CFLAGS} -I${top_builddir}/include -I${top_srcdir}/include
 
 libipq_a_SOURCES = libipq.c
 lib_LIBRARIES    = libipq.a
Signature · 1 line
1.5.5.rc3
#4 lore raw

Re: [PATCH 2/8] Add all necessary header files - compilation fix for various cases

Quoted 3 lines · Jan Engelhardt

Allow iptables to compile without a kernel source tree. This implies fixing build for older kernels, such as 2.6.17 which lack xt_SECMARK.h.

My question is still open - what version are these headers based on. Or differently asked: do they include anything not merged upstream yet?

#5 lore raw

Re: [PATCH 2/8] Add all necessary header files - compilation fix for various cases

In reply to Jan Engelhardt
Quoted 3 lines · Jan Engelhardt

Allow iptables to compile without a kernel source tree. This implies fixing build for older kernels, such as 2.6.17 which lack xt_SECMARK.h.

Applied including the extra chunk you sent seperate mail.

#6 lore raw

PATCH 3/8 Install libiptc header files because xtables.h depends on it

In reply to Jan Engelhardt
---
 Makefile.am |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
Makefile.am +3 -0
index 8137c93..bb7dc4f 100644
@@ -75,6 +75,9 @@ man_MANS         := iptables.8 iptables-restore.8 iptables-save.8 \
 CLEANFILES       := iptables.8 ip6tables.8
 if ENABLE_DEVEL
 include_HEADERS  := include/xtables.h include/iptables.h include/ip6tables.h
+iptcdir          := ${includedir}/libiptc
+iptc_HEADERS     := include/libiptc/libxtc.h \
+                    include/libiptc/ipt_kernel_headers.h
 endif
 
 if ENABLE_STATIC
Signature · 1 line
1.5.5.rc3
#7 lore raw

Re: [PATCH 3/8] Install libiptc header files because xtables.h depends on it

Quoted 3 lines · Jan Engelhardt
---
 Makefile.am |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

Applied.

#8 lore raw

PATCH 4/8 iptables: use C99 lists for struct options

In reply to Jan Engelhardt

From: Gáspár Lajos <[email protected]>

---
 ip6tables-restore.c |   18 ++++++------
 ip6tables-save.c    |   12 ++++----
 ip6tables.c         |   60 ++++++++++++++++++++--------------------
 iptables-restore.c  |   20 +++++++-------
 iptables-save.c     |   12 ++++----
 iptables.c          |   64 +++++++++++++++++++++---------------------
 6 files changed, 93 insertions(+), 93 deletions(-)
ip6tables-restore.c +9 -9
index 2c3e95d..c2703dc 100644
@@ -29,15 +29,15 @@
 static int binary = 0, counters = 0, verbose = 0, noflush = 0;
 
 /* Keeping track of external matches and targets.  */
-static struct option options[] = {
-	{ "binary", 0, 0, 'b' },
-	{ "counters", 0, 0, 'c' },
-	{ "verbose", 0, 0, 'v' },
-	{ "test", 0, 0, 't' },
-	{ "help", 0, 0, 'h' },
-	{ "noflush", 0, 0, 'n'},
-	{ "modprobe", 1, 0, 'M'},
-	{ 0 }
+static const struct option options[] = {
+	{.name = "binary",   .has_arg = false, .val = 'b'},
+	{.name = "counters", .has_arg = false, .val = 'c'},
+	{.name = "verbose",  .has_arg = false, .val = 'v'},
+	{.name = "test",     .has_arg = false, .val = 't'},
+	{.name = "help",     .has_arg = false, .val = 'h'},
+	{.name = "noflush",  .has_arg = false, .val = 'n'},
+	{.name = "modprobe", .has_arg = true,  .val = 'M'},
+	{NULL},
 };
 
 static void print_usage(const char *name, const char *version) __attribute__((noreturn));
ip6tables-save.c +6 -6
index e440887..6e2fea5 100644
@@ -24,12 +24,12 @@
 
 static int show_binary = 0, show_counters = 0;
 
-static struct option options[] = {
-	{ "binary", 0, 0, 'b' },
-	{ "counters", 0, 0, 'c' },
-	{ "dump", 0, 0, 'd' },
-	{ "table", 1, 0, 't' },
-	{ 0 }
+static const struct option options[] = {
+	{.name = "binary",   .has_arg = false, .val = 'b'},
+	{.name = "counters", .has_arg = false, .val = 'c'},
+	{.name = "dump",     .has_arg = false, .val = 'd'},
+	{.name = "table",    .has_arg = true,  .val = 't'},
+	{NULL},
 };
 
 
ip6tables.c +30 -30

66 lines not on this page · raw message

iptables-restore.c +10 -10
index f556fa5..ecf7b2d 100644
@@ -26,16 +26,16 @@
 static int binary = 0, counters = 0, verbose = 0, noflush = 0;
 
 /* Keeping track of external matches and targets.  */
-static struct option options[] = {
-	{ "binary", 0, 0, 'b' },
-	{ "counters", 0, 0, 'c' },
-	{ "verbose", 0, 0, 'v' },
-	{ "test", 0, 0, 't' },
-	{ "help", 0, 0, 'h' },
-	{ "noflush", 0, 0, 'n'},
-	{ "modprobe", 1, 0, 'M'},
-	{ "table", 1, 0, 'T'},
-	{ 0 }
+static const struct option options[] = {
+	{.name = "binary",   .has_arg = false, .val = 'b'},
+	{.name = "counters", .has_arg = false, .val = 'c'},
+	{.name = "verbose",  .has_arg = false, .val = 'v'},
+	{.name = "test",     .has_arg = false, .val = 't'},
+	{.name = "help",     .has_arg = false, .val = 'h'},
+	{.name = "noflush",  .has_arg = false, .val = 'n'},
+	{.name = "modprobe", .has_arg = true,  .val = 'M'},
+	{.name = "table",    .has_arg = true,  .val = 'T'},
+	{NULL},
 };
 
 static void print_usage(const char *name, const char *version) __attribute__((noreturn));
iptables-save.c +6 -6
index 1ce2090..4272202 100644
@@ -23,12 +23,12 @@
 
 static int show_binary = 0, show_counters = 0;
 
-static struct option options[] = {
-	{ "binary", 0, 0, 'b' },
-	{ "counters", 0, 0, 'c' },
-	{ "dump", 0, 0, 'd' },
-	{ "table", 1, 0, 't' },
-	{ 0 }
+static const struct option options[] = {
+	{.name = "binary",   .has_arg = false, .val = 'b'},
+	{.name = "counters", .has_arg = false, .val = 'c'},
+	{.name = "dump",     .has_arg = false, .val = 'd'},
+	{.name = "table",    .has_arg = true,  .val = 't'},
+	{NULL},
 };
 
 #define IP_PARTS_NATIVE(n)			\
iptables.c +32 -32

70 lines not on this page · raw message

Signature · 6 lines
1.5.5.rc3

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#9 lore raw

Re: [PATCH 4/8] iptables: use C99 lists for struct options

Quoted 10 lines · Jan Engelhardt

From: Gáspár Lajos <[email protected]>

---
 ip6tables-restore.c |   18 ++++++------
 ip6tables-save.c    |   12 ++++----
 ip6tables.c         |   60 ++++++++++++++++++++--------------------
 iptables-restore.c  |   20 +++++++-------
 iptables-save.c     |   12 ++++----
 iptables.c          |   64 +++++++++++++++++++++---------------------
 6 files changed, 93 insertions(+), 93 deletions(-)

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#10 lore raw

PATCH 5/8 Combine ipt and ip6t manpages

In reply to Jan Engelhardt
---
 extensions/libip6t_TCPMSS.man                      |   42 ----------
 extensions/libip6t_connlimit.man                   |   27 -------
 extensions/libip6t_length.man                      |    4 -
 extensions/libip6t_multiport.man                   |   20 -----
 extensions/libip6t_tcp.man                         |   45 -----------
 extensions/libipt_TRACE.man                        |   10 ---
 extensions/libipt_length.man                       |    4 -
 extensions/libipt_policy.man                       |   48 ------------
 extensions/{libipt_TCPMSS.man => libxt_TCPMSS.man} |    8 +-
 extensions/{libip6t_TRACE.man => libxt_TRACE.man}  |    3 +-
 .../{libipt_connlimit.man => libxt_connlimit.man}  |    0 
 extensions/libxt_length.man                        |    5 +
 .../{libipt_multiport.man => libxt_multiport.man}  |    0 
 .../{libip6t_policy.man => libxt_policy.man}       |    0 
 extensions/{libipt_tcp.man => libxt_tcp.man}       |    0 
 15 files changed, 12 insertions(+), 204 deletions(-)
 delete mode 100644 extensions/libip6t_TCPMSS.man
 delete mode 100644 extensions/libip6t_connlimit.man
 delete mode 100644 extensions/libip6t_length.man
 delete mode 100644 extensions/libip6t_multiport.man
 delete mode 100644 extensions/libip6t_tcp.man
 delete mode 100644 extensions/libipt_TRACE.man
 delete mode 100644 extensions/libipt_length.man
 delete mode 100644 extensions/libipt_policy.man
 rename extensions/{libipt_TCPMSS.man => libxt_TCPMSS.man} (77%)
 rename extensions/{libip6t_TRACE.man => libxt_TRACE.man} (94%)
 rename extensions/{libipt_connlimit.man => libxt_connlimit.man} (100%)
 create mode 100644 extensions/libxt_length.man
 rename extensions/{libipt_multiport.man => libxt_multiport.man} (100%)
 rename extensions/{libip6t_policy.man => libxt_policy.man} (100%)
 rename extensions/{libipt_tcp.man => libxt_tcp.man} (100%)
extensions/libip6t_TCPMSS.man deleted +0 -42
deleted file mode 100644
index b4c357e..0000000
@@ -1,42 +0,0 @@
-This target allows to alter the MSS value of TCP SYN packets, to control
-the maximum size for that connection (usually limiting it to your
-outgoing interface's MTU minus 60).  Of course, it can only be used
-in conjunction with
-.BR "-p tcp" .
-It is only valid in the
-.BR mangle
-table.
-.br
-This target is used to overcome criminally braindead ISPs or servers
-which block ICMPv6 Packet Too Big packets or are unable to send them.
-The symptoms of this problem are that everything works fine from your 
-Linux firewall/router, but machines behind it can never exchange large
-packets:
-.PD 0
-.RS 0.1i
-.TP 0.3i
-1)
-Web browsers connect, then hang with no data received.
-.TP
-2)
-Small mail works fine, but large emails hang.
-.TP
-3)
-ssh works fine, but scp hangs after initial handshaking.
-.RE
-.PD
-Workaround: activate this option and add a rule to your firewall
-configuration like:
-.nf
- ip6tables -t mangle -A FORWARD -p tcp --tcp-flags SYN,RST SYN \\
-             -j TCPMSS --clamp-mss-to-pmtu
-.fi
-.TP
-.BI "--set-mss " "value"
-Explicitly set MSS option to specified value.
-.TP
-.B "--clamp-mss-to-pmtu"
-Automatically clamp MSS value to (path_MTU - 60).
-.TP
-These options are mutually exclusive.
-
extensions/libip6t_connlimit.man deleted +0 -27
deleted file mode 100644
index d1a4447..0000000
@@ -1,27 +0,0 @@
-Allows you to restrict the number of parallel connections to a server per
-client IP address (or client address block).
-.TP
-[\fB!\fR] \fB--connlimit-above \fIn\fR
-Match if the number of existing connections is (not) above \fIn\fR.
-.TP
-\fB--connlimit-mask\fR \fIprefix_length\fR
-Group hosts using the prefix length. For IPv4, this must be a number between
-(including) 0 and 32. For IPv6, between 0 and 128.
-.P
-Examples:
-.TP
-# allow 2 telnet connections per client host
-ip6tables -A INPUT -p tcp --syn --dport 23 -m connlimit --connlimit-above 2 -j REJECT
-.TP
-# you can also match the other way around:
-ip6tables -A INPUT -p tcp --syn --dport 23 -m connlimit ! --connlimit-above 2 -j ACCEPT
-.TP
-# limit the number of parallel HTTP requests to 16 per class C sized \
-network (24 bit netmask)
-ip6tables -p tcp --syn --dport 80 -m connlimit --connlimit-above 16
---connlimit-mask 24 -j REJECT
-.TP
-# limit the number of parallel HTTP requests to 16 for the link local network \
-(ipv6)
-ip6tables -p tcp --syn --dport 80 -s fe80::/64 -m connlimit --connlimit-above
-16 --connlimit-mask 64 -j REJECT
extensions/libip6t_length.man deleted +0 -4
deleted file mode 100644
index d781a04..0000000
@@ -1,4 +0,0 @@
-This module matches the length of the IPv6 payload in octets, or range of it.
-IPv6 header itself isn't counted.
-.TP
-.BR "--length " "[!] \fIlength\fP[:\fIlength\fP]"
extensions/libip6t_multiport.man deleted +0 -20
deleted file mode 100644
index 6f75a6e..0000000
@@ -1,20 +0,0 @@
-This module matches a set of source or destination ports.  Up to 15
-ports can be specified.  It can only be used in conjunction
-with
-.B "-p tcp"
-or
-.BR "-p udp" .
-.TP
-.BR "--source-ports " "\fI[!] port\fP[,\fIport\fP[,\fIport\fP...]]"
-Match if the source port is one of the given ports.  The flag
-.B --sports
-is a convenient alias for this option.
-.TP
-.BR "--destination-ports " "\fI[!] port\fP[,\fIport\fP[,\fIport\fP...]]"
-Match if the destination port is one of the given ports.  The flag
-.B --dports
-is a convenient alias for this option.
-.TP
-.BR "--ports " "\fI[!] port\fP[,\fIport\fP[,\fIport\fP...]]"
-Match if the both the source and destination ports are equal to each
-other and to one of the given ports.
extensions/libip6t_tcp.man deleted +0 -45

45 lines not on this page · raw message

extensions/libipt_TRACE.man deleted +0 -10
deleted file mode 100644
index 7fbe8e7..0000000
@@ -1,10 +0,0 @@
-This target marks packes so that the kernel will log every rule which match 
-the packets as those traverse the tables, chains, rules. (The ipt_LOG module 
-is required for the logging.) The packets are logged with the string prefix: 
-"TRACE: tablename:chainname:type:rulenum " where type can be "rule" for 
-plain rule, "return" for implicit rule at the end of a user defined chain 
-and "policy" for the policy of the built in chains. 
-.br
-It can only be used in the
-.BR raw
-table.
extensions/libipt_length.man deleted +0 -4
deleted file mode 100644
index 43bbdcf..0000000
@@ -1,4 +0,0 @@
-This module matches the length of a packet against a specific value
-or range of values.
-.TP
-.BR "--length " "[!] \fIlength\fP[:\fIlength\fP]"
extensions/libipt_policy.man deleted +0 -48

48 lines not on this page · raw message

extensions/libxt_TCPMSS.man renamed from extensions/libipt_TCPMSS.man +5 -3
similarity index 77%
rename from extensions/libipt_TCPMSS.man
rename to extensions/libxt_TCPMSS.man
index 30668b0..82f93e0 100644
@@ -1,6 +1,7 @@
 This target allows to alter the MSS value of TCP SYN packets, to control
 the maximum size for that connection (usually limiting it to your
-outgoing interface's MTU minus 40).  Of course, it can only be used
+outgoing interface's MTU minus 40 for IPv4 or 60 for IPv6, respectively).
+Of course, it can only be used
 in conjunction with
 .BR "-p tcp" .
 It is only valid in the
@@ -8,7 +9,8 @@ It is only valid in the
 table.
 .br
 This target is used to overcome criminally braindead ISPs or servers
-which block ICMP Fragmentation Needed packets.  The symptoms of this
+which block "ICMP Fragmentation Needed" or "ICMPv6 Packet Too Big"
+packets.  The symptoms of this
 problem are that everything works fine from your Linux
 firewall/router, but machines behind it can never exchange large
 packets:
@@ -36,6 +38,6 @@ configuration like:
 Explicitly set MSS option to specified value.
 .TP
 .B "--clamp-mss-to-pmtu"
-Automatically clamp MSS value to (path_MTU - 40).
+Automatically clamp MSS value to (path_MTU - 40 for IPv4; -60 for IPv6).
 .TP
 These options are mutually exclusive.
extensions/libxt_TRACE.man renamed from extensions/libip6t_TRACE.man +2 -1
similarity index 94%
rename from extensions/libip6t_TRACE.man
rename to extensions/libxt_TRACE.man
index ca3895a..d28c3a0 100644
@@ -1,5 +1,6 @@
 This target marks packes so that the kernel will log every rule which match 
-the packets as those traverse the tables, chains, rules. (The ip6t_LOG module 
+the packets as those traverse the tables, chains, rules. (The ipt_LOG or
+ip6t_LOG module 
 is required for the logging.) The packets are logged with the string prefix: 
 "TRACE: tablename:chainname:type:rulenum " where type can be "rule" for 
 plain rule, "return" for implicit rule at the end of a user defined chain 
extensions/libxt_connlimit.man renamed from extensions/libipt_connlimit.man +0 -0
similarity index 100%
rename from extensions/libipt_connlimit.man
rename to extensions/libxt_connlimit.man
extensions/libxt_length.man new file +5 -0
new file mode 100644
index 0000000..5a8198b
@@ -0,0 +1,5 @@
+This module matches the length of the layer-3 payload (e.g. layer-4 packet)
+f a packet against a specific value
+or range of values.
+.TP
+.BR "--length " "[!] \fIlength\fP[:\fIlength\fP]"
extensions/libxt_multiport.man renamed from extensions/libipt_multiport.man +0 -0
similarity index 100%
rename from extensions/libipt_multiport.man
rename to extensions/libxt_multiport.man
extensions/libxt_policy.man renamed from extensions/libip6t_policy.man +0 -0
similarity index 100%
rename from extensions/libip6t_policy.man
rename to extensions/libxt_policy.man
extensions/libxt_tcp.man renamed from extensions/libipt_tcp.man +0 -0
similarity index 100%
rename from extensions/libipt_tcp.man
rename to extensions/libxt_tcp.man
Signature · 1 line
1.5.5.rc3
#11 lore raw

Re: [PATCH 5/8] Combine ipt and ip6t manpages

Quoted 24 lines · Jan Engelhardt
---
 extensions/libip6t_TCPMSS.man                      |   42 ----------
 extensions/libip6t_connlimit.man                   |   27 -------
 extensions/libip6t_length.man                      |    4 -
 extensions/libip6t_multiport.man                   |   20 -----
 extensions/libip6t_tcp.man                         |   45 -----------
 extensions/libipt_TRACE.man                        |   10 ---
 extensions/libipt_length.man                       |    4 -
 extensions/libipt_policy.man                       |   48 ------------
 extensions/{libipt_TCPMSS.man => libxt_TCPMSS.man} |    8 +-
 extensions/{libip6t_TRACE.man => libxt_TRACE.man}  |    3 +-
 .../{libipt_connlimit.man => libxt_connlimit.man}  |    0 
 extensions/libxt_length.man                        |    5 +
 .../{libipt_multiport.man => libxt_multiport.man}  |    0 
 .../{libip6t_policy.man => libxt_policy.man}       |    0 
 extensions/{libipt_tcp.man => libxt_tcp.man}       |    0 
 15 files changed, 12 insertions(+), 204 deletions(-)
 delete mode 100644 extensions/libip6t_TCPMSS.man
 delete mode 100644 extensions/libip6t_connlimit.man
 delete mode 100644 extensions/libip6t_length.man
 delete mode 100644 extensions/libip6t_multiport.man
 delete mode 100644 extensions/libip6t_tcp.man
 delete mode 100644 extensions/libipt_TRACE.man
 delete mode 100644 extensions/libipt_length.man
Quoted 8 lines
 delete mode 100644 extensions/libipt_policy.man
 rename extensions/{libipt_TCPMSS.man => libxt_TCPMSS.man} (77%)
 rename extensions/{libip6t_TRACE.man => libxt_TRACE.man} (94%)
 rename extensions/{libipt_connlimit.man => libxt_connlimit.man} (100%)
 create mode 100644 extensions/libxt_length.man
 rename extensions/{libipt_multiport.man => libxt_multiport.man} (100%)
 rename extensions/{libip6t_policy.man => libxt_policy.man} (100%)
 rename extensions/{libipt_tcp.man => libxt_tcp.man} (100%)

Please send a unidiff that includes all those renames so I can apply it using "patch".

#12 lore raw

Re: [PATCH 5/8] Combine ipt and ip6t manpages

Quoted 9 lines · Patrick McHardy
Quoted 8 lines
 delete mode 100644 extensions/libipt_policy.man
 rename extensions/{libipt_TCPMSS.man => libxt_TCPMSS.man} (77%)
 rename extensions/{libip6t_TRACE.man => libxt_TRACE.man} (94%)
 rename extensions/{libipt_connlimit.man => libxt_connlimit.man} (100%)
 create mode 100644 extensions/libxt_length.man
 rename extensions/{libipt_multiport.man => libxt_multiport.man} (100%)
 rename extensions/{libip6t_policy.man => libxt_policy.man} (100%)
 rename extensions/{libipt_tcp.man => libxt_tcp.man} (100%)
Quoted 3 lines

Please send a unidiff that includes all those renames so I can apply it using "patch".

commit 94b7a2a14adc13fdd667d3f06212922e21416e43

Author: Jan Engelhardt <[email protected]>
Date:   Thu Feb 14 03:02:55 2008 +0100

Combine ipt and ip6t manpages

extensions/libip6t_TCPMSS.man deleted +0 -42
deleted file mode 100644
index b4c357e..0000000
@@ -1,42 +0,0 @@
-This target allows to alter the MSS value of TCP SYN packets, to control
-the maximum size for that connection (usually limiting it to your
-outgoing interface's MTU minus 60).  Of course, it can only be used
-in conjunction with
-.BR "-p tcp" .
-It is only valid in the
-.BR mangle
-table.
-.br
-This target is used to overcome criminally braindead ISPs or servers
-which block ICMPv6 Packet Too Big packets or are unable to send them.
-The symptoms of this problem are that everything works fine from your 
-Linux firewall/router, but machines behind it can never exchange large
-packets:
-.PD 0
-.RS 0.1i
-.TP 0.3i
-1)
-Web browsers connect, then hang with no data received.
-.TP
-2)
-Small mail works fine, but large emails hang.
-.TP
-3)
-ssh works fine, but scp hangs after initial handshaking.
-.RE
-.PD
-Workaround: activate this option and add a rule to your firewall
-configuration like:
-.nf
- ip6tables -t mangle -A FORWARD -p tcp --tcp-flags SYN,RST SYN \\
-             -j TCPMSS --clamp-mss-to-pmtu
-.fi
-.TP
-.BI "--set-mss " "value"
-Explicitly set MSS option to specified value.
-.TP
-.B "--clamp-mss-to-pmtu"
-Automatically clamp MSS value to (path_MTU - 60).
-.TP
-These options are mutually exclusive.
-
extensions/libip6t_TRACE.man deleted +0 -10
deleted file mode 100644
index ca3895a..0000000
@@ -1,10 +0,0 @@
-This target marks packes so that the kernel will log every rule which match 
-the packets as those traverse the tables, chains, rules. (The ip6t_LOG module 
-is required for the logging.) The packets are logged with the string prefix: 
-"TRACE: tablename:chainname:type:rulenum " where type can be "rule" for 
-plain rule, "return" for implicit rule at the end of a user defined chain 
-and "policy" for the policy of the built in chains. 
-.br
-It can only be used in the
-.BR raw
-table.
extensions/libip6t_connlimit.man deleted +0 -27
deleted file mode 100644
index d1a4447..0000000
@@ -1,27 +0,0 @@
-Allows you to restrict the number of parallel connections to a server per
-client IP address (or client address block).
-.TP
-[\fB!\fR] \fB--connlimit-above \fIn\fR
-Match if the number of existing connections is (not) above \fIn\fR.
-.TP
-\fB--connlimit-mask\fR \fIprefix_length\fR
-Group hosts using the prefix length. For IPv4, this must be a number between
-(including) 0 and 32. For IPv6, between 0 and 128.
-.P
-Examples:
-.TP
-# allow 2 telnet connections per client host
-ip6tables -A INPUT -p tcp --syn --dport 23 -m connlimit --connlimit-above 2 -j REJECT
-.TP
-# you can also match the other way around:
-ip6tables -A INPUT -p tcp --syn --dport 23 -m connlimit ! --connlimit-above 2 -j ACCEPT
-.TP
-# limit the number of parallel HTTP requests to 16 per class C sized \
-network (24 bit netmask)
-ip6tables -p tcp --syn --dport 80 -m connlimit --connlimit-above 16
---connlimit-mask 24 -j REJECT
-.TP
-# limit the number of parallel HTTP requests to 16 for the link local network \
-(ipv6)
-ip6tables -p tcp --syn --dport 80 -s fe80::/64 -m connlimit --connlimit-above
-16 --connlimit-mask 64 -j REJECT
extensions/libip6t_length.man deleted +0 -4
deleted file mode 100644
index d781a04..0000000
@@ -1,4 +0,0 @@
-This module matches the length of the IPv6 payload in octets, or range of it.
-IPv6 header itself isn't counted.
-.TP
-.BR "--length " "[!] \fIlength\fP[:\fIlength\fP]"
extensions/libip6t_multiport.man deleted +0 -20
deleted file mode 100644
index 6f75a6e..0000000
@@ -1,20 +0,0 @@
-This module matches a set of source or destination ports.  Up to 15
-ports can be specified.  It can only be used in conjunction
-with
-.B "-p tcp"
-or
-.BR "-p udp" .
-.TP
-.BR "--source-ports " "\fI[!] port\fP[,\fIport\fP[,\fIport\fP...]]"
-Match if the source port is one of the given ports.  The flag
-.B --sports
-is a convenient alias for this option.
-.TP
-.BR "--destination-ports " "\fI[!] port\fP[,\fIport\fP[,\fIport\fP...]]"
-Match if the destination port is one of the given ports.  The flag
-.B --dports
-is a convenient alias for this option.
-.TP
-.BR "--ports " "\fI[!] port\fP[,\fIport\fP[,\fIport\fP...]]"
-Match if the both the source and destination ports are equal to each
-other and to one of the given ports.
extensions/libip6t_policy.man deleted +0 -48

48 lines not on this page · raw message

extensions/libip6t_tcp.man deleted +0 -45

45 lines not on this page · raw message

extensions/libipt_TCPMSS.man deleted +0 -41

41 lines not on this page · raw message

extensions/libipt_TRACE.man deleted +0 -10
deleted file mode 100644
index 7fbe8e7..0000000
@@ -1,10 +0,0 @@
-This target marks packes so that the kernel will log every rule which match 
-the packets as those traverse the tables, chains, rules. (The ipt_LOG module 
-is required for the logging.) The packets are logged with the string prefix: 
-"TRACE: tablename:chainname:type:rulenum " where type can be "rule" for 
-plain rule, "return" for implicit rule at the end of a user defined chain 
-and "policy" for the policy of the built in chains. 
-.br
-It can only be used in the
-.BR raw
-table.
extensions/libipt_connlimit.man deleted +0 -27
deleted file mode 100644
index dd6a155..0000000
@@ -1,27 +0,0 @@
-Allows you to restrict the number of parallel connections to a server per
-client IP address (or client address block).
-.TP
-[\fB!\fP] \fB--connlimit-above\fP \fIn\fP
-Match if the number of existing connections is (not) above \fIn\fR.
-.TP
-\fB--connlimit-mask\fR \fIprefix_length\fR
-Group hosts using the prefix length. For IPv4, this must be a number between
-(including) 0 and 32. For IPv6, between 0 and 128.
-.P
-Examples:
-.TP
-# allow 2 telnet connections per client host
-iptables -A INPUT -p tcp --syn --dport 23 -m connlimit --connlimit-above 2 -j REJECT
-.TP
-# you can also match the other way around:
-iptables -A INPUT -p tcp --syn --dport 23 -m connlimit ! --connlimit-above 2 -j ACCEPT
-.TP
-# limit the number of parallel HTTP requests to 16 per class C sized \
-network (24 bit netmask)
-iptables -p tcp --syn --dport 80 -m connlimit --connlimit-above 16
---connlimit-mask 24 -j REJECT
-.TP
-# limit the number of parallel HTTP requests to 16 for the link local network \
-(ipv6)
-ip6tables -p tcp --syn --dport 80 -s fe80::/64 -m connlimit --connlimit-above
-16 --connlimit-mask 64 -j REJECT
extensions/libipt_length.man deleted +0 -4
deleted file mode 100644
index 43bbdcf..0000000
@@ -1,4 +0,0 @@
-This module matches the length of a packet against a specific value
-or range of values.
-.TP
-.BR "--length " "[!] \fIlength\fP[:\fIlength\fP]"
extensions/libipt_multiport.man deleted +0 -20
deleted file mode 100644
index ba760e9..0000000
@@ -1,20 +0,0 @@
-This module matches a set of source or destination ports.  Up to 15
-ports can be specified.  A port range (port:port) counts as two
-ports.  It can only be used in conjunction with
-.B "-p tcp"
-or
-.BR "-p udp" .
-.TP
-.BR "--source-ports " "\fI[!] port\fP[,\fIport\fP[,\fIport:port\fP...]]"
-Match if the source port is one of the given ports.  The flag
-.B --sports
-is a convenient alias for this option.
-.TP
-.BR "--destination-ports " "\fI[!] port\fP[,\fIport\fP[,\fIport:port\fP...]]"
-Match if the destination port is one of the given ports.  The flag
-.B --dports
-is a convenient alias for this option.
-.TP
-.BR "--ports " "\fI[!] port\fP[,\fIport\fP[,\fIport:port\fP...]]"
-Match if either the source or destination ports are equal to one of
-the given ports.
extensions/libipt_policy.man deleted +0 -48

48 lines not on this page · raw message

extensions/libipt_tcp.man deleted +0 -45

45 lines not on this page · raw message

extensions/libxt_TCPMSS.man new file +43 -0

43 lines not on this page · raw message

extensions/libxt_TRACE.man new file +11 -0
new file mode 100644
index 0000000..d28c3a0
@@ -0,0 +1,11 @@
+This target marks packes so that the kernel will log every rule which match 
+the packets as those traverse the tables, chains, rules. (The ipt_LOG or
+ip6t_LOG module 
+is required for the logging.) The packets are logged with the string prefix: 
+"TRACE: tablename:chainname:type:rulenum " where type can be "rule" for 
+plain rule, "return" for implicit rule at the end of a user defined chain 
+and "policy" for the policy of the built in chains. 
+.br
+It can only be used in the
+.BR raw
+table.
extensions/libxt_connlimit.man new file +27 -0
new file mode 100644
index 0000000..dd6a155
@@ -0,0 +1,27 @@
+Allows you to restrict the number of parallel connections to a server per
+client IP address (or client address block).
+.TP
+[\fB!\fP] \fB--connlimit-above\fP \fIn\fP
+Match if the number of existing connections is (not) above \fIn\fR.
+.TP
+\fB--connlimit-mask\fR \fIprefix_length\fR
+Group hosts using the prefix length. For IPv4, this must be a number between
+(including) 0 and 32. For IPv6, between 0 and 128.
+.P
+Examples:
+.TP
+# allow 2 telnet connections per client host
+iptables -A INPUT -p tcp --syn --dport 23 -m connlimit --connlimit-above 2 -j REJECT
+.TP
+# you can also match the other way around:
+iptables -A INPUT -p tcp --syn --dport 23 -m connlimit ! --connlimit-above 2 -j ACCEPT
+.TP
+# limit the number of parallel HTTP requests to 16 per class C sized \
+network (24 bit netmask)
+iptables -p tcp --syn --dport 80 -m connlimit --connlimit-above 16
+--connlimit-mask 24 -j REJECT
+.TP
+# limit the number of parallel HTTP requests to 16 for the link local network \
+(ipv6)
+ip6tables -p tcp --syn --dport 80 -s fe80::/64 -m connlimit --connlimit-above
+16 --connlimit-mask 64 -j REJECT
extensions/libxt_length.man new file +5 -0
new file mode 100644
index 0000000..5a8198b
@@ -0,0 +1,5 @@
+This module matches the length of the layer-3 payload (e.g. layer-4 packet)
+f a packet against a specific value
+or range of values.
+.TP
+.BR "--length " "[!] \fIlength\fP[:\fIlength\fP]"
extensions/libxt_multiport.man new file +20 -0
new file mode 100644
index 0000000..ba760e9
@@ -0,0 +1,20 @@
+This module matches a set of source or destination ports.  Up to 15
+ports can be specified.  A port range (port:port) counts as two
+ports.  It can only be used in conjunction with
+.B "-p tcp"
+or
+.BR "-p udp" .
+.TP
+.BR "--source-ports " "\fI[!] port\fP[,\fIport\fP[,\fIport:port\fP...]]"
+Match if the source port is one of the given ports.  The flag
+.B --sports
+is a convenient alias for this option.
+.TP
+.BR "--destination-ports " "\fI[!] port\fP[,\fIport\fP[,\fIport:port\fP...]]"
+Match if the destination port is one of the given ports.  The flag
+.B --dports
+is a convenient alias for this option.
+.TP
+.BR "--ports " "\fI[!] port\fP[,\fIport\fP[,\fIport:port\fP...]]"
+Match if either the source or destination ports are equal to one of
+the given ports.
extensions/libxt_policy.man new file +48 -0

48 lines not on this page · raw message

extensions/libxt_tcp.man new file +45 -0

45 lines not on this page · raw message

#13 lore raw

Re: [PATCH 5/8] Combine ipt and ip6t manpages

Quoted 9 lines · Jan Engelhardt
Quoted 8 lines · Patrick McHardy
Quoted 8 lines
 delete mode 100644 extensions/libipt_policy.man
 rename extensions/{libipt_TCPMSS.man => libxt_TCPMSS.man} (77%)
 rename extensions/{libip6t_TRACE.man => libxt_TRACE.man} (94%)
 rename extensions/{libipt_connlimit.man => libxt_connlimit.man} (100%)
 create mode 100644 extensions/libxt_length.man
 rename extensions/{libipt_multiport.man => libxt_multiport.man} (100%)
 rename extensions/{libip6t_policy.man => libxt_policy.man} (100%)
 rename extensions/{libipt_tcp.man => libxt_tcp.man} (100%)
Quoted 8 lines
Quoted 3 lines

Please send a unidiff that includes all those renames so I can apply it using "patch".

commit 94b7a2a14adc13fdd667d3f06212922e21416e43

Author: Jan Engelhardt <[email protected]>
Date:   Thu Feb 14 03:02:55 2008 +0100

Combine ipt and ip6t manpages

Applied, thanks.

#14 lore raw

PATCH 6/8 RATEEST: add manpage

In reply to Jan Engelhardt
---
 extensions/libxt_RATEEST.c   |    5 ++---
 extensions/libxt_RATEEST.man |   11 +++++++++++
 2 files changed, 13 insertions(+), 3 deletions(-)
 create mode 100644 extensions/libxt_RATEEST.man
extensions/libxt_RATEEST.c +2 -3
index 4f52c2e..dd7b503 100644
@@ -18,12 +18,11 @@ static void
 RATEEST_help(void)
 {
 	printf(
-"RATEST target v%s options:\n"
+"RATEEST target options:\n"
 "  --rateest-name name		Rate estimator name\n"
 "  --rateest-interval sec	Rate measurement interval in seconds\n"
 "  --rateest-ewmalog value	Rate measurement averaging time constant\n"
-"\n",
-	       IPTABLES_VERSION);
+"\n");
 }
 
 enum RATEEST_options {
extensions/libxt_RATEEST.man new file +11 -0
new file mode 100644
index 0000000..6ad802c
@@ -0,0 +1,11 @@
+The RATEEST target collects statistics, performs rate estimation calculation
+and saves the results for later evaluation using the \fBrateest\fP match.
+.TP
+\fB--rateest-name\fP \fIname\fP
+Count matched packets into the pool referred to by \fIname\fP, which is freely
+choosable.
+.TP
+\fB--rateest-interval\fP \fIamount\fP{\fBs\fP|\fBms\fP|\fBus\fP}
+Rate measurement interval, in seconds, milliseconds or microseconds.
+.TP
+\fB--rateest-ewmalog\fP \fIvalue\fP
Signature · 1 line
1.5.5.rc3
#15 lore raw

Re: [PATCH 6/8] RATEEST: add manpage

Quoted 5 lines · Jan Engelhardt
---
 extensions/libxt_RATEEST.c   |    5 ++---
 extensions/libxt_RATEEST.man |   11 +++++++++++
 2 files changed, 13 insertions(+), 3 deletions(-)
 create mode 100644 extensions/libxt_RATEEST.man

Applied.

#16 lore raw

PATCH 7/8 Remove support for compilation of conditional extensions

In reply to Jan Engelhardt
---
 extensions/.condition-test       |    4 -
 extensions/.condition-test6      |    4 -
 extensions/.set-test             |    4 -
 extensions/GNUmakefile.in        |   27 +----
 extensions/libip6t_condition.c   |   95 ----------------
 extensions/libip6t_condition.man |    4 -
 extensions/libipt_SET.c          |  174 ------------------------------
 extensions/libipt_SET.man        |   16 ---
 extensions/libipt_condition.c    |   94 ----------------
 extensions/libipt_condition.man  |    4 -
 extensions/libipt_set.c          |  161 ---------------------------
 extensions/libipt_set.h          |  104 ------------------
 extensions/libipt_set.man        |   17 ---
 13 files changed, 3 insertions(+), 705 deletions(-)
 delete mode 100755 extensions/.condition-test
 delete mode 100755 extensions/.condition-test6
 delete mode 100755 extensions/.set-test
 delete mode 100644 extensions/libip6t_condition.c
 delete mode 100644 extensions/libip6t_condition.man
 delete mode 100644 extensions/libipt_SET.c
 delete mode 100644 extensions/libipt_SET.man
 delete mode 100644 extensions/libipt_condition.c
 delete mode 100644 extensions/libipt_condition.man
 delete mode 100644 extensions/libipt_set.c
 delete mode 100644 extensions/libipt_set.h
 delete mode 100644 extensions/libipt_set.man
extensions/.condition-test deleted +0 -4
deleted file mode 100755
index 2470a18..0000000
@@ -1,4 +0,0 @@
-#!/bin/sh
-[ "$1" == "provides" -o \
--f "$KERNEL_DIR/include/linux/netfilter_ipv4/ipt_condition.h" ] && \
-echo "condition";
extensions/.condition-test6 deleted +0 -4
deleted file mode 100755
index 15a0f04..0000000
@@ -1,4 +0,0 @@
-#!/bin/sh
-[ "$1" == "provides" -o \
--f "$KERNEL_DIR/include/linux/netfilter_ipv6/ip6t_condition.h" ] && \
-echo "condition";
extensions/.set-test deleted +0 -4
deleted file mode 100755
index 754abfd..0000000
@@ -1,4 +0,0 @@
-#! /bin/sh
-[ "$1" == "provides" -o \
--f "$KERNEL_DIR/include/linux/netfilter_ipv4/ip_set.h" ] && \
-echo "set SET";
extensions/GNUmakefile.in +3 -24
index ee20469..31e6fb7 100644
@@ -32,30 +32,9 @@ endif
 #
 #	Wildcard module list
 #
-pfx_all_mod := $(patsubst ${srcdir}/libxt_%.c,%,$(wildcard ${srcdir}/libxt_*.c))
-pf4_all_mod := $(patsubst ${srcdir}/libipt_%.c,%,$(wildcard ${srcdir}/libipt_*.c))
-pf6_all_mod := $(patsubst ${srcdir}/libip6t_%.c,%,$(wildcard ${srcdir}/libip6t_*.c))
-
-#
-#	Conditional module list
-#
-pfx_cond_mod := $(foreach i,$(wildcard ${srcdir}/.*-testx),$(shell KERNEL_DIR=${ksourcedir} ${i} provides))
-pf4_cond_mod := $(foreach i,$(wildcard ${srcdir}/.*-test),$(shell KERNEL_DIR=${ksourcedir} ${i} provides))
-pf6_cond_mod := $(foreach i,$(wildcard ${srcdir}/.*-test6),$(shell KERNEL_DIR=${ksourcedir} ${i} provides))
-
-#
-#	Conditional modules to build
-#
-pfx_bc_mod := $(foreach i,$(wildcard ${srcdir}/.*-testx),$(shell KERNEL_DIR=${ksourcedir} ${i}))
-pf4_bc_mod := $(foreach i,$(wildcard ${srcdir}/.*-test),$(shell KERNEL_DIR=${ksourcedir} ${i}))
-pf6_bc_mod := $(foreach i,$(wildcard ${srcdir}/.*-test6),$(shell KERNEL_DIR=${ksourcedir} ${i}))
-
-#
-#	Total list of modules to build
-#
-pfx_build_mod := $(filter-out ${pfx_cond_mod},${pfx_all_mod}) ${pfx_bc_mod}
-pf4_build_mod := $(filter-out ${pf4_cond_mod},${pf4_all_mod}) ${pf4_bc_mod}
-pf6_build_mod := $(filter-out ${pf6_cond_mod},${pf6_all_mod}) ${pf6_bc_mod}
+pfx_build_mod := $(patsubst ${srcdir}/libxt_%.c,%,$(wildcard ${srcdir}/libxt_*.c))
+pf4_build_mod := $(patsubst ${srcdir}/libipt_%.c,%,$(wildcard ${srcdir}/libipt_*.c))
+pf6_build_mod := $(patsubst ${srcdir}/libip6t_%.c,%,$(wildcard ${srcdir}/libip6t_*.c))
 pfx_objs      := $(patsubst %,libxt_%.o,${pfx_build_mod})
 pf4_objs      := $(patsubst %,libipt_%.o,${pf4_build_mod})
 pf6_objs      := $(patsubst %,libip6t_%.o,${pf6_build_mod})
extensions/libip6t_condition.c deleted +0 -95

95 lines not on this page · raw message

extensions/libip6t_condition.man deleted +0 -4
deleted file mode 100644
index e0bba75..0000000
@@ -1,4 +0,0 @@
-This matches if a specific /proc filename is '0' or '1'.
-.TP
-.BR "--condition " "[!] \fIfilename"
-Match on boolean value stored in /proc/net/ip6t_condition/filename file
extensions/libipt_SET.c deleted +0 -174

174 lines not on this page · raw message

extensions/libipt_SET.man deleted +0 -16
deleted file mode 100644
index 8f25bea..0000000
@@ -1,16 +0,0 @@
-This modules adds and/or deletes entries from IP sets which can be defined 
-by ipset(8).
-.TP
-.BR "--add-set " "setname flag[,flag...]"
-add the address(es)/port(s) of the packet to the sets
-.TP
-.BR "--del-set " "setname flag[,flag...]"
-delete the address(es)/port(s) of the packet from the sets,
-where flags are
-.BR "src"
-and/or
-.BR "dst"
-and there can be no more than six of them.
-.TP
-The bindings to follow must previously be defined in order to use 
-multilevel adding/deleting by the SET target.
extensions/libipt_condition.c deleted +0 -94

94 lines not on this page · raw message

extensions/libipt_condition.man deleted +0 -4
deleted file mode 100644
index ce2aa95..0000000
@@ -1,4 +0,0 @@
-This matches if a specific /proc filename is '0' or '1'.
-.TP
-.BI "--condition " "[!] \fIfilename\fP"
-Match on boolean value stored in /proc/net/ipt_condition/filename file
extensions/libipt_set.c deleted +0 -161

161 lines not on this page · raw message

extensions/libipt_set.h deleted +0 -104

104 lines not on this page · raw message

extensions/libipt_set.man deleted +0 -17
deleted file mode 100644
index d280577..0000000
@@ -1,17 +0,0 @@
-This modules macthes IP sets which can be defined by ipset(8).
-.TP
-.BR "--set " "setname flag[,flag...]"
-where flags are
-.BR "src"
-and/or
-.BR "dst" 
-and there can be no more than six of them. Hence the command
-.nf
- iptables -A FORWARD -m set --set test src,dst
-.fi
-will match packets, for which (depending on the type of the set) the source
-address or port number of the packet can be found in the specified set. If 
-there is a binding belonging to the mached set element or there is a default 
-binding for the given set, then the rule will match the packet only if 
-additionally (depending on the type of the set) the destination address or 
-port number of the packet can be found in the set according to the binding.
Signature · 1 line
1.5.5.rc3
#17 lore raw

Re: [PATCH 7/8] Remove support for compilation of conditional extensions

Quoted 19 lines · Jan Engelhardt
---
 extensions/.condition-test       |    4 -
 extensions/.condition-test6      |    4 -
 extensions/.set-test             |    4 -
 extensions/GNUmakefile.in        |   27 +----
 extensions/libip6t_condition.c   |   95 ----------------
 extensions/libip6t_condition.man |    4 -
 extensions/libipt_SET.c          |  174 ------------------------------
 extensions/libipt_SET.man        |   16 ---
 extensions/libipt_condition.c    |   94 ----------------
 extensions/libipt_condition.man  |    4 -
 extensions/libipt_set.c          |  161 ---------------------------
 extensions/libipt_set.h          |  104 ------------------
 extensions/libipt_set.man        |   17 ---
 13 files changed, 3 insertions(+), 705 deletions(-)
 delete mode 100755 extensions/.condition-test
 delete mode 100755 extensions/.condition-test6
 delete mode 100755 extensions/.set-test
 delete mode 100644 extensions/libip6t_condition.c
Quoted 8 lines
 delete mode 100644 extensions/libip6t_condition.man
 delete mode 100644 extensions/libipt_SET.c
 delete mode 100644 extensions/libipt_SET.man
 delete mode 100644 extensions/libipt_condition.c
 delete mode 100644 extensions/libipt_condition.man
 delete mode 100644 extensions/libipt_set.c
 delete mode 100644 extensions/libipt_set.h
 delete mode 100644 extensions/libipt_set.man

Was there some resolution on the discussion that this is the way to go? I mainly would like to see an ACK from Jozsef for this change before applying it.

#19 lore raw

Re: [PATCH 7/8] Remove support for compilation of conditional extensions

Quoted 10 lines · Jan Engelhardt
Quoted 4 lines · Patrick McHardy

Was there some resolution on the discussion that this is the way to go? I mainly would like to see an ACK from Jozsef for this change before applying it.

There was some sort of positive agreement:

http://www.spinics.net/lists/netfilter-devel/msg02729.html (ipset)
http://www.spinics.net/lists/netfilter-devel/msg02727.html (condition)

Yes, "sort of". So far it seems most convenient to keep ipset in iptables. What was the exact problem with these extensions again?

#20 lore raw

Re: [PATCH 7/8] Remove support for compilation of conditional extensions

Quoted 6 lines · Patrick McHardy
Quoted 5 lines · Jan Engelhardt
Quoted 4 lines · Patrick McHardy

Was there some resolution on the discussion that this is the way to go? I mainly would like to see an ACK from Jozsef for this change before applying it.

Quoted 8 lines
Quoted 4 lines

There was some sort of positive agreement:

http://www.spinics.net/lists/netfilter-devel/msg02729.html (ipset)
http://www.spinics.net/lists/netfilter-devel/msg02727.html (condition)

Yes, "sort of". So far it seems most convenient to keep ipset in iptables. What was the exact problem with these extensions again?

The problem is not the extensions themselves; but they do not compile due to a lack of their header files. Should it just be added?

Should ipset instead be added to the kernel?

#21 lore raw

Re: [PATCH 7/8] Remove support for compilation of conditional extensions

Quoted 13 lines · Jan Engelhardt
Quoted 11 lines · Patrick McHardy
Quoted 9 lines · Jan Engelhardt
Quoted 4 lines · Patrick McHardy

Was there some resolution on the discussion that this is the way to go? I mainly would like to see an ACK from Jozsef for this change before applying it.

There was some sort of positive agreement:

http://www.spinics.net/lists/netfilter-devel/msg02729.html (ipset)
http://www.spinics.net/lists/netfilter-devel/msg02727.html (condition)

Quoted 7 lines
Quoted 3 lines

Yes, "sort of". So far it seems most convenient to keep ipset in iptables. What was the exact problem with these extensions again?

The problem is not the extensions themselves; but they do not compile due to a lack of their header files. Should it just be added?

Should ipset instead be added to the kernel?

No, I think the missing kernel header files (ip_set.h and ipt_set.h) should be added to the iptables source.

Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics

          H-1525 Budapest 114, POB. 49, Hungary
#22 lore raw

Re: [PATCH 7/8] Remove support for compilation of conditional extensions

Quoted 16 lines · Jozsef Kadlecsik
Quoted 14 lines · Jan Engelhardt
Quoted 13 lines · Patrick McHardy
Quoted 9 lines · Jan Engelhardt
Quoted 4 lines · Patrick McHardy

Was there some resolution on the discussion that this is the way to go? I mainly would like to see an ACK from Jozsef for this change before applying it.

There was some sort of positive agreement:

http://www.spinics.net/lists/netfilter-devel/msg02729.html (ipset)
http://www.spinics.net/lists/netfilter-devel/msg02727.html (condition)

Yes, "sort of". So far it seems most convenient to keep ipset in iptables. What was the exact problem with these extensions again?

Quoted 6 lines
Quoted 4 lines

The problem is not the extensions themselves; but they do not compile due to a lack of their header files. Should it just be added?

Should ipset instead be added to the kernel?

No, I think the missing kernel header files (ip_set.h and ipt_set.h) should be added to the iptables source.

Yes, I agree.

#23 lore raw

PATCH 8/8 Implement AF_UNSPEC as a wildcard for extensions

In reply to Jan Engelhardt

When a match or target is registered using xtables_register_{match,target}, xtables.c will consider AF_UNSPEC as a wildcard when specified as the .family member. Rules between two competing matches/targets are:

- higher revision (if usable in kernel) wins over lower revision
- in case of same revision: generic AF_UNSPEC loses to specific AF_...

---
 extensions/libxt_CLASSIFY.c  |   17 +---------------
 extensions/libxt_MARK.c      |   18 +----------------
 extensions/libxt_RATEEST.c   |   22 ++-----------------
 extensions/libxt_SECMARK.c   |   18 +----------------
 extensions/libxt_TRACE.c     |   13 +-----------
 extensions/libxt_length.c    |   17 +---------------
 extensions/libxt_limit.c     |   17 +---------------
 extensions/libxt_mark.c      |   36 +--------------------------------
 extensions/libxt_pkttype.c   |   17 +---------------
 extensions/libxt_quota.c     |   16 +--------------
 extensions/libxt_rateest.c   |   21 ++-----------------
 extensions/libxt_standard.c  |   13 +-----------
 extensions/libxt_statistic.c |   18 +----------------
 extensions/libxt_string.c    |   19 +-----------------
 extensions/libxt_time.c      |   17 +---------------
 extensions/libxt_u32.c       |   17 +---------------
 xtables.c                    |   22 +++++++++++++++-----
 17 files changed, 37 insertions(+), 281 deletions(-)
extensions/libxt_CLASSIFY.c +1 -16
index e39367a..4a3520f 100644
@@ -103,21 +103,7 @@ CLASSIFY_save(const void *ip, const struct xt_entry_target *target)
 }
 
 static struct xtables_target classify_target = { 
-	.family		= AF_INET,
-	.name		= "CLASSIFY",
-	.version	= IPTABLES_VERSION,
-	.size		= XT_ALIGN(sizeof(struct xt_classify_target_info)),
-	.userspacesize	= XT_ALIGN(sizeof(struct xt_classify_target_info)),
-	.help		= CLASSIFY_help,
-	.parse		= CLASSIFY_parse,
-	.final_check	= CLASSIFY_final_check,
-	.print		= CLASSIFY_print,
-	.save		= CLASSIFY_save,
-	.extra_opts	= CLASSIFY_opts,
-};
-
-static struct xtables_target classify_target6 = { 
-	.family		= AF_INET6,
+	.family		= AF_UNSPEC,
 	.name		= "CLASSIFY",
 	.version	= IPTABLES_VERSION,
 	.size		= XT_ALIGN(sizeof(struct xt_classify_target_info)),
@@ -133,5 +119,4 @@ static struct xtables_target classify_target6 = {
 void _init(void)
 {
 	xtables_register_target(&classify_target);
-	xtables_register_target(&classify_target6);
 }
extensions/libxt_MARK.c +1 -17
index 569d2e8..d7d79d5 100644
@@ -333,22 +333,7 @@ static struct xtables_target mark_tg_reg_v2 = {
 	.version       = IPTABLES_VERSION,
 	.name          = "MARK",
 	.revision      = 2,
-	.family        = AF_INET,
-	.size          = XT_ALIGN(sizeof(struct xt_mark_tginfo2)),
-	.userspacesize = XT_ALIGN(sizeof(struct xt_mark_tginfo2)),
-	.help          = mark_tg_help,
-	.parse         = mark_tg_parse,
-	.final_check   = mark_tg_check,
-	.print         = mark_tg_print,
-	.save          = mark_tg_save,
-	.extra_opts    = mark_tg_opts,
-};
-
-static struct xtables_target mark_tg6_reg_v2 = {
-	.version       = IPTABLES_VERSION,
-	.name          = "MARK",
-	.revision      = 2,
-	.family        = AF_INET6,
+	.family        = AF_UNSPEC,
 	.size          = XT_ALIGN(sizeof(struct xt_mark_tginfo2)),
 	.userspacesize = XT_ALIGN(sizeof(struct xt_mark_tginfo2)),
 	.help          = mark_tg_help,
@@ -365,5 +350,4 @@ void _init(void)
 	xtables_register_target(&mark_target_v1);
 	xtables_register_target(&mark_target6_v0);
 	xtables_register_target(&mark_tg_reg_v2);
-	xtables_register_target(&mark_tg6_reg_v2);
 }
extensions/libxt_RATEEST.c +3 -19
index dd7b503..ee0d116 100644
@@ -202,23 +202,8 @@ RATEEST_save(const void *ip, const struct xt_entry_target *target)
 	__RATEEST_print(target, "--rateest-");
 }
 
-static struct xtables_target rateest_target4 = {
-	.family		= AF_INET,
-	.name		= "RATEEST",
-	.version	= IPTABLES_VERSION,
-	.size		= XT_ALIGN(sizeof(struct xt_rateest_target_info)),
-	.userspacesize	= XT_ALIGN(sizeof(struct xt_rateest_target_info)),
-	.help		= RATEEST_help,
-	.init		= RATEEST_init,
-	.parse		= RATEEST_parse,
-	.final_check	= RATEEST_final_check,
-	.print		= RATEEST_print,
-	.save		= RATEEST_save,
-	.extra_opts	= RATEEST_opts,
-};
-
-static struct xtables_target rateest_target6 = {
-	.family		= AF_INET6,
+static struct xtables_target rateest_tg_reg = {
+	.family		= AF_UNSPEC,
 	.name		= "RATEEST",
 	.version	= IPTABLES_VERSION,
 	.size		= XT_ALIGN(sizeof(struct xt_rateest_target_info)),
@@ -234,6 +219,5 @@ static struct xtables_target rateest_target6 = {
 
 void _init(void)
 {
-	xtables_register_target(&rateest_target4);
-	xtables_register_target(&rateest_target6);
+	xtables_register_target(&rateest_tg_reg);
 }
extensions/libxt_SECMARK.c +1 -17
index b794e7d..92ba527 100644
@@ -100,22 +100,7 @@ static void SECMARK_save(const void *ip, const struct xt_entry_target *target)
 }
 
 static struct xtables_target secmark_target = {
-	.family		= AF_INET,
-	.name		= "SECMARK",
-	.version	= IPTABLES_VERSION,
-	.revision	= 0,
-	.size		= XT_ALIGN(sizeof(struct xt_secmark_target_info)),
-	.userspacesize	= XT_ALIGN(sizeof(struct xt_secmark_target_info)),
-	.help		= SECMARK_help,
-	.parse		= SECMARK_parse,
-	.final_check	= SECMARK_check,
-	.print		= SECMARK_print,
-	.save		= SECMARK_save,
-	.extra_opts	= SECMARK_opts,
-};
-
-static struct xtables_target secmark_target6 = {
-	.family		= AF_INET6,
+	.family		= AF_UNSPEC,
 	.name		= "SECMARK",
 	.version	= IPTABLES_VERSION,
 	.revision	= 0,
@@ -132,5 +117,4 @@ static struct xtables_target secmark_target6 = {
 void _init(void)
 {
 	xtables_register_target(&secmark_target);
-	xtables_register_target(&secmark_target6);
 }
extensions/libxt_TRACE.c +1 -12
index c70df6a..97e3a03 100644
@@ -24,17 +24,7 @@ static int TRACE_parse(int c, char **argv, int invert, unsigned int *flags,
 }
 
 static struct xtables_target trace_target = {
-	.family		= AF_INET,
-	.name		= "TRACE",
-	.version	= IPTABLES_VERSION,
-	.size		= XT_ALIGN(0),
-	.userspacesize	= XT_ALIGN(0),
-	.help		= TRACE_help,
-	.parse		= TRACE_parse,
-};
-
-static struct xtables_target trace_target6 = {
-	.family		= AF_INET6,
+	.family		= AF_UNSPEC,
 	.name		= "TRACE",
 	.version	= IPTABLES_VERSION,
 	.size		= XT_ALIGN(0),
@@ -46,5 +36,4 @@ static struct xtables_target trace_target6 = {
 void _init(void)
 {
 	xtables_register_target(&trace_target);
-	xtables_register_target(&trace_target6);
 }
extensions/libxt_length.c +1 -16
index b812b67..16e00bd 100644
@@ -125,21 +125,7 @@ static void length_save(const void *ip, const struct xt_entry_match *match)
 }
 
 static struct xtables_match length_match = {
-	.family		= AF_INET,
-	.name		= "length",
-	.version	= IPTABLES_VERSION,
-	.size		= XT_ALIGN(sizeof(struct xt_length_info)),
-	.userspacesize	= XT_ALIGN(sizeof(struct xt_length_info)),
-	.help		= length_help,
-	.parse		= length_parse,
-	.final_check	= length_check,
-	.print		= length_print,
-	.save		= length_save,
-	.extra_opts	= length_opts,
-};
-
-static struct xtables_match length_match6 = {
-	.family		= AF_INET6,
+	.family		= AF_UNSPEC,
 	.name		= "length",
 	.version	= IPTABLES_VERSION,
 	.size		= XT_ALIGN(sizeof(struct xt_length_info)),
@@ -155,5 +141,4 @@ static struct xtables_match length_match6 = {
 void _init(void)
 {
 	xtables_register_match(&length_match);
-	xtables_register_match(&length_match6);
 }
extensions/libxt_limit.c +1 -16
index 65a8df3..1c86df9 100644
@@ -165,21 +165,7 @@ static void limit_save(const void *ip, const struct xt_entry_match *match)
 }
 
 static struct xtables_match limit_match = {
-	.family		= AF_INET,
-	.name		= "limit",
-	.version	= IPTABLES_VERSION,
-	.size		= XT_ALIGN(sizeof(struct xt_rateinfo)),
-	.userspacesize	= offsetof(struct xt_rateinfo, prev),
-	.help		= limit_help,
-	.init		= limit_init,
-	.parse		= limit_parse,
-	.print		= limit_print,
-	.save		= limit_save,
-	.extra_opts	= limit_opts,
-};
-
-static struct xtables_match limit_match6 = {
-	.family		= AF_INET6,
+	.family		= AF_UNSPEC,
 	.name		= "limit",
 	.version	= IPTABLES_VERSION,
 	.size		= XT_ALIGN(sizeof(struct xt_rateinfo)),
@@ -195,5 +181,4 @@ static struct xtables_match limit_match6 = {
 void _init(void)
 {
 	xtables_register_match(&limit_match);
-	xtables_register_match(&limit_match6);
 }
extensions/libxt_mark.c +2 -34
index af7f844..fab8ecb 100644
@@ -149,22 +149,7 @@ mark_save(const void *ip, const struct xt_entry_match *match)
 }
 
 static struct xtables_match mark_match = {
-	.family		= AF_INET,
-	.name		= "mark",
-	.revision	= 0,
-	.version	= IPTABLES_VERSION,
-	.size		= XT_ALIGN(sizeof(struct xt_mark_info)),
-	.userspacesize	= XT_ALIGN(sizeof(struct xt_mark_info)),
-	.help		= mark_mt_help,
-	.parse		= mark_parse,
-	.final_check	= mark_mt_check,
-	.print		= mark_print,
-	.save		= mark_save,
-	.extra_opts	= mark_mt_opts,
-};
-
-static struct xtables_match mark_match6 = {
-	.family		= AF_INET6,
+	.family		= AF_UNSPEC,
 	.name		= "mark",
 	.revision	= 0,
 	.version	= IPTABLES_VERSION,
@@ -182,22 +167,7 @@ static struct xtables_match mark_mt_reg = {
 	.version        = IPTABLES_VERSION,
 	.name           = "mark",
 	.revision       = 1,
-	.family         = AF_INET,
-	.size           = XT_ALIGN(sizeof(struct xt_mark_mtinfo1)),
-	.userspacesize  = XT_ALIGN(sizeof(struct xt_mark_mtinfo1)),
-	.help           = mark_mt_help,
-	.parse          = mark_mt_parse,
-	.final_check    = mark_mt_check,
-	.print          = mark_mt_print,
-	.save           = mark_mt_save,
-	.extra_opts     = mark_mt_opts,
-};
-
-static struct xtables_match mark_mt6_reg = {
-	.version        = IPTABLES_VERSION,
-	.name           = "mark",
-	.revision       = 1,
-	.family         = AF_INET6,
+	.family         = AF_UNSPEC,
 	.size           = XT_ALIGN(sizeof(struct xt_mark_mtinfo1)),
 	.userspacesize  = XT_ALIGN(sizeof(struct xt_mark_mtinfo1)),
 	.help           = mark_mt_help,
@@ -211,7 +181,5 @@ static struct xtables_match mark_mt6_reg = {
 void _init(void)
 {
 	xtables_register_match(&mark_match);
-	xtables_register_match(&mark_match6);
 	xtables_register_match(&mark_mt_reg);
-	xtables_register_match(&mark_mt6_reg);
 }
extensions/libxt_pkttype.c +1 -16
index 75194fc..7c469a8 100644
@@ -147,21 +147,7 @@ static void pkttype_save(const void *ip, const struct xt_entry_match *match)
 }
 
 static struct xtables_match pkttype_match = {
-	.family		= AF_INET,
-	.name		= "pkttype",
-	.version	= IPTABLES_VERSION,
-	.size		= XT_ALIGN(sizeof(struct xt_pkttype_info)),
-	.userspacesize	= XT_ALIGN(sizeof(struct xt_pkttype_info)),
-	.help		= pkttype_help,
-	.parse		= pkttype_parse,
-	.final_check	= pkttype_check,
-	.print		= pkttype_print,
-	.save		= pkttype_save,
-	.extra_opts	= pkttype_opts,
-};
-
-static struct xtables_match pkttype_match6 = {
-	.family		= AF_INET6,
+	.family		= AF_UNSPEC,
 	.name		= "pkttype",
 	.version	= IPTABLES_VERSION,
 	.size		= XT_ALIGN(sizeof(struct xt_pkttype_info)),
@@ -177,5 +163,4 @@ static struct xtables_match pkttype_match6 = {
 void _init(void)
 {
 	xtables_register_match(&pkttype_match);
-	xtables_register_match(&pkttype_match6);
 }
extensions/libxt_quota.c +1 -15
index b4fb78b..590dbfb 100644
@@ -78,20 +78,7 @@ quota_parse(int c, char **argv, int invert, unsigned int *flags,
 }
 
 struct xtables_match quota_match = {
-	.family		= AF_INET,
-	.name		= "quota",
-	.version	= IPTABLES_VERSION,
-	.size		= XT_ALIGN(sizeof (struct xt_quota_info)),
-	.userspacesize	= offsetof(struct xt_quota_info, quota),
-	.help		= quota_help,
-	.parse		= quota_parse,
-	.print		= quota_print,
-	.save		= quota_save,
-	.extra_opts	= quota_opts,
-};
-
-struct xtables_match quota_match6 = {
-	.family		= AF_INET6,
+	.family		= AF_UNSPEC,
 	.name		= "quota",
 	.version	= IPTABLES_VERSION,
 	.size		= XT_ALIGN(sizeof (struct xt_quota_info)),
@@ -107,5 +94,4 @@ void
 _init(void)
 {
 	xtables_register_match(&quota_match);
-	xtables_register_match(&quota_match6);
 }
extensions/libxt_rateest.c +3 -18
index 5f13340..a335781 100644
@@ -426,22 +426,8 @@ rateest_save(const void *ip, const struct xt_entry_match *match)
 	}
 }
 
-static struct xtables_match rateest_match4 = {
-	.family		= AF_INET,
-	.name		= "rateest",
-	.version	= IPTABLES_VERSION,
-	.size		= XT_ALIGN(sizeof(struct xt_rateest_match_info)),
-	.userspacesize	= XT_ALIGN(offsetof(struct xt_rateest_match_info, est1)),
-	.help		= rateest_help,
-	.parse		= rateest_parse,
-	.final_check	= rateest_final_check,
-	.print		= rateest_print,
-	.save		= rateest_save,
-	.extra_opts	= rateest_opts,
-};
-
-static struct xtables_match rateest_match6 = {
-	.family		= AF_INET6,
+static struct xtables_match rateest_mt_reg = {
+	.family		= AF_UNSPEC,
 	.name		= "rateest",
 	.version	= IPTABLES_VERSION,
 	.size		= XT_ALIGN(sizeof(struct xt_rateest_match_info)),
@@ -456,6 +442,5 @@ static struct xtables_match rateest_match6 = {
 
 void _init(void)
 {
-	xtables_register_match(&rateest_match4);
-	xtables_register_match(&rateest_match6);
+	xtables_register_match(&rateest_mt_reg);
 }
extensions/libxt_standard.c +1 -12
index eef9369..a50cffe 100644
@@ -24,17 +24,7 @@ static int standard_parse(int c, char **argv, int invert, unsigned int *flags,
 }
 
 static struct xtables_target standard_target = {
-	.family		= AF_INET,
-	.name		= "standard",
-	.version	= IPTABLES_VERSION,
-	.size		= XT_ALIGN(sizeof(int)),
-	.userspacesize	= XT_ALIGN(sizeof(int)),
-	.help		= standard_help,
-	.parse		= standard_parse,
-};
-
-static struct xtables_target standard_target6 = {
-	.family		= AF_INET6,
+	.family		= AF_UNSPEC,
 	.name		= "standard",
 	.version	= IPTABLES_VERSION,
 	.size		= XT_ALIGN(sizeof(int)),
@@ -46,5 +36,4 @@ static struct xtables_target standard_target6 = {
 void _init(void)
 {
 	xtables_register_target(&standard_target);
-	xtables_register_target(&standard_target6);
 }
extensions/libxt_statistic.c +1 -17
index ebb4e91..2c2464d 100644
@@ -164,22 +164,7 @@ static void statistic_save(const void *ip, const struct xt_entry_match *match)
 }
 
 static struct xtables_match statistic_match = {
-	.family		= AF_INET,
-	.name		= "statistic",
-	.version	= IPTABLES_VERSION,
-	.size		= XT_ALIGN(sizeof(struct xt_statistic_info)),
-	.userspacesize	= offsetof(struct xt_statistic_info, u.nth.count),
-	.init		= statistic_mt_init,
-	.help		= statistic_help,
-	.parse		= statistic_parse,
-	.final_check	= statistic_check,
-	.print		= statistic_print,
-	.save		= statistic_save,
-	.extra_opts	= statistic_opts,
-};
-
-static struct xtables_match statistic_match6 = {
-	.family		= AF_INET6,
+	.family		= AF_UNSPEC,
 	.name		= "statistic",
 	.version	= IPTABLES_VERSION,
 	.size		= XT_ALIGN(sizeof(struct xt_statistic_info)),
@@ -196,5 +181,4 @@ static struct xtables_match statistic_match6 = {
 void _init(void)
 {
 	xtables_register_match(&statistic_match);
-	xtables_register_match(&statistic_match6);
 }
extensions/libxt_string.c +1 -18
index f1030bb..dc2cd9d 100644
@@ -327,23 +327,7 @@ static void string_save(const void *ip, const struct xt_entry_match *match)
 
 static struct xtables_match string_match = {
     .name		= "string",
-    .family		= AF_INET,
-    .version		= IPTABLES_VERSION,
-    .size		= XT_ALIGN(sizeof(struct xt_string_info)),
-    .userspacesize	= offsetof(struct xt_string_info, config),
-    .help		= string_help,
-    .init		= string_init,
-    .parse		= string_parse,
-    .final_check	= string_check,
-    .print		= string_print,
-    .save		= string_save,
-    .extra_opts		= string_opts,
-};
-
-
-static struct xtables_match string_match6 = {
-    .name		= "string",
-    .family		= AF_INET6,
+    .family		= AF_UNSPEC,
     .version		= IPTABLES_VERSION,
     .size		= XT_ALIGN(sizeof(struct xt_string_info)),
     .userspacesize	= offsetof(struct xt_string_info, config),
@@ -359,5 +343,4 @@ static struct xtables_match string_match6 = {
 void _init(void)
 {
 	xtables_register_match(&string_match);
-	xtables_register_match(&string_match6);
 }
extensions/libxt_time.c +1 -16
index c39ab1a..c551a6f 100644
@@ -466,21 +466,7 @@ static void time_save(const void *ip, const struct xt_entry_match *match)
 
 static struct xtables_match time_match = {
 	.name          = "time",
-	.family        = AF_INET,
-	.version       = IPTABLES_VERSION,
-	.size          = XT_ALIGN(sizeof(struct xt_time_info)),
-	.userspacesize = XT_ALIGN(sizeof(struct xt_time_info)),
-	.help          = time_help,
-	.init          = time_init,
-	.parse         = time_parse,
-	.print         = time_print,
-	.save          = time_save,
-	.extra_opts    = time_opts,
-};
-
-static struct xtables_match time_match6 = {
-	.name          = "time",
-	.family        = AF_INET6,
+	.family        = AF_UNSPEC,
 	.version       = IPTABLES_VERSION,
 	.size          = XT_ALIGN(sizeof(struct xt_time_info)),
 	.userspacesize = XT_ALIGN(sizeof(struct xt_time_info)),
@@ -495,5 +481,4 @@ static struct xtables_match time_match6 = {
 void _init(void)
 {
 	xtables_register_match(&time_match);
-	xtables_register_match(&time_match6);
 }
extensions/libxt_u32.c +1 -16
index 251b2d4..9360c09 100644
@@ -272,20 +272,7 @@ static void u32_save(const void *ip, const struct xt_entry_match *match)
 
 static struct xtables_match u32_match = {
 	.name          = "u32",
-	.family        = AF_INET,
-	.version       = IPTABLES_VERSION,
-	.size          = XT_ALIGN(sizeof(struct xt_u32)),
-	.userspacesize = XT_ALIGN(sizeof(struct xt_u32)),
-	.help          = u32_help,
-	.parse         = u32_parse,
-	.print         = u32_print,
-	.save          = u32_save,
-	.extra_opts    = u32_opts,
-};
-
-static struct xtables_match u32_match6 = {
-	.name          = "u32",
-	.family        = AF_INET6,
+	.family        = AF_UNSPEC,
 	.version       = IPTABLES_VERSION,
 	.size          = XT_ALIGN(sizeof(struct xt_u32)),
 	.userspacesize = XT_ALIGN(sizeof(struct xt_u32)),
@@ -299,6 +286,4 @@ static struct xtables_match u32_match6 = {
 void _init(void)
 {
 	xtables_register_match(&u32_match);
-	xtables_register_match(&u32_match6);
-	return;
 }
xtables.c +16 -6
index b26b416..21da4b5 100644
@@ -557,12 +557,13 @@ void xtables_register_match(struct xtables_match *me)
 	}
 
 	/* ignore not interested match */
-	if (me->family != afinfo.family)
+	if (me->family != afinfo.family && me->family != AF_UNSPEC)
 		return;
 
 	old = find_match(me->name, DURING_LOAD, NULL);
 	if (old) {
-		if (old->revision == me->revision) {
+		if (old->revision == me->revision &&
+		    old->family == me->family) {
 			fprintf(stderr,
 				"%s: match `%s' already registered.\n",
 				program_name, me->name);
@@ -574,10 +575,14 @@ void xtables_register_match(struct xtables_match *me)
 		    && old->revision > me->revision)
 			return;
 
-		/* Replace if compatible. */
+		/* See if new match can be used. */
 		if (!compatible_match_revision(me->name, me->revision))
 			return;
 
+		/* Prefer !AF_UNSPEC over AF_UNSPEC for same revision. */
+		if (old->revision == me->revision && me->family == AF_UNSPEC)
+			return;
+
 		/* Delete old one. */
 		for (i = &xtables_matches; *i!=old; i = &(*i)->next);
 		*i = old->next;
@@ -623,14 +628,15 @@ void xtables_register_target(struct xtables_target *me)
 	}
 
 	/* ignore not interested target */
-	if (me->family != afinfo.family)
+	if (me->family != afinfo.family && me->family != AF_UNSPEC)
 		return;
 
 	old = find_target(me->name, DURING_LOAD);
 	if (old) {
 		struct xtables_target **i;
 
-		if (old->revision == me->revision) {
+		if (old->revision == me->revision &&
+		    old->family == me->family) {
 			fprintf(stderr,
 				"%s: target `%s' already registered.\n",
 				program_name, me->name);
@@ -642,10 +648,14 @@ void xtables_register_target(struct xtables_target *me)
 		    && old->revision > me->revision)
 			return;
 
-		/* Replace if compatible. */
+		/* See if new target can be used. */
 		if (!compatible_target_revision(me->name, me->revision))
 			return;
 
+		/* Prefer !AF_UNSPEC over AF_UNSPEC for same revision. */
+		if (old->revision == me->revision && me->family == AF_UNSPEC)
+			return;
+
 		/* Delete old one. */
 		for (i = &xtables_targets; *i!=old; i = &(*i)->next);
 		*i = old->next;
Signature · 1 line
1.5.5.rc3
#24 lore raw

Re: [PATCH 8/8] Implement AF_UNSPEC as a wildcard for extensions

Quoted 18 lines · Jan Engelhardt

When a match or target is registered using xtables_register_{match,target}, xtables.c will consider AF_UNSPEC as a wildcard when specified as the .family member. Rules between two competing matches/targets are:

- higher revision (if usable in kernel) wins over lower revision
- in case of same revision: generic AF_UNSPEC loses to specific AF_...

---
 extensions/libxt_CLASSIFY.c  |   17 +---------------
 extensions/libxt_MARK.c      |   18 +----------------
 extensions/libxt_RATEEST.c   |   22 ++-----------------
 extensions/libxt_SECMARK.c   |   18 +----------------
 extensions/libxt_TRACE.c     |   13 +-----------
 extensions/libxt_length.c    |   17 +---------------
 extensions/libxt_limit.c     |   17 +---------------
 extensions/libxt_mark.c      |   36 +--------------------------------
 extensions/libxt_pkttype.c   |   17 +---------------
 extensions/libxt_quota.c     |   16 +--------------
Quoted 8 lines
 extensions/libxt_rateest.c   |   21 ++-----------------
 extensions/libxt_standard.c  |   13 +-----------
 extensions/libxt_statistic.c |   18 +----------------
 extensions/libxt_string.c    |   19 +-----------------
 extensions/libxt_time.c      |   17 +---------------
 extensions/libxt_u32.c       |   17 +---------------
 xtables.c                    |   22 +++++++++++++++-----
 17 files changed, 37 insertions(+), 281 deletions(-)

Applied.