]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
samples/bpf: Fix dummy program unloading for xdp_redirect samples
authorToke Høiland-Jørgensen <toke@redhat.com>
Thu, 21 Feb 2019 16:05:39 +0000 (17:05 +0100)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 22 Feb 2019 15:21:59 +0000 (16:21 +0100)
The xdp_redirect and xdp_redirect_map sample programs both load a dummy
program onto the egress interfaces. However, the unload code checks these
programs against the wrong id number, and thus refuses to unload them. Fix
the comparison to avoid this.

Fixes: 3b7a8ec2dec3 ("samples/bpf: Check the prog id before exiting")
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
samples/bpf/xdp_redirect_map_user.c
samples/bpf/xdp_redirect_user.c

index 327226be5a06990aa3092a417b4c0fa2dfb57048..1dbe7fd3a1a84da3e7ef956dad326056c61e4000 100644 (file)
@@ -57,7 +57,7 @@ static void int_exit(int sig)
                        printf("bpf_get_link_xdp_id failed\n");
                        exit(1);
                }
-               if (prog_id == curr_prog_id)
+               if (dummy_prog_id == curr_prog_id)
                        bpf_set_link_xdp_fd(ifindex_out, -1, xdp_flags);
                else if (!curr_prog_id)
                        printf("couldn't find a prog id on iface OUT\n");
index a5d8ad3129edebfa8385491890d8a0c8b592d921..e9054c0269ff5dcdbf3d0c4f08c37ed6b43f9e5f 100644 (file)
@@ -57,7 +57,7 @@ static void int_exit(int sig)
                        printf("bpf_get_link_xdp_id failed\n");
                        exit(1);
                }
-               if (prog_id == curr_prog_id)
+               if (dummy_prog_id == curr_prog_id)
                        bpf_set_link_xdp_fd(ifindex_out, -1, xdp_flags);
                else if (!curr_prog_id)
                        printf("couldn't find a prog id on iface OUT\n");