netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] tools: bpftool: warn about risky prog array updates
@ 2019-01-28 18:29 Jakub Kicinski
  2019-01-28 18:51 ` [oss-drivers] " Quentin Monnet
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Jakub Kicinski @ 2019-01-28 18:29 UTC (permalink / raw)
  To: alexei.starovoitov, daniel; +Cc: oss-drivers, netdev, Jakub Kicinski

When prog array is updated with bpftool users often refer
to the map via the ID.  Unfortunately, that's likely
to lead to confusion because prog arrays get flushed when
the last user reference is gone.  If there is no other
reference bpftool will create one, update successfully
just to close the map again and have it flushed.

Warn about this case in non-JSON mode.

If the problem continues causing confusion we can remove
the support for referring to a map by ID for prog array
update completely.  For now it seems like the potential
inconvenience to users who know what they're doing outweighs
the benefit.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
---
 tools/bpf/bpftool/map.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
index 8cb0e26907ff..6f33818bb6b6 100644
--- a/tools/bpf/bpftool/map.c
+++ b/tools/bpf/bpftool/map.c
@@ -426,6 +426,9 @@ static int parse_elem(char **argv, struct bpf_map_info *info,
 				p_err("not enough value arguments for map of progs");
 				return -1;
 			}
+			if (is_prefix(*argv, "id"))
+				p_info("Warning: updating program array via MAP_ID, make sure this map is kept open\n"
+				       "         by some process or pinned otherwise update will be lost");
 
 			fd = prog_parse_fd(&argc, &argv);
 			if (fd < 0)
-- 
2.19.2


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

* Re: [oss-drivers] [PATCH bpf-next] tools: bpftool: warn about risky prog array updates
  2019-01-28 18:29 [PATCH bpf-next] tools: bpftool: warn about risky prog array updates Jakub Kicinski
@ 2019-01-28 18:51 ` Quentin Monnet
  2019-01-28 18:54   ` Quentin Monnet
  2019-01-28 20:45 ` Song Liu
  2019-01-28 23:35 ` Daniel Borkmann
  2 siblings, 1 reply; 5+ messages in thread
From: Quentin Monnet @ 2019-01-28 18:51 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Alexei Starovoitov, Daniel Borkmann, OSS-drivers Netronome,
	Linux Kernel Network Developers

On Mon, 28 Jan 2019 at 18:29, Jakub Kicinski
<jakub.kicinski@netronome.com> wrote:
>
> When prog array is updated with bpftool users often refer
> to the map via the ID.  Unfortunately, that's likely
> to lead to confusion because prog arrays get flushed when
> the last user reference is gone.  If there is no other
> reference bpftool will create one, update successfully
> just to close the map again and have it flushed.
>
> Warn about this case in non-JSON mode.
>
> If the problem continues causing confusion we can remove
> the support for referring to a map by ID for prog array
> update completely.  For now it seems like the potential
> inconvenience to users who know what they're doing outweighs
> the benefit.
>
> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>

All good for me!
Quentin

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

* Re: [oss-drivers] [PATCH bpf-next] tools: bpftool: warn about risky prog array updates
  2019-01-28 18:51 ` [oss-drivers] " Quentin Monnet
@ 2019-01-28 18:54   ` Quentin Monnet
  0 siblings, 0 replies; 5+ messages in thread
From: Quentin Monnet @ 2019-01-28 18:54 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Alexei Starovoitov, Daniel Borkmann, OSS-drivers Netronome,
	Linux Kernel Network Developers

2019-01-28 18:51 UTC+0000 ~ Quentin Monnet <quentin.monnet@netronome.com>
> On Mon, 28 Jan 2019 at 18:29, Jakub Kicinski
> <jakub.kicinski@netronome.com> wrote:
>>
>> When prog array is updated with bpftool users often refer
>> to the map via the ID.  Unfortunately, that's likely
>> to lead to confusion because prog arrays get flushed when
>> the last user reference is gone.  If there is no other
>> reference bpftool will create one, update successfully
>> just to close the map again and have it flushed.
>>
>> Warn about this case in non-JSON mode.
>>
>> If the problem continues causing confusion we can remove
>> the support for referring to a map by ID for prog array
>> update completely.  For now it seems like the potential
>> inconvenience to users who know what they're doing outweighs
>> the benefit.
>>
>> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
>> Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
> 
> All good for me!
> Quentin
> 

[Hmm. I read that on GMail interface and thought it was a repost on our 
internal ML. Sorry for the noise.]

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

* Re: [PATCH bpf-next] tools: bpftool: warn about risky prog array updates
  2019-01-28 18:29 [PATCH bpf-next] tools: bpftool: warn about risky prog array updates Jakub Kicinski
  2019-01-28 18:51 ` [oss-drivers] " Quentin Monnet
