From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH nftables] parser_bison: add shortcut syntax for matching flags without binary operations
Date: Thu, 13 May 2021 02:43:48 +0200 [thread overview]
Message-ID: <20210513004348.23640-1-pablo@netfilter.org> (raw)
This patch adds the following shortcut syntax:
expression flags / flags
instead of:
expression and flags == flags
For example:
tcp flags syn,ack / syn,ack,fin,rst
^^^^^^^ ^^^^^^^^^^^^^^^
value mask
instead of:
tcp flags and (syn|ack|fin|rst) == syn|ack
The second list of comma-separated flags represents the mask which are
examined and the first list of comma-separated flags must be set.
You can also use the != operator with this syntax:
tcp flags != fin,rst / syn,ack,fin,rst
This short is based on the prefix notation, but it is also similar to
the iptables tcp matching syntax.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
netlink delinearize code update to list this new syntax is missing in
this patch.
src/parser_bison.y | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/src/parser_bison.y b/src/parser_bison.y
index b50b60649d2e..0747601e551d 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -4469,6 +4469,34 @@ relational_expr : expr /* implicit */ rhs_expr
{
$$ = relational_expr_alloc(&@$, OP_IMPLICIT, $1, $2);
}
+ | expr /* implicit */ basic_rhs_expr SLASH list_rhs_expr
+ {
+ struct expr *expr;
+
+ expr = binop_expr_alloc(&@$, OP_AND, $1, $4);
+ $$ = relational_expr_alloc(&@$, OP_EQ, expr, $2);
+ }
+ | expr /* implicit */ list_rhs_expr SLASH list_rhs_expr
+ {
+ struct expr *expr;
+
+ expr = binop_expr_alloc(&@$, OP_AND, $1, $4);
+ $$ = relational_expr_alloc(&@$, OP_EQ, expr, $2);
+ }
+ | expr relational_op basic_rhs_expr SLASH list_rhs_expr
+ {
+ struct expr *expr;
+
+ expr = binop_expr_alloc(&@$, OP_AND, $1, $5);
+ $$ = relational_expr_alloc(&@$, $2, expr, $3);
+ }
+ | expr relational_op list_rhs_expr SLASH list_rhs_expr
+ {
+ struct expr *expr;
+
+ expr = binop_expr_alloc(&@$, OP_AND, $1, $5);
+ $$ = relational_expr_alloc(&@$, $2, expr, $3);
+ }
| expr relational_op rhs_expr
{
$$ = relational_expr_alloc(&@2, $2, $1, $3);
--
2.20.1
reply other threads:[~2021-05-13 0:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210513004348.23640-1-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=netfilter-devel@vger.kernel.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).