]> git.ipfire.org Git - thirdparty/iptables.git/log
thirdparty/iptables.git
10 years agoebtables-compat: add support for limit extension
Arturo Borrero [Wed, 4 Mar 2015 18:49:02 +0000 (19:49 +0100)] 
ebtables-compat: add support for limit extension

Add support for the ebtables limit extension (match),

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
10 years agoman: using physdev match in OUTPUT is not supported anymore
Florian Westphal [Fri, 6 Mar 2015 12:09:51 +0000 (13:09 +0100)] 
man: using physdev match in OUTPUT is not supported anymore

kernels 2.6.20 and later reject -m physdev in OUTPUT with
"using --physdev-out in the OUTPUT, FORWARD and POSTROUTING chains for
 non-bridged traffic is not supported anymore" error in dmesg.

Signed-off-by: Florian Westphal <fw@strlen.de>
10 years agoarptables-compat: delete extra space in target printing
Arturo Borrero [Thu, 5 Mar 2015 18:47:52 +0000 (19:47 +0100)] 
arptables-compat: delete extra space in target printing

This is an extra space, let's get rid of it.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoarptables-compat: add support for the CLASSIFY target
Arturo Borrero [Thu, 5 Mar 2015 18:47:38 +0000 (19:47 +0100)] 
arptables-compat: add support for the CLASSIFY target

This patch adds support to arptables-compat for the CLASSIFY target.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoebtables-compat: support nflog extension
Arturo Borrero [Tue, 3 Mar 2015 18:48:13 +0000 (19:48 +0100)] 
ebtables-compat: support nflog extension

Let's give support for the nflog extension (a watcher).

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agolibxt_quota: fix _save() invert syntax
Arturo Borrero [Mon, 23 Feb 2015 10:31:11 +0000 (11:31 +0100)] 
libxt_quota: fix _save() invert syntax

Space is misplaced.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoiptables-compat: unset context flags in netlink delinearize step
Pablo Neira Ayuso [Wed, 18 Feb 2015 23:15:13 +0000 (00:15 +0100)] 
iptables-compat: unset context flags in netlink delinearize step

Once the data that the compare expression provides have been digested.

For example:

-A INPUT -i noexist -p udplite -s 10.10.10.10/32 -d 10.0.0.10/32 -j ACCEPT

doesn't show anymore the following broken output via iptables-compat-save:

-A INPUT -i

+t -p udplite -s 10.10.10.10/32 -d 10.0.0.10/32 -j ACCEPT

Reported-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Tested-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
10 years agotests: remove old test cases
Florian Westphal [Thu, 19 Feb 2015 13:17:17 +0000 (14:17 +0100)] 
tests: remove old test cases

