[PATCH mptcp-next v5 05/11] mptcp: add bpf set scheduled helper

Geliang Tang posted 11 patches 3 years, 3 months ago
Maintainers: Jakub Kicinski <kuba@kernel.org>, "David S. Miller" <davem@davemloft.net>, Matthieu Baerts <matthieu.baerts@tessares.net>, Andrii Nakryiko <andrii@kernel.org>, Shuah Khan <shuah@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Song Liu <songliubraving@fb.com>, Eric Dumazet <edumazet@google.com>, Mat Martineau <mathew.j.martineau@linux.intel.com>, KP Singh <kpsingh@kernel.org>, John Fastabend <john.fastabend@gmail.com>, Yonghong Song <yhs@fb.com>, Alexei Starovoitov <ast@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Martin KaFai Lau <kafai@fb.com>
There is a newer version of this series
[PATCH mptcp-next v5 05/11] mptcp: add bpf set scheduled helper
Posted by Geliang Tang 3 years, 3 months ago
This patch adds a new helper bpf_mptcp_subflow_set_scheduled() to set the
scheduled flag of struct mptcp_subflow_context using WRITE_ONCE().
Register this helper in bpf_mptcp_sched_kfunc_init() to make sure it can
be accessed from the BPF context.

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
 net/mptcp/bpf.c                               | 22 +++++++++++++++++++
 tools/testing/selftests/bpf/bpf_tcp_helpers.h |  2 ++
 2 files changed, 24 insertions(+)

diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c
index 0529e70d53b1..23c2776bb989 100644
--- a/net/mptcp/bpf.c
+++ b/net/mptcp/bpf.c
@@ -161,6 +161,28 @@ struct bpf_struct_ops bpf_mptcp_sched_ops = {
 	.init		= bpf_mptcp_sched_init,
 	.name		= "mptcp_sched_ops",
 };
+
+void bpf_mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow)
+{
+	WRITE_ONCE(subflow->scheduled, true);
+}
+EXPORT_SYMBOL(bpf_mptcp_subflow_set_scheduled);
+
+BTF_SET_START(bpf_mptcp_sched_kfunc_ids)
+BTF_ID(func, bpf_mptcp_subflow_set_scheduled)
+BTF_SET_END(bpf_mptcp_sched_kfunc_ids)
+
+static const struct btf_kfunc_id_set bpf_mptcp_sched_kfunc_set = {
+	.owner		= THIS_MODULE,
+	.check_set	= &bpf_mptcp_sched_kfunc_ids,
+};
+
+static int __init bpf_mptcp_sched_kfunc_init(void)
+{
+	return register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,
+					 &bpf_mptcp_sched_kfunc_set);
+}
+late_initcall(bpf_mptcp_sched_kfunc_init);
 #endif /* CONFIG_BPF_JIT */
 
 struct mptcp_sock *bpf_mptcp_sock_from_subflow(struct sock *sk)
diff --git a/tools/testing/selftests/bpf/bpf_tcp_helpers.h b/tools/testing/selftests/bpf/bpf_tcp_helpers.h
index 5f6a7fa2269b..488de4b920ef 100644
--- a/tools/testing/selftests/bpf/bpf_tcp_helpers.h
+++ b/tools/testing/selftests/bpf/bpf_tcp_helpers.h
@@ -261,4 +261,6 @@ struct mptcp_sock {
 	char		ca_name[TCP_CA_NAME_MAX];
 } __attribute__((preserve_access_index));
 
+extern void bpf_mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow) __ksym;
+
 #endif
-- 
2.34.1


Re: [PATCH mptcp-next v5 05/11] mptcp: add bpf set scheduled helper
Posted by kernel test robot 3 years, 3 months ago
Hi Geliang,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on mptcp/export]
[cannot apply to bpf-next/master bpf/master linus/master v5.18 next-20220601]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Geliang-Tang/BPF-packet-scheduler/20220601-144812
base:   https://github.com/multipath-tcp/mptcp_net-next.git export
config: x86_64-randconfig-a006 (https://download.01.org/0day-ci/archive/20220601/202206011710.y7OIrPON-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-1) 11.3.0
reproduce (this is a W=1 build):
        # https://github.com/intel-lab-lkp/linux/commit/4bfb6a3d6d5ea1744a301d97642ff0077eb280f6
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Geliang-Tang/BPF-packet-scheduler/20220601-144812
        git checkout 4bfb6a3d6d5ea1744a301d97642ff0077eb280f6
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash net/mptcp/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> net/mptcp/bpf.c:165:6: warning: no previous prototype for 'bpf_mptcp_subflow_set_scheduled' [-Wmissing-prototypes]
     165 | void bpf_mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +/bpf_mptcp_subflow_set_scheduled +165 net/mptcp/bpf.c

   164	
 > 165	void bpf_mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow)
   166	{
   167		WRITE_ONCE(subflow->scheduled, true);
   168	}
   169	EXPORT_SYMBOL(bpf_mptcp_subflow_set_scheduled);
   170	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp