Skip to contentSkip to conversation

samples/bpf: Fix dummy program unloading for xdp_redirect samples

PATCH In review Toke Høiland-Jørgensen 4 participants 4 messages Feb 21, 2019 – Feb 22, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 samples/bpf: Fix dummy program unloading for xdp_redirect samples

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 fd number, and thus refuses to unload them. Fix the comparison to avoid this.

Fixes 3b7a8ec2dec3 ("samples/bpf: Check the prog id before exiting")
---
 samples/bpf/xdp_redirect_map_user.c | 2 +-
 samples/bpf/xdp_redirect_user.c     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
samples/bpf/xdp_redirect_map_user.c +1 -1
index 327226be5a06..1dbe7fd3a1a8 100644
@@ -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");
samples/bpf/xdp_redirect_user.c +1 -1
index a5d8ad3129ed..e9054c0269ff 100644
@@ -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");
Signature · 1 line
2.20.1
Acked-by on v1 1/1
#1 lore raw
Quoted 30 lines · On Thu, 21 Feb 2019 17:05:39 +0100 Toke Høiland-Jørgensen <[email protected]>…

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 fd number, and thus refuses to unload them. Fix the comparison to avoid this.

Fixes 3b7a8ec2dec3 ("samples/bpf: Check the prog id before exiting")
---
 samples/bpf/xdp_redirect_map_user.c | 2 +-
 samples/bpf/xdp_redirect_user.c     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
samples/bpf/xdp_redirect_map_user.c +1 -1
index 327226be5a06..1dbe7fd3a1a8 100644
@@ -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");
samples/bpf/xdp_redirect_user.c +0 -0
index a5d8ad3129ed..e9054c0269ff 100644

samples/bpf/xdp_redirect_user.c static void int_exit(int sig) · line 63

Quoted 8 lines
samples/bpf/xdp_redirect_user.c +1 -1
@@ -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");

It seems that I confused this in last version of patchset...my bad.

Acked-by
#2 lore raw
Quoted 6 lines · Maciej Fijalkowski
Quoted 3 lines · On Thu, 21 Feb 2019 17:05:39 +0100 Toke Høiland-Jørgensen <[email protected]>…

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 fd number, and thus refuses to unload them. Fix

s/fd/id/

Quoted 1 line
Quoted 1 line

the comparison to avoid this.

The change LGTM.

maintainer
#3 lore raw
Quoted 8 lines · Martin Lau
Quoted 6 lines · Maciej Fijalkowski
Quoted 3 lines · On Thu, 21 Feb 2019 17:05:39 +0100 Toke Høiland-Jørgensen <[email protected]>…

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 fd number, and thus refuses to unload them. Fix

s/fd/id/

Applied and fixed above typo, thanks!

Quoted 5 lines
Quoted 1 line
Quoted 1 line

the comparison to avoid this.

The change LGTM.