Skip to content

Commit

Permalink
Merge pull request google#47 from dcaratti/fix-add-addr-port
Browse files Browse the repository at this point in the history
initial coverage for `ADD_ADDR` with port
  • Loading branch information
dcaratti authored Mar 18, 2021
2 parents d57954e + 2688271 commit c6f912c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
23 changes: 23 additions & 0 deletions gtests/net/mptcp/add_addr/add_addr_port_client.pkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// connection initiated by the kernel
--tolerance_usecs=100000
`../common/defaults.sh`

+0 `../common/client.sh`

+0.0 socket(..., SOCK_STREAM, IPPROTO_MPTCP) = 3
+0.0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [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.0 connect(3, ..., ...) = -1 EINPROGRESS (Operation now in progress)
+0.0 > S 0:0(0) <mss 1460, sackOK, TS val 100 ecr 0, nop, wscale 8, mpcapable v1 flags[flag_h] nokey>
+0.0 < S. 0:0(0) ack 1 win 65535 <mss 1460, sackOK, TS val 700 ecr 100, nop, wscale 8, mpcapable v1 flags[flag_h] key[skey=2]>
+0.0 > . 1:1(0) ack 1 <nop, nop, TS val 100 ecr 700, mpcapable v1 flags[flag_h] key[ckey, skey]>

+0.200 getsockopt(3, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
+0.205 fcntl(3, F_SETFL, O_RDWR) = 0 // set back to blocking

// ADD_ADDRESS with port
+0.0 < . 1:1(0) ack 1 win 256 <add_address address_id=12 addr[saddr] port=4321 hmac=auto, dss dack4=1 dll=0 nocs, nop, nop>
+0.0 > . 1:1(0) ack 1 <nop, nop, TS val 100 ecr 700, add_address address_id=12 addr[saddr] port=4321 addr_echo, nop, nop>

4 changes: 2 additions & 2 deletions gtests/net/packetdrill/mptcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2053,7 +2053,7 @@ int mptcp_subtype_add_address(struct packet *packet_to_modify,
mp_state.packetdrill_key,
add_addr_live->data.add_addr.address_id,
&add_addr_live->data.add_addr.ipv4_w_port_hmac.ipv4,
0);
ntohs(add_addr_live->data.add_addr.ipv4_w_port_hmac.port));
}else if(add_addr_script->length == TCPOLEN_ADD_ADDR_V6){
add_addr_script->data.add_addr.ipv6 = endpoint->ip.ip.v6;
}else if(add_addr_script->length == TCPOLEN_ADD_ADDR_V6_PORT){
Expand All @@ -2079,7 +2079,7 @@ int mptcp_subtype_add_address(struct packet *packet_to_modify,
mp_state.packetdrill_key,
add_addr_live->data.add_addr.address_id,
&add_addr_live->data.add_addr.ipv6_w_port_hmac.ipv6,
0);
ntohs(add_addr_live->data.add_addr.ipv6_w_port_hmac.port));
}else{
return STATUS_ERR;
}
Expand Down
8 changes: 4 additions & 4 deletions gtests/net/packetdrill/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -2249,8 +2249,8 @@ tcp_option
// ipv4 + port + hmac
}else if($4 != UNDEFINED && ($5.auto_conf || $5.hash != UNDEFINED)){
$$ = tcp_option_new(TCPOPT_MPTCP, TCPOLEN_ADD_ADDR_V4_PORT_HMAC);
$$->data.add_addr.ipv4_w_port.port = htons($4);
$$->data.add_addr.ipv4_w_hmac.hmac = htobe64($5.hash);
$$->data.add_addr.ipv4_w_port_hmac.port = htons($4);
$$->data.add_addr.ipv4_w_port_hmac.hmac = htobe64($5.hash);
}
// ipv4
}else if($3 == AF_INET && $4 == UNDEFINED && !$5.auto_conf && $5.hash == UNDEFINED){
Expand All @@ -2268,8 +2268,8 @@ tcp_option
// ipv4 + port + hmac
}else if($3 == AF_INET && $4 != UNDEFINED && ($5.auto_conf || $5.hash != UNDEFINED)){
$$ = tcp_option_new(TCPOPT_MPTCP, TCPOLEN_ADD_ADDR_V4_PORT_HMAC);
$$->data.add_addr.ipv4_w_port.port = htons($4);
$$->data.add_addr.ipv4_w_hmac.hmac = htobe64($5.hash);
$$->data.add_addr.ipv4_w_port_hmac.port = htons($4);
$$->data.add_addr.ipv4_w_port_hmac.hmac = htobe64($5.hash);
// ipv6
}else if($3 == AF_INET6 && $4 == UNDEFINED && !$5.auto_conf && $5.hash == UNDEFINED){
$$ = tcp_option_new(TCPOPT_MPTCP, TCPOLEN_ADD_ADDR_V6);
Expand Down

0 comments on commit c6f912c

Please sign in to comment.