Skip to content

Commit 519357d

Browse files
Geliang Tangintel-lab-lkp
authored andcommitted
selftests: mptcp: sockopt: add TCP_MAXSEG sockopt tests
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 <[email protected]>
1 parent 19300ba commit 519357d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tools/testing/selftests/net/mptcp/mptcp_sockopt.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,26 @@ static int xaccept(int s)
689689
return fd;
690690
}
691691

692+
static void test_tcp_maxseg_sockopt(int fd)
693+
{
694+
int maxseg = 1000;
695+
socklen_t s;
696+
int r;
697+
698+
s = sizeof(maxseg);
699+
r = setsockopt(fd, IPPROTO_TCP, TCP_MAXSEG, &maxseg, s);
700+
if (r != 0)
701+
die_perror("setsockopt TCP_MAXSEG");
702+
703+
maxseg = 0;
704+
r = getsockopt(fd, IPPROTO_TCP, TCP_MAXSEG, &maxseg, &s);
705+
if (r != -1 && errno != EINVAL)
706+
die_perror("getsockopt TCP_MAXSEG did not indicate -EINVAL");
707+
708+
if (maxseg != 1000)
709+
xerror("maxseg=%d", maxseg);
710+
}
711+
692712
static int server(int pipefd)
693713
{
694714
int fd = -1, r;
@@ -713,6 +733,8 @@ static int server(int pipefd)
713733

714734
process_one_client(r, pipefd);
715735

736+
test_tcp_maxseg_sockopt(fd);
737+
716738
return 0;
717739
}
718740

0 commit comments

Comments
 (0)