netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* nftables: parser conflict between tokens & symbols
@ 2015-06-26 12:44 Balazs Scheidler
  2015-06-29 14:57 ` Florian Westphal
  2015-06-29 18:03 ` Pablo Neira Ayuso
  0 siblings, 2 replies; 5+ messages in thread
From: Balazs Scheidler @ 2015-06-26 12:44 UTC (permalink / raw)
  To: netfilter-devel

Hi,

I've noticed that our set of keywords in nftables is pretty rich and
this can cause conflicts in the grammar when a keyword is also used
as a symbol.

For instance, we do have a "redirect" expression and "redirect" as
a word is also used as an ICMP message type.

# here is the redirect expression in action, which works:
$ nft add rule tcp dport 80 redirect to 8080

# here's an ICMP rule that works
$ nft add rule filter input icmp type echo-request accept

# here's an ICMP rule that should work, but it doesn't
$ nft add rule filter input icmp type redirect accept

The root cause is that "redirect" is now recognized as a token, whereas the
icmp type is expecting a STRING token.

I have tried to solve this but the idea I had didn't work out, and I don't
really have more time now to fix it, but still thought this information
would be useful.

Cheers,
Bazsi

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

* Re: nftables: parser conflict between tokens & symbols
  2015-06-26 12:44 nftables: parser conflict between tokens & symbols Balazs Scheidler
@ 2015-06-29 14:57 ` Florian Westphal
  2015-06-29 18:09   ` Pablo Neira Ayuso
  2015-06-29 18:03 ` Pablo Neira Ayuso
  1 sibling, 1 reply; 5+ messages in thread
From: Florian Westphal @ 2015-06-29 14:57 UTC (permalink / raw)
  To: Balazs Scheidler; +Cc: netfilter-devel

Balazs Scheidler <balazs.scheidler@balabit.com> wrote:
> I've noticed that our set of keywords in nftables is pretty rich and
> this can cause conflicts in the grammar when a keyword is also used
> as a symbol.
> For instance, we do have a "redirect" expression and "redirect" as
> a word is also used as an ICMP message type.
> 
> # here is the redirect expression in action, which works:
> $ nft add rule tcp dport 80 redirect to 8080
> 
> # here's an ICMP rule that works
> $ nft add rule filter input icmp type echo-request accept
> 
> # here's an ICMP rule that should work, but it doesn't
> $ nft add rule filter input icmp type redirect accept
> 
> The root cause is that "redirect" is now recognized as a token, whereas the
> icmp type is expecting a STRING token.

While we're at it, there are other issues, f.e.:

ct label saddr
ct label == saddr

won't work since saddr is considered to be the SADDR token.
Similar issues for other places where we accept arbitrary symbol names.

I think the above might be fixable via

|       CT      ct_key  error
{
	yychar = STRING;
...

But of course that won't fix up all cases, e.g.
ct label == saddr would still not work since we encounter
the error (unexpected token) after a relational expression.

Does anyone have better ideas other than plastering parser with error
handlers...?

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

* Re: nftables: parser conflict between tokens & symbols
  2015-06-26 12:44 nftables: parser conflict between tokens & symbols Balazs Scheidler
  2015-06-29 14:57 ` Florian Westphal
@ 2015-06-29 18:03 ` Pablo Neira Ayuso
  1 sibling, 0 replies; 5+ messages in thread
From: Pablo Neira Ayuso @ 2015-06-29 18:03 UTC (permalink / raw)
  To: Balazs Scheidler; +Cc: netfilter-devel

On Fri, Jun 26, 2015 at 02:44:23PM +0200, Balazs Scheidler wrote:
> Hi,
> 
> I've noticed that our set of keywords in nftables is pretty rich and
> this can cause conflicts in the grammar when a keyword is also used
> as a symbol.
> 
> For instance, we do have a "redirect" expression and "redirect" as
> a word is also used as an ICMP message type.
> 
> # here is the redirect expression in action, which works:
> $ nft add rule tcp dport 80 redirect to 8080
> 
> # here's an ICMP rule that works
> $ nft add rule filter input icmp type echo-request accept
> 
> # here's an ICMP rule that should work, but it doesn't
> $ nft add rule filter input icmp type redirect accept
> 
> The root cause is that "redirect" is now recognized as a token, whereas the
> icmp type is expecting a STRING token.
> 
> I have tried to solve this but the idea I had didn't work out, and I don't
> really have more time now to fix it, but still thought this information
> would be useful.

The problem is known, the test infrastructure is catching this among
other existing problems. You can also file a bug to bugzilla if this
doesn't exist already so we can track this.

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

* Re: nftables: parser conflict between tokens & symbols
  2015-06-29 14:57 ` Florian Westphal
@ 2015-06-29 18:09   ` Pablo Neira Ayuso
  2015-06-29 18:15     ` Patrick McHardy
  0 siblings, 1 reply; 5+ messages in thread
From: Pablo Neira Ayuso @ 2015-06-29 18:09 UTC (permalink / raw)
  To: Florian Westphal; +Cc: Balazs Scheidler, netfilter-devel, kaber

On Mon, Jun 29, 2015 at 04:57:25PM +0200, Florian Westphal wrote:
> While we're at it, there are other issues, f.e.:
> 
> ct label saddr
> ct label == saddr
> 
> won't work since saddr is considered to be the SADDR token.

I don't think we're searching for such a flexibility in the grammar at
this stage.

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

* Re: nftables: parser conflict between tokens & symbols
  2015-06-29 18:09   ` Pablo Neira Ayuso
@ 2015-06-29 18:15     ` Patrick McHardy
  0 siblings, 0 replies; 5+ messages in thread
From: Patrick McHardy @ 2015-06-29 18:15 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Florian Westphal; +Cc: Balazs Scheidler, netfilter-devel



Am 29. Juni 2015 20:09:29 MESZ, schrieb Pablo Neira Ayuso <pablo@netfilter.org>:
>On Mon, Jun 29, 2015 at 04:57:25PM +0200, Florian Westphal wrote:
>> While we're at it, there are other issues, f.e.:
>> 
>> ct label saddr
>> ct label == saddr
>> 
>> won't work since saddr is considered to be the SADDR token.
>
>I don't think we're searching for such a flexibility in the grammar at
>this stage.

I know how to fix this once and for all by splitting the expression rules into non-const LHS and const RHS parts. This will unfortunately require to duplicate a lot of the productions.

I'll try to put something together during the next days.


-- 
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.

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

end of thread, other threads:[~2015-06-29 18:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-26 12:44 nftables: parser conflict between tokens & symbols Balazs Scheidler
2015-06-29 14:57 ` Florian Westphal
2015-06-29 18:09   ` Pablo Neira Ayuso
2015-06-29 18:15     ` Patrick McHardy
2015-06-29 18:03 ` Pablo Neira Ayuso

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).