Skip to contentSkip to conversation

update bpf patches on export branch

PATCH In review Geliang Tang 4 participants 22 messages May 11, 2022 – May 16, 2022

Subsystems (11)
lore
Share & tools
lore
#0 lore raw

v2 cover update bpf patches on export branch

v2:
- drop "bpf: expose is_mptcp flag to bpf_tcp_sock" (Martin & Andrii)
- patch 3, use is_mptcp in tcp_sock, instead of bpf_tcp_sock (Martin & Andrii)

base-commit: bcf89bc9c28e ("DO-NOT-MERGE: git markup: features net-next-next") on export/20220510T054929

v1:
- drop bpf_mptcp_helpers.h (Andrii)
- patch 6, skip the test if 'ip mptcp monitor' is not supported (Mat)

Geliang Tang (13):
bpf: add bpf_skc_to_mptcp_sock_proto selftests/bpf: Enable CONFIG_IKCONFIG_PROC in config selftests/bpf: test bpf_skc_to_mptcp_sock selftests/bpf: verify token of struct mptcp_sock selftests/bpf: verify ca_name of struct mptcp_sock selftests/bpf: verify first of struct mptcp_sock
mptcp: add struct mptcp_sched_ops
mptcp: add a new sysctl scheduler
mptcp: add sched in mptcp_sock
mptcp: add get_subflow wrappers
mptcp: add bpf_mptcp_sched_ops selftests/bpf: add bpf_first scheduler selftests/bpf: add bpf_first test

Nicolas Rybowski (1):
selftests/bpf: add MPTCP test base

 Documentation/networking/mptcp-sysctl.rst     |   8 +
 MAINTAINERS                                   |   1 +
 include/linux/bpf.h                           |   1 +
 include/linux/btf_ids.h                       |   3 +-
 include/net/mptcp.h                           |  25 ++
 include/uapi/linux/bpf.h                      |   7 +
 kernel/bpf/bpf_struct_ops_types.h             |   4 +
 kernel/bpf/verifier.c                         |   1 +
 kernel/trace/bpf_trace.c                      |   2 +
 net/core/filter.c                             |  18 +
 net/mptcp/Makefile                            |   4 +-
 net/mptcp/bpf.c                               | 175 ++++++++
 net/mptcp/ctrl.c                              |  14 +
 net/mptcp/protocol.c                          |  32 +-
 net/mptcp/protocol.h                          |  12 +
 net/mptcp/sched.c                             | 141 +++++++
 scripts/bpf_doc.py                            |   2 +
 tools/include/uapi/linux/bpf.h                |   7 +
 tools/testing/selftests/bpf/bpf_tcp_helpers.h |  32 ++
 tools/testing/selftests/bpf/config            |   3 +
 tools/testing/selftests/bpf/network_helpers.c |  43 +-
 tools/testing/selftests/bpf/network_helpers.h |   4 +
 .../testing/selftests/bpf/prog_tests/mptcp.c  | 378 ++++++++++++++++++
 .../selftests/bpf/progs/mptcp_bpf_first.c     |  32 ++
 .../testing/selftests/bpf/progs/mptcp_sock.c  |  82 ++++
 25 files changed, 1002 insertions(+), 29 deletions(-)
 create mode 100644 net/mptcp/bpf.c
 create mode 100644 net/mptcp/sched.c
 create mode 100644 tools/testing/selftests/bpf/prog_tests/mptcp.c
 create mode 100644 tools/testing/selftests/bpf/progs/mptcp_bpf_first.c
 create mode 100644 tools/testing/selftests/bpf/progs/mptcp_sock.c
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/14 bpf: add bpf_skc_to_mptcp_sock_proto

This patch implements a new struct bpf_func_proto, named bpf_skc_to_mptcp_sock_proto. Define a new bpf_id BTF_SOCK_TYPE_MPTCP, and a new helper bpf_skc_to_mptcp_sock(), which invokes another new helper bpf_mptcp_sock_from_subflow() in net/mptcp/bpf.c to get struct mptcp_sock from a given subflow socket.

v2: Emit BTF type, add func_id checks in verifier.c and bpf_trace.c, remove build check for CONFIG_BPF_JIT

---
 include/linux/bpf.h            |  1 +
 include/linux/btf_ids.h        |  3 ++-
 include/net/mptcp.h            |  6 ++++++
 include/uapi/linux/bpf.h       |  7 +++++++
 kernel/bpf/verifier.c          |  1 +
 kernel/trace/bpf_trace.c       |  2 ++
 net/core/filter.c              | 18 ++++++++++++++++++
 net/mptcp/Makefile             |  2 ++
 net/mptcp/bpf.c                | 22 ++++++++++++++++++++++
 scripts/bpf_doc.py             |  2 ++
 tools/include/uapi/linux/bpf.h |  7 +++++++
 11 files changed, 70 insertions(+), 1 deletion(-)
 create mode 100644 net/mptcp/bpf.c
include/linux/bpf.h +1 -0
index be94833d390a..f53e39065a6e 100644
@@ -2204,6 +2204,7 @@ extern const struct bpf_func_proto bpf_skc_to_tcp_timewait_sock_proto;
 extern const struct bpf_func_proto bpf_skc_to_tcp_request_sock_proto;
 extern const struct bpf_func_proto bpf_skc_to_udp6_sock_proto;
 extern const struct bpf_func_proto bpf_skc_to_unix_sock_proto;
+extern const struct bpf_func_proto bpf_skc_to_mptcp_sock_proto;
 extern const struct bpf_func_proto bpf_copy_from_user_proto;
 extern const struct bpf_func_proto bpf_snprintf_btf_proto;
 extern const struct bpf_func_proto bpf_snprintf_proto;
include/linux/btf_ids.h +2 -1
index bc5d9cc34e4c..335a19092368 100644
@@ -178,7 +178,8 @@ extern struct btf_id_set name;
 	BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP6, tcp6_sock)			\
 	BTF_SOCK_TYPE(BTF_SOCK_TYPE_UDP, udp_sock)			\
 	BTF_SOCK_TYPE(BTF_SOCK_TYPE_UDP6, udp6_sock)			\
