]> The Tcpdump Group git mirrors - tcpdump/commitdiff
mptcp: add support for MP_TCPRST 918/head
authorDavide Caratti <[email protected]>
Fri, 7 May 2021 13:42:53 +0000 (15:42 +0200)
committerDavide Caratti <[email protected]>
Mon, 12 Jul 2021 08:51:58 +0000 (10:51 +0200)
dissect the MP_TCPRST sub-option in accordance to RFC8684 ยง3.6.

Link: https://github.com/multipath-tcp/mptcp_net-next/issues/189
Signed-off-by: Davide Caratti <[email protected]>
print-mptcp.c
tests/TESTLIST
tests/mptcp-tcprst.out [new file with mode: 0644]
tests/mptcp-tcprst.pcap [new file with mode: 0644]

index 6697b88424678c07c1485cc5d7bb130ccc57a9e7..b8af92db0a4d6b199ad08ecf4f37382c85978d22 100644 (file)
@@ -56,6 +56,7 @@
 #define MPTCP_SUB_PRIO          0x5
 #define MPTCP_SUB_FAIL          0x6
 #define MPTCP_SUB_FCLOSE        0x7
+#define MPTCP_SUB_TCPRST        0x8
 
 struct mptcp_option {
         nd_uint8_t     kind;
@@ -182,6 +183,32 @@ struct mp_prio {
 
 #define MP_PRIO_B                       0x01
 
+static const struct tok mp_tcprst_flags[] = {
+        { 0x08, "U" },
+        { 0x04, "V" },
+        { 0x02, "W" },
+        { 0x01, "T" },
+        { 0, NULL }
+};
+
+static const struct tok mp_tcprst_reasons[] = {
+        { 0x06, "Middlebox interference" },
+        { 0x05, "Unacceptable performance" },
+        { 0x04, "Too much outstanding data" },
+        { 0x03, "Administratively prohibited" },
+        { 0x02, "Lack of resources" },
+        { 0x01, "MPTCP-specific error" },
+        { 0x00, "Unspecified error" },
+        { 0, NULL }
+};
+
+struct mp_tcprst {
+        nd_uint8_t     kind;
+        nd_uint8_t     len;
+        nd_uint8_t     sub_b;
+        nd_uint8_t     reason;
+};
+
 static int
 dummy_print(netdissect_options *ndo _U_,
             const u_char *opt _U_, u_int opt_len _U_, u_char flags _U_)
@@ -454,6 +481,23 @@ mp_fast_close_print(netdissect_options *ndo,
         return 1;
 }
 
+static int
+mp_tcprst_print(netdissect_options *ndo,
+                const u_char *opt, u_int opt_len, u_char flags _U_)
+{
+        const struct mp_tcprst *mpr = (const struct mp_tcprst *)opt;
+
+        if (opt_len != 4)
+                return 0;
+
+        ND_PRINT(" flags [%s]", bittok2str_nosep(mp_tcprst_flags, "none",
+                 GET_U_1(mpr->sub_b)));
+
+        ND_PRINT(" reason %s", tok2str(mp_tcprst_reasons, "unknown (0x%02x)",
+                 GET_U_1(mpr->reason)));
+        return 1;
+}
+
 static const struct {
         const char *name;
         int (*print)(netdissect_options *, const u_char *, u_int, u_char);
@@ -466,6 +510,7 @@ static const struct {
         { "prio",       mp_prio_print },
         { "fail",       mp_fail_print },
         { "fast-close", mp_fast_close_print },
+        { "tcprst",     mp_tcprst_print },
         { "unknown",    dummy_print },
 };
 
@@ -482,7 +527,7 @@ mptcp_print(netdissect_options *ndo,
 
         opt = (const struct mptcp_option *) cp;
         subtype = MPTCP_OPT_SUBTYPE(GET_U_1(opt->sub_etc));
-        subtype = ND_MIN(subtype, MPTCP_SUB_FCLOSE + 1);
+        subtype = ND_MIN(subtype, MPTCP_SUB_TCPRST + 1);
 
         ND_PRINT(" %u", len);
 
index 1994335e678a8724e4272c5b8e9e6629e7007f51..05a326e446f3c29d9471eceab93d028af155d3b8 100644 (file)
@@ -257,6 +257,7 @@ mptcp-v1    mptcp-v1.pcap           mptcp-v1.out
 mptcp-fclose   mptcp-fclose.pcap       mptcp-fclose.out
 mptcp-aa-v1    mptcp-aa-v1.pcap        mptcp-aa-v1.out
 mptcp-aa-echo  mptcp-aa-echo.pcap      mptcp-aa-echo.out
+mptcp-tcprst   mptcp-tcprst.pcap       mptcp-tcprst.out
 
 # TFO tests
 tfo            tfo-5c1fa7f9ae91.pcap   tfo.out
diff --git a/tests/mptcp-tcprst.out b/tests/mptcp-tcprst.out
new file mode 100644 (file)
index 0000000..ef8c8e9
--- /dev/null
@@ -0,0 +1,2 @@
+    1  14:27:19.175792 IP 192.0.2.1.55739 > 192.168.76.28.8080: Flags [R.], seq 1, ack 2176696966, win 256, options [mptcp 4 tcprst flags [none] reason Unspecified error], length 0
+    2  14:27:19.175964 IP 192.0.2.1.55739 > 192.168.76.28.8080: Flags [R.], seq 0, ack 1, win 256, options [mptcp 4 tcprst flags [T] reason MPTCP-specific error], length 0
diff --git a/tests/mptcp-tcprst.pcap b/tests/mptcp-tcprst.pcap
new file mode 100644 (file)
index 0000000..f5e78c0
Binary files /dev/null and b/tests/mptcp-tcprst.pcap differ