netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] samples/bpf: Fix dummy program unloading for xdp_redirect samples
@ 2019-02-21 16:05 Toke Høiland-Jørgensen
  2019-02-21 16:30 ` Maciej Fijalkowski
  0 siblings, 1 reply; 4+ messages in thread
From: Toke Høiland-Jørgensen @ 2019-02-21 16:05 UTC (permalink / raw)
  To: netdev; +Cc: Toke Høiland-Jørgensen

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")
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
---
 samples/bpf/xdp_redirect_map_user.c | 2 +-
 samples/bpf/xdp_redirect_user.c     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/samples/bpf/xdp_redirect_map_user.c b/samples/bpf/xdp_redirect_map_user.c
index 327226be5a06..1dbe7fd3a1a8 100644
--- a/samples/bpf/xdp_redirect_map_user.c
+++ b/samples/bpf/xdp_redirect_map_user.c
@@ -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");
diff --git a/samples/bpf/xdp_redirect_user.c b/samples/bpf/xdp_redirect_user.c
index a5d8ad3129ed..e9054c0269ff 100644
--- a/samples/bpf/xdp_redirect_user.c
+++ b/samples/bpf/xdp_redirect_user.c
@@ -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");
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] samples/bpf: Fix dummy program unloading for xdp_redirect samples
  2019-02-21 16:05 [PATCH] samples/bpf: Fix dummy program unloading for xdp_redirect samples Toke Høiland-Jørgensen
@ 2019-02-21 16:30 ` Maciej Fijalkowski
  2019-02-21 22:47   ` Martin Lau
  0 siblings, 1 reply; 4+ messages in thread
From: Maciej Fijalkowski @ 2019-02-21 16:30 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen; +Cc: netdev

On Thu, 21 Feb 2019 17:05:39 +0100
Toke Høiland-Jørgensen <toke@redhat.com> wrote:

> 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")
> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
> ---
>  samples/bpf/xdp_redirect_map_user.c | 2 +-
>  samples/bpf/xdp_redirect_user.c     | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/samples/bpf/xdp_redirect_map_user.c b/samples/bpf/xdp_redirect_map_user.c
> index 327226be5a06..1dbe7fd3a1a8 100644
> --- a/samples/bpf/xdp_redirect_map_user.c
> +++ b/samples/bpf/xdp_redirect_map_user.c
> @@ -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");
> diff --git a/samples/bpf/xdp_redirect_user.c b/samples/bpf/xdp_redirect_user.c
> index a5d8ad3129ed..e9054c0269ff 100644
> --- a/samples/bpf/xdp_redirect_user.c
> +++ b/samples/bpf/xdp_redirect_user.c
> @@ -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: Maciej Fijalkowski <maciej.fijalkowski@intel.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] samples/bpf: Fix dummy program unloading for xdp_redirect samples
  2019-02-21 16:30 ` Maciej Fijalkowski
@ 2019-02-21 22:47   ` Martin Lau
  2019-02-22 15:23     ` Daniel Borkmann
  0 siblings, 1 reply; 4+ messages in thread
From: Martin Lau @ 2019-02-21 22:47 UTC (permalink / raw)
  To: Maciej Fijalkowski; +Cc: Toke Høiland-Jørgensen, netdev

On Thu, Feb 21, 2019 at 05:30:54PM +0100, Maciej Fijalkowski wrote:
> On Thu, 21 Feb 2019 17:05:39 +0100
> Toke Høiland-Jørgensen <toke@redhat.com> wrote:
> 
> > 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/

> > the comparison to avoid this.
The change LGTM.

Acked-by: Martin KaFai Lau <kafai@fb.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] samples/bpf: Fix dummy program unloading for xdp_redirect samples
  2019-02-21 22:47   ` Martin Lau
@ 2019-02-22 15:23     ` Daniel Borkmann
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Borkmann @ 2019-02-22 15:23 UTC (permalink / raw)
  To: Martin Lau, Maciej Fijalkowski; +Cc: Toke Høiland-Jørgensen, netdev

On 02/21/2019 11:47 PM, Martin Lau wrote:
> On Thu, Feb 21, 2019 at 05:30:54PM +0100, Maciej Fijalkowski wrote:
>> On Thu, 21 Feb 2019 17:05:39 +0100
>> Toke Høiland-Jørgensen <toke@redhat.com> wrote:
>>
>>> 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!

>>> the comparison to avoid this.
> The change LGTM.
> 
> Acked-by: Martin KaFai Lau <kafai@fb.com>
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-02-22 15:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-21 16:05 [PATCH] samples/bpf: Fix dummy program unloading for xdp_redirect samples Toke Høiland-Jørgensen
2019-02-21 16:30 ` Maciej Fijalkowski
2019-02-21 22:47   ` Martin Lau
2019-02-22 15:23     ` Daniel Borkmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).