* [bpf-next v3 2/2] bpftool: Update doc (add auto_attach to prog load)
@ 2022-09-09 6:17 Wang Yufen
2022-09-09 11:38 ` Quentin Monnet
0 siblings, 1 reply; 2+ messages in thread
From: Wang Yufen @ 2022-09-09 6:17 UTC (permalink / raw)
To: quentin, ast, daniel, andrii, martin.lau, song, yhs,
john.fastabend, kpsingh, sdf, haoluo, jolsa, davem, kuba, hawk,
nathan, ndesaulniers, trix
Cc: bpf, linux-kernel, netdev, llvm
Add auto_attach optional to prog load|loadall for supporting
one-step load-attach-pin_link.
Signed-off-by: Wang Yufen <wangyufen@huawei.com>
---
tools/bpf/bpftool/Documentation/bpftool-prog.rst | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/tools/bpf/bpftool/Documentation/bpftool-prog.rst b/tools/bpf/bpftool/Documentation/bpftool-prog.rst
index eb1b2a2..c640ad3 100644
--- a/tools/bpf/bpftool/Documentation/bpftool-prog.rst
+++ b/tools/bpf/bpftool/Documentation/bpftool-prog.rst
@@ -31,7 +31,8 @@ PROG COMMANDS
| **bpftool** **prog dump xlated** *PROG* [{**file** *FILE* | **opcodes** | **visual** | **linum**}]
| **bpftool** **prog dump jited** *PROG* [{**file** *FILE* | **opcodes** | **linum**}]
| **bpftool** **prog pin** *PROG* *FILE*
-| **bpftool** **prog** { **load** | **loadall** } *OBJ* *PATH* [**type** *TYPE*] [**map** {**idx** *IDX* | **name** *NAME*} *MAP*] [**dev** *NAME*] [**pinmaps** *MAP_DIR*]
+| **bpftool** **prog** { **load** | **loadall** } *OBJ* *PATH* [**type** *TYPE*] [**map** {**idx** *IDX* | **name** *NAME*} *MAP*] \
+| [**dev** *NAME*] [**pinmaps** *MAP_DIR*] [**auto_attach**]
| **bpftool** **prog attach** *PROG* *ATTACH_TYPE* [*MAP*]
| **bpftool** **prog detach** *PROG* *ATTACH_TYPE* [*MAP*]
| **bpftool** **prog tracelog**
@@ -131,7 +132,7 @@ DESCRIPTION
contain a dot character ('.'), which is reserved for future
extensions of *bpffs*.
- **bpftool prog { load | loadall }** *OBJ* *PATH* [**type** *TYPE*] [**map** {**idx** *IDX* | **name** *NAME*} *MAP*] [**dev** *NAME*] [**pinmaps** *MAP_DIR*]
+ **bpftool prog { load | loadall }** *OBJ* *PATH* [**type** *TYPE*] [**map** {**idx** *IDX* | **name** *NAME*} *MAP*] [**dev** *NAME*] [**pinmaps** *MAP_DIR*] [**auto_attach**]
Load bpf program(s) from binary *OBJ* and pin as *PATH*.
**bpftool prog load** pins only the first program from the
*OBJ* as *PATH*. **bpftool prog loadall** pins all programs
@@ -149,6 +150,8 @@ DESCRIPTION
given networking device (offload).
Optional **pinmaps** argument can be provided to pin all
maps under *MAP_DIR* directory.
+ If **auto_attach** is specified program will be attached
+ before pin.
Note: *PATH* must be located in *bpffs* mount. It must not
contain a dot character ('.'), which is reserved for future
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [bpf-next v3 2/2] bpftool: Update doc (add auto_attach to prog load)
2022-09-09 6:17 [bpf-next v3 2/2] bpftool: Update doc (add auto_attach to prog load) Wang Yufen
@ 2022-09-09 11:38 ` Quentin Monnet
0 siblings, 0 replies; 2+ messages in thread
From: Quentin Monnet @ 2022-09-09 11:38 UTC (permalink / raw)
To: Wang Yufen, ast, daniel, andrii, martin.lau, song, yhs,
john.fastabend, kpsingh, sdf, haoluo, jolsa, davem, kuba, hawk,
nathan, ndesaulniers, trix
Cc: bpf, linux-kernel, netdev, llvm
On 09/09/2022 07:17, Wang Yufen wrote:
> Add auto_attach optional to prog load|loadall for supporting
> one-step load-attach-pin_link.
>
> Signed-off-by: Wang Yufen <wangyufen@huawei.com>
> ---
> tools/bpf/bpftool/Documentation/bpftool-prog.rst | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/tools/bpf/bpftool/Documentation/bpftool-prog.rst b/tools/bpf/bpftool/Documentation/bpftool-prog.rst
> index eb1b2a2..c640ad3 100644
> --- a/tools/bpf/bpftool/Documentation/bpftool-prog.rst
> +++ b/tools/bpf/bpftool/Documentation/bpftool-prog.rst
> @@ -31,7 +31,8 @@ PROG COMMANDS
> | **bpftool** **prog dump xlated** *PROG* [{**file** *FILE* | **opcodes** | **visual** | **linum**}]
> | **bpftool** **prog dump jited** *PROG* [{**file** *FILE* | **opcodes** | **linum**}]
> | **bpftool** **prog pin** *PROG* *FILE*
> -| **bpftool** **prog** { **load** | **loadall** } *OBJ* *PATH* [**type** *TYPE*] [**map** {**idx** *IDX* | **name** *NAME*} *MAP*] [**dev** *NAME*] [**pinmaps** *MAP_DIR*]
> +| **bpftool** **prog** { **load** | **loadall** } *OBJ* *PATH* [**type** *TYPE*] [**map** {**idx** *IDX* | **name** *NAME*} *MAP*] \
> +| [**dev** *NAME*] [**pinmaps** *MAP_DIR*] [**auto_attach**]
Nit: Let's keep this on one line. Not necessary the best in the RST, but
I prefer to leave it to man to wrap the line on the generated page.
> | **bpftool** **prog attach** *PROG* *ATTACH_TYPE* [*MAP*]
> | **bpftool** **prog detach** *PROG* *ATTACH_TYPE* [*MAP*]
> | **bpftool** **prog tracelog**
> @@ -131,7 +132,7 @@ DESCRIPTION
> contain a dot character ('.'), which is reserved for future
> extensions of *bpffs*.
>
> - **bpftool prog { load | loadall }** *OBJ* *PATH* [**type** *TYPE*] [**map** {**idx** *IDX* | **name** *NAME*} *MAP*] [**dev** *NAME*] [**pinmaps** *MAP_DIR*]
> + **bpftool prog { load | loadall }** *OBJ* *PATH* [**type** *TYPE*] [**map** {**idx** *IDX* | **name** *NAME*} *MAP*] [**dev** *NAME*] [**pinmaps** *MAP_DIR*] [**auto_attach**]
> Load bpf program(s) from binary *OBJ* and pin as *PATH*.
> **bpftool prog load** pins only the first program from the
> *OBJ* as *PATH*. **bpftool prog loadall** pins all programs
> @@ -149,6 +150,8 @@ DESCRIPTION
> given networking device (offload).
> Optional **pinmaps** argument can be provided to pin all
> maps under *MAP_DIR* directory.
> + If **auto_attach** is specified program will be attached
> + before pin.
I would like more precisions here, please. In particular, can you add
that 1) in that case, only the link (representing the program attached
to its hook) is pinned, not the program as such, so the path won't show
in "bpftool prog show -f" (I think), and 2) this only works when bpftool
(libbpf) is able to infer all necessary information from the object
file, in particular, it's not supported for all program types. Probably
worth adding an empty line before the description for auto_attach to
have it in a dedicated paragraph.
>
> Note: *PATH* must be located in *bpffs* mount. It must not
> contain a dot character ('.'), which is reserved for future
Can you also update the bash completion, please? Just the following:
diff --git a/tools/bpf/bpftool/bash-completion/bpftool
b/tools/bpf/bpftool/bash-completion/bpftool
index dc1641e3670e..3f6f4f9c3e80 100644
--- a/tools/bpf/bpftool/bash-completion/bpftool
+++ b/tools/bpf/bpftool/bash-completion/bpftool
@@ -505,6 +505,7 @@ _bpftool()
_bpftool_once_attr 'type'
_bpftool_once_attr 'dev'
_bpftool_once_attr 'pinmaps'
+ _bpftool_once_attr 'auto_attach'
return 0
;;
esac
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-09-09 11:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-09 6:17 [bpf-next v3 2/2] bpftool: Update doc (add auto_attach to prog load) Wang Yufen
2022-09-09 11:38 ` Quentin Monnet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox