samples/bpf: use bpf_set_link_xdp_fd
Use bpf_set_link_xdp_fd instead of set_link_xdp_fd to remove some code duplication and benefit of netlink ext ack errors message. Signed-off-by: Eric Leblond <eric@regit.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:

committed by
Alexei Starovoitov

parent
6061a3d672
commit
b259c2ffd9
@@ -30,7 +30,7 @@ static __u32 xdp_flags = 0;
|
||||
static void int_exit(int sig)
|
||||
{
|
||||
if (ifindex > -1)
|
||||
set_link_xdp_fd(ifindex, -1, xdp_flags);
|
||||
bpf_set_link_xdp_fd(ifindex, -1, xdp_flags);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@@ -254,14 +254,14 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (set_link_xdp_fd(ifindex, prog_fd[0], xdp_flags) < 0) {
|
||||
if (bpf_set_link_xdp_fd(ifindex, prog_fd[0], xdp_flags) < 0) {
|
||||
printf("link set xdp fd failed\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
poll_stats(kill_after_s);
|
||||
|
||||
set_link_xdp_fd(ifindex, -1, xdp_flags);
|
||||
bpf_set_link_xdp_fd(ifindex, -1, xdp_flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user