It shares two keywords with PARSER_SC_IP. Signed-off-by: Phil Sutter <phil@xxxxxx> --- include/parser.h | 1 + src/parser_bison.y | 5 +++-- src/scanner.l | 13 +++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/parser.h b/include/parser.h index ab372ad0bae88..82402dbc54a70 100644 --- a/include/parser.h +++ b/include/parser.h @@ -51,6 +51,7 @@ enum startcond_type { PARSER_SC_EXPR_HASH, PARSER_SC_EXPR_IPSEC, PARSER_SC_EXPR_NUMGEN, + PARSER_SC_EXPR_OSF, PARSER_SC_EXPR_QUEUE, PARSER_SC_EXPR_RT, PARSER_SC_EXPR_SCTP_CHUNK, diff --git a/src/parser_bison.y b/src/parser_bison.y index adfaa460caf36..2deee99394999 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -943,6 +943,7 @@ close_scope_ipsec : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_IPSEC) close_scope_list : { scanner_pop_start_cond(nft->scanner, PARSER_SC_CMD_LIST); }; close_scope_limit : { scanner_pop_start_cond(nft->scanner, PARSER_SC_LIMIT); }; close_scope_numgen : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_NUMGEN); }; +close_scope_osf : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_OSF); }; close_scope_quota : { scanner_pop_start_cond(nft->scanner, PARSER_SC_QUOTA); }; close_scope_queue : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_QUEUE); }; close_scope_rt : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_RT); }; @@ -4104,11 +4105,11 @@ fib_tuple : fib_flag DOT fib_tuple | fib_flag ; -osf_expr : OSF osf_ttl HDRVERSION +osf_expr : OSF osf_ttl HDRVERSION close_scope_osf { $$ = osf_expr_alloc(&@$, $2, NFT_OSF_F_VERSION); } - | OSF osf_ttl NAME + | OSF osf_ttl NAME close_scope_osf { $$ = osf_expr_alloc(&@$, $2, 0); } diff --git a/src/scanner.l b/src/scanner.l index ed26811c5d906..65640ebbf40eb 100644 --- a/src/scanner.l +++ b/src/scanner.l @@ -217,6 +217,7 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr}) %s SCANSTATE_EXPR_HASH %s SCANSTATE_EXPR_IPSEC %s SCANSTATE_EXPR_NUMGEN +%s SCANSTATE_EXPR_OSF %s SCANSTATE_EXPR_QUEUE %s SCANSTATE_EXPR_RT %s SCANSTATE_EXPR_SCTP_CHUNK @@ -367,7 +368,7 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr}) } "counter" { scanner_push_start_cond(yyscanner, SCANSTATE_COUNTER); return COUNTER; } -"name" { return NAME; } +<SCANSTATE_COUNTER,SCANSTATE_LIMIT,SCANSTATE_QUOTA,SCANSTATE_STMT_SYNPROXY,SCANSTATE_EXPR_OSF>"name" { return NAME; } <SCANSTATE_COUNTER,SCANSTATE_CT,SCANSTATE_LIMIT>"packets" { return PACKETS; } <SCANSTATE_COUNTER,SCANSTATE_CT,SCANSTATE_LIMIT,SCANSTATE_QUOTA>"bytes" { return BYTES; } @@ -456,13 +457,17 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr}) } "ip" { scanner_push_start_cond(yyscanner, SCANSTATE_IP); return IP; } -"version" { return HDRVERSION; } +<SCANSTATE_IP,SCANSTATE_IP6,SCANSTATE_EXPR_OSF>{ + "version" { return HDRVERSION; } +} "hdrlength" { return HDRLENGTH; } "dscp" { return DSCP; } "ecn" { return ECN; } "length" { return LENGTH; } "frag-off" { return FRAG_OFF; } -"ttl" { return TTL; } +<SCANSTATE_EXPR_OSF,SCANSTATE_IP>{ + "ttl" { return TTL; } +} "protocol" { return PROTOCOL; } "checksum" { return CHECKSUM; } @@ -705,7 +710,7 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr}) "fib" { scanner_push_start_cond(yyscanner, SCANSTATE_EXPR_FIB); return FIB; } -"osf" { return OSF; } +"osf" { scanner_push_start_cond(yyscanner, SCANSTATE_EXPR_OSF); return OSF; } "synproxy" { scanner_push_start_cond(yyscanner, SCANSTATE_STMT_SYNPROXY); return SYNPROXY; } <SCANSTATE_STMT_SYNPROXY>{ -- 2.34.1