Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

selftests/bpf: Remove unnecessary mount/umount dance #4111

Closed
wants to merge 8 commits into from

Conversation

kernel-patches-bot
Copy link

Pull request for series with
subject: selftests/bpf: Remove unnecessary mount/umount dance
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=699957

@kernel-patches-bot
Copy link
Author

Upstream branch: 2b3e8f6
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=699957
version: 1

@kernel-patches-bot
Copy link
Author

Upstream branch: a61474c
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=699957
version: 1

@kernel-patches-bot
Copy link
Author

Upstream branch: f2bb566
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=699957
version: 1

Martin KaFai Lau added 4 commits November 30, 2022 13:52
…ss/*/ifindex

When switching netns, the setns_by_fd() is doing dances in mount/umounting
the /sys directories.  One reason is the tc_redirect.c test is depending
on the /sys/net/class/*/ifindex instead of using the if_nametoindex().
if_nametoindex() uses ioctl() to get the ifindex.

This patch is to move all /sys/net/class/*/ifindex usages to
if_nametoindex().  The current code checks ifindex >= 0 which is
incorrect.  ifindex > 0 should be checked instead.  This patch also
stores ifindex_veth_src and ifindex_veth_dst since the latter patch
will need them.

Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
This patch removes the need to pin prog in the tc_redirect_dtime
test by directly using the bpf_tc_hook_create() and bpf_tc_attach().
The clsact qdisc will go away together with the test netns, so
no need to do bpf_tc_hook_destroy().

Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
This patch removes the need to pin prog in the tc_redirect_peer_l3
test by directly using the bpf_tc_hook_create() and bpf_tc_attach().
The clsact qdisc will go away together with the test netns, so
no need to do bpf_tc_hook_destroy().

Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
This patch removes the need to pin prog in the remaining tests in
tc_redirect.c by directly using the bpf_tc_hook_create() and
bpf_tc_attach().  The clsact qdisc will go away together with
the test netns, so no need to do bpf_tc_hook_destroy().

Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
@kernel-patches-bot
Copy link
Author

Upstream branch: 91a7de8
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=699957
version: 1

Martin KaFai Lau added 3 commits November 30, 2022 13:52
…e}_netns

The previous patches have removed the need to do the mount and umount
dance when switching netns. In particular:
* Avoid remounting /sys/fs/bpf to have a clean start
* Avoid remounting /sys to get a ifindex of a particular netns

This patch can finally remove the mount and umount dance in
{open,close}_netns which is unnecessarily complicated and
error-prone.

Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
After removing the mount/umount dance from {open,close}_netns()
in the pervious patch, "serial_" can be removed from
the tests using {open,close}_netns().

Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
…_skc_cls_ingress

This patch removes the need to pin prog when attaching to tc ingress
in the btf_skc_cls_ingress test.  Instead, directly use the
bpf_tc_hook_create() and bpf_tc_attach().  The qdisc clsact
will go away together with the netns, so no need to
bpf_tc_hook_destroy().

Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
@kernel-patches-bot
Copy link
Author

Upstream branch: f8186bf
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=699957
version: 1

Pull request is NOT updated. Failed to apply https://patchwork.kernel.org/project/netdevbpf/list/?series=699957
error message:

Cmd('git') failed due to: exit code(128)
  cmdline: git am --3way
  stdout: 'Applying: selftests/bpf: Use if_nametoindex instead of reading the /sys/net/class/*/ifindex
Using index info to reconstruct a base tree...
M	tools/testing/selftests/bpf/prog_tests/tc_redirect.c
Falling back to patching base and 3-way merge...
Auto-merging tools/testing/selftests/bpf/prog_tests/tc_redirect.c
CONFLICT (content): Merge conflict in tools/testing/selftests/bpf/prog_tests/tc_redirect.c
Patch failed at 0001 selftests/bpf: Use if_nametoindex instead of reading the /sys/net/class/*/ifindex
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".'
  stderr: 'error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch'

conflict:

diff --cc tools/testing/selftests/bpf/prog_tests/tc_redirect.c
index bca5e6839ac4,2d85742efdd3..000000000000
--- a/tools/testing/selftests/bpf/prog_tests/tc_redirect.c
+++ b/tools/testing/selftests/bpf/prog_tests/tc_redirect.c
@@@ -161,12 -165,12 +161,21 @@@ static int netns_setup_links_and_routes
  
  	result->ifindex_veth_src = if_nametoindex("veth_src");
  	if (!ASSERT_GT(result->ifindex_veth_src, 0, "ifindex_veth_src"))
++<<<<<<< HEAD
 +		goto fail;
 +
 +	result->ifindex_veth_src_fwd = if_nametoindex("veth_src_fwd");
 +	if (!ASSERT_GT(result->ifindex_veth_src_fwd, 0, "ifindex_veth_src_fwd"))
 +		goto fail;
 +
++=======
+ 		goto fail;
+ 
+ 	result->ifindex_veth_src_fwd = if_nametoindex("veth_src_fwd");
+ 	if (!ASSERT_GT(result->ifindex_veth_src_fwd, 0, "ifindex_veth_src_fwd"))
+ 		goto fail;
+ 
++>>>>>>> selftests/bpf: Use if_nametoindex instead of reading the /sys/net/class/*/ifindex
  	result->ifindex_veth_dst = if_nametoindex("veth_dst");
  	if (!ASSERT_GT(result->ifindex_veth_dst, 0, "ifindex_veth_dst"))
  		goto fail;

@kernel-patches-bot
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=699957 irrelevant now. Closing PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant