netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/3] tools: bpftool: bring minor fixes to bpftool
@ 2018-10-20 22:01 Quentin Monnet
  2018-10-20 22:01 ` [PATCH bpf-next 1/3] tools: bpftool: document restriction on '.' in names to pin in bpffs Quentin Monnet
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Quentin Monnet @ 2018-10-20 22:01 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann; +Cc: netdev, oss-drivers, Quentin Monnet

Hi,
These are three minor fixes for bpftool, its documentation and its bash
completion function. Please refer to individual patches for details.

Quentin Monnet (3):
  tools: bpftool: document restriction on '.' in names to pin in bpffs
  tools: bpftool: print nb of cmds to stdout (not stderr) for batch mode
  tools: bpftool: fix completion for "bpftool map update"

 tools/bpf/bpftool/Documentation/bpftool-map.rst  | 4 +++-
 tools/bpf/bpftool/Documentation/bpftool-prog.rst | 8 ++++++--
 tools/bpf/bpftool/bash-completion/bpftool        | 2 +-
 tools/bpf/bpftool/main.c                         | 3 ++-
 4 files changed, 12 insertions(+), 5 deletions(-)

-- 
2.7.4

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

* [PATCH bpf-next 1/3] tools: bpftool: document restriction on '.' in names to pin in bpffs
  2018-10-20 22:01 [PATCH bpf-next 0/3] tools: bpftool: bring minor fixes to bpftool Quentin Monnet
@ 2018-10-20 22:01 ` Quentin Monnet
  2018-10-20 22:01 ` [PATCH bpf-next 2/3] tools: bpftool: print nb of cmds to stdout (not stderr) for batch mode Quentin Monnet
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Quentin Monnet @ 2018-10-20 22:01 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann; +Cc: netdev, oss-drivers, Quentin Monnet

Names used to pin eBPF programs and maps under the eBPF virtual file
system cannot contain a dot character, which is reserved for future
extensions of this file system.

Document this in bpftool man pages to avoid users getting confused if
pinning fails because of a dot.

Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
 tools/bpf/bpftool/Documentation/bpftool-map.rst  | 4 +++-
 tools/bpf/bpftool/Documentation/bpftool-prog.rst | 8 ++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/tools/bpf/bpftool/Documentation/bpftool-map.rst b/tools/bpf/bpftool/Documentation/bpftool-map.rst
index 3497f2d80328..f55a2daed59b 100644
--- a/tools/bpf/bpftool/Documentation/bpftool-map.rst
+++ b/tools/bpf/bpftool/Documentation/bpftool-map.rst
@@ -86,7 +86,9 @@ DESCRIPTION
 	**bpftool map pin**     *MAP*  *FILE*
 		  Pin map *MAP* as *FILE*.
 
-		  Note: *FILE* must be located in *bpffs* mount.
+		  Note: *FILE* must be located in *bpffs* mount. It must not
+		  contain a dot character ('.'), which is reserved for future
+		  extensions of *bpffs*.
 
 	**bpftool** **map event_pipe** *MAP* [**cpu** *N* **index** *M*]
 		  Read events from a BPF_MAP_TYPE_PERF_EVENT_ARRAY map.
diff --git a/tools/bpf/bpftool/Documentation/bpftool-prog.rst b/tools/bpf/bpftool/Documentation/bpftool-prog.rst
index 12c803003ab2..ac4e904b10fb 100644
--- a/tools/bpf/bpftool/Documentation/bpftool-prog.rst
+++ b/tools/bpf/bpftool/Documentation/bpftool-prog.rst
@@ -75,7 +75,9 @@ DESCRIPTION
 	**bpftool prog pin** *PROG* *FILE*
 		  Pin program *PROG* as *FILE*.
 
-		  Note: *FILE* must be located in *bpffs* mount.
+		  Note: *FILE* must be located in *bpffs* mount. It must not
+		  contain a dot character ('.'), which is reserved for future
+		  extensions of *bpffs*.
 
 	**bpftool prog load** *OBJ* *FILE* [**type** *TYPE*] [**map** {**idx** *IDX* | **name** *NAME*} *MAP*] [**dev** *NAME*]
 		  Load bpf program from binary *OBJ* and pin as *FILE*.
@@ -91,7 +93,9 @@ DESCRIPTION
 		  If **dev** *NAME* is specified program will be loaded onto
 		  given networking device (offload).
 
-		  Note: *FILE* must be located in *bpffs* mount.
+		  Note: *FILE* must be located in *bpffs* mount. It must not
+		  contain a dot character ('.'), which is reserved for future
+		  extensions of *bpffs*.
 
         **bpftool prog attach** *PROG* *ATTACH_TYPE* *MAP*
                   Attach bpf program *PROG* (with type specified by *ATTACH_TYPE*)
-- 
2.7.4

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

* [PATCH bpf-next 2/3] tools: bpftool: print nb of cmds to stdout (not stderr) for batch mode
  2018-10-20 22:01 [PATCH bpf-next 0/3] tools: bpftool: bring minor fixes to bpftool Quentin Monnet
  2018-10-20 22:01 ` [PATCH bpf-next 1/3] tools: bpftool: document restriction on '.' in names to pin in bpffs Quentin Monnet
