]> git.ipfire.org Git - thirdparty/libnftnl.git/log
thirdparty/libnftnl.git
10 years agoexpr: Fix compilation with JSON and XML parsing enabled
Vijay Subramanian [Fri, 9 Oct 2015 19:21:07 +0000 (12:21 -0700)] 
expr: Fix compilation with JSON and XML parsing enabled

Fix missing/incorrect variables.
Also remove unsed variables to avoid warnings.

Signed-off-by: Vijay Subramanian <subramanian.vijay@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoexpr: dup: fix missing space in text output
Pablo Neira Ayuso [Tue, 29 Sep 2015 18:07:03 +0000 (20:07 +0200)] 
expr: dup: fix missing space in text output

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoexpr: add dup expression support
Pablo Neira Ayuso [Wed, 3 Jun 2015 16:50:50 +0000 (18:50 +0200)] 
expr: add dup expression support

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoexpr: limit: add per-byte limiting support
Pablo Neira Ayuso [Sun, 2 Aug 2015 16:51:43 +0000 (18:51 +0200)] 
expr: limit: add per-byte limiting support

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoexpr: limit: add burst attribute
Pablo Neira Ayuso [Sun, 2 Aug 2015 16:44:13 +0000 (18:44 +0200)] 
expr: limit: add burst attribute

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agobump version to 1.0.5 libnftnl-1.0.5
Pablo Neira Ayuso [Wed, 16 Sep 2015 18:46:06 +0000 (20:46 +0200)] 
bump version to 1.0.5

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agobuild: bump library versioning
Jan Engelhardt [Wed, 16 Sep 2015 17:12:47 +0000 (19:12 +0200)] 
build: bump library versioning

Commit libnftnl-1.0.3-31-g5ea54b2 removed a symbol. Such requires a
bumped to n+1:0:0. The symbol groups can be merged again to save time
processing them as the groups are relative to a particular SONAME
(of which we have a new one).

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agobump version to 1.0.4 libnftnl-1.0.4
Pablo Neira Ayuso [Wed, 16 Sep 2015 10:29:50 +0000 (12:29 +0200)] 
bump version to 1.0.4

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agosrc: get rid of _attr_ infix in new nftnl_ definitions
Pablo Neira Ayuso [Mon, 7 Sep 2015 16:57:50 +0000 (18:57 +0200)] 
src: get rid of _attr_ infix in new nftnl_ definitions

The function names are already large, trim off the _ATTR_ infix in the
attribute definitions.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agosrc: get rid of _ATTR_ infix in new nfntl_ definitions
Pablo Neira Ayuso [Mon, 7 Sep 2015 16:02:50 +0000 (18:02 +0200)] 
src: get rid of _ATTR_ infix in new nfntl_ definitions

The constant names are already large, trim off the _ATTR_ infix in the
attribute definitions.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agosrc: rename NFTNL_RULE_EXPR_ATTR to NFTNL_EXPR_
Pablo Neira Ayuso [Mon, 7 Sep 2015 15:59:49 +0000 (17:59 +0200)] 
src: rename NFTNL_RULE_EXPR_ATTR to NFTNL_EXPR_

So we get a shorter constant definition for expression attributes.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agosrc: rename nftnl_rule_expr to nftnl_expr
Pablo Neira Ayuso [Mon, 7 Sep 2015 15:56:47 +0000 (17:56 +0200)] 
src: rename nftnl_rule_expr to nftnl_expr

Use a shorter name for this, morever this can be used from sets so the _rule_
is misleading.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agosrc: add compat header file definitions
Pablo Neira Ayuso [Tue, 1 Sep 2015 17:34:18 +0000 (19:34 +0200)] 
src: add compat header file definitions

This patch restores the original nft_* definitions from the header files to
avoid sudden compilation breakage of the existing clients of this library.

Then, moving forward the idea is to deprecate the old nft_* symbols anytime
soon using __attribute__((deprecated)) from the header files to warn our users
that they need to update their code.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agosrc: rename existing functions to use the nftnl_ prefix
Pablo Neira Ayuso [Tue, 1 Sep 2015 18:19:56 +0000 (20:19 +0200)] 
src: rename existing functions to use the nftnl_ prefix

So we can use the nft_* prefix anytime soon for our upcoming higher level
library.

After this patch, the nft_* symbols become an alias of the nftnl_* symbols.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agosrc: introduce nftnl_* aliases for all existing functions
Pablo Neira Ayuso [Tue, 1 Sep 2015 11:59:54 +0000 (13:59 +0200)] 
src: introduce nftnl_* aliases for all existing functions

This patch introduces the nftnl_ symbols as aliases for the existing nft_
symbols through the EXPORT_SYMBOL(...) macro.

We would like to use the nft_* prefix from our upcoming higher level library,
meanwhile with this move we avoid that old binaries break because of missing
symbol dependencies.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoexpr: immediate: fix leak in expression destroy path
Pablo Neira Ayuso [Mon, 17 Aug 2015 02:41:32 +0000 (04:41 +0200)] 
expr: immediate: fix leak in expression destroy path

The verdict can be a chain string, make sure we release it when the expression
is destroyed. This patch adds a new nft_free_data() for this purpose and use it
from the immediate expression.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agosrc: fix memory leaks at nft_[object]_nlmsg_parse
Carlos Falgueras García [Wed, 5 Aug 2015 10:23:34 +0000 (12:23 +0200)] 
src: fix memory leaks at nft_[object]_nlmsg_parse

Free object attributes before overwrite it. Fix 'nlmsg_parse' methods of
following objects: 'table', 'chain', 'rule', 'set' and 'set_element'.

Signed-off-by: Carlos Falgueras García <carlosfg@riseup.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoexpr: redir: fix snprintf to return the number of bytes printed
Balazs Scheidler [Fri, 26 Jun 2015 09:57:53 +0000 (11:57 +0200)] 
expr: redir: fix snprintf to return the number of bytes printed

This fixes --debug netlink output when a redir target is included.

Signed-off-by: Balazs Scheidler <balazs.scheidler@balabit.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agochain: add netdev family support
Pablo Neira Ayuso [Thu, 11 Jun 2015 18:43:54 +0000 (20:43 +0200)] 
chain: add netdev family support

Add support for the new NFT_CHAIN_ATTR_DEV attribute that indicates that the
basechain is attached to a net_device.

This partially reworks 1dd9ba1ea23c ("table: add netdev family support").

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agotable: add netdev family support
Pablo Neira Ayuso [Mon, 25 May 2015 10:51:54 +0000 (12:51 +0200)] 
table: add netdev family support

This adds support for the new 'netdev' family tables.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agosrc: add batch abstraction
Pablo Neira Ayuso [Tue, 24 Feb 2015 23:53:51 +0000 (00:53 +0100)] 
src: add batch abstraction

This patch adds a new batch class to libnftnl, it basically generalizes what we
already have.

A batch is composed of one or more page objects. Every page may contain one or
more netlink messages.

 batch
   *      .------.   .------.         .------.
   |      |      |   |      |         |      |
   `----> | page |-->| page |-->...-->| page |
          |      |   |      |         |      |
          `------'   `------'         `------'

You can create a batch via:

batch = nft_batch_alloc(...);

This batch initially comes with one initial page.

You can fetch a pointer to the next spare area in the current page to add a new
netlink message to the batch.

void *nft_batch_buffer(struct nft_batch *batch);

Once you have added a netlink message, you have to call:

nft_batch_update(batch);

this internally updates the pointer to the next spare data area in the page.

Every page has a limit threshold after which you start using the overrun area.

  page  .------.
        |      |
        |      |
        .      . page area
        |      |
        |      |
        |------|<--- limit
        |      |
        |      | overrun area
        |      |
        '______'<--- real page size

If we write over the limit, then the next call to nft_batch_update() results in
a new empty page added to the batch. With careful page size and limit
selection, we ensure that a netlink message always fit into the page, so we
avoid the overhead of canceling the netlink message that doesn't fit in.

Once your batch is complete, if you want to send it out to kernel-space, you
can convert them to iovec via:

nft_batch_iovec(batch, iov, iov_len);

Then, after having sent the batch, you can release it via:

nft_batch_free(batch);

This class relies on the libmnl batching infrastructure.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agodynset: support expression templates
Patrick McHardy [Sun, 12 Apr 2015 19:17:52 +0000 (20:17 +0100)] 
dynset: support expression templates

Support expression templates for the dynset expression for dynamic
expression instantiation.

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agoset_elem: support expressions attached to set elements
Patrick McHardy [Sun, 12 Apr 2015 19:17:52 +0000 (20:17 +0100)] 
set_elem: support expressions attached to set elements

This patch supports attaching a struct nft_rule_expr to a set element
and adds netlink attribute encoding and decoding.

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agoexpr: seperate expression parsing and building functions
Patrick McHardy [Sun, 12 Apr 2015 19:17:52 +0000 (20:17 +0100)] 
expr: seperate expression parsing and building functions

The expression build function currently assumes to be only used from
rule context and actually builds rule attributes. Fix that and only
build the expression. Also it seems to have been exported by accident,
undo that.

Additionally, move the expression parsing function from rule parsing
and also remove any assumptions about being used in rule context.

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agodata: increase maximum possible data size
Patrick McHardy [Sun, 1 Mar 2015 10:28:02 +0000 (10:28 +0000)] 
data: increase maximum possible data size

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agoheaders: resync headers for new register definitions
Patrick McHardy [Thu, 26 Mar 2015 12:47:56 +0000 (12:47 +0000)] 
headers: resync headers for new register definitions

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agoexpr: dynset: fix json/xml parsing
Arturo Borrero Gonzalez [Mon, 13 Apr 2015 19:23:45 +0000 (20:23 +0100)] 
expr: dynset: fix json/xml parsing

expr/dynset.c: In function 'nft_rule_expr_dynset_json_parse':
expr/dynset.c:194:3: warning: implicit declaration of function 'nft_rule_expr_dynset_str' [-Wimplicit-function-declaration]
   nft_rule_expr_dynset_str(e, NFT_EXPR_DYNSET_SET, set_name);
   ^
expr/dynset.c:194:31: error: 'NFT_EXPR_DYNSET_SET' undeclared (first use in this function)
   nft_rule_expr_dynset_str(e, NFT_EXPR_DYNSET_SET, set_name);
                               ^
expr/dynset.c:194:31: note: each undeclared identifier is reported only once for each function it appears in
expr/dynset.c:197:3: warning: implicit declaration of function 'nft_rule_expr_dynset_u32' [-Wimplicit-function-declaration]
   nft_rule_expr_dynset_u32(e, NFT_EXPR_DYNSET_SREG, sreg);
   ^
expr/dynset.c:197:31: error: 'NFT_EXPR_DYNSET_SREG' undeclared (first use in this function)
   nft_rule_expr_dynset_u32(e, NFT_EXPR_DYNSET_SREG, sreg);
                               ^
expr/dynset.c:200:31: error: 'NFT_EXPR_DYNSET_DREG' undeclared (first use in this function)
   nft_rule_expr_dynset_u32(e, NFT_EXPR_DYNSET_DREG, dreg);
                               ^
expr/dynset.c: In function 'nft_rule_expr_dynset_xml_parse':
expr/dynset.c:220:31: error: 'NFT_EXPR_DYNSET_SET' undeclared (first use in this function)
   nft_rule_expr_dynset_str(e, NFT_EXPR_DYNSET_SET, set_name);
                               ^
expr/dynset.c:224:31: error: 'NFT_EXPR_DYNSET_SREG' undeclared (first use in this function)
   nft_rule_expr_dynset_u32(e, NFT_EXPR_DYNSET_SREG, sreg);
                               ^
expr/dynset.c:228:31: error: 'NFT_EXPR_DYNSET_DREG' undeclared (first use in this function)
   nft_rule_expr_dynset_u32(e, NFT_EXPR_DYNSET_DREG, dreg);
                               ^
Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agoexpr: add support for the dynset expr
Patrick McHardy [Sun, 12 Apr 2015 19:17:51 +0000 (20:17 +0100)] 
expr: add support for the dynset expr

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agoset_elem: add support for userdata
Patrick McHardy [Sun, 12 Apr 2015 19:17:51 +0000 (20:17 +0100)] 
set_elem: add support for userdata

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agoset: print set elem timeout information
Patrick McHardy [Sun, 12 Apr 2015 19:17:51 +0000 (20:17 +0100)] 
set: print set elem timeout information

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agoset_elem: add timeout support
Patrick McHardy [Thu, 26 Mar 2015 13:10:20 +0000 (13:10 +0000)] 
set_elem: add timeout support

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoset: add support for set timeouts
Patrick McHardy [Thu, 26 Mar 2015 13:10:19 +0000 (13:10 +0000)] 
set: add support for set timeouts

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agolist: fix prefetch dummy
Patrick McHardy [Thu, 26 Mar 2015 12:48:36 +0000 (12:48 +0000)] 
list: fix prefetch dummy

../include/linux_list.h:385:59: warning: right-hand operand of comma expression has no effect [-Wunused-value]
  for (pos = list_entry((head)->next, typeof(*pos), member), \
                                                           ^
set.c:266:2: note: in expansion of macro 'list_for_each_entry'
  list_for_each_entry(elem, &set->element_list, head) {

Signed-off-by: Patrick McHardy <kaber@trash.net>
10 years agosrc: restore static array with expression operations
Pablo Neira Ayuso [Sun, 22 Mar 2015 19:59:42 +0000 (20:59 +0100)] 
src: restore static array with expression operations

We cannot use __attribute__((constructor)) to register the supported
expressions in runtime when the library is statically linked. This lead
us to some explicit libnftnl_init() function that needs to be called
from the main() function of the client program.

This patch reverts 4dd0772 ("expr: use __attribute__((constructor)) to
register expression").

Reported-by: Laurent Bercot <ska-devel@skarnet.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoparser: Add operation not supported error message
Alvaro Neira [Mon, 16 Mar 2015 15:06:09 +0000 (16:06 +0100)] 
parser: Add operation not supported error message

If we try to import a ruleset in json or xml and the library was not
compile with support for those, this shows a misleading error.

To resolve this problem, this patch sets up EOPNOTSUPP by default when
we create the nft_parse_err structure.

Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoruleset: add nft_ruleset_ctx_free
Alvaro Neira [Thu, 12 Mar 2015 16:33:09 +0000 (17:33 +0100)] 
ruleset: add nft_ruleset_ctx_free

This function releases the ruleset objects attached in the parse context
structure, ie. struct nft_parse_ctx.

Moreover, this patch updates the nft_parse_ruleset_file to use it.

Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoexamples: add nft-ruleset-parse-file
Alvaro Neira [Mon, 2 Mar 2015 18:59:39 +0000 (19:59 +0100)] 
examples: add nft-ruleset-parse-file

With this example, we can parse the objects in the ruleset and create the
netlink message with the action associated. For example:

- Flush ruleset
- Add, delete or flush tables/chains
- Add, delete sets
- Add, delete set elements
- Add, delete, replace or prepend rules

Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoxml: test if the root node name is initialized
Alvaro Neira [Mon, 2 Mar 2015 19:58:38 +0000 (20:58 +0100)] 
xml: test if the root node name is initialized

If the root node name is missing, we have a crash.

Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoruleset: crash from error path when we build the xml/json tree
Alvaro Neira [Mon, 2 Mar 2015 18:59:38 +0000 (19:59 +0100)] 
ruleset: crash from error path when we build the xml/json tree

Fix crash when we try to release a tree that is not initialized.

Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoruleset: fix crash if we free sets included in the set_list
Alvaro Neira [Tue, 24 Feb 2015 08:10:32 +0000 (09:10 +0100)] 
ruleset: fix crash if we free sets included in the set_list

When we parse a ruleset which has a rule using a set. First step is to
parse the set, set up an ID and add it to a set list. Later, we use this
set list to find the set associated to the rule and we set up the set ID
to the expression (lookup expression) of the rule.

The problem is that if we return this set to the callback function
nft_ruleset_parse_file_cb() and we free this set, we have a crash when
we try to iterate in the set list.

This patch solves it, cloning the set and adding the new set to the set
list.

Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoMakefile: internal.h now resides in include
Pablo Neira Ayuso [Thu, 19 Feb 2015 00:24:44 +0000 (01:24 +0100)] 
Makefile: internal.h now resides in include

Remove reference to the former internal.h under src/

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agosrc: split internal.h is smaller files
Pablo Neira Ayuso [Fri, 13 Feb 2015 17:01:02 +0000 (18:01 +0100)] 
src: split internal.h is smaller files

The internal.h file started being a small file with private definitions.
Its size has been increasing over time more and more, so let's split
this in small header files that map to the corresponding class where the
functions belong to.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoruleset: fix more leaks in error path
Pablo Neira Ayuso [Fri, 13 Feb 2015 15:48:35 +0000 (16:48 +0100)] 
ruleset: fix more leaks in error path

Shouldn't happen though, since you need to introduce an unsupported
markup language.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoruleset: fix leak in json/xml in set lists
Alvaro Neira [Wed, 11 Feb 2015 21:12:22 +0000 (22:12 +0100)] 
ruleset: fix leak in json/xml in set lists

==18632== 285 (16 direct, 269 indirect) bytes in 1 blocks are definitely lost in loss record 6 of 6
==18632==    at 0x4C272B8: calloc (vg_replace_malloc.c:566)
==18632==    by 0x5043822: nft_set_list_alloc (set.c:977)
==18632==    by 0x5045483: nft_ruleset_json_parse (ruleset.c:442)
==18632==    by 0x50458BE: nft_ruleset_do_parse (ruleset.c:696)
==18632==    by 0x408AEC: do_command (rule.c:1317)
==18632==    by 0x406B05: nft_run (main.c:194)
==18632==    by 0x40667C: main (main.c:360)

Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agorule: don't release the tree parameter from nft_jansson_parse_rule()
Alvaro Neira [Wed, 11 Feb 2015 21:12:21 +0000 (22:12 +0100)] 
rule: don't release the tree parameter from nft_jansson_parse_rule()

We release the tree that we receive from the parameter in
nft_jansson_parse_rule. With this patch, we're going to release the tree
where we create it. Therefore, we will have a code more traceable and
readable.

Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agosrc: add missing include in utils.c
Pablo Neira Ayuso [Tue, 10 Feb 2015 12:10:48 +0000 (13:10 +0100)] 
src: add missing include in utils.c

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agotests: update JSON/XML tests with the new syntax
Alvaro Neira Ayuso [Mon, 9 Feb 2015 20:09:56 +0000 (21:09 +0100)] 
tests: update JSON/XML tests with the new syntax

Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agosrc: add support to import JSON/XML with the new command tag
Alvaro Neira Ayuso [Mon, 9 Feb 2015 20:09:54 +0000 (21:09 +0100)] 
src: add support to import JSON/XML with the new command tag

This patch adds support to parse the new command tag in XML/JSON. This
patch adds two new functions:

* nft_ruleset_parse_file_cb
* nft_ruleset_parse_buffer_cb

The idea is to invoke the callback function that is passed as parameter is
called for each object that is parsed from the corresponding input. Each
callback has access to the nft_parse_ctx structure that provides the necessary
context such as the command, the object type and the object itself.

This change also adds support to update the content of a set incrementally.

{"nftables":[{"add":[{"element":{"name":"blackhole","table":"filter",
 "family":"ip","key_type":7,"key_len":4,"set_elem":[{"key":{
 "reg":{"type":"value","len":4,"data0":"0x0403a8c0"}}}]}}]}]}

This also patch consolidates the xml/json ruleset import path.

Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agosrc: add command tag in JSON/XML export support
Alvaro Neira Ayuso [Mon, 9 Feb 2015 20:09:53 +0000 (21:09 +0100)] 
src: add command tag in JSON/XML export support

Currently, we can't do incremental updates via JSON/XML.

This patch enriches the existing output to indicate the kind of
update that you want to perform.

So, if we have a ruleset like:

table ip filter {
chain input {
type filter hook input priority 0;
}
}

The new output looks like:

{"nftables":[{"add":[{"table":{"name":"filter",...}}]}]}
              ^^^^^

Where we explicitly indicate that we want to add a table.

We support all the actions that we can do with nft, they are:

 - Add, delete and flush tables and chains.
 - Add, delete, replace and insert rules.
 - Add and delete sets.
 - Add and delete set elements.
 - Flush ruleset.

You only need to add the command tag:

{"nftables":[{"delete":[{...}, {...},...}]}]}
       ^^^^^^^^

The possible command tags that you can use are "add", "delete", "insert",
"replace" and "flush".

- Flush table or chain, eg.:

{"nftables":[{"flush":[{"table":{"name":...}}]}]}

- Delete table, chain, set or rule:

{"nftables":[{"delete":[{"chain":{"name":...}]}]}

- Replace a rule (you have to  specify the handle):

{"nftables":[{"replace":[{"rule":{...}}]}]}

- Insert a rule:

{"nftables":[{"insert":[{"rule":{...}}]}]}

Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agobuffer: fix missing XML string tag in nft_buf_close
Alvaro Neira Ayuso [Mon, 9 Feb 2015 20:09:52 +0000 (21:09 +0100)] 
buffer: fix missing XML string tag in nft_buf_close

Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoset: refactor code in json parse function
Alvaro Neira [Fri, 23 Jan 2015 14:49:51 +0000 (15:49 +0100)] 
set: refactor code in json parse function

This patch refactors code to parse the set in two functions
nft_jansson_parse_set_info and nft_jansson_parse_set. These changes are
used in follow up patches.

Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoruleset: refactor nft_ruleset_*_parse_ruleset()
Alvaro Neira [Mon, 12 Jan 2015 13:46:15 +0000 (14:46 +0100)] 
ruleset: refactor nft_ruleset_*_parse_ruleset()

Refactor the parsing ruleset element functions calls in xml/json to do
that calls in the functions nft_ruleset_*_parse_ruleset. This patch is
used in follow up patches.

Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agosrc: don't create iterator with empty list
Alvaro Neira [Mon, 12 Jan 2015 13:46:14 +0000 (14:46 +0100)] 
src: don't create iterator with empty list

Currently, we create iterator without test if the list is empty. If the
list is empty, we have a crash when we set up the current element. With
this patch, we test if the list is empty before to create the iterator.
If the list is empty the iterator return NULL.

Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 years agoruleset: clean up the variable names in the xml/json parsing functions
Alvaro Neira [Fri, 9 Jan 2015 12:47:41 +0000 (13:47 +0100)] 
ruleset: clean up the variable names in the xml/json parsing functions

Rename variables to use more intuitive name like table, chain, rule or set.

Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoinclude: add missing gen.h to Makefile.am libnftnl-1.0.3
Pablo Neira Ayuso [Mon, 15 Dec 2014 23:15:33 +0000 (00:15 +0100)] 
include: add missing gen.h to Makefile.am

Fixes make distcheck.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agobump version to 1.0.3
Pablo Neira Ayuso [Mon, 15 Dec 2014 23:05:17 +0000 (00:05 +0100)] 
bump version to 1.0.3

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agobuffer: include stdarg header
Giuseppe Longo [Thu, 20 Nov 2014 12:15:57 +0000 (13:15 +0100)] 
buffer: include stdarg header

This fixes the following warnings:

buffer.c: In function 'nft_buf_put':
buffer.c:53:2: warning: implicit declaration of function 'va_start' [-Wimplicit-function-declaration]
  va_start(ap, fmt);
  ^
buffer.c:56:2: warning: implicit declaration of function 'va_end' [-Wimplicit-function-declaration]
  va_end(ap);
  ^

Signed-off-by: Giuseppe Longo <giuseppelng@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoexamples: nft-rule-parse-add: fix wrong buffer usage when building rule header
Arturo Borrero [Mon, 17 Nov 2014 09:26:41 +0000 (10:26 +0100)] 
examples: nft-rule-parse-add: fix wrong buffer usage when building rule header

The libmnl helper returns a pointer where to start putting the rule data.

Reported-by: Ian Bishop <ian@pace7.com>
Closes: http://bugzilla.netfilter.org/show_bug.cgi?id=983
Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoexpr: data_reg: use 'reg' instead of 'data_reg'
Pablo Neira Ayuso [Mon, 10 Nov 2014 12:35:57 +0000 (13:35 +0100)] 
expr: data_reg: use 'reg' instead of 'data_reg'

data_reg is unnecessarily long name and it always has to be
wrapped by another data node. This will allow us to represent
data not only as registers if needed.

Get rid of 'cmpdata' and 'immediatedata' too and use 'data'
instead to wrap 'reg' so these are consistent with the bitwise
expression. No reason for such specific tag per expression.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agosrc: consolidate XML/JSON exportation
Pablo Neira Ayuso [Sun, 9 Nov 2014 18:26:48 +0000 (19:26 +0100)] 
src: consolidate XML/JSON exportation

Add new buffer class to consolidate the existing code to export objects
in XML/JSON and use it. We save ~700 LOC with this change.

The rule and set objects are not yet consolidated. It seems this would
require some specific glue code per representation type since lists are
arranged differently.

This also consolidates the tag names, so we make sure the same are used
from XML and JSON by placing them in include/buffer.h.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoexpr: nat: use 'nat_type' instead of 'type' in the parser
Pablo Neira Ayuso [Mon, 10 Nov 2014 12:57:54 +0000 (13:57 +0100)] 
expr: nat: use 'nat_type' instead of 'type' in the parser

'type' is already used from the expression.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoexpr: meta: Add cgroup support
Ana Rey [Mon, 3 Nov 2014 17:10:49 +0000 (18:10 +0100)] 
expr: meta: Add cgroup support

The kernel support is add in the commit:
netfilter: nft_meta: add cgroup support

Signed-off-by: Ana Rey <anarey@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoremove empty src/attr.c
Pablo Neira Ayuso [Sun, 9 Nov 2014 20:16:54 +0000 (21:16 +0100)] 
remove empty src/attr.c

This empty file slipped through the repository, remove it.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agotests: add tests for nft_redir expression
Arturo Borrero [Tue, 14 Oct 2014 17:36:22 +0000 (19:36 +0200)] 
tests: add tests for nft_redir expression

This patch add some tests for the nft_redir expression.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agosrc: add support for nft_redir expression
Arturo Borrero [Fri, 17 Oct 2014 10:40:24 +0000 (12:40 +0200)] 
src: add support for nft_redir expression

This patch adds support for the new nft_redir expression.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoruleset: deconstify _get interface
Arturo Borrero [Mon, 20 Oct 2014 19:46:09 +0000 (21:46 +0200)] 
ruleset: deconstify _get interface

Having this interface returning a const pointer makes very hard to
modificate the content of a chain contained in a nft_ruleset.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoutils: fix arp family number
Arturo Borrero [Mon, 20 Oct 2014 11:52:18 +0000 (13:52 +0200)] 
utils: fix arp family number

NFPROTO_ARP = 3 in kernel space.

We need the same value here in userspace in order to correctly communicate
with the kernel.

The failure solved by this patch made that {XML|JSON}-parsed tables of ARP
family unable to be directly injected into kernel.

To prevent future errors, this patch changes raw and AF_* values by the mathing
NFPROTO_* couterpart as seen in linux/netfilter.h in both functions:
 * nft_family2str()
 * nft_str2family()

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agosrc: fix compilation without xml/json support
Pablo Neira Ayuso [Sat, 11 Oct 2014 10:23:10 +0000 (12:23 +0200)] 
src: fix compilation without xml/json support

Fixes: c04175e ("src: internal set id allocation from nft_ruleset_parse*()")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agosrc: cleanup in mxml and jansson regarding set_id parsing
Arturo Borrero [Fri, 10 Oct 2014 19:43:44 +0000 (21:43 +0200)] 
src: cleanup in mxml and jansson regarding set_id parsing

jansson.c: In function 'nft_jansson_expr_parse':
jansson.c:212:6: warning: pointer targets in passing argument 3 of 'nft_set_lookup_id' differ in signedness [-Wpointer-sign]
In file included from jansson.c:10:0:
./internal.h:95:5: note: expected 'uint32_t *' but argument is of type 'int *'
jansson.c:195:18: warning: unused variable 'set_cur' [-Wunused-variable]
mxml.c: In function 'nft_mxml_expr_parse':
mxml.c:97:6: warning: pointer targets in passing argument 3 of 'nft_set_lookup_id' differ in signedness [-Wpointer-sign]
In file included from mxml.c:12:0:
internal.h:95:5: note: expected 'uint32_t *' but argument is of type 'int *'
mxml.c:68:18: warning: unused variable 'set_cur' [-Wunused-variable]

Spotted with: gcc (Debian 4.7.2-5) 4.7.2

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agosrc: internal set id allocation from nft_ruleset_parse*()
Alvaro Neira [Fri, 3 Oct 2014 18:02:40 +0000 (20:02 +0200)] 
src: internal set id allocation from nft_ruleset_parse*()

Extends this function to attach the set to the rule through the set_idi.
If it doesn't exist in the list, maybe the set already exists in the
kernel. In that case, we don't set any id.

Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoruleset: add set id to parsed sets
Alvaro Neira [Fri, 3 Oct 2014 18:02:39 +0000 (20:02 +0200)] 
ruleset: add set id to parsed sets

Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agotests: also test nat flags attribute
Arturo Borrero [Thu, 2 Oct 2014 11:58:47 +0000 (13:58 +0200)] 
tests: also test nat flags attribute

The nat expression has a new attribute. Let's give some testing.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agotests: add tests for the masq expression
Arturo Borrero [Thu, 2 Oct 2014 11:58:42 +0000 (13:58 +0200)] 
tests: add tests for the masq expression

The masq expression is lacking of tests. Let's add some.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoexpr: masq: optional printing of flags attr in snprintf_default
Arturo Borrero [Thu, 2 Oct 2014 11:58:36 +0000 (13:58 +0200)] 
expr: masq: optional printing of flags attr in snprintf_default

The flags attribute is optional. Thus we should print only if it
was originally set.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoexamples: nft-table-add: fix wrong buffer pointer
Arturo Borrero [Mon, 29 Sep 2014 20:41:05 +0000 (22:41 +0200)] 
examples: nft-table-add: fix wrong buffer pointer

We should point to the batch buffer as returned by the libmnl helper.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoexamples: nft-set-parse-add: add batching support
Arturo Borrero [Fri, 26 Sep 2014 18:34:48 +0000 (20:34 +0200)] 
examples: nft-set-parse-add: add batching support

Batching is needed in current kernels.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoexamples: nft-set-json-add: generalize parsing format support
Arturo Borrero [Fri, 26 Sep 2014 18:34:42 +0000 (20:34 +0200)] 
examples: nft-set-json-add: generalize parsing format support

Let's create a single code example with XML/JSON support.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
11 years agoexamples: nft-rule-parse-add: add batching support
Arturo Borrero [Tue, 23 Sep 2014 11:15:26 +0000 (13:15 +0200)] 
examples: nft-rule-parse-add: add batching support

Let's add support for current kernels.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoexamples: merge nft-rule-{xml|json}-add.c
Arturo Borrero [Tue, 23 Sep 2014 11:15:21 +0000 (13:15 +0200)] 
examples: merge nft-rule-{xml|json}-add.c

Merge the two examples in just one. An input argument choose the format to use.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agosrc: add ruleset generation class
Pablo Neira Ayuso [Fri, 12 Sep 2014 09:52:18 +0000 (11:52 +0200)] 
src: add ruleset generation class

The generation object currently only contains the uint32_t that
indicates the generation ID. I could have just add the API to return
the uint32_t ID instead, but I think this API is easier to extend
without adding new APIs.

We can probably include meaningful statistics in the generation
message in the future without much hassle.

This patch also extends examples/nft-events.c.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoset: fix set nlmsg desc parsing
Arturo Borrero [Thu, 18 Sep 2014 18:18:19 +0000 (20:18 +0200)] 
set: fix set nlmsg desc parsing

In commit ff62959("set: add support for set mechanism selection") the
support for parsing the nested attribute (NFTA_SET_DESC) was incorrect.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoutils: nft_fprintf: prevent an empty buffer from being printed
Arturo Borrero [Fri, 12 Sep 2014 19:41:25 +0000 (21:41 +0200)] 
utils: nft_fprintf: prevent an empty buffer from being printed

If the snprintf_cb() printed 0 characters, no \0 exists in the buffer.
Also, in that case fprintf() is meant to print nothing, so we can just exit.

This patch addresses new cases of textual output by libnftnl with trash.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agonf_tables.h: add NFTA_MASQ_UNSPEC
Arturo Borrero [Thu, 11 Sep 2014 16:56:34 +0000 (18:56 +0200)] 
nf_tables.h: add NFTA_MASQ_UNSPEC

To keep this consistent with other nft_*_attributes.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoexpr: add new nft_masq expression
Arturo Borrero [Mon, 8 Sep 2014 11:38:46 +0000 (13:38 +0200)] 
expr: add new nft_masq expression

This patch adds userspace support to nft_masq, the new expression to
perform masquerade.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoexpr: nat: add support for the new flags attribute
Arturo Borrero [Tue, 9 Sep 2014 11:21:28 +0000 (13:21 +0200)] 
expr: nat: add support for the new flags attribute

This patchs adds support for the new flags attribute in the nft_nat
expression.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
11 years agoexpr: meta: Add devgroup support
Ana Rey [Tue, 2 Sep 2014 18:36:58 +0000 (20:36 +0200)] 
expr: meta: Add devgroup support

The kernel support is add in commit:
netfilter: nf_tables: add devgroup support in meta expresion

Signed-off-by: Ana Rey <anarey@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agosrc: get rid of cached copies of x_tables.h and xt_LOG.h
Pablo Neira Ayuso [Sun, 31 Aug 2014 19:53:12 +0000 (21:53 +0200)] 
src: get rid of cached copies of x_tables.h and xt_LOG.h

Keeping the full cached copy the of x_tables.h file in tree is too much
for just the XT_EXTENSION_MAXNAMELEN constant. Similarly, xt_LOG.h is not
actually required by the tests, we can use any whatever syntetic data
to make sure the setter and getter provide the same result. So, let's
get rid of these headers from the library tree.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agosrc: fix printing of XML/JSON event wrapper header/footer
Arturo Borrero [Mon, 25 Aug 2014 13:02:27 +0000 (15:02 +0200)] 
src: fix printing of XML/JSON event wrapper header/footer

Use the nft_fprintf() helper. The helper handles \0 properly.

Before this patch, we get trash in the output due to the buffer being
printed without any \0.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoexamples: nft-table-del: add batching support
Arturo Borrero [Fri, 22 Aug 2014 09:39:56 +0000 (11:39 +0200)] 
examples: nft-table-del: add batching support

Add batching support so this code example works with current kernels.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoexamples: nft-table-del: add table_del_parse()
Arturo Borrero [Fri, 22 Aug 2014 09:39:51 +0000 (11:39 +0200)] 
examples: nft-table-del: add table_del_parse()

This new function parses the input arguments and generates the nft_table.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoexamples: nft-table-add: add batching support
Arturo Borrero [Fri, 22 Aug 2014 09:39:46 +0000 (11:39 +0200)] 
examples: nft-table-add: add batching support

Adds batching support to this code example, so it works with current kernels.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoexamples: nft-table-add: add table_add_parse()
Arturo Borrero [Fri, 22 Aug 2014 09:39:40 +0000 (11:39 +0200)] 
examples: nft-table-add: add table_add_parse()

This fucntion parses the command line options and creates the nft_table object.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoexamples: nft-table-parse-add: add batching support
Arturo Borrero [Fri, 22 Aug 2014 09:39:35 +0000 (11:39 +0200)] 
examples: nft-table-parse-add: add batching support

Add batching support to operate with recent kernels.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoexamples: merge nft-table-{xml|json}-add.c
Arturo Borrero [Fri, 22 Aug 2014 09:39:29 +0000 (11:39 +0200)] 
examples: merge nft-table-{xml|json}-add.c

Merge the two examples in one. An input argument choose the format to use.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoexpr: meta: Add cpu support for meta expresion
Ana Rey [Sun, 24 Aug 2014 12:26:32 +0000 (14:26 +0200)] 
expr: meta: Add cpu support for meta expresion

Signed-off-by: Ana Rey <anarey@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoexpr: meta: Add pkttype support
Ana Rey [Tue, 5 Aug 2014 18:30:18 +0000 (20:30 +0200)] 
expr: meta: Add pkttype support

Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
Signed-off-by: Ana Rey <anarey@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoutils: define xfree() as macro
Pablo Neira Ayuso [Wed, 20 Aug 2014 12:51:12 +0000 (14:51 +0200)] 
utils: define xfree() as macro

Original description from Thomas Petazzoni:

When ELF binaries and shared libraries are used, the internal
functions of libnftnl such as xfree() are not visible to the outside
world (their visibility is 'hidden'). Therefore, the fact that other
programs (especially nftables) may have symbols with the same name
does not cause any problem.

However, when doing static linking on a non-ELF platform (such as
Blackfin, which uses the FLAT binary format), there is no way of
encoding this visibility. Therefore, the xfree() symbols of libnftnl
becomes visible to the outside world, causing a conflict with the
xfree() symbol defined by nftables.

To solve this, this patch convers xfree as a macro instead of
a function.

Reported-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoexamples: nft-chain-parse-add: add batching support
Arturo Borrero [Mon, 18 Aug 2014 19:06:20 +0000 (21:06 +0200)] 
examples: nft-chain-parse-add: add batching support

Add batching support to operate with current kernels.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoexamples: merge nft-chain-{xml|json}-add.c
Arturo Borrero [Mon, 18 Aug 2014 19:06:14 +0000 (21:06 +0200)] 
examples: merge nft-chain-{xml|json}-add.c

Merge the two examples in one. Use an input argument to choose the
format to parse.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoset_elem: use proper free function
Arturo Borrero [Thu, 3 Jul 2014 16:04:21 +0000 (18:04 +0200)] 
set_elem: use proper free function

Let's use the proper free function to liberate the set_elem,
so we avoid potential memory leaks.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>