iptables: add more test cases and minor bug fixes
Florian Westphal
maintainerWill push to master soon if there are no objections. iptables-test.py should now be complete enough to replace the old iptables-save format "test" files, so I'm going to remove the tests/ directory as well.
All tests pass on current nf.git tree (minus ULOG since thats no longer supported).
Cheers,
Florian
Florian Westphal
maintainerPATCH 1/7 extensions: remove MIRROR
removed from the kernel back in 2003.
--- extensions/libipt_MIRROR.c | 15 --------------- extensions/libipt_MIRROR.man | 12 ------------ 2 files changed, 27 deletions(-) delete mode 100644 extensions/libipt_MIRROR.c delete mode 100644 extensions/libipt_MIRROR.man
extensions/libipt_MIRROR.c deleted +0 -15
@@ -1,15 +0,0 @@ -/* Shared library add-on to iptables to add MIRROR target support. */ -#include <xtables.h> - -static struct xtables_target mirror_tg_reg = { - .name ="MIRROR" , - .version =XTABLES_VERSION , - .family =NFPROTO_IPV4 , - .size =XT_ALIGN (0 ), - .userspacesize =XT_ALIGN (0 ), -}; - -void _init (void ) -{ -xtables_register_target (&mirror_tg_reg); -}
extensions/libipt_MIRROR.man deleted +0 -12
@@ -1,12 +0,0 @@ -This is an experimental demonstration target which inverts the source -and destination fields in the IP header and retransmits the packet. -It is only valid in the -.BR INPUT , -.B FORWARD -and -.B PREROUTING -chains, and user-defined chains which are only called from those -chains. Note that the outgoing packets are -.B NOT -seen by any packet filtering chains, connection tracking or NAT, to -avoid loops and other problems.
Signature · 1 line
2.0.5
Re: [PATCH 1/7] extensions: remove MIRROR
Quoted 1 line · Florian Westphal
removed from the kernel back in 2003.
Last time I remember, Pablo wanted to keep this. Because modern iptables may still be used with overly old preexisting kernels.
Florian Westphal
maintainerRe: [PATCH 1/7] extensions: remove MIRROR
Quoted 6 lines · Jan Engelhardt
Quoted 1 line · Florian Westphal
removed from the kernel back in 2003.
Last time I remember, Pablo wanted to keep this. Because modern iptables may still be used with overly old preexisting kernels.
Fair enough, I can just omit the target/match removal patches when pushing the changes.
Pablo Neira Ayuso
maintainerRe: [PATCH 1/7] extensions: remove MIRROR
In reply to Jan EngelhardtQuoted 6 lines · Jan Engelhardt
Quoted 1 line · Florian Westphal
removed from the kernel back in 2003.
Last time I remember, Pablo wanted to keep this. Because modern iptables may still be used with overly old preexisting kernels.
No objections from my side to get rid of these old extensions.
Florian Westphal
maintainerPATCH 2/7 extensions: remove SAME target
In reply to Florian Westphalremoved from the kernel December 2007.
--- extensions/libipt_SAME.c | 186 -------------------------------- extensions/libipt_SAME.man | 17 --- include/linux/netfilter_ipv4/ipt_SAME.h | 20 ---- 3 files changed, 223 deletions(-) delete mode 100644 extensions/libipt_SAME.c delete mode 100644 extensions/libipt_SAME.man delete mode 100644 include/linux/netfilter_ipv4/ipt_SAME.h
extensions/libipt_SAME.c deleted +0 -186
@@ -1,186 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <xtables.h> -#include <linux/netfilter/nf_nat.h> -#include <linux/netfilter_ipv4/ipt_SAME.h> - -enum { -O_TO_ADDR =0 , -O_NODST , -O_RANDOM , -F_TO_ADDR =1 <<O_TO_ADDR , -F_RANDOM =1 <<O_RANDOM , -}; - -static void SAME_help (void ) -{ -printf ( -"SAME target options:\n" -" --to <ipaddr>-<ipaddr>\n" -" Addresses to map source to.\n" -" May be specified more than\n" -" once for multiple ranges.\n" -" --nodst\n" -" Don't use destination-ip in\n" -" source selection\n" -" --random\n" -" Randomize source port\n" ); -} - -static const struct xt_option_entry SAME_opts[] = { - {.name ="to" , .id =O_TO_ADDR , .type =XTTYPE_STRING , - .flags =XTOPT_MAND }, - {.name ="nodst" , .id =O_NODST , .type =XTTYPE_NONE }, - {.name ="random" , .id =O_RANDOM , .type =XTTYPE_NONE }, -XTOPT_TABLEEND , -}; - -/* Parses range of IPs */ -static void parse_to (const char *orig_arg,struct nf_nat_ipv4_range *range) -{ -char *dash, *arg; -const struct in_addr *ip; - - arg =strdup (orig_arg); -if (arg ==NULL ) -xtables_error (RESOURCE_PROBLEM ,"strdup" ); - range->flags |=NF_NAT_RANGE_MAP_IPS ; - dash =strchr (arg,'-' ); - -if (dash) - *dash ='\0' ; - - ip =xtables_numeric_to_ipaddr (arg); -if (!ip) -xtables_error (PARAMETER_PROBLEM ,"Bad IP address \"%s\"\n" , - arg); - range->min_ip = ip->s_addr; - -if (dash) { - ip =xtables_numeric_to_ipaddr (dash+1 ); -if (!ip) -xtables_error (PARAMETER_PROBLEM ,"Bad IP address \"%s\"\n" , - dash+1 ); - } - range->max_ip = ip->s_addr; -if (dash) -if (range->min_ip > range->max_ip) -xtables_error (PARAMETER_PROBLEM ,"Bad IP range \"%s-%s\"\n" , - arg, dash+1 ); -free (arg); -} - -static void SAME_parse (struct xt_option_call *cb) -{ -struct ipt_same_info *mr = cb->data; -unsigned int count; - -xtables_option_parse (cb); -switch (cb->entry->id) { -case O_TO_ADDR : -if (mr->rangesize ==IPT_SAME_MAX_RANGE ) -xtables_error (PARAMETER_PROBLEM , -"Too many ranges specified, maximum " -"is %i ranges.\n" , -IPT_SAME_MAX_RANGE ); -parse_to (cb->arg, &mr->range[mr->rangesize]); - mr->rangesize++; -break ; -case O_NODST : - mr->info |=IPT_SAME_NODST ; -break ; -case O_RANDOM : -for (count=0 ; count < mr->rangesize; count++) - mr->range[count].flags |=NF_NAT_RANGE_PROTO_RANDOM ; -break ; - } -} - -static void SAME_fcheck (struct xt_fcheck_call *cb) -{ -static const unsigned int f =F_TO_ADDR |F_RANDOM ; -struct ipt_same_info *mr = cb->data; -unsigned int count; - -if ((cb->xflags & f) == f) -for (count =0 ; count < mr->rangesize; ++count) - mr->range[count].flags |=NF_NAT_RANGE_PROTO_RANDOM ; -} - -static void SAME_print (const void *ip,const struct xt_entry_target *target, -int numeric) -{ -unsigned int count; -const struct ipt_same_info *mr = (const void *)target->data; -int random_selection =0 ; - -printf (" same:" ); - -for (count =0 ; count < mr->rangesize; count++) { -const struct nf_nat_ipv4_range *r = &mr->range[count]; -struct in_addr a; - - a.s_addr = r->min_ip; - -printf ("%s" ,xtables_ipaddr_to_numeric (&a)); - a.s_addr = r->max_ip; - -if (r->min_ip != r->max_ip) -printf ("-%s" ,xtables_ipaddr_to_numeric (&a)); -if (r->flags &NF_NAT_RANGE_PROTO_RANDOM ) - random_selection =1 ; - } - -if (mr->info &IPT_SAME_NODST ) -printf (" nodst" ); - -if (random_selection) -printf (" random" ); -} - -static void SAME_save (const void *ip,const struct xt_entry_target *target) -{ -unsigned int count; -const struct ipt_same_info *mr = (const void *)target->data; -int random_selection =0 ; - -for (count =0 ; count < mr->rangesize; count++) { -const struct nf_nat_ipv4_range *r = &mr->range[count]; -struct in_addr a; - - a.s_addr = r->min_ip; -printf (" --to %s" ,xtables_ipaddr_to_numeric (&a)); - a.s_addr = r->max_ip; - -if (r->min_ip != r->max_ip) -printf ("-%s" ,xtables_ipaddr_to_numeric (&a)); -if (r->flags &NF_NAT_RANGE_PROTO_RANDOM ) - random_selection =1 ; - } - -if (mr->info &IPT_SAME_NODST ) -printf (" --nodst" ); - -if (random_selection) -printf (" --random" ); -} - -static struct xtables_target same_tg_reg = { - .name ="SAME" , - .version =XTABLES_VERSION , - .family =NFPROTO_IPV4 , - .size =XT_ALIGN (sizeof (struct ipt_same_info )), - .userspacesize =XT_ALIGN (sizeof (struct ipt_same_info )), - .help = SAME_help, - .x6_parse = SAME_parse, - .x6_fcheck = SAME_fcheck, - .print = SAME_print, - .save = SAME_save, - .x6_options = SAME_opts, -}; - -void _init (void ) -{ -xtables_register_target (&same_tg_reg); -}
extensions/libipt_SAME.man deleted +0 -17
@@ -1,17 +0,0 @@ -Similar to SNAT/DNAT depending on chain: it takes a range of addresses -(`\-\-to 1.2.3.4\-1.2.3.7') and gives a client the same -source-/destination-address for each connection. -.PP -N.B.: The DNAT target's \fB\-\-persistent\fP option replaced the SAME target. -.TP -\fB\-\-to\fP \fIipaddr\fP[\fB\-\fP\fIipaddr\fP] -Addresses to map source to. May be specified more than once for -multiple ranges. -.TP -\fB\-\-nodst\fP -Don't use the destination-ip in the calculations when selecting the -new source-ip -.TP -\fB\-\-random\fP -Port mapping will be forcibly randomized to avoid attacks based on -port prediction (kernel >= 2.6.21).
include/linux/netfilter_ipv4/ipt_SAME.h deleted +0 -20
@@ -1,20 +0,0 @@ -#ifndef _IPT_SAME_H -#define _IPT_SAME_H - -#include <linux/types.h> - -#define IPT_SAME_MAX_RANGE 10 - -#define IPT_SAME_NODST 0x01 - -struct ipt_same_info { -unsigned char info; -__u32 rangesize; -__u32 ipnum; -__u32 *iparray; - -/* hangs off end. */ -struct nf_nat_ipv4_range range[IPT_SAME_MAX_RANGE ]; -}; - -#endif /*_IPT_SAME_H*/
Signature · 1 line
2.0.5
Florian Westphal
maintainerPATCH 3/7 extensions: remove 'unclean' match
In reply to Florian Westphalremoved from kernel in 2003.
--- extensions/libipt_unclean.c | 15 --------------- extensions/libipt_unclean.man | 2 -- 2 files changed, 17 deletions(-) delete mode 100644 extensions/libipt_unclean.c delete mode 100644 extensions/libipt_unclean.man
extensions/libipt_unclean.c deleted +0 -15
@@ -1,15 +0,0 @@ -/* Shared library add-on to iptables for unclean. */ -#include <xtables.h> - -static struct xtables_match unclean_mt_reg = { - .name ="unclean" , - .version =XTABLES_VERSION , - .family =NFPROTO_IPV4 , - .size =XT_ALIGN (0 ), - .userspacesize =XT_ALIGN (0 ), -}; - -void _init (void ) -{ -xtables_register_match (&unclean_mt_reg); -}
extensions/libipt_unclean.man deleted +0 -2
@@ -1,2 +0,0 @@ -This module takes no options, but attempts to match packets which seem -malformed or unusual. This is regarded as experimental.
Signature · 1 line
2.0.5
Florian Westphal
maintainerPATCH 4/7 extensions: add more test cases for iptables-test.py
In reply to Florian WestphalInstead of using iptables-save-formatted files in the tests/ dir, lets use the iptables-test.py framework for all matches/targets.
This obsoletes tests/ completely, will be removed in followup patch.
--- extensions/libip6t_DNAT.t | 8 ++++++++ extensions/libip6t_DNPT.t | 6 ++++++ extensions/libip6t_HL.t | 10 ++++++++++ extensions/libip6t_MASQUERADE.t | 8 ++++++++ extensions/libip6t_NETMAP.t | 4 ++++ extensions/libip6t_REDIRECT.t | 6 ++++++ extensions/libip6t_SNAT.t | 8 ++++++++ extensions/libip6t_SNPT.t | 6 ++++++ extensions/libip6t_dst.t | 4 ++++ extensions/libip6t_frag.t | 11 +++++++++++ extensions/libip6t_hbh.t | 5 +++++ extensions/libip6t_hl.t | 8 ++++++++ extensions/libip6t_icmp6.t | 6 ++++++ extensions/libip6t_ipv6header.t | 4 ++++ extensions/libip6t_mh.t | 6 ++++++ extensions/libip6t_rt.t | 4 ++++ extensions/libipt_NETMAP.t | 4 ++++ extensions/libipt_REDIRECT.t | 6 ++++++ extensions/libipt_TTL.t | 10 ++++++++++ extensions/libipt_realm.t | 4 ++++ extensions/libxt_CONNSECMARK.t | 5 +++++ extensions/libxt_HMARK.t | 8 ++++++++ extensions/libxt_IDLETIMER.t | 4 ++++ extensions/libxt_LED.t | 4 ++++ extensions/libxt_RATEEST.t | 2 ++ extensions/libxt_SET.t | 3 +++ extensions/libxt_SYNPROXY.t | 3 +++ extensions/libxt_TCPMSS.t | 6 ++++++ extensions/libxt_TCPOPTSTRIP.t | 8 ++++++++ extensions/libxt_TPROXY.t | 5 +++++ extensions/libxt_bpf.t | 2 ++ extensions/libxt_ecn.t | 5 +++++ extensions/libxt_mac.t | 5 +++++ extensions/libxt_osf.t | 4 ++++ extensions/libxt_policy.t | 5 +++++ extensions/libxt_recent.t | 7 +++++++ extensions/libxt_rpfilter.t | 4 ++++ extensions/libxt_set.t | 4 ++++ extensions/libxt_socket.t | 4 ++++ extensions/libxt_statistic.t | 8 ++++++++ extensions/libxt_tcpmss.t | 5 +++++ extensions/libxt_u32.t | 2 ++ 42 files changed, 231 insertions(+) create mode 100644 extensions/libip6t_DNAT.t create mode 100644 extensions/libip6t_DNPT.t create mode 100644 extensions/libip6t_HL.t create mode 100644 extensions/libip6t_MASQUERADE.t create mode 100644 extensions/libip6t_NETMAP.t create mode 100644 extensions/libip6t_REDIRECT.t create mode 100644 extensions/libip6t_SNAT.t create mode 100644 extensions/libip6t_SNPT.t create mode 100644 extensions/libip6t_dst.t create mode 100644 extensions/libip6t_frag.t create mode 100644 extensions/libip6t_hbh.t create mode 100644 extensions/libip6t_hl.t create mode 100644 extensions/libip6t_icmp6.t create mode 100644 extensions/libip6t_ipv6header.t create mode 100644 extensions/libip6t_mh.t create mode 100644 extensions/libip6t_rt.t create mode 100644 extensions/libipt_NETMAP.t create mode 100644 extensions/libipt_REDIRECT.t create mode 100644 extensions/libipt_TTL.t create mode 100644 extensions/libipt_realm.t create mode 100644 extensions/libxt_CONNSECMARK.t create mode 100644 extensions/libxt_HMARK.t create mode 100644 extensions/libxt_IDLETIMER.t create mode 100644 extensions/libxt_LED.t create mode 100644 extensions/libxt_RATEEST.t create mode 100644 extensions/libxt_SET.t create mode 100644 extensions/libxt_SYNPROXY.t create mode 100644 extensions/libxt_TCPMSS.t create mode 100644 extensions/libxt_TCPOPTSTRIP.t create mode 100644 extensions/libxt_TPROXY.t create mode 100644 extensions/libxt_bpf.t create mode 100644 extensions/libxt_ecn.t create mode 100644 extensions/libxt_mac.t create mode 100644 extensions/libxt_osf.t create mode 100644 extensions/libxt_policy.t create mode 100644 extensions/libxt_recent.t create mode 100644 extensions/libxt_rpfilter.t create mode 100644 extensions/libxt_set.t create mode 100644 extensions/libxt_socket.t create mode 100644 extensions/libxt_statistic.t create mode 100644 extensions/libxt_tcpmss.t create mode 100644 extensions/libxt_u32.t
extensions/libip6t_DNAT.t new file +8 -0
@@ -0,0 +1,8 @@ +:PREROUTING +*nat +-j DNAT --to-destination dead::beef;=;OK +-j DNAT --to-destination dead::beef-dead::fee7;=;OK +-p tcp -j DNAT --to-destination [dead::beef]:1025-65535;=;OK +-p tcp -j DNAT --to-destination [dead::beef-dead::fee7]:1025-65535;=;OK +-p tcp -j DNAT --to-destination [dead::beef-dead::fee7]:1025-65536;;FAIL +-j DNAT;;FAIL
extensions/libip6t_DNPT.t new file +6 -0
@@ -0,0 +1,6 @@ +:PREROUTING +*mangle +-j DNPT --src-pfx dead::beef --dst-pfx 1c3::/64;;FAIL +-j DNPT --src-pfx dead::/64;;FAIL +-j DNPT --dst-pfx dead::/64;;FAIL +-j DNPT;;FAIL
extensions/libip6t_HL.t new file +10 -0
@@ -0,0 +1,10 @@ +:PREROUTING,INPUT,FORWARD,OUTPUT,POSTROUTING +*mangle +-j HL --hl-set 42;=;OK +-j HL --hl-inc 1;=;OK +-j HL --hl-dec 1;=;OK +-j HL --hl-set 256;;FAIL +-j HL --hl-inc 0;;FAIL +-j HL --hl-dec 0;;FAIL +-j HL --hl-dec 1 --hl-inc 1;;FAIL +-j HL --hl-set --hl-inc 1;;FAIL
extensions/libip6t_MASQUERADE.t new file +8 -0
@@ -0,0 +1,8 @@ +:POSTROUTING +*nat +-j MASQUERADE;=;OK +-j MASQUERADE --random;=;OK +-p tcp -j MASQUERADE --to-ports 1024;=;OK +-p udp -j MASQUERADE --to-ports 1024-65535;=;OK +-p udp -j MASQUERADE --to-ports 1024-65536;;FAIL +-p udp -j MASQUERADE --to-ports -1;;FAIL
extensions/libip6t_NETMAP.t new file +4 -0
@@ -0,0 +1,4 @@ +:PREROUTING,INPUT,OUTPUT,POSTROUTING +*nat +-j NETMAP --to dead::/64;=;OK +-j NETMAP --to dead::beef;=;OK
extensions/libip6t_REDIRECT.t new file +6 -0
@@ -0,0 +1,6 @@ +:PREROUTING,OUTPUT +*nat +-p tcp -j REDIRECT --to-ports 42;=;OK +-p udp -j REDIRECT --to-ports 42-1234;=;OK +-p tcp -j REDIRECT --to-ports 42-1234 --random;=;OK +-j REDIRECT --to-ports 42;;FAIL
extensions/libip6t_SNAT.t new file +8 -0
@@ -0,0 +1,8 @@ +:POSTROUTING +*nat +-j SNAT --to-source dead::beef;=;OK +-j SNAT --to-source dead::beef-dead::fee7;=;OK +-p tcp -j SNAT --to-source [dead::beef]:1025-65535;=;OK +-p tcp -j SNAT --to-source [dead::beef-dead::fee7]:1025-65535;=;OK +-p tcp -j SNAT --to-source [dead::beef-dead::fee7]:1025-65536;;FAIL +-j SNAT;;FAIL
extensions/libip6t_SNPT.t new file +6 -0
@@ -0,0 +1,6 @@ +:INPUT,POSTROUTING +*mangle +-j SNPT --src-pfx dead::beef --dst-pfx 1c3::/64;;FAIL +-j SNPT --src-pfx dead::/64;;FAIL +-j SNPT --dst-pfx dead::/64;;FAIL +-j SNPT;;FAIL
extensions/libip6t_dst.t new file +4 -0
@@ -0,0 +1,4 @@ +:INPUT,FORWARD,OUTPUT +-m dst --dst-len 0;=;OK +-m dst --dst-opts 149:92,12:12,123:12;=;OK +-m dst --dst-len 42 --dst-opts 149:92,12:12,123:12;=;OK
extensions/libip6t_frag.t new file +11 -0
@@ -0,0 +1,11 @@ +:INPUT,FORWARD,OUTPUT +-m frag --fragid 1:42;=;OK +-m frag --fraglen 42;=;OK +-m frag --fragres;=;OK +-m frag --fragfirst;=;OK +-m frag --fragmore;=;OK +-m frag --fraglast;=;OK +-m frag ! --fragid 1 ! --fraglen 42 --fragres --fragfirst;=;OK +-m frag --fragfirst --fragmore;=;OK +-m frag --fragfirst --fraglast;=;OK +-m frag --fraglast --fragmore;;FAIL
extensions/libip6t_hbh.t new file +5 -0
@@ -0,0 +1,5 @@ +:INPUT,FORWARD,OUTPUT +-m hbh;=;OK +-m hbh --hbh-len 42;=;OK +-m hbh ! --hbh-len 42;=;OK +-m hbh --hbh-len 42 --hbh-opts 1:2,23:42,4:6,8:10,42,23,4:5;=;OK
extensions/libip6t_hl.t new file +8 -0
@@ -0,0 +1,8 @@ +:INPUT,FORWARD,OUTPUT +-m hl;;FAIL +-m hl --hl-eq 42;=;OK +-m hl ! --hl-eq 42;=;OK +-m hl --hl-lt 42;=;OK +-m hl --hl-gt 42;=;OK +-m hl --hl-gt 42 --hl-eq 42;;FAIL +-m hl --hl-gt;;FAIL
extensions/libip6t_icmp6.t new file +6 -0
@@ -0,0 +1,6 @@ +:INPUT,FORWARD,OUTPUT +-m icmpv6;;FAIL +-p ipv6-icmp -m icmp6 --icmpv6-type 1/0;=;OK +-p ipv6-icmp -m icmp6 --icmpv6-type 2;=;OK +# cannot use option twice: +-p ipv6-icmp -m icmp6 --icmpv6-type no-route --icmpv6-type packet-too-big;;FAIL
extensions/libip6t_ipv6header.t new file +4 -0
@@ -0,0 +1,4 @@ +:INPUT,FORWARD,OUTPUT +-m ipv6header --header hop-by-hop;=;OK +-m ipv6header --header hop-by-hop --soft;=;OK +-m ipv6header --header ipv6-nonxt;=;OK
extensions/libip6t_mh.t new file +6 -0
@@ -0,0 +1,6 @@ +:INPUT,FORWARD,OUTPUT +-m mh;;FAIL +-p mobility-header -m mh;=;OK +-p mobility-header -m mh --mh-type 1;=;OK +-p mobility-header -m mh ! --mh-type 4;=;OK +-p mobility-header -m mh --mh-type 4:123;=;OK
extensions/libip6t_rt.t new file +4 -0
@@ -0,0 +1,4 @@ +:INPUT,FORWARD,OUTPUT +-m rt --rt-type 0 --rt-segsleft 1:23 --rt-len 42 --rt-0-res;=;OK +-m rt --rt-type 0 ! --rt-segsleft 1:23 ! --rt-len 42 --rt-0-res;=;OK +-m rt ! --rt-type 1 ! --rt-segsleft 12:23 ! --rt-len 42;=;OK
extensions/libipt_NETMAP.t new file +4 -0
@@ -0,0 +1,4 @@ +:PREROUTING,INPUT,OUTPUT,POSTROUTING +*nat +-j NETMAP --to 1.2.3.0/24;=;OK +-j NETMAP --to 1.2.3.4;=;OK
extensions/libipt_REDIRECT.t new file +6 -0
@@ -0,0 +1,6 @@ +:PREROUTING,OUTPUT +*nat +-p tcp -j REDIRECT --to-ports 42;=;OK +-p udp -j REDIRECT --to-ports 42-1234;=;OK +-p tcp -j REDIRECT --to-ports 42-1234 --random;=;OK +-j REDIRECT --to-ports 42;;FAIL
extensions/libipt_TTL.t new file +10 -0
@@ -0,0 +1,10 @@ +:PREROUTING,INPUT,FORWARD,OUTPUT,POSTROUTING +*mangle +-j TTL --ttl-set 42;=;OK +-j TTL --ttl-inc 1;=;OK +-j TTL --ttl-dec 1;=;OK +-j TTL --ttl-set 256;;FAIL +-j TTL --ttl-inc 0;;FAIL +-j TTL --ttl-dec 0;;FAIL +-j TTL --ttl-dec 1 --ttl-inc 1;;FAIL +-j TTL --ttl-set --ttl-inc 1;;FAIL
extensions/libipt_realm.t new file +4 -0
@@ -0,0 +1,4 @@ +:INPUT,FORWARD,OUTPUT +-m realm --realm 0x1/0x2a;=;OK +-m realm --realm 0x2a;=;OK +-m realm;;FAIL
extensions/libxt_CONNSECMARK.t new file +5 -0
@@ -0,0 +1,5 @@ +:PREROUTING,FORWARD,OUTPUT,POSTROUTING +*mangle +-j CONNSECMARK --restore;=;OK +-j CONNSECMARK --save;=;OK +-j CONNSECMARK;;FAIL
extensions/libxt_HMARK.t new file +8 -0
@@ -0,0 +1,8 @@ +:INPUT,FORWARD,OUTPUT +-j HMARK;;FAIL +-j HMARK --hmark-src-prefix 32 --hmark-rnd 0x00000004 --hmark-mod 42;=;OK +-j HMARK --hmark-src-prefix 32 --hmark-dst-prefix 32 --hmark-sport-mask 0xffff --hmark-dport-mask 0xffff --hmark-proto-mask 0xffff --hmark-rnd 0x00000004 --hmark-mod 42 --hmark-offset 1 --hmark-tuple ct;=;OK +-j HMARK --hmark-src-prefix 32 --hmark-dst-prefix 32 --hmark-spi-mask 0x00000004 --hmark-proto-mask 0xffff --hmark-rnd 0x00000004 --hmark-mod 42 --hmark-offset 1 --hmark-tuple ct;=;OK +-j HMARK --hmark-src-prefix 1 --hmark-dst-prefix 2 --hmark-sport-mask 0x0003 --hmark-dport-mask 0x0004 --hmark-proto-mask 0x05 --hmark-rnd 0x00000004 --hmark-mod 42 --hmark-offset 1 --hmark-tuple ct;=;OK +# cannot mix in spi mask: +-j HMARK --hmark-src-prefix 32 --hmark-dst-prefix 32 --hmark-sport-mask 0xffff --hmark-dport-mask 0xffff --hmark-proto-mask 0xffff --hmark-rnd 0x00000004 --hmark-mod 42 --hmark-offset 1 --hmark-tuple ct --hmark-spi-mask 4;;FAIL
extensions/libxt_IDLETIMER.t new file +4 -0
@@ -0,0 +1,4 @@ +:INPUT,FORWARD,OUTPUT +-j IDLETIMER --timeout;;FAIL +-j IDLETIMER --timeout 42;;FAIL +-j IDLETIMER --timeout 42 --label foo;=;OK
extensions/libxt_LED.t new file +4 -0
@@ -0,0 +1,4 @@ +:INPUT,FORWARD,OUTPUT +-j LED;;FAIL +-j LED --led-trigger-id "foo";=;OK +-j LED --led-trigger-id "foo" --led-delay 42 --led-always-blink;=;OK
extensions/libxt_RATEEST.t new file +2 -0
@@ -0,0 +1,2 @@ +:INPUT,FORWARD,OUTPUT +-j RATEEST --rateest-name RE1 --rateest-interval 250.0ms --rateest-ewmalog 500.0ms;=;OK
extensions/libxt_SET.t new file +3 -0
@@ -0,0 +1,3 @@ +:INPUT,FORWARD,OUTPUT +# fails: foo does not exist +-j SET --add-set foo src,dst;;FAIL
extensions/libxt_SYNPROXY.t new file +3 -0
@@ -0,0 +1,3 @@ +:INPUT,FORWARD +-j SYNPROXY --sack-perm --timestamp --mss 1460 --wscale 9;;FAIL +-p tcp -m tcp --dport 42 -m conntrack --ctstate INVALID,UNTRACKED -j SYNPROXY --sack-perm --timestamp --wscale 9 --mss 1460;=;OK
extensions/libxt_TCPMSS.t new file +6 -0
@@ -0,0 +1,6 @@ +:FORWARD,OUTPUT,POSTROUTING +*mangle +-j TCPMSS;;FAIL +-p tcp -j TCPMSS --set-mss 42;;FAIL +-p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j TCPMSS --set-mss 42;=;OK +-p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j TCPMSS --clamp-mss-to-pmtu;=;OK
extensions/libxt_TCPOPTSTRIP.t new file +8 -0
@@ -0,0 +1,8 @@ +:PREROUTING,INPUT,FORWARD,OUTPUT,POSTROUTING +*mangle +-j TCPOPTSTRIP;;FAIL +-p tcp -j TCPOPTSTRIP;=;OK +-p tcp -j TCPOPTSTRIP --strip-options 2,3,4,5,6,7;=;OK +-p tcp -j TCPOPTSTRIP --strip-options 0;;FAIL +-p tcp -j TCPOPTSTRIP --strip-options 1;;FAIL +-p tcp -j TCPOPTSTRIP --strip-options 1,2;;FAIL
extensions/libxt_TPROXY.t new file +5 -0
@@ -0,0 +1,5 @@ +:PREROUTING +*mangle +-j TPROXY --on-port 12345 --on-ip 10.0.0.1 --tproxy-mark 0x23/0xff;;FAIL +-p udp -j TPROXY --on-port 12345 --on-ip 10.0.0.1 --tproxy-mark 0x23/0xff;=;OK +-p tcp -m tcp --dport 2342 -j TPROXY --on-port 12345 --on-ip 10.0.0.1 --tproxy-mark 0x23/0xff;=;OK
extensions/libxt_bpf.t new file +2 -0
@@ -0,0 +1,2 @@ +:INPUT,FORWARD,OUTPUT +-m bpf --bytecode "4,48 0 0 9,21 0 1 6,6 0 0 1,6 0 0 0";=;OK
extensions/libxt_ecn.t new file +5 -0
@@ -0,0 +1,5 @@ +:INPUT,FORWARD,OUTPUT +-m ecn --ecn-tcp-cwr;;FAIL +-p tcp -m ecn --ecn-tcp-cwr;=;OK +-p tcp -m ecn --ecn-tcp-ece --ecn-tcp-cwr --ecn-ip-ect 2;=;OK +-p tcp -m ecn ! --ecn-tcp-ece ! --ecn-tcp-cwr ! --ecn-ip-ect 2;=;OK
extensions/libxt_mac.t new file +5 -0
@@ -0,0 +1,5 @@ +:INPUT,FORWARD +-m mac --mac-source 42:01:02:03:04:05;=;OK +-m mac --mac-source 42:01:02:03:04;=;FAIL +-m mac --mac-source 42:01:02:03:04:05:06;=;FAIL +-m mac;;FAIL
extensions/libxt_osf.t new file +4 -0
@@ -0,0 +1,4 @@ +:INPUT,FORWARD +-m osf --genre linux --ttl 0 --log 0;;FAIL +-p tcp -m osf --genre linux --ttl 0 --log 0;=;OK +-p tcp -m osf --genre linux --ttl 3 --log 0;;FAIL
extensions/libxt_policy.t new file +5 -0
@@ -0,0 +1,5 @@ +:INPUT,FORWARD +-m policy --dir in --pol ipsec;=;OK +-m policy --dir in --pol ipsec --strict;;FAIL +-m policy --dir in --pol ipsec --strict --reqid 1 --spi 0x1 --proto esp --mode tunnel --tunnel-dst 10.0.0.0/8 --tunnel-src 10.0.0.0/8 --next --reqid 2;=;OK +-m policy --dir in --pol ipsec --strict --reqid 1 --spi 0x1 --proto esp --tunnel-dst 10.0.0.0/8;;FAIL
extensions/libxt_recent.t new file +7 -0
@@ -0,0 +1,7 @@ +:INPUT,FORWARD,OUTPUT +-m recent --set;=;OK +-m recent --rcheck --hitcount 8 --name foo --mask 255.255.255.255 --rsource;=;OK +-m recent --rcheck --hitcount 12 --name foo --mask 255.255.255.255 --rsource;=;OK +-m recent --update --rttl;=;OK +-m recent --set --rttl;=;FAIL +-m recent --rcheck --hitcount 999 --name foo --mask 255.255.255.255 --rsource;=;FAIL
extensions/libxt_rpfilter.t new file +4 -0
@@ -0,0 +1,4 @@ +:PREROUTING +*mangle +-m rpfilter;=;OK +-m rpfilter --loose --validmark --accept-local --invert;=;OK
extensions/libxt_set.t new file +4 -0
@@ -0,0 +1,4 @@ +:INPUT,FORWARD,OUTPUT +-m set --match-set foo;;FAIL +# fails: foo does not exist +-m set --match-set foo src,dst;;FAIL
extensions/libxt_socket.t new file +4 -0
@@ -0,0 +1,4 @@ +:PREROUTING,INPUT +*mangle +-m socket;=;OK +-m socket --transparent --nowildcard;=;OK
extensions/libxt_statistic.t new file +8 -0
@@ -0,0 +1,8 @@ +:INPUT,FORWARD,OUTPUT +-m statistic;;FAIL +-m statistic --mode random ! --probability 0.50000000000;=;OK +-m statistic --mode random ! --probability 1.1;;FAIL +-m statistic --probability 1;;FAIL +-m statistic --mode nth ! --every 5 --packet 2;=;OK +-m statistic --mode nth ! --every 5;;FAIL +-m statistic --mode nth ! --every 5 --packet 5;;FAIL
extensions/libxt_tcpmss.t new file +5 -0
@@ -0,0 +1,5 @@ +:INPUT,FORWARD,OUTPUT +-m tcpmss --mss 42;;FAIL +-p tcp -m tcpmss --mss 42;=;OK +-p tcp -m tcpmss --mss 42:12345;=;OK +-p tcp -m tcpmss --mss 42:65536;;FAIL
extensions/libxt_u32.t new file +2 -0
@@ -0,0 +1,2 @@ +:INPUT,FORWARD,OUTPUT +-m u32 --u32 "0x0=0x0&&0x0=0x1";=;OK
Signature · 1 line
2.0.5
Florian Westphal
maintainerPATCH 5/7 extensions: SNPT,DNPT: fix save/print output
In reply to Florian Westphalwrong placement of ' ', i.e. we get
-j SNPT--src-pfx dead::/64 --dst-pfx 1c3::/64
--- extensions/libip6t_DNPT.c | 8 ++++---- extensions/libip6t_DNPT.t | 1 + extensions/libip6t_SNPT.c | 8 ++++---- extensions/libip6t_SNPT.t | 1 + 4 files changed, 10 insertions(+), 8 deletions(-)
extensions/libip6t_DNPT.c +4 -4
@@ -52,9 +52,9 @@ static void DNPT_print(const void *ip, const struct xt_entry_target *target, {const struct ip6t_npt_tginfo *npt = (const void *)target->data; -printf ("src-pfx %s/%u " ,xtables_ip6addr_to_numeric (&npt->src_pfx.in6), +printf (" DNPT src-pfx %s/%u" ,xtables_ip6addr_to_numeric (&npt->src_pfx.in6), npt->src_pfx_len); -printf ("dst-pfx %s/%u " ,xtables_ip6addr_to_numeric (&npt->dst_pfx.in6), +printf (" dst-pfx %s/%u" ,xtables_ip6addr_to_numeric (&npt->dst_pfx.in6), npt->dst_pfx_len); }
@@ -65,12 +65,12 @@ static void DNPT_save(const void *ip, const struct xt_entry_target *target)if (memcmp (&info->src_pfx.in6, &zero_addr,sizeof (zero_addr)) !=0 || info->src_pfx_len !=0 ) -printf ("--src-pfx %s/%u " , +printf (" --src-pfx %s/%u" ,xtables_ip6addr_to_numeric (&info->src_pfx.in6), info->src_pfx_len);if (memcmp (&info->dst_pfx.in6, &zero_addr,sizeof (zero_addr)) !=0 || info->dst_pfx_len !=0 ) -printf ("--dst-pfx %s/%u " , +printf (" --dst-pfx %s/%u" ,xtables_ip6addr_to_numeric (&info->dst_pfx.in6), info->dst_pfx_len); }
extensions/libip6t_DNPT.t +1 -0
@@ -1,5 +1,6 @@ :PREROUTING *mangle +-j DNPT --src-pfx dead::/64 --dst-pfx 1c3::/64;=;OK -j DNPT --src-pfx dead::beef --dst-pfx 1c3::/64;;FAIL -j DNPT --src-pfx dead::/64;;FAIL -j DNPT --dst-pfx dead::/64;;FAIL
extensions/libip6t_SNPT.c +4 -4
@@ -52,9 +52,9 @@ static void SNPT_print(const void *ip, const struct xt_entry_target *target, {const struct ip6t_npt_tginfo *npt = (const void *)target->data; -printf ("src-pfx %s/%u " ,xtables_ip6addr_to_numeric (&npt->src_pfx.in6), +printf (" SNPT src-pfx %s/%u" ,xtables_ip6addr_to_numeric (&npt->src_pfx.in6), npt->src_pfx_len); -printf ("dst-pfx %s/%u " ,xtables_ip6addr_to_numeric (&npt->dst_pfx.in6), +printf (" dst-pfx %s/%u" ,xtables_ip6addr_to_numeric (&npt->dst_pfx.in6), npt->dst_pfx_len); }
@@ -65,12 +65,12 @@ static void SNPT_save(const void *ip, const struct xt_entry_target *target)if (memcmp (&info->src_pfx.in6, &zero_addr,sizeof (zero_addr)) !=0 || info->src_pfx_len !=0 ) -printf ("--src-pfx %s/%u " , +printf (" --src-pfx %s/%u" ,xtables_ip6addr_to_numeric (&info->src_pfx.in6), info->src_pfx_len);if (memcmp (&info->dst_pfx.in6, &zero_addr,sizeof (zero_addr)) !=0 || info->dst_pfx_len !=0 ) -printf ("--dst-pfx %s/%u " , +printf (" --dst-pfx %s/%u" ,xtables_ip6addr_to_numeric (&info->dst_pfx.in6), info->dst_pfx_len); }
extensions/libip6t_SNPT.t +1 -0
@@ -1,5 +1,6 @@ :INPUT,POSTROUTING *mangle +-j SNPT --src-pfx dead::/64 --dst-pfx 1c3::/64;=;OK -j SNPT --src-pfx dead::beef --dst-pfx 1c3::/64;;FAIL -j SNPT --src-pfx dead::/64;;FAIL -j SNPT --dst-pfx dead::/64;;FAIL
Signature · 1 line
2.0.5
Florian Westphal
maintainerPATCH 6/7 extensions/libxt_recent.t: add test case for 3.19 regression
In reply to Florian Westphalfail with vanilla 3.19.
--- extensions/libxt_recent.t | 4 ++++ 1 file changed, 4 insertions(+)
extensions/libxt_recent.t +4 -0
@@ -5,3 +5,7 @@ -m recent --update --rttl;=;OK -m recent --set --rttl;=;FAIL -m recent --rcheck --hitcount 999 --name foo --mask 255.255.255.255 --rsource;=;FAIL +# nonsensical, but all should load successfully: +-m recent --rcheck --hitcount 3 --name foo --mask 255.255.255.255 --rsource -m recent --rcheck --hitcount 4 --name foo --mask 255.255.255.255 --rsource;=;OK +-m recent --rcheck --hitcount 4 --name foo --mask 255.255.255.255 --rsource -m recent --rcheck --hitcount 4 --name foo --mask 255.255.255.255 --rsource;=;OK +-m recent --rcheck --hitcount 8 --name foo --mask 255.255.255.255 --rsource -m recent --rcheck --hitcount 12 --name foo --mask 255.255.255.255 --rsource;=;OK
Signature · 1 line
2.0.5
Florian Westphal
maintainerPATCH 7/7 extensions: libip6t_dst: make inversion work
In reply to Florian WestphalThe inversion flag wasn't set in the match struct.
--- extensions/libip6t_dst.c | 8 ++++---- extensions/libip6t_dst.t | 1 + 2 files changed, 5 insertions(+), 4 deletions(-)
extensions/libip6t_dst.c +4 -4
@@ -70,22 +70,21 @@ parse_options(const char *optsstr, uint16_t *opts) *next++='\0' ; range =strchr (cp,':' ); -if (range) {if (i ==IP6T_OPTS_OPTSNR -1 )xtables_error (PARAMETER_PROBLEM ,"too many ports specified" ); *range++ ='\0' ; } - opts[i] = (parse_opts_num (cp,"opt" ) &0xFF ) <<8 ;if (range) {if (opts[i] ==0 )xtables_error (PARAMETER_PROBLEM ,"PAD0 hasn't got length" ); opts[i] |=parse_opts_num (range,"length" ) &0xFF ; - }else + }else { opts[i] |= (0x00FF ); + }#ifdef DEBUG printf ("opts str: %s %s\n" , cp, range);
@@ -112,6 +111,8 @@ static void dst_parse(struct xt_option_call *cb)xtables_option_parse (cb);switch (cb->entry->id) {case O_DSTLEN : +if (cb->invert) + optinfo->invflags |=IP6T_OPTS_INV_LEN ; optinfo->flags |=IP6T_OPTS_LEN ;break ;case O_DSTOPTS :
@@ -152,7 +153,6 @@ static void dst_print(const void *ip, const struct xt_entry_match *match,printf (" opts" );print_options (optinfo->optsnr, (uint16_t *)optinfo->opts); -if (optinfo->invflags & ~IP6T_OPTS_INV_MASK )printf (" Unknown invflags: 0x%X" , optinfo->invflags & ~IP6T_OPTS_INV_MASK );
extensions/libip6t_dst.t +1 -0
@@ -1,4 +1,5 @@ :INPUT,FORWARD,OUTPUT -m dst --dst-len 0;=;OK -m dst --dst-opts 149:92,12:12,123:12;=;OK +-m dst ! --dst-len 42;=;OK -m dst --dst-len 42 --dst-opts 149:92,12:12,123:12;=;OK
Signature · 1 line
2.0.5
Re: [PATCH 7/7] extensions: libip6t_dst: make inversion work
Quoted 1 line · Florian Westphal
The inversion flag wasn't set in the match struct.
The documentation needs to be updated too.
It reflected what source code did: not supportting the "!" option at all/silently ignoring it.
Florian Westphal
maintainerRe: [PATCH 7/7] extensions: libip6t_dst: make inversion work
Quoted 8 lines · Jan Engelhardt
Quoted 1 line · Florian Westphal
The inversion flag wasn't set in the match struct.
The documentation needs to be updated too.
It reflected what source code did: not supportting the "!" option at all/silently ignoring it.
Interesting, --help does mention it:
dst match options:
[!] --dst-len length total length of this header
So, whats the desired action?
Given that the kernel already supports it (on kernel side its a module alias for hop-by-hop match) I'd vote for just also updating the man page snippet to mention ! as well, since it seems like artifical restriction.
Re: [PATCH 7/7] extensions: libip6t_dst: make inversion work
Quoted 3 lines · Florian Westphal
Interesting, --help does mention it:
dst match options:
[!] --dst-len length total length of this header
Um, I got confused by your change to dst-opts related code:
Quoted 1 line
Quoted 1 line
Quoted 1 line
opts[i] = (parse_opts_num(cp, "opt") & 0xFF) << 8;
if (range) { if (opts[i] == 0)
xtables_error(PARAMETER_PROBLEM,
"PAD0 hasn't got length");
opts[i] |= parse_opts_num(range, "length") & 0xFF;
- } else
+ } else {
opts[i] |= (0x00FF);+ }
<<<
All in order. But perhaps separate style changes from real changes commit-wise.
Pablo Neira Ayuso
maintainerQuoted 4 lines · Florian Westphal
Will push to master soon if there are no objections.
iptables-test.pyshould now be complete enough to replace the old iptables-save format "test" files, so I'm going to remove the tests/ directory as well.
Nice you added more regression test, this will also help us with the iptables-compat stuff, thanks Florian!
Florian Westphal
maintainerQuoted 4 lines · Florian Westphal
Will push to master soon if there are no objections.
iptables-test.pyshould now be complete enough to replace the old iptables-save format "test" files, so I'm going to remove the tests/ directory as well.
pushed everthing plus/tests/ dir removal, I amended the ip6t_dst change to not include the unrelated whitspace changes.
Thanks,
Florian