@@ -77,6 +77,8 @@ static struct veth_configuration net_config[VETH_PAIRS_COUNT] = {
struct prog_configuration {
char local_name[PROG_NAME_MAX_LEN]; /* BPF prog to attach to local_veth */
char remote_name[PROG_NAME_MAX_LEN]; /* BPF prog to attach to remote_veth */
+ u32 local_flags; /* XDP flags to use on local_veth */
+ u32 remote_flags; /* XDP flags to use on remote_veth */
};
static int attach_programs_to_veth_pair(struct bpf_object **objs, size_t nb_obj,
@@ -106,7 +108,8 @@ static int attach_programs_to_veth_pair(struct bpf_object **objs, size_t nb_obj,
if (!ASSERT_NEQ(interface, 0, "non zero interface index"))
return -1;
- ret = bpf_xdp_attach(interface, bpf_program__fd(local_prog), 0, NULL);
+ ret = bpf_xdp_attach(interface, bpf_program__fd(local_prog),
+ prog[index].local_flags, NULL);
if (!ASSERT_OK(ret, "attach xdp program to local veth"))
return -1;
@@ -120,7 +123,8 @@ static int attach_programs_to_veth_pair(struct bpf_object **objs, size_t nb_obj,
return -1;
}
- ret = bpf_xdp_attach(interface, bpf_program__fd(remote_prog), 0, NULL);
+ ret = bpf_xdp_attach(interface, bpf_program__fd(remote_prog),
+ prog[index].remote_flags, NULL);
if (!ASSERT_OK(ret, "attach xdp program to remote veth")) {
close_netns(nstoken);
return -1;
@@ -187,14 +191,20 @@ void test_xdp_veth_redirect(void)
{
.local_name = "xdp_redirect_map_0",
.remote_name = "xdp_dummy_prog",
+ .local_flags = 0,
+ .remote_flags = 0,
},
{
.local_name = "xdp_redirect_map_1",
.remote_name = "xdp_tx",
+ .local_flags = 0,
+ .remote_flags = 0,
},
{
.local_name = "xdp_redirect_map_2",
.remote_name = "xdp_dummy_prog",
+ .local_flags = 0,
+ .remote_flags = 0,
}
};
struct bpf_object *bpf_objs[VETH_REDIRECT_SKEL_NB];
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) <bastien.curutchet@bootlin.com> --- tools/testing/selftests/bpf/prog_tests/test_xdp_veth.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)