From: Geliang Tang <tanggeliang@kylinos.cn>
Add helper functions to conditionally set TCP_INQ sockopt on accepted
sockets when running in inq mode. This ensures proper testing of TCP_CM_INQ
functionality by enabling the required socket option on both ends of the
connection. This setup is necessary for validating TCP_CM_INQ behavior
during TCP_INQ-specific tests.
These codes are from mptcp_inq.c.
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
tools/testing/selftests/net/mptcp/mptcp_sockopt.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
index cb3d8dc34997..366e4aa4df0b 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
@@ -715,6 +715,14 @@ static void process_one_client(int fd, int pipefd)
close(fd);
}
+static void do_setsockopt_inq(int fd)
+{
+ int on = 1;
+
+ if (setsockopt(fd, IPPROTO_TCP, TCP_INQ, &on, sizeof(on)))
+ die_perror("setsockopt(TCP_INQ)");
+}
+
static int xaccept(int s)
{
int fd = accept(s, NULL, 0);
@@ -722,6 +730,9 @@ static int xaccept(int s)
if (fd < 0)
die_perror("accept");
+ if (inq)
+ do_setsockopt_inq(fd);
+
return fd;
}
--
2.48.1