Commit dd6b25de authored by Arturo Borrero Gonzalez's avatar Arturo Borrero Gonzalez
Browse files

Merge tag 'upstream/1.6.0+snapshot20161117'

Upstream version 1.6.0+snapshot20161117
parents 8fceaf37 7b095084
:INPUT,FORWARD,OUTPUT
-m mark --mark 0xfeedcafe/0xfeedcafe;=;OK
-m mark --mark 0;=;OK
-m mark --mark 4294967295;-m mark --mark 0xffffffff;OK
-m mark --mark 4294967296;;FAIL
-m mark --mark -1;;FAIL
-m mark;;FAIL
......@@ -468,6 +468,110 @@ static void multiport_save6_v1(const void *ip_void,
__multiport_save_v1(match, ip->proto);
}
static int __multiport_xlate(struct xt_xlate *xl,
const struct xt_xlate_mt_params *params)
{
const struct xt_multiport *multiinfo
= (const struct xt_multiport *)params->match->data;
unsigned int i;
switch (multiinfo->flags) {
case XT_MULTIPORT_SOURCE:
xt_xlate_add(xl, " sport ");
break;
case XT_MULTIPORT_DESTINATION:
xt_xlate_add(xl, " dport ");
break;
case XT_MULTIPORT_EITHER:
return 0;
}
if (multiinfo->count > 1)
xt_xlate_add(xl, "{ ");
for (i = 0; i < multiinfo->count; i++)
xt_xlate_add(xl, "%s%u", i ? "," : "", multiinfo->ports[i]);
if (multiinfo->count > 1)
xt_xlate_add(xl, "}");
return 1;
}
static int multiport_xlate(struct xt_xlate *xl,
const struct xt_xlate_mt_params *params)
{
uint8_t proto = ((const struct ipt_ip *)params->ip)->proto;
xt_xlate_add(xl, "%s", proto_to_name(proto));
return __multiport_xlate(xl, params);
}
static int multiport_xlate6(struct xt_xlate *xl,
const struct xt_xlate_mt_params *params)
{
uint8_t proto = ((const struct ip6t_ip6 *)params->ip)->proto;
xt_xlate_add(xl, "%s", proto_to_name(proto));
return __multiport_xlate(xl, params);
}
static int __multiport_xlate_v1(struct xt_xlate *xl,
const struct xt_xlate_mt_params *params)
{
const struct xt_multiport_v1 *multiinfo =
(const struct xt_multiport_v1 *)params->match->data;
unsigned int i;
switch (multiinfo->flags) {
case XT_MULTIPORT_SOURCE:
xt_xlate_add(xl, " sport ");
break;
case XT_MULTIPORT_DESTINATION:
xt_xlate_add(xl, " dport ");
break;
case XT_MULTIPORT_EITHER:
return 0;
}
if (multiinfo->invert)
xt_xlate_add(xl, "!= ");
if (multiinfo->count > 2 ||
(multiinfo->count > 1 && !multiinfo->pflags[0]))
xt_xlate_add(xl, "{ ");
for (i = 0; i < multiinfo->count; i++) {
xt_xlate_add(xl, "%s%u", i ? "," : "", multiinfo->ports[i]);
if (multiinfo->pflags[i])
xt_xlate_add(xl, "-%u", multiinfo->ports[++i]);
}
if (multiinfo->count > 2 ||
(multiinfo->count > 1 && !multiinfo->pflags[0]))
xt_xlate_add(xl, "}");
return 1;
}
static int multiport_xlate_v1(struct xt_xlate *xl,
const struct xt_xlate_mt_params *params)
{
uint8_t proto = ((const struct ipt_ip *)params->ip)->proto;
xt_xlate_add(xl, "%s", proto_to_name(proto));
return __multiport_xlate_v1(xl, params);
}
static int multiport_xlate6_v1(struct xt_xlate *xl,
const struct xt_xlate_mt_params *params)
{
uint8_t proto = ((const struct ip6t_ip6 *)params->ip)->proto;
xt_xlate_add(xl, "%s", proto_to_name(proto));
return __multiport_xlate_v1(xl, params);
}
static struct xtables_match multiport_mt_reg[] = {
{
.family = NFPROTO_IPV4,
......@@ -482,6 +586,7 @@ static struct xtables_match multiport_mt_reg[] = {
.print = multiport_print,
.save = multiport_save,
.x6_options = multiport_opts,
.xlate = multiport_xlate,
},
{
.family = NFPROTO_IPV6,
......@@ -496,6 +601,7 @@ static struct xtables_match multiport_mt_reg[] = {
.print = multiport_print6,
.save = multiport_save6,
.x6_options = multiport_opts,
.xlate = multiport_xlate6,
},
{
.family = NFPROTO_IPV4,
......@@ -510,6 +616,7 @@ static struct xtables_match multiport_mt_reg[] = {
.print = multiport_print_v1,
.save = multiport_save_v1,
.x6_options = multiport_opts,
.xlate = multiport_xlate_v1,
},
{
.family = NFPROTO_IPV6,
......@@ -524,6 +631,7 @@ static struct xtables_match multiport_mt_reg[] = {
.print = multiport_print6_v1,
.save = multiport_save6_v1,
.x6_options = multiport_opts,
.xlate = multiport_xlate6_v1,
},
};
......
:INPUT,FORWARD,OUTPUT
-p tcp -m multiport --sports 53,1024:65535;=;OK
-p tcp -m multiport --dports 53,1024:65535;=;OK
-p udp -m multiport --sports 53,1024:65535;=;OK
-p udp -m multiport --dports 53,1024:65535;=;OK
-p udp -m multiport --ports 53,1024:65535;=;OK
-p udp -m multiport --ports 53,1024:65535;=;OK
-p sctp -m multiport --sports 53,1024:65535;=;OK
-p sctp -m multiport --dports 53,1024:65535;=;OK
-p dccp -m multiport --sports 53,1024:65535;=;OK
-p dccp -m multiport --dports 53,1024:65535;=;OK
-p udplite -m multiport --sports 53,1024:65535;=;OK
-p udplite -m multiport --dports 53,1024:65535;=;OK
-p tcp -m multiport --sports 1024:65536;;FAIL
-p udp -m multiport --sports 1024:65536;;FAIL
-p tcp -m multiport --ports 1024:65536;;FAIL
-p udp -m multiport --ports 1024:65536;;FAIL
-p tcp -m multiport --ports 1,2,3,4,6,7,8,9,10,11,12,13,14,15;=;OK
# fix manpage, it says "up to 15 ports supported"
# ERROR: should fail: iptables -A INPUT -p tcp -m multiport --ports 1,2,3,4,6,7,8,9,10,11,12,13,14,15,16
# -p tcp -m multiport --ports 1,2,3,4,6,7,8,9,10,11,12,13,14,15,16;;FAIL
-p tcp --multiport;;FAIL
-m multiport;;FAIL
:INPUT,FORWARD,OUTPUT
@nfacct add test
#
# extra space in iptables-save output, fix it
#
# ERROR: cannot load: iptables -A INPUT -m nfacct --nfacct-name test
#-m nfacct --nfacct-name test;=;OK
-m nfacct --nfacct-name wrong;;FAIL
-m nfacct;;FAIL
@nfacct del test
: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
......@@ -492,6 +492,56 @@ static void owner_mt_save(const void *ip, const struct xt_entry_match *match)
owner_mt_print_item(info, "--gid-owner", XT_OWNER_GID, true);
}
static int
owner_mt_print_uid_xlate(const struct xt_owner_match_info *info,
struct xt_xlate *xl)
{
xt_xlate_add(xl, "skuid%s ", info->invert ? " !=" : "");
if (info->uid_min != info->uid_max)
xt_xlate_add(xl, "%u-%u", (unsigned int)info->uid_min,
(unsigned int)info->uid_max);
else
xt_xlate_add(xl, "%u", (unsigned int)info->uid_min);
return 1;
}
static int
owner_mt_print_gid_xlate(const struct xt_owner_match_info *info,
struct xt_xlate *xl)
{
xt_xlate_add(xl, "skgid%s ", info->invert ? " !=" : "");
if (info->gid_min != info->gid_max)
xt_xlate_add(xl, "%u-%u", (unsigned int)info->gid_min,
(unsigned int)info->gid_max);
else
xt_xlate_add(xl, "%u", (unsigned int)info->gid_min);
return 1;
}
static int owner_mt_xlate(struct xt_xlate *xl,
const struct xt_xlate_mt_params *params)
{
const struct xt_owner_match_info *info = (void *)params->match->data;
int ret;
switch (info->match) {
case XT_OWNER_UID:
ret = owner_mt_print_uid_xlate(info, xl);
break;
case XT_OWNER_GID:
ret = owner_mt_print_gid_xlate(info, xl);
break;
default:
ret = 0;
}
return ret;
}
static struct xtables_match owner_mt_reg[] = {
{
.version = XTABLES_VERSION,
......@@ -534,6 +584,7 @@ static struct xtables_match owner_mt_reg[] = {
.print = owner_mt_print,
.save = owner_mt_save,
.x6_options = owner_mt_opts,
.xlate = owner_mt_xlate,
},
};
......
:OUTPUT,POSTROUTING
*mangle
-m owner --uid-owner root;-m owner --uid-owner 0;OK
-m owner --uid-owner 0-10;=;OK
-m owner --gid-owner root;-m owner --gid-owner 0;OK
-m owner --gid-owner 0-10;=;OK
-m owner --uid-owner root --gid-owner root;-m owner --uid-owner 0 --gid-owner 0;OK
-m owner --uid-owner 0-10 --gid-owner 0-10;=;OK
-m owner ! --uid-owner root;-m owner ! --uid-owner 0;OK
-m owner --socket-exists;=;OK
:INPUT
-m owner --uid-owner root;;FAIL
:INPUT,FORWARD
-m physdev --physdev-in lo;=;OK
-m physdev --physdev-is-in --physdev-in lo;=;OK
:OUTPUT,FORWARD
# xt_physdev: using --physdev-out in the OUTPUT, FORWARD and POSTROUTING chains for non-bridged traffic is not supported anymore.
# ERROR: should fail: iptables -A FORWARD -m physdev --physdev-out lo
#-m physdev --physdev-out lo;;FAIL
# ERROR: cannot load: iptables -A OUTPUT -m physdev --physdev-is-out --physdev-out lo
#-m physdev --physdev-is-out --physdev-out lo;=;OK
:FORWARD
-m physdev --physdev-in lo --physdev-is-bridged;=;OK
:POSTROUTING
*mangle
-m physdev --physdev-out lo --physdev-is-bridged;=;OK
......@@ -21,6 +21,11 @@ struct pkttypes {
const char *help;
};
struct pkttypes_xlate {
const char *name;
unsigned char pkttype;
};
static const struct pkttypes supported_types[] = {
{"unicast", PACKET_HOST, 1, "to us"},
{"broadcast", PACKET_BROADCAST, 1, "to all"},
......@@ -115,6 +120,37 @@ static void pkttype_save(const void *ip, const struct xt_entry_match *match)
print_pkttype(info);
}
static const struct pkttypes_xlate supported_types_xlate[] = {
{"unicast", PACKET_HOST},
{"broadcast", PACKET_BROADCAST},
{"multicast", PACKET_MULTICAST},
};
static void print_pkttype_xlate(const struct xt_pkttype_info *info,
struct xt_xlate *xl)
{
unsigned int i;
for (i = 0; i < ARRAY_SIZE(supported_types_xlate); ++i) {
if (supported_types_xlate[i].pkttype == info->pkttype) {
xt_xlate_add(xl, "%s", supported_types_xlate[i].name);
return;
}
}
xt_xlate_add(xl, "%d", info->pkttype);
}
static int pkttype_xlate(struct xt_xlate *xl,
const struct xt_xlate_mt_params *params)
{
const struct xt_pkttype_info *info = (const void *)params->match->data;
xt_xlate_add(xl, "pkttype%s ", info->invert ? " !=" : "");
print_pkttype_xlate(info, xl);
return 1;
}
static struct xtables_match pkttype_match = {
.family = NFPROTO_UNSPEC,
.name = "pkttype",
......@@ -126,6 +162,7 @@ static struct xtables_match pkttype_match = {
.save = pkttype_save,
.x6_parse = pkttype_parse,
.x6_options = pkttype_opts,
.xlate = pkttype_xlate,
};
void _init(void)
......
:INPUT,FORWARD,OUTPUT
-m pkttype --pkt-type unicast;=;OK
-m pkttype --pkt-type broadcast;=;OK
-m pkttype --pkt-type multicast;=;OK
-m pkttype --pkt-type wrong;;FAIL
-m pkttype;;FAIL
: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
......@@ -50,6 +50,17 @@ static void quota_parse(struct xt_option_call *cb)
info->flags |= XT_QUOTA_INVERT;
}
static int quota_xlate(struct xt_xlate *xl,
const struct xt_xlate_mt_params *params)
{
const struct xt_quota_info *q = (void *)params->match->data;
xt_xlate_add(xl, "quota %s%llu bytes",
q->flags & XT_QUOTA_INVERT ? "over " : "",
(unsigned long long) q->quota);
return 1;
}
static struct xtables_match quota_match = {
.family = NFPROTO_UNSPEC,
.name = "quota",
......@@ -61,6 +72,7 @@ static struct xtables_match quota_match = {
.save = quota_save,
.x6_parse = quota_parse,
.x6_options = quota_opts,
.xlate = quota_xlate,
};
void
......
:INPUT,FORWARD,OUTPUT
-m quota --quota 0;=;OK
-m quota ! --quota 0;=;OK
-m quota --quota 18446744073709551615;=;OK
-m quota ! --quota 18446744073709551615;=;OK
-m quota --quota 18446744073709551616;;FAIL
-m quota;;FAIL
:INPUT,FORWARD,OUTPUT
@iptables -I INPUT -j RATEEST --rateest-name RE1 --rateest-interval 250.0ms --rateest-ewmalog 500.0ms
-m rateest --rateest RE1 --rateest-lt --rateest-bps 8bit;=;OK
-m rateest --rateest RE1 --rateest-eq --rateest-pps 5;=;OK
-m rateest --rateest RE1 --rateest-gt --rateest-bps 5kbit;-m rateest --rateest RE1 --rateest-gt --rateest-bps 5000bit;OK
-m rateest --rateest-delta --rateest RE1 --rateest-bps1 8bit --rateest-lt --rateest-bps2 16bit;=;OK
@iptables -I INPUT -j RATEEST --rateest-name RE2 --rateest-interval 250.0ms --rateest-ewmalog 500.0ms
-m rateest --rateest1 RE1 --rateest-lt --rateest-bps --rateest2 RE2;=;OK
-m rateest --rateest-delta --rateest1 RE1 --rateest-pps1 0 --rateest-lt --rateest-pps2 42 --rateest2 RE2;=;OK
-m rateest --rateest-delta --rateest RE1 --rateest-bps1 8bit --rateest-eq --rateest-bps2 16bit;=;OK
-m rateest --rateest-delta --rateest RE1 --rateest-bps1 8bit --rateest-gt --rateest-bps2 16bit;=;OK
-m rateest --rateest-delta --rateest RE1 --rateest-pps1 8 --rateest-lt --rateest-pps2 9;=;OK
-m rateest --rateest-delta --rateest RE1 --rateest-pps1 8 --rateest-eq --rateest-pps2 9;=;OK
-m rateest --rateest-delta --rateest RE1 --rateest-pps1 8 --rateest-gt --rateest-pps2 9;=;OK
@iptables -D INPUT -j RATEEST --rateest-name RE1 --rateest-interval 250.0ms --rateest-ewmalog 500.0ms
@iptables -D INPUT -j RATEEST --rateest-name RE2 --rateest-interval 250.0ms --rateest-ewmalog 500.0ms
: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
# 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
......@@ -8,7 +8,7 @@ Also, packets arriving via the loopback interface are always permitted.
This match can only be used in the PREROUTING chain of the raw or mangle table.
.TP
\fB\-\-loose\fP
Used to specifiy that the reverse path filter test should match
Used to specify that the reverse path filter test should match
even if the selected output device is not the expected one.
.TP
\fB\-\-validmark\fP
......
:PREROUTING
*mangle
-m rpfilter;=;OK
-m rpfilter --loose --validmark --accept-local --invert;=;OK
......@@ -485,6 +485,44 @@ static void sctp_save(const void *ip, const struct xt_entry_match *match)
}
}
static int sctp_xlate(struct xt_xlate *xl,
const struct xt_xlate_mt_params *params)
{
const struct xt_sctp_info *einfo =
(const struct xt_sctp_info *)params->match->data;
char *space = "";
if (!einfo->flags)
return 0;
xt_xlate_add(xl, "sctp ");
if (einfo->flags & XT_SCTP_SRC_PORTS) {
if (einfo->spts[0] != einfo->spts[1])
xt_xlate_add(xl, "sport%s %u-%u",
einfo->invflags & XT_SCTP_SRC_PORTS ? " !=" : "",
einfo->spts[0], einfo->spts[1]);
else
xt_xlate_add(xl, "sport%s %u",
einfo->invflags & XT_SCTP_SRC_PORTS ? " !=" : "",
einfo->spts[0]);
space = " ";
}
if (einfo->flags & XT_SCTP_DEST_PORTS) {
if (einfo->dpts[0] != einfo->dpts[1])
xt_xlate_add(xl, "%sdport%s %u-%u", space,
einfo->invflags & XT_SCTP_DEST_PORTS ? " !=" : "",
einfo->dpts[0], einfo->dpts[1]);
else
xt_xlate_add(xl, "%sdport%s %u", space,
einfo->invflags & XT_SCTP_DEST_PORTS ? " !=" : "",
einfo->dpts[0]);
}
return 1;
}
static struct xtables_match sctp_match = {
.name = "sctp",
.family = NFPROTO_UNSPEC,
......@@ -497,6 +535,7 @@ static struct xtables_match sctp_match = {
.print = sctp_print,
.save = sctp_save,
.extra_opts = sctp_opts,
.xlate = sctp_xlate,
};
void _init(void)
......
:INPUT,FORWARD,OUTPUT
-p sctp -m sctp --sport 1;=;OK
-p sctp -m sctp --sport 65535;=;OK
-p sctp -m sctp --sport 1:65535;=;OK
-p sctp -m sctp --sport -1;;FAIL
-p sctp -m sctp --sport 65536;;FAIL
-p sctp -m sctp --dport 1;=;OK
-p sctp -m sctp --dport 1:65535;=;OK
-p sctp -m sctp --dport 65535;=;OK
-p sctp -m sctp --dport -1;;FAIL
-p sctp -m sctp --dport 65536;;FAIL
-p sctp -m sctp --chunk-types all DATA;=;OK
-p sctp -m sctp --chunk-types all INIT;=;OK
-p sctp -m sctp --chunk-types all INIT_ACK;=;OK
-p sctp -m sctp --chunk-types all SACK;=;OK
-p sctp -m sctp --chunk-types all HEARTBEAT;=;OK
-p sctp -m sctp --chunk-types all HEARTBEAT_ACK;=;OK
-p sctp -m sctp --chunk-types all ABORT;=;OK
-p sctp -m sctp --chunk-types all SHUTDOWN;=;OK
-p sctp -m sctp --chunk-types all SHUTDOWN_ACK;=;OK
-p sctp -m sctp --chunk-types all ERROR;=;OK
-p sctp -m sctp --chunk-types all COOKIE_ECHO;=;OK
-p sctp -m sctp --chunk-types all COOKIE_ACK;=;OK
-p sctp -m sctp --chunk-types all ECN_ECNE;=;OK
-p sctp -m sctp --chunk-types all ECN_CWR;=;OK
# ERROR: iptables-save segfaults: iptables -A INPUT -p sctp -m sctp --chunk-types all ASCONF
# -p sctp -m sctp --chunk-types all ASCONF;=;OK
# ERROR: iptables-save segfaults: iptables -A INPUT -p sctp -m sctp --chunk-types all ASCONF_ACK
# -p sctp -m sctp --chunk-types all ASCONF_ACK;=;OK
# ERROR: iptables-save segfaults: iptables -A INPUT -p sctp -m sctp --chunk-types all FORWARD_TSN
# -p sctp -m sctp --chunk-types all FORWARD_TSN;=;OK
-p sctp -m sctp --chunk-types all SHUTDOWN_COMPLETE;=;OK
:INPUT,FORWARD,OUTPUT
-m set --match-set foo;;FAIL
# fails: foo does not exist
-m set --match-set foo src,dst;;FAIL
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment