From 8bd99f2fca7e8210771e0b3cb97ce7dbb3cb494d Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Tue, 13 Dec 2016 23:51:33 +0100 Subject: 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 --- tests/py/ip/flowtable.t | 5 +++++ tests/py/ip/flowtable.t.payload | 7 +++++++ 2 files changed, 12 insertions(+) create mode 100644 tests/py/ip/flowtable.t create mode 100644 tests/py/ip/flowtable.t.payload (limited to 'tests/py/ip') diff --git a/tests/py/ip/flowtable.t b/tests/py/ip/flowtable.t new file mode 100644 index 00000000..aea57c32 --- /dev/null +++ b/tests/py/ip/flowtable.t @@ -0,0 +1,5 @@ +:input;type filter hook input priority 0 + +*ip;test-ip;input + +flow table xyz { ip saddr timeout 30s counter packets 0 bytes 0};ok diff --git a/tests/py/ip/flowtable.t.payload b/tests/py/ip/flowtable.t.payload new file mode 100644 index 00000000..ffadfd25 --- /dev/null +++ b/tests/py/ip/flowtable.t.payload @@ -0,0 +1,7 @@ +# flow table xyz { ip saddr timeout 30s counter packets 0 bytes 0} +xyz test-ip 31 +xyz test-ip 0 +ip test-ip input + [ payload load 4b @ network header + 12 => reg 1 ] + [ dynset update reg_key 1 set xyz timeout 30000ms expr [ counter pkts 0 bytes 0 ] ] + -- cgit v1.2.3