Skip to content

Commit

Permalink
mptcp: sockopt: add coverage for TCP_CORK and TCP_NODELAY
Browse files Browse the repository at this point in the history
Add coverage for new socket options that allow changing behavior of
Nagle's algorithm on MPTCP sockets.

Link: https://lore.kernel.org/mptcp/20211123070708.2897469-1-max@internet.ru/T/
Signed-off-by: Maxim Galaganov <max@internet.ru>
  • Loading branch information
darkwrat committed Nov 25, 2021
1 parent 7a16e5f commit dc5a1c5
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
50 changes: 50 additions & 0 deletions gtests/net/mptcp/sockopts/sockopt_cork_multi.pkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
--tolerance_usecs=100000
`../common/defaults.sh`
+0 `../common/multi-ep.sh -e 0`

+0.0 socket(..., SOCK_STREAM, IPPROTO_MPTCP) = 3
+0.0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+0.0 setsockopt(3, SOL_TCP, TCP_CORK, [1], 4) = 0
+0.0 fcntl(3, F_GETFL) = 0x2 (flags O_RDWR)
+0.0 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0

+0 bind(3, ..., ...) = 0
+0 listen(3, 1) = 0

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

+0.2 < P. 1:3(2) ack 1 win 256 <nop, nop, TS val 4074418292 ecr 4074410674, mpcapable v1 flags[flag_h] key[skey, ckey] mpcdatalen 2, nop, nop>
// MP_CAPABLE carrying data are acked with 64-bit, safer not knowing if the
// sender will use a DSN on 64-bit or 32-bit. Later we can use the lower 32 bits
+0.0 > . 1:1(0) ack 3 <nop, nop, TS val 4074418293 ecr 4074418292, dss dack8=3 dll=0 nocs>
+0.0 read(4, ..., 2) = 2

// more inbound data and MP_PRIO to flip active -> backup
+0.0 < P. 3:5(2) ack 1 win 256 <dss dack8=1 dsn4=3 ssn=3 dll=2 nocs, mp_prio backup=1, nop, nop, nop>
+0.0 > . 1:1(0) ack 5 <nop, nop, TS val 4074418293 ecr 4074418292, dss dack4=5 nocs>
+0.0 read(4, ..., 2) = 2

// create subflow
+0.0 < addr[caddr1] > addr[saddr0] S 0:0(0) win 65535 <mss 1460, sackOK, TS val 448955294 ecr 0, nop, wscale 8, mp_join_syn backup=1 address_id=1 token=sha256_32(skey)>
+0.0 > S. 0:0(0) ack 1 <mss 1460, sackOK, TS val 448955294 ecr 448955294, nop, wscale 8, mp_join_syn_ack backup=1 address_id=0 sender_hmac=auto>
+0.0 < . 1:1(0) ack 1 win 256 <nop, nop, TS val 448955294 ecr 448955294, mp_join_ack sender_hmac=auto>
+0.0 > . 1:1(0) ack 1 <nop, nop, TS val 448955294 ecr 448955294, dss dack4=5 nocs>

// more inbound data and MP_PRIO to flip backup -> active
+0.0 < P. 1:11(10) ack 1 win 256 <dss dack8=1 dsn4=5 ssn=1 dll=10 nocs, mp_prio backup=0, nop, nop, nop>
+0.0 > . 1:1(0) ack 11 <nop, nop, TS val 448955294 ecr 448955294, dss dack4=15 nocs>
+0.0 read(4, ..., 10) = 10

// check that TCP_CORK was cloned from listener
+0.0 getsockopt(4, SOL_TCP, TCP_CORK, [1], [4]) = 0

// write() should now go through joined subflow
+0.0 write(4, ..., 1) = 1
+0.01 write(4, ..., 1) = 1

