Skip to content

Commit

Permalink
mp_reset: add test cases
Browse files Browse the repository at this point in the history
mp_reset_multi_v4.pkt - check we can reset a subflow and mptcp
connection is unaffected.

mp_reset_single.pkt - check we can reset single subflow.
Check mp_reset on non-RST packets has no effect.

mp_reset_single_tcp.pkt - check TCP doesn't care about
mp_reset presence.

This also "fixes" existing test cases to expect mp_reset option
in some cases.

Signed-off-by: Florian Westphal <fw@strlen.de>
  • Loading branch information
Florian Westphal authored and matttbe committed Feb 24, 2021
1 parent 21c2710 commit f24a513
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gtests/net/mptcp/fastclose/receive_fastclose_with_ack.pkt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
// send another ack fastclose, this time with matching key
+0.1 < . 2001:2001(0) win 450 <mp_fastclose>
// expect peer to reset all subflows now:
+0.01 > R. 1:1(0) ack 2001
+0.01 > R. 1:1(0) ack 2001 <mp_reset 0>

// more data, expect a reset and win0 (no socket anymore)
+1.0 < P. 2001:3001(1000) ack 1 win 450 <nop, nop, dss dack8=1 dsn8=2001 ssn=2001 dll=1000 nocs>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
+0.1 < . 1002:1002(0) win 450 <mp_fastclose>

// expect peer to reset both subflows now:
+0.0 > addr[saddr0] > addr[caddr0] R. 1:1(0) ack 1001
+0.0 > addr[saddr1] > addr[caddr1] R. 1:1(0) ack 1002
+0.0 > addr[saddr0] > addr[caddr0] R. 1:1(0) ack 1001 <mp_reset 0>
+0.0 > addr[saddr1] > addr[caddr1] R. 1:1(0) ack 1002 <mp_reset 0>

+0 read(4, ..., 2002) = 2001
+0 close(4) = 0
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
+0.1 < R. 1002:1002(0) win 450 <mp_fastclose>

// expect peer to reset the original flow now:
+0.0 > addr[saddr0] > addr[caddr0] R. 1:1(0) ack 1001
+0.0 > addr[saddr0] > addr[caddr0] R. 1:1(0) ack 1001 <mp_reset 0>

+0 read(4, ..., 2002) = 2001
+0 close(4) = 0
4 changes: 2 additions & 2 deletions gtests/net/mptcp/mp_join/mp_join_server_bad_token.pkt
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
+0 bind(3, ..., ...) = 0
+0 listen(3, 1) = 0

+0.0 < S 0:0(0) win 65535 <mss 1460, mp_join_syn address_id=0 token=1>
+0.0 > R. 0:0(0) ack 1
+0.0 < S 0:0(0) win 65535 <mss 1460, mp_join_syn address_id=0 token=1>
+0.0 > R. 0:0(0) ack 1 <mp_reset 1>
56 changes: 56 additions & 0 deletions gtests/net/mptcp/mp_reset/mp_reset_multi_v4.pkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// connection initiated by packetdrill
--tolerance_usecs=100000
`../common/defaults.sh`

+0 `../common/server.sh`

+0 socket(..., SOCK_STREAM, IPPROTO_MPTCP) = 3
+0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0

+0 bind(3, ..., ...) = 0
+0 listen(3, 1) = 0
+0.0 < addr[caddr0] > addr[saddr0] S 0:0(0) win 65535 <mss 1460, nop, wscale 7, mpcapable v1 flags[flag_h] nokey>
+0.0 > S. 0:0(0) ack 1 <mss 1460, nop, wscale 8, mpcapable v1 flags[flag_h] key[skey]>
+0.0 < . 1:1(0) ack 1 win 256 <mpcapable v1 flags[flag_h] key[ckey=2, skey]>
+0 accept(3, ..., ...) = 4

// add_addr
+0.0 > . 1:1(0) ack 1 <add_address addr[saddr1] hmac=auto, dss dack4=1 dll=0 nocs>
// +0.0 < . 1:1(0) ack 1 win 256 <add_address addr[saddr1], dss dack8=1 dll=0 nocs>

+0.2 < P. 1:1001(1000) ack 1 win 450 <nop, nop, dss dack8=1 dsn8=1 ssn=1 dll=1000 nocs>
+0.0 > . 1:1(0) ack 1001 <dss dack8=1001 nocs>

+0.2 < P. 1:1(0) ack 1 win 450 <mpcapable v1 flags[flag_h] key[skey, ckey]>
+0.0 > . 1:1(0) ack 1001 <dss dack8=1001 nocs>

