[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e1648c86-7859-a7c8-4474-83c826cbb464@linux.dev>
Date: Thu, 8 Sep 2022 16:32:39 -0700
From: Martin KaFai Lau <martin.lau@...ux.dev>
To: YiFei Zhu <zhuyifei@...gle.com>, bpf@...r.kernel.org
Cc: netdev@...r.kernel.org, Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Stanislav Fomichev <sdf@...gle.com>,
John Fastabend <john.fastabend@...il.com>,
Jiri Olsa <jolsa@...nel.org>,
"David S. Miller" <davem@...emloft.net>,
Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>,
David Ahern <dsahern@...nel.org>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>
Subject: Re: [PATCH v3 bpf-next 3/3] selftests/bpf: Ensure cgroup/connect{4,6}
programs can bind unpriv ICMP ping
On 9/8/22 4:16 PM, YiFei Zhu wrote:
> +void test_connect_ping(void)
> +{
> + struct connect_ping *skel;
> + int cgroup_fd;
> +
> + if (!ASSERT_OK(unshare(CLONE_NEWNET | CLONE_NEWNS), "unshare"))
> + return;
> +
> + /* overmount sysfs, and making original sysfs private so overmount
> + * does not propagate to other mntns.
> + */
> + if (!ASSERT_OK(mount("none", "/sys", NULL, MS_PRIVATE, NULL),
> + "remount-private-sys"))
> + return;
> + if (!ASSERT_OK(mount("sysfs", "/sys", "sysfs", 0, NULL),
> + "mount-sys"))
> + return;
> + if (!ASSERT_OK(mount("bpffs", "/sys/fs/bpf", "bpf", 0, NULL),
> + "mount-bpf"))
> + goto clean_mount;
> +
> + if (!ASSERT_OK(system("ip link set dev lo up"), "lo-up"))
> + goto clean_mount;
> + if (!ASSERT_OK(system("ip addr add 1.1.1.1 dev lo"), "lo-addr-v4"))
> + goto clean_mount;
> + if (!ASSERT_OK(system("ip -6 addr add 2001:db8::1 dev lo"), "lo-addr-v6"))
> + goto clean_mount;
> + if (write_sysctl("/proc/sys/net/ipv4/ping_group_range", "0 0"))
> + goto clean_mount;
> +
> + cgroup_fd = test__join_cgroup("/connect_ping");
> + if (!ASSERT_GE(cgroup_fd, 0, "cg-create"))
> + goto clean_mount;
> +
> + skel = connect_ping__open_and_load();
> + if (!ASSERT_OK_PTR(skel, "skel-load"))
> + goto close_cgroup;
> + skel->links.connect_v4_prog =
> + bpf_program__attach_cgroup(skel->progs.connect_v4_prog, cgroup_fd);
> + if (!ASSERT_OK_PTR(skel->links.connect_v4_prog, "cg-attach-v4"))
> + goto close_cgroup;
connect_ping__destroy() is also needed in this error path.
I had already mentioned that in v2. I went back to v2 and noticed my
editor some how merged my reply with the previous quoted line ">". A
similar thing happened in my recent replies also. I hope it appears
fine this time.
> + skel->links.connect_v6_prog =
> + bpf_program__attach_cgroup(skel->progs.connect_v6_prog, cgroup_fd);
> + if (!ASSERT_OK_PTR(skel->links.connect_v6_prog, "cg-attach-v6"))
> + goto close_cgroup;
Same here.
Powered by blists - more mailing lists