Obsoleted by iptables-test.py in project root directory,
see extensions/*.t for the new test cases.

Signed-off-by: Florian Westphal <fw@strlen.de>
10 years agoextensions: libip6t_dst: make inversion work
Florian Westphal [Thu, 19 Feb 2015 11:26:42 +0000 (12:26 +0100)] 
extensions: libip6t_dst: make inversion work

The inversion flag wasn't set in the match struct.

Signed-off-by: Florian Westphal <fw@strlen.de>
10 years agoextensions/libxt_recent.t: add test case for 3.19 regression
Florian Westphal [Thu, 19 Feb 2015 11:24:31 +0000 (12:24 +0100)] 
extensions/libxt_recent.t: add test case for 3.19 regression

fail with vanilla 3.19.

Signed-off-by: Florian Westphal <fw@strlen.de>
10 years agoextensions: SNPT,DNPT: fix save/print output
Florian Westphal [Thu, 19 Feb 2015 11:28:18 +0000 (12:28 +0100)] 
extensions: SNPT,DNPT: fix save/print output

wrong placement of ' ', i.e. we get
-j SNPT--src-pfx dead::/64 --dst-pfx 1c3::/64

Signed-off-by: Florian Westphal <fw@strlen.de>
10 years agoextensions: add more test cases for iptables-test.py
Florian Westphal [Thu, 19 Feb 2015 01:23:19 +0000 (02:23 +0100)] 
extensions: add more test cases for iptables-test.py

Instead 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.

Suggested-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Florian Westphal <fw@strlen.de>
10 years agoextensions: remove 'unclean' match
Florian Westphal [Thu, 19 Feb 2015 00:27:36 +0000 (01:27 +0100)] 
extensions: remove 'unclean' match

removed from kernel in 2003.

Signed-off-by: Florian Westphal <fw@strlen.de>
10 years agoextensions: remove SAME target
Florian Westphal [Thu, 19 Feb 2015 00:20:15 +0000 (01:20 +0100)] 
extensions: remove SAME target

removed from the kernel December 2007.

Signed-off-by: Florian Westphal <fw@strlen.de>
10 years agoextensions: remove MIRROR
Florian Westphal [Thu, 19 Feb 2015 00:17:18 +0000 (01:17 +0100)] 
extensions: remove MIRROR

removed from the kernel back in 2003.

Signed-off-by: Florian Westphal <fw@strlen.de>
10 years agoxtables-compat: remove unused fields from bridge and arp families
Pablo Neira Ayuso [Mon, 16 Feb 2015 19:17:51 +0000 (20:17 +0100)] 
xtables-compat: remove unused fields from bridge and arp families

These two families only work under nft compat, so leave unset the fields
that we don't use. Basically, we need neither the module autoload code
nor the native get/setsockopt() revision infrastructure since we use the
one that nft_compat provides through nfnetlink.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoarptables-compat: add mangle target extension
Arturo Borrero [Fri, 13 Feb 2015 10:38:02 +0000 (11:38 +0100)] 
arptables-compat: add mangle target extension

This patch adds support to use the mangle target extensions, along with
the required changes in the surrounding code.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoxshared: calm down compilation warning
Pablo Neira Ayuso [Mon, 16 Feb 2015 15:57:39 +0000 (16:57 +0100)] 
xshared: calm down compilation warning

xshared.c: In function ‘xtables_lock’:
xshared.c:255:3: warning: implicit declaration of function ‘flock’ [-Wimplicit-function-declaration]

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agotests: add test case for xt_recent regression
Florian Westphal [Fri, 13 Feb 2015 13:07:21 +0000 (14:07 +0100)] 
tests: add test case for xt_recent regression

fails on 3.19 kernel:
xt_recent: hitcount (8) is larger than packets to be remembered (8) for table foo

Signed-off-by: Florian Westphal <fw@strlen.de>
10 years agotests: split into family and table specific files
Florian Westphal [Fri, 13 Feb 2015 13:00:27 +0000 (14:00 +0100)] 
tests: split into family and table specific files

also add simple script to restore/save them.
run_qa.sh passes on standard-distro kernels.

Signed-off-by: Florian Westphal <fw@strlen.de>
10 years agoMerge branch 'ebtables-compat'
Pablo Neira Ayuso [Wed, 11 Feb 2015 15:16:50 +0000 (16:16 +0100)] 
Merge branch 'ebtables-compat'

The ebtables-compat branch provides the compatibility layer to run
ebtables extensions. Currently, only the following matches / targets /
watchers are supported:

* 802_3
* ip
* mark_m and mark
* log

The remaining ones should be easy to port them to on top of libxtables,
they will follow up later.

10 years agoebtables-compat: add log watcher extension
Arturo Borrero [Mon, 9 Feb 2015 12:16:17 +0000 (13:16 +0100)] 
ebtables-compat: add log watcher extension

This patch adds the log 'watcher' extension.

The work was started by Giuseppe Longo <giuseppelng@gmail.com> and finised
by me.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoebtables-compat: add watchers support
Arturo Borrero [Mon, 9 Feb 2015 12:16:12 +0000 (13:16 +0100)] 
ebtables-compat: add watchers support

ebtables watchers are targets which always return EBT_CONTINUE.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoebtables-compat: add mark target extension
Arturo Borrero [Tue, 3 Feb 2015 15:29:35 +0000 (16:29 +0100)] 
ebtables-compat: add mark target extension

Translate the mark target extension to the xtables-compat environment.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoebtables-compat: finish target infrastructure
Arturo Borrero [Tue, 3 Feb 2015 16:58:17 +0000 (17:58 +0100)] 
ebtables-compat: finish target infrastructure

Signed-off-by: Arturo Borrero <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoebtables-compat: call extensions final checks
Arturo Borrero [Tue, 3 Feb 2015 15:26:39 +0000 (16:26 +0100)] 
ebtables-compat: call extensions final checks

Let's call extensions final checks.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agolibxtables: search first for AF-specific extension
Arturo Borrero [Thu, 29 Jan 2015 16:44:33 +0000 (17:44 +0100)] 
libxtables: search first for AF-specific extension

There are some extension which may name-clash, for example:
 * libxt_mark.so
 * liebt_mark.so

Let's search first for AF-specific extension and then for the generic libxt_**.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoextensions: cleanup commented code in ebtables-compat extensions
Arturo Borrero [Fri, 30 Jan 2015 11:47:16 +0000 (12:47 +0100)] 
extensions: cleanup commented code in ebtables-compat extensions

This code can be cleaned up. No need for validation from userspace,
the kernel will reject incorrect options.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoebtables-compat: add mark_m match extension
Arturo Borrero [Fri, 30 Jan 2015 11:43:08 +0000 (12:43 +0100)] 
ebtables-compat: add mark_m match extension

Translate mark_m match extension to the xtables-compat environment.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoebtables-compat: add 'ip' match extension
Arturo Borrero [Mon, 19 Jan 2015 13:28:07 +0000 (14:28 +0100)] 
ebtables-compat: add 'ip' match extension

This patch adds the 'ip' match extension to ebtables-compat.

It involves adapting old ebtables extension code to the xtables-compat
environment.

For testing:
% sudo ebtables-compat -p 0x0800 --ip-src 1.1.1.1 -j ACCEPT

The patch includes a cached copy of the extension kernel header.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoebtables-compat: fix nft payload bases
Arturo Borrero [Mon, 19 Jan 2015 13:28:02 +0000 (14:28 +0100)] 
ebtables-compat: fix nft payload bases

ebtables should use NFT_PAYLOAD_LL_HEADER to fetch basic payload information
from packets in the bridge family.

Let's allow the add_payload() function to know in which base it should work.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoebtables-compat: include rule counters in ebtables rules
Arturo Borrero [Mon, 19 Jan 2015 13:27:57 +0000 (14:27 +0100)] 
ebtables-compat: include rule counters in ebtables rules

Counters are missing in ebtables rules.

This patch includes them just before the target, so counters are incremented
when the rule is about to take his action.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoebtables-compat: prevent same matches to be included multiple times
Arturo Borrero [Mon, 19 Jan 2015 13:27:51 +0000 (14:27 +0100)] 
ebtables-compat: prevent same matches to be included multiple times

Using two matches options results in two copies of the match being included
in the nft rule.

Example before this patch:
 % ebtables-compat -A FORWARD -p 0x0800 --ip-src 10.0.0.1 --ip-dst 10.0.0.2 -j ACCEPT
 % ebtables-compat -L
 [...]
 -p 0x0800 --ip-src 10.0.0.1 --ip-dst 10.0.0.2 --ip-src 10.0.0.1 --ip-dst 10.0.0.2 -j ACCEPT

Example with this patch:
 % ebtables-compat -A FORWARD -p 0x0800 --ip-src 10.0.0.1 --ip-dst 10.0.0.2 -j ACCEPT
 % ebtables-compat -L
 [...]
 % -p 0x0800 --ip-src 10.0.0.1 --ip-dst 10.0.0.2 -j ACCEPT

[Note: the br_ip extension comes in a follow-up patch]

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoebtables-compat: prevent options overwrite
Arturo Borrero [Mon, 19 Jan 2015 13:27:46 +0000 (14:27 +0100)] 
ebtables-compat: prevent options overwrite

Parsing options will be overwritten if every time we load a match
the extension options are merged to the original options.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoebtables-compat: add nft rule compat information to bridge rules
Arturo Borrero [Mon, 19 Jan 2015 13:27:41 +0000 (14:27 +0100)] 
ebtables-compat: add nft rule compat information to bridge rules

The compat information is required by some ebtables extensions to properly
work.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoinclude: cache copy of Linux header uapi/linux/netfilter_bridge/ebt_802_3.h
Arturo Borrero [Mon, 19 Jan 2015 13:27:36 +0000 (14:27 +0100)] 
include: cache copy of Linux header uapi/linux/netfilter_bridge/ebt_802_3.h

Cache a copy of Linux header uapi/linux/netfilter_bridge/ebt_802_3.h
which contains the struct ebt_802_3_info definition.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoebtables-compat: fix ACCEPT printing by simplifying logic
Arturo Borrero [Tue, 13 Jan 2015 17:36:10 +0000 (18:36 +0100)] 
ebtables-compat: fix ACCEPT printing by simplifying logic

The commit bc543af ("ebtables-compat: fix segfault in rules w/o target")
doesn't handle all possible cases of target printing, and ACCEPT is left
behind.

BTW, the logic of target (-j XXX) printing is a bit weird. This patch
simplifies it.

I assume:
 * cs->jumpto is only filled by nft_immediate.
 * cs->target is only filled by nft_target.

So we end with these cases:
 * nft_immediate contains a 'standard' target (ACCEPT, DROP, CONTINUE, RETURN, chain)
  Then cs->jumpto contains the target already. We have the rule.
 * No standard target. If nft_target contains a target, try to load it.
 * Neither nft_target nor nft_immediate exist. Then, assume CONTINUE.

The printing path is then straight forward: either cs.jumpto or cs.target
contains the target.

As there isn't support for target extensions yet, there is no way to test the
nft_target (cs.target) path.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoiptables: use flock() instead of abstract unix sockets
Pablo Neira Ayuso [Fri, 16 Jan 2015 13:21:57 +0000 (14:21 +0100)] 
iptables: use flock() instead of abstract unix sockets

Abstract unix sockets cannot be used to synchronize several concurrent
instances of iptables since an unpriviledged process can create them and
prevent the legitimate iptables instance from running.

Use flock() and /run instead as suggested by Lennart Poettering.

Fixes: 93587a0 ("ip[6]tables: Add locking to prevent concurrent instances")
Reported-by: Lennart Poettering <lennart@poettering.net>
Cc: Phil Oester <kernel@linuxace.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoebtables-compat: include /etc/ethertypes in tarball
Arturo Borrero [Wed, 7 Jan 2015 16:22:01 +0000 (17:22 +0100)] 
ebtables-compat: include /etc/ethertypes in tarball

The /etc/ethertypes file was originally distributed by the ebtables tarball.
So, let's include the file also in ebtables-compat, so users can keep using
protocol names instead of the hex code.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoebtables-compat: fix segfault in rules w/o target
Arturo Borrero [Mon, 5 Jan 2015 14:28:46 +0000 (15:28 +0100)] 
ebtables-compat: fix segfault in rules w/o target

This patch fixes a segfault in rules without target.

Now, these two rules are allowed:

% ebtables-compat -A FORWARD -p 0x0600 -j CONTINUE
% ebtables-compat -A FORWARD -p 0x0600

And both are printed:

Bridge chain: FORWARD, entries: 1, policy: ACCEPT
-p 0x600 -j CONTINUE

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoman: string: document icase
Florian Westphal [Mon, 5 Jan 2015 13:54:34 +0000 (14:54 +0100)] 
man: string: document icase

Signed-off-by: Florian Westphal <fw@strlen.de>
10 years agoebtables-compat: fix printing of extension
Arturo Borrero [Fri, 26 Dec 2014 12:49:52 +0000 (13:49 +0100)] 
ebtables-compat: fix printing of extension

This patch fix printing of ebt extensions:

% sudo ebtables-compat -L
[...]
Bridge chain: FORWARD, entries: 1, policy: ACCEPT
--802_3-type 0x0012 -j ACCEPT
[...]

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoebtables-compat: fix counter listing
Arturo Borrero [Tue, 23 Dec 2014 12:24:26 +0000 (13:24 +0100)] 
ebtables-compat: fix counter listing

With this patch:

% sudo ebtables-compat -L --Lc
Bridge table: filter

Bridge chain: INPUT, entries: 0, policy: ACCEPT
-j ACCEPT , pcnt = 123 -- bcnt = 123

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoextensions: add ebt 802_3 extension
Arturo Borrero [Wed, 17 Dec 2014 11:06:56 +0000 (12:06 +0100)] 
extensions: add ebt 802_3 extension

This patch adds the first ebtables extension to ebtables-compat.
The original 802_3 code is adapted to the xtables environment.

I tried to mimic as much as possible the original ebtables code paths.

With this patch, ebtables-compat is able to send the 802_3 match to the kernel,
but the kernel-to-userspace path is not tested and should be adjusted
in follow-up patches.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoiptables: xtables-eb: fix renaming of chains
Arturo Borrero [Mon, 24 Nov 2014 18:43:05 +0000 (19:43 +0100)] 
iptables: xtables-eb: fix renaming of chains

Renaming of chains is not working. and ebtables-compat gets:
 libnftnl: attribute 0 assertion failed in chain.c:159

This patch brings back the parser code of the original ebtables tool:
 http://git.netfilter.org/ebtables.old-history/tree/userspace/ebtables2/ebtables.c#n652

I adapted the original parser code to fit in the new environment. Also tried to
keep original error messages as much as possible.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoiptables: xtables-eb: user-defined chains default policy is always RETURN
Arturo Borrero [Mon, 24 Nov 2014 09:52:04 +0000 (10:52 +0100)] 
iptables: xtables-eb: user-defined chains default policy is always RETURN

The RETURN default policy is mandatory in user-defined chains.
Builtin chains must have one of ACCEPT or DROP.

So, with this patch, ebtables-compat ends with:

Command:                             Result:

-L                                   Always RETURN for user-defined chains
-P builtin RETURN                    Policy RETURN only allowed for user defined chains
-P builtin ACCEPT|DROP               ok
-P userdefined RETURN|ACCEPT|DROP    Policy XYZ not allowed for user defined chains
-N userdefined                       ok
-N userdefined -P RETURN|ACCEPT|DROP Policy XYZ not allowed for user defined chains

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoebtables-compat: build ebtables extensions
Giuseppe Longo [Mon, 10 Nov 2014 19:03:08 +0000 (20:03 +0100)] 
ebtables-compat: build ebtables extensions

This permits to build extensions for ebtables-compat layer.

Signed-off-by: Giuseppe Longo <giuseppelng@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoiptables: xtables-eb: delete extra 'policy' printf
Arturo Borrero [Mon, 17 Nov 2014 11:09:33 +0000 (12:09 +0100)] 
iptables: xtables-eb: delete extra 'policy' printf

This message doesn't exist in the original ebtables tool.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agonft-bridge: fix inversion of builtin matches
Arturo Borrero [Wed, 12 Nov 2014 16:10:25 +0000 (17:10 +0100)] 
nft-bridge: fix inversion of builtin matches

This patch fixes inversion of builtin matches by updating the use of add_*()
functions and using nft_invflags2cmp() as well.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agonft-bridge: fix printing of inverted protocols, addresses
Arturo Borrero [Sat, 8 Nov 2014 21:40:37 +0000 (22:40 +0100)] 
nft-bridge: fix printing of inverted protocols, addresses

Previous to this patch, no '!' is printed in payload comparisions.
This patch solves it, so we can print for example inverted protocols:

 % ebtables-compat -L
[...]
-p ! 0x800 -j ACCEPT

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoebtables-compat: fix print_header
Giuseppe Longo [Thu, 16 Oct 2014 14:29:51 +0000 (16:29 +0200)] 
ebtables-compat: fix print_header

This prints the header like ebtables.

Signed-off-by: Giuseppe Longo <giuseppelng@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoebtables-compat: use ebtables_command_state in bootstrap code
Pablo Neira Ayuso [Thu, 9 Oct 2014 18:11:16 +0000 (20:11 +0200)] 
ebtables-compat: use ebtables_command_state in bootstrap code

And introduce fake ebt_entry.

This gets the code in sync in other existing compat tools. This
will likely allow to consolidate common infrastructure.

This code is still quite experimental.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agonft: bootstrap ebtables-compat
Pablo Neira Ayuso [Thu, 9 Oct 2014 13:02:02 +0000 (15:02 +0200)] 
nft: bootstrap ebtables-compat

This patch bootstraps ebtables-compat, the ebtables compatibility
software upon nf_tables.

[ Original patches:

  http://patchwork.ozlabs.org/patch/395544/
  http://patchwork.ozlabs.org/patch/395545/
  http://patchwork.ozlabs.org/patch/395546/

I have also forward port them on top of the current git HEAD, otherwise
compilation breaks.

This bootstrap is experimental, this still needs more work. --Pablo ]

Signed-off-by: Giuseppe Longo <giuseppelng@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agonft-compat: create a separated object update type to rename chains
Arturo Borrero [Mon, 24 Nov 2014 10:12:15 +0000 (11:12 +0100)] 
nft-compat: create a separated object update type to rename chains

This patch adds an explicit object update type to rename chains, so we avoid
calling the nf_tables API with NLM_F_EXCL.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoiptables-compat: kill add_*() invflags parameter
Arturo Borrero [Wed, 12 Nov 2014 12:00:12 +0000 (13:00 +0100)] 
iptables-compat: kill add_*() invflags parameter

Let's kill the invflags parameter and use directly NFT_CMP_[N]EQ.
The caller must calculate which kind of cmp operation requires.

BTW, this patch solves absence of inversion in some arptables-compat
builtin matches. Thus, translating arptables inv flags is no longer needed.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoextensions: libxt_TEE: Trim kernel struct to allow deletion
Loganaden Velvindron [Sun, 9 Nov 2014 14:15:05 +0000 (06:15 -0800)] 
extensions: libxt_TEE: Trim kernel struct to allow deletion

Correct trimming of userspacesize to fix deletions.

Fixes: Bugzilla #884.
The rule having TEE target with '--oif' option cannot be deleted by iptables command.

  $ iptables -I INPUT -i foo -j TEE --gateway x.x.x.x --oif bar
  $ iptables -D INPUT -i foo -j TEE --gateway x.x.x.x --oif bar
  iptables: No chain/target/match by that name.

Signed-off-by: Loganaden Velvindron <logan@elandsys.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoiptables-compat: homogenize error messages with 'R' option
Ana Rey [Wed, 5 Nov 2014 15:46:34 +0000 (16:46 +0100)] 
iptables-compat: homogenize error messages with 'R' option

There is a difference between error messages in iptables and
iptables-compat:

 # iptables -R INPUT 23 -s 192.168.2.140 -j ACCEPT
iptables: Index of replacement too big.
 # iptables-compat -R INPUT 23 -s 192.168.2.140 -j ACCEPT
iptables: No chain/target/match by that name.

Now, iptables-compat shows the same error message than iptables in
this case.

Signed-off-by: Ana Rey <anarey@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoMerge branch 'ipset'
Pablo Neira Ayuso [Tue, 4 Nov 2014 23:57:12 +0000 (00:57 +0100)] 
Merge branch 'ipset'

This provides the ipset skbinfo extension.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoextensions: devgroup: fix showing and saving of dst-group
Ana Rey [Thu, 30 Oct 2014 16:26:26 +0000 (17:26 +0100)] 
extensions: devgroup: fix showing and saving of dst-group

Closes bugzilla: https://bugzilla.netfilter.org/show_bug.cgi?id=985

The --dst-group parameter in devgroup extensions lists and saves
incorrectly its value. --dst-group always shows "0x0/0x0".

This is an example:

 # iptables -I FORWARD -m devgroup --dst-group 200 -j ACCEPT

 # iptables -L FORWARD
 Chain FORWARD (policy ACCEPT)
 target     prot opt source               destination
 ACCEPT     all  --  anywhere             anywhere     src-group 0x64 dst-group 0x0/0x0

 # iptables -S FORWARD
 -P FORWARD ACCEPT
 -A FORWARD -m devgroup --dst-group 0x0/0x0 -j ACCEPT

Reporte-by: Axinchan <axinchan@cnrouter.com>
Signed-off-by: Ana Rey <anarey@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoiptables-compat: homogenize error messages
Ana Rey [Thu, 30 Oct 2014 08:31:56 +0000 (09:31 +0100)] 
iptables-compat: homogenize error messages

There are some differences between error messages in iptables and
iptables-compat:

 # iptables -C INPUT -s 192.168.2.102 -j ACCEPT
iptables: Bad rule (does a matching rule exist in that chain?).
 # iptables-compat -C INPUT -s 192.168.2.102 -j ACCEPT
iptables: No chain/target/match by that name.

 # iptables -N new_chain
 # iptables -N new_chain
iptables: Chain already exists.
 # iptables-compat -N new_chain
 # iptables-compat -N new_chain
iptables: File exists.

Now, iptables-compat shows the same error messages than iptables in
those cases.

Signed-off-by: Ana Rey <anarey@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agolibxtables: move some code to avoid cautions in vfork man page
Dan Wilder [Fri, 24 Oct 2014 22:51:59 +0000 (00:51 +0200)] 
libxtables: move some code to avoid cautions in vfork man page

Running iptables-restore on an embedded platform containing no modprobe program, the following lines in xtables.c lead to corrupted stack frame:

 357     switch (vfork()) {
 358     case 0:
 359         argv[0] = (char *)modprobe;
 360         argv[1] = (char *)modname;
 361         if (quiet) {
 362             argv[2] = "-q";
 363             argv[3] = NULL;
 364         } else {
 365             argv[2] = NULL;
 366             argv[3] = NULL;
 367         }
 368         execv(argv[0], argv);
 369
 370         /* not usually reached */
 371         exit(1);

