]> git.ipfire.org Git - thirdparty/nftables.git/log
thirdparty/nftables.git
9 years agonft: support listing expressions that use non-byte header fields
Florian Westphal [Fri, 7 Aug 2015 10:09:08 +0000 (12:09 +0200)] 
nft: support listing expressions that use non-byte header fields

This allows to list rules that check fields that are not aligned on byte
boundary.

Signed-off-by: Florian Westphal <fw@strlen.de>
9 years agotests: add tests for ip version/hdrlength/tcp doff
Florian Westphal [Wed, 12 Aug 2015 01:23:40 +0000 (03:23 +0200)] 
tests: add tests for ip version/hdrlength/tcp doff

Header fields of 4 bit lengths.  Requires implicit masks and
shifting of RHS constant.

Signed-off-by: Florian Westphal <fw@strlen.de>
9 years agonetlink: cmp: shift rhs constant if lhs offset doesn't start on byte boundary
Florian Westphal [Tue, 4 Aug 2015 12:11:03 +0000 (14:11 +0200)] 
netlink: cmp: shift rhs constant if lhs offset doesn't start on byte boundary

if we have payload(someoffset) == 42, then shift 42 in case someoffset
doesn't start on a byte boundary.

We already insert a mask instruction to only load those bits into
the register that we were interested in, but the cmp will fail without
also adjusting rhs accordingly.

Needs additional patch in reverse direction to undo the shift again
when dumping ruleset.

Signed-off-by: Florian Westphal <fw@strlen.de>
9 years agonft: fill in doff and fix ihl/version template entries
Florian Westphal [Sun, 26 Jan 2014 13:52:47 +0000 (14:52 +0100)] 
nft: fill in doff and fix ihl/version template entries

This allows to use

nft add rule ip filter input tcp doff 8

or similar.

Furhermore, ip version looked at hdrlen and vice versa.

Signed-off-by: Florian Westphal <fw@strlen.de>
9 years agosrc: netlink: don't truncate set key lengths
Florian Westphal [Fri, 14 Aug 2015 01:16:32 +0000 (03:16 +0200)] 
src: netlink: don't truncate set key lengths

If key is e.g. 12 bits, pretend its 16 instead of 8.  This is needed
to make sets work with header fields with size not divisible by 8.

Signed-off-by: Florian Westphal <fw@strlen.de>
9 years agosrc: netlink_linearize: handle sub-byte lengths
Florian Westphal [Tue, 17 Sep 2013 12:29:29 +0000 (14:29 +0200)] 
src: netlink_linearize: handle sub-byte lengths

Currently length is expr->len / BITS_PER_BYTE, i.e. expr->len
has to be a multiple of 8.

When core asks for e.g. '9 bits', we truncate this to 8.
Round up to 16 and inject a 9-bit mask to zero out the parts we're not
interested in.

This will also need change to the delinarization step to
remove the extra op when dumping rules from kernel.

Signed-off-by: Florian Westphal <fw@strlen.de>
9 years agopayload: disable payload merge if offsets are not on byte boundary.
Florian Westphal [Tue, 4 Aug 2015 10:29:50 +0000 (12:29 +0200)] 
payload: disable payload merge if offsets are not on byte boundary.

... because it doesn't work, we attempt to merge it into wrong
place, we would have to merge the second value at a specific location.

F.e. vlan hdr 4094 gives us

0xfe0f

Merging in the CFI should yield 0xfe1f, but the constant merging
doesn't know how to achive that; at the moment 'vlan id 4094'
and 'vlan id 4094 vlan cfi 1' give same result -- 0xfe0f.

For now just turn off the optimization step unless everything is
byte divisible (the common case).

Signed-off-by: Florian Westphal <fw@strlen.de>
9 years agonft: allow stacking vlan header on top of ethernet
Florian Westphal [Sun, 5 Jul 2015 18:27:28 +0000 (20:27 +0200)] 
nft: allow stacking vlan header on top of ethernet

currently 'vlan id 42' or even 'vlan type ip' doesn't work since
we expect ethernet header but get vlan.

So if we want to add another protocol header to the same base, we
attempt to figure out if the new header can fit on top of the existing
one (i.e. proto_find_num gives a protocol number when asking to find
link between the two).

We also annotate protocol description for eth and vlan with the full
header size and track the offset from the current base.

Otherwise, 'vlan type ip' fetches the protocol field from mac header
offset 0, which is some mac address.

Instead, we must consider full size of ethernet header.

Signed-off-by: Florian Westphal <fw@strlen.de>
9 years agotests: don't depend on set element order
Florian Westphal [Thu, 17 Sep 2015 21:23:25 +0000 (23:23 +0200)] 
tests: don't depend on set element order

Pablo reported test failures because the order of returned set entries
is not deterministic.

This sorts set elements before comparision.
Patrick suggested to move ordering into libnftnl (since we could f.e.
also get duplicate entries due to how netlink dumps work), but thats a bit
more work.  Hence this quick workaround.

Reported-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Florian Westphal <fw@strlen.de>
9 years agoBump version to v0.5 v0.5
Pablo Neira Ayuso [Wed, 16 Sep 2015 14:44:40 +0000 (16:44 +0200)] 
Bump version to v0.5

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 years agosrc: use new symbols in libnftnl
Pablo Neira Ayuso [Tue, 15 Sep 2015 11:20:34 +0000 (13:20 +0200)] 
src: use new symbols in libnftnl

Adapt the nftables code to use the new symbols in libnftnl. This patch contains
quite some renaming to reserve the nft_ prefix for our high level library.

