* [PATCH mptcp-next v3 1/5] Squash to "selftests/bpf: add two mptcp netns helpers"
2023-07-03 6:39 [PATCH mptcp-next v3 0/5] BPF 'force to MPTCP' Geliang Tang
@ 2023-07-03 6:39 ` Geliang Tang
2023-07-03 6:39 ` [PATCH mptcp-next v3 2/5] net: socket: add socket_create wrapper Geliang Tang
` (3 subsequent siblings)
4 siblings, 0 replies; 10+ messages in thread
From: Geliang Tang @ 2023-07-03 6:39 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
Move the helpers to the beginning.
Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
.../testing/selftests/bpf/prog_tests/mptcp.c | 40 +++++++++----------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c
index a968641cc94a..e430bebebcf0 100644
--- a/tools/testing/selftests/bpf/prog_tests/mptcp.c
+++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c
@@ -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;
--
2.35.3
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH mptcp-next v3 2/5] net: socket: add socket_create wrapper
2023-07-03 6:39 [PATCH mptcp-next v3 0/5] BPF 'force to MPTCP' Geliang Tang
2023-07-03 6:39 ` [PATCH mptcp-next v3 1/5] Squash to "selftests/bpf: add two mptcp netns helpers" Geliang Tang
@ 2023-07-03 6:39 ` Geliang Tang
2023-07-03 10:07 ` kernel test robot
2023-07-03 10:48 ` kernel test robot
2023-07-03 6:39 ` [PATCH mptcp-next v3 3/5] bpf: Add bpf_mptcpify helper Geliang Tang
` (2 subsequent siblings)
4 siblings, 2 replies; 10+ messages in thread
From: Geliang Tang @ 2023-07-03 6:39 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
The 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.
Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
include/linux/net.h | 6 ++++++
net/socket.c | 12 +++++++++++-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/include/linux/net.h b/include/linux/net.h
index 41c608c1b02c..81f6a85512ea 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -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
diff --git a/net/socket.c b/net/socket.c
index 2b0e54b2405c..72fc8701ce69 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -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);
--
2.35.3
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH mptcp-next v3 2/5] net: socket: add socket_create wrapper
2023-07-03 6:39 ` [PATCH mptcp-next v3 2/5] net: socket: add socket_create wrapper Geliang Tang
@ 2023-07-03 10:07 ` kernel test robot
2023-07-03 10:48 ` kernel test robot
1 sibling, 0 replies; 10+ messages in thread
From: kernel test robot @ 2023-07-03 10:07 UTC (permalink / raw)
To: Geliang Tang, mptcp; +Cc: llvm, oe-kbuild-all, Geliang Tang
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/202307031701.pEfe6hVq-lkp@intel.com/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a)
reproduce: (https://download.01.org/0day-ci/archive/20230703/202307031701.pEfe6hVq-lkp@intel.com/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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202307031701.pEfe6hVq-lkp@intel.com/
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
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH mptcp-next v3 2/5] net: socket: add socket_create wrapper
2023-07-03 6:39 ` [PATCH mptcp-next v3 2/5] net: socket: add socket_create wrapper Geliang Tang
2023-07-03 10:07 ` kernel test robot
@ 2023-07-03 10:48 ` kernel test robot
1 sibling, 0 replies; 10+ messages in thread
From: kernel test robot @ 2023-07-03 10:48 UTC (permalink / raw)
To: Geliang Tang, mptcp; +Cc: oe-kbuild-all, Geliang Tang
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/202307031850.054Lqlel-lkp@intel.com/config)
compiler: arc-elf-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230703/202307031850.054Lqlel-lkp@intel.com/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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202307031850.054Lqlel-lkp@intel.com/
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
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH mptcp-next v3 3/5] bpf: Add bpf_mptcpify helper
2023-07-03 6:39 [PATCH mptcp-next v3 0/5] BPF 'force to MPTCP' Geliang Tang
2023-07-03 6:39 ` [PATCH mptcp-next v3 1/5] Squash to "selftests/bpf: add two mptcp netns helpers" Geliang Tang
2023-07-03 6:39 ` [PATCH mptcp-next v3 2/5] net: socket: add socket_create wrapper Geliang Tang
@ 2023-07-03 6:39 ` Geliang Tang
2023-07-21 1:20 ` kernel test robot
2023-07-03 6:39 ` [PATCH mptcp-next v3 4/5] selftests/bpf: Test " Geliang Tang
2023-07-03 6:40 ` [PATCH mptcp-next v3 5/5] selftests/bpf: Add mptcpify selftest Geliang Tang
4 siblings, 1 reply; 10+ messages in thread
From: Geliang Tang @ 2023-07-03 6:39 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
This 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.
Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
include/uapi/linux/bpf.h | 7 +++++++
kernel/trace/bpf_trace.c | 23 +++++++++++++++++++++++
tools/include/uapi/linux/bpf.h | 7 +++++++
3 files changed, 37 insertions(+)
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index 60a9d59beeab..0fb8222964d6 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -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
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 03b7f6b8e4f0..272166e9689a 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -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 ?
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index 60a9d59beeab..0fb8222964d6 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -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
--
2.35.3
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH mptcp-next v3 3/5] bpf: Add bpf_mptcpify helper
2023-07-03 6:39 ` [PATCH mptcp-next v3 3/5] bpf: Add bpf_mptcpify helper Geliang Tang
@ 2023-07-21 1:20 ` kernel test robot
0 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2023-07-21 1:20 UTC (permalink / raw)
To: Geliang Tang, mptcp; +Cc: oe-kbuild-all, Geliang Tang
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/202307210923.TeQxMqW5-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce: (https://download.01.org/0day-ci/archive/20230721/202307210923.TeQxMqW5-lkp@intel.com/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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202307210923.TeQxMqW5-lkp@intel.com/
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
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH mptcp-next v3 4/5] selftests/bpf: Test bpf_mptcpify helper
2023-07-03 6:39 [PATCH mptcp-next v3 0/5] BPF 'force to MPTCP' Geliang Tang
` (2 preceding siblings ...)
2023-07-03 6:39 ` [PATCH mptcp-next v3 3/5] bpf: Add bpf_mptcpify helper Geliang Tang
@ 2023-07-03 6:39 ` Geliang Tang
2023-07-03 6:40 ` [PATCH mptcp-next v3 5/5] selftests/bpf: Add mptcpify selftest Geliang Tang
4 siblings, 0 replies; 10+ messages in thread
From: Geliang Tang @ 2023-07-03 6:39 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
This 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().
Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
tools/testing/selftests/bpf/progs/mptcpify.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
create mode 100644 tools/testing/selftests/bpf/progs/mptcpify.c
diff --git a/tools/testing/selftests/bpf/progs/mptcpify.c b/tools/testing/selftests/bpf/progs/mptcpify.c
new file mode 100644
index 000000000000..18078c1d351a
--- /dev/null
+++ b/tools/testing/selftests/bpf/progs/mptcpify.c
@@ -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;
+}
--
2.35.3
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH mptcp-next v3 5/5] selftests/bpf: Add mptcpify selftest
2023-07-03 6:39 [PATCH mptcp-next v3 0/5] BPF 'force to MPTCP' Geliang Tang
` (3 preceding siblings ...)
2023-07-03 6:39 ` [PATCH mptcp-next v3 4/5] selftests/bpf: Test " Geliang Tang
@ 2023-07-03 6:40 ` Geliang Tang
2023-07-03 7:52 ` selftests/bpf: Add mptcpify selftest: Tests Results MPTCP CI
4 siblings, 1 reply; 10+ messages in thread
From: Geliang Tang @ 2023-07-03 6:40 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
This 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.
Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
.../testing/selftests/bpf/prog_tests/mptcp.c | 87 +++++++++++++++++++
1 file changed, 87 insertions(+)
diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c
index e430bebebcf0..ac38d473329d 100644
--- a/tools/testing/selftests/bpf/prog_tests/mptcp.c
+++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c
@@ -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"))
--
2.35.3
^ permalink raw reply related [flat|nested] 10+ messages in thread