Skip to content

Commit 3a3edb2

Browse files
authored
Merge pull request #918 from dcaratti/gh189
mptcp: add support for MP_TCPRST
2 parents 5ff873f + 1ac4764 commit 3a3edb2

File tree

4 files changed

+49
-1
lines changed

4 files changed

+49
-1
lines changed

print-mptcp.c

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
#define MPTCP_SUB_PRIO 0x5
5757
#define MPTCP_SUB_FAIL 0x6
5858
#define MPTCP_SUB_FCLOSE 0x7
59+
#define MPTCP_SUB_TCPRST 0x8
5960

6061
struct mptcp_option {
6162
nd_uint8_t kind;
@@ -182,6 +183,32 @@ struct mp_prio {
182183

183184
#define MP_PRIO_B 0x01
184185

186+
static const struct tok mp_tcprst_flags[] = {
187+
{ 0x08, "U" },
188+
{ 0x04, "V" },
189+
{ 0x02, "W" },
190+
{ 0x01, "T" },
191+
{ 0, NULL }
192+
};
193+
194+
static const struct tok mp_tcprst_reasons[] = {
195+
{ 0x06, "Middlebox interference" },
196+
{ 0x05, "Unacceptable performance" },
197+
{ 0x04, "Too much outstanding data" },
198+
{ 0x03, "Administratively prohibited" },
199+
{ 0x02, "Lack of resources" },
200+
{ 0x01, "MPTCP-specific error" },
201+
{ 0x00, "Unspecified error" },
202+
{ 0, NULL }
203+
};
204+
205+
struct mp_tcprst {
206+
nd_uint8_t kind;
207+
nd_uint8_t len;
208+
nd_uint8_t sub_b;
209+
nd_uint8_t reason;
210+
};
211+
185212
static int
186213
dummy_print(netdissect_options *ndo _U_,
187214
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,
454481
return 1;
455482
}
456483

484+
static int
485+
mp_tcprst_print(netdissect_options *ndo,
486+
const u_char *opt, u_int opt_len, u_char flags _U_)
487+
{
488+
const struct mp_tcprst *mpr = (const struct mp_tcprst *)opt;
489+
490+
if (opt_len != 4)
491+
return 0;
492+
493+
ND_PRINT(" flags [%s]", bittok2str_nosep(mp_tcprst_flags, "none",
494+
GET_U_1(mpr->sub_b)));
495+
496+
ND_PRINT(" reason %s", tok2str(mp_tcprst_reasons, "unknown (0x%02x)",
497+
GET_U_1(mpr->reason)));
498+
return 1;
499+
}
500+
457501
static const struct {
458502
const char *name;
459503
int (*print)(netdissect_options *, const u_char *, u_int, u_char);
@@ -466,6 +510,7 @@ static const struct {
466510
{ "prio", mp_prio_print },
467511
{ "fail", mp_fail_print },
468512
{ "fast-close", mp_fast_close_print },
513+
{ "tcprst", mp_tcprst_print },
469514
{ "unknown", dummy_print },
470515
};
471516

@@ -482,7 +527,7 @@ mptcp_print(netdissect_options *ndo,
482527

483528
opt = (const struct mptcp_option *) cp;
484529
subtype = MPTCP_OPT_SUBTYPE(GET_U_1(opt->sub_etc));
485-
subtype = ND_MIN(subtype, MPTCP_SUB_FCLOSE + 1);
530+
subtype = ND_MIN(subtype, MPTCP_SUB_TCPRST + 1);
486531

487532
ND_PRINT(" %u", len);
488533

tests/TESTLIST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ mptcp-v1 mptcp-v1.pcap mptcp-v1.out
257257
mptcp-fclose mptcp-fclose.pcap mptcp-fclose.out
258258
mptcp-aa-v1 mptcp-aa-v1.pcap mptcp-aa-v1.out
259259
mptcp-aa-echo mptcp-aa-echo.pcap mptcp-aa-echo.out
260+
mptcp-tcprst mptcp-tcprst.pcap mptcp-tcprst.out
260261

261262
# TFO tests
262263
tfo tfo-5c1fa7f9ae91.pcap tfo.out

tests/mptcp-tcprst.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
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+
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

tests/mptcp-tcprst.pcap

144 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)