Allow to use fib expression in set statements, eg. meta mark set ip saddr . fib daddr check map { 1.2.3.4 . exists : 0x00000001 } Fixes: 4a75ed32132d ("src: add fib expression") Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx> --- v2: no changes. src/parser_bison.y | 1 + src/parser_json.c | 2 +- tests/py/inet/fib.t | 2 ++ tests/py/inet/fib.t.json | 45 +++++++++++++++++++++++++++++++++++++ tests/py/inet/fib.t.payload | 8 +++++++ 5 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/parser_bison.y b/src/parser_bison.y index e1afbbb6e56e..f9cc909836bc 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -3873,6 +3873,7 @@ primary_stmt_expr : symbol_expr { $$ = $1; } | payload_expr { $$ = $1; } | keyword_expr { $$ = $1; } | socket_expr { $$ = $1; } + | fib_expr { $$ = $1; } | osf_expr { $$ = $1; } | '(' basic_stmt_expr ')' { $$ = $2; } ; diff --git a/src/parser_json.c b/src/parser_json.c index a8724a0c5af5..62e3a0cfd4f4 100644 --- a/src/parser_json.c +++ b/src/parser_json.c @@ -1627,7 +1627,7 @@ static struct expr *json_parse_expr(struct json_ctx *ctx, json_t *root) /* below two are hash expr */ { "jhash", json_parse_hash_expr, CTX_F_STMT | CTX_F_PRIMARY | CTX_F_SET_RHS | CTX_F_SES | CTX_F_MAP | CTX_F_CONCAT }, { "symhash", json_parse_hash_expr, CTX_F_STMT | CTX_F_PRIMARY | CTX_F_SET_RHS | CTX_F_SES | CTX_F_MAP | CTX_F_CONCAT }, - { "fib", json_parse_fib_expr, CTX_F_PRIMARY | CTX_F_SET_RHS | CTX_F_SES | CTX_F_MAP | CTX_F_CONCAT }, + { "fib", json_parse_fib_expr, CTX_F_STMT | CTX_F_PRIMARY | CTX_F_SET_RHS | CTX_F_SES | CTX_F_MAP | CTX_F_CONCAT }, { "|", json_parse_binop_expr, CTX_F_RHS | CTX_F_STMT | CTX_F_PRIMARY | CTX_F_SET_RHS | CTX_F_SES | CTX_F_MAP | CTX_F_CONCAT }, { "^", json_parse_binop_expr, CTX_F_RHS | CTX_F_STMT | CTX_F_PRIMARY | CTX_F_SET_RHS | CTX_F_SES | CTX_F_MAP | CTX_F_CONCAT }, { "&", json_parse_binop_expr, CTX_F_RHS | CTX_F_STMT | CTX_F_PRIMARY | CTX_F_SET_RHS | CTX_F_SES | CTX_F_MAP | CTX_F_CONCAT }, diff --git a/tests/py/inet/fib.t b/tests/py/inet/fib.t index f9c03b3ad2be..60b77a4ac00a 100644 --- a/tests/py/inet/fib.t +++ b/tests/py/inet/fib.t @@ -17,3 +17,5 @@ fib daddr check missing;ok fib daddr oif exists;ok;fib daddr check exists fib daddr check vmap { missing : drop, exists : accept };ok + +meta mark set fib daddr check . ct mark map { exists . 0x00000000 : 0x00000001 };ok diff --git a/tests/py/inet/fib.t.json b/tests/py/inet/fib.t.json index c2e9d4548a06..14a6249ad9b2 100644 --- a/tests/py/inet/fib.t.json +++ b/tests/py/inet/fib.t.json @@ -159,3 +159,48 @@ } } ] + +# meta mark set fib daddr check . ct mark map { exists . 0x00000000 : 0x00000001 } +[ + { + "mangle": { + "key": { + "meta": { + "key": "mark" + } + }, + "value": { + "map": { + "data": { + "set": [ + [ + { + "concat": [ + true, + 0 + ] + }, + 1 + ] + ] + }, + "key": { + "concat": [ + { + "fib": { + "flags": "daddr", + "result": "check" + } + }, + { + "ct": { + "key": "mark" + } + } + ] + } + } + } + } + } +] diff --git a/tests/py/inet/fib.t.payload b/tests/py/inet/fib.t.payload index e09a260cc41e..02d92b57a477 100644 --- a/tests/py/inet/fib.t.payload +++ b/tests/py/inet/fib.t.payload @@ -36,3 +36,11 @@ ip test-ip prerouting ip test-ip prerouting [ fib daddr oif present => reg 1 ] [ lookup reg 1 set __map%d dreg 0 ] + +# meta mark set fib daddr check . ct mark map { exists . 0x00000000 : 0x00000001 } + element 00000001 00000000 : 00000001 0 [end] +ip test-ip prerouting + [ fib daddr oif present => reg 1 ] + [ ct load mark => reg 9 ] + [ lookup reg 1 set __map%d dreg 1 ] + [ meta set mark with reg 1 ] -- 2.30.2