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: Migrate test_xdp_redirect_multi.sh to test_progs #4899

Open
wants to merge 11 commits into
base: bpf-next_base
Choose a base branch
from

Conversation

kernel-patches-daemon-bpf-rc[bot]
Copy link

Pull request for series with
subject: selftests/bpf: Migrate test_xdp_redirect_multi.sh to test_progs
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=927180

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 3f3c2f0
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=927180
version: 1

configure_network() does two things : it first creates the network
topology and then configures the BPF maps to fit the test needs. This
isn't convenient if we want to re-use the same network topology for
different test cases.

Rename configure_network() create_network().
Move the BPF configuration to the test itself.
Split the test description in two parts, first the description of the
network topology, then the description of the test case.
Remove the veth indexes from the ASCII art as dynamic ones are used

Signed-off-by: Bastien Curutchet (eBPF Foundation) <[email protected]>
check_ping() doesn't use the struct skeletons it has as input.

Remove the unused input.

Signed-off-by: Bastien Curutchet (eBPF Foundation) <[email protected]>
The network topology is held by the config[] table. This 'config' name
is a bit too generic if we want to add other configuration variable.

Rename config[] to net_config[].

Signed-off-by: Bastien Curutchet (eBPF Foundation) <[email protected]>
The BPF program attached to each veth is hardcoded through the
use of the struct skeletons. It prevents from re-using the initialization
code in new test cases.

Replace the struct skeletons by a bpf_object table.
Add a struct prog_configuration that holds the name of BPF program to
load on a given veth pair.
Use bpf_object__find_program_by_name() / bpf_xdp_attach() API instead of
bpf_program__attach_xdp() to retrieve the BPF programs from their names.
Detach BPF progs in the cleanup() as it's not automatically done by this
API.

Signed-off-by: Bastien Curutchet (eBPF Foundation) <[email protected]>
XDP flags are hardcoded to 0 at attachment.

Add flags attributes to the struct prog_configuration to allow flag
modifications for each test case.

Signed-off-by: Bastien Curutchet (eBPF Foundation) <[email protected]>
The XDP redirection is tested without any flag provided to the
xdp_attach() function.

Add two subtests that check the correct behaviour with
XDP_FLAGS_{DRV/SKB}_MODE flags

Signed-off-by: Bastien Curutchet (eBPF Foundation) <[email protected]>
Broadcasting flags are hardcoded for each kind for protocol.

Create a redirect_flags map that allows to select the broadcasting flags
to use in the bpf_redirect_map(). The protocol ID is used as a key.
Set the old hardcoded values as default if the map isn't filled by the
BPF caller.

Signed-off-by: Bastien Curutchet (eBPF Foundation) <[email protected]>
XDP redirections with BPF_F_BROADCAST and BPF_F_EXCLUDE_INGRESS flags
are tested by test_xdp_redirect_multi.sh but not within the test_progs
framework.

Add a broadcast test case in test_xdp_veth.c to test them.
Use the same BPF programs than the one used by
test_xdp_redirect_multi.sh.
Use a BPF map to select the broadcast flags.
Use a BPF map with an entry per veth to check whether packets are
received or not
Set the tests to run serially to avoid conflicts with
test_xdp_veth_redirect

Signed-off-by: Bastien Curutchet (eBPF Foundation) <[email protected]>
XDP programs loaded on egress is tested by test_xdp_redirect_multi.sh
but not by the test_progs framework.

Add a test case in test_xdp_veth.c to test the XDP program on egress.
Use the same BPF program than test_xdp_redirect_multi.sh that replaces
the source MAC address by one provided through a BPF map.
Use a BPF program that stores the source MAC of received packets in a
map to check the test results.

Signed-off-by: Bastien Curutchet (eBPF Foundation) <[email protected]>
The tests done by test_xdp_redirect_multi.sh are now fully covered by
the CI through test_xdp_veth.c.

Remove test_xdp_redirect_multi.sh
Remove xdp_redirect_multi.c that was used by the script to load and
attach the BPF programs.
Remove their entries in the Makefile

Signed-off-by: Bastien Curutchet (eBPF Foundation) <[email protected]>
@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 3f3c2f0
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=927236
version: 2

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

Successfully merging this pull request may close these issues.

1 participant