From: Florian Westphal <fw@strlen.de>
To: <netfilter-devel@vger.kernel.org>
Cc: Florian Westphal <fw@strlen.de>
Subject: [PATCH nft 6/8] mptcp: add subtype matching
Date: Fri, 19 Nov 2021 16:28:45 +0100 [thread overview]
Message-ID: <20211119152847.18118-7-fw@strlen.de> (raw)
In-Reply-To: <20211119152847.18118-1-fw@strlen.de>
MPTCP multiplexes the various mptcp signalling data using the
first 4 bits of the mptcp option.
This allows to match on the mptcp subtype via:
tcp option mptcp subtype 1
This misses delinearization support. mptcp subtype is the first tcp
option field that has a length of less than one byte.
Serialization processing will add a binop for this, but netlink
delinearization can't remove them, yet.
Also misses a new datatype/symbol table to allow to use mnemonics like
'mp_join' instead of raw numbers.
For this reason, no tests are added yet.
Signed-off-by: Florian Westphal <fw@strlen.de>
---
include/tcpopt.h | 1 +
src/parser_bison.y | 11 ++++++++++-
src/scanner.l | 1 +
src/tcpopt.c | 1 +
4 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/include/tcpopt.h b/include/tcpopt.h
index 22df69dc5b93..bb5c1329018e 100644
--- a/include/tcpopt.h
+++ b/include/tcpopt.h
@@ -77,6 +77,7 @@ enum tcpopt_hdr_field_sack {
enum tcpopt_hdr_mptcp_common {
TCPOPT_MPTCP_KIND,
TCPOPT_MPTCP_LENGTH,
+ TCPOPT_MPTCP_SUBTYPE,
};
extern const struct exthdr_desc *tcpopt_protocols[__TCPOPT_KIND_MAX];
diff --git a/src/parser_bison.y b/src/parser_bison.y
index a6a591b7e00d..355758e1befb 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -424,6 +424,7 @@ int nft_lex(void *, void *, void *);
%token RIGHT "right"
%token TSVAL "tsval"
%token TSECR "tsecr"
+%token SUBTYPE "subtype"
%token DCCP "dccp"
@@ -882,7 +883,7 @@ int nft_lex(void *, void *, void *);
%type <val> tcp_hdr_field
%type <val> tcp_hdr_option_type
%type <val> tcp_hdr_option_sack
-%type <val> tcpopt_field_maxseg tcpopt_field_sack tcpopt_field_tsopt tcpopt_field_window
+%type <val> tcpopt_field_maxseg tcpopt_field_mptcp tcpopt_field_sack tcpopt_field_tsopt tcpopt_field_window
%type <tcp_kind_field> tcp_hdr_option_kind_and_field
%type <expr> boolean_expr
@@ -5540,6 +5541,11 @@ tcp_hdr_option_kind_and_field : MSS tcpopt_field_maxseg
struct tcp_kind_field kind_field = { .kind = $1, .field = TCPOPT_COMMON_LENGTH };
$$ = kind_field;
}
+ | MPTCP tcpopt_field_mptcp
+ {
+ struct tcp_kind_field kind_field = { .kind = TCPOPT_KIND_MPTCP, .field = $2 };
+ $$ = kind_field;
+ }
;
tcp_hdr_option_sack : SACK { $$ = TCPOPT_KIND_SACK; }
@@ -5583,6 +5589,9 @@ tcpopt_field_tsopt : TSVAL { $$ = TCPOPT_TS_TSVAL; }
tcpopt_field_maxseg : SIZE { $$ = TCPOPT_MAXSEG_SIZE; }
;
+tcpopt_field_mptcp : SUBTYPE { $$ = TCPOPT_MPTCP_SUBTYPE; }
+ ;
+
dccp_hdr_expr : DCCP dccp_hdr_field
{
$$ = payload_expr_alloc(&@$, &proto_dccp, $2);
diff --git a/src/scanner.l b/src/scanner.l
index c65d57846c59..f28bf3153f0b 100644
--- a/src/scanner.l
+++ b/src/scanner.l
@@ -472,6 +472,7 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr})
"fastopen" { return FASTOPEN; }
"mptcp" { return MPTCP; }
"md5sig" { return MD5SIG; }
+"subtype" { return SUBTYPE; }
"nop" { return NOP; }
"noop" { return NOP; }
"sack" { return SACK; }
diff --git a/src/tcpopt.c b/src/tcpopt.c
index 5913cd065d03..641daa7359a3 100644
--- a/src/tcpopt.c
+++ b/src/tcpopt.c
@@ -116,6 +116,7 @@ static const struct exthdr_desc tcpopt_mptcp = {
.templates = {
[TCPOPT_MPTCP_KIND] = PHT("kind", 0, 8),
[TCPOPT_MPTCP_LENGTH] = PHT("length", 8, 8),
+ [TCPOPT_MPTCP_SUBTYPE] = PHT("subtype", 16, 4),
},
};
#undef PHT
--
2.32.0
next prev parent reply other threads:[~2021-11-19 15:29 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-19 15:28 [PATCH nft 0/8] mptcp subtype option match support Florian Westphal
2021-11-19 15:28 ` [PATCH nft 1/8] tcpopt: remove KIND keyword Florian Westphal
2021-11-19 15:28 ` [PATCH nft 2/8] scanner: add tcp flex scope Florian Westphal
2021-11-19 15:28 ` [PATCH nft 3/8] parser: split tcp option rules Florian Westphal
2021-11-19 15:28 ` [PATCH nft 4/8] tcpopt: add md5sig, fastopen and mptcp options Florian Westphal
2021-11-19 15:28 ` [PATCH nft 5/8] tests: py: add test cases for md5sig, fastopen and mptcp mnemonics Florian Westphal
2021-11-19 15:28 ` Florian Westphal [this message]
2021-11-19 15:28 ` [PATCH nft 7/8] exthdr: fix tcpopt_find_template to use length after mask adjustment Florian Westphal
2021-11-19 15:28 ` [PATCH nft 8/8] tests: py: add tcp subtype match test cases Florian Westphal
2021-11-23 13:16 ` [PATCH nft 0/8] mptcp subtype option match support Pablo Neira Ayuso
2021-11-23 13:37 ` Florian Westphal
2021-11-30 21:45 ` Pablo Neira Ayuso
2021-12-01 11:30 ` Florian Westphal
2021-12-02 21:42 ` Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211119152847.18118-7-fw@strlen.de \
--to=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox