Commit 89c92f0c authored by Arturo Borrero Gonzalez's avatar Arturo Borrero Gonzalez
Browse files

New upstream version 1.8.3

parent 0309474b
:PREROUTING,FORWARD,OUTPUT,POSTROUTING
*mangle
-j CONNSECMARK --restore;=;OK
-j CONNSECMARK --save;=;OK
-j CONNSECMARK;;FAIL
:PREROUTING,OUTPUT
*raw
-j CT --notrack;=;OK
-j CT --ctevents new,related,destroy,reply,assured,protoinfo,helper,mark;=;OK
-j CT --expevents new;=;OK
# ERROR: cannot find: iptables -I PREROUTING -t raw -j CT --zone 0
# -j CT --zone 0;=;OK
-j CT --zone 65535;=;OK
-j CT --zone 65536;;FAIL
-j CT --zone -1;;FAIL
# ERROR: should fail: iptables -A PREROUTING -t raw -j CT
# -j CT;;FAIL
@nfct timeout add test inet tcp ESTABLISHED 100
# cannot load: iptables -A PREROUTING -t raw -j CT --timeout test
# -j CT --timeout test;=;OK
@nfct timeout del test
@nfct helper add rpc inet tcp
# cannot load: iptables -A PREROUTING -t raw -j CT --helper rpc
# -j CT --helper rpc;=;OK
@nfct helper del rpc
:PREROUTING,INPUT,FORWARD,OUTPUT,POSTROUTING
*mangle
-j DSCP --set-dscp 0;=;OK
-j DSCP --set-dscp 0x3f;=;OK
-j DSCP --set-dscp -1;;FAIL
-j DSCP --set-dscp 0x40;;FAIL
-j DSCP --set-dscp 0x3f --set-dscp-class CS0;;FAIL
-j DSCP --set-dscp-class CS0;-j DSCP --set-dscp 0x00;OK
-j DSCP --set-dscp-class BE;-j DSCP --set-dscp 0x00;OK
-j DSCP --set-dscp-class EF;-j DSCP --set-dscp 0x2e;OK
-j DSCP;;FAIL
: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
:INPUT,FORWARD,OUTPUT
-j IDLETIMER --timeout;;FAIL
-j IDLETIMER --timeout 42;;FAIL
-j IDLETIMER --timeout 42 --label foo;=;OK
: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
#include <getopt.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <xtables.h> #include <xtables.h>
...@@ -245,6 +246,87 @@ static void mark_tg_save(const void *ip, const struct xt_entry_target *target) ...@@ -245,6 +246,87 @@ static void mark_tg_save(const void *ip, const struct xt_entry_target *target)
printf(" --set-xmark 0x%x/0x%x", info->mark, info->mask); printf(" --set-xmark 0x%x/0x%x", info->mark, info->mask);
} }
static void mark_tg_arp_save(const void *ip, const struct xt_entry_target *target)
{
const struct xt_mark_tginfo2 *info = (const void *)target->data;
if (info->mark == 0)
printf(" --and-mark %x", (unsigned int)(uint32_t)~info->mask);
else if (info->mark == info->mask)
printf(" --or-mark %x", info->mark);
else
printf(" --set-mark %x", info->mark);
}
static void mark_tg_arp_print(const void *ip,
const struct xt_entry_target *target, int numeric)
{
mark_tg_arp_save(ip, target);
}
#define MARK_OPT 1
#define AND_MARK_OPT 2
#define OR_MARK_OPT 3
static struct option mark_tg_arp_opts[] = {
{ .name = "set-mark", .has_arg = required_argument, .flag = 0, .val = MARK_OPT },
{ .name = "and-mark", .has_arg = required_argument, .flag = 0, .val = AND_MARK_OPT },
{ .name = "or-mark", .has_arg = required_argument, .flag = 0, .val = OR_MARK_OPT },
{ .name = NULL}
};
static int
mark_tg_arp_parse(int c, char **argv, int invert, unsigned int *flags,
const void *entry, struct xt_entry_target **target)
{
struct xt_mark_tginfo2 *info =
(struct xt_mark_tginfo2 *)(*target)->data;
int i;
switch (c) {
case MARK_OPT:
if (sscanf(argv[optind-1], "%x", &i) != 1) {
xtables_error(PARAMETER_PROBLEM,
"Bad mark value `%s'", optarg);
return 0;
}
info->mark = i;
if (*flags)
xtables_error(PARAMETER_PROBLEM,
"MARK: Can't specify --set-mark twice");
*flags = 1;
break;
case AND_MARK_OPT:
if (sscanf(argv[optind-1], "%x", &i) != 1) {
xtables_error(PARAMETER_PROBLEM,
"Bad mark value `%s'", optarg);
return 0;
}
info->mark = 0;
info->mask = ~i;
if (*flags)
xtables_error(PARAMETER_PROBLEM,
"MARK: Can't specify --and-mark twice");
*flags = 1;
break;
case OR_MARK_OPT:
if (sscanf(argv[optind-1], "%x", &i) != 1) {
xtables_error(PARAMETER_PROBLEM,
"Bad mark value `%s'", optarg);
return 0;
}
info->mark = info->mask = i;
if (*flags)
xtables_error(PARAMETER_PROBLEM,
"MARK: Can't specify --or-mark twice");
*flags = 1;
break;
default:
return 0;
}
return 1;
}
static int mark_tg_xlate(struct xt_xlate *xl, static int mark_tg_xlate(struct xt_xlate *xl,
const struct xt_xlate_tg_params *params) const struct xt_xlate_tg_params *params)
{ {
...@@ -335,6 +417,19 @@ static struct xtables_target mark_tg_reg[] = { ...@@ -335,6 +417,19 @@ static struct xtables_target mark_tg_reg[] = {
.x6_options = mark_tg_opts, .x6_options = mark_tg_opts,
.xlate = mark_tg_xlate, .xlate = mark_tg_xlate,
}, },
{
.version = XTABLES_VERSION,
.name = "MARK",
.revision = 2,
.family = NFPROTO_ARP,
.size = XT_ALIGN(sizeof(struct xt_mark_tginfo2)),
.userspacesize = XT_ALIGN(sizeof(struct xt_mark_tginfo2)),
.help = mark_tg_help,
.print = mark_tg_arp_print,
.save = mark_tg_arp_save,
.parse = mark_tg_arp_parse,
.extra_opts = mark_tg_arp_opts,
},
}; };
void _init(void) void _init(void)
......
:INPUT,FORWARD,OUTPUT
-j MARK --set-xmark 0xfeedcafe/0xfeedcafe;=;OK
-j MARK --set-xmark 0;=;OK
-j MARK --set-xmark 4294967295;-j MARK --set-xmark 0xffffffff;OK
-j MARK --set-xmark 4294967296;;FAIL
-j MARK --set-xmark -1;;FAIL
-j MARK;;FAIL
:INPUT,FORWARD,OUTPUT
-j NFLOG --nflog-group 1;=;OK
-j NFLOG --nflog-group 65535;=;OK
-j NFLOG --nflog-group 65536;;FAIL
-j NFLOG --nflog-group 0;-j NFLOG;OK
-j NFLOG --nflog-range 1;=;OK
-j NFLOG --nflog-range 4294967295;=;OK
-j NFLOG --nflog-range 4294967296;;FAIL
-j NFLOG --nflog-range -1;;FAIL
-j NFLOG --nflog-size 0;=;OK
-j NFLOG --nflog-size 1;=;OK
-j NFLOG --nflog-size 4294967295;=;OK
-j NFLOG --nflog-size 4294967296;;FAIL
-j NFLOG --nflog-size -1;;FAIL
# ERROR: cannot find: iptables -I INPUT -j NFLOG --nflog-prefix xxxxxx [...]
# -j NFLOG --nflog-prefix xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx;=;OK
# ERROR: should fail: iptables -A INPUT -j NFLOG --nflog-prefix xxxxxxx [...]
# -j NFLOG --nflog-prefix xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx;;FAIL
-j NFLOG --nflog-threshold 1;=;OK
# ERROR: line 13 (should fail: iptables -A INPUT -j NFLOG --nflog-threshold 0
# -j NFLOG --nflog-threshold 0;;FAIL
-j NFLOG --nflog-threshold 65535;=;OK
-j NFLOG --nflog-threshold 65536;;FAIL
-j NFLOG;=;OK
:INPUT,FORWARD,OUTPUT
-j NFQUEUE;=;OK
-j NFQUEUE --queue-num 0;=;OK
-j NFQUEUE --queue-num 65535;=;OK
-j NFQUEUE --queue-num 65536;;FAIL
-j NFQUEUE --queue-num -1;;FAIL
# it says "NFQUEUE: number of total queues is 0", overflow in NFQUEUE_parse_v1?
# ERROR: cannot load: iptables -A INPUT -j NFQUEUE --queue-balance 0:65535
# -j NFQUEUE --queue-balance 0:65535;=;OK
-j NFQUEUE --queue-balance 0:65536;;FAIL
-j NFQUEUE --queue-balance -1:65535;;FAIL
-j NFQUEUE --queue-num 10 --queue-bypass;=;OK
-j NFQUEUE --queue-balance 0:6 --queue-cpu-fanout --queue-bypass;-j NFQUEUE --queue-balance 0:6 --queue-bypass --queue-cpu-fanout;OK
-j NFQUEUE --queue-bypass --queue-balance 0:6 --queue-cpu-fanout;-j NFQUEUE --queue-balance 0:6 --queue-bypass --queue-cpu-fanout;OK
-j NFQUEUE --queue-balance 0:6 --queue-bypass;=;OK
-j NFQUEUE --queue-bypass;-j NFQUEUE --queue-num 0 --queue-bypass;OK
:PREROUTING,OUTPUT
*raw
# ERROR: cannot find: iptables -I PREROUTING -t raw -j NOTRACK
#-j NOTRACK;=;OK
:INPUT,FORWARD,OUTPUT
-j RATEEST --rateest-name RE1 --rateest-interval 250.0ms --rateest-ewmalog 500.0ms;=;OK
:INPUT,FORWARD,OUTPUT
# fails: foo does not exist
-j SET --add-set foo src,dst;;FAIL
This target will process TCP three-way-handshake parallel in netfilter This target will process TCP three-way-handshake parallel in netfilter
context to protect either local or backend system. This target requires context to protect either local or backend system. This target requires
connection tracking because sequence numbers need to be translated. connection tracking because sequence numbers need to be translated.
The kernels ability to absorb SYNFLOOD was greatly improved starting with
Linux 4.4, so this target should not be needed anymore to protect Linux servers.
.TP .TP
\fB\-\-mss\fP \fImaximum segment size\fP \fB\-\-mss\fP \fImaximum segment size\fP
Maximum segment size announced to clients. This must match the backend. Maximum segment size announced to clients. This must match the backend.
......
: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
: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
: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
:INPUT,FORWARD,OUTPUT
-j TEE --gateway 1.1.1.1;=;OK
-j TEE ! --gateway 1.1.1.1;;FAIL
-j TEE;;FAIL
:PREROUTING,INPUT,FORWARD,OUTPUT,POSTROUTING
*mangle
-j TOS --set-tos 0x1f;=;OK
-j TOS --set-tos 0x1f/0x1f;=;OK
# maximum TOS is 0x1f (5 bits)
# ERROR: should fail: iptables -A PREROUTING -t mangle -j TOS --set-tos 0xff
# -j TOS --set-tos 0xff;;FAIL
-j TOS --set-tos Minimize-Delay;-j TOS --set-tos 0x10;OK
-j TOS --set-tos Maximize-Throughput;-j TOS --set-tos 0x08;OK
-j TOS --set-tos Maximize-Reliability;-j TOS --set-tos 0x04;OK
-j TOS --set-tos Minimize-Cost;-j TOS --set-tos 0x02;OK
-j TOS --set-tos Normal-Service;-j TOS --set-tos 0x00;OK
-j TOS --and-tos 0x12;-j TOS --set-tos 0x00/0xed;OK
-j TOS --or-tos 0x12;-j TOS --set-tos 0x12/0x12;OK
-j TOS --xor-tos 0x12;-j TOS --set-tos 0x12/0x00;OK
-j TOS;;FAIL
: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
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