Re: [PATCH bpf-next v14 4/4] selftests/bpf: Add mptcpify test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/15/23 6:11 PM, Geliang Tang wrote:
Implement a new test program mptcpify: if the family is AF_INET or
AF_INET6, the type is SOCK_STREAM, and the protocol ID is 0 or
IPPROTO_TCP, set it to IPPROTO_MPTCP. It will be hooked in
update_socket_protocol().

Extend the MPTCP test base, add a selftest test_mptcpify() for the
mptcpify case. Open and load the mptcpify test prog to mptcpify the
TCP sockets dynamically, then use start_server() and connect_to_fd()
to create a TCP socket, but actually what's created is an MPTCP
socket, which can be verified through 'getsockopt(SOL_PROTOCOL)'
and 'getsockopt(MPTCP_INFO)'.

Acked-by: Yonghong Song <yonghong.song@xxxxxxxxx>
Reviewed-by: Matthieu Baerts <matthieu.baerts@xxxxxxxxxxxx>
Signed-off-by: Geliang Tang <geliang.tang@xxxxxxxx>
---
  .../testing/selftests/bpf/prog_tests/mptcp.c  | 116 ++++++++++++++++++
  tools/testing/selftests/bpf/progs/mptcpify.c  |  20 +++
  2 files changed, 136 insertions(+)
  create mode 100644 tools/testing/selftests/bpf/progs/mptcpify.c

diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c
index 3d3999067e27..68ebf9735e16 100644
--- a/tools/testing/selftests/bpf/prog_tests/mptcp.c
+++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c
@@ -2,13 +2,30 @@
  /* Copyright (c) 2020, Tessares SA. */
  /* Copyright (c) 2022, SUSE. */
+#include <linux/mptcp.h>
bpf CI failed (https://github.com/kernel-patches/bpf/actions/runs/5882006207/job/15951617063):

/tmp/work/bpf/bpf/tools/testing/selftests/bpf/prog_tests/mptcp.c:5:10: fatal error: 'linux/mptcp.h' file not found
  #include <linux/mptcp.h>

I fixed that by copying the 'struct mptcp_info' but renamed to 'struct __mptcp_info' just in case any fallout in the future.

My environment also does not have SOL_MPTCP, so I do an ifndef for it also.

+#include <netinet/in.h>
  #include <test_progs.h>
  #include "cgroup_helpers.h"
  #include "network_helpers.h"
  #include "mptcp_sock.skel.h"
+#include "mptcpify.skel.h"
#define NS_TEST "mptcp_ns" +#ifndef IPPROTO_MPTCP
+#define IPPROTO_MPTCP 262
+#endif
+
+#ifndef MPTCP_INFO
+#define MPTCP_INFO		1
+#endif
+#ifndef MPTCP_INFO_FLAG_FALLBACK
+#define MPTCP_INFO_FLAG_FALLBACK		_BITUL(0)

I have to add '#include <linux/const.h>' for the _BITUL() here also....

The set is applied. Please follow up if I make mistake on those fixes.





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux