netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin KaFai Lau <martin.lau@linux.dev>
To: YiFei Zhu <zhuyifei@google.com>, bpf@vger.kernel.org
Cc: netdev@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Stanislav Fomichev <sdf@google.com>,
	John Fastabend <john.fastabend@gmail.com>,
	Jiri Olsa <jolsa@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
	David Ahern <dsahern@kernel.org>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Subject: Re: [PATCH v3 bpf-next 3/3] selftests/bpf: Ensure cgroup/connect{4,6} programs can bind unpriv ICMP ping
Date: Thu, 8 Sep 2022 16:32:39 -0700	[thread overview]
Message-ID: <e1648c86-7859-a7c8-4474-83c826cbb464@linux.dev> (raw)
In-Reply-To: <97288b66a44c984cb5514ca7390ca0cf9c30275f.1662678623.git.zhuyifei@google.com>

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.

  reply	other threads:[~2022-09-08 23:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-08 23:16 [PATCH v3 bpf-next 0/3] cgroup/connect{4,6} programs for unprivileged ICMP ping YiFei Zhu
2022-09-08 23:16 ` [PATCH v3 bpf-next 1/3] bpf: Invoke " YiFei Zhu
2022-09-08 23:16 ` [PATCH v3 bpf-next 2/3] selftests/bpf: Deduplicate write_sysctl() to test_progs.c YiFei Zhu
2022-09-08 23:16 ` [PATCH v3 bpf-next 3/3] selftests/bpf: Ensure cgroup/connect{4,6} programs can bind unpriv ICMP ping YiFei Zhu
2022-09-08 23:32   ` Martin KaFai Lau [this message]
2022-09-08 23:44     ` YiFei Zhu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e1648c86-7859-a7c8-4474-83c826cbb464@linux.dev \
    --to=martin.lau@linux.dev \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@google.com \
    --cc=yoshfuji@linux-ipv6.org \
    --cc=zhuyifei@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).