modprobe pointed to a non-existant program /sbin/modprobe, so execv()
always failed.  Not a problem in itself on our platform, as the kernel
modules are pre-loaded before iptables-restore is run, but it took a
bit of headscratching to track this down, as a stack frame was
corrupted, leading to failures quite a while after the function
containing this code had returned!

Relevant caution in man 2 vfork:

    "The vfork() function has the same effect as fork(2), except that
    the behavior is undefined if the process created by vfork() either
    modifies any data ... or calls any other function before
    successfully calling _exit(2) or one of the exec(3) family of
    functions."

Apparently this has not been a problem for us in earlier versions of
glibc, maybe because vfork was more like fork, maybe because the
stack corruption was innocuous.  Ours is a corner case anyway, as
it might not have been a problem had modprobe existed or had
modprobe been a symlink to /bin/true.  But it seems odd to disregard
man page cautions, and our problem goes away if they are heeded.

Signed-off-by: Florian Westphal <fw@strlen.de>
10 years agoiptables-compat: fix empty chains after first invocation of iptables-compat -L
Pablo Neira Ayuso [Thu, 23 Oct 2014 11:30:36 +0000 (13:30 +0200)] 
iptables-compat: fix empty chains after first invocation of iptables-compat -L

 # iptables-compat -L
 # iptables-compat -L
 Chain INPUT (policy ACCEPT)
 target     prot opt source               destination

 Chain FORWARD (policy ACCEPT)
 target     prot opt source               destination

 Chain OUTPUT (policy ACCEPT)
 target     prot opt source               destination