// reset TCP_CORK that was cloned from listener in order to push pending data
+0.01 setsockopt(4, SOL_TCP, TCP_CORK, [0], 4) = 0
+0.0 > addr[saddr1] > addr[caddr1] P. 1:3(2) ack 11 <nop, nop, TS val 448955294 ecr 448955294, dss dack4=15 dsn8=1 ssn=1 dll=2 nocs, nop, nop>
50 changes: 50 additions & 0 deletions gtests/net/mptcp/sockopts/sockopt_cork_nodelay.pkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
--tolerance_usecs=100000
`../common/defaults.sh`


+0.0 socket(..., SOCK_STREAM, IPPROTO_MPTCP) = 3
+0.0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+0.0 setsockopt(3, SOL_TCP, TCP_CORK, [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, sackOK, TS val 4074410674 ecr 0, nop, wscale 8, mpcapable v1 flags[flag_h] nokey>
+0.0 > S. 0:0(0) ack 1 <mss 1460, sackOK, TS val 4074410674 ecr 4074410674, nop, wscale 8, mpcapable v1 flags[flag_h] key[skey]>
+0.0 < . 1:1(0) ack 1 win 256 <nop, nop, TS val 4074410674 ecr 4074410674, mpcapable v1 flags[flag_h] key[ckey=2, skey]>
+0 accept(3, ..., ...) = 4

// TCP_CORK synced from listener
+0.0 write(4, ..., 40) = 40
+0.05 write(4, ..., 40) = 40

// clearing TCP_CORK should push pending bytes out
+0.01 setsockopt(4, SOL_TCP, TCP_CORK, [0], 4) = 0
+0.0 > P. 1:81(80) ack 1 <nop, nop, TS val 448955294 ecr 448955294, dss dack4=1 dsn8=1 ssn=1 dll=80 nocs, nop, nop>
+0.01 < . 1:1(0) ack 81 win 256 <nop, nop, TS val 448955294 ecr 448955294, dss dack4=81 nocs>

// set TCP_CORK once again
+0.0 setsockopt(4, SOL_TCP, TCP_CORK, [1], 4) = 0
+0.0 write(4, ..., 40) = 40
+0.05 write(4, ..., 40) = 40

// setting TCP_NODELAY on a socket with TCP_CORK should push pending bytes out
+0.0 setsockopt(4, SOL_TCP, TCP_NODELAY, [1], 4) = 0
+0.0 > P. 81:161(80) ack 1 <nop, nop, TS val 448955294 ecr 448955294, dss dack4=1 dsn8=81 ssn=81 dll=80 nocs, nop, nop>
+0.1 < . 1:1(0) ack 161 win 256 <nop, nop, TS val 448955294 ecr 448955294, dss dack4=161 nocs>

// TCP_CORK has priority over TCP_NODELAY
+0.0 write(4, ..., 1) = 1
+0.01 write(4, ..., 1) = 1
+0.2 > P. 161:163(2) ack 1 <nop, nop, TS val 448955294 ecr 448955294, dss dack4=1 dsn8=161 ssn=161 dll=2 nocs, nop, nop>
+0.0 < . 1:1(0) ack 163 win 256 <nop, nop, TS val 448955294 ecr 448955294, dss dack4=163 nocs>

// clearing TCP_CORK on the accepted connection (TCP_NODELAY stays enabled)
+0.01 setsockopt(4, SOL_TCP, TCP_CORK, [0], 4) = 0

// check that Nagle's algorithm is disabled
+0.0 write(4, ..., 1) = 1
+0.01 write(4, ..., 1) = 1
+0.0 > P. 163:164(1) ack 1 <nop, nop, TS val 448955294 ecr 448955294, dss dack4=1 dsn8=163 ssn=163 dll=1 nocs, nop, nop>
+0.0 > P. 164:165(1) ack 1 <nop, nop, TS val 448955294 ecr 448955294, dss dack4=1 dsn8=164 ssn=164 dll=1 nocs, nop, nop>
+0.0 < . 1:1(0) ack 165 win 256 <nop, nop, TS val 448955294 ecr 448955294, dss dack4=165 nocs>

0 comments on commit dc5a1c5

Please sign in to comment.