Explicitly request libnftnl 1.0.5 at configure stage.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 years agotests: add concatenations and maps; combine them too
Pablo Neira Ayuso [Thu, 3 Sep 2015 16:23:18 +0000 (18:23 +0200)] 
tests: add concatenations and maps; combine them too

This patch adds simple tests for concatenation and maps, including more
advanced tests that combine them.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 years agoevaluate: use existing table object from evaluation context
Pablo Neira Ayuso [Wed, 9 Sep 2015 23:30:06 +0000 (01:30 +0200)] 
evaluate: use existing table object from evaluation context

Skip table object lookup if we are in the context of table declaration already,
ctx->table already points to the right table we have to use during the
evalution. Otherwise, a list corruption occurs when using the wrong table
object when it already exists in the kernel.

http://marc.info/?l=netfilter-devel&m=144179814209295&w=2

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>
9 years agomnl: rework netlink socket receive path for events
Pablo Neira Ayuso [Fri, 4 Sep 2015 16:29:00 +0000 (18:29 +0200)] 
mnl: rework netlink socket receive path for events

This patch reworks two aspects of the netlink socket event receive path:

1) In case of ENOBUFS, stay in the loop to keep receiving messages. The tool
   displays a message so the user knows that we got lost event messages.

2) Rise the default size of the receive socket buffer up to 16 MBytes to reduce
   chances of hitting ENOBUFS. Asumming that the netlink event message size is
   ~150 bytes, we can bear with ~111848 rules without message loss.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 years agonetlink: flush stdout after each event in monitor mode
Pablo Neira Ayuso [Fri, 4 Sep 2015 16:29:04 +0000 (18:29 +0200)] 
netlink: flush stdout after each event in monitor mode

So we get all events when redirecting them to file, ie.

# nftables monitor > file

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 years agotests: display error when trying to run tests out of the root directory
Pablo Neira Ayuso [Thu, 3 Sep 2015 17:39:48 +0000 (19:39 +0200)] 
tests: display error when trying to run tests out of the root directory

Since 357d8cfcceb2 ("tests: use the src/nft binary instead of $PATH one"), the
tests fail if you try to run them if you are not under the root directory of
the nftables repository.

Display an error so I don't forget I have to do it like this.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 years agosrc: fix build with debug off
Florian Westphal [Mon, 7 Sep 2015 13:56:15 +0000 (15:56 +0200)] 
src: fix build with debug off

mnl.c:241:1: error: expected identifier or '(' before '}' token

Signed-off-by: Florian Westphal <fw@strlen.de>
9 years agotests: add 'awkward' prefix match expression
Florian Westphal [Fri, 7 Aug 2015 19:33:25 +0000 (21:33 +0200)] 
tests: add 'awkward' prefix match expression

Its just a more complicated way of saying 'ip saddr 255.255.0.0/16'.

Signed-off-by: Florian Westphal <fw@strlen.de>
9 years agotests: use the src/nft binary instead of $PATH one
Florian Westphal [Tue, 4 Aug 2015 13:51:25 +0000 (15:51 +0200)] 
tests: use the src/nft binary instead of $PATH one

... so one doesn't need to install new binary into $PATH (or
change PATH... ) during development.

Signed-off-by: Florian Westphal <fw@strlen.de>
9 years agotests: redirect: fix payload display
Pablo Neira Ayuso [Tue, 18 Aug 2015 04:28:10 +0000 (06:28 +0200)] 
tests: redirect: fix payload display

This has to be related to libnftnl's 0edeb667a2cf ("expr: redir: fix snprintf
to return the number of bytes printed").

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 years agotests: sets: don't include listing in payload tests
Pablo Neira Ayuso [Tue, 18 Aug 2015 04:11:41 +0000 (06:11 +0200)] 
tests: sets: don't include listing in payload tests