@ 2018-10-20 22:01 ` Quentin Monnet
  2018-10-20 22:01 ` [PATCH bpf-next 3/3] tools: bpftool: fix completion for "bpftool map update" Quentin Monnet
  2018-10-21  6:22 ` [PATCH bpf-next 0/3] tools: bpftool: bring minor fixes to bpftool Alexei Starovoitov
  3 siblings, 0 replies; 5+ messages in thread
From: Quentin Monnet @ 2018-10-20 22:01 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann; +Cc: netdev, oss-drivers, Quentin Monnet

When batch mode is used and all commands succeeds, bpftool prints the
number of commands processed to stderr. There is no particular reason to
use stderr for this, we could as well use stdout. It would avoid getting
unnecessary output on stderr if the standard ouptut is redirected, for
example.

Reported-by: David Beckett <david.beckett@netronome.com>
Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
 tools/bpf/bpftool/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c
index 828dde30e9ec..75a3296dc0bc 100644
--- a/tools/bpf/bpftool/main.c
+++ b/tools/bpf/bpftool/main.c
@@ -321,7 +321,8 @@ static int do_batch(int argc, char **argv)
 		p_err("reading batch file failed: %s", strerror(errno));
 		err = -1;
 	} else {
-		p_info("processed %d commands", lines);
+		if (!json_output)
+			printf("processed %d commands\n", lines);
 		err = 0;
 	}
 err_close:
-- 
2.7.4

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

* [PATCH bpf-next 3/3] tools: bpftool: fix completion for "bpftool map update"
  2018-10-20 22:01 [PATCH bpf-next 0/3] tools: bpftool: bring minor fixes to bpftool Quentin Monnet
  2018-10-20 22:01 ` [PATCH bpf-next 1/3] tools: bpftool: document restriction on '.' in names to pin in bpffs Quentin Monnet
  2018-10-20 22:01 ` [PATCH bpf-next 2/3] tools: bpftool: print nb of cmds to stdout (not stderr) for batch mode Quentin Monnet
@ 2018-10-20 22:01 ` Quentin Monnet
  2018-10-21  6:22 ` [PATCH bpf-next 0/3] tools: bpftool: bring minor fixes to bpftool Alexei Starovoitov
  3 siblings, 0 replies; 5+ messages in thread
From: Quentin Monnet @ 2018-10-20 22:01 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann; +Cc: netdev, oss-drivers, Quentin Monnet

When trying to complete "bpftool map update" commands, the call to
printf would print an error message that would show on the command line
if no map is found to complete the command line.

Fix it by making sure we have map ids to complete the line with, before
we try to print something.

Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
 tools/bpf/bpftool/bash-completion/bpftool | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/bpf/bpftool/bash-completion/bpftool b/tools/bpf/bpftool/bash-completion/bpftool
index c56545e87b0d..3f78e6404589 100644
--- a/tools/bpf/bpftool/bash-completion/bpftool
+++ b/tools/bpf/bpftool/bash-completion/bpftool
@@ -143,7 +143,7 @@ _bpftool_map_update_map_type()
     local type
     type=$(bpftool -jp map show $keyword $ref | \
         command sed -n 's/.*"type": "\(.*\)",$/\1/p')
-    printf $type
+    [[ -n $type ]] && printf $type
 }
 
 _bpftool_map_update_get_id()
-- 
2.7.4

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

* Re: [PATCH bpf-next 0/3] tools: bpftool: bring minor fixes to bpftool
  2018-10-20 22:01 [PATCH bpf-next 0/3] tools: bpftool: bring minor fixes to bpftool Quentin Monnet
                   ` (2 preceding siblings ...)
  2018-10-20 22:01 ` [PATCH bpf-next 3/3] tools: bpftool: fix completion for "bpftool map update" Quentin Monnet
@ 2018-10-21  6:22 ` Alexei Starovoitov
  3 siblings, 0 replies; 5+ messages in thread
From: Alexei Starovoitov @ 2018-10-21  6:22 UTC (permalink / raw)
  To: Quentin Monnet; +Cc: Alexei Starovoitov, Daniel Borkmann, netdev, oss-drivers

On Sat, Oct 20, 2018 at 11:01:47PM +0100, Quentin Monnet wrote:
> Hi,
> These are three minor fixes for bpftool, its documentation and its bash
> completion function. Please refer to individual patches for details.

Applied, Thanks

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

end of thread, other threads:[~2018-10-21 14:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-20 22:01 [PATCH bpf-next 0/3] tools: bpftool: bring minor fixes to bpftool Quentin Monnet
2018-10-20 22:01 ` [PATCH bpf-next 1/3] tools: bpftool: document restriction on '.' in names to pin in bpffs Quentin Monnet
2018-10-20 22:01 ` [PATCH bpf-next 2/3] tools: bpftool: print nb of cmds to stdout (not stderr) for batch mode Quentin Monnet
2018-10-20 22:01 ` [PATCH bpf-next 3/3] tools: bpftool: fix completion for "bpftool map update" Quentin Monnet
2018-10-21  6:22 ` [PATCH bpf-next 0/3] tools: bpftool: bring minor fixes to bpftool Alexei Starovoitov

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).