All of lore.kernel.org
 help / color / mirror / Atom feed
* [nft PATCH] xt: Fix fallback printing for extensions matching keywords
@ 2023-03-09 13:43 Phil Sutter
  2023-03-09 17:43 ` Pablo Neira Ayuso
  2023-03-10 11:46 ` Phil Sutter
  0 siblings, 2 replies; 3+ messages in thread
From: Phil Sutter @ 2023-03-09 13:43 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

Yet another Bison workaround: Instead of the fancy error message, an
incomprehensible syntax error is emitted:

| # iptables-nft -A FORWARD -p tcp -m osf --genre linux
| # nft list ruleset | nft -f -
| # Warning: table ip filter is managed by iptables-nft, do not touch!
| /dev/stdin:4:29-31: Error: syntax error, unexpected osf, expecting string
| 		meta l4proto tcp xt match osf counter packets 0 bytes 0
| 		                          ^^^

Avoid this by quoting the extension name when printing:

| # nft list ruleset | sudo ./src/nft -f -
| # Warning: table ip filter is managed by iptables-nft, do not touch!
| /dev/stdin:4:20-33: Error: unsupported xtables compat expression, use iptables-nft with this ruleset
| 		meta l4proto tcp xt match "osf" counter packets 0 bytes 0
| 		                 ^^^^^^^^^^^^^^

Fixes: 79195a8cc9e9d ("xt: Rewrite unsupported compat expression dumping")
Fixes: e41c53ca5b043 ("xt: Fall back to generic printing from translation")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 src/parser_bison.y | 2 +-
 src/xt.c           | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/parser_bison.y b/src/parser_bison.y
index 824e5db8ad90c..32f6b32268f49 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -2992,7 +2992,7 @@ stmt			:	verdict_stmt
 			|	xt_stmt		close_scope_xt
 			;
 
-xt_stmt			:	XT	STRING	STRING
+xt_stmt			:	XT	STRING	string
 			{
 				$$ = NULL;
 				xfree($2);
diff --git a/src/xt.c b/src/xt.c
index 2405d3c34773c..f63096a554e7f 100644
--- a/src/xt.c
+++ b/src/xt.c
@@ -116,7 +116,7 @@ void xt_stmt_xlate(const struct stmt *stmt, struct output_ctx *octx)
 	xfree(entry);
 #endif
 	if (!rc)
-		nft_print(octx, "xt %s %s",
+		nft_print(octx, "xt %s \"%s\"",
 			  typename[stmt->xt.type], stmt->xt.name);
 }
 
-- 
2.38.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [nft PATCH] xt: Fix fallback printing for extensions matching keywords
  2023-03-09 13:43 [nft PATCH] xt: Fix fallback printing for extensions matching keywords Phil Sutter
@ 2023-03-09 17:43 ` Pablo Neira Ayuso
  2023-03-10 11:46 ` Phil Sutter
  1 sibling, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2023-03-09 17:43 UTC (permalink / raw)
  To: Phil Sutter; +Cc: netfilter-devel

On Thu, Mar 09, 2023 at 02:43:50PM +0100, Phil Sutter wrote:
> Yet another Bison workaround: Instead of the fancy error message, an
> incomprehensible syntax error is emitted:
> 
> | # iptables-nft -A FORWARD -p tcp -m osf --genre linux
> | # nft list ruleset | nft -f -
> | # Warning: table ip filter is managed by iptables-nft, do not touch!
> | /dev/stdin:4:29-31: Error: syntax error, unexpected osf, expecting string
> | 		meta l4proto tcp xt match osf counter packets 0 bytes 0
> | 		                          ^^^
> 
> Avoid this by quoting the extension name when printing:
> 
> | # nft list ruleset | sudo ./src/nft -f -
> | # Warning: table ip filter is managed by iptables-nft, do not touch!
> | /dev/stdin:4:20-33: Error: unsupported xtables compat expression, use iptables-nft with this ruleset
> | 		meta l4proto tcp xt match "osf" counter packets 0 bytes 0
> | 		                 ^^^^^^^^^^^^^^


LGTM.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [nft PATCH] xt: Fix fallback printing for extensions matching keywords
  2023-03-09 13:43 [nft PATCH] xt: Fix fallback printing for extensions matching keywords Phil Sutter
  2023-03-09 17:43 ` Pablo Neira Ayuso
@ 2023-03-10 11:46 ` Phil Sutter
  1 sibling, 0 replies; 3+ messages in thread
From: Phil Sutter @ 2023-03-10 11:46 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

On Thu, Mar 09, 2023 at 02:43:50PM +0100, Phil Sutter wrote:
> Yet another Bison workaround: Instead of the fancy error message, an
> incomprehensible syntax error is emitted:
> 
> | # iptables-nft -A FORWARD -p tcp -m osf --genre linux
> | # nft list ruleset | nft -f -
> | # Warning: table ip filter is managed by iptables-nft, do not touch!
> | /dev/stdin:4:29-31: Error: syntax error, unexpected osf, expecting string
> | 		meta l4proto tcp xt match osf counter packets 0 bytes 0
> | 		                          ^^^
> 
> Avoid this by quoting the extension name when printing:
> 
> | # nft list ruleset | sudo ./src/nft -f -
> | # Warning: table ip filter is managed by iptables-nft, do not touch!
> | /dev/stdin:4:20-33: Error: unsupported xtables compat expression, use iptables-nft with this ruleset
> | 		meta l4proto tcp xt match "osf" counter packets 0 bytes 0
> | 		                 ^^^^^^^^^^^^^^
> 
> Fixes: 79195a8cc9e9d ("xt: Rewrite unsupported compat expression dumping")
> Fixes: e41c53ca5b043 ("xt: Fall back to generic printing from translation")
> Signed-off-by: Phil Sutter <phil@nwl.cc>

Patch applied.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-10 11:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-09 13:43 [nft PATCH] xt: Fix fallback printing for extensions matching keywords Phil Sutter
2023-03-09 17:43 ` Pablo Neira Ayuso
2023-03-10 11:46 ` Phil Sutter

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.