Since e715f6d1241c ("netlink: don't call netlink_dump_*() from listing
functions with --debug=netlink"), there is no debugging from the listing path.
Thus, we can remove the set line from the test files.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 years agonetlink: don't call netlink_dump_*() from listing functions with --debug=netlink
Pablo Neira Ayuso [Wed, 12 Aug 2015 17:07:39 +0000 (19:07 +0200)] 
netlink: don't call netlink_dump_*() from listing functions with --debug=netlink

Now that we always retrieve the object list to build a cache before executing
the command, this results in fully listing of existing objects in the kernel.

This is confusing when adding a simple rule, so better not to call
netlink_dump_*() from listing functions.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 years agoevaluate: display error on unexisting chain when listing
Pablo Neira Ayuso [Wed, 12 Aug 2015 16:44:22 +0000 (18:44 +0200)] 
evaluate: display error on unexisting chain when listing

nft list chain ip test output
<cmdline>:1:1-25: Error: Could not process rule: Chain 'output' does not exist
list chain ip test output
^^^^^^^^^^^^^^^^^^^^^^^^^

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 years agosrc: get rid of EINTR handling for nft_netlink()
Pablo Neira Ayuso [Tue, 7 Jul 2015 11:36:17 +0000 (13:36 +0200)] 
src: get rid of EINTR handling for nft_netlink()

The only remaining caller that needs this is netlink_dump_ruleset(), that is
used to export the ruleset using markup representation. We can remove it and
handle this from do_command_export() now that we have a centralized point to
build up the object cache.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 years agosrc: use cache infrastructure for set element objects
Pablo Neira Ayuso [Mon, 6 Jul 2015 09:47:12 +0000 (11:47 +0200)] 
src: use cache infrastructure for set element objects

Populate the cache iff the user requests a ruleset listing.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 years agosrc: use cache infrastructure for rule objects
Pablo Neira Ayuso [Mon, 6 Jul 2015 00:02:00 +0000 (02:02 +0200)] 
src: use cache infrastructure for rule objects

Populate the cache iff the user requests a ruleset listing.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 years agosrc: add chain declarations to cache
Pablo Neira Ayuso [Fri, 3 Jul 2015 17:31:14 +0000 (19:31 +0200)] 
src: add chain declarations to cache

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 years agoevaluate: add cmd_evaluate_rename()
Pablo Neira Ayuso [Fri, 3 Jul 2015 17:35:35 +0000 (19:35 +0200)] 
evaluate: add cmd_evaluate_rename()

Make sure the table that we want to rename already exist. This is required by
the follow up patch that that adds chains to the cache.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 years agosrc: use cache infrastructure for chain objects
Pablo Neira Ayuso [Fri, 3 Jul 2015 17:26:25 +0000 (19:26 +0200)] 
src: use cache infrastructure for chain objects

The chain list is obtained if the user requests a listing.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 years agorule: add chain reference counter
Pablo Neira Ayuso [Mon, 6 Jul 2015 12:29:33 +0000 (14:29 +0200)] 
rule: add chain reference counter

When adding declared chains to the cache, we may hold more than one single
reference from struct cmd and the cache.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 years agosrc: early allocation of the set ID
Pablo Neira Ayuso [Sat, 27 Jun 2015 21:36:20 +0000 (23:36 +0200)] 
src: early allocation of the set ID

By when the set is created, so element in the batch use this set ID as
reference.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 years agosrc: add set declaration to cache
Pablo Neira Ayuso [Fri, 3 Jul 2015 11:15:48 +0000 (13:15 +0200)] 
src: add set declaration to cache

This patch adds set objects to the cache if they don't exist in the kernel, so
they can be referenced from this batch. This occurs from the evaluation step.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 years agosrc: use cache infrastructure for set objects
Pablo Neira Ayuso [Fri, 26 Jun 2015 09:33:22 +0000 (11:33 +0200)] 
src: use cache infrastructure for set objects

This patch populates the cache only once through netlink_list_sets() during
evaluation. As a result, there is a single call to netlink_list_sets().

After this change, we can rid of get_set(). This function was fine by the time
we had no transaction support, but this doesn't work for set objects that are
declared in this batch, so inquiring the kernel doesn't help since they are not
yet available.

As a result from this update, the monitor code gets simplified quite a lot
since it can rely of the set cache. Moreover, we can now validate that the
table and set exists from evaluation path.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 years agosrc: add table declaration to cache
Pablo Neira Ayuso [Sun, 28 Jun 2015 19:02:32 +0000 (21:02 +0200)] 
src: add table declaration to cache

Add declared table objects to the cache, thus we can refer to objects that
come in this batch but that are not yet available in the kernel. This happens
from the evaluation step.

Get rid of code that is doing this from the later do_command_*() stage.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 years agorule: add reference counter to the table object
Pablo Neira Ayuso [Mon, 6 Jul 2015 11:52:09 +0000 (13:52 +0200)] 
rule: add reference counter to the table object

We may hold multiple references to table objects in follow up patches when
adding object declarations to the cache.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 years agosrc: add cmd_evaluate_list()
Pablo Neira Ayuso [Mon, 6 Jul 2015 18:02:50 +0000 (20:02 +0200)] 
src: add cmd_evaluate_list()

This function validates that the table that we want to list already exists by
looking it up from the cache.

This also adds cmd_error() to display an error from the evaluation step, when
the objects that the rule indicates do not exist.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 years agosrc: add cache infrastructure and use it for table objects
Pablo Neira Ayuso [Fri, 26 Jun 2015 09:33:22 +0000 (11:33 +0200)] 
src: add cache infrastructure and use it for table objects

This patch introduces the generic object cache that is populated during the
evaluation phase.

The first client of this infrastructure are table objects. As a result, there
is a single call to netlink_list_tables().

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 years agoMerge branch 'next-4.2'
Pablo Neira Ayuso [Mon, 17 Aug 2015 23:07:24 +0000 (01:07 +0200)] 
Merge branch 'next-4.2'

This branch adds support for the new 'netdev' family. This also resolves a
simple conflict with the default chain policy printing.

Conflicts:
src/rule.c

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 years agotests: add two test cases using binop w. payload
Florian Westphal [Fri, 7 Aug 2015 18:52:04 +0000 (20:52 +0200)] 
tests: add two test cases using binop w. payload

[ payload load 4b @ network header + 12 => reg 1 ]
[ bitwise reg 1 = (reg=1 & 0xff000000 ) ^ 0x00000000 ]
[ cmp eq reg 1 ...

.. to make sure that later support to match header elements that have odd
(non-byte aligned) lengths/offsets doesn't erronously eliminate explicitly
added binops while searching expressions for implicit binops.

Signed-off-by: Florian Westphal <fw@strlen.de>
9 years agosrc: restore nft list tables
Pablo Neira Ayuso [Mon, 3 Aug 2015 16:04:43 +0000 (18:04 +0200)] 
src: restore nft list tables

Iterate over the ctx->list which is where the table objects are after
calling netlink_list_tables().

Fixes: e4d21958c835 ("rule: add do_list_tables()")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 years agotests: validate generated netlink instructions
Florian Westphal [Fri, 10 Jul 2015 09:56:31 +0000 (11:56 +0200)] 
tests: validate generated netlink instructions

compare netlink instructions generated by given nft command line
with recorded version.

Example: udp dport 80 accept in ip family should look like

ip test-ip4 input
  [ payload load 1b @ network header + 9 => reg 1 ]
  [ cmp eq reg 1 0x00000011 ]
  [ payload load 2b @ transport header + 2 => reg 1 ]
  [ cmp eq reg 1 0x00005000 ]
  [ immediate reg 0 accept ]

This is stored in udp.t.payload.ip

Other suffixes:
.payload.ip6
.payload.inet
.payload ('any')

The test script first looks for 'testname.t.payload.$family', if that
doesn't exist 'testname.t.payload' is used.

This allows for family independent test (e.g. meta), where we don't
expect/have any family specific expressions.

Signed-off-by: Florian Westphal <fw@strlen.de>
9 years agonetlink_delinearize: meta l4proto range printing broken on 32bit
Pablo Neira Ayuso [Fri, 17 Jul 2015 12:38:37 +0000 (14:38 +0200)] 
netlink_delinearize: meta l4proto range printing broken on 32bit

Florian Westphal says:

09565a4b1ed4863d44c4509a93c50f44efd12771 ("netlink_delinearize: consolidate
range printing") causes nft to segfault on 32bit machine when printing l4proto
ranges.

The problem is that meta_expr_pctx_update() assumes that right is a value, but
after this change it can also be a range.

Thus, expr->value contents are undefined (its union).  On x86_64 this is also
broken but by virtue of struct layout and pointer sizes, value->_mp_size will
almost always be 0 so mpz_get_uint8() returns 0.

But on x86-32 _mp_size will be huge value (contains expr->right pointer of
range), so we crash in libgmp.

Pablo says:

We shouldn't call pctx_update(), before the transformation we had
there a expr->op == { OP_GT, OP_GTE, OP_LT, OP_LTE }. So we never
entered that path as the assert in payload_expr_pctx_update()
indicates.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Tested-by: Florian Westphal <fw@strlen.de>
9 years agotests: meta: use root for uid/gid checks
Florian Westphal [Thu, 16 Jul 2015 10:54:48 +0000 (12:54 +0200)] 
tests: meta: use root for uid/gid checks

I get failures here since 'man' has different uid vs. what
test suite expects.
Furthermore, this box does not have a 'backup' user.

Switch to root/bin/daemon -- those exist on both debian and fedora.

After this meta.t passes on all my machines.

Signed-off-by: Florian Westphal <fw@strlen.de>
10 years agotests: avoid more warnings
Florian Westphal [Wed, 15 Jul 2015 13:24:18 +0000 (15:24 +0200)] 
tests: avoid more warnings

... 2001:838:35f:1::-2001:838:35f:2:: :80-100' mismatches
... 2001:838:35f:1::-2001:838:35f:2:::80-100'

nft accepts both, so just alter test to not complain.

Also, fix test script to display the expected output rather than
the input.  Otherwise, a rule like
some_input;ok;expected_output

may display nonsensical message like
warning: some_input mismatches some_input

This also fixes the icmpv6 test accordingly, nft displays ranges
correctly.

Signed-off-by: Florian Westphal <fw@strlen.de>
10 years agomain: return error to shell on evaluation problems
Pablo Neira Ayuso [Fri, 10 Jul 2015 12:54:09 +0000 (14:54 +0200)] 
main: return error to shell on evaluation problems

 # nft add chain filter input { type filter hook inputt priority 0\; }
 <cmdline>:1:43-48: Error: unknown chain hook inputt
 add chain filter input { type filter hook inputt priority 0; }
                                           ^^^^^^

Before:

 # echo $?
 0

After:

 # echo $?
 1

Note that nft_parse() returns 1 on parsing errors and 0 + state->errs on
evaluation problems, so return -1 as other functions do here to pass up the
error to the main routine.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoconfigure: fix --enable-debug
Pablo Neira Ayuso [Tue, 7 Jul 2015 12:32:21 +0000 (14:32 +0200)] 
configure: fix --enable-debug

As the documentation indicates "The most common mistake for this macro is to
consider the two actions as action-if-enabled and action-if-disabled."

Use AS_IF in the action-if-present to check the real argument that we're
getting from the user.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agonetlink: release table object via table_free() in netlink_get_table()
Pablo Neira Ayuso [Mon, 6 Jul 2015 11:40:19 +0000 (13:40 +0200)] 
netlink: release table object via table_free() in netlink_get_table()

Instead of xfree().

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agorule: add do_list_tables()
Pablo Neira Ayuso [Mon, 6 Jul 2015 11:39:14 +0000 (13:39 +0200)] 
rule: add do_list_tables()

Wrap code to list existing tables in a function.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agosrc: set chain->hookstr from delinearization
Pablo Neira Ayuso [Fri, 3 Jul 2015 21:09:03 +0000 (23:09 +0200)] 
src: set chain->hookstr from delinearization

Set human readable hookname chain->hookstr field from delinearize.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agorule: missing family when listing of tables
Pablo Neira Ayuso [Fri, 3 Jul 2015 10:51:19 +0000 (12:51 +0200)] 
rule: missing family when listing of tables

 # nft list tables
 table ip nat

instead of:

 # nft list tables
 table nat

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agodatatype: avoid crash in debug mode when printing integers
Florian Westphal [Fri, 26 Jun 2015 08:50:44 +0000 (10:50 +0200)] 
datatype: avoid crash in debug mode when printing integers

nft -i --debug=all
nft> add rule ip filter foo mark 42

dies with sigfpe; seems mpz doesn't like len 0:
#1  0x0805f2ee in mpz_export_data (data=0xbfeda588, op=0x9d9fb08, byteorder=BYTEORDER_HOST_ENDIAN, len=0) at gmputil.c:115

After patch this prints 0x0000002a.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agopayload: reorder case in a switch for consistency
Eric Leblond [Fri, 26 Jun 2015 09:55:21 +0000 (11:55 +0200)] 
payload: reorder case in a switch for consistency

As pointed out by Patrick McHardy the order in the inet switch
in payload_gen_dependency was not consistent.

Signed-off-by: Eric Leblond <eric@regit.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agopayload: fix transport matching with no network layer info in bridge family
Pablo Neira Ayuso [Thu, 25 Jun 2015 13:09:33 +0000 (15:09 +0200)] 
payload: fix transport matching with no network layer info in bridge family

 # nft --debug=netlink add rule bridge filter input tcp dport 22
 bridge filter input
  [ meta load l4proto => reg 1 ]
  [ cmp eq reg 1 0x00000006 ]
  [ payload load 2b @ transport header + 2 => reg 1 ]
  [ cmp eq reg 1 0x00001600 ]

Reported-by: Eric Leblond <eric@regit.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoerec: fix logic when reading from file
Eric Leblond [Wed, 24 Jun 2015 07:51:50 +0000 (09:51 +0200)] 
erec: fix logic when reading from file

In case we are reading the rules from a file we need to reset the
file descriptor to the original position when calling erec_print.

This was not the case in previous code and was leading to valid
file to be seen as invalid when treated in debug mode.

Signed-off-by: Eric Leblond <eric@regit.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoerec: fix buffer overflow
Eric Leblond [Wed, 24 Jun 2015 07:51:49 +0000 (09:51 +0200)] 
erec: fix buffer overflow

A static array was used to read data and to write information in
it without checking the limit of the array. The result was a buffer
overflow when the line was longer than 1024.

This patch now uses a allocated buffer to avoid the problem.

Signed-off-by: Eric Leblond <eric@regit.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agosrc: add netdev family support
Pablo Neira Ayuso [Thu, 4 Jun 2015 18:58:59 +0000 (20:58 +0200)] 
src: add netdev family support

This patch adds support for the new 'netdev' table. So far, this table allows
you to create filter chains from ingress.

The following example shows a very simple base configuration with one table that
contains a basechain that is attached to the 'eth0':

 # nft list table netdev filter
 table netdev filter {
        chain eth0-ingress {
                type filter hook ingress device eth0 priority 0; policy accept;
        }
 }

You can test that this works by adding a simple rule with counters:

 # nft add rule netdev filter eth0-ingress counter

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agonetlink: fix use-after-free netlink_events_cache_deltable()
Pablo Neira Ayuso [Tue, 16 Jun 2015 16:10:53 +0000 (18:10 +0200)] 
netlink: fix use-after-free netlink_events_cache_deltable()

h.table stores a pointer to a nftnl table object that is gone just after
assignment. Release this object once its content is not referenced anymore.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoparser_bison: allow to use mark as datatype for maps and sets
Pablo Neira Ayuso [Tue, 16 Jun 2015 15:49:22 +0000 (17:49 +0200)] 
parser_bison: allow to use mark as datatype for maps and sets

Update the grammar to accept a MARK token as datatype.

Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1012
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agotests: regression: ip6: reduce warning noise
Pablo Neira Ayuso [Sat, 13 Jun 2015 18:21:22 +0000 (20:21 +0200)] 
tests: regression: ip6: reduce warning noise

getnameinfo() displays this:

 ::1234:1234:1234:1234:1234:1234:1234

as:

 0:1234:1234:1234:1234:1234:1234:1234

which is basically equivalent. nft accepts both inputs.

So add some exceptions to the tests to reduce the amount of noise in the tests,
so we can focus on real problems.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agonetlink_delinarize: fix merge conflict
Patrick McHardy [Sat, 13 Jun 2015 12:50:25 +0000 (14:50 +0200)] 
netlink_delinarize: fix merge conflict

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agoMerge remote-tracking branch 'origin/next-4.1'
Patrick McHardy [Sat, 13 Jun 2015 12:48:56 +0000 (14:48 +0200)] 
Merge remote-tracking branch 'origin/next-4.1'

10 years agoproto: use bitmask_type for comp flags
Pablo Neira Ayuso [Fri, 5 Jun 2015 15:02:05 +0000 (17:02 +0200)] 
proto: use bitmask_type for comp flags

I think flags should be displayed in hexadecimal and should be handled as a
bitmask.

inet/comp.t: WARNING: line: 15: 'nft add rule ip test-ip4 input comp flags 0x00': 'comp flags 0x00' mismatches 'comp flags 0'
inet/comp.t: WARNING: line: 16: 'nft add rule ip test-ip4 input comp flags != 0x23': 'comp flags != 0x23' mismatches 'comp flags != 35'
inet/comp.t: WARNING: line: 17: 'nft add rule ip test-ip4 input comp flags 0x33-0x45': 'comp flags 0x33-0x45' mismatches 'comp flags 51-69'
inet/comp.t: WARNING: line: 18: 'nft add rule ip test-ip4 input comp flags != 0x33-0x45': 'comp flags != 0x33-0x45' mismatches 'comp flags != 51-69'
inet/comp.t: WARNING: line: 19: 'nft add rule ip test-ip4 input comp flags {0x33, 0x55, 0x67, 0x88}': 'comp flags {0x33, 0x55, 0x67, 0x88}' mismatches 'comp flags { 103, 85, 51, 136}'
inet/comp.t: WARNING: line: 21: 'nft add rule ip test-ip4 input comp flags { 0x33-0x55}': 'comp flags { 0x33-0x55}' mismatches 'comp flags { 51-85}'

rfc3173 says that this is unused for future use though.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agodatatype: default to display bitmask in hexadecimal
Pablo Neira Ayuso [Fri, 5 Jun 2015 15:12:47 +0000 (17:12 +0200)] 
datatype: default to display bitmask in hexadecimal

Instead of a plain integer.

This updates integer_type_print() to look up some basefmt in the change of
datatype, the first we find will be used to format the output.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agonetlink_delinearize: restore listing of host byteorder set elements
Pablo Neira [Wed, 3 Jun 2015 18:16:41 +0000 (20:16 +0200)] 
netlink_delinearize: restore listing of host byteorder set elements

before:

table ip filter {
        chain test {
                cpu { 671088645033164833554432}
        }
}

after:

table ip filter {
        chain test {
                cpu { 4, 3, 2 }
        }
}

Related to 525323352904 ("expr: add set_elem_expr as container for set element
attributes").

We'll have to revisit this once we have support to use integer datatypes from
set declarations, see: http://patchwork.ozlabs.org/patch/480068/

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoMerge branch 'next-4.1'
Pablo Neira Ayuso [Thu, 4 Jun 2015 18:57:20 +0000 (20:57 +0200)] 
Merge branch 'next-4.1'

10 years agotests: regression: fix NAT tests
Pablo Neira Ayuso [Tue, 2 Jun 2015 15:14:59 +0000 (17:14 +0200)] 
tests: regression: fix NAT tests

snat can be only used from prerouting and input, and dnat from output and
postrouting.

 ip/nat.t: ERROR: line 12: nft add rule ip test-ip4 output iifname eth0 tcp sport 23-34 snat 192.168.3.2: This rule should not have failed.

Split the test file as they require different chain configuration.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agotests: regression: fix warnings related to range listing
Pablo Neira Ayuso [Sun, 31 May 2015 16:20:02 +0000 (18:20 +0200)] 
tests: regression: fix warnings related to range listing

Fix lots of warnings, mostly related to the listing of ranges in many of the
tests that we have, eg.

any/meta.t: WARNING: line: 30: 'nft add rule ip test-ip4 input meta l4proto 33-45': 'meta l4proto 33-45' mismatches 'meta l4proto 33-45'
any/meta.t: WARNING: line: 31: 'nft add rule ip test-ip4 input meta l4proto != 33-45': 'meta l4proto != 33-45' mismatches 'meta l4proto != 33-45'
any/meta.t: WARNING: line: 99: 'nft add rule ip test-ip4 input meta skuid 3001-3005 accept': 'meta skuid 3001-3005 accept' mismatches 'skuid 3001-3005 accept'
any/meta.t: WARNING: line: 100: 'nft add rule ip test-ip4 input meta skuid != 2001-2005 accept': 'meta skuid != 2001-2005 accept' mismatches 'skuid != 2001-2005 accept'
any/meta.t: WARNING: line: 111: 'nft add rule ip test-ip4 input meta skgid 2001-2005 accept': 'meta skgid 2001-2005 accept' mismatches 'skgid 2001-2005 accept'
any/meta.t: WARNING: line: 112: 'nft add rule ip test-ip4 input meta skgid != 2001-2005 accept': 'meta skgid != 2001-2005 accept' mismatches 'skgid != 2001-2005 accept'
any/meta.t: WARNING: line: 156: 'nft add rule ip test-ip4 input meta cpu 1-3': 'meta cpu 1-3' mismatches 'cpu 1-3'
any/meta.t: WARNING: line: 158: 'nft add rule ip test-ip4 input meta cpu != 1-2': 'meta cpu != 1-2' mismatches 'cpu != 1-2'
any/meta.t: WARNING: line: 187: 'nft add rule ip test-ip4 input meta cgroup 0x100001 - 0x100003': 'meta cgroup 0x100001 - 0x100003' mismatches 'cgroup 1048577-1048579'
...

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agotests: regression: reduce code duplication a bit on error reporting
Pablo Neira Ayuso [Sat, 30 May 2015 20:07:40 +0000 (22:07 +0200)] 
tests: regression: reduce code duplication a bit on error reporting

Consolidate print_err() and print_warning() into print_msg() to reduce code
duplication.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agonetlink_delinearize: consolidate range printing
Pablo Neira Ayuso [Sat, 30 May 2015 18:01:43 +0000 (20:01 +0200)] 
netlink_delinearize: consolidate range printing

This patch adds a routine to the postprocess stage to check if the previous
expression statement and the current actually represent a range, so we can
provide a more compact listing, eg.

 # nft -nn list table test
 table ip test {
        chain test {
                tcp dport 22
                tcp dport 22-23
                tcp dport != 22-23
                ct mark != 0x00000016-0x00000017
                ct mark 0x00000016-0x00000017
                mark 0x00000016-0x00000017
                mark != 0x00000016-0x00000017
        }
 }

To do so, the context state stores a pointer to the current statement. This
pointer needs to be invalidated in case the current statement is replaced.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agonetlink_delinearize: add payload_match_expand()
Pablo Neira Ayuso [Sat, 30 May 2015 19:57:57 +0000 (21:57 +0200)] 
netlink_delinearize: add payload_match_expand()

This function encapsulates the payload expansion logic. This change in required
by the follow up patch to consolidate range printing.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agonetlink_delinearize: keep pointer to current statement from rule_pp_ctx
Pablo Neira Ayuso [Tue, 2 Jun 2015 14:45:23 +0000 (16:45 +0200)] 
netlink_delinearize: keep pointer to current statement from rule_pp_ctx

This patch is required by the range postprocess routine that comes in follow up
patches.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agonetlink: handle concat expressions in set data
Patrick McHardy [Sun, 12 Apr 2015 20:10:42 +0000 (21:10 +0100)] 
netlink: handle concat expressions in set data

Reconstruct the concat expressions in set data by splicing off the
subtype values based on the keytype of the set.

Signed-off-by: Patrick McHardy
10 years agonetlink_delinearize: handle relational and lookup concat expressions
Patrick McHardy [Sun, 12 Apr 2015 20:10:42 +0000 (21:10 +0100)] 
netlink_delinearize: handle relational and lookup concat expressions

When the RHS length differs from the LHS length (which is only the
first expression), both expressions are assumed to be concat expressions.

The LHS concat expression is reconstructed from the available register
values, advancing by the number of registers required by the subexpressions'
register space, until the RHS length has been reached.

The RHS concat expression is reconstructed by splitting the data value
into multiple subexpressions based on the LHS concat expressions types.

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agonetlink_delinearize: introduce register translation helper
Patrick McHardy [Sun, 12 Apr 2015 20:10:41 +0000 (21:10 +0100)] 
netlink_delinearize: introduce register translation helper

Introduce a helper function to translate register numbers from the kernel
from the compat values to the NFT_REG32 values.

Internally we use the register numbers 0-16:

* 0 is the verdict register in both old and new addressing modes.
* 1-16 are the 32 bit data registers

The NFT_REG32_00 values are mapped to 1-16, the NFT_REG_1-NFT_REG_4
values are each use up 4 registers starting at 1 (1, 5, 9, 13).

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agonetlink: pad constant concat sub-expressions
Patrick McHardy [Sun, 12 Apr 2015 20:10:42 +0000 (21:10 +0100)] 
netlink: pad constant concat sub-expressions

Pad all but the last sub-expressions of a concat expressions.

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agonetlink_linearize: generate concat expressions
Patrick McHardy [Mon, 13 Apr 2015 11:19:12 +0000 (12:19 +0100)] 
netlink_linearize: generate concat expressions

Use the real length for reserving/releasing registers when generating
concat expressions.

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agonetlink_linearize: use NFT_REG32 values internally
Patrick McHardy [Sun, 12 Apr 2015 20:10:41 +0000 (21:10 +0100)] 
netlink_linearize: use NFT_REG32 values internally

Prepare netlink_linearize for 32 bit register usage:

Switch to use 16 data registers of 32 bit each. A helper function takes
care of mapping the registers to the NFT_REG32 values and, if the
register refers to the beginning of an 128 bit area, the old NFT_REG_1-4
values for compatibility.

New register reservation and release helper function take the size into
account and reserve the required amount of registers.

The reservation and release functions will so far still always allocate
128 bit. If no other expression in a rule uses a 32 bit register directly,
these will be mapped to the old register values, meaning everything
continues to work with old kernel versions.

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agonetlink: pass expression to register allocation/release functions
Patrick McHardy [Mon, 20 Apr 2015 12:45:40 +0000 (14:45 +0200)] 
netlink: pass expression to register allocation/release functions

Prepare for taking the expression size into account.

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agoheaders: sync headers for new register values
Patrick McHardy [Sun, 12 Apr 2015 20:10:41 +0000 (21:10 +0100)] 
headers: sync headers for new register values

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agoeval: prohibit variable sized types in concat expressions
Patrick McHardy [Tue, 2 Jun 2015 10:16:42 +0000 (12:16 +0200)] 
eval: prohibit variable sized types in concat expressions

Since we need to calculate the length of the entire concat type, we can
not support variable sized types where the length can't be determined
by the type.

This only affects base types since all higher types include a length.

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agoMerge remote-tracking branch 'origin/master' into next-4.1
Patrick McHardy [Tue, 2 Jun 2015 11:03:33 +0000 (13:03 +0200)] 
Merge remote-tracking branch 'origin/master' into next-4.1

10 years agonetlink_delinearize: remove obsolete fixme
Patrick McHardy [Tue, 2 Jun 2015 10:53:11 +0000 (12:53 +0200)] 
netlink_delinearize: remove obsolete fixme

The FIXME was related to exclusion of string types from cmp length checks.
Since with fixed sized helper names the last case where this could happen
is gone, remove the FIXME and perform length checks on strings as well.

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agoct: add maximum helper length value
Patrick McHardy [Tue, 2 Jun 2015 10:53:10 +0000 (12:53 +0200)] 
ct: add maximum helper length value

The current kernel restricts ct helper names to 16 bytes length. Specify
this limit in the ct expression table to catch oversized strings in userspace.
Since older versions of nft didn't support larger values, this does not
negatively affect interaction with old kernel versions.

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agonetlink_linearize: fix range cmp instruction generation
Patrick McHardy [Tue, 2 Jun 2015 10:53:10 +0000 (12:53 +0200)] 
netlink_linearize: fix range cmp instruction generation

The LHS expression is generated twice and the register not properly released.
Fix by calling netlink_gen_range() before generating the LHS.

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agonetlink_delinearize: pass ctx pointer to stmt_reject_postprocess()
Pablo Neira Ayuso [Sat, 30 May 2015 15:59:18 +0000 (17:59 +0200)] 
netlink_delinearize: pass ctx pointer to stmt_reject_postprocess()

Instead of a copy of the context variable.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agomnl: use new libnftnl batch API
Pablo Neira Ayuso [Tue, 14 Apr 2015 12:59:15 +0000 (14:59 +0200)] 
mnl: use new libnftnl batch API

Each batch page has a size of 320 Kbytes, and the limit has been set to 256
KBytes, so the overrun area is 64 KBytes long to accomodate the largest netlink
message (sets).

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agonftables: add set statemet
Patrick McHardy [Thu, 19 Mar 2015 13:34:18 +0000 (13:34 +0000)] 
nftables: add set statemet

The set statement is used to dynamically add or update elements in a set.

Syntax:

# nft filter input set add tcp dport @myset
# nft filter input set add ip saddr timeout 10s @myset
# nft filter input set update ip saddr timeout 10s @myset

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agosetelem: add support for attaching comments to set elements
Patrick McHardy [Fri, 20 Mar 2015 06:30:29 +0000 (06:30 +0000)] 
setelem: add support for attaching comments to set elements

Syntax:

# nft add element filter test { 192.168.0.1 comment "some host" }

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agosetelem: add timeout support for set elements
Patrick McHardy [Thu, 19 Mar 2015 13:34:18 +0000 (13:34 +0000)] 
setelem: add timeout support for set elements

Support specifying per element timeout values and displaying the expiration
time.

If an element should not use the default timeout value of the set, an
element specific value can be specified as follows:

# nft add element filter test { 192.168.0.1, 192.168.0.2 timeout 10m}

For listing of elements that use the default timeout value, just the
expiration time is shown, otherwise the element specific timeout value
is also displayed:

set test {
type ipv4_addr
timeout 1h
elements = { 192.168.0.2 timeout 10m expires 9m59s, 192.168.0.1 expires 59m59s}
}

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agoset: add timeout support for sets
Patrick McHardy [Mon, 23 Mar 2015 21:34:57 +0000 (21:34 +0000)] 
set: add timeout support for sets

Timeout support can be enabled in one of two ways:

1. Using a default timeout value:

set test {
type ipv4_addr;
timeout 1h;
}

2. Using the timeout flag without a default:

set test {
type ipv4_addr;
flags timeout;
}

Optionally a garbage collection interval can be specified using

gc-interval <interval>;

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agoexpr: add set_elem_expr as container for set element attributes
Patrick McHardy [Sat, 11 Apr 2015 16:02:13 +0000 (17:02 +0100)] 
expr: add set_elem_expr as container for set element attributes

Add a new expression type "set_elem_expr" that is used as container for
the key in order to attach different attributes, such as timeout values,
to the key.

The expression hierarchy is as follows:

Sets:

    elem
     |
    key

Maps:

   mapping
   /      \
 elem    data
  |
 key

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agoparser: fix inconsistencies in set expression rules
Patrick McHardy [Sun, 12 Apr 2015 09:41:56 +0000 (10:41 +0100)] 
parser: fix inconsistencies in set expression rules

Set keys are currently defined as a regular expr for pure sets and
map_lhs_expr for maps. map_lhs_expr is what can actually be used for
a single member, namely a concat_expr or a multiton_expr. The reason
why pure sets use expr for the key is to allow recursive set specifications,
which doesn't make sense for maps since every element needs a mapping.

However, the rule is too wide and also allows map expressions as a key,
which obviously doesn't make sense.

Rearrange the rules so we have:

set_lhs_expr: concat or multiton
set_rhs_expr: concat or verdict

and special case the recursive set specifications, as they deserve.

Besides making it a lot easier to understand what is actually supported,
this will be used by the following patch to support timeouts and comments
for keys in a uniform way.

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agoparser: add a time_spec rule
Patrick McHardy [Sat, 11 Apr 2015 14:41:32 +0000 (15:41 +0100)] 
parser: add a time_spec rule

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agodatatype: seperate time parsing/printing from time_type
Patrick McHardy [Sat, 11 Apr 2015 14:59:44 +0000 (15:59 +0100)] 
datatype: seperate time parsing/printing from time_type

Seperate relative time parsing and printing from the time_type to make
it usable for set and set element time related parameters.

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agodatatype: less strict time parsing
Patrick McHardy [Sat, 11 Apr 2015 13:56:16 +0000 (14:56 +0100)] 
datatype: less strict time parsing

Don't require hours to be in range 0-23 and minutes/seconds in range 0-59.
The time_type is used for relative times where it is entirely reasonable
to specify 180s instead of 3m.

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agodatatype: fix parsing of time type
Patrick McHardy [Sat, 11 Apr 2015 13:54:19 +0000 (14:54 +0100)] 
datatype: fix parsing of time type

Properly detect time strings in the lexer without quotation marks.

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agosrc: restore interface to index cache
Pablo Neira Ayuso [Thu, 9 Apr 2015 12:15:15 +0000 (14:15 +0200)] 
src: restore interface to index cache

nftables used to have a cache to speed up interface name <-> index lookup,
restore it using libmnl.

This reduces netlink traffic since if_nametoindex() and if_indextoname() open,
send a request, receive the list of interface and close a netlink socket for
each call.  I think this is also good for consistency since nft -f will operate
with the same index number when reloading the ruleset.

The cache is populated by when nft_if_nametoindex() and nft_if_indextoname()
are used for first time. Then, it it released in the output path. In the
interactive mode, it is invalidated after each command.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agosrc: introduce netlink_init_error()
Pablo Neira Ayuso [Mon, 6 Apr 2015 11:57:10 +0000 (13:57 +0200)] 
src: introduce netlink_init_error()

Based on the existing netlink_open_error(), but indicate file and line
where the error happens. This will help us to diagnose what is going
wrong when users can back to us to report problems.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agomonitor: fix missing space after chain name
Arturo Borrero [Tue, 7 Apr 2015 15:05:14 +0000 (17:05 +0200)] 
monitor: fix missing space after chain name

Due to change f3ff9e9 ("rule: delete extra space in rule indentation") in
function rule_print(), a missing space happens in monitor.

before this patch:
 % nft monitor
 add rule ip test-table test-chainip protocol tcp

after this patch:
 % nft monitor
 add rule ip test-table test-chain ip protocol tcp

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoparser: remove duplicated grammar for chain policy
Patrick McHardy [Tue, 24 Mar 2015 10:59:26 +0000 (10:59 +0000)] 
parser: remove duplicated grammar for chain policy

Signed-off-by: Patrick McHardy <kaber@trash.net>