From 2e1f821d713aa44717b38901ee80cac8e2aa0335 Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Mon, 2 Nov 2020 15:22:40 +0100 Subject: 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 --- src/parser_bison.y | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/parser_bison.y') 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 -- cgit v1.2.3