From 43263975e2aaffd7b395457467248b091a4a90a5 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Fri, 15 Dec 2023 10:52:47 +0100 Subject: [PATCH] Revert "Revert "mptcp: new tests to validate IP_TTL and IPV6_UNICAST_HOPS sockopts"" --- gtests/net/mptcp/sockopts/ip_ttl_v4.pkt | 25 +++++++++++++++++++ .../mptcp/sockopts/ipv6_unicast_hops_v6.pkt | 25 +++++++++++++++++++ gtests/net/packetdrill/ipv6.h | 1 + gtests/net/packetdrill/symbols_linux.c | 1 + 4 files changed, 52 insertions(+) create mode 100644 gtests/net/mptcp/sockopts/ip_ttl_v4.pkt create mode 100644 gtests/net/mptcp/sockopts/ipv6_unicast_hops_v6.pkt diff --git a/gtests/net/mptcp/sockopts/ip_ttl_v4.pkt b/gtests/net/mptcp/sockopts/ip_ttl_v4.pkt new file mode 100644 index 00000000..22ef9b87 --- /dev/null +++ b/gtests/net/mptcp/sockopts/ip_ttl_v4.pkt @@ -0,0 +1,25 @@ +// Send data with MSG_FASTOPEN +--tolerance_usecs=400000 +`../common/defaults.sh` + + 0.0 socket(..., SOCK_STREAM, IPPROTO_MPTCP) = 3 ++0.0 getsockopt(3, SOL_IP, IP_TTL, [64], [4]) = 0 ++0.0 setsockopt(3, SOL_IP, IP_TTL, [1], 4) = 0 ++0.0 getsockopt(3, SOL_IP, IP_TTL, [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.01 > [ttl 1] S 0:0(0) ++0.01 < [ttl 1] S. 0:0(0) ack 1 win 65535 ++0.01 > [ttl 1] . 1:1(0) ack 1 + ++0.0 fcntl(3, F_SETFL, O_RDWR) = 0 // set back to blocking ++0.0 setsockopt(3, SOL_IP, IP_TTL, [2], 4) = 0 ++0.0 getsockopt(3, SOL_IP, IP_TTL, [2], [4]) = 0 + ++0.1 write(3, ..., 2) = 2 + ++0.0 > [ttl 2] P. 1:3(2) ack 1 diff --git a/gtests/net/mptcp/sockopts/ipv6_unicast_hops_v6.pkt b/gtests/net/mptcp/sockopts/ipv6_unicast_hops_v6.pkt new file mode 100644 index 00000000..1c178f2c --- /dev/null +++ b/gtests/net/mptcp/sockopts/ipv6_unicast_hops_v6.pkt @@ -0,0 +1,25 @@ +// Send data with MSG_FASTOPEN +--tolerance_usecs=400000 +`../common/defaults.sh` + + 0.0 socket(..., SOCK_STREAM, IPPROTO_MPTCP) = 3 ++0.0 getsockopt(3, SOL_IPV6, IPV6_UNICAST_HOPS, [64], [4]) = 0 ++0.0 setsockopt(3, SOL_IPV6, IPV6_UNICAST_HOPS, [1], 4) = 0 ++0.0 getsockopt(3, SOL_IPV6, IPV6_UNICAST_HOPS, [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.01 > [ttl 1] S 0:0(0) ++0.01 < [ttl 1] S. 0:0(0) ack 1 win 65535 ++0.01 > [ttl 1] . 1:1(0) ack 1 + ++0.0 fcntl(3, F_SETFL, O_RDWR) = 0 // set back to blocking ++0.0 setsockopt(3, SOL_IPV6, IPV6_UNICAST_HOPS, [2], 4) = 0 ++0.0 getsockopt(3, SOL_IPV6, IPV6_UNICAST_HOPS, [2], [4]) = 0 + ++0.1 write(3, ..., 2) = 2 + ++0.0 > [ttl 2] P. 1:3(2) ack 1 diff --git a/gtests/net/packetdrill/ipv6.h b/gtests/net/packetdrill/ipv6.h index 07a0964e..0a538d80 100644 --- a/gtests/net/packetdrill/ipv6.h +++ b/gtests/net/packetdrill/ipv6.h @@ -57,6 +57,7 @@ struct ipv6 { }; #ifdef linux +#define IPV6_UNICAST_HOPS 16 #define IPV6_HOPLIMIT 52 #define IPV6_TCLASS 67 #endif /* linux */ diff --git a/gtests/net/packetdrill/symbols_linux.c b/gtests/net/packetdrill/symbols_linux.c index 16551438..b055f865 100644 --- a/gtests/net/packetdrill/symbols_linux.c +++ b/gtests/net/packetdrill/symbols_linux.c @@ -166,6 +166,7 @@ struct int_symbol platform_symbols_table[] = { #ifdef IPV6_MTU { IPV6_MTU, "IPV6_MTU" }, #endif + { IPV6_UNICAST_HOPS, "IPV6_UNICAST_HOPS" }, { IPV6_TCLASS, "IPV6_TCLASS" }, { IPV6_HOPLIMIT, "IPV6_HOPLIMIT" },