// add another subflow.
+0.5 < addr[caddr1] > addr[saddr1] S 0:0(0) win 65535 <mss 1460, nop, wscale 7, mp_join_syn address_id=2 token=sha256_32(skey)>
+0.0 > S. 0:0(0) ack 1 <mss 1460, nop, wscale 8, mp_join_syn_ack address_id=0 sender_hmac=auto>
+0.0 < . 1:1(0) ack 1 win 256 <mp_join_ack sender_hmac=auto>
+0.0 > . 1:1(0) ack 1 <dss dack8=1001 nocs>

// send more data.
+0.2 < P. 1:1002(1001) ack 1 win 450 <nop, nop, dss dack8=1 dsn8=1001 ssn=1 dll=1001 nocs>
+0 > . 1:1(0) ack 1002 <dss dack8=2002 dll=0 nocs>

// send rst option. RST is not set, so it should have no effect.
+0 < . 1002:1002(0) win 256 <mp_reset 1>

// again, this time with RST but out of window.
+0.1 < R. 3001:3001(0) win 450 <mp_reset 1>
// ... expect challenge ack.
+0 > . 1:1(0) ack 1002 <dss dack8=2002 dll=0 nocs>

// again. RST the 2nd subflow.
+0.1 < R. 1002:1002(0) win 450 <mp_reset 1>

// This should result in a RST, since subflow was closed.
+0.2 < P. 1:1002(1001) ack 1 win 450 <nop, nop, dss dack8=1 dsn8=1001 ssn=1 dll=1001 nocs>
+0 > R 1:1(0)

// More data.
+0.2 < addr[caddr0] > addr[saddr0] P. 1001:2003(1002) ack 1 win 450 <nop, nop, dss dack8=1 dsn8=2002 ssn=1001 dll=1002 nocs>

+1 read(4, ..., 3004) = 3003
+0 close(4) = 0
32 changes: 32 additions & 0 deletions gtests/net/mptcp/mp_reset/mp_reset_single.pkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// connection initiated by packetdrill
--tolerance_usecs=100000
`../common/defaults.sh`

+0 socket(..., SOCK_STREAM, IPPROTO_MPTCP) = 3
+0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0

+0 bind(3, ..., ...) = 0
+0 listen(3, 1) = 0
+0 < S 0:0(0) win 32792 <mss 1460, sackOK, nop, nop, nop, wscale 7, mpcapable v1 flags[flag_h] nokey>
+0 > S. 0:0(0) ack 1 <mss 1460, nop, nop, sackOK, nop, wscale 8, mpcapable v1 flags[flag_h] key[skey]>
+0.01 < . 1:1(0) ack 1 win 256 <mpcapable v1 flags[flag_h] key[ckey=2, skey]>
+0 accept(3, ..., ...) = 4

// ignore, out of window
+0 < R. 1002:1002(0) win 256
+0 > . 1:1(0) ack 1 <dss dack4=1>

// ignore, TCP RST flag not set
+0 < . 1:1(0) win 256 <mp_reset 1>

+0.0 write(4, ..., 1000) = 1000
+0 > P. 1:1001(1000) ack 1 <dss dack4=1 dsn8=1 dll=1000 nocs, nop, nop>
+0 < P. 1:1(0) ack 1001 win 256 <dss dack4=1001 dsn8=1 dll=0 nocs, nop, nop>

// should work.
+0 < R. 1:1(0) win 256 <mp_reset 1>

// probe. SF should be closed...
+0 < . 1:1(0) win 256
// .. and a reset should be sent.
+0 > R 0:0(0)
32 changes: 32 additions & 0 deletions gtests/net/mptcp/mp_reset/mp_reset_single_tcp.pkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// connection initiated by packetdrill
--tolerance_usecs=100000
`../common/defaults.sh`

+0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0

+0 bind(3, ..., ...) = 0
+0 listen(3, 1) = 0
+0 < S 0:0(0) win 32792 <mss 1460, sackOK, nop, nop, nop, wscale 7, mpcapable v1 flags[flag_h] nokey>
+0 > S. 0:0(0) ack 1 <mss 1460, nop, nop, sackOK, nop, wscale 8>
+0.01 < . 1:1(0) ack 1 win 256
+0 accept(3, ..., ...) = 4

// ignore, out of window
+0 < R. 1002:1002(0) win 256
+0 > . 1:1(0) ack 1

// ignore, TCP RST flag not set
+0 < . 1:1(0) win 256 <mp_reset 1>

+0.0 write(4, ..., 1000) = 1000
+0 > P. 1:1001(1000) ack 1
+0 < P. 1:1(0) ack 1001 win 256

// should work.
+0 < R. 1:1(0) win 256 <mp_reset 1>

// probe.
+0 < . 1:1(0) win 256
// .. and a reset should be sent.
+0 > R 0:0(0)

0 comments on commit f24a513

Please sign in to comment.