62 lines
2.0 KiB
Diff
62 lines
2.0 KiB
Diff
From 8efab5527cbcb15cd9bff462b7549c0d6181c003 Mon Sep 17 00:00:00 2001
|
|
From: Pablo Neira Ayuso <pablo@netfilter.org>
|
|
Date: Mon, 1 Aug 2022 16:15:08 +0200
|
|
Subject: [PATCH] parser_json: fix device parsing in netdev family
|
|
|
|
json_unpack() function is not designed to take a pre-allocated buffer.
|
|
|
|
Conflict: NA
|
|
Reference: https://git.netfilter.org/nftables/commit?id=8efab5527cbcb15cd9bff462b7549c0d6181c003
|
|
|
|
Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1612
|
|
Fixes: 3fdc7541fba0 ("src: add multidevice support for netdev chain")
|
|
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
|
|
---
|
|
src/parser_json.c | 3 +--
|
|
tests/shell/testcases/json/netdev | 19 +++++++++++++++++++
|
|
2 files changed, 20 insertions(+), 2 deletions(-)
|
|
create mode 100755 tests/shell/testcases/json/netdev
|
|
|
|
diff --git a/src/parser_json.c b/src/parser_json.c
|
|
index 666aa2f..d434839 100644
|
|
--- a/src/parser_json.c
|
|
+++ b/src/parser_json.c
|
|
@@ -2746,8 +2746,7 @@ static struct cmd *json_parse_cmd_add_chain(struct json_ctx *ctx, json_t *root,
|
|
struct handle h = {
|
|
.table.location = *int_loc,
|
|
};
|
|
- const char *family = "", *policy = "", *type, *hookstr;
|
|
- const char name[IFNAMSIZ];
|
|
+ const char *family = "", *policy = "", *type, *hookstr, *name;
|
|
struct chain *chain;
|
|
int prio;
|
|
|
|
diff --git a/tests/shell/testcases/json/netdev b/tests/shell/testcases/json/netdev
|
|
new file mode 100755
|
|
index 0000000..a16a4f5
|
|
--- /dev/null
|
|
+++ b/tests/shell/testcases/json/netdev
|
|
@@ -0,0 +1,19 @@
|
|
+#!/bin/bash
|
|
+
|
|
+ip link add d0 type dummy || {
|
|
+ echo "Skipping, no dummy interface available"
|
|
+ exit 0
|
|
+}
|
|
+trap "ip link del d0" EXIT
|
|
+
|
|
+set -e
|
|
+
|
|
+$NFT flush ruleset
|
|
+$NFT add table inet test
|
|
+$NFT add chain inet test c
|
|
+
|
|
+$NFT flush ruleset
|
|
+
|
|
+RULESET='{"nftables":[{"flush":{"ruleset":null}},{"add":{"table":{"family":"netdev","name":"test_table"}}},{"add":{"chain":{"family":"netdev","table":"test_table","name":"test_chain","type":"filter","hook":"ingress","prio":0,"dev":"d0","policy":"accept"}}}]}'
|
|
+
|
|
+$NFT -j -f - <<< $RULESET
|
|
--
|
|
2.33.0
|
|
|