From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH nft] rule: print chain and flowtable devices in quotes
Date: Wed, 9 Jul 2025 01:11:28 +0200 [thread overview]
Message-ID: <20250708231128.2045876-1-pablo@netfilter.org> (raw)
Print devices in quotes, for consistency with:
- the existing chain listing with single device:
type filter hook ingress device "lo" priority filter; policy accept
- the ifname datatype used in sets.
In general, tokens that are user-defined, not coming in the datatype
symbol list, are enclosed in quotes.
Fixes: 3fdc7541fba0 ("src: add multidevice support for netdev chain")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
src/rule.c | 4 ++--
tests/shell/features/flowtable_counter.sh | 2 +-
.../testcases/chains/dumps/0042chain_variable_0.nft | 4 ++--
.../testcases/flowtable/dumps/0001flowtable_0.nft | 2 +-
.../flowtable/dumps/0002create_flowtable_0.nft | 2 +-
.../flowtable/dumps/0003add_after_flush_0.nft | 2 +-
.../flowtable/dumps/0005delete_in_use_1.nft | 2 +-
.../flowtable/dumps/0012flowtable_variable_0.nft | 4 ++--
.../flowtable/dumps/0013addafterdelete_0.nft | 2 +-
.../flowtable/dumps/0014addafterdelete_0.nft | 2 +-
tests/shell/testcases/listing/0020flowtable_0 | 12 ++++++------
.../testcases/listing/dumps/0020flowtable_0.nft | 4 ++--
12 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/src/rule.c b/src/rule.c
index c0f7570e233c..3e3cc3b0fb7d 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -1062,7 +1062,7 @@ static void chain_print_declaration(const struct chain *chain,
} else if (chain->dev_array_len > 1) {
nft_print(octx, " devices = { ");
for (i = 0; i < chain->dev_array_len; i++) {
- nft_print(octx, "%s", chain->dev_array[i]);
+ nft_print(octx, "\"%s\"", chain->dev_array[i]);
if (i + 1 != chain->dev_array_len)
nft_print(octx, ", ");
}
@@ -2149,7 +2149,7 @@ static void flowtable_print_declaration(const struct flowtable *flowtable,
if (flowtable->dev_array_len > 0) {
nft_print(octx, "%s%sdevices = { ", opts->tab, opts->tab);
for (i = 0; i < flowtable->dev_array_len; i++) {
- nft_print(octx, "%s", flowtable->dev_array[i]);
+ nft_print(octx, "\"%s\"", flowtable->dev_array[i]);
if (i + 1 != flowtable->dev_array_len)
nft_print(octx, ", ");
}
diff --git a/tests/shell/features/flowtable_counter.sh b/tests/shell/features/flowtable_counter.sh
index a4c4c62124b0..5d47215f2f94 100755
--- a/tests/shell/features/flowtable_counter.sh
+++ b/tests/shell/features/flowtable_counter.sh
@@ -6,7 +6,7 @@
EXPECTED="table ip filter2 {
flowtable main_ft2 {
hook ingress priority filter
- devices = { lo }
+ devices = { \"lo\" }
counter
}
}"
diff --git a/tests/shell/testcases/chains/dumps/0042chain_variable_0.nft b/tests/shell/testcases/chains/dumps/0042chain_variable_0.nft
index 84a908d33dee..08a19014e7b8 100644
--- a/tests/shell/testcases/chains/dumps/0042chain_variable_0.nft
+++ b/tests/shell/testcases/chains/dumps/0042chain_variable_0.nft
@@ -5,12 +5,12 @@ table netdev filter1 {
}
table netdev filter2 {
chain Main_Ingress2 {
- type filter hook ingress devices = { d23456789012345, lo } priority -500; policy accept;
+ type filter hook ingress devices = { "d23456789012345", "lo" } priority -500; policy accept;
}
}
table netdev filter3 {
chain Main_Ingress3 {
- type filter hook ingress devices = { d23456789012345, lo } priority -500; policy accept;
+ type filter hook ingress devices = { "d23456789012345", "lo" } priority -500; policy accept;
}
chain Main_Egress3 {
diff --git a/tests/shell/testcases/flowtable/dumps/0001flowtable_0.nft b/tests/shell/testcases/flowtable/dumps/0001flowtable_0.nft
index 629bfe81cb18..79fa59130843 100644
--- a/tests/shell/testcases/flowtable/dumps/0001flowtable_0.nft
+++ b/tests/shell/testcases/flowtable/dumps/0001flowtable_0.nft
@@ -1,7 +1,7 @@
table inet t {
flowtable f {
hook ingress priority filter + 10
- devices = { lo }
+ devices = { "lo" }
}
chain c {
diff --git a/tests/shell/testcases/flowtable/dumps/0002create_flowtable_0.nft b/tests/shell/testcases/flowtable/dumps/0002create_flowtable_0.nft
index aecfb2ab25df..2d0ea905d8b9 100644
--- a/tests/shell/testcases/flowtable/dumps/0002create_flowtable_0.nft
+++ b/tests/shell/testcases/flowtable/dumps/0002create_flowtable_0.nft
@@ -1,6 +1,6 @@
table ip t {
flowtable f {
hook ingress priority filter + 10
- devices = { lo }
+ devices = { "lo" }
}
}
diff --git a/tests/shell/testcases/flowtable/dumps/0003add_after_flush_0.nft b/tests/shell/testcases/flowtable/dumps/0003add_after_flush_0.nft
index dd904f449ca1..39de91b19a82 100644
--- a/tests/shell/testcases/flowtable/dumps/0003add_after_flush_0.nft
+++ b/tests/shell/testcases/flowtable/dumps/0003add_after_flush_0.nft
@@ -1,6 +1,6 @@
table ip x {
flowtable y {
hook ingress priority filter
- devices = { lo }
+ devices = { "lo" }
}
}
diff --git a/tests/shell/testcases/flowtable/dumps/0005delete_in_use_1.nft b/tests/shell/testcases/flowtable/dumps/0005delete_in_use_1.nft
index c1d79e7b144d..b01b3027c50e 100644
--- a/tests/shell/testcases/flowtable/dumps/0005delete_in_use_1.nft
+++ b/tests/shell/testcases/flowtable/dumps/0005delete_in_use_1.nft
@@ -1,7 +1,7 @@
table ip x {
flowtable y {
hook ingress priority filter
- devices = { lo }
+ devices = { "lo" }
}
chain x {
diff --git a/tests/shell/testcases/flowtable/dumps/0012flowtable_variable_0.nft b/tests/shell/testcases/flowtable/dumps/0012flowtable_variable_0.nft
index df1c51a24703..7863822d754b 100644
--- a/tests/shell/testcases/flowtable/dumps/0012flowtable_variable_0.nft
+++ b/tests/shell/testcases/flowtable/dumps/0012flowtable_variable_0.nft
@@ -1,14 +1,14 @@
table ip filter1 {
flowtable Main_ft1 {
hook ingress priority filter
- devices = { lo }
+ devices = { "lo" }
counter
}
}
table ip filter2 {
flowtable Main_ft2 {
hook ingress priority filter
- devices = { lo }
+ devices = { "lo" }
counter
}
}
diff --git a/tests/shell/testcases/flowtable/dumps/0013addafterdelete_0.nft b/tests/shell/testcases/flowtable/dumps/0013addafterdelete_0.nft
index 67db7d029392..585f63b1b916 100644
--- a/tests/shell/testcases/flowtable/dumps/0013addafterdelete_0.nft
+++ b/tests/shell/testcases/flowtable/dumps/0013addafterdelete_0.nft
@@ -1,6 +1,6 @@
table inet filter {
flowtable f {
hook ingress priority filter - 1
- devices = { lo }
+ devices = { "lo" }
}
}
diff --git a/tests/shell/testcases/flowtable/dumps/0014addafterdelete_0.nft b/tests/shell/testcases/flowtable/dumps/0014addafterdelete_0.nft
index 145aa08153bc..12f97a75e2e5 100644
--- a/tests/shell/testcases/flowtable/dumps/0014addafterdelete_0.nft
+++ b/tests/shell/testcases/flowtable/dumps/0014addafterdelete_0.nft
@@ -1,7 +1,7 @@
table inet filter {
flowtable f {
hook ingress priority filter - 1
- devices = { lo }
+ devices = { "lo" }
counter
}
diff --git a/tests/shell/testcases/listing/0020flowtable_0 b/tests/shell/testcases/listing/0020flowtable_0
index 14b0c909a7eb..84f518970426 100755
--- a/tests/shell/testcases/listing/0020flowtable_0
+++ b/tests/shell/testcases/listing/0020flowtable_0
@@ -8,11 +8,11 @@ set -e
FLOWTABLES="flowtable f {
hook ingress priority filter
- devices = { lo }
+ devices = { \"lo\" }
}
flowtable f2 {
hook ingress priority filter
- devices = { d0 }
+ devices = { \"d0\" }
}"
RULESET="table inet filter {
@@ -25,23 +25,23 @@ table ip filter {
EXPECTED="table inet filter {
flowtable f {
hook ingress priority filter
- devices = { lo }
+ devices = { \"lo\" }
}
}"
EXPECTED2="table ip filter {
flowtable f2 {
hook ingress priority filter
- devices = { d0 }
+ devices = { \"d0\" }
}
}"
EXPECTED3="table ip filter {
flowtable f {
hook ingress priority filter
- devices = { lo }
+ devices = { \"lo\" }
}
flowtable f2 {
hook ingress priority filter
- devices = { d0 }
+ devices = { \"d0\" }
}
}"
diff --git a/tests/shell/testcases/listing/dumps/0020flowtable_0.nft b/tests/shell/testcases/listing/dumps/0020flowtable_0.nft
index 4a64e531db84..0962e73aff2c 100644
--- a/tests/shell/testcases/listing/dumps/0020flowtable_0.nft
+++ b/tests/shell/testcases/listing/dumps/0020flowtable_0.nft
@@ -1,7 +1,7 @@
table inet filter {
flowtable f {
hook ingress priority filter
- devices = { lo }
+ devices = { "lo" }
}
flowtable f2 {
@@ -11,7 +11,7 @@ table inet filter {
table ip filter {
flowtable f {
hook ingress priority filter
- devices = { lo }
+ devices = { "lo" }
}
flowtable f2 {
--
2.30.2
next reply other threads:[~2025-07-08 23:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-08 23:11 Pablo Neira Ayuso [this message]
2025-07-09 13:47 ` [PATCH nft] rule: print chain and flowtable devices in quotes Florian Westphal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250708231128.2045876-1-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.