BPF 'force to MPTCP'
Subsystems (9)
v3 cover BPF 'force to MPTCP'
v3:
- add a wrapper socket_create(), the bpf hooks will added in this wrapper.
v2:
- Address issue #79 "allow 'force to MPTCP' mode: BPF".
- Define the prog in patch 3 in SEC "cgroup/sock_create" instead of "sockops".
- Update other patches correspondingly.
v1:
This series depends on the two netns patches, should be inserted before the BPF scheduler series:
selftests/bpf: use random netns name for mptcp selftests/bpf: add two mptcp netns helpers
bpf: Add bpf_mptcpify helper
selftests/bpf: Test bpf_mptcpify helper
selftests/bpf: Add mptcpify selftest
mptcp: refactor push_pending logic
Geliang Tang (5):
Squash to "selftests/bpf: add two mptcp netns helpers"
net: socket: add socket_create wrapper
bpf: Add bpf_mptcpify helper
selftests/bpf: Test bpf_mptcpify helper selftests/bpf: Add mptcpify selftest
include/linux/net.h | 6 + include/uapi/linux/bpf.h | 7 + kernel/trace/bpf_trace.c | 23 ++++ net/socket.c | 12 +- tools/include/uapi/linux/bpf.h | 7 + .../testing/selftests/bpf/prog_tests/mptcp.c | 127 +++++++++++++++--- tools/testing/selftests/bpf/progs/mptcpify.c | 16 +++ 7 files changed, 177 insertions(+), 21 deletions(-) create mode 100644 tools/testing/selftests/bpf/progs/mptcpify.c
Signature · 1 line
2.35.3
PATCH v3 1/5 Squash to "selftests/bpf: add two mptcp netns helpers"
Move the helpers to the beginning.
--- .../testing/selftests/bpf/prog_tests/mptcp.c | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-)
tools/testing/selftests/bpf/prog_tests/mptcp.c +20 -20
@@ -26,6 +26,26 @@ struct mptcp_storage {char ca_name[TCP_CA_NAME_MAX ]; }; +static struct nstoken *create_netns (void ) +{ +srand (time (NULL )); +snprintf (NS_TEST ,sizeof (NS_TEST ),"mptcp_ns_%d" ,rand ()); +SYS (fail,"ip netns add %s" ,NS_TEST ); +SYS (fail,"ip -net %s link set dev lo up" ,NS_TEST ); + +return open_netns (NS_TEST ); +fail: +return NULL ; +} + +static void cleanup_netns (struct nstoken *nstoken) +{ +if (nstoken) +close_netns (nstoken); + +SYS_NOFAIL ("ip netns del %s &> /dev/null" ,NS_TEST ); +} +static int verify_tsk (int map_fd,int client_fd) {int err, cfd = client_fd;
@@ -142,26 +162,6 @@ static int run_test(int cgroup_fd, int server_fd, bool is_mptcp)return err; } -static struct nstoken *create_netns (void ) -{ -srand (time (NULL )); -snprintf (NS_TEST ,sizeof (NS_TEST ),"mptcp_ns_%d" ,rand ()); -SYS (fail,"ip netns add %s" ,NS_TEST ); -SYS (fail,"ip -net %s link set dev lo up" ,NS_TEST ); - -return open_netns (NS_TEST ); -fail: -return NULL ; -} - -static void cleanup_netns (struct nstoken *nstoken) -{ -if (nstoken) -close_netns (nstoken); - -SYS_NOFAIL ("ip netns del %s &> /dev/null" ,NS_TEST ); -} -static void test_base (void ) {struct nstoken *nstoken =NULL ;
Signature · 1 line
2.35.3
PATCH v3 2/5 net: socket: add socket_create wrapper
In reply to Geliang TangThe arguments of socket() need to be changed sometimes like the MPTCP case in the next commits.
It's too late to add the BPF hooks in BPF_CGROUP_RUN_PROG_INET_SOCK() in inet_create(). So this patch adds a new wrapper socket_create().
The arguments of the wrapper need be changed through the BPF traces. So add a new struct socket_args to put together all arguments, and pass a pointer of this struct to the wrapper.
--- include/linux/net.h | 6 ++++++ net/socket.c | 12 +++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-)
include/linux/net.h +6 -0
@@ -84,6 +84,12 @@ enum sock_type {#endif /* ARCH_HAS_SOCKET_TYPES */ +struct socket_args { +int family; +int type; +int protocol; +}; +/** * enum sock_shutdown_cmd - Shutdown types * @SHUT_RD: shutdown receptions
net/socket.c +11 -1
@@ -1588,6 +1588,12 @@ int sock_create(int family, int type, int protocol, struct socket **res) }EXPORT_SYMBOL (sock_create); +int socket_create (struct socket_args *args,struct socket **res) +{ +return sock_create (args->family, args->type, args->protocol, res); +} +EXPORT_SYMBOL (socket_create); +/** * sock_create_kern - creates a socket (kernel space) * @net: net namespace
@@ -1608,6 +1614,7 @@ EXPORT_SYMBOL(sock_create_kern);static struct socket *__sys_socket_create (int family,int type,int protocol) { +struct socket_args args = {0 };struct socket *sock;int retval;
@@ -1621,7 +1628,10 @@ static struct socket *__sys_socket_create(int family, int type, int protocol)return ERR_PTR (-EINVAL ); type &=SOCK_TYPE_MASK ; - retval =sock_create (family, type, protocol, &sock); + args.family = family; + args.type = type; + args.protocol = protocol; + retval =socket_create (&args, &sock);if (retval <0 )return ERR_PTR (retval);
Signature · 1 line
2.35.3
kernel test robot
build botRe: [PATCH mptcp-next v3 2/5] net: socket: add socket_create wrapper
kernel test robot noticed the following build warnings:
Hi Geliang,
kernel test robot noticed the following build warnings:
[auto build test WARNING on mptcp/export]
[also build test WARNING on mptcp/export-net bpf-next/master bpf/master linus/master v6.4 next-20230703] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Geliang-Tang/Squash-to-selftests-bpf-add-two-mptcp-netns-helpers/20230703-144151 base: https://github.com/multipath-tcp/mptcp_net-next.git export patch link: https://lore.kernel.org/r/bf1cd56ede55306b3272c6b3069830ea6a189c97.1688366249.git.geliang.tang%40suse.com patch subject: [PATCH mptcp-next v3 2/5] net: socket: add socket_create wrapper config: um-allnoconfig (https://download.01.org/0day-ci/archive/20230703/[email protected]/config) compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a) reproduce: (https://download.01.org/0day-ci/archive/20230703/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
In file included from net/socket.c:55:
In file included from include/linux/bpf-cgroup.h:5:
In file included from include/linux/bpf.h:31:
In file included from include/linux/memcontrol.h:13:
In file included from include/linux/cgroup.h:26:
In file included from include/linux/kernel_stat.h:9:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:11:
In file included from arch/um/include/asm/hardirq.h:5:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/um/include/asm/io.h:24:
include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
547 | val = __raw_readb(PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
560 | val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
| ^
In file included from net/socket.c:55:
In file included from include/linux/bpf-cgroup.h:5:
In file included from include/linux/bpf.h:31:
In file included from include/linux/memcontrol.h:13:
In file included from include/linux/cgroup.h:26:
In file included from include/linux/kernel_stat.h:9:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:11:
In file included from arch/um/include/asm/hardirq.h:5:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/um/include/asm/io.h:24:
include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
573 | val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
| ^
In file included from net/socket.c:55:
In file included from include/linux/bpf-cgroup.h:5:
In file included from include/linux/bpf.h:31:
In file included from include/linux/memcontrol.h:13:
In file included from include/linux/cgroup.h:26:
In file included from include/linux/kernel_stat.h:9:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:11:
In file included from arch/um/include/asm/hardirq.h:5:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/um/include/asm/io.h:24:
include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
584 | __raw_writeb(value, PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
594 | __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
604 | __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:692:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
692 | readsb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:700:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
700 | readsw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:708:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
708 | readsl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:717:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
717 | writesb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:726:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
726 | writesw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:735:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
735 | writesl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
>> net/socket.c:1591:5: warning: no previous prototype for function 'socket_create' [-Wmissing-prototypes]
1591 | int socket_create(struct socket_args *args, struct socket **res)
| ^
net/socket.c:1591:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
1591 | int socket_create(struct socket_args *args, struct socket **res)
| ^
| static 13 warnings generated.
vim +/socket_create +1591 net/socket.c
1590
> 1591 int socket_create(struct socket_args *args, struct socket **res)
1592 {
1593 return sock_create(args->family, args->type, args->protocol, res);
1594 }
1595 EXPORT_SYMBOL(socket_create);
1596
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH mptcp-next v3 2/5] net: socket: add socket_create wrapper
In reply to Geliang Tangkernel test robot noticed the following build warnings:
Hi Geliang,
kernel test robot noticed the following build warnings:
[auto build test WARNING on mptcp/export]
[also build test WARNING on mptcp/export-net bpf-next/master bpf/master linus/master v6.4 next-20230703] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Geliang-Tang/Squash-to-selftests-bpf-add-two-mptcp-netns-helpers/20230703-144151 base: https://github.com/multipath-tcp/mptcp_net-next.git export patch link: https://lore.kernel.org/r/bf1cd56ede55306b3272c6b3069830ea6a189c97.1688366249.git.geliang.tang%40suse.com patch subject: [PATCH mptcp-next v3 2/5] net: socket: add socket_create wrapper config: arc-randconfig-r015-20230703 (https://download.01.org/0day-ci/archive/20230703/[email protected]/config) compiler: arc-elf-gcc (GCC) 12.3.0 reproduce: (https://download.01.org/0day-ci/archive/20230703/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> net/socket.c:1591:5: warning: no previous prototype for 'socket_create' [-Wmissing-prototypes]
1591 | int socket_create(struct socket_args *args, struct socket **res)
| ^~~~~~~~~~~~~
vim +/socket_create +1591 net/socket.c
1590
> 1591 int socket_create(struct socket_args *args, struct socket **res)
1592 {
1593 return sock_create(args->family, args->type, args->protocol, res);
1594 }
1595 EXPORT_SYMBOL(socket_create);
1596
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH v3 3/5 bpf: Add bpf_mptcpify helper
In reply to Geliang TangThis patch implements a new struct bpf_func_proto bpf_mptcpify_proto. And define a new helper bpf_mptcpify() to mptcpify a TCP socket dynamically as an MPTCP one when it is created.
In bpf_mptcpify(), if the protocol ID of sk is IPPROTO_TCP, set it to IPPROTO_MPTCP.
--- include/uapi/linux/bpf.h | 7 +++++++ kernel/trace/bpf_trace.c | 23 +++++++++++++++++++++++ tools/include/uapi/linux/bpf.h | 7 +++++++ 3 files changed, 37 insertions(+)
include/uapi/linux/bpf.h +7 -0
@@ -5573,6 +5573,12 @@ union bpf_attr {* 0 on success. * * **-ENOENT** if the bpf_local_storage cannot be found. +* +* int bpf_mptcpify(void *args) +* Description +* Dynamically mptcpify a TCP socket as an MPTCP one when it is created. +* Return +* 0 on success. */ #define ___BPF_FUNC_MAPPER(FN, ctx...) \ FN(unspec, 0, ##ctx) \
@@ -5787,6 +5793,7 @@ union bpf_attr { FN(user_ringbuf_drain, 209, ##ctx) \ FN(cgrp_storage_get, 210, ##ctx) \ FN(cgrp_storage_delete, 211, ##ctx) \ + FN(mptcpify, 212, ##ctx) \/* */ /* backwards-compatibility macros for users of __BPF_FUNC_MAPPER that don't
kernel/trace/bpf_trace.c +23 -0
@@ -1886,6 +1886,27 @@ static const struct bpf_func_proto bpf_get_stack_proto_raw_tp = { .arg4_type = ARG_ANYTHING, }; +BPF_CALL_1(bpf_mptcpify, struct socket_args *, args) +{ +if (args->family ==AF_INET && + args->type ==SOCK_STREAM && + (!args->protocol || args->protocol ==IPPROTO_TCP )) + args->protocol =IPPROTO_MPTCP ; + +return 0 ; +} + +BTF_ID_LIST (bpf_mptcpify_btf_ids) +BTF_ID(struct, socket_args) + +static const struct bpf_func_proto bpf_mptcpify_proto = { + .func = bpf_mptcpify, + .gpl_only = false, + .ret_type =RET_INTEGER , + .arg1_type =ARG_PTR_TO_BTF_ID , + .arg1_btf_id = &bpf_mptcpify_btf_ids[0 ], +}; +static const struct bpf_func_proto *raw_tp_prog_func_proto (enum bpf_func_id func_id,const struct bpf_prog *prog) {
@@ -1936,6 +1957,8 @@ tracing_prog_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)return &bpf_get_socket_ptr_cookie_proto;case BPF_FUNC_xdp_get_buff_len:return &bpf_xdp_get_buff_len_trace_proto; +case BPF_FUNC_mptcpify: +return &bpf_mptcpify_proto;#endif case BPF_FUNC_seq_printf: return prog->expected_attach_type == BPF_TRACE_ITER ?
tools/include/uapi/linux/bpf.h +7 -0
@@ -5573,6 +5573,12 @@ union bpf_attr {* 0 on success. * * **-ENOENT** if the bpf_local_storage cannot be found. +* +* int bpf_mptcpify(void *args) +* Description +* Dynamically mptcpify a TCP socket as an MPTCP one when it is created. +* Return +* 0 on success. */ #define ___BPF_FUNC_MAPPER(FN, ctx...) \ FN(unspec, 0, ##ctx) \
@@ -5787,6 +5793,7 @@ union bpf_attr { FN(user_ringbuf_drain, 209, ##ctx) \ FN(cgrp_storage_get, 210, ##ctx) \ FN(cgrp_storage_delete, 211, ##ctx) \ + FN(mptcpify, 212, ##ctx) \/* */ /* backwards-compatibility macros for users of __BPF_FUNC_MAPPER that don't
Signature · 1 line
2.35.3
kernel test robot
build botRe: [PATCH mptcp-next v3 3/5] bpf: Add bpf_mptcpify helper
kernel test robot noticed the following build warnings:
Hi Geliang,
kernel test robot noticed the following build warnings:
[auto build test WARNING on mptcp/export]
[also build test WARNING on mptcp/export-net bpf-next/master bpf/master linus/master v6.5-rc2 next-20230720] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Geliang-Tang/Squash-to-selftests-bpf-add-two-mptcp-netns-helpers/20230703-144151 base: https://github.com/multipath-tcp/mptcp_net-next.git export patch link: https://lore.kernel.org/r/d746717840dfdcab3e4d8fa710dfaa3958a0ead1.1688366249.git.geliang.tang%40suse.com patch subject: [PATCH mptcp-next v3 3/5] bpf: Add bpf_mptcpify helper config: x86_64-buildonly-randconfig-r003-20230720 (https://download.01.org/0day-ci/archive/20230721/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce: (https://download.01.org/0day-ci/archive/20230721/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> kernel/trace/bpf_trace.c:1902:36: warning: 'bpf_mptcpify_proto' defined but not used [-Wunused-const-variable=]
1902 | static const struct bpf_func_proto bpf_mptcpify_proto = {
| ^~~~~~~~~~~~~~~~~~vim +/bpf_mptcpify_proto +1902 kernel/trace/bpf_trace.c
1901
> 1902 static const struct bpf_func_proto bpf_mptcpify_proto = { 1903 .func = bpf_mptcpify,
1904 .gpl_only = false,
1905 .ret_type = RET_INTEGER,
1906 .arg1_type = ARG_PTR_TO_BTF_ID,
1907 .arg1_btf_id = &bpf_mptcpify_btf_ids[0],
1908 };
1909
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH v3 4/5 selftests/bpf: Test bpf_mptcpify helper
In reply to Geliang TangThis patch tests the new helper bpf_mptcpify(). Store the new protocol value after invoking the helper to a local BSS variable.
This is defined in a 'socket_create' SEC, so it will be hooked in the newly added wrapper socket_create().
--- tools/testing/selftests/bpf/progs/mptcpify.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tools/testing/selftests/bpf/progs/mptcpify.c
tools/testing/selftests/bpf/progs/mptcpify.c new file +16 -0
@@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2023, SUSE. */ + +#include <linux/bpf.h> +#include <bpf/bpf_helpers.h> +#include "bpf_tcp_helpers.h" + +char _license[] SEC("license") = "GPL"; + +SEC("fentry/socket_create") +int BPF_PROG (trace_socket_create ,void *args, +struct socket **res) +{ +bpf_mptcpify (args); +return 0 ; +}
Signature · 1 line
2.35.3
PATCH v3 5/5 selftests/bpf: Add mptcpify selftest
In reply to Geliang TangThis patch extends 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 the output of 'ss' command.
--- .../testing/selftests/bpf/prog_tests/mptcp.c | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+)
tools/testing/selftests/bpf/prog_tests/mptcp.c +87 -0
@@ -6,6 +6,7 @@#include "cgroup_helpers.h" #include "network_helpers.h" #include "mptcp_sock.skel.h" +#include "mptcpify.skel.h" #include "mptcp_bpf_first.skel.h" #include "mptcp_bpf_bkup.skel.h" #include "mptcp_bpf_rr.skel.h"
@@ -200,6 +201,90 @@ static void test_base(void)close (cgroup_fd); } +static void send_byte (int fd) +{ +char b =0x55 ; + +ASSERT_EQ (write (fd, &b,sizeof (b)),1 ,"send single byte" ); +} + +static int verify_mptcpify (void ) +{ +char cmd[128 ]; +int err =0 ; + +snprintf (cmd,sizeof (cmd), +"ip netns exec %s ss -tOni | grep -q tcp-ulp-mptcp" , +NS_TEST ); +if (!ASSERT_OK (system (cmd),"No tcp-ulp-mptcp found!" )) + err++; + +return err; +} + +static int run_mptcpify (int cgroup_fd) +{ +int server_fd, client_fd, prog_fd, err =0 ; +struct mptcpify *mptcpify_skel; + + mptcpify_skel =mptcpify__open_and_load (); +if (!ASSERT_OK_PTR (mptcpify_skel,"skel_open_load" )) +return -EIO ; + + err =mptcpify__attach (mptcpify_skel); +if (!ASSERT_OK (err,"skel_attach" )) + goto out; + + prog_fd =bpf_program__fd (mptcpify_skel->progs.trace_socket_create); +if (!ASSERT_GE (prog_fd,0 ,"bpf_program__fd" )) { + err = -EIO ; + goto out; + } + +/* without MPTCP */ + server_fd =start_server (AF_INET ,SOCK_STREAM ,NULL ,0 ,0 ); +if (!ASSERT_GE (server_fd,0 ,"start_server" )) { + err = -EIO ; + goto out; + } + + client_fd =connect_to_fd (server_fd,0 ); +if (!ASSERT_GE (client_fd,0 ,"connect to fd" )) { + err = -EIO ; + goto close_server; + } + +send_byte (client_fd); + err +=verify_mptcpify (); + +close (client_fd); +close_server: +close (server_fd); +out: +mptcpify__destroy (mptcpify_skel); +return err; +} + +static void test_mptcpify (void ) +{ +struct nstoken *nstoken =NULL ; +int cgroup_fd; + + cgroup_fd =test__join_cgroup ("/mptcpify" ); +if (!ASSERT_GE (cgroup_fd,0 ,"test__join_cgroup" )) +return ; + + nstoken =create_netns (); +if (!ASSERT_OK_PTR (nstoken,"create_netns" )) + goto fail; + +ASSERT_OK (run_mptcpify (cgroup_fd),"run_mptcpify" ); + +fail: +cleanup_netns (nstoken); +close (cgroup_fd); +} +static const unsigned int total_bytes =10 *1024 *1024 ;static int stop, duration;
@@ -459,6 +544,8 @@ void test_mptcp(void) {if (test__start_subtest ("base" ))test_base (); +if (test__start_subtest ("mptcpify" )) +test_mptcpify ();if (test__start_subtest ("first" ))test_first ();if (test__start_subtest ("bkup" ))
Signature · 1 line
2.35.3
Re: selftests/bpf: Add mptcpify selftest: Tests Results
Hi Geliang,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal (except selftest_mptcp_join):
- Success! ✅:
- Task: https://cirrus-ci.com/task/5904799128879104
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5904799128879104/summary/summary.txt
- KVM Validation: debug (except selftest_mptcp_join):
- Success! ✅:
- Task: https://cirrus-ci.com/task/6467749082300416
- Summary: https://api.cirrus-ci.com/v1/artifact/task/6467749082300416/summary/summary.txt
- KVM Validation: debug (only selftest_mptcp_join):
- Success! ✅:
- Task: https://cirrus-ci.com/task/5060374198747136
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5060374198747136/summary/summary.txt
- KVM Validation: normal (only selftest_mptcp_join):
- Unstable: 1 failed test(s): selftest_mptcp_join 🔴:
- Task: https://cirrus-ci.com/task/5341849175457792
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5341849175457792/summary/summary.txt
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/de52c09fbaf4
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-debugFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (Tessares)