Note that the second (and follow up) invocations after the first one
display the chains.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoiptables-compat: assume chain policy NF_ACCEPT when creating built-in chains
Pablo Neira Ayuso [Thu, 23 Oct 2014 11:21:27 +0000 (13:21 +0200)] 
iptables-compat: assume chain policy NF_ACCEPT when creating built-in chains

Newly created (emulated) xt built-in chain have to use NF_ACCEPT. Remove
extra unused chain parameter and rename nft_chain_builtin_init to
nft_xt_builtin_init too.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoiptables-compat: statify unused built-in table/chain functions
Pablo Neira Ayuso [Thu, 23 Oct 2014 10:53:59 +0000 (12:53 +0200)] 
iptables-compat: statify unused built-in table/chain functions

The functions that allows you to create built-in table and chains are
required out of the scope of nft.c

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoiptables-compat: fix chain policy reset with iptables -L -n
Pablo Neira Ayuso [Thu, 23 Oct 2014 10:42:11 +0000 (12:42 +0200)] 
iptables-compat: fix chain policy reset with iptables -L -n

Initialize built-in tables/chains if they don't exists, otherwise
simply skip.

This avoids the chain policy reset to NF_ACCEPT by when you call
iptables -L -n.

Reported-by: Ana Rey <anarey@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Tested-by: Ana Rey <anarey@gmail.com>
10 years agonft-ipv46: replace offset var with ctx->payload.offset
Giuseppe Longo [Thu, 16 Oct 2014 14:29:53 +0000 (16:29 +0200)] 
nft-ipv46: replace offset var with ctx->payload.offset

