]> git.ipfire.org Git - thirdparty/nftables.git/commit
parser: evaluate commands immediately after parsing
authorPatrick McHardy <kaber@trash.net>
Tue, 4 Feb 2014 08:09:27 +0000 (08:09 +0000)
committerPatrick McHardy <kaber@trash.net>
Tue, 4 Feb 2014 08:17:47 +0000 (08:17 +0000)
commit61236968b7a1b4a4986f9a5c9a5e46d3eb70b799
tree49cbec37c5e2bc8e1f748d2ae1626af6c1e7df90
parentf3129a3cc4800321ed2157eb400da8b43398606e
parser: evaluate commands immediately after parsing

We currently do parsing and evaluation in two seperate stages. This means
that if any error occurs during parsing, we won't evaluate the syntactical
correct commands and detect possible evaluation errors in them.

In order to improve error reporting, change this to evaluate every command
as soon as it is fully parsed.

With this in place, the ruleset can be fully validated and all errors
reported in one step:

tests/error.1:6:23-23: Error: syntax error, unexpected newline
filter input tcp dport
                      ^
tests/error.1:7:24-26: Error: datatype mismatch, expected internet network service, expression has type Internet protocol
filter input tcp dport tcp
             ~~~~~~~~~ ^^^
tests/error.1:8:24-32: Error: Right hand side of relational expression (==) must be constant
filter input tcp dport tcp dport
             ~~~~~~~~~~^^^^^^^^^

Signed-off-by: Patrick McHardy <kaber@trash.net>
include/parser.h
include/rule.h
src/evaluate.c
src/main.c
src/parser.y