lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <6b678872-5303-4088-b65c-42e166b4d9e5@linux.dev>
Date: Fri, 13 Sep 2024 17:29:25 -0700
From: Martin KaFai Lau <martin.lau@...ux.dev>
To: "Matthieu Baerts (NGI0)" <matttbe@...nel.org>,
 Geliang Tang <geliang@...nel.org>
Cc: linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
 bpf@...r.kernel.org, linux-kselftest@...r.kernel.org, mptcp@...ts.linux.dev,
 Mat Martineau <martineau@...nel.org>, Andrii Nakryiko <andrii@...nel.org>,
 Eduard Zingerman <eddyz87@...il.com>, Mykola Lysenko <mykolal@...com>,
 Alexei Starovoitov <ast@...nel.org>, Daniel Borkmann <daniel@...earbox.net>,
 Song Liu <song@...nel.org>, Yonghong Song <yonghong.song@...ux.dev>,
 John Fastabend <john.fastabend@...il.com>, KP Singh <kpsingh@...nel.org>,
 Stanislav Fomichev <sdf@...ichev.me>, Hao Luo <haoluo@...gle.com>,
 Jiri Olsa <jolsa@...nel.org>, Shuah Khan <shuah@...nel.org>
Subject: Re: [PATCH bpf-next/net v6 3/3] selftests/bpf: Add mptcp subflow
 subtest

On 9/11/24 8:16 AM, Matthieu Baerts (NGI0) wrote:
> +static void test_subflow(void)
> +{
> +	int cgroup_fd, prog_fd, err;
> +	struct mptcp_subflow *skel;
> +	struct nstoken *nstoken;
> +	struct bpf_link *link;
> +
> +	cgroup_fd = test__join_cgroup("/mptcp_subflow");
> +	if (!ASSERT_OK_FD(cgroup_fd, "join_cgroup: mptcp_subflow"))
> +		return;
> +
> +	skel = mptcp_subflow__open_and_load();
> +	if (!ASSERT_OK_PTR(skel, "skel_open_load: mptcp_subflow"))
> +		goto close_cgroup;
> +
> +	skel->bss->pid = getpid();
> +
> +	err = mptcp_subflow__attach(skel);

This is not needed.

> +	if (!ASSERT_OK(err, "skel_attach: mptcp_subflow"))
> +		goto skel_destroy;
> +
> +	prog_fd = bpf_program__fd(skel->progs.mptcp_subflow);
> +	err = bpf_prog_attach(prog_fd, cgroup_fd, BPF_CGROUP_SOCK_OPS, 0);

Use bpf_program__attach_cgroup here instead since ...

> +	if (!ASSERT_OK(err, "prog_attach"))
> +		goto skel_destroy;
> +
> +	nstoken = create_netns();
> +	if (!ASSERT_OK_PTR(nstoken, "create_netns: mptcp_subflow"))
> +		goto skel_destroy;
> +
> +	if (endpoint_init("subflow") < 0)
> +		goto close_netns;
> +
> +	link = bpf_program__attach_cgroup(skel->progs._getsockopt_subflow,
> +					  cgroup_fd);

... bpf_program__attach_cgroup is used here also.

Instead of declaring a local "link", use the skel->links.{mptcp_subflow, 
_getsockopt_subflow}. Then mptcp_subflow__destroy(skel) will take care of them 
also. e.g. "skel->links._getsockopt_subflow = bpf_program__attach_cgroup(...)"

pw-bot: cr


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