The offset variable (undefined) is passed to DEBUGP function,
so you get a compilation error if you try to build iptables
with debug enabled

Signed-off-by: Giuseppe Longo <giuseppelng@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agonft: fix syntax error in nft_parse_cmp()
Giuseppe Longo [Thu, 16 Oct 2014 14:29:52 +0000 (16:29 +0200)] 
nft: fix syntax error in nft_parse_cmp()

This fixes a syntax error, remove ; in an if statement

Signed-off-by: Giuseppe Longo <giuseppelng@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agorefresh nf_tables.h cached copy
Pablo Neira Ayuso [Wed, 1 Oct 2014 19:10:47 +0000 (21:10 +0200)] 
refresh nf_tables.h cached copy

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoarptables-compat: remove save code
Pablo Neira Ayuso [Thu, 9 Oct 2014 11:07:05 +0000 (13:07 +0200)] 
arptables-compat: remove save code

There is not native arptables-save. The original author provides
perl scripts to implement arptables-save and arptables-restore.
We should use them to mimic arptables behaviour.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoarptables-compat: get output in sync with arptables -L -n --line-numbers
Pablo Neira Ayuso [Thu, 9 Oct 2014 10:45:42 +0000 (12:45 +0200)] 
arptables-compat: get output in sync with arptables -L -n --line-numbers

 # arptables-compat -L -n --line-numbers
 Chain INPUT (policy ACCEPT)
 num  target     prot opt source               destination <--