-	BTF_SOCK_TYPE(BTF_SOCK_TYPE_UNIX, unix_sock)
+	BTF_SOCK_TYPE(BTF_SOCK_TYPE_UNIX, unix_sock)			\
+	BTF_SOCK_TYPE(BTF_SOCK_TYPE_MPTCP, mptcp_sock)
 
 enum {
 #define BTF_SOCK_TYPE(name, str) name,
include/net/mptcp.h +6 -0
index d4ec894ce67b..4d761ad530c9 100644
@@ -284,4 +284,10 @@ static inline int mptcpv6_init(void) { return 0; }
 static inline void mptcpv6_handle_mapped(struct sock *sk, bool mapped) { }
 #endif
 
+#if defined(CONFIG_MPTCP) && defined(CONFIG_BPF_SYSCALL)
+struct mptcp_sock *bpf_mptcp_sock_from_subflow(struct sock *sk);
+#else
+static inline struct mptcp_sock *bpf_mptcp_sock_from_subflow(struct sock *sk) { return NULL; }
+#endif
+
 #endif /* __NET_MPTCP_H */
include/uapi/linux/bpf.h +7 -0
index 444fe6f1cf35..3e996e097084 100644
@@ -5154,6 +5154,12 @@ union bpf_attr {
  *		if not NULL, is a reference which must be released using its
  *		corresponding release function, or moved into a BPF map before
  *		program exit.
+ *
+ * struct mptcp_sock *bpf_skc_to_mptcp_sock(void *sk)
+ *	Description
+ *		Dynamically cast a *sk* pointer to a *mptcp_sock* pointer.
+ *	Return
+ *		*sk* if casting is valid, or **NULL** otherwise.
  */
 #define __BPF_FUNC_MAPPER(FN)		\
 	FN(unspec),			\
@@ -5351,6 +5357,7 @@ union bpf_attr {
 	FN(skb_set_tstamp),		\
 	FN(ima_file_hash),		\
 	FN(kptr_xchg),			\
+	FN(skc_to_mptcp_sock),		\
 	/* */
 
 /* integer value in 'imm' field of BPF_CALL instruction selects which helper
kernel/bpf/verifier.c +1 -0
index 813f6ee80419..3d8790e81c48 100644
@@ -509,6 +509,7 @@ static bool is_ptr_cast_function(enum bpf_func_id func_id)
 		func_id == BPF_FUNC_skc_to_tcp_sock ||
 		func_id == BPF_FUNC_skc_to_tcp6_sock ||
 		func_id == BPF_FUNC_skc_to_udp6_sock ||
+		func_id == BPF_FUNC_skc_to_mptcp_sock ||
 		func_id == BPF_FUNC_skc_to_tcp_timewait_sock ||
 		func_id == BPF_FUNC_skc_to_tcp_request_sock;
 }
kernel/trace/bpf_trace.c +2 -0
index f15b826f9899..8451fc83d031 100644
@@ -1688,6 +1688,8 @@ tracing_prog_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
 		return &bpf_skc_to_udp6_sock_proto;
 	case BPF_FUNC_skc_to_unix_sock:
 		return &bpf_skc_to_unix_sock_proto;
+	case BPF_FUNC_skc_to_mptcp_sock:
+		return &bpf_skc_to_mptcp_sock_proto;
 	case BPF_FUNC_sk_storage_get:
 		return &bpf_sk_storage_get_tracing_proto;
 	case BPF_FUNC_sk_storage_delete:
net/core/filter.c +18 -0
index b741b9f7e6a9..ef84a9087651 100644
@@ -78,6 +78,7 @@
 #include <linux/btf_ids.h>
 #include <net/tls.h>
 #include <net/xdp.h>
+#include <net/mptcp.h>
 
 static const struct bpf_func_proto *
 bpf_sk_base_func_proto(enum bpf_func_id func_id);
@@ -11272,6 +11273,20 @@ const struct bpf_func_proto bpf_skc_to_unix_sock_proto = {
 	.ret_btf_id		= &btf_sock_ids[BTF_SOCK_TYPE_UNIX],
 };
 
+BPF_CALL_1(bpf_skc_to_mptcp_sock, struct sock *, sk)
+{
+	BTF_TYPE_EMIT(struct mptcp_sock);
+	return (unsigned long)bpf_mptcp_sock_from_subflow(sk);
+}
+
+const struct bpf_func_proto bpf_skc_to_mptcp_sock_proto = {
+	.func		= bpf_skc_to_mptcp_sock,
+	.gpl_only	= false,
+	.ret_type	= RET_PTR_TO_BTF_ID_OR_NULL,
+	.arg1_type	= ARG_PTR_TO_SOCK_COMMON,
+	.ret_btf_id	= &btf_sock_ids[BTF_SOCK_TYPE_MPTCP],
+};
+
 BPF_CALL_1(bpf_sock_from_file, struct file *, file)
 {
 	return (unsigned long)sock_from_file(file);
@@ -11314,6 +11329,9 @@ bpf_sk_base_func_proto(enum bpf_func_id func_id)
 	case BPF_FUNC_skc_to_unix_sock:
 		func = &bpf_skc_to_unix_sock_proto;
 		break;
+	case BPF_FUNC_skc_to_mptcp_sock:
+		func = &bpf_skc_to_mptcp_sock_proto;
+		break;
 	case BPF_FUNC_ktime_get_coarse_ns:
 		return &bpf_ktime_get_coarse_ns_proto;
 	default:
net/mptcp/Makefile +2 -0
index cb7f53f6ab22..6e7df47c9584 100644
@@ -10,3 +10,5 @@ obj-$(CONFIG_INET_MPTCP_DIAG) += mptcp_diag.o
 mptcp_crypto_test-objs := crypto_test.o
 mptcp_token_test-objs := token_test.o
 obj-$(CONFIG_MPTCP_KUNIT_TEST) += mptcp_crypto_test.o mptcp_token_test.o
+
+obj-$(CONFIG_BPF_SYSCALL) += bpf.o
net/mptcp/bpf.c new file +22 -0
new file mode 100644
index 000000000000..535602ba2582
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Multipath TCP
+ *
+ * Copyright (c) 2020, Tessares SA.
+ * Copyright (c) 2022, SUSE.
+ *
+ * Author: Nicolas Rybowski <[email protected]>
+ */
+
+#define pr_fmt(fmt) "MPTCP: " fmt
+
+#include <linux/bpf.h>
+#include "protocol.h"
+
+struct mptcp_sock *bpf_mptcp_sock_from_subflow(struct sock *sk)
+{
+	if (sk && sk_fullsock(sk) && sk->sk_protocol == IPPROTO_TCP && sk_is_mptcp(sk))
+		return mptcp_sk(mptcp_subflow_ctx(sk)->conn);
+
+	return NULL;
+}
+EXPORT_SYMBOL(bpf_mptcp_sock_from_subflow);
scripts/bpf_doc.py +2 -0
index 096625242475..d5452f7eb996 100755
@@ -633,6 +633,7 @@ class PrinterHelpers(Printer):
             'struct socket',
             'struct file',
             'struct bpf_timer',
+            'struct mptcp_sock',
     ]
     known_types = {
             '...',
@@ -682,6 +683,7 @@ class PrinterHelpers(Printer):
             'struct socket',
             'struct file',
             'struct bpf_timer',
+            'struct mptcp_sock',
     }
     mapped_types = {
             'u8': '__u8',
tools/include/uapi/linux/bpf.h +7 -0
index 444fe6f1cf35..3e996e097084 100644
@@ -5154,6 +5154,12 @@ union bpf_attr {
  *		if not NULL, is a reference which must be released using its
  *		corresponding release function, or moved into a BPF map before
  *		program exit.
+ *
+ * struct mptcp_sock *bpf_skc_to_mptcp_sock(void *sk)
+ *	Description
+ *		Dynamically cast a *sk* pointer to a *mptcp_sock* pointer.
+ *	Return
+ *		*sk* if casting is valid, or **NULL** otherwise.
  */
 #define __BPF_FUNC_MAPPER(FN)		\
 	FN(unspec),			\
@@ -5351,6 +5357,7 @@ union bpf_attr {
 	FN(skb_set_tstamp),		\
 	FN(ima_file_hash),		\
 	FN(kptr_xchg),			\
+	FN(skc_to_mptcp_sock),		\
 	/* */
 
 /* integer value in 'imm' field of BPF_CALL instruction selects which helper
Signature · 1 line
2.34.1
#2 lore raw

PATCH v2 2/14 selftests/bpf: Enable CONFIG_IKCONFIG_PROC in config

In reply to Geliang Tang

CONFIG_IKCONFIG_PROC is required by BPF selftests, otherwise we get errors like this:

libbpf: failed to open system Kconfig
libbpf: failed to load object 'kprobe_multi'
libbpf: failed to load BPF skeleton 'kprobe_multi': -22

It's because /proc/config.gz is opened in bpf_object__read_kconfig_file() in tools/lib/bpf/libbpf.c:

        file = gzopen("/proc/config.gz", "r");

So this patch enables CONFIG_IKCONFIG and CONFIG_IKCONFIG_PROC in tools/testing/selftests/bpf/config.

---
 tools/testing/selftests/bpf/config | 2 ++
 1 file changed, 2 insertions(+)
tools/testing/selftests/bpf/config +2 -0
index 763db63a3890..8d7faff33c54 100644
@@ -53,3 +53,5 @@ CONFIG_NF_DEFRAG_IPV4=y
 CONFIG_NF_DEFRAG_IPV6=y
 CONFIG_NF_CONNTRACK=y
 CONFIG_USERFAULTFD=y
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
Signature · 1 line
2.34.1
#3 lore raw

PATCH v2 3/14 selftests/bpf: add MPTCP test base

In reply to Geliang Tang

From: Nicolas Rybowski <[email protected]>

This patch adds a base for MPTCP specific tests.

It is currently limited to the is_mptcp field in case of plain TCP connection because there is no easy way to get the subflow sk from a msk in userspace. This implies that we cannot lookup the sk_storage attached to the subflow sk in the sockops program.

v4:
- add copyright 2022 (Andrii)
- use ASSERT_* instead of CHECK_FAIL (Andrii)
- drop SEC("version") (Andrii)
- use is_mptcp in tcp_sock, instead of bpf_tcp_sock (Martin & Andrii)

---
 MAINTAINERS                                   |   1 +
 tools/testing/selftests/bpf/bpf_tcp_helpers.h |   1 +
 tools/testing/selftests/bpf/config            |   1 +
 tools/testing/selftests/bpf/network_helpers.c |  43 ++++--
 tools/testing/selftests/bpf/network_helpers.h |   4 +
 .../testing/selftests/bpf/prog_tests/mptcp.c  | 136 ++++++++++++++++++
 .../testing/selftests/bpf/progs/mptcp_sock.c  |  53 +++++++
 7 files changed, 231 insertions(+), 8 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/mptcp.c
 create mode 100644 tools/testing/selftests/bpf/progs/mptcp_sock.c
MAINTAINERS +1 -0
index 0ea12c2b53f3..fe03a22d7fe1 100644
@@ -13798,6 +13798,7 @@ F:	include/net/mptcp.h
 F:	include/trace/events/mptcp.h
 F:	include/uapi/linux/mptcp.h
 F:	net/mptcp/
+F:	tools/testing/selftests/bpf/*/*mptcp*.c
 F:	tools/testing/selftests/net/mptcp/
 
 NETWORKING [TCP]
tools/testing/selftests/bpf/bpf_tcp_helpers.h +1 -0
index b1ede6f0b821..22e0c8849a17 100644
@@ -81,6 +81,7 @@ struct tcp_sock {
 	__u32	lsndtime;
 	__u32	prior_cwnd;
 	__u64	tcp_mstamp;	/* most recent packet received/sent */
+	bool	is_mptcp;
 } __attribute__((preserve_access_index));
 
 static __always_inline struct inet_connection_sock *inet_csk(const struct sock *sk)
tools/testing/selftests/bpf/config +1 -0
index 8d7faff33c54..a25e15d55918 100644
@@ -55,3 +55,4 @@ CONFIG_NF_CONNTRACK=y
 CONFIG_USERFAULTFD=y
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
+CONFIG_MPTCP=y
tools/testing/selftests/bpf/network_helpers.c +35 -8

99 lines not on this page · raw message

tools/testing/selftests/bpf/network_helpers.h +4 -0
index a4b3b2f9877b..e0feb115b2ae 100644
@@ -21,6 +21,7 @@ struct network_helper_opts {
 	const char *cc;
 	int timeout_ms;
 	bool must_fail;
+	int protocol;
 };
 
 /* ipv4 test vector */
@@ -42,11 +43,14 @@ extern struct ipv6_packet pkt_v6;
 int settimeo(int fd, int timeout_ms);
 int start_server(int family, int type, const char *addr, __u16 port,
 		 int timeout_ms);
+int start_mptcp_server(int family, const char *addr, __u16 port,
+		       int timeout_ms);
 int *start_reuseport_server(int family, int type, const char *addr_str,
 			    __u16 port, int timeout_ms,
 			    unsigned int nr_listens);
 void free_fds(int *fds, unsigned int nr_close_fds);
 int connect_to_fd(int server_fd, int timeout_ms);
+int connect_to_mptcp_fd(int server_fd, int timeout_ms);
 int connect_to_fd_opts(int server_fd, const struct network_helper_opts *opts);
 int connect_fd_to_fd(int client_fd, int server_fd, int timeout_ms);
 int fastopen_connect(int server_fd, const char *data, unsigned int data_len,
tools/testing/selftests/bpf/prog_tests/mptcp.c new file +136 -0

136 lines not on this page · raw message

tools/testing/selftests/bpf/progs/mptcp_sock.c new file +53 -0

53 lines not on this page · raw message

Signature · 1 line
2.34.1
#4 lore raw

PATCH v2 4/14 selftests/bpf: test bpf_skc_to_mptcp_sock

In reply to Geliang Tang

This patch extends the MPTCP test base, to test the new helper bpf_skc_to_mptcp_sock().

Define struct mptcp_sock in bpf_tcp_helpers.h, use bpf_skc_to_mptcp_sock to get the msk socket in progs/mptcp_sock.c and store the infos in socket_storage_map.

Get the infos from socket_storage_map in prog_tests/mptcp.c. Add a new function verify_msk() to verify the infos of MPTCP socket, and rename verify_sk() to verify_tsk() to verify TCP socket only.

v2: Add CONFIG_MPTCP check for clearer error messages v4:
- use ASSERT_* instead of CHECK_FAIL (Andrii)
- drop bpf_mptcp_helpers.h (Andrii)

---
 tools/testing/selftests/bpf/bpf_tcp_helpers.h |  5 +++
 .../testing/selftests/bpf/prog_tests/mptcp.c  | 45 ++++++++++++++-----
 .../testing/selftests/bpf/progs/mptcp_sock.c  | 23 ++++++++--
 3 files changed, 58 insertions(+), 15 deletions(-)
tools/testing/selftests/bpf/bpf_tcp_helpers.h +5 -0
index 22e0c8849a17..90fecafc493d 100644
@@ -226,4 +226,9 @@ static __always_inline bool tcp_cc_eq(const char *a, const char *b)
 extern __u32 tcp_slow_start(struct tcp_sock *tp, __u32 acked) __ksym;
 extern void tcp_cong_avoid_ai(struct tcp_sock *tp, __u32 w, __u32 acked) __ksym;
 
+struct mptcp_sock {
+	struct inet_connection_sock	sk;
+
+} __attribute__((preserve_access_index));
+
 #endif
tools/testing/selftests/bpf/prog_tests/mptcp.c +34 -11

87 lines not on this page · raw message

tools/testing/selftests/bpf/progs/mptcp_sock.c +19 -4
index bc09dba0b078..3feb7ff578e2 100644
@@ -7,6 +7,7 @@
 #include "bpf_tcp_helpers.h"
 
 char _license[] SEC("license") = "GPL";
+extern bool CONFIG_MPTCP __kconfig;
 
 struct mptcp_storage {
 	__u32 invoked;
@@ -24,6 +25,7 @@ SEC("sockops")
 int _sockops(struct bpf_sock_ops *ctx)
 {
 	struct mptcp_storage *storage;
+	struct mptcp_sock *msk;
 	int op = (int)ctx->op;
 	struct tcp_sock *tsk;
 	struct bpf_sock *sk;
@@ -41,11 +43,24 @@ int _sockops(struct bpf_sock_ops *ctx)
 		return 1;
 
 	is_mptcp = bpf_core_field_exists(tsk->is_mptcp) ? tsk->is_mptcp : 0;
-	storage = bpf_sk_storage_get(&socket_storage_map, sk, 0,
-				     BPF_SK_STORAGE_GET_F_CREATE);
-	if (!storage)
-		return 1;
+	if (!is_mptcp) {
+		storage = bpf_sk_storage_get(&socket_storage_map, sk, 0,
+					     BPF_SK_STORAGE_GET_F_CREATE);
+		if (!storage)
+			return 1;
+	} else {
+		if (!CONFIG_MPTCP)
+			return 1;
+
+		msk = bpf_skc_to_mptcp_sock(sk);
+		if (!msk)
+			return 1;
 
+		storage = bpf_sk_storage_get(&socket_storage_map, msk, 0,
+					     BPF_SK_STORAGE_GET_F_CREATE);
+		if (!storage)
+			return 1;
+	}
 	storage->invoked++;
 	storage->is_mptcp = is_mptcp;
 
Signature · 1 line
2.34.1
#5 lore raw

PATCH v2 5/14 selftests/bpf: verify token of struct mptcp_sock

In reply to Geliang Tang

This patch verifies the struct member token of struct mptcp_sock. Add a new function get_msk_token() to parse the msk token from the output of the command 'ip mptcp monitor', and verify it in verify_msk().

v4:
- use ASSERT_* instead of CHECK_FAIL (Andrii)
- skip the test if 'ip mptcp monitor' is not supported (Mat)

---
 tools/testing/selftests/bpf/bpf_tcp_helpers.h |  1 +
 .../testing/selftests/bpf/prog_tests/mptcp.c  | 64 +++++++++++++++++++
 .../testing/selftests/bpf/progs/mptcp_sock.c  |  5 ++
 3 files changed, 70 insertions(+)
tools/testing/selftests/bpf/bpf_tcp_helpers.h +1 -0
index 90fecafc493d..422491872619 100644
@@ -229,6 +229,7 @@ extern void tcp_cong_avoid_ai(struct tcp_sock *tp, __u32 w, __u32 acked) __ksym;
 struct mptcp_sock {
 	struct inet_connection_sock	sk;
 
+	__u32		token;
 } __attribute__((preserve_access_index));
 
 #endif
tools/testing/selftests/bpf/prog_tests/mptcp.c +64 -0

107 lines not on this page · raw message

tools/testing/selftests/bpf/progs/mptcp_sock.c +5 -0
index 3feb7ff578e2..4890130826c6 100644
@@ -12,6 +12,7 @@ extern bool CONFIG_MPTCP __kconfig;
 struct mptcp_storage {
 	__u32 invoked;
 	__u32 is_mptcp;
+	__u32 token;
 };
 
 struct {
@@ -48,6 +49,8 @@ int _sockops(struct bpf_sock_ops *ctx)
 					     BPF_SK_STORAGE_GET_F_CREATE);
 		if (!storage)
 			return 1;
+
+		storage->token = 0;
 	} else {
 		if (!CONFIG_MPTCP)
 			return 1;
@@ -60,6 +63,8 @@ int _sockops(struct bpf_sock_ops *ctx)
 					     BPF_SK_STORAGE_GET_F_CREATE);
 		if (!storage)
 			return 1;
+
+		storage->token = msk->token;
 	}
 	storage->invoked++;
 	storage->is_mptcp = is_mptcp;
Signature · 1 line
2.34.1
#6 lore raw

PATCH v2 6/14 selftests/bpf: verify ca_name of struct mptcp_sock

In reply to Geliang Tang

This patch verifies another member of struct mptcp_sock, ca_name. Add a new function get_msk_ca_name() to read the sysctl tcp_congestion_control and verify it in verify_msk().

v3: Access the sysctl through the filesystem to avoid compatibility
issues with the busybox sysctl command.
v4: use ASSERT_* instead of CHECK_FAIL (Andrii)

---
 tools/testing/selftests/bpf/bpf_tcp_helpers.h |  5 +++
 .../testing/selftests/bpf/prog_tests/mptcp.c  | 34 +++++++++++++++++++
 .../testing/selftests/bpf/progs/mptcp_sock.c  |  4 +++
 3 files changed, 43 insertions(+)
tools/testing/selftests/bpf/bpf_tcp_helpers.h +5 -0
index 422491872619..c38c66d5c1e6 100644
@@ -16,6 +16,10 @@ BPF_PROG(name, args)
 #define SOL_TCP 6
 #endif
 
+#ifndef TCP_CA_NAME_MAX
+#define TCP_CA_NAME_MAX	16
+#endif
+
 #define tcp_jiffies32 ((__u32)bpf_jiffies64())
 
 struct sock_common {
@@ -230,6 +234,7 @@ struct mptcp_sock {
 	struct inet_connection_sock	sk;
 
 	__u32		token;
+	char		ca_name[TCP_CA_NAME_MAX];
 } __attribute__((preserve_access_index));
 
 #endif
tools/testing/selftests/bpf/prog_tests/mptcp.c +34 -0
index ac98aa314123..2ff7f18ea0ce 100644
@@ -6,10 +6,15 @@
 #include "cgroup_helpers.h"
 #include "network_helpers.h"
 
+#ifndef TCP_CA_NAME_MAX
+#define TCP_CA_NAME_MAX	16
+#endif
+
 struct mptcp_storage {
 	__u32 invoked;
 	__u32 is_mptcp;
 	__u32 token;
+	char ca_name[TCP_CA_NAME_MAX];
 };
 
 static char monitor_log_path[64];
@@ -75,17 +80,40 @@ static __u32 get_msk_token(void)
 	return token;
 }
 
+void get_msk_ca_name(char ca_name[])
+{
+	size_t len;
+	int fd;
+
+	fd = open("/proc/sys/net/ipv4/tcp_congestion_control", O_RDONLY);
+	if (!ASSERT_GE(fd, 0, "Failed to open tcp_congestion_control"))
+		return;
+
+	len = read(fd, ca_name, TCP_CA_NAME_MAX);
+	if (!ASSERT_GT(len, 0, "Failed to read ca_name"))
+		goto err;
+
+	if (len > 0 && ca_name[len - 1] == '\n')
+		ca_name[len - 1] = '\0';
+
+err:
+	close(fd);
+}
+
 static int verify_msk(int map_fd, int client_fd)
 {
 	char *msg = "MPTCP subflow socket";
 	int err, cfd = client_fd;
 	struct mptcp_storage val;
+	char ca_name[TCP_CA_NAME_MAX];
 	__u32 token;
 
 	token = get_msk_token();
 	if (!ASSERT_GT(token, 0, "Unexpected token"))
 		return -1;
 
+	get_msk_ca_name(ca_name);
+
 	err = bpf_map_lookup_elem(map_fd, &cfd, &val);
 	if (!ASSERT_OK(err, "bpf_map_lookup_elem"))
 		return err;
@@ -108,6 +136,12 @@ static int verify_msk(int map_fd, int client_fd)
 		err++;
 	}
 
+	if (strncmp(val.ca_name, ca_name, TCP_CA_NAME_MAX)) {
+		log_err("Unexpected mptcp_sock.ca_name %s != %s",
+			val.ca_name, ca_name);
+		err++;
+	}
+
 	return err;
 }
 
tools/testing/selftests/bpf/progs/mptcp_sock.c +4 -0
index 4890130826c6..c36f2f6bd2f1 100644
@@ -2,6 +2,7 @@
 /* Copyright (c) 2020, Tessares SA. */
 /* Copyright (c) 2022, SUSE. */
 
+#include <string.h>
 #include <linux/bpf.h>
 #include <bpf/bpf_helpers.h>
 #include "bpf_tcp_helpers.h"
@@ -13,6 +14,7 @@ struct mptcp_storage {
 	__u32 invoked;
 	__u32 is_mptcp;
 	__u32 token;
+	char ca_name[TCP_CA_NAME_MAX];
 };
 
 struct {
@@ -51,6 +53,7 @@ int _sockops(struct bpf_sock_ops *ctx)
 			return 1;
 
 		storage->token = 0;
+		bzero(storage->ca_name, TCP_CA_NAME_MAX);
 	} else {
 		if (!CONFIG_MPTCP)
 			return 1;
@@ -65,6 +68,7 @@ int _sockops(struct bpf_sock_ops *ctx)
 			return 1;
 
 		storage->token = msk->token;
+		memcpy(storage->ca_name, msk->ca_name, TCP_CA_NAME_MAX);
 	}
 	storage->invoked++;
 	storage->is_mptcp = is_mptcp;
Signature · 1 line
2.34.1
#7 lore raw

PATCH v2 7/14 selftests/bpf: verify first of struct mptcp_sock

In reply to Geliang Tang

This patch verifies the 'first' struct member of struct mptcp_sock, which points to the first subflow of msk. Save 'sk' in mptcp_storage, and verify it with 'first' in verify_msk().

---
 tools/testing/selftests/bpf/bpf_tcp_helpers.h  | 1 +
 tools/testing/selftests/bpf/prog_tests/mptcp.c | 8 ++++++++
 tools/testing/selftests/bpf/progs/mptcp_sock.c | 5 +++++
 3 files changed, 14 insertions(+)
tools/testing/selftests/bpf/bpf_tcp_helpers.h +1 -0
index c38c66d5c1e6..82a7c9de95f9 100644
@@ -234,6 +234,7 @@ struct mptcp_sock {
 	struct inet_connection_sock	sk;
 
 	__u32		token;
+	struct sock	*first;
 	char		ca_name[TCP_CA_NAME_MAX];
 } __attribute__((preserve_access_index));
 
tools/testing/selftests/bpf/prog_tests/mptcp.c +8 -0
index 2ff7f18ea0ce..51a3e17acb9e 100644
@@ -13,7 +13,9 @@
 struct mptcp_storage {
 	__u32 invoked;
 	__u32 is_mptcp;
+	struct sock *sk;
 	__u32 token;
+	struct sock *first;
 	char ca_name[TCP_CA_NAME_MAX];
 };
 
@@ -136,6 +138,12 @@ static int verify_msk(int map_fd, int client_fd)
 		err++;
 	}
 
+	if (val.first != val.sk) {
+		log_err("Unexpected mptcp_sock.first %p != %p",
+			val.first, val.sk);
+		err++;
+	}
+
 	if (strncmp(val.ca_name, ca_name, TCP_CA_NAME_MAX)) {
 		log_err("Unexpected mptcp_sock.ca_name %s != %s",
 			val.ca_name, ca_name);
tools/testing/selftests/bpf/progs/mptcp_sock.c +5 -0
index c36f2f6bd2f1..ab135edf3ae3 100644
@@ -13,7 +13,9 @@ extern bool CONFIG_MPTCP __kconfig;
 struct mptcp_storage {
 	__u32 invoked;
 	__u32 is_mptcp;
+	struct sock *sk;
 	__u32 token;
+	struct sock *first;
 	char ca_name[TCP_CA_NAME_MAX];
 };
 
@@ -54,6 +56,7 @@ int _sockops(struct bpf_sock_ops *ctx)
 
 		storage->token = 0;
 		bzero(storage->ca_name, TCP_CA_NAME_MAX);
+		storage->first = NULL;
 	} else {
 		if (!CONFIG_MPTCP)
 			return 1;
@@ -69,9 +72,11 @@ int _sockops(struct bpf_sock_ops *ctx)
 
 		storage->token = msk->token;
 		memcpy(storage->ca_name, msk->ca_name, TCP_CA_NAME_MAX);
+		storage->first = msk->first;
 	}
 	storage->invoked++;
 	storage->is_mptcp = is_mptcp;
+	storage->sk = (struct sock *)sk;
 
 	return 1;
 }
Signature · 1 line
2.34.1
#8 lore raw

PATCH v2 8/14 mptcp: add struct mptcp_sched_ops

In reply to Geliang Tang

This patch defines struct mptcp_sched_ops, which has three struct members, name, owner and list, and three function pointers, init, release and get_subflow.

Add the scheduler registering, unregistering and finding functions to add, delete and find a packet scheduler on the global list mptcp_sched_list.

For supporting a "redundant" packet scheduler in the future, this patch adds a flag in struct mptcp_sched_data named call_again to indicate that get_subflow() function needs to be called again.

---
 include/net/mptcp.h                           | 19 +++++++
 net/mptcp/Makefile                            |  2 +-
 net/mptcp/protocol.h                          |  3 +
 net/mptcp/sched.c                             | 56 +++++++++++++++++++
 tools/testing/selftests/bpf/bpf_tcp_helpers.h | 18 ++++++
 5 files changed, 97 insertions(+), 1 deletion(-)
 create mode 100644 net/mptcp/sched.c
include/net/mptcp.h +19 -0
index 4d761ad530c9..b596ba7a8494 100644
@@ -95,6 +95,25 @@ struct mptcp_out_options {
 #endif
 };
 
+#define MPTCP_SCHED_NAME_MAX	16
+
+struct mptcp_sched_data {
+	struct sock	*sock;
+	bool		call_again;
+};
+
+struct mptcp_sched_ops {
+	void (*get_subflow)(const struct mptcp_sock *msk, bool reinject,
+			    struct mptcp_sched_data *data);
+
+	char			name[MPTCP_SCHED_NAME_MAX];
+	struct module		*owner;
+	struct list_head	list;
+
+	void (*init)(const struct mptcp_sock *msk);
+	void (*release)(const struct mptcp_sock *msk);
+} ____cacheline_aligned_in_smp;
+
 #ifdef CONFIG_MPTCP
 extern struct request_sock_ops mptcp_subflow_request_sock_ops;
 
net/mptcp/Makefile +1 -1
index 6e7df47c9584..8a7f68efa35f 100644
@@ -2,7 +2,7 @@
 obj-$(CONFIG_MPTCP) += mptcp.o
 
 mptcp-y := protocol.o subflow.o options.o token.o crypto.o ctrl.o pm.o diag.o \
-	   mib.o pm_netlink.o sockopt.o pm_userspace.o
+	   mib.o pm_netlink.o sockopt.o pm_userspace.o sched.o
 
 obj-$(CONFIG_SYN_COOKIES) += syncookies.o
 obj-$(CONFIG_INET_MPTCP_DIAG) += mptcp_diag.o
net/mptcp/protocol.h +3 -0
index 06b8ebc15204..2f6c4486a009 100644
@@ -621,6 +621,9 @@ int mptcp_subflow_create_socket(struct sock *sk, struct socket **new_sock);
 void mptcp_info2sockaddr(const struct mptcp_addr_info *info,
 			 struct sockaddr_storage *addr,
 			 unsigned short family);
+struct mptcp_sched_ops *mptcp_sched_find(const char *name);
+int mptcp_register_scheduler(struct mptcp_sched_ops *sched);
+void mptcp_unregister_scheduler(struct mptcp_sched_ops *sched);
 
 static inline bool __mptcp_subflow_active(struct mptcp_subflow_context *subflow)
 {
net/mptcp/sched.c new file +56 -0

56 lines not on this page · raw message

tools/testing/selftests/bpf/bpf_tcp_helpers.h +18 -0
index 82a7c9de95f9..bca318d2cc78 100644
@@ -230,6 +230,24 @@ static __always_inline bool tcp_cc_eq(const char *a, const char *b)
 extern __u32 tcp_slow_start(struct tcp_sock *tp, __u32 acked) __ksym;
 extern void tcp_cong_avoid_ai(struct tcp_sock *tp, __u32 w, __u32 acked) __ksym;
 
+#define MPTCP_SCHED_NAME_MAX	16
+
+struct mptcp_sched_data {
+	struct sock	*sock;
+	bool		call_again;
+};
+
+struct mptcp_sched_ops {
+	char name[MPTCP_SCHED_NAME_MAX];
+
+	void (*init)(const struct mptcp_sock *msk);
+	void (*release)(const struct mptcp_sock *msk);
+
+	void (*get_subflow)(const struct mptcp_sock *msk, bool reinject,
+			    struct mptcp_sched_data *data);
+	void *owner;
+};
+
 struct mptcp_sock {
 	struct inet_connection_sock	sk;
 
Signature · 1 line
2.34.1
#9 lore raw

PATCH v2 9/14 mptcp: add a new sysctl scheduler

In reply to Geliang Tang

This patch adds a new sysctl, named scheduler, to support for selection of different schedulers. Export mptcp_get_scheduler helper to get this sysctl.

---
 Documentation/networking/mptcp-sysctl.rst |  8 ++++++++
 net/mptcp/ctrl.c                          | 14 ++++++++++++++
 net/mptcp/protocol.h                      |  1 +
 3 files changed, 23 insertions(+)
Documentation/networking/mptcp-sysctl.rst +8 -0
index e263dfcc4b40..d9e69fdc7ea3 100644
@@ -75,3 +75,11 @@ stale_loss_cnt - INTEGER
 	This is a per-namespace sysctl.
 
 	Default: 4
+
+scheduler - STRING
+	Select the scheduler of your choice.
+
+	Support for selection of different schedulers. This is a per-namespace
+	sysctl.
+
+	Default: "default"
net/mptcp/ctrl.c +14 -0
index ae20b7d92e28..c46c22a84d23 100644
@@ -32,6 +32,7 @@ struct mptcp_pernet {
 	u8 checksum_enabled;
 	u8 allow_join_initial_addr_port;
 	u8 pm_type;
+	char scheduler[MPTCP_SCHED_NAME_MAX];
 };
 
 static struct mptcp_pernet *mptcp_get_pernet(const struct net *net)
@@ -69,6 +70,11 @@ int mptcp_get_pm_type(const struct net *net)
 	return mptcp_get_pernet(net)->pm_type;
 }
 
+const char *mptcp_get_scheduler(const struct net *net)
+{
+	return mptcp_get_pernet(net)->scheduler;
+}
+
 static void mptcp_pernet_set_defaults(struct mptcp_pernet *pernet)
 {
 	pernet->mptcp_enabled = 1;
@@ -77,6 +83,7 @@ static void mptcp_pernet_set_defaults(struct mptcp_pernet *pernet)
 	pernet->allow_join_initial_addr_port = 1;
 	pernet->stale_loss_cnt = 4;
 	pernet->pm_type = MPTCP_PM_TYPE_KERNEL;
+	strcpy(pernet->scheduler, "default");
 }
 
 #ifdef CONFIG_SYSCTL
@@ -128,6 +135,12 @@ static struct ctl_table mptcp_sysctl_table[] = {
 		.extra1       = SYSCTL_ZERO,
 		.extra2       = &mptcp_pm_type_max
 	},
+	{
+		.procname = "scheduler",
+		.maxlen	= MPTCP_SCHED_NAME_MAX,
+		.mode = 0644,
+		.proc_handler = proc_dostring,
+	},
 	{}
 };
 
@@ -149,6 +162,7 @@ static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet)
 	table[3].data = &pernet->allow_join_initial_addr_port;
 	table[4].data = &pernet->stale_loss_cnt;
 	table[5].data = &pernet->pm_type;
+	table[6].data = &pernet->scheduler;
 
 	hdr = register_net_sysctl(net, MPTCP_SYSCTL_PATH, table);
 	if (!hdr)
net/mptcp/protocol.h +1 -0
index 2f6c4486a009..b52cef5fdd9c 100644
@@ -596,6 +596,7 @@ int mptcp_is_checksum_enabled(const struct net *net);
 int mptcp_allow_join_id0(const struct net *net);
 unsigned int mptcp_stale_loss_cnt(const struct net *net);
 int mptcp_get_pm_type(const struct net *net);
+const char *mptcp_get_scheduler(const struct net *net);
 void mptcp_subflow_fully_established(struct mptcp_subflow_context *subflow,
 				     struct mptcp_options_received *mp_opt);
 bool __mptcp_retransmit_pending_data(struct sock *sk);
Signature · 1 line
2.34.1
#10 lore raw

PATCH v2 10/14 mptcp: add sched in mptcp_sock

In reply to Geliang Tang

This patch adds a new struct member sched in struct mptcp_sock. And two helpers mptcp_init_sched() and mptcp_release_sched() to init and release it.

Init it with the sysctl scheduler in mptcp_init_sock(), copy the scheduler from the parent in mptcp_sk_clone(), and release it in __mptcp_destroy_sock().

---
 net/mptcp/protocol.c                          |  7 ++++
 net/mptcp/protocol.h                          |  4 +++
 net/mptcp/sched.c                             | 33 +++++++++++++++++++
 tools/testing/selftests/bpf/bpf_tcp_helpers.h |  1 +
 4 files changed, 45 insertions(+)
net/mptcp/protocol.c +7 -0
index 921d67174e49..3e9246822412 100644
@@ -2657,6 +2657,11 @@ static int mptcp_init_sock(struct sock *sk)
 	if (ret)
 		return ret;
 
+	ret = mptcp_init_sched(mptcp_sk(sk),
+			       mptcp_sched_find(mptcp_get_scheduler(net)));
+	if (ret)
+		return ret;
+
 	/* fetch the ca name; do it outside __mptcp_init_sock(), so that clone will
 	 * propagate the correct value
 	 */
@@ -2812,6 +2817,7 @@ static void __mptcp_destroy_sock(struct sock *sk)
 	mptcp_stop_timer(sk);
 	sk_stop_timer(sk, &sk->sk_timer);
 	msk->pm.status = 0;
+	mptcp_release_sched(msk);
 
 	/* clears msk->subflow, allowing the following loop to close
 	 * even the initial subflow
@@ -2985,6 +2991,7 @@ struct sock *mptcp_sk_clone(const struct sock *sk,
 	msk->snd_una = msk->write_seq;
 	msk->wnd_end = msk->snd_nxt + req->rsk_rcv_wnd;
 	msk->setsockopt_seq = mptcp_sk(sk)->setsockopt_seq;
+	mptcp_init_sched(msk, mptcp_sk(sk)->sched);
 
 	if (mp_opt->suboptions & OPTIONS_MPTCP_MPC) {
 		msk->can_ack = true;
net/mptcp/protocol.h +4 -0
index b52cef5fdd9c..85dd69b8d9d5 100644
@@ -298,6 +298,7 @@ struct mptcp_sock {
 	struct socket	*subflow; /* outgoing connect/listener/!mp_capable */
 	struct sock	*first;
 	struct mptcp_pm_data	pm;
+	struct mptcp_sched_ops	*sched;
 	struct {
 		u32	space;	/* bytes copied in last measurement window */
 		u32	copied; /* bytes copied in this measurement window */
@@ -625,6 +626,9 @@ void mptcp_info2sockaddr(const struct mptcp_addr_info *info,
 struct mptcp_sched_ops *mptcp_sched_find(const char *name);
 int mptcp_register_scheduler(struct mptcp_sched_ops *sched);
 void mptcp_unregister_scheduler(struct mptcp_sched_ops *sched);
+int mptcp_init_sched(struct mptcp_sock *msk,
+		     struct mptcp_sched_ops *sched);
+void mptcp_release_sched(struct mptcp_sock *msk);
 
 static inline bool __mptcp_subflow_active(struct mptcp_subflow_context *subflow)
 {
net/mptcp/sched.c +33 -0
index c5d3bbafba71..53773668b5ee 100644
@@ -54,3 +54,36 @@ void mptcp_unregister_scheduler(struct mptcp_sched_ops *sched)
 	list_del_rcu(&sched->list);
 	spin_unlock(&mptcp_sched_list_lock);
 }
+
+int mptcp_init_sched(struct mptcp_sock *msk,
+		     struct mptcp_sched_ops *sched)
+{
+	if (!sched)
+		goto out;
+
+	if (!bpf_try_module_get(sched, sched->owner))
+		return -EBUSY;
+
+	msk->sched = sched;
+	if (msk->sched->init)
+		msk->sched->init(msk);
+
+	pr_debug("sched=%s", msk->sched->name);
+
+out:
+	return 0;
+}
+
+void mptcp_release_sched(struct mptcp_sock *msk)
+{
+	struct mptcp_sched_ops *sched = msk->sched;
+
+	if (!sched)
+		return;
+
+	msk->sched = NULL;
+	if (sched->release)
+		sched->release(msk);
+
+	bpf_module_put(sched, sched->owner);
+}
tools/testing/selftests/bpf/bpf_tcp_helpers.h +1 -0
index bca318d2cc78..e17ce2b856bd 100644
@@ -253,6 +253,7 @@ struct mptcp_sock {
 
 	__u32		token;
 	struct sock	*first;
+	struct mptcp_sched_ops *sched;
 	char		ca_name[TCP_CA_NAME_MAX];
 } __attribute__((preserve_access_index));
 
Signature · 1 line
2.34.1
#11 lore raw

PATCH v2 11/14 mptcp: add get_subflow wrappers

In reply to Geliang Tang

This patch defines two new wrappers mptcp_sched_get_send() and mptcp_sched_get_retrans(), invoke get_subflow() of msk->sched in them. Use them instead of using mptcp_subflow_get_send() or mptcp_subflow_get_retrans() directly.

---
 net/mptcp/protocol.c | 25 +++++----------------
 net/mptcp/protocol.h |  4 ++++
 net/mptcp/sched.c    | 52 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 62 insertions(+), 19 deletions(-)
net/mptcp/protocol.c +6 -19
index 3e9246822412..ea3c93322592 100644
@@ -1427,7 +1427,7 @@ bool mptcp_subflow_active(struct mptcp_subflow_context *subflow)
  * returns the subflow that will transmit the next DSS
  * additionally updates the rtx timeout
  */
-static struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk)
+struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk)
 {
 	struct subflow_send_info send_info[SSK_MODE_MAX];
 	struct mptcp_subflow_context *subflow;
@@ -1438,14 +1438,6 @@ static struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk)
 	u64 linger_time;
 	long tout = 0;
 
-	sock_owned_by_me(sk);
-
-	if (__mptcp_check_fallback(msk)) {
-		if (!msk->first)
-			return NULL;
-		return sk_stream_memory_free(msk->first) ? msk->first : NULL;
-	}
-
 	/* re-use last subflow, if the burst allow that */
 	if (msk->last_snd && msk->snd_burst > 0 &&
 	    sk_stream_memory_free(msk->last_snd) &&
@@ -1575,7 +1567,7 @@ void __mptcp_push_pending(struct sock *sk, unsigned int flags)
 			int ret = 0;
 
 			prev_ssk = ssk;
-			ssk = mptcp_subflow_get_send(msk);
+			ssk = mptcp_sched_get_send(msk);
 
 			/* First check. If the ssk has changed since
 			 * the last round, release prev_ssk
@@ -1642,7 +1634,7 @@ static void __mptcp_subflow_push_pending(struct sock *sk, struct sock *ssk)
 			 * check for a different subflow usage only after
 			 * spooling the first chunk of data
 			 */
-			xmit_ssk = first ? ssk : mptcp_subflow_get_send(mptcp_sk(sk));
+			xmit_ssk = first ? ssk : mptcp_sched_get_send(mptcp_sk(sk));
 			if (!xmit_ssk)
 				goto out;
 			if (xmit_ssk != ssk) {
@@ -2216,17 +2208,12 @@ static void mptcp_timeout_timer(struct timer_list *t)
  *
  * A backup subflow is returned only if that is the only kind available.
  */
-static struct sock *mptcp_subflow_get_retrans(struct mptcp_sock *msk)
+struct sock *mptcp_subflow_get_retrans(struct mptcp_sock *msk)
 {
 	struct sock *backup = NULL, *pick = NULL;
 	struct mptcp_subflow_context *subflow;
 	int min_stale_count = INT_MAX;
 
-	sock_owned_by_me((const struct sock *)msk);
-
-	if (__mptcp_check_fallback(msk))
-		return NULL;
-
 	mptcp_for_each_subflow(msk, subflow) {
 		struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
 
@@ -2479,7 +2466,7 @@ static void __mptcp_retrans(struct sock *sk)
 	mptcp_clean_una_wakeup(sk);
 
 	/* first check ssk: need to kick "stale" logic */
-	ssk = mptcp_subflow_get_retrans(msk);
+	ssk = mptcp_sched_get_retrans(msk);
 	dfrag = mptcp_rtx_head(sk);
 	if (!dfrag) {
 		if (mptcp_data_fin_enabled(msk)) {
@@ -3128,7 +3115,7 @@ void __mptcp_check_push(struct sock *sk, struct sock *ssk)
 		return;
 
 	if (!sock_owned_by_user(sk)) {
-		struct sock *xmit_ssk = mptcp_subflow_get_send(mptcp_sk(sk));
+		struct sock *xmit_ssk = mptcp_sched_get_send(mptcp_sk(sk));
 
 		if (xmit_ssk == ssk)
 			__mptcp_subflow_push_pending(sk, ssk);
net/mptcp/protocol.h +4 -0
index 85dd69b8d9d5..59a23838782f 100644
@@ -629,6 +629,10 @@ void mptcp_unregister_scheduler(struct mptcp_sched_ops *sched);
 int mptcp_init_sched(struct mptcp_sock *msk,
 		     struct mptcp_sched_ops *sched);
 void mptcp_release_sched(struct mptcp_sock *msk);
+struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk);
+struct sock *mptcp_subflow_get_retrans(struct mptcp_sock *msk);
+struct sock *mptcp_sched_get_send(struct mptcp_sock *msk);
+struct sock *mptcp_sched_get_retrans(struct mptcp_sock *msk);
 
 static inline bool __mptcp_subflow_active(struct mptcp_subflow_context *subflow)
 {
net/mptcp/sched.c +52 -0

55 lines not on this page · raw message

Signature · 1 line
2.34.1
#12 lore raw

PATCH v2 12/14 mptcp: add bpf_mptcp_sched_ops

In reply to Geliang Tang

This patch implements a new struct bpf_struct_ops, bpf_mptcp_sched_ops. Register and unregister the bpf scheduler in .reg and .unreg.

This MPTCP BPF scheduler implementation is similar to BPF TCP CC. And net/ipv4/bpf_tcp_ca.c is a frame of reference for this patch.

---
 kernel/bpf/bpf_struct_ops_types.h |   4 +
 net/mptcp/bpf.c                   | 153 ++++++++++++++++++++++++++++++
 2 files changed, 157 insertions(+)
kernel/bpf/bpf_struct_ops_types.h +4 -0
index 5678a9ddf817..5a6b0c0d8d3d 100644
@@ -8,5 +8,9 @@ BPF_STRUCT_OPS_TYPE(bpf_dummy_ops)
 #ifdef CONFIG_INET
 #include <net/tcp.h>
 BPF_STRUCT_OPS_TYPE(tcp_congestion_ops)
+#ifdef CONFIG_MPTCP
+#include <net/mptcp.h>
+BPF_STRUCT_OPS_TYPE(mptcp_sched_ops)
+#endif
 #endif
 #endif
net/mptcp/bpf.c +153 -0

161 lines not on this page · raw message

Signature · 1 line
2.34.1
#13 lore raw

PATCH v2 13/14 selftests/bpf: add bpf_first scheduler

In reply to Geliang Tang

This patch implements the simplest MPTCP scheduler, named bpf_first, which always picks the first subflow to send data. It's a sample of MPTCP BPF scheduler implementations.

---
 .../selftests/bpf/progs/mptcp_bpf_first.c     | 32 +++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 tools/testing/selftests/bpf/progs/mptcp_bpf_first.c
tools/testing/selftests/bpf/progs/mptcp_bpf_first.c new file +32 -0
new file mode 100644
index 000000000000..fd67b5f42964
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2022, SUSE. */
+
+#include <linux/bpf.h>
+#include "bpf_tcp_helpers.h"
+
+char _license[] SEC("license") = "GPL";
+
+SEC("struct_ops/mptcp_sched_first_init")
+void BPF_PROG(mptcp_sched_first_init, const struct mptcp_sock *msk)
+{
+}
+
+SEC("struct_ops/mptcp_sched_first_release")
+void BPF_PROG(mptcp_sched_first_release, const struct mptcp_sock *msk)
+{
+}
+
+void BPF_STRUCT_OPS(bpf_first_get_subflow, const struct mptcp_sock *msk,
+		    bool reinject, struct mptcp_sched_data *data)
+{
+	data->sock = msk->first;
+	data->call_again = 0;
+}
+
+SEC(".struct_ops")
+struct mptcp_sched_ops first = {
+	.init		= (void *)mptcp_sched_first_init,
+	.release	= (void *)mptcp_sched_first_release,
+	.get_subflow	= (void *)bpf_first_get_subflow,
+	.name		= "bpf_first",
+};
Signature · 1 line
2.34.1
#14 lore raw

PATCH v2 14/14 selftests/bpf: add bpf_first test

In reply to Geliang Tang

This patch expends the MPTCP test base to support MPTCP packet scheduler tests. Add the bpf_first scheduler test in it. Use sysctl to set net.mptcp.scheduler to use this sched.

Some code in send_data() is from prog_tests/bpf_tcp_ca.c.

---
 .../testing/selftests/bpf/prog_tests/mptcp.c  | 113 ++++++++++++++++++
 1 file changed, 113 insertions(+)
tools/testing/selftests/bpf/prog_tests/mptcp.c +113 -0
index 51a3e17acb9e..93a5739712ce 100644
@@ -5,6 +5,7 @@
 #include <test_progs.h>
 #include "cgroup_helpers.h"
 #include "network_helpers.h"
+#include "mptcp_bpf_first.skel.h"
 
 #ifndef TCP_CA_NAME_MAX
 #define TCP_CA_NAME_MAX	16
@@ -20,6 +21,8 @@ struct mptcp_storage {
 };
 
 static char monitor_log_path[64];
+static const unsigned int total_bytes = 10 * 1024 * 1024;
+static int stop, duration;
 
 static int verify_tsk(int map_fd, int client_fd)
 {
@@ -258,8 +261,118 @@ void test_base(void)
 	close(cgroup_fd);
 }
 
+static void *server(void *arg)
+{
+	int lfd = (int)(long)arg, err = 0, fd;
+	ssize_t nr_sent = 0, bytes = 0;
+	char batch[1500];
+
+	fd = accept(lfd, NULL, NULL);
+	while (fd == -1) {
+		if (errno == EINTR)
+			continue;
+		err = -errno;
+		goto done;
+	}
+
+	if (settimeo(fd, 0)) {
+		err = -errno;
+		goto done;
+	}
+
+	while (bytes < total_bytes && !READ_ONCE(stop)) {
+		nr_sent = send(fd, &batch,
+			       MIN(total_bytes - bytes, sizeof(batch)), 0);
+		if (nr_sent == -1 && errno == EINTR)
+			continue;
+		if (nr_sent == -1) {
+			err = -errno;
+			break;
+		}
+		bytes += nr_sent;
+	}
+
+	CHECK(bytes != total_bytes, "send", "%zd != %u nr_sent:%zd errno:%d\n",
+	      bytes, total_bytes, nr_sent, errno);
+
+done:
+	if (fd >= 0)
+		close(fd);
+	if (err) {
+		WRITE_ONCE(stop, 1);
+		return ERR_PTR(err);
+	}
+	return NULL;
+}
+
+static void send_data(int lfd, int fd)
+{
+	ssize_t nr_recv = 0, bytes = 0;
+	pthread_t srv_thread;
+	void *thread_ret;
+	char batch[1500];
+	int err;
+
+	WRITE_ONCE(stop, 0);
+
+	err = pthread_create(&srv_thread, NULL, server, (void *)(long)lfd);
+	if (CHECK(err != 0, "pthread_create", "err:%d errno:%d\n", err, errno))
+		return;
+
+	/* recv total_bytes */
+	while (bytes < total_bytes && !READ_ONCE(stop)) {
+		nr_recv = recv(fd, &batch,
+			       MIN(total_bytes - bytes, sizeof(batch)), 0);
+		if (nr_recv == -1 && errno == EINTR)
+			continue;
+		if (nr_recv == -1)
+			break;
+		bytes += nr_recv;
+	}
+
+	CHECK(bytes != total_bytes, "recv", "%zd != %u nr_recv:%zd errno:%d\n",
+	      bytes, total_bytes, nr_recv, errno);
+
+	WRITE_ONCE(stop, 1);
+
+	pthread_join(srv_thread, &thread_ret);
+	CHECK(IS_ERR(thread_ret), "pthread_join", "thread_ret:%ld",
+	      PTR_ERR(thread_ret));
+}
+
+static void test_first(void)
+{
+	struct mptcp_bpf_first *first_skel;
+	int server_fd, client_fd;
+	struct bpf_link *link;
+
+	first_skel = mptcp_bpf_first__open_and_load();
+	if (!ASSERT_OK_PTR(first_skel, "bpf_first__open_and_load"))
+		return;
+
+	link = bpf_map__attach_struct_ops(first_skel->maps.first);
+	if (!ASSERT_OK_PTR(link, "bpf_map__attach_struct_ops")) {
+		mptcp_bpf_first__destroy(first_skel);
+		return;
+	}
+
+	system("sysctl -qw net.mptcp.scheduler=bpf_first");
+	server_fd = start_mptcp_server(AF_INET, NULL, 0, 0);
+	client_fd = connect_to_mptcp_fd(server_fd, 0);
+
+	send_data(server_fd, client_fd);
+
+	close(client_fd);
+	close(server_fd);
+	system("sysctl -qw net.mptcp.scheduler=default");
+	bpf_link__destroy(link);
+	mptcp_bpf_first__destroy(first_skel);
+}
+
 void test_mptcp(void)
 {
 	if (test__start_subtest("base"))
 		test_base();
+	if (test__start_subtest("first"))
+		test_first();
 }
Signature · 1 line
2.34.1
#15 lore raw
In reply to Geliang Tang
Quoted 7 lines · Geliang Tang

v2:
- drop "bpf: expose is_mptcp flag to bpf_tcp_sock" (Martin & Andrii)
- patch 3, use is_mptcp in tcp_sock, instead of bpf_tcp_sock (Martin & Andrii)

base-commit: bcf89bc9c28e ("DO-NOT-MERGE: git markup: features net-next-next") on export/20220510T054929

These look good to replace the equivalent patches in the export branch. Thanks Geliang.

- Mat

Quoted 48 lines

v1:
- drop bpf_mptcp_helpers.h (Andrii)
- patch 6, skip the test if 'ip mptcp monitor' is not supported (Mat)

Geliang Tang (13):
bpf: add bpf_skc_to_mptcp_sock_proto selftests/bpf: Enable CONFIG_IKCONFIG_PROC in config selftests/bpf: test bpf_skc_to_mptcp_sock selftests/bpf: verify token of struct mptcp_sock selftests/bpf: verify ca_name of struct mptcp_sock selftests/bpf: verify first of struct mptcp_sock
mptcp: add struct mptcp_sched_ops
mptcp: add a new sysctl scheduler
mptcp: add sched in mptcp_sock
mptcp: add get_subflow wrappers
mptcp: add bpf_mptcp_sched_ops selftests/bpf: add bpf_first scheduler selftests/bpf: add bpf_first test

Nicolas Rybowski (1):
selftests/bpf: add MPTCP test base

Documentation/networking/mptcp-sysctl.rst     |   8 +
MAINTAINERS                                   |   1 +
include/linux/bpf.h                           |   1 +
include/linux/btf_ids.h                       |   3 +-
include/net/mptcp.h                           |  25 ++
include/uapi/linux/bpf.h                      |   7 +
kernel/bpf/bpf_struct_ops_types.h             |   4 +
kernel/bpf/verifier.c                         |   1 +
kernel/trace/bpf_trace.c                      |   2 +
net/core/filter.c                             |  18 +
net/mptcp/Makefile                            |   4 +-
net/mptcp/bpf.c                               | 175 ++++++++
net/mptcp/ctrl.c                              |  14 +
net/mptcp/protocol.c                          |  32 +-
net/mptcp/protocol.h                          |  12 +
net/mptcp/sched.c                             | 141 +++++++
scripts/bpf_doc.py                            |   2 +
tools/include/uapi/linux/bpf.h                |   7 +
tools/testing/selftests/bpf/bpf_tcp_helpers.h |  32 ++
tools/testing/selftests/bpf/config            |   3 +
tools/testing/selftests/bpf/network_helpers.c |  43 +-
tools/testing/selftests/bpf/network_helpers.h |   4 +
.../testing/selftests/bpf/prog_tests/mptcp.c  | 378 ++++++++++++++++++
.../selftests/bpf/progs/mptcp_bpf_first.c     |  32 ++
.../testing/selftests/bpf/progs/mptcp_sock.c  |  82 ++++
25 files changed, 1002 insertions(+), 29 deletions(-)
Quoted 11 lines

create mode 100644 net/mptcp/bpf.c
create mode 100644 net/mptcp/sched.c
create mode 100644 tools/testing/selftests/bpf/prog_tests/mptcp.c create mode 100644 tools/testing/selftests/bpf/progs/mptcp_bpf_first.c create mode 100644 tools/testing/selftests/bpf/progs/mptcp_sock.c

Signature · 1 line
2.34.1

--
Mat Martineau
Intel

#16 lore raw
In reply to Geliang Tang

Hi Geliang, Mat

Quoted 10 lines · Geliang Tang

v2:
- drop "bpf: expose is_mptcp flag to bpf_tcp_sock" (Martin & Andrii)
- patch 3, use is_mptcp in tcp_sock, instead of bpf_tcp_sock (Martin & Andrii)

base-commit: bcf89bc9c28e ("DO-NOT-MERGE: git markup: features net-next-next") on export/20220510T054929

v1:
- drop bpf_mptcp_helpers.h (Andrii)
- patch 6, skip the test if 'ip mptcp monitor' is not supported (Mat)

Thank you for the patches.

I *think* everything is now sync in our tree but feel free to check because I had to "manually" compare patches with what was in our tree.

But in theory, our tree is now ready for a v5.

- 82041505ae27: tg:msg: changelog v4
- a59272c197c5: selftests/bpf: add MPTCP test base
- e30677603c0a: Squash to "selftests/bpf: add MPTCP test base"
- 79399587d58f: tg:msg: changelog v4
- b0d947191559: selftests/bpf: verify token of struct mptcp_sock
- d84ab981b155: conflict in t/selftests-bpf-verify-first-of-struct-mptcp_sock
- 0c8b3a796796: conflict in t/selftests-bpf-test-bpf_skc_to_mptcp_sock
- Results: 7809acd805cf..a4159e050cd2 (export)

Builds and tests are now in progress:

https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export/20220514T112122
https://github.com/multipath-tcp/mptcp_net-next/actions/workflows/build-validation.yml?query=branch:export

Cheers,
Matt

Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net
#17 lore raw
Quoted 14 lines · Matthieu Baerts

Hi Geliang, Mat

Quoted 10 lines · Geliang Tang

v2:
- drop "bpf: expose is_mptcp flag to bpf_tcp_sock" (Martin & Andrii)
- patch 3, use is_mptcp in tcp_sock, instead of bpf_tcp_sock (Martin & Andrii)

base-commit: bcf89bc9c28e ("DO-NOT-MERGE: git markup: features net-next-next") on export/20220510T054929

v1:
- drop bpf_mptcp_helpers.h (Andrii)
- patch 6, skip the test if 'ip mptcp monitor' is not supported (Mat)

Quoted 6 lines

Thank you for the patches.

I *think* everything is now sync in our tree but feel free to check because I had to "manually" compare patches with what was in our tree.

But in theory, our tree is now ready for a v5.

Thanks Matt, but three patches still need to be updated:

Patch #4, selftests/bpf: test bpf_skc_to_mptcp_sock

if (!tcp_sk->is_mptcp) {

->

if (!is_mptcp) {

Patch #10, mptcp: add sched in mptcp_sock

struct mptcp_sock {
struct inet_connection_sock sk;

- __u32 token;
- struct sock *first;
- char ca_name[TCP_CA_NAME_MAX];
+ __u32 token;
+ struct sock *first;
+ struct mptcp_sched_ops *sched;
+ char ca_name[TCP_CA_NAME_MAX];
} __attribute__((preserve_access_index));

->

__u32 token;
struct sock *first;
+ struct mptcp_sched_ops *sched;
char ca_name[TCP_CA_NAME_MAX];
} __attribute__((preserve_access_index));

Patch #13, selftests/bpf: add bpf_first scheduler

bpf_mptcp_helpers.h

->

bpf_tcp_helpers.h

Thanks,
-Geliang

Quoted 22 lines

- 82041505ae27: tg:msg: changelog v4
- a59272c197c5: selftests/bpf: add MPTCP test base
- e30677603c0a: Squash to "selftests/bpf: add MPTCP test base"
- 79399587d58f: tg:msg: changelog v4
- b0d947191559: selftests/bpf: verify token of struct mptcp_sock
- d84ab981b155: conflict in t/selftests-bpf-verify-first-of-struct-mptcp_sock
- 0c8b3a796796: conflict in t/selftests-bpf-test-bpf_skc_to_mptcp_sock
- Results: 7809acd805cf..a4159e050cd2 (export)

Builds and tests are now in progress:

https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export/20220514T112122
https://github.com/multipath-tcp/mptcp_net-next/actions/workflows/build-validation.yml?query=branch:export

Cheers,
Matt

Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net
#18 lore raw

Hi Geliang,

Quoted 24 lines · Geliang Tang
Quoted 14 lines · Matthieu Baerts

Hi Geliang, Mat

Quoted 10 lines · Geliang Tang

v2:
- drop "bpf: expose is_mptcp flag to bpf_tcp_sock" (Martin & Andrii)
- patch 3, use is_mptcp in tcp_sock, instead of bpf_tcp_sock (Martin & Andrii)

base-commit: bcf89bc9c28e ("DO-NOT-MERGE: git markup: features net-next-next") on export/20220510T054929

v1:
- drop bpf_mptcp_helpers.h (Andrii)
- patch 6, skip the test if 'ip mptcp monitor' is not supported (Mat)

Quoted 6 lines

Thank you for the patches.

I *think* everything is now sync in our tree but feel free to check because I had to "manually" compare patches with what was in our tree.

But in theory, our tree is now ready for a v5.

Thanks Matt, but three patches still need to be updated:

Quoted 7 lines

Patch #4, selftests/bpf: test bpf_skc_to_mptcp_sock

if (!tcp_sk->is_mptcp) {

->

if (!is_mptcp) {

Thank you, I missed that!

- a973ee164a70 tg: fix wrong merge conflict resolution

Quoted 11 lines

Patch #10, mptcp: add sched in mptcp_sock

struct mptcp_sock {

(quoted diff) +3 -3
 	struct inet_connection_sock	sk;
 
-	__u32		token;
-	struct sock	*first;
-	char		ca_name[TCP_CA_NAME_MAX];
+	__u32			token;
+	struct sock		*first;
+	struct mptcp_sched_ops	*sched;

Review

Quoted 10 lines
(quoted diff) +2 -1
+	char			ca_name[TCP_CA_NAME_MAX];
 } __attribute__((preserve_access_index));
 
->
 
 	__u32		token;
 	struct sock	*first;
+	struct mptcp_sched_ops *sched;
 	char		ca_name[TCP_CA_NAME_MAX];
 } __attribute__((preserve_access_index));

I did that on purpose, I thought it was clearer to read after.

Do you prefer not to change the alignment?

Quoted 7 lines

Patch #13, selftests/bpf: add bpf_first scheduler

bpf_mptcp_helpers.h

->

bpf_tcp_helpers.h

Thanks!

- fc2aafca4737: bpf: use bpf_tcp_helpers.h instead of the mptcp one

Cheers,
Matt

Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net
#19 lore raw

Hi Matt,

Quoted 62 lines · Matthieu Baerts <[email protected]> 于2022年5月15日周日 00:31写道:

Hi Geliang,

Quoted 24 lines · Geliang Tang
Quoted 14 lines · Matthieu Baerts

Hi Geliang, Mat

Quoted 10 lines · Geliang Tang

v2:
- drop "bpf: expose is_mptcp flag to bpf_tcp_sock" (Martin & Andrii)
- patch 3, use is_mptcp in tcp_sock, instead of bpf_tcp_sock (Martin & Andrii)

base-commit: bcf89bc9c28e ("DO-NOT-MERGE: git markup: features net-next-next") on export/20220510T054929

v1:
- drop bpf_mptcp_helpers.h (Andrii)
- patch 6, skip the test if 'ip mptcp monitor' is not supported (Mat)

Quoted 6 lines

Thank you for the patches.

I *think* everything is now sync in our tree but feel free to check because I had to "manually" compare patches with what was in our tree.

But in theory, our tree is now ready for a v5.

Thanks Matt, but three patches still need to be updated:

Quoted 7 lines

Patch #4, selftests/bpf: test bpf_skc_to_mptcp_sock

if (!tcp_sk->is_mptcp) {

->

if (!is_mptcp) {

Thank you, I missed that!

- a973ee164a70 tg: fix wrong merge conflict resolution

Quoted 11 lines

Patch #10, mptcp: add sched in mptcp_sock

 struct mptcp_sock {
      struct inet_connection_sock     sk;
(quoted diff) +3 -3
-     __u32           token;
-     struct sock     *first;
-     char            ca_name[TCP_CA_NAME_MAX];
+     __u32                   token;
+     struct sock             *first;
+     struct mptcp_sched_ops  *sched;

Review

Quoted 10 lines
(quoted diff) +2 -1
+     char                    ca_name[TCP_CA_NAME_MAX];
 } __attribute__((preserve_access_index));
 
->
 
      __u32           token;
      struct sock     *first;
+     struct mptcp_sched_ops *sched;
      char            ca_name[TCP_CA_NAME_MAX];
 } __attribute__((preserve_access_index));
Quoted 3 lines

I did that on purpose, I thought it was clearer to read after.

Do you prefer not to change the alignment?

Yes, I prefer not to change the alignments, it's much easier. If we want to change them, it's better to squash the changes into the original patches.

Thanks,
-Geliang

Quoted 19 lines
Quoted 8 lines

Patch #13, selftests/bpf: add bpf_first scheduler

bpf_mptcp_helpers.h

->

bpf_tcp_helpers.h

Thanks!

- fc2aafca4737: bpf: use bpf_tcp_helpers.h instead of the mptcp one

Cheers,
Matt
--
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net

#20 lore raw
Quoted 66 lines · Geliang Tang <[email protected]> 于2022年5月15日周日 00:46写道:

Hi Matt,

Quoted 62 lines · Matthieu Baerts <[email protected]> 于2022年5月15日周日 00:31写道:

Hi Geliang,

Quoted 24 lines · Geliang Tang
Quoted 14 lines · Matthieu Baerts

Hi Geliang, Mat

Quoted 10 lines · Geliang Tang

v2:
- drop "bpf: expose is_mptcp flag to bpf_tcp_sock" (Martin & Andrii)
- patch 3, use is_mptcp in tcp_sock, instead of bpf_tcp_sock (Martin & Andrii)

base-commit: bcf89bc9c28e ("DO-NOT-MERGE: git markup: features net-next-next") on export/20220510T054929

v1:
- drop bpf_mptcp_helpers.h (Andrii)
- patch 6, skip the test if 'ip mptcp monitor' is not supported (Mat)

Quoted 6 lines

Thank you for the patches.

I *think* everything is now sync in our tree but feel free to check because I had to "manually" compare patches with what was in our tree.

But in theory, our tree is now ready for a v5.

Thanks Matt, but three patches still need to be updated:

Quoted 7 lines

Patch #4, selftests/bpf: test bpf_skc_to_mptcp_sock

if (!tcp_sk->is_mptcp) {

->

if (!is_mptcp) {

Thank you, I missed that!

- a973ee164a70 tg: fix wrong merge conflict resolution

Quoted 21 lines

Patch #10, mptcp: add sched in mptcp_sock

 struct mptcp_sock {
      struct inet_connection_sock     sk;
(quoted diff) +5 -4
-     __u32           token;
-     struct sock     *first;
-     char            ca_name[TCP_CA_NAME_MAX];
+     __u32                   token;
+     struct sock             *first;
+     struct mptcp_sched_ops  *sched;
+     char                    ca_name[TCP_CA_NAME_MAX];
 } __attribute__((preserve_access_index));
 
->
 
      __u32           token;
      struct sock     *first;
+     struct mptcp_sched_ops *sched;
      char            ca_name[TCP_CA_NAME_MAX];
 } __attribute__((preserve_access_index));
Quoted 7 lines
Quoted 3 lines

I did that on purpose, I thought it was clearer to read after.

Do you prefer not to change the alignment?

Yes, I prefer not to change the alignments, it's much easier. If we want to change them, it's better to squash the changes into the original patches.

Hi Matt & Mat,

I think it's better to keep the alignment of members of mptcp_sock in bpf_tcp_helpers.h as the same as the alignment of mptcp_sock in net/mptcp/protocol.h. So I just sent a squash-to patch in our ML to fix this.

Anyway, bpf patches in our tree are now ready for a bpf-next v5.

Thanks,
-Geliang

Quoted 23 lines

Thanks,
-Geliang

Quoted 19 lines
Quoted 8 lines

Patch #13, selftests/bpf: add bpf_first scheduler

bpf_mptcp_helpers.h

->

bpf_tcp_helpers.h

Thanks!

- fc2aafca4737: bpf: use bpf_tcp_helpers.h instead of the mptcp one

Cheers,
Matt
--
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net

#21 lore raw
In reply to Matthieu Baerts
Quoted 32 lines · Matthieu Baerts <[email protected]> 于2022年5月15日周日 00:31写道:

Hi Geliang,

Quoted 28 lines · Geliang Tang
Quoted 14 lines · Matthieu Baerts

Hi Geliang, Mat

Quoted 10 lines · Geliang Tang

v2:
- drop "bpf: expose is_mptcp flag to bpf_tcp_sock" (Martin & Andrii)
- patch 3, use is_mptcp in tcp_sock, instead of bpf_tcp_sock (Martin & Andrii)

base-commit: bcf89bc9c28e ("DO-NOT-MERGE: git markup: features net-next-next") on export/20220510T054929

v1:
- drop bpf_mptcp_helpers.h (Andrii)
- patch 6, skip the test if 'ip mptcp monitor' is not supported (Mat)

Quoted 6 lines

Thank you for the patches.

I *think* everything is now sync in our tree but feel free to check because I had to "manually" compare patches with what was in our tree.

But in theory, our tree is now ready for a v5.

Thanks Matt, but three patches still need to be updated:

Patch #4, selftests/bpf: test bpf_skc_to_mptcp_sock

if (!tcp_sk->is_mptcp) {

Quoted 7 lines
Quoted 3 lines

->

if (!is_mptcp) {

Thank you, I missed that!

- a973ee164a70 tg: fix wrong merge conflict resolution

Hi Matt,

Here should be:

        if (!is_mptcp) {
not:
        if (is_mptcp) {

Otherwise, the mptcp bpf selftests failed.

I just sent a squash-to patch to fix this.

Thanks,
-Geliang

Quoted 45 lines
Quoted 12 lines

Patch #10, mptcp: add sched in mptcp_sock

 struct mptcp_sock {
      struct inet_connection_sock     sk;
(quoted diff) +3 -3
-     __u32           token;
-     struct sock     *first;
-     char            ca_name[TCP_CA_NAME_MAX];
+     __u32                   token;
+     struct sock             *first;
+     struct mptcp_sched_ops  *sched;

Review

Quoted 10 lines
(quoted diff) +2 -1
+     char                    ca_name[TCP_CA_NAME_MAX];
 } __attribute__((preserve_access_index));
 
->
 
      __u32           token;
      struct sock     *first;
+     struct mptcp_sched_ops *sched;
      char            ca_name[TCP_CA_NAME_MAX];
 } __attribute__((preserve_access_index));

I did that on purpose, I thought it was clearer to read after.

Do you prefer not to change the alignment?

Quoted 7 lines

Patch #13, selftests/bpf: add bpf_first scheduler

bpf_mptcp_helpers.h

->

bpf_tcp_helpers.h

Thanks!

- fc2aafca4737: bpf: use bpf_tcp_helpers.h instead of the mptcp one

Cheers,
Matt
--
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net