(unknown)
Hi,
here are a number of patches I am suggesting for the -master branch (-stable is separate in my view and my management, but see other discussion thread).
Pullable from
git://dev.medozas.de/iptables master
Jan Engelhardt (9):
libiptc: split v4 and v6
extensions: collapse registration structures
iptables: allow for parse-less extensions
iptables: allow for help-less extensions
extensions: remove empty help and parse functions
xtables: add multi-registration functions
extensions: collapse data variables to use multi-reg calls
xtables: warn of missing version identifier in extensions
COMMIT_NOTES: notice to check for soversion bumps
Michael Granzow (1):
iptables: accept multiple IP address specifications for -s, -d
(Shall I post the entire mergestat, or just the "X files changed" line?)
COMMIT_NOTES | 6 +- Makefile.am | 35 ++++--- configure.ac | 4 +- extensions/libip6t_eui64.c | 26 ----- extensions/libipt_MIRROR.c | 20 ---- extensions/libipt_addrtype.c | 58 ++++++------ extensions/libipt_unclean.c | 16 --- extensions/libxt_CONNMARK.c | 98 +++++++------------- extensions/libxt_CONNSECMARK.c | 18 +---- extensions/libxt_DSCP.c | 17 +--- extensions/libxt_MARK.c | 106 +++++++++------------- extensions/libxt_NFLOG.c | 17 +--- extensions/libxt_NFQUEUE.c | 16 +--- extensions/libxt_NOTRACK.c | 33 +------- extensions/libxt_TCPOPTSTRIP.c | 18 +---- extensions/libxt_TOS.c | 76 ++++++--------- extensions/libxt_TRACE.c | 13 --- extensions/libxt_comment.c | 17 +--- extensions/libxt_connbytes.c | 17 +--- extensions/libxt_connlimit.c | 60 ++++++------ extensions/libxt_connmark.c | 92 ++++++------------- extensions/libxt_conntrack.c | 90 +++++++++--------- extensions/libxt_dccp.c | 17 +--- extensions/libxt_dscp.c | 17 +--- extensions/libxt_esp.c | 17 +--- extensions/libxt_hashlimit.c | 113 ++++++++++------------- extensions/libxt_helper.c | 16 +--- extensions/libxt_iprange.c | 90 +++++++++--------- extensions/libxt_mac.c | 17 +--- extensions/libxt_mark.c | 60 ++++++------ extensions/libxt_multiport.c | 120 ++++++++++++------------- extensions/libxt_owner.c | 106 +++++++++------------- extensions/libxt_physdev.c | 17 +--- extensions/libxt_policy.c | 56 ++++++------ extensions/libxt_recent.c | 19 +---- extensions/libxt_sctp.c | 17 +--- extensions/libxt_socket.c | 20 ---- extensions/libxt_standard.c | 12 --- extensions/libxt_state.c | 17 +--- extensions/libxt_string.c | 64 +++++++------- extensions/libxt_tcp.c | 17 +--- extensions/libxt_tcpmss.c | 17 +--- extensions/libxt_tos.c | 76 ++++++--------- extensions/libxt_udp.c | 17 +--- include/xtables.h.in | 7 ++ ip6tables.8.in | 3 + ip6tables.c | 76 ++++++++-------- iptables.8.in | 7 +- iptables.c | 69 ++++++++------- xshared.c | 31 ++++++ xshared.h | 10 ++ xtables.c | 199 ++++++++++++++++++++++++++++++++++++++++ 52 files changed, 929 insertions(+), 1248 deletions(-) create mode 100644 xshared.c create mode 100644 xshared.h
PATCH 1/10 iptables: accept multiple IP address specifications for -s, -d
From: Michael Granzow <[email protected]>
libiptc already supports adding and deleting multiple rules with different addresses, so it only needs to be wired up to the options.
# ip6tables -I INPUT -s 2001:db8::d,2001:db8::e -j DROP
References: http://marc.info/?l=netfilter-devel&m=123929790719202&w=2
Adjustments made: syntax, removal of unneeded variables, manpage adjustment, soversion bump.
--- configure.ac | 4 +- include/xtables.h.in | 5 ++ ip6tables.8.in | 3 + ip6tables.c | 49 +++++++++----- iptables.8.in | 7 ++- iptables.c | 42 +++++++++---- xtables.c | 175 ++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 251 insertions(+), 34 deletions(-)
configure.ac +2 -2
@@ -2,8 +2,8 @@ AC_INIT([iptables], [1.4.4]) # See libtool.info "Libtool's versioning system" -libxtables_vcurrent=2 -libxtables_vage=0 +libxtables_vcurrent=3 +libxtables_vage=1 AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4])
include/xtables.h.in +5 -0
@@ -215,6 +215,7 @@ extern void xtables_init(void); extern void xtables_set_nfproto(uint8_t); extern void *xtables_calloc(size_t, size_t); extern void *xtables_malloc(size_t); +extern void *xtables_realloc(void *, size_t); extern int xtables_insmod(const char *, const char *, bool); extern int xtables_load_ko(const char *, bool);
@@ -260,6 +261,8 @@ extern struct in_addr *xtables_numeric_to_ipaddr(const char *); extern struct in_addr *xtables_numeric_to_ipmask(const char *); extern void xtables_ipparse_any(const char *, struct in_addr **, struct in_addr *, unsigned int *); +extern void xtables_ipparse_multiple(const char *, struct in_addr **, + struct in_addr **, unsigned int *); extern struct in6_addr *xtables_numeric_to_ip6addr(const char *); extern const char *xtables_ip6addr_to_numeric(const struct in6_addr *);
@@ -267,6 +270,8 @@ extern const char *xtables_ip6addr_to_anyname(const struct in6_addr *); extern const char *xtables_ip6mask_to_numeric(const struct in6_addr *); extern void xtables_ip6parse_any(const char *, struct in6_addr **, struct in6_addr *, unsigned int *); +extern void xtables_ip6parse_multiple(const char *, struct in6_addr **, + struct in6_addr **, unsigned int *); /** * Print the specified value to standard output, quoting dangerous
ip6tables.8.in +3 -0
@@ -248,6 +248,9 @@ specifying the number of 1's at the left side of the network mask. A "!" argument before the address specification inverts the sense of the address. The flag \fB\-\-src\fP is an alias for this option. +Multiple addresses can be specified, but this will \fBexpand to multiple +rules\fP (when adding with \-A), or will cause multiple rules to be +deleted (with \-D). .TP [\fB!\fP] \fB\-d\fP, \fB\-\-destination\fP \fIaddress\fP[\fB/\fP\fImask\fP] Destination specification.
ip6tables.c +31 -18
151 lines not on this page · raw message
iptables.8.in +5 -2
@@ -236,7 +236,7 @@ Protocol \fBall\fP will match with all protocols and is taken as default when this option is omitted. .TP -[\fB!\fP] \fB\-s\fP, \fB\-\-source\fP \fIaddress\fP[\fB/\fP\fImask\fP] +[\fB!\fP] \fB\-s\fP, \fB\-\-source\fP \fIaddress\fP[\fB/\fP\fImask\fP][\fB,\fP\fI...\fP] Source specification. \fIAddress\fP can be either a network name, a hostname (please note that specifying any name to be resolved with a remote query such as DNS is a really bad idea),
@@ -247,8 +247,11 @@ specifying the number of 1's at the left side of the network mask. Thus, a mask of \fI24\fP is equivalent to \fI255.255.255.0\fP. A "!" argument before the address specification inverts the sense of the address. The flag \fB\-\-src\fP is an alias for this option. +Multiple addresses can be specified, but this will \fBexpand to multiple +rules\fP (when adding with \-A), or will cause multiple rules to be +deleted (with \-D). .TP -[\fB!\fP] \fB\-d\fP, \fB\-\-destination\fP \fIaddress\fP[\fB/\fP\fImask\fP] +[\fB!\fP] \fB\-d\fP, \fB\-\-destination\fP \fIaddress\fP[\fB/\fP\fImask\fP][\fB,\fP\fI...\fP] Destination specification. See the description of the \fB\-s\fP (source) flag for a detailed description of the syntax. The flag
iptables.c +30 -12
143 lines not on this page · raw message
xtables.c +175 -0
193 lines not on this page · raw message
Signature · 1 line
1.6.3.2
PATCH 2/10 libiptc: split v4 and v6
In reply to Jan EngelhardtThe split can save some diskspace for constrained systems running which are only running one protocol.
--- Makefile.am | 19 ++++++++++++------- 1 files changed, 12 insertions(+), 7 deletions(-)
Makefile.am +12 -7
@@ -14,9 +14,14 @@ endif lib_LTLIBRARIES = # libiptc -lib_LTLIBRARIES += libiptc/libiptc.la -libiptc_libiptc_la_SOURCES = libiptc/libip4tc.c libiptc/libip6tc.c -libiptc_libiptc_la_LDFLAGS = -version-info 0:0:0 +lib_LTLIBRARIES += libiptc/libiptc.la libiptc/libip4tc.la libiptc/libip6tc.la +libiptc_libiptc_la_SOURCES = +libiptc_libiptc_la_LIBADD = libiptc/libip4tc.la libiptc/libip6tc.la +libiptc_libiptc_la_LDFLAGS = -version-info 0:0:0 +libiptc_libip4tc_la_SOURCES = libiptc/libip4tc.c +libiptc_libip4tc_la_LDFLAGS = -version-info 0:0:0 +libiptc_libip6tc_la_SOURCES = libiptc/libip6tc.c +libiptc_libip6tc_la_LDFLAGS = -version-info 0:0:0 lib_LTLIBRARIES += libxtables.la libxtables_la_SOURCES = xtables.c
@@ -26,7 +31,7 @@ libxtables_la_LIBADD = -ldl # iptables, dynamic iptables_SOURCES = iptables-standalone.c iptables.c iptables_LDFLAGS = -rdynamic -iptables_LDADD = libiptc/libiptc.la extensions/libext4.a libxtables.la -lm +iptables_LDADD = libiptc/libip4tc.la extensions/libext4.a libxtables.la -lm iptables_xml_LDADD = libxtables.la iptables_multi_SOURCES = iptables-multi.c iptables-save.c \
@@ -47,14 +52,14 @@ iptables_save_LDADD = ${iptables_LDADD} # iptables-multi, semi-static iptables_static_SOURCES = ${iptables_multi_SOURCES} xtables.c iptables_static_CFLAGS = ${iptables_multi_CFLAGS} -DNO_SHARED_LIBS=1 -iptables_static_LDADD = libiptc/libiptc.la extensions/libext4.a -lm +iptables_static_LDADD = libiptc/libip4tc.la extensions/libext4.a -lm iptables_xml_SOURCES = iptables-xml.c # ip6tables, dynamic ip6tables_SOURCES = ip6tables-standalone.c ip6tables.c ip6tables_LDFLAGS = -rdynamic -ip6tables_LDADD = libiptc/libiptc.la extensions/libext6.a libxtables.la -lm +ip6tables_LDADD = libiptc/libip6tc.la extensions/libext6.a libxtables.la -lm ip6tables_multi_SOURCES = ip6tables-multi.c ip6tables-save.c \ ip6tables-restore.c ip6tables-standalone.c \
@@ -74,7 +79,7 @@ ip6tables_save_LDADD = ${ip6tables_LDADD} # iptables-multi, semi-static ip6tables_static_SOURCES = ${ip6tables_multi_SOURCES} xtables.c ip6tables_static_CFLAGS = ${ip6tables_multi_CFLAGS} -DNO_SHARED_LIBS=1 -ip6tables_static_LDADD = libiptc/libiptc.la extensions/libext6.a -lm +ip6tables_static_LDADD = libiptc/libip6tc.la extensions/libext6.a -lm bin_PROGRAMS = iptables-xml sbin_PROGRAMS =
Signature · 1 line
1.6.3.2
PATCH 3/10 extensions: collapse registration structures
In reply to Jan EngelhardtThere are no different code paths between IPV4 and IPV6, so data can be consolidated here.
text data bss dec hex filename
243757 12212 2576 258545 3f1f1 ip6tables-static[before.i586] 243613 9428 2576 255617 3e681 ip6tables-static[after.i586]
-144 -2784
--- extensions/libxt_CONNMARK.c | 38 ++------------------------------------ extensions/libxt_CONNSECMARK.c | 18 +----------------- extensions/libxt_DSCP.c | 17 +---------------- extensions/libxt_MARK.c | 18 +----------------- extensions/libxt_NFLOG.c | 17 +---------------- extensions/libxt_NFQUEUE.c | 16 +--------------- extensions/libxt_NOTRACK.c | 13 +------------ extensions/libxt_TCPOPTSTRIP.c | 18 +----------------- extensions/libxt_TOS.c | 18 +----------------- extensions/libxt_comment.c | 17 +---------------- extensions/libxt_connbytes.c | 17 +---------------- extensions/libxt_connmark.c | 36 ++---------------------------------- extensions/libxt_dccp.c | 17 +---------------- extensions/libxt_dscp.c | 17 +---------------- extensions/libxt_esp.c | 17 +---------------- extensions/libxt_hashlimit.c | 19 +------------------ extensions/libxt_helper.c | 16 +--------------- extensions/libxt_mac.c | 17 +---------------- extensions/libxt_owner.c | 18 +----------------- extensions/libxt_physdev.c | 17 +---------------- extensions/libxt_recent.c | 19 +------------------ extensions/libxt_sctp.c | 17 +---------------- extensions/libxt_state.c | 17 +---------------- extensions/libxt_tcp.c | 17 +---------------- extensions/libxt_tcpmss.c | 17 +---------------- extensions/libxt_tos.c | 18 +----------------- extensions/libxt_udp.c | 17 +---------------- 27 files changed, 29 insertions(+), 474 deletions(-)
extensions/libxt_CONNMARK.c +2 -36
@@ -399,23 +399,7 @@ connmark_tg_save(const void *ip, const struct xt_entry_target *target) }static struct xtables_target connmark_target = { - .family =NFPROTO_IPV4 , - .name ="CONNMARK" , - .revision =0 , - .version =XTABLES_VERSION , - .size =XT_ALIGN (sizeof (struct xt_connmark_target_info )), - .userspacesize =XT_ALIGN (sizeof (struct xt_connmark_target_info )), - .help = CONNMARK_help, - .init = CONNMARK_init, - .parse = CONNMARK_parse, - .final_check = connmark_tg_check, - .print = CONNMARK_print, - .save = CONNMARK_save, - .extra_opts = CONNMARK_opts, -}; - -static struct xtables_target connmark_target6 = { - .family =NFPROTO_IPV6 , + .family =NFPROTO_UNSPEC , .name ="CONNMARK" , .revision =0 , .version =XTABLES_VERSION ,
@@ -434,23 +418,7 @@ static struct xtables_target connmark_tg_reg = { .version = XTABLES_VERSION, .name = "CONNMARK", .revision = 1, - .family = NFPROTO_IPV4, - .size = XT_ALIGN(sizeof(struct xt_connmark_tginfo1)), - .userspacesize = XT_ALIGN(sizeof(struct xt_connmark_tginfo1)), - .help = connmark_tg_help, - .init = connmark_tg_init, - .parse = connmark_tg_parse, - .final_check = connmark_tg_check, - .print = connmark_tg_print, - .save = connmark_tg_save, - .extra_opts = connmark_tg_opts, -}; - -static struct xtables_target connmark_tg6_reg = { - .version =XTABLES_VERSION , - .name ="CONNMARK" , - .revision =1 , - .family =NFPROTO_IPV6 , + .family = NFPROTO_UNSPEC, .size = XT_ALIGN(sizeof(struct xt_connmark_tginfo1)), .userspacesize = XT_ALIGN(sizeof(struct xt_connmark_tginfo1)), .help = connmark_tg_help,
@@ -465,7 +433,5 @@ static struct xtables_target connmark_tg6_reg = {void _init (void ) {xtables_register_target (&connmark_target); -xtables_register_target (&connmark_target6);xtables_register_target (&connmark_tg_reg); -xtables_register_target (&connmark_tg6_reg); }
extensions/libxt_CONNSECMARK.c +1 -17
@@ -107,22 +107,7 @@ CONNSECMARK_save(const void *ip, const struct xt_entry_target *target) }static struct xtables_target connsecmark_target = { - .family =NFPROTO_IPV4 , - .name ="CONNSECMARK" , - .version =XTABLES_VERSION , - .revision =0 , - .size =XT_ALIGN (sizeof (struct xt_connsecmark_target_info )), - .userspacesize =XT_ALIGN (sizeof (struct xt_connsecmark_target_info )), - .parse = CONNSECMARK_parse, - .help = CONNSECMARK_help, - .final_check = CONNSECMARK_check, - .print = CONNSECMARK_print, - .save = CONNSECMARK_save, - .extra_opts = CONNSECMARK_opts, -}; - -static struct xtables_target connsecmark_target6 = { - .family =NFPROTO_IPV6 , + .family =NFPROTO_UNSPEC , .name ="CONNSECMARK" , .version =XTABLES_VERSION , .revision =0 ,
@@ -139,5 +124,4 @@ static struct xtables_target connsecmark_target6 = {void _init (void ) {xtables_register_target (&connsecmark_target); -xtables_register_target (&connsecmark_target6); }
extensions/libxt_DSCP.c +1 -16
@@ -130,21 +130,7 @@ static void DSCP_save(const void *ip, const struct xt_entry_target *target) }static struct xtables_target dscp_target = { - .family =NFPROTO_IPV4 , - .name ="DSCP" , - .version =XTABLES_VERSION , - .size =XT_ALIGN (sizeof (struct xt_DSCP_info )), - .userspacesize =XT_ALIGN (sizeof (struct xt_DSCP_info )), - .help = DSCP_help, - .parse = DSCP_parse, - .final_check = DSCP_check, - .print = DSCP_print, - .save = DSCP_save, - .extra_opts = DSCP_opts, -}; - -static struct xtables_target dscp_target6 = { - .family =NFPROTO_IPV6 , + .family =NFPROTO_UNSPEC , .name ="DSCP" , .version =XTABLES_VERSION , .size =XT_ALIGN (sizeof (struct xt_DSCP_info )),
@@ -160,5 +146,4 @@ static struct xtables_target dscp_target6 = {void _init (void ) {xtables_register_target (&dscp_target); -xtables_register_target (&dscp_target6); }
extensions/libxt_MARK.c +1 -17
@@ -278,7 +278,7 @@ static void mark_tg_save(const void *ip, const struct xt_entry_target *target) }static struct xtables_target mark_target_v0 = { - .family =NFPROTO_IPV4 , + .family =NFPROTO_UNSPEC , .name ="MARK" , .version =XTABLES_VERSION , .revision =0 ,
@@ -307,21 +307,6 @@ static struct xtables_target mark_target_v1 = { .extra_opts = MARK_opts, }; -static struct xtables_target mark_target6_v0 = { - .family =NFPROTO_IPV6 , - .name ="MARK" , - .version =XTABLES_VERSION , - .revision =0 , - .size =XT_ALIGN (sizeof (struct xt_mark_target_info )), - .userspacesize =XT_ALIGN (sizeof (struct xt_mark_target_info )), - .help = MARK_help, - .parse = MARK_parse_v0, - .final_check = MARK_check, - .print = MARK_print_v0, - .save = MARK_save_v0, - .extra_opts = MARK_opts, -}; -static struct xtables_target mark_tg_reg_v2 = { .version =XTABLES_VERSION , .name ="MARK" ,
@@ -341,6 +326,5 @@ void _init(void) {xtables_register_target (&mark_target_v0);xtables_register_target (&mark_target_v1); -xtables_register_target (&mark_target6_v0);xtables_register_target (&mark_tg_reg_v2); }
extensions/libxt_NFLOG.c +1 -16
@@ -139,21 +139,7 @@ static void NFLOG_save(const void *ip, const struct xt_entry_target *target) }static struct xtables_target nflog_target = { - .family =NFPROTO_IPV4 , - .name ="NFLOG" , - .version =XTABLES_VERSION , - .size =XT_ALIGN (sizeof (struct xt_nflog_info )), - .userspacesize =XT_ALIGN (sizeof (struct xt_nflog_info )), - .help = NFLOG_help, - .init = NFLOG_init, - .parse = NFLOG_parse, - .print = NFLOG_print, - .save = NFLOG_save, - .extra_opts = NFLOG_opts, -}; - -static struct xtables_target nflog_target6 = { - .family =NFPROTO_IPV6 , + .family =NFPROTO_UNSPEC , .name ="NFLOG" , .version =XTABLES_VERSION , .size =XT_ALIGN (sizeof (struct xt_nflog_info )),
@@ -169,5 +155,4 @@ static struct xtables_target nflog_target6 = {void _init (void ) {xtables_register_target (&nflog_target); -xtables_register_target (&nflog_target6); }
extensions/libxt_NFQUEUE.c +1 -15
@@ -78,7 +78,7 @@ static void NFQUEUE_save(const void *ip, const struct xt_entry_target *target) }static struct xtables_target nfqueue_target = { - .family =NFPROTO_IPV4 , + .family =NFPROTO_UNSPEC , .name ="NFQUEUE" , .version =XTABLES_VERSION , .size =XT_ALIGN (sizeof (struct xt_NFQ_info )),
@@ -90,21 +90,7 @@ static struct xtables_target nfqueue_target = { .extra_opts = NFQUEUE_opts }; -static struct xtables_target nfqueue_target6 = { - .family =NFPROTO_IPV6 , - .name ="NFQUEUE" , - .version =XTABLES_VERSION , - .size =XT_ALIGN (sizeof (struct xt_NFQ_info )), - .userspacesize =XT_ALIGN (sizeof (struct xt_NFQ_info )), - .help = NFQUEUE_help, - .parse = NFQUEUE_parse, - .print = NFQUEUE_print, - .save = NFQUEUE_save, - .extra_opts = NFQUEUE_opts, -}; -void _init (void ) {xtables_register_target (&nfqueue_target); -xtables_register_target (&nfqueue_target6); }
extensions/libxt_NOTRACK.c +1 -12
@@ -20,17 +20,7 @@ NOTRACK_parse(int c, char **argv, int invert, unsigned int *flags, }static struct xtables_target notrack_target = { - .family =NFPROTO_IPV4 , - .name ="NOTRACK" , - .version =XTABLES_VERSION , - .size =XT_ALIGN (0 ), - .userspacesize =XT_ALIGN (0 ), - .help = NOTRACK_help, - .parse = NOTRACK_parse, -}; - -static struct xtables_target notrack_target6 = { - .family =NFPROTO_IPV6 , + .family =NFPROTO_UNSPEC , .name ="NOTRACK" , .version =XTABLES_VERSION , .size =XT_ALIGN (0 ),
@@ -42,5 +32,4 @@ static struct xtables_target notrack_target6 = {void _init (void ) {xtables_register_target (¬rack_target); -xtables_register_target (¬rack_target6); }
extensions/libxt_TCPOPTSTRIP.c +1 -17
@@ -180,22 +180,7 @@ tcpoptstrip_tg_save(const void *ip, const struct xt_entry_target *target)static struct xtables_target tcpoptstrip_tg_reg = { .version =XTABLES_VERSION , .name ="TCPOPTSTRIP" , - .family =NFPROTO_IPV4 , - .size =XT_ALIGN (sizeof (struct xt_tcpoptstrip_target_info )), - .userspacesize =XT_ALIGN (sizeof (struct xt_tcpoptstrip_target_info )), - .help = tcpoptstrip_tg_help, - .init = tcpoptstrip_tg_init, - .parse = tcpoptstrip_tg_parse, - .final_check = tcpoptstrip_tg_check, - .print = tcpoptstrip_tg_print, - .save = tcpoptstrip_tg_save, - .extra_opts = tcpoptstrip_tg_opts, -}; - -static struct xtables_target tcpoptstrip_tg6_reg = { - .version =XTABLES_VERSION , - .name ="TCPOPTSTRIP" , - .family =NFPROTO_IPV6 , + .family =NFPROTO_UNSPEC , .size =XT_ALIGN (sizeof (struct xt_tcpoptstrip_target_info )), .userspacesize =XT_ALIGN (sizeof (struct xt_tcpoptstrip_target_info )), .help = tcpoptstrip_tg_help,
@@ -210,5 +195,4 @@ static struct xtables_target tcpoptstrip_tg6_reg = {void _init (void ) {xtables_register_target (&tcpoptstrip_tg_reg); -xtables_register_target (&tcpoptstrip_tg6_reg); }
extensions/libxt_TOS.c +1 -17
@@ -224,22 +224,7 @@ static struct xtables_target tos_tg_reg = { .version = XTABLES_VERSION, .name = "TOS", .revision = 1, - .family = NFPROTO_IPV4, - .size = XT_ALIGN(sizeof(struct xt_tos_target_info)), - .userspacesize = XT_ALIGN(sizeof(struct xt_tos_target_info)), - .help = tos_tg_help, - .parse = tos_tg_parse, - .final_check = tos_tg_check, - .print = tos_tg_print, - .save = tos_tg_save, - .extra_opts = tos_tg_opts, -}; - -static struct xtables_target tos_tg6_reg = { - .version =XTABLES_VERSION , - .name ="TOS" , - .family =NFPROTO_IPV6 , - .revision =1 , + .family = NFPROTO_UNSPEC, .size = XT_ALIGN(sizeof(struct xt_tos_target_info)), .userspacesize = XT_ALIGN(sizeof(struct xt_tos_target_info)), .help = tos_tg_help,
@@ -254,5 +239,4 @@ void _init(void) {xtables_register_target (&tos_tg_reg_v0);xtables_register_target (&tos_tg_reg); -xtables_register_target (&tos_tg6_reg); }
extensions/libxt_comment.c +1 -16
@@ -89,21 +89,7 @@ comment_save(const void *ip, const struct xt_entry_match *match) }static struct xtables_match comment_match = { - .family =NFPROTO_IPV4 , - .name ="comment" , - .version =XTABLES_VERSION , - .size =XT_ALIGN (sizeof (struct xt_comment_info )), - .userspacesize =XT_ALIGN (sizeof (struct xt_comment_info )), - .help = comment_help, - .parse = comment_parse, - .final_check = comment_check, - .print = comment_print, - .save = comment_save, - .extra_opts = comment_opts, -}; - -static struct xtables_match comment_match6 = { - .family =NFPROTO_IPV6 , + .family =NFPROTO_UNSPEC , .name ="comment" , .version =XTABLES_VERSION , .size =XT_ALIGN (sizeof (struct xt_comment_info )),
@@ -119,5 +105,4 @@ static struct xtables_match comment_match6 = {void _init (void ) {xtables_register_match (&comment_match); -xtables_register_match (&comment_match6); }
extensions/libxt_connbytes.c +1 -16
@@ -180,21 +180,7 @@ static void connbytes_save(const void *ip, const struct xt_entry_match *match) }static struct xtables_match connbytes_match = { - .family =NFPROTO_IPV4 , - .name ="connbytes" , - .version =XTABLES_VERSION , - .size =XT_ALIGN (sizeof (struct xt_connbytes_info )), - .userspacesize =XT_ALIGN (sizeof (struct xt_connbytes_info )), - .help = connbytes_help, - .parse = connbytes_parse, - .final_check = connbytes_check, - .print = connbytes_print, - .save = connbytes_save, - .extra_opts = connbytes_opts, -}; - -static struct xtables_match connbytes_match6 = { - .family =NFPROTO_IPV6 , + .family =NFPROTO_UNSPEC , .name ="connbytes" , .version =XTABLES_VERSION , .size =XT_ALIGN (sizeof (struct xt_connbytes_info )),
@@ -210,5 +196,4 @@ static struct xtables_match connbytes_match6 = {void _init (void ) {xtables_register_match (&connbytes_match); -xtables_register_match (&connbytes_match6); }
extensions/libxt_connmark.c +2 -34
@@ -164,22 +164,7 @@ connmark_mt_save(const void *ip, const struct xt_entry_match *match) }static struct xtables_match connmark_mt_reg_v0 = { - .family =NFPROTO_IPV4 , - .name ="connmark" , - .revision =0 , - .version =XTABLES_VERSION , - .size =XT_ALIGN (sizeof (struct xt_connmark_info )), - .userspacesize =XT_ALIGN (sizeof (struct xt_connmark_info )), - .help = connmark_mt_help, - .parse = connmark_parse, - .final_check = connmark_mt_check, - .print = connmark_print, - .save = connmark_save, - .extra_opts = connmark_mt_opts, -}; - -static struct xtables_match connmark_mt6_reg_v0 = { - .family =NFPROTO_IPV6 , + .family =NFPROTO_UNSPEC , .name ="connmark" , .revision =0 , .version =XTABLES_VERSION ,
@@ -197,22 +182,7 @@ static struct xtables_match connmark_mt_reg = { .version = XTABLES_VERSION, .name = "connmark", .revision = 1, - .family = NFPROTO_IPV4, - .size = XT_ALIGN(sizeof(struct xt_connmark_mtinfo1)), - .userspacesize = XT_ALIGN(sizeof(struct xt_connmark_mtinfo1)), - .help = connmark_mt_help, - .parse = connmark_mt_parse, - .final_check = connmark_mt_check, - .print = connmark_mt_print, - .save = connmark_mt_save, - .extra_opts = connmark_mt_opts, -}; - -static struct xtables_match connmark_mt6_reg = { - .version =XTABLES_VERSION , - .name ="connmark" , - .revision =1 , - .family =NFPROTO_IPV6 , + .family = NFPROTO_UNSPEC, .size = XT_ALIGN(sizeof(struct xt_connmark_mtinfo1)), .userspacesize = XT_ALIGN(sizeof(struct xt_connmark_mtinfo1)), .help = connmark_mt_help,
@@ -226,7 +196,5 @@ static struct xtables_match connmark_mt6_reg = {void _init (void ) {xtables_register_match (&connmark_mt_reg_v0); -xtables_register_match (&connmark_mt6_reg_v0);xtables_register_match (&connmark_mt_reg); -xtables_register_match (&connmark_mt6_reg); }
extensions/libxt_dccp.c +1 -16
@@ -336,21 +336,7 @@ static void dccp_save(const void *ip, const struct xt_entry_match *match)static struct xtables_match dccp_match = { .name ="dccp" , - .family =NFPROTO_IPV4 , - .version =XTABLES_VERSION , - .size =XT_ALIGN (sizeof (struct xt_dccp_info )), - .userspacesize =XT_ALIGN (sizeof (struct xt_dccp_info )), - .help = dccp_help, - .init = dccp_init, - .parse = dccp_parse, - .print = dccp_print, - .save = dccp_save, - .extra_opts = dccp_opts, -}; - -static struct xtables_match dccp_match6 = { - .name ="dccp" , - .family =NFPROTO_IPV6 , + .family =NFPROTO_UNSPEC , .version =XTABLES_VERSION , .size =XT_ALIGN (sizeof (struct xt_dccp_info )), .userspacesize =XT_ALIGN (sizeof (struct xt_dccp_info )),
@@ -365,5 +351,4 @@ static struct xtables_match dccp_match6 = {void _init (void ) {xtables_register_match (&dccp_match); -xtables_register_match (&dccp_match6); }
extensions/libxt_dscp.c +1 -16
@@ -131,21 +131,7 @@ static void dscp_save(const void *ip, const struct xt_entry_match *match) }static struct xtables_match dscp_match = { - .family =NFPROTO_IPV4 , - .name ="dscp" , - .version =XTABLES_VERSION , - .size =XT_ALIGN (sizeof (struct xt_dscp_info )), - .userspacesize =XT_ALIGN (sizeof (struct xt_dscp_info )), - .help = dscp_help, - .parse = dscp_parse, - .final_check = dscp_check, - .print = dscp_print, - .save = dscp_save, - .extra_opts = dscp_opts, -}; - -static struct xtables_match dscp_match6 = { - .family =NFPROTO_IPV6 , + .family =NFPROTO_UNSPEC , .name ="dscp" , .version =XTABLES_VERSION , .size =XT_ALIGN (sizeof (struct xt_dscp_info )),
@@ -161,5 +147,4 @@ static struct xtables_match dscp_match6 = {void _init (void ) {xtables_register_match (&dscp_match); -xtables_register_match (&dscp_match6); }
extensions/libxt_esp.c +1 -16
@@ -149,21 +149,7 @@ static void esp_save(const void *ip, const struct xt_entry_match *match) }static struct xtables_match esp_match = { - .family =NFPROTO_IPV4 , - .name ="esp" , - .version =XTABLES_VERSION , - .size =XT_ALIGN (sizeof (struct xt_esp )), - .userspacesize =XT_ALIGN (sizeof (struct xt_esp )), - .help = esp_help, - .init = esp_init, - .parse = esp_parse, - .print = esp_print, - .save = esp_save, - .extra_opts = esp_opts, -}; - -static struct xtables_match esp_match6 = { - .family =NFPROTO_IPV6 , + .family =NFPROTO_UNSPEC , .name ="esp" , .version =XTABLES_VERSION , .size =XT_ALIGN (sizeof (struct xt_esp )),
@@ -180,5 +166,4 @@ void_init (void) {xtables_register_match (&esp_match); -xtables_register_match (&esp_match6); }
extensions/libxt_hashlimit.c +1 -18
@@ -660,23 +660,7 @@ hashlimit_mt6_save(const void *ip, const struct xt_entry_match *match) }static struct xtables_match hashlimit_match = { - .family =NFPROTO_IPV4 , - .name ="hashlimit" , - .version =XTABLES_VERSION , - .revision =0 , - .size =XT_ALIGN (sizeof (struct xt_hashlimit_info )), - .userspacesize = offsetof(struct xt_hashlimit_info , hinfo), - .help = hashlimit_help, - .init = hashlimit_init, - .parse = hashlimit_parse, - .final_check = hashlimit_check, - .print = hashlimit_print, - .save = hashlimit_save, - .extra_opts = hashlimit_opts, -}; - -static struct xtables_match hashlimit_match6 = { - .family =NFPROTO_IPV6 , + .family =NFPROTO_UNSPEC , .name ="hashlimit" , .version =XTABLES_VERSION , .revision =0 ,
@@ -726,7 +710,6 @@ static struct xtables_match hashlimit_mt6_reg = {void _init (void ) {xtables_register_match (&hashlimit_match); -xtables_register_match (&hashlimit_match6);xtables_register_match (&hashlimit_mt_reg);xtables_register_match (&hashlimit_mt6_reg); }
extensions/libxt_helper.c +1 -15
@@ -69,20 +69,7 @@ static void helper_save(const void *ip, const struct xt_entry_match *match) }static struct xtables_match helper_match = { - .family =NFPROTO_IPV4 , - .name ="helper" , - .version =XTABLES_VERSION , - .size =XT_ALIGN (sizeof (struct xt_helper_info )), - .help = helper_help, - .parse = helper_parse, - .final_check = helper_check, - .print = helper_print, - .save = helper_save, - .extra_opts = helper_opts, -}; - -static struct xtables_match helper_match6 = { - .family =NFPROTO_IPV6 , + .family =NFPROTO_UNSPEC , .name ="helper" , .version =XTABLES_VERSION , .size =XT_ALIGN (sizeof (struct xt_helper_info )),
@@ -97,5 +84,4 @@ static struct xtables_match helper_match6 = {void _init (void ) {xtables_register_match (&helper_match); -xtables_register_match (&helper_match6); }
extensions/libxt_mac.c +1 -16
@@ -112,21 +112,7 @@ static void mac_save(const void *ip, const struct xt_entry_match *match) }static struct xtables_match mac_match = { - .family =NFPROTO_IPV4 , - .name ="mac" , - .version =XTABLES_VERSION , - .size =XT_ALIGN (sizeof (struct xt_mac_info )), - .userspacesize =XT_ALIGN (sizeof (struct xt_mac_info )), - .help = mac_help, - .parse = mac_parse, - .final_check = mac_check, - .print = mac_print, - .save = mac_save, - .extra_opts = mac_opts, -}; - -static struct xtables_match mac_match6 = { - .family =NFPROTO_IPV6 , + .family =NFPROTO_UNSPEC , .name ="mac" , .version =XTABLES_VERSION , .size =XT_ALIGN (sizeof (struct xt_mac_info )),
@@ -142,5 +128,4 @@ static struct xtables_match mac_match6 = {void _init (void ) {xtables_register_match (&mac_match); -xtables_register_match (&mac_match6); }
extensions/libxt_owner.c +1 -17
@@ -567,22 +567,7 @@ static struct xtables_match owner_mt_reg = { .version = XTABLES_VERSION, .name = "owner", .revision = 1, - .family = NFPROTO_IPV4, - .size = XT_ALIGN(sizeof(struct xt_owner_match_info)), - .userspacesize = XT_ALIGN(sizeof(struct xt_owner_match_info)), - .help = owner_mt_help, - .parse = owner_mt_parse, - .final_check = owner_mt_check, - .print = owner_mt_print, - .save = owner_mt_save, - .extra_opts = owner_mt_opts, -}; - -static struct xtables_match owner_mt6_reg = { - .version =XTABLES_VERSION , - .name ="owner" , - .revision =1 , - .family =NFPROTO_IPV6 , + .family = NFPROTO_UNSPEC, .size = XT_ALIGN(sizeof(struct xt_owner_match_info)), .userspacesize = XT_ALIGN(sizeof(struct xt_owner_match_info)), .help = owner_mt_help,
@@ -598,5 +583,4 @@ void _init(void)xtables_register_match (&owner_mt_reg_v0);xtables_register_match (&owner_mt6_reg_v0);xtables_register_match (&owner_mt_reg); -xtables_register_match (&owner_mt6_reg); }
extensions/libxt_physdev.c +1 -16
@@ -161,21 +161,7 @@ static void physdev_save(const void *ip, const struct xt_entry_match *match) }static struct xtables_match physdev_match = { - .family =NFPROTO_IPV4 , - .name ="physdev" , - .version =XTABLES_VERSION , - .size =XT_ALIGN (sizeof (struct xt_physdev_info )), - .userspacesize =XT_ALIGN (sizeof (struct xt_physdev_info )), - .help = physdev_help, - .parse = physdev_parse, - .final_check = physdev_check, - .print = physdev_print, - .save = physdev_save, - .extra_opts = physdev_opts, -}; - -static struct xtables_match physdev_match6 = { - .family =NFPROTO_IPV6 , + .family =NFPROTO_UNSPEC , .name ="physdev" , .version =XTABLES_VERSION , .size =XT_ALIGN (sizeof (struct xt_physdev_info )),
@@ -191,5 +177,4 @@ static struct xtables_match physdev_match6 = {void _init (void ) {xtables_register_match (&physdev_match); -xtables_register_match (&physdev_match6); }
extensions/libxt_recent.c +1 -18
@@ -215,7 +215,7 @@ static void recent_save(const void *ip, const struct xt_entry_match *match)static struct xtables_match recent_mt_reg = { .name ="recent" , .version =XTABLES_VERSION , - .family =NFPROTO_IPV4 , + .family =NFPROTO_UNSPEC , .size =XT_ALIGN (sizeof (struct xt_recent_mtinfo )), .userspacesize =XT_ALIGN (sizeof (struct xt_recent_mtinfo )), .help = recent_help,
@@ -227,24 +227,7 @@ static struct xtables_match recent_mt_reg = { .extra_opts = recent_opts, }; -static struct xtables_match recent_mt6_reg = { - .version =XTABLES_VERSION , - .name ="recent" , - .revision =0 , - .family =NFPROTO_IPV6 , - .size =XT_ALIGN (sizeof (struct xt_recent_mtinfo )), - .userspacesize =XT_ALIGN (sizeof (struct xt_recent_mtinfo )), - .help = recent_help, - .init = recent_init, - .parse = recent_parse, - .final_check = recent_check, - .print = recent_print, - .save = recent_save, - .extra_opts = recent_opts, -}; -void _init (void ) {xtables_register_match (&recent_mt_reg); -xtables_register_match (&recent_mt6_reg); }
extensions/libxt_sctp.c +1 -16
@@ -496,21 +496,7 @@ static void sctp_save(const void *ip, const struct xt_entry_match *match)static struct xtables_match sctp_match = { .name ="sctp" , - .family =NFPROTO_IPV4 , - .version =XTABLES_VERSION , - .size =XT_ALIGN (sizeof (struct xt_sctp_info )), - .userspacesize =XT_ALIGN (sizeof (struct xt_sctp_info )), - .help = sctp_help, - .init = sctp_init, - .parse = sctp_parse, - .print = sctp_print, - .save = sctp_save, - .extra_opts = sctp_opts, -}; - -static struct xtables_match sctp_match6 = { - .name ="sctp" , - .family =NFPROTO_IPV6 , + .family =NFPROTO_UNSPEC , .version =XTABLES_VERSION , .size =XT_ALIGN (sizeof (struct xt_sctp_info )), .userspacesize =XT_ALIGN (sizeof (struct xt_sctp_info )),
@@ -525,5 +511,4 @@ static struct xtables_match sctp_match6 = {void _init (void ) {xtables_register_match (&sctp_match); -xtables_register_match (&sctp_match6); }
extensions/libxt_state.c +1 -16
@@ -139,21 +139,7 @@ static void state_save(const void *ip, const struct xt_entry_match *match) }static struct xtables_match state_match = { - .family =NFPROTO_IPV4 , - .name ="state" , - .version =XTABLES_VERSION , - .size =XT_ALIGN (sizeof (struct xt_state_info )), - .userspacesize =XT_ALIGN (sizeof (struct xt_state_info )), - .help = state_help, - .parse = state_parse, - .final_check = state_final_check, - .print = state_print, - .save = state_save, - .extra_opts = state_opts, -}; - -static struct xtables_match state_match6 = { - .family =NFPROTO_IPV6 , + .family =NFPROTO_UNSPEC , .name ="state" , .version =XTABLES_VERSION , .size =XT_ALIGN (sizeof (struct xt_state_info )),
@@ -169,5 +155,4 @@ static struct xtables_match state_match6 = {void _init (void ) {xtables_register_match (&state_match); -xtables_register_match (&state_match6); }
extensions/libxt_tcp.c +1 -16
@@ -375,21 +375,7 @@ static void tcp_save(const void *ip, const struct xt_entry_match *match) }static struct xtables_match tcp_match = { - .family =NFPROTO_IPV4 , - .name ="tcp" , - .version =XTABLES_VERSION , - .size =XT_ALIGN (sizeof (struct xt_tcp )), - .userspacesize =XT_ALIGN (sizeof (struct xt_tcp )), - .help = tcp_help, - .init = tcp_init, - .parse = tcp_parse, - .print = tcp_print, - .save = tcp_save, - .extra_opts = tcp_opts, -}; - -static struct xtables_match tcp_match6 = { - .family =NFPROTO_IPV6 , + .family =NFPROTO_UNSPEC , .name ="tcp" , .version =XTABLES_VERSION , .size =XT_ALIGN (sizeof (struct xt_tcp )),
@@ -406,5 +392,4 @@ void_init (void) {xtables_register_match (&tcp_match); -xtables_register_match (&tcp_match6); }
extensions/libxt_tcpmss.c +1 -16
@@ -109,21 +109,7 @@ static void tcpmss_save(const void *ip, const struct xt_entry_match *match) }static struct xtables_match tcpmss_match = { - .family =NFPROTO_IPV4 , - .name ="tcpmss" , - .version =XTABLES_VERSION , - .size =XT_ALIGN (sizeof (struct xt_tcpmss_match_info )), - .userspacesize =XT_ALIGN (sizeof (struct xt_tcpmss_match_info )), - .help = tcpmss_help, - .parse = tcpmss_parse, - .final_check = tcpmss_check, - .print = tcpmss_print, - .save = tcpmss_save, - .extra_opts = tcpmss_opts, -}; - -static struct xtables_match tcpmss_match6 = { - .family =NFPROTO_IPV6 , + .family =NFPROTO_UNSPEC , .name ="tcpmss" , .version =XTABLES_VERSION , .size =XT_ALIGN (sizeof (struct xt_tcpmss_match_info )),
@@ -139,5 +125,4 @@ static struct xtables_match tcpmss_match6 = {void _init (void ) {xtables_register_match (&tcpmss_match); -xtables_register_match (&tcpmss_match6); }
extensions/libxt_tos.c +1 -17
@@ -155,22 +155,7 @@ static struct xtables_match tos_mt_reg_v0 = {static struct xtables_match tos_mt_reg = { .version =XTABLES_VERSION , .name ="tos" , - .family =NFPROTO_IPV4 , - .revision =1 , - .size =XT_ALIGN (sizeof (struct xt_tos_match_info )), - .userspacesize =XT_ALIGN (sizeof (struct xt_tos_match_info )), - .help = tos_mt_help, - .parse = tos_mt_parse, - .final_check = tos_mt_check, - .print = tos_mt_print, - .save = tos_mt_save, - .extra_opts = tos_mt_opts, -}; - -static struct xtables_match tos_mt6_reg = { - .version =XTABLES_VERSION , - .name ="tos" , - .family =NFPROTO_IPV6 , + .family =NFPROTO_UNSPEC , .revision =1 , .size =XT_ALIGN (sizeof (struct xt_tos_match_info )), .userspacesize =XT_ALIGN (sizeof (struct xt_tos_match_info )),
@@ -186,5 +171,4 @@ void _init(void) {xtables_register_match (&tos_mt_reg_v0);xtables_register_match (&tos_mt_reg); -xtables_register_match (&tos_mt6_reg); }
extensions/libxt_udp.c +1 -16
@@ -191,21 +191,7 @@ static void udp_save(const void *ip, const struct xt_entry_match *match) }static struct xtables_match udp_match = { - .family =NFPROTO_IPV4 , - .name ="udp" , - .version =XTABLES_VERSION , - .size =XT_ALIGN (sizeof (struct xt_udp )), - .userspacesize =XT_ALIGN (sizeof (struct xt_udp )), - .help = udp_help, - .init = udp_init, - .parse = udp_parse, - .print = udp_print, - .save = udp_save, - .extra_opts = udp_opts, -}; - -static struct xtables_match udp_match6 = { - .family =NFPROTO_IPV6 , + .family =NFPROTO_UNSPEC , .name ="udp" , .version =XTABLES_VERSION , .size =XT_ALIGN (sizeof (struct xt_udp )),
@@ -222,5 +208,4 @@ void_init (void) {xtables_register_match (&udp_match); -xtables_register_match (&udp_match6); }
Signature · 1 line
1.6.3.2
PATCH 4/10 iptables: allow for parse-less extensions
In reply to Jan EngelhardtThis means we can do some code removal in extensions.
--- ip6tables.c | 9 +++++---- iptables.c | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-)
ip6tables.c +5 -4
@@ -1699,13 +1699,14 @@ int do_command6(int argc, char *argv[], char **table, struct ip6tc_handle **handexit_tryhelp (2 );default : -if (!target - || !(target->parse (c - target->option_offset, +if (target ==NULL || target->parse ==NULL || + !target->parse (c - target->option_offset, argv, invert, &target->tflags, - &fw, &target->t))) { + &fw, &target->t)) {for (matchp = matches; matchp; matchp = matchp->next) { -if (matchp->completed) +if (matchp->completed || + matchp->match->parse ==NULL )continue ; if (matchp->match->parse(c - matchp->match->option_offset, argv, invert,
iptables.c +5 -4
@@ -1727,13 +1727,14 @@ int do_command(int argc, char *argv[], char **table, struct iptc_handle **handleexit_tryhelp (2 );default : -if (!target - || !(target->parse (c - target->option_offset, +if (target ==NULL || target->parse ==NULL || + !target->parse (c - target->option_offset, argv, invert, &target->tflags, - &fw, &target->t))) { + &fw, &target->t)) {for (matchp = matches; matchp; matchp = matchp->next) { -if (matchp->completed) +if (matchp->completed || + matchp->match->parse ==NULL )continue ; if (matchp->match->parse(c - matchp->match->option_offset, argv, invert,
Signature · 1 line
1.6.3.2
PATCH 5/10 iptables: allow for help-less extensions
In reply to Jan EngelhardtThis is for extensions that do not take any options, and which subsequently do not offer any help text either.
--- Makefile.am | 16 ++++++++-------- ip6tables.c | 18 ++---------------- iptables.c | 18 ++---------------- xshared.c | 31 +++++++++++++++++++++++++++++++ xshared.h | 10 ++++++++++ 5 files changed, 53 insertions(+), 40 deletions(-) create mode 100644 xshared.c create mode 100644 xshared.h
Makefile.am +8 -8
@@ -29,23 +29,23 @@ libxtables_la_LDFLAGS = -version-info ${libxtables_vcurrent}:0:${libxtables_vage libxtables_la_LIBADD = -ldl # iptables, dynamic -iptables_SOURCES = iptables-standalone.c iptables.c +iptables_SOURCES = iptables-standalone.c iptables.c xshared.c iptables_LDFLAGS = -rdynamic iptables_LDADD = libiptc/libip4tc.la extensions/libext4.a libxtables.la -lm iptables_xml_LDADD = libxtables.la iptables_multi_SOURCES = iptables-multi.c iptables-save.c \ iptables-restore.c iptables-xml.c \ - iptables-standalone.c iptables.c + iptables-standalone.c iptables.c xshared.c iptables_multi_CFLAGS = ${AM_CFLAGS} -DIPTABLES_MULTI iptables_multi_LDFLAGS = ${iptables_LDFLAGS} iptables_multi_LDADD = ${iptables_LDADD} -iptables_restore_SOURCES = iptables-restore.c iptables.c +iptables_restore_SOURCES = iptables-restore.c iptables.c xshared.c iptables_restore_LDFLAGS = ${iptables_LDFLAGS} iptables_restore_LDADD = ${iptables_LDADD} -iptables_save_SOURCES = iptables-save.c iptables.c +iptables_save_SOURCES = iptables-save.c iptables.c xshared.c iptables_save_LDFLAGS = ${iptables_LDFLAGS} iptables_save_LDADD = ${iptables_LDADD}
@@ -57,22 +57,22 @@ iptables_static_LDADD = libiptc/libip4tc.la extensions/libext4.a -lm iptables_xml_SOURCES = iptables-xml.c # ip6tables, dynamic -ip6tables_SOURCES = ip6tables-standalone.c ip6tables.c +ip6tables_SOURCES = ip6tables-standalone.c ip6tables.c xshared.c ip6tables_LDFLAGS = -rdynamic ip6tables_LDADD = libiptc/libip6tc.la extensions/libext6.a libxtables.la -lm ip6tables_multi_SOURCES = ip6tables-multi.c ip6tables-save.c \ ip6tables-restore.c ip6tables-standalone.c \ - ip6tables.c + ip6tables.c xshared.c ip6tables_multi_CFLAGS = ${AM_CFLAGS} -DIPTABLES_MULTI ip6tables_multi_LDFLAGS = ${ip6tables_LDFLAGS} ip6tables_multi_LDADD = ${ip6tables_LDADD} -ip6tables_restore_SOURCES = ip6tables-restore.c ip6tables.c +ip6tables_restore_SOURCES = ip6tables-restore.c ip6tables.c xshared.c ip6tables_restore_LDFLAGS = ${ip6tables_LDFLAGS} ip6tables_restore_LDADD = ${ip6tables_LDADD} -ip6tables_save_SOURCES = ip6tables-save.c ip6tables.c +ip6tables_save_SOURCES = ip6tables-save.c ip6tables.c xshared.c ip6tables_save_LDFLAGS = ${ip6tables_LDFLAGS} ip6tables_save_LDADD = ${ip6tables_LDADD}
ip6tables.c +2 -16
@@ -43,6 +43,7 @@#include <sys/types.h> #include <sys/socket.h> #include "ip6tables-multi.h" +#include "xshared.h" #ifndef TRUE #define TRUE 1
@@ -235,9 +236,6 @@ exit_tryhelp(int status)static void exit_printhelp (struct xtables_rule_match *matches) { -struct xtables_rule_match *matchp =NULL ; -struct xtables_target *t =NULL ; -printf ("%s v%s\n\n" "Usage: %s -[AD] chain rule-specification [options]\n" " %s -I chain [rulenum] rule-specification [options]\n"
@@ -307,19 +305,7 @@ exit_printhelp(struct xtables_rule_match *matches)" --set-counters PKTS BYTES set the counter during insert/append\n" "[!] --version -V print package version.\n"); -/* Print out any special helps. A user might like to be able to add a --help -to the commandline, and see expected results. So we call help for all -specified matches & targets */ -for (t = xtables_targets; t; t = t->next) { -if (t->used) { -printf ("\n" ); - t->help (); - } - } -for (matchp = matches; matchp; matchp = matchp->next) { -printf ("\n" ); - matchp->match->help (); - } +print_extension_helps (xtables_targets, matches);exit (0 ); }
iptables.c +2 -16
@@ -40,6 +40,7 @@#include <xtables.h> #include <fcntl.h> #include <sys/utsname.h> +#include "xshared.h" #ifndef TRUE #define TRUE 1
@@ -248,9 +249,6 @@ exit_tryhelp(int status)static void exit_printhelp (struct xtables_rule_match *matches) { -struct xtables_rule_match *matchp =NULL ; -struct xtables_target *t =NULL ; -printf ("%s v%s\n\n" "Usage: %s -[AD] chain rule-specification [options]\n" " %s -I chain [rulenum] rule-specification [options]\n"
@@ -320,19 +318,7 @@ exit_printhelp(struct xtables_rule_match *matches)" --set-counters PKTS BYTES set the counter during insert/append\n" "[!] --version -V print package version.\n"); -/* Print out any special helps. A user might like to be able -to add a --help to the commandline, and see expected -results. So we call help for all specified matches & targets */ -for (t = xtables_targets; t ;t = t->next) { -if (t->used) { -printf ("\n" ); - t->help (); - } - } -for (matchp = matches; matchp; matchp = matchp->next) { -printf ("\n" ); - matchp->match->help (); - } +print_extension_helps (xtables_targets, matches);exit (0 ); }
xshared.c new file +31 -0
@@ -0,0 +1,31 @@ +#include <stdio.h> +#include <xtables.h> +#include "xshared.h" + +/* +* Print out any special helps. A user might like to be able to add a --help +* to the commandline, and see expected results. So we call help for all +* specified matches and targets. +*/ +void print_extension_helps (const struct xtables_target *t, +const struct xtables_rule_match *m) +{ +for (; t !=NULL ; t = t->next) { +if (t->used) { +printf ("\n" ); +if (t->help ==NULL ) +printf ("%s does not take any options\n" , + t->name); +else + t->help (); + } + } +for (; m !=NULL ; m = m->next) { +printf ("\n" ); +if (m->match->help ==NULL ) +printf ("%s does not take any options\n" , + m->match->name); +else + m->match->help (); + } +}
xshared.h new file +10 -0
@@ -0,0 +1,10 @@ +#ifndef IPTABLES_XSHARED_H +#define IPTABLES_XSHARED_H 1 + +struct xtables_rule_match ; +struct xtables_target ; + +extern void print_extension_helps (const struct xtables_target *, +const struct xtables_rule_match *); + +#endif /* IPTABLES_XSHARED_H */
Signature · 1 line
1.6.3.2
PATCH 6/10 extensions: remove empty help and parse functions
In reply to Jan Engelhardt--- extensions/libip6t_eui64.c | 26 -------------------------- extensions/libipt_MIRROR.c | 20 -------------------- extensions/libipt_unclean.c | 16 ---------------- extensions/libxt_NOTRACK.c | 20 -------------------- extensions/libxt_TRACE.c | 13 ------------- extensions/libxt_socket.c | 20 -------------------- extensions/libxt_standard.c | 12 ------------ 7 files changed, 0 insertions(+), 127 deletions(-)
extensions/libip6t_eui64.c +0 -26
@@ -1,38 +1,12 @@/* Shared library add-on to ip6tables to add EUI64 address checking support. */ -#include <stdio.h> -#include <netdb.h> -#include <string.h> -#include <stdlib.h> -#include <getopt.h> -#if defined(__GLIBC__) && __GLIBC__ ==2 -#include <net/ethernet.h> -#else -#include <linux/if_ether.h> -#endif #include <xtables.h> -static void eui64_help (void ) -{ -printf ( -"eui64 match options:\n" -" This module hasn't got any option\n" -" This module checks for EUI64 IPv6 addresses\n" ); -} - -static int eui64_parse (int c,char **argv,int invert,unsigned int *flags, -const void *entry,struct xt_entry_match **match) -{ -return 0 ; -} -static struct xtables_match eui64_mt6_reg = { .name ="eui64" , .version =XTABLES_VERSION , .family =NFPROTO_IPV6 , .size =XT_ALIGN (sizeof (int )), .userspacesize =XT_ALIGN (sizeof (int )), - .help = eui64_help, - .parse = eui64_parse, };void _init (void )
extensions/libipt_MIRROR.c +0 -20
@@ -1,32 +1,12 @@/* Shared library add-on to iptables to add MIRROR target support. */ -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <getopt.h> -#include <xtables.h> -static void MIRROR_help (void ) -{ -printf ("MIRROR target takes no options\n" ); -} - -static int MIRROR_parse (int c,char **argv,int invert,unsigned int *flags, -const void *entry,struct xt_entry_target **target) -{ -return 0 ; -} -static struct xtables_target mirror_tg_reg = { .name ="MIRROR" , .version =XTABLES_VERSION , .family =NFPROTO_IPV4 , .size =XT_ALIGN (0 ), .userspacesize =XT_ALIGN (0 ), - .help = MIRROR_help, - .parse = MIRROR_parse, - .print =NULL , - .save =NULL , };void _init (void )
extensions/libipt_unclean.c +0 -16
@@ -1,28 +1,12 @@/* Shared library add-on to iptables for unclean. */ -#include <stdio.h> -#include <stdlib.h> -#include <getopt.h> #include <xtables.h> -static void unclean_help (void ) -{ -printf ("unclean match takes no options\n" ); -} - -static int unclean_parse (int c,char **argv,int invert,unsigned int *flags, -const void *entry,struct xt_entry_match **match) -{ -return 0 ; -} -static struct xtables_match unclean_mt_reg = { .name ="unclean" , .version =XTABLES_VERSION , .family =NFPROTO_IPV4 , .size =XT_ALIGN (0 ), .userspacesize =XT_ALIGN (0 ), - .help = unclean_help, - .parse = unclean_parse, };void _init (void )
extensions/libxt_NOTRACK.c +0 -20
@@ -1,23 +1,5 @@/* Shared library add-on to iptables to add NOTRACK target support. */ -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <getopt.h> -#include <xtables.h> -#include <linux/netfilter/x_tables.h> - -static void NOTRACK_help (void ) -{ -printf ("NOTRACK target takes no options\n" ); -} - -static int -NOTRACK_parse (int c,char **argv,int invert,unsigned int *flags, -const void *entry,struct xt_entry_target **target) -{ -return 0 ; -}static struct xtables_target notrack_target = { .family =NFPROTO_UNSPEC ,
@@ -25,8 +7,6 @@ static struct xtables_target notrack_target = { .version = XTABLES_VERSION, .size = XT_ALIGN(0), .userspacesize = XT_ALIGN(0), - .help = NOTRACK_help, - .parse = NOTRACK_parse, };void _init (void )
extensions/libxt_TRACE.c +0 -13
@@ -7,25 +7,12 @@#include <xtables.h> #include <linux/netfilter/x_tables.h> -static void TRACE_help (void ) -{ -printf ("TRACE target takes no options\n" ); -} - -static int TRACE_parse (int c,char **argv,int invert,unsigned int *flags, -const void *entry,struct xt_entry_target **target) -{ -return 0 ; -} -static struct xtables_target trace_target = { .family =NFPROTO_UNSPEC , .name ="TRACE" , .version =XTABLES_VERSION , .size =XT_ALIGN (0 ), .userspacesize =XT_ALIGN (0 ), - .help = TRACE_help, - .parse = TRACE_parse, };void _init (void )
extensions/libxt_socket.c +0 -20
@@ -3,34 +3,14 @@* * Copyright (C) 2007 BalaBit IT Ltd. */ -#include <stdio.h> -#include <getopt.h> #include <xtables.h> -static void socket_mt_help (void ) -{ -printf ("socket v%s has no options\n\n" ,XTABLES_VERSION ); -} - -static int socket_mt_parse (int c,char **argv,int invert,unsigned int *flags, -const void *entry,struct xt_entry_match **match) -{ -return 0 ; -} - -static void socket_mt_check (unsigned int flags) -{ -} -static struct xtables_match socket_mt_reg = { .name ="socket" , .version =XTABLES_VERSION , .family =NFPROTO_IPV4 , .size =XT_ALIGN (0 ), .userspacesize =XT_ALIGN (0 ), - .parse = socket_mt_parse, - .final_check = socket_mt_check, - .help = socket_mt_help, };void _init (void )
extensions/libxt_standard.c +0 -12
@@ -1,10 +1,5 @@/* Shared library add-on to iptables for standard target support. */ #include <stdio.h> -#include <netdb.h> -#include <string.h> -#include <stdlib.h> -#include <limits.h> -#include <getopt.h> #include <xtables.h> static void standard_help (void )
@@ -14,12 +9,6 @@ static void standard_help(void) "(If target is DROP, ACCEPT, RETURN or nothing)\n"); } -static int standard_parse (int c,char **argv,int invert,unsigned int *flags, -const void *entry,struct xt_entry_target **target) -{ -return 0 ; -} -static struct xtables_target standard_target = { .family =NFPROTO_UNSPEC , .name ="standard" ,
@@ -27,7 +16,6 @@ static struct xtables_target standard_target = { .size = XT_ALIGN(sizeof(int)), .userspacesize = XT_ALIGN(sizeof(int)), .help = standard_help, - .parse = standard_parse, };void _init (void )
Signature · 1 line
1.6.3.2
PATCH 7/10 xtables: add multi-registration functions
In reply to Jan EngelhardtSimilar to the ones that are present in the kernel.
--- include/xtables.h.in | 2 ++ xtables.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 0 deletions(-)
include/xtables.h.in +2 -0
@@ -233,7 +233,9 @@ extern struct xtables_target *xtables_find_target(const char *name, /* Your shared library should call one of these. */ extern void xtables_register_match(struct xtables_match *me); +extern void xtables_register_matches(struct xtables_match *, unsigned int); extern void xtables_register_target(struct xtables_target *me); +extern void xtables_register_targets(struct xtables_target *, unsigned int); extern bool xtables_strtoul(const char *, char **, unsigned long *, unsigned long, unsigned long);
xtables.c +14 -0
@@ -794,6 +794,13 @@ void xtables_register_match(struct xtables_match *me) me->mflags =0 ; } +void xtables_register_matches (struct xtables_match *match,unsigned int n) +{ +do { +xtables_register_match (&match[--n]); + }while (n >0 ); +} +void xtables_register_target (struct xtables_target *me) {struct xtables_target *old;
@@ -868,6 +875,13 @@ void xtables_register_target(struct xtables_target *me) me->tflags =0 ; } +void xtables_register_targets (struct xtables_target *target,unsigned int n) +{ +do { +xtables_register_target (&target[--n]); + }while (n >0 ); +} +/** * xtables_param_act - act on condition * @status: a constant from enum xtables_exittype
Signature · 1 line
1.6.3.2
PATCH 8/10 extensions: collapse data variables to use multi-reg calls
In reply to Jan Engelhardt--- extensions/libipt_addrtype.c | 58 ++++++++++---------- extensions/libxt_CONNMARK.c | 64 +++++++++++----------- extensions/libxt_MARK.c | 90 +++++++++++++++---------------- extensions/libxt_TOS.c | 60 ++++++++++---------- extensions/libxt_connlimit.c | 60 ++++++++++---------- extensions/libxt_connmark.c | 60 ++++++++++---------- extensions/libxt_conntrack.c | 90 +++++++++++++++---------------- extensions/libxt_hashlimit.c | 96 ++++++++++++++++----------------- extensions/libxt_iprange.c | 90 +++++++++++++++---------------- extensions/libxt_mark.c | 60 ++++++++++---------- extensions/libxt_multiport.c | 120 ++++++++++++++++++++---------------------- extensions/libxt_owner.c | 90 +++++++++++++++---------------- extensions/libxt_policy.c | 56 ++++++++++---------- extensions/libxt_string.c | 64 +++++++++++----------- extensions/libxt_tos.c | 60 ++++++++++---------- 15 files changed, 552 insertions(+), 566 deletions(-)
extensions/libipt_addrtype.c +29 -29
@@ -323,38 +323,38 @@ static const struct option addrtype_opts_v1[] = { { .name = NULL } }; -static struct xtables_match addrtype_mt_reg_v0 = { - .name ="addrtype" , - .version =XTABLES_VERSION , - .family =NFPROTO_IPV4 , - .size =XT_ALIGN (sizeof (struct ipt_addrtype_info )), - .userspacesize =XT_ALIGN (sizeof (struct ipt_addrtype_info )), - .help = addrtype_help_v0, - .parse = addrtype_parse_v0, - .final_check = addrtype_check_v0, - .print = addrtype_print_v0, - .save = addrtype_save_v0, - .extra_opts = addrtype_opts_v0, -}; - -static struct xtables_match addrtype_mt_reg_v1 = { - .name ="addrtype" , - .version =XTABLES_VERSION , - .family =NFPROTO_IPV4 , - .size =XT_ALIGN (sizeof (struct ipt_addrtype_info_v1 )), - .userspacesize =XT_ALIGN (sizeof (struct ipt_addrtype_info_v1 )), - .help = addrtype_help_v1, - .parse = addrtype_parse_v1, - .final_check = addrtype_check_v1, - .print = addrtype_print_v1, - .save = addrtype_save_v1, - .extra_opts = addrtype_opts_v1, - .revision =1 , +static struct xtables_match addrtype_mt_reg[] = { + { + .name ="addrtype" , + .version =XTABLES_VERSION , + .family =NFPROTO_IPV4 , + .size =XT_ALIGN (sizeof (struct ipt_addrtype_info )), + .userspacesize =XT_ALIGN (sizeof (struct ipt_addrtype_info )), + .help = addrtype_help_v0, + .parse = addrtype_parse_v0, + .final_check = addrtype_check_v0, + .print = addrtype_print_v0, + .save = addrtype_save_v0, + .extra_opts = addrtype_opts_v0, + }, + { + .name ="addrtype" , + .revision =1 , + .version =XTABLES_VERSION , + .family =NFPROTO_IPV4 , + .size =XT_ALIGN (sizeof (struct ipt_addrtype_info_v1 )), + .userspacesize =XT_ALIGN (sizeof (struct ipt_addrtype_info_v1 )), + .help = addrtype_help_v1, + .parse = addrtype_parse_v1, + .final_check = addrtype_check_v1, + .print = addrtype_print_v1, + .save = addrtype_save_v1, + .extra_opts = addrtype_opts_v1, + }, };void _init (void ) { -xtables_register_match (&addrtype_mt_reg_v0); -xtables_register_match (&addrtype_mt_reg_v1); +xtables_register_matches (addrtype_mt_reg,ARRAY_SIZE (addrtype_mt_reg)); }
extensions/libxt_CONNMARK.c +32 -32
72 lines not on this page · raw message
extensions/libxt_MARK.c +44 -46
98 lines not on this page · raw message
extensions/libxt_TOS.c +30 -30
68 lines not on this page · raw message
extensions/libxt_connlimit.c +30 -30
68 lines not on this page · raw message
extensions/libxt_connmark.c +30 -30
68 lines not on this page · raw message
extensions/libxt_conntrack.c +44 -46
98 lines not on this page · raw message
extensions/libxt_hashlimit.c +47 -49
104 lines not on this page · raw message
extensions/libxt_iprange.c +44 -46
98 lines not on this page · raw message
extensions/libxt_mark.c +30 -30
68 lines not on this page · raw message
extensions/libxt_multiport.c +58 -62
129 lines not on this page · raw message
extensions/libxt_owner.c +44 -46
98 lines not on this page · raw message
extensions/libxt_policy.c +28 -28
64 lines not on this page · raw message
extensions/libxt_string.c +32 -32
72 lines not on this page · raw message
extensions/libxt_tos.c +30 -30
68 lines not on this page · raw message
Signature · 1 line
1.6.3.2
PATCH 9/10 xtables: warn of missing version identifier in extensions
In reply to Jan Engelhardt--- xtables.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
xtables.c +10 -0
@@ -724,6 +724,11 @@ void xtables_register_match(struct xtables_match *me) {struct xtables_match **i, *old; +if (me->version ==NULL ) { +fprintf (stderr,"%s: match %s<%u> is missing a version\n" , + xt_params->program_name, me->name, me->revision); +exit (1 ); + }if (strcmp (me->version,XTABLES_VERSION ) !=0 ) { fprintf(stderr, "%s: match \"%s\" has version \"%s\", " "but \"%s\" is required.\n",
@@ -805,6 +810,11 @@ void xtables_register_target(struct xtables_target *me) {struct xtables_target *old; +if (me->version ==NULL ) { +fprintf (stderr,"%s: target %s<%u> is missing a version\n" , + xt_params->program_name, me->name, me->revision); +exit (1 ); + }if (strcmp (me->version,XTABLES_VERSION ) !=0 ) { fprintf(stderr, "%s: target \"%s\" has version \"%s\", " "but \"%s\" is required.\n",
Signature · 1 line
1.6.3.2
PATCH 10/10 COMMIT_NOTES: notice to check for soversion bumps
In reply to Jan Engelhardt--- COMMIT_NOTES | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
COMMIT_NOTES +5 -1
@@ -11,5 +11,9 @@ A quick list of rules for committing stuff into netfilter git: - If you touch any parts of libxtables (xtables.c, include/xtables.h.in), make sure the so-version is updated _appropriately_ (i.e. read the - libtool manual about Versioning:: first if need be) in configure.ac. + libtool manual about Versioning:: first, if need be) in configure.ac. Adding fields to a struct always entails a vcurrent bump. + + - Check, whether a bump (vcurrent,vage) has already been made since the + last release (no more than one per release), e.g.: + git log v1.4.4.. configure.ac
Signature · 1 line
1.6.3.2
Re:
In reply to Jan EngelhardtQuoted 21 lines · Jan Engelhardt
Hi,
here are a number of patches I am suggesting for the -master branch (-stable is separate in my view and my management, but see other discussion thread).
Pullable from
git://dev.medozas.de/iptablesmasterJan Engelhardt (9):
libiptc: split v4 and v6
extensions: collapse registration structures
iptables: allow for parse-less extensions
iptables: allow for help-less extensions
extensions: remove empty help and parse functions
xtables: add multi-registration functions
extensions: collapse data variables to use multi-reg calls
xtables: warn of missing version identifier in extensions
COMMIT_NOTES: notice to check for soversion bumps
Quoted 2 lines
Michael Granzow (1):
iptables: accept multiple IP address specifications for -s, -d
Looks good, pulled and pushed out again, thanks.
Quoted 1 line
(Shall I post the entire mergestat, or just the "X files changed" line?)
This is fine, I mainly want something comparable to the git pull output.