Skip to contentSkip to conversation

rule: print chain and flowtable devices in quotes

PATCH In review Pablo Neira Ayuso 2 participants 2 messages Jul 8, 2025 – Jul 9, 2025 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 rule: print chain and flowtable devices in quotes

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")
---
 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(-)
src/rule.c +2 -2
index c0f7570e233c..3e3cc3b0fb7d 100644
@@ -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, ", ");
 		}
tests/shell/features/flowtable_counter.sh +1 -1
index a4c4c62124b0..5d47215f2f94 100755
@@ -6,7 +6,7 @@
 EXPECTED="table ip filter2 {
 	flowtable main_ft2 {
 		hook ingress priority filter
-		devices = { lo }
+		devices = { \"lo\" }
 		counter
 	}
 }"
tests/shell/testcases/chains/dumps/0042chain_variable_0.nft +2 -2
index 84a908d33dee..08a19014e7b8 100644
@@ -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 {
tests/shell/testcases/flowtable/dumps/0001flowtable_0.nft +1 -1
index 629bfe81cb18..79fa59130843 100644
@@ -1,7 +1,7 @@
 table inet t {
 	flowtable f {
 		hook ingress priority filter + 10
-		devices = { lo }
+		devices = { "lo" }
 	}
 
 	chain c {
tests/shell/testcases/flowtable/dumps/0002create_flowtable_0.nft +1 -1
index aecfb2ab25df..2d0ea905d8b9 100644
@@ -1,6 +1,6 @@
 table ip t {
 	flowtable f {
 		hook ingress priority filter + 10
-		devices = { lo }
+		devices = { "lo" }
 	}
 }
tests/shell/testcases/flowtable/dumps/0003add_after_flush_0.nft +1 -1
index dd904f449ca1..39de91b19a82 100644
@@ -1,6 +1,6 @@
 table ip x {
 	flowtable y {
 		hook ingress priority filter
-		devices = { lo }
+		devices = { "lo" }
 	}
 }
tests/shell/testcases/flowtable/dumps/0005delete_in_use_1.nft +1 -1
index c1d79e7b144d..b01b3027c50e 100644
@@ -1,7 +1,7 @@
 table ip x {
 	flowtable y {
 		hook ingress priority filter
-		devices = { lo }
+		devices = { "lo" }
 	}
 
 	chain x {
tests/shell/testcases/flowtable/dumps/0012flowtable_variable_0.nft +2 -2
index df1c51a24703..7863822d754b 100644
@@ -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
 	}
 }
tests/shell/testcases/flowtable/dumps/0013addafterdelete_0.nft +1 -1
index 67db7d029392..585f63b1b916 100644
@@ -1,6 +1,6 @@
 table inet filter {
 	flowtable f {
 		hook ingress priority filter - 1
-		devices = { lo }
+		devices = { "lo" }
 	}
 }
tests/shell/testcases/flowtable/dumps/0014addafterdelete_0.nft +1 -1
index 145aa08153bc..12f97a75e2e5 100644
@@ -1,7 +1,7 @@
 table inet filter {
 	flowtable f {
 		hook ingress priority filter - 1
-		devices = { lo }
+		devices = { "lo" }
 		counter
 	}
 
tests/shell/testcases/listing/0020flowtable_0 +6 -6
index 14b0c909a7eb..84f518970426 100755
@@ -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\" }
 	}
 }"
 
tests/shell/testcases/listing/dumps/0020flowtable_0.nft +2 -2
index 4a64e531db84..0962e73aff2c 100644
@@ -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 {
Signature · 1 line
2.30.2
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Pablo Neira Ayuso

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.

Thanks a lot Pablo. I checked tests/py and they still pass after this also.