From cb04b97ecaf980bdf92ae0e23f55fe8791ce3e2b Mon Sep 17 00:00:00 2001 From: Richard Scheffenegger Date: Thu, 27 Jul 2023 23:30:24 +0200 Subject: [PATCH] mask tcp[tcpflags] with 0x0fff to provide tcp flags only --- grammar.y.in | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grammar.y.in b/grammar.y.in index c72f4e5521..999aa22d47 100644 --- a/grammar.y.in +++ b/grammar.y.in @@ -856,7 +856,10 @@ arth: pnum { CHECK_PTR_VAL(($$ = gen_loadi(cstate, $1))); } ; tcpflags: TCPFLAGS ; -narth: pname '[' tcpflags ']' { CHECK_PTR_VAL(($$ = gen_load(cstate, $1, gen_loadi(cstate, 12), 2))); } +narth: pname '[' tcpflags ']' { CHECK_PTR_VAL(($$ = + gen_arth(cstate, BPF_AND, + gen_load(cstate, $1, gen_loadi(cstate, 12), 2), + gen_loadi(cstate, 0x0FFF)))); } | pname '[' arth ']' { CHECK_PTR_VAL(($$ = gen_load(cstate, $1, $3, 1))); } | pname '[' arth ':' NUM ']' { CHECK_PTR_VAL(($$ = gen_load(cstate, $1, $3, $5))); } | arth '+' arth { CHECK_PTR_VAL(($$ = gen_arth(cstate, BPF_ADD, $1, $3))); }