@ 2019-01-28 20:45 ` Song Liu
  2019-01-28 23:35 ` Daniel Borkmann
  2 siblings, 0 replies; 5+ messages in thread
From: Song Liu @ 2019-01-28 20:45 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Alexei Starovoitov, Daniel Borkmann, oss-drivers, Networking

On Mon, Jan 28, 2019 at 10:30 AM Jakub Kicinski
<jakub.kicinski@netronome.com> wrote:
>
> When prog array is updated with bpftool users often refer
> to the map via the ID.  Unfortunately, that's likely
> to lead to confusion because prog arrays get flushed when
> the last user reference is gone.  If there is no other
> reference bpftool will create one, update successfully
> just to close the map again and have it flushed.
>
> Warn about this case in non-JSON mode.
>
> If the problem continues causing confusion we can remove
> the support for referring to a map by ID for prog array
> update completely.  For now it seems like the potential
> inconvenience to users who know what they're doing outweighs
> the benefit.
>
> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>

Acked-by: Song Liu <songliubraving@fb.com>

> ---
>  tools/bpf/bpftool/map.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
> index 8cb0e26907ff..6f33818bb6b6 100644
> --- a/tools/bpf/bpftool/map.c
> +++ b/tools/bpf/bpftool/map.c
> @@ -426,6 +426,9 @@ static int parse_elem(char **argv, struct bpf_map_info *info,
>                                 p_err("not enough value arguments for map of progs");
>                                 return -1;
>                         }
> +                       if (is_prefix(*argv, "id"))
> +                               p_info("Warning: updating program array via MAP_ID, make sure this map is kept open\n"
> +                                      "         by some process or pinned otherwise update will be lost");
>
>                         fd = prog_parse_fd(&argc, &argv);
>                         if (fd < 0)
> --
> 2.19.2
>

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

* Re: [PATCH bpf-next] tools: bpftool: warn about risky prog array updates
  2019-01-28 18:29 [PATCH bpf-next] tools: bpftool: warn about risky prog array updates Jakub Kicinski
  2019-01-28 18:51 ` [oss-drivers] " Quentin Monnet
  2019-01-28 20:45 ` Song Liu
@ 2019-01-28 23:35 ` Daniel Borkmann
  2 siblings, 0 replies; 5+ messages in thread
From: Daniel Borkmann @ 2019-01-28 23:35 UTC (permalink / raw)
  To: Jakub Kicinski, alexei.starovoitov; +Cc: oss-drivers, netdev

On 01/28/2019 07:29 PM, Jakub Kicinski wrote:
> When prog array is updated with bpftool users often refer
> to the map via the ID.  Unfortunately, that's likely
> to lead to confusion because prog arrays get flushed when
> the last user reference is gone.  If there is no other
> reference bpftool will create one, update successfully
> just to close the map again and have it flushed.
> 
> Warn about this case in non-JSON mode.
> 
> If the problem continues causing confusion we can remove
> the support for referring to a map by ID for prog array
> update completely.  For now it seems like the potential
> inconvenience to users who know what they're doing outweighs
> the benefit.
> 
> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>

Applied, thanks!

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

end of thread, other threads:[~2019-01-28 23:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-28 18:29 [PATCH bpf-next] tools: bpftool: warn about risky prog array updates Jakub Kicinski
2019-01-28 18:51 ` [oss-drivers] " Quentin Monnet
2019-01-28 18:54   ` Quentin Monnet
2019-01-28 20:45 ` Song Liu
2019-01-28 23:35 ` 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).