diff options
author | Florian Westphal <fw@strlen.de> | 2020-11-02 15:22:40 +0100 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2020-11-09 12:19:31 +0100 |
commit | 2e1f821d713aa44717b38901ee80cac8e2aa0335 (patch) | |
tree | 4f9fbf0959b49a58ec5499005f68d3a74e15ddff /src/parser_bison.y | |
parent | 8f591eba561aceeef605283c693b659a708d1cd3 (diff) |
tcpopt: split tcpopt_hdr_fields into per-option enum
Currently we're limited to ten template fields in exthdr_desc struct.
Using a single enum for all tpc option fields thus won't work
indefinitely (TCPOPTHDR_FIELD_TSECR is 9) when new option templates get
added.
Fortunately we can just use one enum per tcp option to avoid this.
As a side effect this also allows to simplify the sack offset
calculations. Rather than computing that on-the-fly, just add extra
fields to the SACK template.
expr->exthdr.offset now holds the 'raw' value, filled in from the option
template. This would ease implementation of 'raw option matching'
using offset and length to load from the option.
Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'src/parser_bison.y')
-rw-r--r-- | src/parser_bison.y | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/parser_bison.y b/src/parser_bison.y index fcbfb40d..7dedbd25 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -5195,7 +5195,7 @@ tcp_hdr_expr : TCP tcp_hdr_field } | TCP OPTION tcp_hdr_option_type { - $$ = tcpopt_expr_alloc(&@$, $3, TCPOPTHDR_FIELD_KIND); + $$ = tcpopt_expr_alloc(&@$, $3, TCPOPT_COMMON_KIND); $$->exthdr.flags = NFT_EXTHDR_F_PRESENT; } ; @@ -5226,14 +5226,14 @@ tcp_hdr_option_type : EOL { $$ = TCPOPT_KIND_EOL; } | TIMESTAMP { $$ = TCPOPT_KIND_TIMESTAMP; } ; -tcp_hdr_option_field : KIND { $$ = TCPOPTHDR_FIELD_KIND; } - | LENGTH { $$ = TCPOPTHDR_FIELD_LENGTH; } - | SIZE { $$ = TCPOPTHDR_FIELD_SIZE; } - | COUNT { $$ = TCPOPTHDR_FIELD_COUNT; } - | LEFT { $$ = TCPOPTHDR_FIELD_LEFT; } - | RIGHT { $$ = TCPOPTHDR_FIELD_RIGHT; } - | TSVAL { $$ = TCPOPTHDR_FIELD_TSVAL; } - | TSECR { $$ = TCPOPTHDR_FIELD_TSECR; } +tcp_hdr_option_field : KIND { $$ = TCPOPT_COMMON_KIND; } + | LENGTH { $$ = TCPOPT_COMMON_LENGTH; } + | SIZE { $$ = TCPOPT_MAXSEG_SIZE; } + | COUNT { $$ = TCPOPT_WINDOW_COUNT; } + | LEFT { $$ = TCPOPT_SACK_LEFT; } + | RIGHT { $$ = TCPOPT_SACK_RIGHT; } + | TSVAL { $$ = TCPOPT_TS_TSVAL; } + | TSECR { $$ = TCPOPT_TS_TSECR; } ; dccp_hdr_expr : DCCP dccp_hdr_field |