From: Phil Sutter <phil@nwl.cc>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: [nft PATCH v2] parser_bison: Accept arbitrary user-defined names by quoting
Date: Mon, 24 Jun 2019 18:36:08 +0200 [thread overview]
Message-ID: <20190624163608.17348-1-phil@nwl.cc> (raw)
Parser already allows to quote user-defined strings in some places to
avoid clashing with defined keywords, but not everywhere. Extend this
support further and add a test case for it.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
Changes since v1:
- Fix testcase, I forgot to commit adjustments done to it.
Note: This is a reduced variant of "src: Quote user-defined names" sent
back in January. Discussion was not conclusive regarding whether
to quote these names on output or not, but I assume allowing for
users to specify them by adding quotes is a step forward without
drawbacks.
---
src/parser_bison.y | 3 ++-
.../shell/testcases/nft-f/0018quoted-names_0 | 20 +++++++++++++++++++
2 files changed, 22 insertions(+), 1 deletion(-)
create mode 100755 tests/shell/testcases/nft-f/0018quoted-names_0
diff --git a/src/parser_bison.y b/src/parser_bison.y
index 670e91f544c75..de8b097a4c222 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -1761,7 +1761,7 @@ flowtable_list_expr : flowtable_expr_member
| flowtable_list_expr COMMA opt_newline
;
-flowtable_expr_member : STRING
+flowtable_expr_member : string
{
$$ = symbol_expr_alloc(&@$, SYMBOL_VALUE,
current_scope(state),
@@ -1968,6 +1968,7 @@ chain_policy : ACCEPT { $$ = NF_ACCEPT; }
;
identifier : STRING
+ | QUOTED_STRING
;
string : STRING
diff --git a/tests/shell/testcases/nft-f/0018quoted-names_0 b/tests/shell/testcases/nft-f/0018quoted-names_0
new file mode 100755
index 0000000000000..6526d66b8e8a1
--- /dev/null
+++ b/tests/shell/testcases/nft-f/0018quoted-names_0
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+# Test if keywords are allowed as names if quoted
+
+set -e
+
+RULESET='
+table inet "day" {
+ chain "minute" {}
+ set "hour" { type inet_service; }
+ flowtable "second" { hook ingress priority 0; devices = { "lo" }; }
+ counter "table" { packets 0 bytes 0 }
+ quota "chain" { 10 bytes }
+}'
+
+$NFT -f - <<< "$RULESET"
+
+# XXX: not possible (yet)
+#OUTPUT=$($NFT list ruleset)
+#$NFT -f - <<< "$OUTPUT"
--
2.21.0
next reply other threads:[~2019-06-24 16:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-24 16:36 Phil Sutter [this message]
2019-06-28 18:00 ` [nft PATCH v2] parser_bison: Accept arbitrary user-defined names by quoting Pablo Neira Ayuso
2019-07-01 16:11 ` Phil Sutter
2019-07-01 18:13 ` Pablo Neira Ayuso
2019-07-01 18:19 ` Pablo Neira Ayuso
2019-07-01 21:47 ` Phil Sutter
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=20190624163608.17348-1-phil@nwl.cc \
--to=phil@nwl.cc \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).