]> git.ipfire.org Git - thirdparty/nftables.git/commit
mnl: don't send empty set elements netlink message to kernel
authorPablo Neira Ayuso <pablo@netfilter.org>
Tue, 13 Dec 2016 22:51:33 +0000 (23:51 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 13 Dec 2016 23:07:34 +0000 (00:07 +0100)
commit8bd99f2fca7e8210771e0b3cb97ce7dbb3cb494d
tree2e3b3d70c6027c91015e13dac6d70f21858c131e
parentcd326af6d46b725c99fa8017a294c51876e486f7
mnl: don't send empty set elements netlink message to kernel

The following command:

 # nft --debug=mnl add rule x y flow table xyz { ip saddr timeout 30s counter }

breaks with EINVAL. The following netlink message is causing the
problem:

...
----------------        ------------------
|  0000000044  |        | message length |
| 02572 | R--- |        |  type | flags  |
|  0000000004  |        | sequence number|
|  0000000000  |        |     port ID    |
----------------        ------------------
| 02 00 00 00  |        |  extra header  |
|00008|--|00002|        |len |flags| type|
| 78 79 7a 00  |        |      data      |       x y z
|00008|--|00004|        |len |flags| type|
| 00 00 00 01  |        |      data      |
|00006|--|00001|        |len |flags| type|
| 78 00 00 00  |        |      data      |       x
----------------        ------------------
...

This is incorrect since this describes no elements at all, so it is
useless.  Add upfront check before iterating over the list of set
elements so the netlink message is not placed in the batch.

This patch also adds a set so flow tables are minimally covered.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/mnl.c
tests/py/ip/flowtable.t [new file with mode: 0644]
tests/py/ip/flowtable.t.payload [new file with mode: 0644]