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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3b1949b9-775a-8093-6a14-16dec843a446@iogearbox.net>
Date: Fri, 19 Jul 2024 17:14:07 +0200
From: Daniel Borkmann <daniel@...earbox.net>
To: Alexis Lothoré (eBPF Foundation)
 <alexis.lothore@...tlin.com>, Alexei Starovoitov <ast@...nel.org>,
 "David S. Miller" <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>,
 Jesper Dangaard Brouer <hawk@...nel.org>,
 John Fastabend <john.fastabend@...il.com>,
 Andrii Nakryiko <andrii@...nel.org>, Martin KaFai Lau
 <martin.lau@...ux.dev>, Eduard Zingerman <eddyz87@...il.com>,
 Song Liu <song@...nel.org>, Yonghong Song <yonghong.song@...ux.dev>,
 KP Singh <kpsingh@...nel.org>, Stanislav Fomichev <sdf@...ichev.me>,
 Hao Luo <haoluo@...gle.com>, Jiri Olsa <jolsa@...nel.org>,
 Mykola Lysenko <mykolal@...com>, Shuah Khan <shuah@...nel.org>,
 Simon Horman <horms@...nel.org>
Cc: ebpf@...uxfoundation.org, netdev@...r.kernel.org, bpf@...r.kernel.org,
 linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org,
 Thomas Petazzoni <thomas.petazzoni@...tlin.com>
Subject: Re: [PATCH v3 2/2] selftests/bpf: integrate test_xdp_veth into
 test_progs

On 7/16/24 12:13 PM, Alexis Lothoré (eBPF Foundation) wrote:
[...]
> +static int attach_programs_to_veth_pair(struct skeletons *skeletons, int index)
> +{
> +	struct bpf_program *local_prog, *remote_prog;
> +	struct bpf_link **local_link, **remote_link;
> +	struct nstoken *nstoken;
> +	struct bpf_link *link;
> +	int interface;
> +
> +	switch (index) {
> +	case 0:
> +		local_prog = skeletons->xdp_redirect_maps->progs.xdp_redirect_map_0;
> +		local_link = &skeletons->xdp_redirect_maps->links.xdp_redirect_map_0;
> +		remote_prog = skeletons->xdp_dummy->progs.xdp_dummy_prog;
> +		remote_link = &skeletons->xdp_dummy->links.xdp_dummy_prog;
> +		break;
> +	case 1:
> +		local_prog = skeletons->xdp_redirect_maps->progs.xdp_redirect_map_1;
> +		local_link = &skeletons->xdp_redirect_maps->links.xdp_redirect_map_1;
> +		remote_prog = skeletons->xdp_tx->progs.xdp_tx;
> +		remote_link = &skeletons->xdp_tx->links.xdp_tx;
> +		break;
> +	case 2:
> +		local_prog = skeletons->xdp_redirect_maps->progs.xdp_redirect_map_2;
> +		local_link = &skeletons->xdp_redirect_maps->links.xdp_redirect_map_2;
> +		remote_prog = skeletons->xdp_dummy->progs.xdp_dummy_prog;
> +		remote_link = &skeletons->xdp_dummy->links.xdp_dummy_prog;
> +		break;
> +	}
> +	interface = if_nametoindex(config[index].local_veth);
> +	if (!ASSERT_NEQ(interface, 0, "non zero interface index"))
> +		return -1;
> +	link = bpf_program__attach_xdp(local_prog, interface);
> +	if (!ASSERT_OK_PTR(link, "attach xdp program to local veth"))
> +		return -1;
> +	*local_link = link;
> +	nstoken = open_netns(config[index].namespace);
> +	if (!ASSERT_OK_PTR(nstoken, "switch to remote veth namespace"))
> +		return -1;
> +	interface = if_nametoindex(config[index].remote_veth);
> +	if (!ASSERT_NEQ(interface, 0, "non zero interface index"))
> +		return -1;

Missing `close_netns(nstoken);` in error path here, otherwise looks reasonable to me.

> +	link = bpf_program__attach_xdp(remote_prog, interface);
> +	*remote_link = link;
> +	close_netns(nstoken);
> +	if (!ASSERT_OK_PTR(link, "attach xdp program to remote veth"))
> +		return -1;
> +
> +	return 0;
> +}

Thanks,
Daniel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