From nobody Sat Dec 21 12:04:32 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03027282F7 for ; Wed, 11 Sep 2024 03:03:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726023788; cv=none; b=OyFzJB36q4eV++O84L8n4vCbrEfduCfdMZ9DcK/MVJ+uq+lQwyD92VZtRKPzsWs8Y8Y+v3U/V4jVEqw4yxzJr8743I8uYXs+RPK1rYVbtZIPy0u8873tKU0ZFhNR61cI3hHHUysMTRUNwBpg3fjwo7gsd03QBsDuqYk3tT+DgGY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726023788; c=relaxed/simple; bh=KIS4caqoNjH0E4BAyvWDRRI/oxQI0k/8jBq6pMbjszw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Jn2WkxJzuX0Z2d+foM6/sHST6mKk1fD215/v/8W46mOUdBsptmAyJGyWsIZV2UIv7oZkqkHkuojGX9ntoK3qngLGet8E2gLsg6WtMNutbLJLhh5KLTnIu7yepS1e/l9rlYMtOG5k4jwaPNGhZy83YoOh2ma4LIdLiMmY01wUvH4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=A+Zsv5WD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="A+Zsv5WD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3697C4CEC3; Wed, 11 Sep 2024 03:03:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726023787; bh=KIS4caqoNjH0E4BAyvWDRRI/oxQI0k/8jBq6pMbjszw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A+Zsv5WDF5JrGUutoZ2ryC13EKT5oEmO3vclLyuIXsFVOG2xLD4udtTFEIYBfSAXn lozSkrUAbq/3gyvo5u41lK8BZRXe37K5j2FG1uSVdgmT88mw/Jr0gEVqrtuenr/qtZ JEINFilT6+W2LLxDJG7NohAA7BggYutZMl1HkkIh5CTvKZWa+zHXkZsK4hGVr0SNnV FkwHj2/ffIWbkQo/I2z6CRDk7hA+eXk7fe7uvFP+OG1kSxkbQBuWa2Jr6330b43fZK YsLc2coriE7U++NQ2NUWIx5NrKkKBOIGbF9ggbGf6SFuDCJJJ5qdlb+pkxkP/AEhrc OS6iiMrdPr3Dw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang , Martin KaFai Lau Subject: [PATCH mptcp-next v4 1/5] bpf: Add mptcp_subflow bpf_iter Date: Wed, 11 Sep 2024 11:02:55 +0800 Message-ID: <34159d5cb4df8168bc7613ef651b714ba2762d80.1726023577.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang It's necessary to traverse all subflows on the conn_list of an MPTCP socket and then call kfunc to modify the fields of each subflow. In kernel space, mptcp_for_each_subflow() helper is used for this: mptcp_for_each_subflow(msk, subflow) kfunc(subflow); But in the MPTCP BPF program, this has not yet been implemented. As Martin suggested recently, this conn_list walking + modify-by-kfunc usage fits the bpf_iter use case. So this patch adds a new bpf_iter type named "mptcp_subflow" to do this and implements its helpers bpf_iter_mptcp_subflow_new()/_next()/_destroy(). Since these bpf_iter mptcp_subflow helpers are invoked in its selftest in a ftrace hook for mptcp_sched_get_send(), it's necessary to register them into a BPF_PROG_TYPE_TRACING type kfunc set together with other two used kfuncs mptcp_subflow_active() and mptcp_subflow_set_scheduled(). Then bpf_for_each() for mptcp_subflow can be used in BPF program like this: bpf_rcu_read_lock(); bpf_for_each(mptcp_subflow, subflow, msk) kfunc(subflow); bpf_rcu_read_unlock(); Suggested-by: Martin KaFai Lau Signed-off-by: Geliang Tang --- net/mptcp/bpf.c | 54 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index 6414824402e6..0b7a0c2634c4 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -201,9 +201,48 @@ static const struct btf_kfunc_id_set bpf_mptcp_fmodret= _set =3D { .set =3D &bpf_mptcp_fmodret_ids, }; =20 -__diag_push(); -__diag_ignore_all("-Wmissing-prototypes", - "kfuncs which will be used in BPF programs"); +struct bpf_iter_mptcp_subflow { + __u64 __opaque[2]; +} __attribute__((aligned(8))); + +struct bpf_iter_mptcp_subflow_kern { + struct mptcp_sock *msk; + struct list_head *pos; +} __attribute__((aligned(8))); + +__bpf_kfunc_start_defs(); + +__bpf_kfunc int bpf_iter_mptcp_subflow_new(struct bpf_iter_mptcp_subflow *= it, + struct mptcp_sock *msk) +{ + struct bpf_iter_mptcp_subflow_kern *kit =3D (void *)it; + + if (!msk) + return -EINVAL; + + kit->msk =3D msk; + kit->pos =3D &msk->conn_list; + return 0; +} + +__bpf_kfunc struct mptcp_subflow_context * +bpf_iter_mptcp_subflow_next(struct bpf_iter_mptcp_subflow *it) +{ + struct bpf_iter_mptcp_subflow_kern *kit =3D (void *)it; + struct mptcp_subflow_context *subflow; + struct mptcp_sock *msk =3D kit->msk; + + subflow =3D list_entry((kit->pos)->next, struct mptcp_subflow_context, no= de); + if (!msk || list_entry_is_head(subflow, &msk->conn_list, node)) + return NULL; + + kit->pos =3D &subflow->node; + return subflow; +} + +__bpf_kfunc void bpf_iter_mptcp_subflow_destroy(struct bpf_iter_mptcp_subf= low *it) +{ +} =20 __bpf_kfunc struct mptcp_subflow_context * bpf_mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned= int pos) @@ -218,12 +257,15 @@ __bpf_kfunc bool bpf_mptcp_subflow_queues_empty(struc= t sock *sk) return tcp_rtx_queue_empty(sk); } =20 -__diag_pop(); +__bpf_kfunc_end_defs(); =20 BTF_KFUNCS_START(bpf_mptcp_sched_kfunc_ids) +BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_new) +BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_next) +BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_destroy) +BTF_ID_FLAGS(func, mptcp_subflow_active) BTF_ID_FLAGS(func, mptcp_subflow_set_scheduled) BTF_ID_FLAGS(func, bpf_mptcp_subflow_ctx_by_pos) -BTF_ID_FLAGS(func, mptcp_subflow_active) BTF_ID_FLAGS(func, mptcp_set_timeout) BTF_ID_FLAGS(func, mptcp_wnd_end) BTF_ID_FLAGS(func, tcp_stream_memory_free) @@ -241,6 +283,8 @@ static int __init bpf_mptcp_kfunc_init(void) int ret; =20 ret =3D register_btf_fmodret_id_set(&bpf_mptcp_fmodret_set); + ret =3D ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, + &bpf_mptcp_sched_kfunc_set); ret =3D ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, &bpf_mptcp_sched_kfunc_set); #ifdef CONFIG_BPF_JIT --=20 2.43.0 From nobody Sat Dec 21 12:04:32 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A73D29CE6 for ; Wed, 11 Sep 2024 03:03:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726023790; cv=none; b=fT5xtujA+cRX2nfbhGBa9sR/gN30XQlCjLUAzdR91M+whaaYCXsvtTclbsFVrAq/TnJJURdJiy01ChBc8RBzXEH63FqFGs15CbkcbW02k4XKPPrzG8hl26RNEnQcLuKCLRhP7VCgGLJ0iwW+7+mJLqhag5VAYUiIIpqBUfDdAaQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726023790; c=relaxed/simple; bh=O7H5p81f3ccOd4bUeotTC/JgYHamD54yF+Aj4VgqtxI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O+A6C6WdMORc8MB7nZZ2V+v2e3Jrb6spp7LIo5ljH8ITp/pj5qOGF95aCvqxf97JuGqEhR1rJ8xvvxri/z/Pdbvnj1ZNoBkmpCj93Fjcgj04DzE8aMDgUiKbvT6PeMl6FopbF1rYCxSvElcEJlfwKroXK69U2JfVGx2dzG+1Anc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HDiFfwxJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HDiFfwxJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1267EC4CECE; Wed, 11 Sep 2024 03:03:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726023789; bh=O7H5p81f3ccOd4bUeotTC/JgYHamD54yF+Aj4VgqtxI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HDiFfwxJ06EsMk9Oasciv14GSvdUYMczZIUlr8c57jXgZttqTgTL3TldsfMhVC72N Vx0XnFjlIfe0lBCogRI8aGm1ZOBUaiQk53kehZIYjbF4xp50BR50VuJztn/O8HIJ7k qf5Gh8IZj2QHdvjplTLd92smM+FHEc+c2YCnXqLZfaj1Cyyps0aJF+LkX6wkiIgyhY v57rfmbghtekpLmjn68npJd/qtyOT1/gR9yBpm4cHZE43nKuiEJGYwKtOpZv2yMdJB YeOydjvypbPtjRxMVLWPSCphSU6DuzihmXF/7BN2+/GqV9ZlJ4KDNRmHLRhoBH8HZo 3O7qXYGTKLx6A== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v4 2/5] selftests/bpf: Add mptcp_subflow bpf_iter test prog Date: Wed, 11 Sep 2024 11:02:56 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang This patch adds a new mptcp bpf selftest program for the newly added mptcp_subflow bpf_iter. Export bpf_iter_mptcp_subflow_new/_next/_destroy into bpf_experimental.h then use bpf_for_each(mptcp_subflow, subflow, msk) to walk the mptcp subflow list. Add a ftrace hook for mptcp_sched_get_send() to do this test and invoke kfuncs mptcp_subflow_active() and mptcp_subflow_set_scheduled() in the loops. Signed-off-by: Geliang Tang --- .../testing/selftests/bpf/bpf_experimental.h | 7 ++++ tools/testing/selftests/bpf/progs/mptcp_bpf.h | 4 ++ .../selftests/bpf/progs/mptcp_bpf_iter.c | 38 +++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 tools/testing/selftests/bpf/progs/mptcp_bpf_iter.c diff --git a/tools/testing/selftests/bpf/bpf_experimental.h b/tools/testing= /selftests/bpf/bpf_experimental.h index 828556cdc2f0..97aad95c90c6 100644 --- a/tools/testing/selftests/bpf/bpf_experimental.h +++ b/tools/testing/selftests/bpf/bpf_experimental.h @@ -549,6 +549,13 @@ extern int bpf_iter_css_new(struct bpf_iter_css *it, extern struct cgroup_subsys_state *bpf_iter_css_next(struct bpf_iter_css *= it) __weak __ksym; extern void bpf_iter_css_destroy(struct bpf_iter_css *it) __weak __ksym; =20 +struct bpf_iter_mptcp_subflow; +extern int bpf_iter_mptcp_subflow_new(struct bpf_iter_mptcp_subflow *it, + struct mptcp_sock *msk) __weak __ksym; +extern struct mptcp_subflow_context * +bpf_iter_mptcp_subflow_next(struct bpf_iter_mptcp_subflow *it) __weak __ks= ym; +extern void bpf_iter_mptcp_subflow_destroy(struct bpf_iter_mptcp_subflow *= it) __weak __ksym; + extern int bpf_wq_init(struct bpf_wq *wq, void *p__map, unsigned int flags= ) __weak __ksym; extern int bpf_wq_start(struct bpf_wq *wq, unsigned int flags) __weak __ks= ym; extern int bpf_wq_set_callback_impl(struct bpf_wq *wq, diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf.h b/tools/testing/= selftests/bpf/progs/mptcp_bpf.h index 928a1e5ad8db..3280d4183beb 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf.h +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf.h @@ -43,9 +43,13 @@ mptcp_subflow_tcp_sock(const struct mptcp_subflow_contex= t *subflow) } =20 /* ksym */ +extern bool mptcp_subflow_active(struct mptcp_subflow_context *subflow) __= ksym; extern void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subf= low, bool scheduled) __ksym; =20 +extern void bpf_rcu_read_lock(void) __ksym; +extern void bpf_rcu_read_unlock(void) __ksym; + extern struct mptcp_subflow_context * bpf_mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned= int pos) __ksym; =20 diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_iter.c b/tools/tes= ting/selftests/bpf/progs/mptcp_bpf_iter.c new file mode 100644 index 000000000000..03168be3980b --- /dev/null +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_iter.c @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2024, Kylin Software */ + +/* vmlinux.h, bpf_helpers.h and other 'define' */ +#include "bpf_tracing_net.h" +#include "mptcp_bpf.h" + +char _license[] SEC("license") =3D "GPL"; +int iter =3D 0; +int pid; + +SEC("fentry/mptcp_sched_get_send") +int BPF_PROG(trace_mptcp_sched_get_send, struct mptcp_sock *msk) +{ + struct mptcp_subflow_context *subflow; + int i =3D 0; + + if (bpf_get_current_pid_tgid() >> 32 !=3D pid) + return 0; + + bpf_rcu_read_lock(); + bpf_for_each(mptcp_subflow, subflow, msk) { + if (i++ >=3D MPTCP_SUBFLOWS_MAX) + break; + + if (subflow->token !=3D msk->token) + break; + + if (!mptcp_subflow_active(subflow)) + continue; + + mptcp_subflow_set_scheduled(subflow, false); + } + bpf_rcu_read_unlock(); + + iter =3D i; + return 0; +} --=20 2.43.0 From nobody Sat Dec 21 12:04:32 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 806182A1B8 for ; Wed, 11 Sep 2024 03:03:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726023791; cv=none; b=ATmdieJdIXRaKRPbggZUz9nj6qT67xFq9qHB5BymdaAKw3/2KyMZTuHgoPoRihZTYdLaPJMQDvFriuqedJ4amUQMnG5w8kxqa2BlhuFz3K6DY8lxHkFTbkVrcBVYko7oilveAXKhUvWrRZi3G+lR7+tkDbCVCsQmUJsfgbp64Dw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726023791; c=relaxed/simple; bh=nTdXKO35pRYXkkantGCnoyP0uincnrXD0t5fxqzt93w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fUucV46xaT2c/uvUjl0Pdu586jh0Bzr9Obv9tgLnOzG1cPj3ik++6b2PBFI7Di83mfc7hDkQBdxpKQ5x5MUTaIF30gvVAQJx9LzjjHQYimlY54+4FpLPLB2FH+Svd8yVf/Sk0PtyyH0UaZqx9UtnT6CWPGb7nOGHShOcAMGD02Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=e9YGIuRd; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="e9YGIuRd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9608C4CEC3; Wed, 11 Sep 2024 03:03:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726023791; bh=nTdXKO35pRYXkkantGCnoyP0uincnrXD0t5fxqzt93w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e9YGIuRdrf/T5SucOgua7E4FtLRCVyK7n6AOoF7Kt0hlUOoN08Iwzd2xmFvqG+Sti DzmhzdF99aHBTq5C66+0Q5flBerMwGxY23XUHISmuqheLzsByCjGQ4aFFETur/v5n0 PQORr7Y79tVdxbsiB8etWvyhzpgEFnjjlIIyfE6qQJU5ywkX84mS+qKXHSUfGnQHGj YaiUBpyujw2rtfzmzyI5uYsATcNSHdiZrfWjKTUPqnQ7HefXMP85yzUZDG2oe5YiTt o87gFvGsbCXJtPN5UgR8YkYBIMAdkzFXjhpHPNweif1qNnVjfntcLJj5bG+GKpWvHt i3qG4XX3sClkw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v4 3/5] selftests/bpf: Add mptcp_subflow bpf_iter subtest Date: Wed, 11 Sep 2024 11:02:57 +0800 Message-ID: <07fb62076430d7f79752f0d60259ad3f2f4902f6.1726023577.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang This patch adds a subtest named test_bpf_iter to load and verify the newly added mptcp_subflow type bpf_iter example in test_mptcp. Use endpoint_init() to add a new subflow endpoint. A new helper recv_send() is invoked to trigg= er the ftrace hook for mptcp_sched_get_send() after wait_for_new_subflows(). Check if skel->bss->iter equals 2 to verify whether the ftrace program loops twice as expected. Signed-off-by: Geliang Tang --- .../testing/selftests/bpf/prog_tests/mptcp.c | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing= /selftests/bpf/prog_tests/mptcp.c index a3e68bc6afa3..bb40c1f35918 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -11,6 +11,7 @@ #include "mptcp_sock.skel.h" #include "mptcpify.skel.h" #include "mptcp_subflow.skel.h" +#include "mptcp_bpf_iter.skel.h" #include "mptcp_bpf_first.skel.h" #include "mptcp_bpf_bkup.skel.h" #include "mptcp_bpf_rr.skel.h" @@ -259,6 +260,34 @@ static void send_byte(int fd) ASSERT_EQ(write(fd, &b, sizeof(b)), 1, "send single byte"); } =20 +static int recv_send(int server_fd) +{ + char buf[1]; + int ret, fd; + ssize_t n; + + fd =3D accept(server_fd, NULL, NULL); + if (!ASSERT_OK_FD(fd, "accept")) + return -1; + + n =3D recv(fd, buf, sizeof(buf), 0); + if (!ASSERT_GT(n, 0, "recv")) { + ret =3D -1; + goto close; + } + + n =3D send(fd, buf, n, 0); + if (!ASSERT_GT(n, 0, "send")) { + ret =3D -1; + goto close; + } + + ret =3D 0; +close: + close(fd); + return ret; +} + static int verify_mptcpify(int server_fd, int client_fd) { struct __mptcp_info info; @@ -471,6 +500,60 @@ static void test_subflow(void) close(cgroup_fd); } =20 +static void run_bpf_iter(void) +{ + int server_fd, client_fd; + + server_fd =3D start_mptcp_server(AF_INET, ADDR_1, PORT_1, 0); + if (!ASSERT_OK_FD(server_fd, "start_mptcp_server")) + return; + + client_fd =3D connect_to_fd(server_fd, 0); + if (!ASSERT_OK_FD(client_fd, "connect_to_fd")) + goto close_server; + + send_byte(client_fd); + wait_for_new_subflows(client_fd); + recv_send(server_fd); + + close(client_fd); +close_server: + close(server_fd); +} + +static void test_bpf_iter(void) +{ + struct mptcp_bpf_iter *skel; + struct nstoken *nstoken; + int err; + + skel =3D mptcp_bpf_iter__open_and_load(); + if (!ASSERT_OK_PTR(skel, "skel_open_load: mptcp_iter")) + return; + + skel->bss->pid =3D getpid(); + + err =3D mptcp_bpf_iter__attach(skel); + if (!ASSERT_OK(err, "skel_attach: mptcp_iter")) + goto skel_destroy; + + nstoken =3D create_netns(); + if (!ASSERT_OK_PTR(nstoken, "create_netns: mptcp_iter")) + goto skel_destroy; + + if (endpoint_init("subflow") < 0) + goto close_netns; + + run_bpf_iter(); + + ASSERT_EQ(skel->bss->iter, 2, "iter"); + +close_netns: + cleanup_netns(nstoken); +skel_destroy: + mptcp_bpf_iter__destroy(skel); +} + static struct nstoken *sched_init(char *flags, char *sched) { struct nstoken *nstoken; @@ -652,6 +735,8 @@ void test_mptcp(void) test_mptcpify(); if (test__start_subtest("subflow")) test_subflow(); + if (test__start_subtest("bpf_iter")) + test_bpf_iter(); if (test__start_subtest("default")) test_default(); if (test__start_subtest("first")) --=20 2.43.0 From nobody Sat Dec 21 12:04:32 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0BC592A1B8 for ; Wed, 11 Sep 2024 03:03:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726023793; cv=none; b=FjMKOFQ6JCVEQ5EonLHcv/pM4q9M7P+QrYAKraLFkTbTLdPyei9hf2llhu3HBAiY8po1pSiQZssla8XzZttH5BrUP35pALpOhnLAg/KPqQ2q3mFxLtHFoCgWCb70xF5a2/KvUbFjVnsI3Z+kmr+TnxBc9X+2OsfPFMTCZX3QFjQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726023793; c=relaxed/simple; bh=tmUhyMbuivaejbJwrRN0H8HLOXpXYI1ZrAXOA8fWcYw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i4DbGHVS6/OU9eXOqP1cG8IuXsRMqTtM9GpAbuG2v65XTYcLiTjo0QyxUUyevWgVEkfj4r04kR07dUarTcIE9BpFYgzRqLPjukyFhkq5hxK5wzRdcQffkm7FTaM6y8sbknPBEE/V7iyQosocPNjJ2QY9l8FvbKXAcxKq841pDPE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Zxu0PvFo; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Zxu0PvFo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B33C5C4CEC3; Wed, 11 Sep 2024 03:03:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726023792; bh=tmUhyMbuivaejbJwrRN0H8HLOXpXYI1ZrAXOA8fWcYw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zxu0PvFoL7fUjZ1W2nU4Ofyx76Oh85fqgOGqbkCqDMP2z11A1D3oTtFrLOK7xvxOn WlqyO5/ylHimslADvTj+BZZ47q2gP49Pezr8DnqPmYHWTFezUDnBWAyUoF4pXSrubn KC/AxTIOXWvtblHAtmdkUNUK1okQc1KxFY+YB5WQwsU8inS27+xGUk1S6YFBv9tV2h aRkPngS6a0/l996amPT6EISzgLtotBivta+63PSF8bKKsk67ZUexspHlmjeoLmAyzL ezXpBuCqRGKajKRu294U3DqUPWsDYeoQ98fl04lk+eyCTdm1Op1DaxDv+h5giZaCBz 0PX8a7sQ7kUhA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v4 4/5] Squash to "mptcp: add sched_data helpers" Date: Wed, 11 Sep 2024 11:02:58 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang Drop bpf_mptcp_subflow_ctx_by_pos declaration, since "-Wmissing-declarations" is ignored in __bpf_kfunc_start_defs. Signed-off-by: Geliang Tang --- net/mptcp/protocol.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 6e7d88ca7d42..aa0969d4440b 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -722,8 +722,6 @@ void mptcp_sock_graft(struct sock *sk, struct socket *p= arent); u64 mptcp_wnd_end(const struct mptcp_sock *msk); void mptcp_set_timeout(struct sock *sk); bool bpf_mptcp_subflow_queues_empty(struct sock *sk); -struct mptcp_subflow_context * -bpf_mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned= int pos); struct sock *__mptcp_nmpc_sk(struct mptcp_sock *msk); bool __mptcp_close(struct sock *sk, long timeout); void mptcp_cancel_work(struct sock *sk); --=20 2.43.0 From nobody Sat Dec 21 12:04:32 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35487224CF for ; Wed, 11 Sep 2024 03:03:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726023795; cv=none; b=ad+ELfFRZ//swFcWIsy3jVGFHQU/KFgr9TfD5EEUM0MoHe+hWkDzOD0qzZUfqN0g3/orxbL8h+XU/PAsy85c5SK5fLxjy+7s5Arsm5jvrQQyE9x3uq/3x5MWA03jB8xl7lxlik+ISXhlvzInC9hGnh0Zq2OB5r05Bewy3P9vhiQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726023795; c=relaxed/simple; bh=Zb+32JUdCvzFr6YS3HVWxtO3o2fz5/zgF4mbGXoaSRA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KsiraJBY4RD0MNMMwPdGKty/pU2REbf7g/Yn1kc/4/CCFEkzo2R3Up5j8kE8y1vnQV80GdHhy9w2jwN7tnVZvpJLBTjMinLaOwlnvN35/6QvY1VrAh61dcnJhoAyb9Sd4rk3c+Sk/LO6H6fJZhkLlHVHU6KFkw4qOCl9kjv0Z2o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=s59e5XGN; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="s59e5XGN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C619C4CEC3; Wed, 11 Sep 2024 03:03:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726023794; bh=Zb+32JUdCvzFr6YS3HVWxtO3o2fz5/zgF4mbGXoaSRA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s59e5XGNestBf1gSD4f7bvSqzlIugOvQISy93oPqCO5S3Rz0ksi+XwK674TouSP00 3qCSejjZFy44n2fhTFVC0vv3U7ohPBZvSKjcmDsQlLM6Za08sIMfEFhsWBxXnICYMm 3OgVKZsZI4bIYZf0otpnWNh6ZdC4lPcdwkQSA0/oMCpJNrQXH6u+WHynMjab/cfx7w y8ToKwDYQsJX/3gA3DkBtLb8YlcvXHLTHK8H0U+pu0zGPWVBVWd1PLecbPJzGubHXq 91VwRXLsUfZOagK6dAPDHdHKq1zQwEEbGAV+e1KexfyO1vygnlKFRC1U+U9ESIZ0rY 6QxT8X0CR28Eg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v4 5/5] Squash to "selftests/bpf: Add bpf_burst scheduler & test" Date: Wed, 11 Sep 2024 11:02:59 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang Drop mptcp_subflow_active declaration. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c b/tools/te= sting/selftests/bpf/progs/mptcp_bpf_burst.c index eb21119aa8f7..dcab196867fe 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c @@ -16,7 +16,6 @@ struct bpf_subflow_send_info { __u64 linger_time; }; =20 -extern bool mptcp_subflow_active(struct mptcp_subflow_context *subflow) __= ksym; extern void mptcp_set_timeout(struct sock *sk) __ksym; extern __u64 mptcp_wnd_end(const struct mptcp_sock *msk) __ksym; extern bool tcp_stream_memory_free(const struct sock *sk, int wake) __ksym; --=20 2.43.0