From nobody Sat Dec 21 13:12:05 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 32EF018A6A9; Thu, 12 Sep 2024 09:26:03 +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=1726133164; cv=none; b=iqJ1eK1LInp4eogyzE8MWcTIJ0r/COTlok5s/rjLYX/ka50Cq/QJrN99yL4iMUUpPl6PSlx+rai/NRT4+tptTqt+7GVcHD4Cdggw9VEJLOg+H30u5tmvR2iEO2UMBNUfRZBFiHr57v78DHfPX1ku5wYvsnPw6ZBGSuEWILYTtcs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726133164; c=relaxed/simple; bh=i1tfent+G9wgkD21AvmV+FJAVzh/MdSal+bBN4pXdGk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mPjCMG+BQeii/8bju2rl2Hce1iF4ZcF/TPsKDUEMhpl6sGLwsoD8DK96MCV3zl/sH7dPL/tqv1Pp0bSGhLwPj9S8Bvsp1s+qgo6ak24/Eoj3wwNVfcC5CkxcNwXZx/w2euB5JMc+juHaLFiv1jYTiPl8ycQY6cNw3TaSQCYyRK8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rPV1pqjT; 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="rPV1pqjT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED118C4CEC3; Thu, 12 Sep 2024 09:26:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726133163; bh=i1tfent+G9wgkD21AvmV+FJAVzh/MdSal+bBN4pXdGk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rPV1pqjTewkJFVGHmrLq9GncYKsYuqMveK6e2e8ck6cQjPIZB8vt74UfDmphAIVKQ xOqavZ6qP3UAr62m1gMA2t18BdQZDowQsU5sfoj/AFlPh1yf5sedsH3SwAEijw5791 l6OoXK6b2Ory9fmJyQqT3bhrgLrWaRfTsrSQ9WNnGHuGRAfQvC/MV+qIftRP0dq0Y+ QfAaz4aM5Bpni1q2exFFemyxMTu22BYW/ZAudbqpyJ8/2UM4LciGdx06tcdFhaRVVT 7gB7AHnxnGltox7CoKpjJ8FB/4z8TU9QqCQr0aXKfEiJQxxYUxxlY4aemgz+JPOo7f 1upNSaLR8gcAA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang , bpf@vger.kernel.org, Martin KaFai Lau Subject: [PATCH mptcp-next v5 1/5] bpf: Add mptcp_subflow bpf_iter Date: Thu, 12 Sep 2024 17:25:51 +0800 Message-ID: <5e5b91efc6e06a90fb4d2440ddcbe9b55ee464be.1726132802.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: i =3D 0; bpf_rcu_read_lock(); bpf_for_each(mptcp_subflow, subflow, msk) { if (i++ >=3D MPTCP_SUBFLOWS_MAX) break; kfunc(subflow); } bpf_rcu_read_unlock(); v2: remove msk->pm.lock in _new() and _destroy() (Martin) drop DEFINE_BPF_ITER_FUNC, change opaque[3] to opaque[2] (Andrii) v3: drop bpf_iter__mptcp_subflow v4: if msk is NULL, initialize kit->msk to NULL in _new() and check it in _next() (Andrii) Suggested-by: Martin KaFai Lau Signed-off-by: Geliang Tang --- net/mptcp/bpf.c | 57 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 5 deletions(-) diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index 6414824402e6..fec18e7e5e4a 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -201,9 +201,51 @@ 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; + + kit->msk =3D msk; + if (!msk) + return -EINVAL; + + 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; + + if (!msk) + return NULL; + + subflow =3D list_entry(kit->pos->next, struct mptcp_subflow_context, node= ); + if (!subflow || 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 +260,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 +286,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 13:12:05 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 ED70B18A6A9 for ; Thu, 12 Sep 2024 09:26:05 +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=1726133166; cv=none; b=TSQ/jOtG1OcpAblOaCdU+zzi3U3soR0TbpgNCcLZpSe2gM5BaaBIV+t+3XvaGCAyqYwdDcO8VYeu3yCckqMJlUXYwKp5dp6u4Yw8A2mQwZilS3URZocLAZjXj2vQkfETlD3livChtT0oV8xY8XhqBFBmzOHtRqsSZWUakJBBnbg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726133166; c=relaxed/simple; bh=O7H5p81f3ccOd4bUeotTC/JgYHamD54yF+Aj4VgqtxI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fwr+hl3xOl5MEbDKaQGNOBT1Ma8CVcVvPXeWp2v8oZdmJhHYLxkWoVoIwcv5WNbXDkL44KPP4VosoZEtZ3sWLsXH+Bupl3FTQFMq4afAmWMwn9+Wz2/P3nJ8jaT47aXx08qmlKZRQEVOmNmkVCLhRYlLBXEAtgSx9K75B29u/Nw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lmJQowze; 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="lmJQowze" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68B79C4CEC5; Thu, 12 Sep 2024 09:26:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726133165; bh=O7H5p81f3ccOd4bUeotTC/JgYHamD54yF+Aj4VgqtxI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lmJQowzeXsnOws1Pm3+je5xWy3L/QU4RCWFKsTOen6GMMFcSedmKej9CEYvhQYbYB 38B7hI+i9tv2lDRyAzNbKhTWKsvLLV8Zy9ke2FeHhb47Uys0bfSUOo9XL2Nvi9lrtN S+nJh7YvY3ZaGUM5sREek83Lkcn9jMHcpXkQev2Vr4wJdUvYZDk2RK9q/rp+YrKKa4 G716PLV59GmkrJGXTWsl0mGhQYXgL9zpojFV1taSlz3uQI1SyVVgri0Z078jjFBQ3z cLYvnFq06n8yX5DbC5sOQYaj/qPzaPfzgq8AR/kCJh2YsskjAu+7Mdi5+9m12tCdTz GAp8szX2e0UAA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v5 2/5] selftests/bpf: Add mptcp_subflow bpf_iter test prog Date: Thu, 12 Sep 2024 17:25:52 +0800 Message-ID: <4467ab3af0f1a6c378778ca6be72753b16a1532c.1726132802.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 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 13:12:05 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 CAEE818A6A9 for ; Thu, 12 Sep 2024 09:26: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=1726133167; cv=none; b=oZOr/G1EdrDTANsfJjGEMYkuwiea1waswhWtuQZOwZT+B7LEiayCGV9ZRijLAqA8NPf9VsRPT2Czgj6qQtI+nwTTdejEObbPuHjp+f/i/gMZguFTclmY3UPhT030+4WKfo+BPnWrDGJFBPNK0S3l4kNSzA8UvjVy5vYE7MPismM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726133167; c=relaxed/simple; bh=nTdXKO35pRYXkkantGCnoyP0uincnrXD0t5fxqzt93w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rPyN5uHmjvgownZWd/p28lyw/dkqM1FjzEUO399IYJuztWI5DFE4uiZ5nuFLEvKMyxuscYajMMf8onzXs9PIjwD9lptx55mxxLzWhIJfJKnm3SbJZgIi0BurH4ivrZFOJRIF8dCeH+SMyHgpl3g2KKai9yjvpa6Scnc1id8xwCQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=V4hqAdH3; 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="V4hqAdH3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2851AC4CEC3; Thu, 12 Sep 2024 09:26:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726133167; bh=nTdXKO35pRYXkkantGCnoyP0uincnrXD0t5fxqzt93w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V4hqAdH3QIaQNy0YI8QpY6DTMWelq5uB2rMkp8okChxQmzt4oyk8IN4plJbHFFxXl qdlV45VTj9USjxmZy6jT7pnhFw+tUTAoxEPUa5IUAk7vdl3JUCRbdDGxR9JyW4vvbr nIEHjwjsFb5/AppEradbZaVmuvCGd1r4Mu8nynzLlOTuPzCLHXNru7RKVv4hBJfaz2 XeCjdUoOWSh8wAoEfkqqpzebwvVpejmMhiSS4Smv+RrCcxWJFp5HW+kTFGSGxYhIy/ vnsObMp8TReZ+UrQ8fRRsN2oWH3Gf4/ARS0Fjk78lUeyJxJB110NfarYiDMTdQ8Hbs +8rG1iG49/lUw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v5 3/5] selftests/bpf: Add mptcp_subflow bpf_iter subtest Date: Thu, 12 Sep 2024 17:25:53 +0800 Message-ID: <4095bce644e17b89ad4b2de520f5400cafa70712.1726132802.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 13:12:05 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 81EE1190063 for ; Thu, 12 Sep 2024 09:26: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=1726133169; cv=none; b=bnnuaZuUi6oja4Y3dCgF+LtgB7bd9T/93QfQWdgvm+ywYZE/0MSBF4o9L8SEJ9IYhejR8nN03gr2rmT//ZYPkCXzpKMpP2P3O/y0OhGvP9gkUxIJuNjmnzc+xtwPSr6nSWmd4d02oTzx+/vspzgYrks8G9qb7MMMd48QT/j8PyA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726133169; c=relaxed/simple; bh=p/u08phHhlqhN6T2xbBOiHaa1aRmGqAr6bqCvczOld0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ru3EgWlfwgGqycffhT1AO172isi3hHQcC9xmCsig5tL543sZ8nTBFduV4CUN3GtmlTL0LM2nl98BcnuR7jmdeRCBbRgGpvgoXqZcn2D5fClwGqIbG6ZTNXVtKhC+EiRXy7rKMSzoqyfs0gWdTyqiiFgV7HYwhERSdEAzODY+jqs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tawOhe/o; 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="tawOhe/o" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0227CC4CEC3; Thu, 12 Sep 2024 09:26:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726133169; bh=p/u08phHhlqhN6T2xbBOiHaa1aRmGqAr6bqCvczOld0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tawOhe/ok6z2texgmxzEtqWEebDGnetPD5m4ffXUiD/38b8zIerxR0WU3kbL91O83 Yvi1oFn7MA4bn9+tZD2iNSi/5jAXN4O9X5KTenHpr3ErSuXCq1jmnjoZhz6QBQ0T4L GZHXzJ1bZy2J4dEfY8CCUqlL95kzGfoujb+g5+k2j3P6KfSHPB3lBzU02t7P97TEAZ v6pyMFrvHzQaPpnyzvtoZcHC76qA0f15K8nM/AUV/WGgPbehxDcuCzDIjTseTX5XD7 WHAzpQ03cAe6MCXexHBvB4g4BQY+QtWRGu7oDRT4donYtfA2GpatvYEO4BlxA/kiMg t4CNDhW7jXjIg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v5 4/5] Squash to "mptcp: add sched_data helpers" Date: Thu, 12 Sep 2024 17:25:54 +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 c3942416fa3a..d864c8ccf316 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 13:12:05 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 6B04518E043 for ; Thu, 12 Sep 2024 09:26: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=1726133171; cv=none; b=ALvDCQckVdL1A4yT5wJMR19DTXNl+wqPb87n+ujMiO7AiJ4apdUHfyUbjxxXhum+RfrmimI8NmvRfmiIMAux2o95kLl5flLcorg2GT1XxgjxCWgFCuqPIPc+RAlDnYcoiLLrSHCbDmzxvn4wkWtugdML/9H/E82EphgUKFq4qTM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726133171; c=relaxed/simple; bh=Zb+32JUdCvzFr6YS3HVWxtO3o2fz5/zgF4mbGXoaSRA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FG/Rf4XwaRoDiJii1M9AtUswEVLa4nz1eQ7dKG3n61Z8xnF/eDuGW+OIclOZ3T8KceFARpt3mMDQcxybq6wFaS3fS/u0NGPGUDaTME8EjpeRvf5jQchsYggAjorMH8NKE2g/MhcMKtP+Bn+vzKm3NAEMtNkLrH5ylzOb3pvgxYY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=d9f88HAC; 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="d9f88HAC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1ED4C4CEC3; Thu, 12 Sep 2024 09:26:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726133171; bh=Zb+32JUdCvzFr6YS3HVWxtO3o2fz5/zgF4mbGXoaSRA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d9f88HACDwNszXkA7ti4PxRsoR+bKMBSyFdZJokAaldLNoMc80ZpILUp3f8Oleh8i Bxlake77nBXvhK3bPQ7PISSvnp0RQQyES/UjrHUMH7ZCAUu2aRGzTJzxVkr+inueG1 bUPKZtwv7bp+bmq30HJXYpr/UCu/WafClQUIatY8D/8gc5pEqkaitOBhMOu5E5/dMB L3jRQ1ukeJlbbpYSWqvPzjJi0dH0s1HQ9CvAZEYHhXdoFXTpYrbF3SD4nnHxRlRqg6 k5L2+2t2s9bza7n4vTyAGM2PpZmJ5jnNqDssB8+YR+LP2p+tipHO1d9qYV5QD5csCY tkQf1AyxPQdIA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v5 5/5] Squash to "selftests/bpf: Add bpf_burst scheduler & test" Date: Thu, 12 Sep 2024 17:25:55 +0800 Message-ID: <543ecc733565d61caad8dd953ebcbcb5b689094a.1726132802.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 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