Commit 268c6aa1 authored by Arturo Borrero Gonzalez's avatar Arturo Borrero Gonzalez
Browse files

Merge tag 'debian/1.8.5-3' into debian/buster-backports



Debian package 1.8.5-3
Signed-off-by: default avatarArturo Borrero Gonzalez <arturo@debian.org>
parents ada8a2c9 9fa0e185
...@@ -9,7 +9,7 @@ DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) ...@@ -9,7 +9,7 @@ DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
LIB_DIR := /usr/lib/$(DEB_HOST_MULTIARCH) LIB_DIR := /usr/lib/$(DEB_HOST_MULTIARCH)
%: %:
dh $@ --with autoreconf dh $@
override_dh_auto_configure: override_dh_auto_configure:
dh_auto_configure -- --disable-libipq --enable-devel \ dh_auto_configure -- --disable-libipq --enable-devel \
......
Test-Command: iptables -h Test-Command: iptables-legacy -h
Depends: @ Depends: @
Restrictions: needs-root, isolation-container Restrictions: needs-root, isolation-container
Test-Command: ip6tables -h Test-Command: ip6tables-legacy -h
Depends: @ Depends: @
Restrictions: needs-root, isolation-container Restrictions: needs-root, isolation-container
Test-Command: iptables-save Test-Command: iptables-legacy-save
Depends: @ Depends: @
Restrictions: needs-root, isolation-container Restrictions: needs-root, isolation-container
Test-Command: ip6tables-save Test-Command: ip6tables-legacy-save
Depends: @ Depends: @
Restrictions: needs-root, isolation-container Restrictions: needs-root, isolation-container
Test-Command: iptables-restore -h Test-Command: iptables-legacy-restore -h
Depends: @ Depends: @
Restrictions: needs-root, isolation-container, allow-stderr Restrictions: needs-root, isolation-container, allow-stderr
Test-Command: ip6tables-restore -h Test-Command: ip6tables-legacy-restore -h
Depends: @ Depends: @
Restrictions: needs-root, isolation-container, allow-stderr Restrictions: needs-root, isolation-container, allow-stderr
......
Repository: git://git.netfilter.org/iptables
...@@ -18,3 +18,19 @@ nft add rule bridge filter FORWARD iifname != "iname" meta ibrname "ilogname" oi ...@@ -18,3 +18,19 @@ nft add rule bridge filter FORWARD iifname != "iname" meta ibrname "ilogname" oi
ebtables-translate -I INPUT -p ip -d 1:2:3:4:5:6/ff:ff:ff:ff:00:00 ebtables-translate -I INPUT -p ip -d 1:2:3:4:5:6/ff:ff:ff:ff:00:00
nft insert rule bridge filter INPUT ether type 0x800 ether daddr 01:02:03:04:00:00 and ff:ff:ff:ff:00:00 == 01:02:03:04:00:00 counter nft insert rule bridge filter INPUT ether type 0x800 ether daddr 01:02:03:04:00:00 and ff:ff:ff:ff:00:00 == 01:02:03:04:00:00 counter
# asterisk is not special in iptables and it is even a valid interface name
iptables-translate -A FORWARD -i '*' -o 'eth*foo'
nft add rule ip filter FORWARD iifname "\*" oifname "eth\*foo" counter
# escape all asterisks but translate only the first plus character
iptables-translate -A FORWARD -i 'eth*foo*+' -o 'eth++'
nft add rule ip filter FORWARD iifname "eth\*foo\**" oifname "eth+*" counter
# skip for always matching interface names
iptables-translate -A FORWARD -i '+'
nft add rule ip filter FORWARD counter
# match against invalid interface name to simulate never matching rule
iptables-translate -A FORWARD ! -i '+'
nft add rule ip filter FORWARD iifname "INVAL/D" counter
/* ebt_among
*
* Authors:
* Grzegorz Borowiak <grzes@gnu.univ.gda.pl>
*
* August, 2003
*/
#include <errno.h>
#include <ctype.h>
#include <fcntl.h>
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <xtables.h>
#include <arpa/inet.h>
#include <netinet/ether.h>
#include <netinet/in.h>
#include <linux/if_ether.h>
#include <linux/netfilter_bridge/ebt_among.h>
#include <sys/mman.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include "iptables/nft.h"
#include "iptables/nft-bridge.h"
#define AMONG_DST '1'
#define AMONG_SRC '2'
#define AMONG_DST_F '3'
#define AMONG_SRC_F '4'
static const struct option bramong_opts[] = {
{"among-dst", required_argument, 0, AMONG_DST},
{"among-src", required_argument, 0, AMONG_SRC},
{"among-dst-file", required_argument, 0, AMONG_DST_F},
{"among-src-file", required_argument, 0, AMONG_SRC_F},
{0}
};
static void bramong_print_help(void)
{
printf(
"`among' options:\n"
"--among-dst [!] list : matches if ether dst is in list\n"
"--among-src [!] list : matches if ether src is in list\n"
"--among-dst-file [!] file : obtain dst list from file\n"
"--among-src-file [!] file : obtain src list from file\n"
"list has form:\n"
" xx:xx:xx:xx:xx:xx[=ip.ip.ip.ip],yy:yy:yy:yy:yy:yy[=ip.ip.ip.ip]"
",...,zz:zz:zz:zz:zz:zz[=ip.ip.ip.ip][,]\n"
"Things in brackets are optional.\n"
"If you want to allow two (or more) IP addresses to one MAC address, you\n"
"can specify two (or more) pairs with the same MAC, e.g.\n"
" 00:00:00:fa:eb:fe=153.19.120.250,00:00:00:fa:eb:fe=192.168.0.1\n"
);
}
static void
parse_nft_among_pair(char *buf, struct nft_among_pair *pair, bool have_ip)
{
char *sep = index(buf, '=');
struct ether_addr *ether;
if (sep) {
*sep = '\0';
if (!inet_aton(sep + 1, &pair->in))
xtables_error(PARAMETER_PROBLEM,
"Invalid IP address '%s'\n", sep + 1);
}
ether = ether_aton(buf);
if (!ether)
xtables_error(PARAMETER_PROBLEM,
"Invalid MAC address '%s'\n", buf);
memcpy(&pair->ether, ether, sizeof(*ether));
}
static void
parse_nft_among_pairs(struct nft_among_pair *pairs, char *buf,
size_t cnt, bool have_ip)
{
size_t tmpcnt = 0;
buf = strtok(buf, ",");
while (buf) {
struct nft_among_pair pair = {};
parse_nft_among_pair(buf, &pair, have_ip);
nft_among_insert_pair(pairs, &tmpcnt, &pair);
buf = strtok(NULL, ",");
}
}
static size_t count_nft_among_pairs(char *buf)
{
size_t cnt = 0;
char *p = buf;
if (!*buf)
return 0;
do {
cnt++;
p = index(++p, ',');
} while (p);
return cnt;
}
static bool nft_among_pairs_have_ip(char *buf)
{
return !!index(buf, '=');
}
static int bramong_parse(int c, char **argv, int invert,
unsigned int *flags, const void *entry,
struct xt_entry_match **match)
{
struct nft_among_data *data = (struct nft_among_data *)(*match)->data;
struct xt_entry_match *new_match;
bool have_ip, dst = false;
size_t new_size, cnt;
struct stat stats;
int fd = -1, poff;
long flen = 0;
switch (c) {
case AMONG_DST_F:
dst = true;
/* fall through */
case AMONG_SRC_F:
if ((fd = open(optarg, O_RDONLY)) == -1)
xtables_error(PARAMETER_PROBLEM,
"Couldn't open file '%s'", optarg);
if (fstat(fd, &stats) < 0)
xtables_error(PARAMETER_PROBLEM,
"fstat(%s) failed: '%s'",
optarg, strerror(errno));
flen = stats.st_size;
/* use mmap because the file will probably be big */
optarg = mmap(0, flen, PROT_READ | PROT_WRITE,
MAP_PRIVATE, fd, 0);
if (optarg == MAP_FAILED)
xtables_error(PARAMETER_PROBLEM,
"Couldn't map file to memory");
if (optarg[flen-1] != '\n')
xtables_error(PARAMETER_PROBLEM,
"File should end with a newline");
if (strchr(optarg, '\n') != optarg+flen-1)
xtables_error(PARAMETER_PROBLEM,
"File should only contain one line");
optarg[flen-1] = '\0';
/* fall through */
case AMONG_DST:
if (c == AMONG_DST)
dst = true;
/* fall through */
case AMONG_SRC:
break;
default:
return 0;
}
cnt = count_nft_among_pairs(optarg);
if (cnt == 0)
return 0;
new_size = data->src.cnt + data->dst.cnt + cnt;
new_size *= sizeof(struct nft_among_pair);
new_size += XT_ALIGN(sizeof(struct xt_entry_match)) +
sizeof(struct nft_among_data);
new_match = xtables_calloc(1, new_size);
memcpy(new_match, *match, (*match)->u.match_size);
new_match->u.match_size = new_size;
data = (struct nft_among_data *)new_match->data;
have_ip = nft_among_pairs_have_ip(optarg);
poff = nft_among_prepare_data(data, dst, cnt, invert, have_ip);
parse_nft_among_pairs(data->pairs + poff, optarg, cnt, have_ip);
free(*match);
*match = new_match;
if (c == AMONG_DST_F || c == AMONG_SRC_F) {
munmap(argv, flen);
close(fd);
}
return 1;
}
static void __bramong_print(struct nft_among_pair *pairs,
int cnt, bool inv, bool have_ip)
{
const char *isep = inv ? "! " : "";
int i;
for (i = 0; i < cnt; i++) {
printf("%s", isep);
isep = ",";
printf("%s", ether_ntoa(&pairs[i].ether));
if (pairs[i].in.s_addr != INADDR_ANY)
printf("=%s", inet_ntoa(pairs[i].in));
}
printf(" ");
}
static void bramong_print(const void *ip, const struct xt_entry_match *match,
int numeric)
{
struct nft_among_data *data = (struct nft_among_data *)match->data;
if (data->src.cnt) {
printf("--among-src ");
__bramong_print(data->pairs,
data->src.cnt, data->src.inv, data->src.ip);
}
if (data->dst.cnt) {
printf("--among-dst ");
__bramong_print(data->pairs + data->src.cnt,
data->dst.cnt, data->dst.inv, data->dst.ip);
}
}
static struct xtables_match bramong_match = {
.name = "among",
.revision = 0,
.version = XTABLES_VERSION,
.family = NFPROTO_BRIDGE,
.size = XT_ALIGN(sizeof(struct nft_among_data)),
.userspacesize = XT_ALIGN(sizeof(struct nft_among_data)),
.help = bramong_print_help,
.parse = bramong_parse,
.print = bramong_print,
.extra_opts = bramong_opts,
};
void _init(void)
{
xtables_register_match(&bramong_match);
}
:INPUT,FORWARD,OUTPUT
--among-dst de:ad:0:be:ee:ff,c0:ff:ee:0:ba:be;--among-dst c0:ff:ee:0:ba:be,de:ad:0:be:ee:ff;OK
--among-dst ! c0:ff:ee:0:ba:be,de:ad:0:be:ee:ff;=;OK
--among-src be:ef:0:c0:ff:ee,c0:ff:ee:0:ba:be,de:ad:0:be:ee:ff;=;OK
--among-src de:ad:0:be:ee:ff=10.0.0.1,c0:ff:ee:0:ba:be=192.168.1.1;--among-src c0:ff:ee:0:ba:be=192.168.1.1,de:ad:0:be:ee:ff=10.0.0.1;OK
--among-src ! c0:ff:ee:0:ba:be=192.168.1.1,de:ad:0:be:ee:ff=10.0.0.1;=;OK
--among-src de:ad:0:be:ee:ff --among-dst c0:ff:ee:0:ba:be;=;OK
--among-src de:ad:0:be:ee:ff=10.0.0.1 --among-dst c0:ff:ee:0:ba:be=192.168.1.1;=;OK
--among-src ! de:ad:0:be:ee:ff --among-dst c0:ff:ee:0:ba:be;=;OK
--among-src de:ad:0:be:ee:ff=10.0.0.1 --among-dst ! c0:ff:ee:0:ba:be=192.168.1.1;=;OK
--among-src ! de:ad:0:be:ee:ff --among-dst c0:ff:ee:0:ba:be=192.168.1.1;=;OK
--among-src de:ad:0:be:ee:ff=10.0.0.1 --among-dst ! c0:ff:ee:0:ba:be=192.168.1.1;=;OK
--among-src;=;FAIL
--among-src 00:11=10.0.0.1;=;FAIL
--among-src de:ad:0:be:ee:ff=10.256.0.1;=;FAIL
--among-src c0:ff:ee:0:ba:be=192.168.1.1,de:ad:0:be:ee:ff;=;OK
...@@ -9,3 +9,20 @@ ...@@ -9,3 +9,20 @@
-p ! ARP -j ACCEPT;=;OK -p ! ARP -j ACCEPT;=;OK
-p 0 -j ACCEPT;=;FAIL -p 0 -j ACCEPT;=;FAIL
-p ! 0 -j ACCEPT;=;FAIL -p ! 0 -j ACCEPT;=;FAIL
:INPUT
-i foobar;=;OK
-o foobar;=;FAIL
:FORWARD
-i foobar;=;OK
-o foobar;=;OK
:OUTPUT
-i foobar;=;FAIL
-o foobar;=;OK
:PREROUTING
*nat
-i foobar;=;OK
-o foobar;=;FAIL
:POSTROUTING
*nat
-i foobar;=;FAIL
-o foobar;=;OK
...@@ -23,7 +23,7 @@ ip6tables \-t mangle \-I PREROUTING \-i wlan0 \-d 2001:e20:2000:40f::/64 ...@@ -23,7 +23,7 @@ ip6tables \-t mangle \-I PREROUTING \-i wlan0 \-d 2001:e20:2000:40f::/64
.PP .PP
You may need to enable IPv6 neighbor proxy: You may need to enable IPv6 neighbor proxy:
.IP .IP
sysctl -w net.ipv6.conf.all.proxy_ndp=1 sysctl \-w net.ipv6.conf.all.proxy_ndp=1
.PP .PP
You also have to use the You also have to use the
.B NOTRACK .B NOTRACK
......
...@@ -23,7 +23,7 @@ ip6tables \-t mangle \-I PREROUTING \-i wlan0 \-d 2001:e20:2000:40f::/64 ...@@ -23,7 +23,7 @@ ip6tables \-t mangle \-I PREROUTING \-i wlan0 \-d 2001:e20:2000:40f::/64
.PP .PP
You may need to enable IPv6 neighbor proxy: You may need to enable IPv6 neighbor proxy:
.IP .IP
sysctl -w net.ipv6.conf.all.proxy_ndp=1 sysctl \-w net.ipv6.conf.all.proxy_ndp=1
.PP .PP
You also have to use the You also have to use the
.B NOTRACK .B NOTRACK
......
...@@ -23,6 +23,6 @@ ...@@ -23,6 +23,6 @@
-m srh ! --srh-tag 0;=;OK -m srh ! --srh-tag 0;=;OK
-m srh --srh-next-hdr 17 --srh-segs-left-eq 1 --srh-last-entry-eq 4 --srh-tag 0;=;OK -m srh --srh-next-hdr 17 --srh-segs-left-eq 1 --srh-last-entry-eq 4 --srh-tag 0;=;OK
-m srh ! --srh-next-hdr 17 ! --srh-segs-left-eq 0 --srh-tag 0;=;OK -m srh ! --srh-next-hdr 17 ! --srh-segs-left-eq 0 --srh-tag 0;=;OK
-m srh --srh-psid A::/64 --srh-nsid B:: --srh-lsid C::/0;;OK -m srh --srh-psid a::/64 --srh-nsid b::/128 --srh-lsid c::/0;=;OK
-m srh ! --srh-psid A::/64 ! --srh-nsid B:: ! --srh-lsid C::/0;;OK -m srh ! --srh-psid a::/64 ! --srh-nsid b::/128 ! --srh-lsid c::/0;=;OK
-m srh;=;OK -m srh;=;OK
...@@ -2,6 +2,9 @@ This module allows you to configure a simple cluster of nodes that share ...@@ -2,6 +2,9 @@ This module allows you to configure a simple cluster of nodes that share
a certain IP and MAC address without an explicit load balancer in front of a certain IP and MAC address without an explicit load balancer in front of
them. Connections are statically distributed between the nodes in this them. Connections are statically distributed between the nodes in this
cluster. cluster.
.PP
Please note that CLUSTERIP target is considered deprecated in favour of cluster
match which is more flexible and not limited to IPv4.
.TP .TP
\fB\-\-new\fP \fB\-\-new\fP
Create a new ClusterIP. You always have to set this on the first rule Create a new ClusterIP. You always have to set this on the first rule
......
This target allows to selectively work around known ECN blackholes. This target selectively works around known ECN blackholes.
It can only be used in the mangle table. It can only be used in the mangle table.
.TP .TP
\fB\-\-ecn\-tcp\-remove\fP \fB\-\-ecn\-tcp\-remove\fP
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <strings.h>
#include <xtables.h> #include <xtables.h>
/* For 64bit kernel / 32bit userspace */ /* For 64bit kernel / 32bit userspace */
#include <linux/netfilter_ipv4/ipt_ULOG.h> #include <linux/netfilter_ipv4/ipt_ULOG.h>
......
This target allows to create audit records for packets hitting the target. This target creates audit records for packets hitting the target.
It can be used to record accepted, dropped, and rejected packets. See It can be used to record accepted, dropped, and rejected packets. See
auditd(8) for additional details. auditd(8) for additional details.
.TP .TP
......
This target allows to selectively work around broken/old applications. This target selectively works around broken/old applications.
It can only be used in the mangle table. It can only be used in the mangle table.
.TP .TP
\fB\-\-checksum\-fill\fP \fB\-\-checksum\-fill\fP
......
...@@ -348,6 +348,20 @@ static void notrack_ct2_tg_init(struct xt_entry_target *target) ...@@ -348,6 +348,20 @@ static void notrack_ct2_tg_init(struct xt_entry_target *target)
info->flags = XT_CT_NOTRACK | XT_CT_NOTRACK_ALIAS; info->flags = XT_CT_NOTRACK | XT_CT_NOTRACK_ALIAS;
} }
static int xlate_ct1_tg(struct xt_xlate *xl,
const struct xt_xlate_tg_params *params)
{
struct xt_ct_target_info_v1 *info =
(struct xt_ct_target_info_v1 *)params->target->data;
if (info->flags & XT_CT_NOTRACK)
xt_xlate_add(xl, "notrack");
else
return 0;
return 1;
}
static struct xtables_target ct_target_reg[] = { static struct xtables_target ct_target_reg[] = {
{ {
.family = NFPROTO_UNSPEC, .family = NFPROTO_UNSPEC,
...@@ -387,6 +401,7 @@ static struct xtables_target ct_target_reg[] = { ...@@ -387,6 +401,7 @@ static struct xtables_target ct_target_reg[] = {
.alias = ct_print_name_alias, .alias = ct_print_name_alias,
.x6_parse = ct_parse_v1, .x6_parse = ct_parse_v1,
.x6_options = ct_opts_v1, .x6_options = ct_opts_v1,
.xlate = xlate_ct1_tg,
}, },
{ {
.family = NFPROTO_UNSPEC, .family = NFPROTO_UNSPEC,
...@@ -418,6 +433,7 @@ static struct xtables_target ct_target_reg[] = { ...@@ -418,6 +433,7 @@ static struct xtables_target ct_target_reg[] = {
.size = XT_ALIGN(sizeof(struct xt_ct_target_info_v1)), .size = XT_ALIGN(sizeof(struct xt_ct_target_info_v1)),
.userspacesize = offsetof(struct xt_ct_target_info_v1, ct), .userspacesize = offsetof(struct xt_ct_target_info_v1, ct),
.init = notrack_ct2_tg_init, .init = notrack_ct2_tg_init,
.xlate = xlate_ct1_tg,
}, },
{ {
.family = NFPROTO_UNSPEC, .family = NFPROTO_UNSPEC,
......
The CT target allows to set parameters for a packet or its associated The CT target sets parameters for a packet or its associated
connection. The target attaches a "template" connection tracking entry to connection. The target attaches a "template" connection tracking entry to
the packet, which is then used by the conntrack core when initializing the packet, which is then used by the conntrack core when initializing
a new ct entry. This target is thus only valid in the "raw" table. a new ct entry. This target is thus only valid in the "raw" table.
......
This target allows to alter the value of the DSCP bits within the TOS This target alters the value of the DSCP bits within the TOS
header of the IPv4 packet. As this manipulates a packet, it can only header of the IPv4 packet. As this manipulates a packet, it can only
be used in the mangle table. be used in the mangle table.
.TP .TP
......
...@@ -56,5 +56,5 @@ iptables \-t mangle \-A PREROUTING \-m conntrack \-\-ctstate NEW ...@@ -56,5 +56,5 @@ iptables \-t mangle \-A PREROUTING \-m conntrack \-\-ctstate NEW
\-j HMARK \-\-hmark-tuple ct,src,dst,proto \-\-hmark-offset 10000 \-j HMARK \-\-hmark-tuple ct,src,dst,proto \-\-hmark-offset 10000
\-\-hmark\-mod 10 \-\-hmark\-rnd 0xfeedcafe \-\-hmark\-mod 10 \-\-hmark\-rnd 0xfeedcafe
.PP .PP
iptables \-t mangle \-A PREROUTING -j HMARK \-\-hmark\-offset 10000 iptables \-t mangle \-A PREROUTING \-j HMARK \-\-hmark\-offset 10000
\-\-hmark-tuple src,dst,proto \-\-hmark-mod 10 \-\-hmark\-rnd 0xdeafbeef \-\-hmark-tuple src,dst,proto \-\-hmark-mod 10 \-\-hmark\-rnd 0xdeafbeef
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
enum { enum {
O_TIMEOUT = 0, O_TIMEOUT = 0,
O_LABEL, O_LABEL,
O_ALARM,
}; };
#define s struct idletimer_tg_info #define s struct idletimer_tg_info
...@@ -39,6 +40,17 @@ static const struct xt_option_entry idletimer_tg_opts[] = { ...@@ -39,6 +40,17 @@ static const struct xt_option_entry idletimer_tg_opts[] = {
}; };
#undef s #undef s
#define s struct idletimer_tg_info_v1
static const struct xt_option_entry idletimer_tg_opts_v1[] = {
{.name = "timeout", .id = O_TIMEOUT, .type = XTTYPE_UINT32,
.flags = XTOPT_MAND | XTOPT_PUT, XTOPT_POINTER(s, timeout)},
{.name = "label", .id = O_LABEL, .type = XTTYPE_STRING,
.flags = XTOPT_MAND | XTOPT_PUT, XTOPT_POINTER(s, label)},
{.name = "alarm", .id = O_ALARM, .type = XTTYPE_NONE},
XTOPT_TABLEEND,
};
#undef s
static void idletimer_tg_help(void) static void idletimer_tg_help(void)
{ {
printf( printf(
...@@ -48,6 +60,16 @@ static void idletimer_tg_help(void) ...@@ -48,6 +60,16 @@ static void idletimer_tg_help(void)
"\n"); "\n");
} }
static void idletimer_tg_help_v1(void)
{
printf(
"IDLETIMER target options:\n"
" --timeout time Timeout until the notification is sent (in seconds)\n"
" --label string Unique rule identifier\n"
" --alarm Use alarm instead of default timer\n"
"\n");
}
static void idletimer_tg_print(const void *ip, static void idletimer_tg_print(const void *ip,
const struct xt_entry_target *target, const struct xt_entry_target *target,
int numeric) int numeric)
...@@ -59,6 +81,20 @@ static void idletimer_tg_print(const void *ip, ...@@ -59,6 +81,20 @@ static void idletimer_tg_print(const void *ip,
printf(" label:%s", info->label); printf(" label:%s", info->label);
} }
static void idletimer_tg_print_v1(const void *ip,
const struct xt_entry_target *target,
int numeric)
{
struct idletimer_tg_info_v1 *info =
(struct idletimer_tg_info_v1 *) target->data;
printf(" timeout:%u", info->timeout);
printf(" label:%s", info->label);
if (info->timer_type == XT_IDLETIMER_ALARM)
printf(" alarm");
}
static void idletimer_tg_save(const void *ip, static void idletimer_tg_save(const void *ip,
const struct xt_entry_target *target) const struct xt_entry_target *target)
{ {
...@@ -69,21 +105,58 @@ static void idletimer_tg_save(const void *ip, ...@@ -69,21 +105,58 @@ static void idletimer_tg_save(const void *ip,
printf(" --label %s", info->label); printf(" --label %s", info->label);
} }
static struct xtables_target idletimer_tg_reg = { static void idletimer_tg_save_v1(const void *ip,
.family = NFPROTO_UNSPEC, const struct xt_entry_target *target)
.name = "IDLETIMER", {
.version = XTABLES_VERSION, struct idletimer_tg_info_v1 *info =
.revision = 0, (struct idletimer_tg_info_v1 *) target->data;
.size = XT_ALIGN(sizeof(struct idletimer_tg_info)),
.userspacesize = offsetof(struct idletimer_tg_info, timer), printf(" --timeout %u", info->timeout);
.help = idletimer_tg_help, printf(" --label %s", info->label);
.x6_parse = xtables_option_parse, if (info->timer_type == XT_IDLETIMER_ALARM)
.print = idletimer_tg_print, printf(" --alarm");
.save = idletimer_tg_save, }
.x6_options = idletimer_tg_opts,
static void idletimer_tg_parse_v1(struct xt_option_call *cb)
{
struct idletimer_tg_info_v1 *info = cb->data;
xtables_option_parse(cb);
if (cb->entry->id == O_ALARM)
info->timer_type = XT_IDLETIMER_ALARM;
}
static struct xtables_target idletimer_tg_reg[] = {
{
.family = NFPROTO_UNSPEC,
.name = "IDLETIMER",
.version = XTABLES_VERSION,
.revision = 0,
.size = XT_ALIGN(sizeof(struct idletimer_tg_info)),
.userspacesize = offsetof(struct idletimer_tg_info, timer),
.help = idletimer_tg_help,
.x6_parse = xtables_option_parse,
.print = idletimer_tg_print,
.save = idletimer_tg_save,
.x6_options = idletimer_tg_opts,
},
{
.family = NFPROTO_UNSPEC,
.name = "IDLETIMER",
.version = XTABLES_VERSION,
.revision = 1,
.size = XT_ALIGN(sizeof(struct idletimer_tg_info_v1)),
.userspacesize = offsetof(struct idletimer_tg_info_v1, timer),
.help = idletimer_tg_help_v1,
.x6_parse = idletimer_tg_parse_v1,
.print = idletimer_tg_print_v1,
.save = idletimer_tg_save_v1,
.x6_options = idletimer_tg_opts_v1,
},
}; };
void _init(void) void _init(void)
{ {
xtables_register_target(&idletimer_tg_reg); xtables_register_targets(idletimer_tg_reg, ARRAY_SIZE(idletimer_tg_reg));
} }
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