Skip to contentSkip to conversation

BPF round-robin scheduler

PATCH New Geliang Tang 1 participant 3 messages May 23, 2022

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

v15 cover BPF round-robin scheduler

v15:
- use the new BPF scheduler API
- verify data was sent on new subflow in 'ss' output
- depends on "BPF packet scheduler" v2

v14:
- export subflows number in patch 1, it will be used in redundant scheduler.
- rebased on "update bpf patches on export branch" v2.

v13:
- add !msk->last_snd check in patch 2
- use ASSERT_OK_PTR instead of CHECK in patch 3
- base-commit: export/20220509T115202

v12:
- init ssk from data->contexts[0], instead of msk->first.
- cycle through all the subflows, instead of the first two.

v11:
- rename array to contexts.
- drop number of subflows in mptcp_sched_data.
- set unused array elements to NULL.
- add MPTCP_SUBFLOWS_MAX check in mptcp_sched_data_init.

v10:
- init subflows array in mptcp_sched_data_init.
- for (int i = 0; i < data->subflows; i++) is not allowed in BPF, using this instead:

        for (int i = 0; i < MPTCP_SUBFLOWS_MAX && i < data->subflows; i++)

- deponds on: "BPF packet scheduler" series v18.

v9:
- add subflows array in mptcp_sched_data
- deponds on: "BPF packet scheduler" series v17 + Squash to "mptcp: add struct mptcp_sched_ops v17".

v8:
- use struct mptcp_sched_data.
- deponds on: "BPF packet scheduler" series v14.

v7:
- rename retrans to reinject.
- drop last_snd setting.
- deponds on: "BPF packet scheduler" series v13.

v6:
- set call_me_again flag.
- deponds on: "BPF packet scheduler" series v12.

v5:
- update patch 2, use temporary storage instead.
- update patch 3, use new helpers.
- deponds on: "BPF packet scheduler" series v11.

v4:
- add retrans argment for get_subflow()

v3:
- add last_snd write access.
- keep msk->last_snd setting in get_subflow().
- deponds on: "BPF packet scheduler" series v10.

v2:
- merge the squash-to patch.
- implement bpf_mptcp_get_subflows helper, instead of bpf_mptcp_get_next_subflow.
- deponds on: "BPF packet scheduler v9".

This patchset implements round-robin scheduler using BPF. Address to some commends for the RFC version:

https://patchwork.kernel.org/project/mptcp/cover/[email protected]/

Geliang Tang (2):
selftests/bpf: add bpf_rr scheduler
selftests/bpf: add bpf_rr test

 tools/testing/selftests/bpf/bpf_tcp_helpers.h |  1 +
 .../testing/selftests/bpf/prog_tests/mptcp.c  | 39 +++++++++++++++
 .../selftests/bpf/progs/mptcp_bpf_rr.c        | 48 +++++++++++++++++++
 3 files changed, 88 insertions(+)
 create mode 100644 tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c
Signature · 1 line
2.34.1
#1 lore raw

PATCH v15 1/2 selftests/bpf: add bpf_rr scheduler

This patch implements the round-robin BPF MPTCP scheduler, named bpf_rr, which always picks the next available subflow to send data. If no such next subflow available, picks the first one.

---
 tools/testing/selftests/bpf/bpf_tcp_helpers.h |  1 +
 .../selftests/bpf/progs/mptcp_bpf_rr.c        | 48 +++++++++++++++++++
 2 files changed, 49 insertions(+)
 create mode 100644 tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c
tools/testing/selftests/bpf/bpf_tcp_helpers.h +1 -0
index 9c7d33e106a4..0f29b47260ff 100644
@@ -255,6 +255,7 @@ struct mptcp_sched_ops {
 struct mptcp_sock {
 	struct inet_connection_sock	sk;
 
+	struct sock	*last_snd;
 	__u32		token;
 	struct sock	*first;
 	char		ca_name[TCP_CA_NAME_MAX];
tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c new file +48 -0

48 lines not on this page · raw message

Signature · 1 line
2.34.1
#2 lore raw

PATCH v15 2/2 selftests/bpf: add bpf_rr test

In reply to Geliang Tang

This patch adds the round-robin BPF MPTCP scheduler test. Use sysctl to set net.mptcp.scheduler to use this sched. Add a veth net device to simulate the multiple addresses case. Use 'ip mptcp endpoint' command to add this new endpoint to PM netlink.

---
 .../testing/selftests/bpf/prog_tests/mptcp.c  | 39 +++++++++++++++++++
 1 file changed, 39 insertions(+)
tools/testing/selftests/bpf/prog_tests/mptcp.c +39 -0
index 9d37c509d3ce..1746b6488bc0 100644
@@ -7,6 +7,7 @@
 #include "network_helpers.h"
 #include "mptcp_sock.skel.h"
 #include "mptcp_bpf_first.skel.h"
+#include "mptcp_bpf_rr.skel.h"
 
 #ifndef TCP_CA_NAME_MAX
 #define TCP_CA_NAME_MAX	16
@@ -279,10 +280,48 @@ static void test_first(void)
 	mptcp_bpf_first__destroy(first_skel);
 }
 
+static void test_rr(void)
+{
+	struct mptcp_bpf_rr *rr_skel;
+	int server_fd, client_fd;
+	struct bpf_link *link;
+
+	rr_skel = mptcp_bpf_rr__open_and_load();
+	if (!ASSERT_OK_PTR(rr_skel, "bpf_rr__open_and_load"))
+		return;
+
+	link = bpf_map__attach_struct_ops(rr_skel->maps.rr);
+	if (!ASSERT_OK_PTR(link, "bpf_map__attach_struct_ops")) {
+		mptcp_bpf_rr__destroy(rr_skel);
+		return;
+	}
+
+	system("ip link add veth1 type veth");
+	system("ip addr add 10.0.1.1/24 dev veth1");
+	system("ip link set veth1 up");
+	system("ip mptcp endpoint add 10.0.1.1 subflow");
+	system("sysctl -qw net.mptcp.scheduler=bpf_rr");
+	server_fd = start_mptcp_server(AF_INET, NULL, 0, 0);
+	client_fd = connect_to_fd(server_fd, 0);
+
+	send_data(server_fd, client_fd);
+	ASSERT_OK(system("ss -MOenita | grep '10.0.1.1' | grep -q 'bytes_sent:'"), "ss");
+
+	close(client_fd);
+	close(server_fd);
+	system("sysctl -qw net.mptcp.scheduler=default");
+	system("ip mptcp endpoint flush");
+	system("ip link del veth1");
+	bpf_link__destroy(link);
+	mptcp_bpf_rr__destroy(rr_skel);
+}
+
 void test_mptcp(void)
 {
 	if (test__start_subtest("base"))
 		test_base();
 	if (test__start_subtest("first"))
 		test_first();
+	if (test__start_subtest("rr"))
+		test_rr();
 }
Signature · 1 line
2.34.1