From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: kaber@trash.net
Subject: [PATCH 3/3 nft] parser: restore bitwise operations from the rhs of relational expressions
Date: Tue, 29 Dec 2015 21:09:15 +0100 [thread overview]
Message-ID: <1451419755-29997-3-git-send-email-pablo@netfilter.org> (raw)
In-Reply-To: <1451419755-29997-1-git-send-email-pablo@netfilter.org>
Reintroduce bitwise operation on constants that was removed in ("parser:
restrict relational rhs expression recursion") since we support this
since the beginning.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
src/parser_bison.y | 47 +++++++++++++++++++++++++++++++++++++++++------
1 file changed, 41 insertions(+), 6 deletions(-)
diff --git a/src/parser_bison.y b/src/parser_bison.y
index 9f75abe..af51e4d 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -514,8 +514,11 @@ static void location_update(struct location *loc, struct location *rhs, int n)
%type <expr> rhs_expr concat_rhs_expr basic_rhs_expr
%destructor { expr_free($$); } rhs_expr concat_rhs_expr basic_rhs_expr
-%type <expr> primary_rhs_expr list_rhs_expr
-%destructor { expr_free($$); } primary_rhs_expr list_rhs_expr
+%type <expr> primary_rhs_expr list_rhs_expr shift_rhs_expr
+%destructor { expr_free($$); } primary_rhs_expr list_rhs_expr shift_rhs_expr
+%type <expr> and_rhs_expr exclusive_or_rhs_expr inclusive_or_rhs_expr
+%destructor { expr_free($$); } and_rhs_expr exclusive_or_rhs_expr inclusive_or_rhs_expr
+
%type <expr> relational_expr
%destructor { expr_free($$); } relational_expr
@@ -2010,7 +2013,42 @@ rhs_expr : concat_rhs_expr { $$ = $1; }
| set_expr { $$ = $1; }
;
-concat_rhs_expr : basic_rhs_expr { $$ = $1; }
+shift_rhs_expr : primary_rhs_expr
+ | shift_rhs_expr LSHIFT primary_rhs_expr
+ {
+ $$ = binop_expr_alloc(&@$, OP_LSHIFT, $1, $3);
+ }
+ | shift_rhs_expr RSHIFT primary_rhs_expr
+ {
+ $$ = binop_expr_alloc(&@$, OP_RSHIFT, $1, $3);
+ }
+ ;
+
+and_rhs_expr : shift_rhs_expr
+ | and_rhs_expr AMPERSAND shift_rhs_expr
+ {
+ $$ = binop_expr_alloc(&@$, OP_AND, $1, $3);
+ }
+ ;
+
+exclusive_or_rhs_expr : and_rhs_expr
+ | exclusive_or_rhs_expr CARET and_rhs_expr
+ {
+ $$ = binop_expr_alloc(&@$, OP_XOR, $1, $3);
+ }
+ ;
+
+inclusive_or_rhs_expr : exclusive_or_rhs_expr
+ | inclusive_or_rhs_expr '|' exclusive_or_rhs_expr
+ {
+ $$ = binop_expr_alloc(&@$, OP_OR, $1, $3);
+ }
+ ;
+
+basic_rhs_expr : inclusive_or_rhs_expr
+ ;
+
+concat_rhs_expr : basic_rhs_expr
| concat_rhs_expr DOT basic_rhs_expr
{
if ($$->ops->type != EXPR_CONCAT) {
@@ -2030,9 +2068,6 @@ concat_rhs_expr : basic_rhs_expr { $$ = $1; }
}
;
-basic_rhs_expr : primary_rhs_expr { $$ = $1; }
- ;
-
primary_rhs_expr : symbol_expr { $$ = $1; }
| integer_expr { $$ = $1; }
| ETHER
--
2.1.4
next prev parent reply other threads:[~2015-12-29 20:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-29 20:09 [PATCH 1/3 nft] parser: get rid of multiton_expr from lhs relational expression Pablo Neira Ayuso
2015-12-29 20:09 ` [PATCH 2/3 nft] parser: rename multiton_expr to multiton_rhs_expr Pablo Neira Ayuso
2015-12-29 20:09 ` Pablo Neira Ayuso [this message]
2016-01-04 22:48 ` [PATCH 1/3 nft] parser: get rid of multiton_expr from lhs relational expression Patrick McHardy
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=1451419755-29997-3-git-send-email-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=kaber@trash.net \
--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).