From: Geliang Tang <tanggeliang@kylinos.cn>
This patch adds the TCP_MAXSEG sockopt tests in mptcp_sockopt.c. Since
in getsockopt TCP_MAXSEG, the "user_mss" value can be obtained only in
the LISTEN state (see do_tcp_getsockopt in net/ipv4/tcp.c), the test
items are added to server() instead of client().
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
.../selftests/net/mptcp/mptcp_sockopt.c | 22 +++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
index 9934a68df237..5ad1e9ed2fe6 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
@@ -697,6 +697,26 @@ static int xaccept(int s)
return fd;
}
+static void test_tcp_maxseg_sockopt(int fd)
+{
+ int maxseg = 1000;
+ socklen_t s;
+ int r;
+
+ s = sizeof(maxseg);
+ r = setsockopt(fd, IPPROTO_TCP, TCP_MAXSEG, &maxseg, s);
+ if (r != 0)
+ die_perror("setsockopt TCP_MAXSEG");
+
+ maxseg = 0;
+ r = getsockopt(fd, IPPROTO_TCP, TCP_MAXSEG, &maxseg, &s);
+ if (r != -1 && errno != EINVAL)
+ die_perror("getsockopt TCP_MAXSEG did not indicate -EINVAL");
+
+ if (maxseg != 1000)
+ xerror("maxseg=%d", maxseg);
+}
+
static int server(int pipefd)
{
int fd = -1, r;
@@ -721,6 +741,8 @@ static int server(int pipefd)
process_one_client(r, pipefd);
+ test_tcp_maxseg_sockopt(fd);
+
return 0;
}
--
2.43.0