This header is not shown by arptables.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoarptables-compat: allow to not specify a target
Pablo Neira Ayuso [Wed, 8 Oct 2014 20:17:51 +0000 (22:17 +0200)] 
arptables-compat: allow to not specify a target

arptables allows this:

 # arptables -I INPUT

however, arptables-compat says:

 arptables v1.4.21: No target provided or initalization failed
 Try `arptables -h' or 'arptables --help' for more information.

the compat utility must mimic the same behaviour.

Fix this by introducing the arptables_command_state abstraction that
is already available in ip{6}tables.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoarptables-compat: fix missing error reporting
Pablo Neira Ayuso [Wed, 8 Oct 2014 20:17:50 +0000 (22:17 +0200)] 
arptables-compat: fix missing error reporting

# arptables-compat -D INPUT -j ACCEPT
 arptables: Bad rule (does a matching rule exist in that chain?)

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoiptables-compat: nft: fix error reporting
Pablo Neira Ayuso [Wed, 8 Oct 2014 20:17:49 +0000 (22:17 +0200)] 
iptables-compat: nft: fix error reporting

This fixes

 # iptables-compat -X test4345
 iptables: No chain/target/match by that name.

 # iptables-compat -N test4345
 # iptables-compat -N test4345
 iptables: File exists.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoiptables-compat: nft: fix user chain addition, deletion and rename
Pablo Neira Ayuso [Wed, 8 Oct 2014 20:17:48 +0000 (22:17 +0200)] 
iptables-compat: nft: fix user chain addition, deletion and rename

Add the glue code to use the chain batching for user chain commands.

Reported-by: Giuseppe Longo <giuseppelng@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoMerge branch 'tests'
Pablo Neira Ayuso [Wed, 1 Oct 2014 08:44:49 +0000 (10:44 +0200)] 
Merge branch 'tests'

This merges the iptables-test.py script and the corresponding
test files.

10 years agoiptables-compat: get rid of error reporting via perror
Pablo Neira Ayuso [Tue, 30 Sep 2014 17:40:18 +0000 (19:40 +0200)] 
iptables-compat: get rid of error reporting via perror

The compat layer should report problems in the iptables way instead.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoiptables-compat: fix use after free in the batch send path
Pablo Neira Ayuso [Tue, 30 Sep 2014 16:12:34 +0000 (18:12 +0200)] 
iptables-compat: fix use after free in the batch send path

Release the batch pages once they have been sent via sendmsg().

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoiptables-compat: nft: use nft_batch_begin and nft_batch_end from libnftnl
Pablo Neira Ayuso [Tue, 30 Sep 2014 15:52:15 +0000 (17:52 +0200)] 
iptables-compat: nft: use nft_batch_begin and nft_batch_end from libnftnl

Use the existing functions in libnftnl to begin and end a batch.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoiptables-compat: fix address prefix
Pablo Neira Ayuso [Tue, 30 Sep 2014 11:07:18 +0000 (13:07 +0200)] 
iptables-compat: fix address prefix

This patch fixes:

 # iptables-compat -I INPUT -s 1.2.3.0/24

generates this bytecode:

ip filter INPUT 20
  [ payload load 4b @ network header + 12 => reg 1 ]
  [ bitwise reg 1 = (reg=1 & 0x00ffffff ) ^ 0x00000000 ]
  [ cmp eq reg 1 0x00030201 ]
  [ counter pkts 0 bytes 0 ]

and it displays:

 # iptables-compat-save
...
-A INPUT -s 1.2.3.0/24

ip6tables-compat and arptables-compat are also fixed.

This patch uses the new context structure to annotate payload, meta
and bitwise, so it interprets the cmp expression based on the context.
This provides a rudimentary way to delinearize the iptables-compat
rule-set, but it should be enough for the built-in xtables selectors
since we still use the xtables extensions.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoextensions: libxt_devgroup: Fix the path of the group mappings file
Ana Rey [Thu, 18 Sep 2014 11:06:42 +0000 (13:06 +0200)] 
extensions: libxt_devgroup: Fix the path of the group mappings file

Use "/etc/iproute2/group" as the default path to the mapping file
instead of "/etc/iproute2/group_map".

Signed-off-by: Ana Rey <anarey@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoxtables: SET target: Add mapping of meta informations (skbinfo ipset extension)
Anton Danilov [Tue, 2 Sep 2014 10:15:53 +0000 (14:15 +0400)] 
xtables: SET target: Add mapping of meta informations (skbinfo ipset extension)

This feature add support of mapping metainformation to packets like nftables maps or
ipfw tables. Currently we can map firewall mark, tc priority and hardware NIC queue.
Usage of this functionality allowed only from mangle table. We can map tc priority
only in OUTPUT/FORWARD/POSTROUTING chains because it rewrite by route decision.
If entry doesn't exist in the set nothing of fields changed.

Example of classify by destination address:
iptables -t mangle -A POSTROUTING -o eth0 -j SET --map-set DST2CLASS dst --map-prio

Signed-off-by: Anton Danilov <littlesmilingcloud@gmail.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agoextensions: libxt_connlabel: do not open config file from _init hook
Florian Westphal [Fri, 5 Sep 2014 18:45:56 +0000 (20:45 +0200)] 
extensions: libxt_connlabel: do not open config file from _init hook

else, static builds will print this for every iptables invocation,
even 'iptables -L'.  Delay open until we need to translate a mapping.

Reported-by: Thomas De Schampheleire <patrickdepinguin@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
10 years agolibxtables: fix two off-by-one memory corruption bugs
Ronald Wahl [Thu, 4 Sep 2014 22:54:48 +0000 (00:54 +0200)] 
libxtables: fix two off-by-one memory corruption bugs

The LSB of xtables_pending_matches was overwritten with zero
that lead to segmentation fault. But simply adding an additional variable
in the code or changing compilation options modified the behaviour so that no
segmentation fault happens so it is rather subtle.

(1) memset(p + (bits / 8) + 1, 0, (128 - bits) / 8);
In case of bits % 8 == 0 we write the byte behind *p

(2) p[bits/8] = 0xff << (8 - (bits & 7));
In case of bits == 128 we write the byte behind *p

Closes bug 943.

Signed-off-by: Florian Westphal <fw@strlen.de>
10 years agonft: add nft_xt_ctx struct
Giuseppe Longo [Fri, 22 Aug 2014 09:16:29 +0000 (11:16 +0200)] 
nft: add nft_xt_ctx struct

This patch provides the context used to transfer
information between different nft_parse_* function calls.

Signed-off-by: Giuseppe Longo <giuseppelng@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agonft: compare layer 4 protocol in first place
Giuseppe Longo [Fri, 22 Aug 2014 09:16:31 +0000 (11:16 +0200)] 
nft: compare layer 4 protocol in first place

Currently the protocol is tested after the ip address,
this fixes the order testing the protocol before the ip address.

Now the code generated is incorrect:

ip filter INPUT 16
  [ payload load 4b @ network header + 12 => reg 1 ]
  [ cmp eq reg 1 0x0100a8c0 ]
  [ payload load 1b @ network header + 9 => reg 1 ]
  [ cmp eq reg 1 0x00000006 ]
  [ match name tcp rev 0 ]
  [ match name conntrack rev 3 ]
  [ counter pkts 0 bytes 0 ]
  [ immediate reg 0 accept ]

With this patch, the code generated is:
ip filter INPUT 16
  [ payload load 1b @ network header + 9 => reg 1 ]
  [ cmp eq reg 1 0x00000006 ]
  [ payload load 4b @ network header + 12 => reg 1 ]
  [ cmp eq reg 1 0x0100a8c0 ]
  [ bitwise reg 1 = (reg=1 & 0xffffffff ) ^ 0x00000000 ]
  [ match name tcp rev 0 ]
  [ match name conntrack rev 3 ]
  [ counter pkts 0 bytes 0 ]
  [ immediate reg 0 accept ]

Signed-off-by: Giuseppe Longo <giuseppelng@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agonft-arp: remove wrong conditions
Giuseppe Longo [Fri, 8 Aug 2014 23:04:17 +0000 (01:04 +0200)] 
nft-arp: remove wrong conditions

Removes wrong conditions in flags translating functions
that doesn't permit to delete rule with inverse flags set.

For instance, the following command doesn't remove the rule:
arptables-compat -D INPUT -i ! eth1 -j ACCEPT

Signed-off-by: Giuseppe Longo <giuseppelng@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoinclude: add linux/filter.h
Willem de Bruijn [Tue, 29 Jul 2014 22:19:02 +0000 (18:19 -0400)] 
include: add linux/filter.h

xt_bpf.h includes linux/filter.h for the definition of sock_filter.
add that file to the repository

Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoiptables: add optional [seconds] argument to -w
Jiri Popelka [Fri, 4 Jul 2014 13:50:41 +0000 (15:50 +0200)] 
iptables: add optional [seconds] argument to -w

This patch adds an optional numeric argument
to -w option (added with 93587a0) so one can
specify how long to wait for an exclusive lock.

If the value isn't specified it works as before,
i.e. program waits indefinitely.

If user specifies it, program exits after
the given time interval passes.

This patch also adds the -w/--wait to nftables
compat code, so the parser doesn't complain.

[ In the original patch, iptables-compat -w X was not working,
  I have fixed by adding the dummy code not to break scripts
  using the new optional argument --pablo ]

Signed-off-by: Jiri Popelka <jpopelka@redhat.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoMakefile: fix static compilation iptables-compat without shared libraries
Pablo Neira Ayuso [Fri, 13 Jun 2014 09:40:41 +0000 (11:40 +0200)] 
Makefile: fix static compilation iptables-compat without shared libraries

Fix linking problems when this configuration is used:

 $ ./configure --prefix=/usr --enable-shared=no --enable-static=yes
 $ make
 ...
xtables_compat_multi-xtables-save.o: In function `xtables_save_main':
/home/pablo/devel/iptables/iptables/xtables-save.c:98: undefined reference to `init_extensions4'
xtables_compat_multi-xtables-restore.o: In function `xtables_restore_main':
/home/pablo/devel/iptables/iptables/xtables-restore.c:195: undefined reference to `init_extensions4'
xtables_compat_multi-xtables-standalone.o: In function `xtables_main':
/home/pablo/devel/iptables/iptables/xtables-standalone.c:61: undefined reference to `init_extensions4'
xtables_compat_multi-xtables-events.o: In function `xtables_events_main':
/home/pablo/devel/iptables/iptables/xtables-events.c:184: undefined reference to `init_extensions4'

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agolibxtables: fix getaddrinfo return value usage
Domen Puncer [Tue, 10 Jun 2014 13:29:49 +0000 (14:29 +0100)] 
libxtables: fix getaddrinfo return value usage

getaddrinfo return value on error can also be positive.

On Android they're positive, e.g.:

 android-ndk-r9d/platforms/android-19/arch-arm/usr/include/netdb.h
 147 #define EAI_NONAME       8      /* hostname nor servname provided, or not known */

And as a plus, it's not bad to conform to specs.

Signed-off-by: Domen Puncer Kugler <domen.puncer@samsung.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agonft: save: fix the printing of the counters
Giuseppe Longo [Wed, 11 Jun 2014 08:53:12 +0000 (10:53 +0200)] 
nft: save: fix the printing of the counters

This patch prints the counters of a rule before the details,
like iptables-save syntax.

Signed-off-by: Giuseppe Longo <giuseppelng@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoiptables: nft: add tables and chains to the batch
Pablo Neira Ayuso [Mon, 9 Jun 2014 16:55:29 +0000 (18:55 +0200)] 
iptables: nft: add tables and chains to the batch

Since kernel changes:

55dd6f9 ("netfilter: nf_tables: use new transaction infrastructure
to handle table").
91c7b38 ("netfilter: nf_tables: use new transaction infrastructure
to handle chain").

it is possible to put tables and chains in the same batch (which was
already including rules). This patch probes the kernel to check if
if the new transaction is available, otherwise it falls back to the
previous non-transactional approach to handle these two objects.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoiptables: nft: remove unused code
Pablo Neira Ayuso [Mon, 9 Jun 2014 16:23:05 +0000 (18:23 +0200)] 
iptables: nft: remove unused code

Remove code to set table in dormant state, this is not required from
the iptables over nft compatibility layer.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoiptables: nft: generalize batch infrastructure
Pablo Neira Ayuso [Mon, 9 Jun 2014 16:18:26 +0000 (18:18 +0200)] 
iptables: nft: generalize batch infrastructure

Prepare inclusion of tables and chain objects in the batch.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoMerge branch 'next-3.14'
Pablo Neira Ayuso [Fri, 16 May 2014 12:11:05 +0000 (14:11 +0200)] 
Merge branch 'next-3.14'

11 years agoiptables.8: --policy is either ACCEPT or DROP
Florian Westphal [Thu, 17 Apr 2014 11:03:00 +0000 (13:03 +0200)] 
iptables.8: --policy is either ACCEPT or DROP

its enforced by both by libiptc and kernel.

Signed-off-by: Florian Westphal <fw@strlen.de>
11 years agonft: replace nft_rule_attr_get_u8
Giuseppe Longo [Mon, 24 Mar 2014 10:59:46 +0000 (11:59 +0100)] 
nft: replace nft_rule_attr_get_u8

Since the family declaration has been modified in libnftnl,
from commit 3cd9cd06625f8181c713489cec2c1ce6722a7e16
the assertion is failed for {ip,ip6,arp}tables-compat
when printing rules.

iptables-compat -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
libnftnl: attribute 0 assertion failed in rule.c:273

ip6tables-compat -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
libnftnl: attribute 0 assertion failed in rule.c:273

arptables-compat -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
libnftnl: attribute 0 assertion failed in rule.c:273

Signed-off-by: Giuseppe Longo <giuseppelng@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoiptables-save: actually parse -M/--modprobe option
Jiri Popelka [Fri, 14 Mar 2014 11:52:48 +0000 (12:52 +0100)] 
iptables-save: actually parse -M/--modprobe option

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoiptables-{save,restore}: warn that -b/--binary isn't implemented
Jiri Popelka [Fri, 14 Mar 2014 11:52:47 +0000 (12:52 +0100)] 
iptables-{save,restore}: warn that -b/--binary isn't implemented

see also 296dca39be

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoiptables-restore.8: file to read from can be specified as argument
Jiri Popelka [Thu, 13 Mar 2014 16:01:20 +0000 (17:01 +0100)] 
iptables-restore.8: file to read from can be specified as argument

original bug report:
https://bugzilla.redhat.com/show_bug.cgi?id=1022228

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>