diff mbox series

[bpf-next,v6,2/3] bpftool: Update doc (add autoattach to prog load)

Message ID 1664014430-5286-2-git-send-email-wangyufen@huawei.com (mailing list archive)
State Superseded
Delegated to: BPF
Headers show
Series [bpf-next,v6,1/3] bpftool: Add auto_attach for bpf prog load|loadall | expand

Checks

Context Check Description
bpf/vmtest-bpf-next-PR success PR summary
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter warning Series does not have a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 18 of 18 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 31 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-VM_Test-1 success Logs for build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-15 success Logs for test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-16 success Logs for test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-17 success Logs for test_verifier on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-9 success Logs for test_progs on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-12 success Logs for test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-13 success Logs for test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-14 success Logs for test_progs_no_alu32 on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-10 success Logs for test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-11 success Logs for test_progs on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-8 success Logs for test_maps on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-7 success Logs for test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-6 success Logs for test_maps on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-4 success Logs for llvm-toolchain
bpf/vmtest-bpf-next-VM_Test-5 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-2 success Logs for build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-3 success Logs for build for x86_64 with llvm-16

Commit Message

wangyufen Sept. 24, 2022, 10:13 a.m. UTC
Add autoattach 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 | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

Comments

Daniel Borkmann Sept. 26, 2022, 4:20 p.m. UTC | #1
On 9/24/22 12:13 PM, Wang Yufen wrote:
> Add autoattach 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 | 13 +++++++++++--
>   1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/bpf/bpftool/Documentation/bpftool-prog.rst b/tools/bpf/bpftool/Documentation/bpftool-prog.rst
> index eb1b2a254eb1..2d9f27a0120f 100644
> --- a/tools/bpf/bpftool/Documentation/bpftool-prog.rst
> +++ b/tools/bpf/bpftool/Documentation/bpftool-prog.rst
> @@ -31,7 +31,7 @@ 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*] [**autoattach**]
>   |	**bpftool** **prog attach** *PROG* *ATTACH_TYPE* [*MAP*]
>   |	**bpftool** **prog detach** *PROG* *ATTACH_TYPE* [*MAP*]
>   |	**bpftool** **prog tracelog**
> @@ -131,7 +131,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*] [**autoattach**]
>   		  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
> @@ -150,6 +150,15 @@ DESCRIPTION
>   		  Optional **pinmaps** argument can be provided to pin all
>   		  maps under *MAP_DIR* directory.
>   
> +		  If **autoattach** is specified program will be attached
> +		  before pin. 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**",
> +		  only show in "**bpftool link show -f**". Also, this only works
> +		  when bpftool (libbpf) is able to infer all necessary information
> +		  from the objectfile, in particular, it's not supported for all
> +		  program types.

Related to Quentin's comment, the documentation should also describe clear semantics
on what happens in failure case. I presume the use case you have in mind is to use
this facility for scripts e.g. to run/load some tests objs? Thus would be good to describe
to users what they need to do/clean up when things only partially succeed etc..

>   		  Note: *PATH* must be located in *bpffs* mount. It must not
>   		  contain a dot character ('.'), which is reserved for future
>   		  extensions of *bpffs*.
>
wangyufen Sept. 27, 2022, 11:05 a.m. UTC | #2
在 2022/9/27 0:20, Daniel Borkmann 写道:
> On 9/24/22 12:13 PM, Wang Yufen wrote:
>> Add autoattach 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 | 13 +++++++++++--
>>   1 file changed, 11 insertions(+), 2 deletions(-)
>>
>> diff --git a/tools/bpf/bpftool/Documentation/bpftool-prog.rst 
>> b/tools/bpf/bpftool/Documentation/bpftool-prog.rst
>> index eb1b2a254eb1..2d9f27a0120f 100644
>> --- a/tools/bpf/bpftool/Documentation/bpftool-prog.rst
>> +++ b/tools/bpf/bpftool/Documentation/bpftool-prog.rst
>> @@ -31,7 +31,7 @@ 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*] [**autoattach**]
>>   |    **bpftool** **prog attach** *PROG* *ATTACH_TYPE* [*MAP*]
>>   |    **bpftool** **prog detach** *PROG* *ATTACH_TYPE* [*MAP*]
>>   |    **bpftool** **prog tracelog**
>> @@ -131,7 +131,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*] [**autoattach**]
>>             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
>> @@ -150,6 +150,15 @@ DESCRIPTION
>>             Optional **pinmaps** argument can be provided to pin all
>>             maps under *MAP_DIR* directory.
>>   +          If **autoattach** is specified program will be attached
>> +          before pin. 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**",
>> +          only show in "**bpftool link show -f**". Also, this only 
>> works
>> +          when bpftool (libbpf) is able to infer all necessary 
>> information
>> +          from the objectfile, in particular, it's not supported for 
>> all
>> +          program types.
>
> Related to Quentin's comment, the documentation should also describe 
> clear semantics
> on what happens in failure case. I presume the use case you have in 
> mind is to use
> this facility for scripts e.g. to run/load some tests objs? Thus would 
> be good to describe
> to users what they need to do/clean up when things only partially 
> succeed etc..


Thanks for your comment.
add in v7, please check.

>
>>             Note: *PATH* must be located in *bpffs* mount. It must not
>>             contain a dot character ('.'), which is reserved for future
>>             extensions of *bpffs*.
>>
>
>
diff mbox series

Patch

diff --git a/tools/bpf/bpftool/Documentation/bpftool-prog.rst b/tools/bpf/bpftool/Documentation/bpftool-prog.rst
index eb1b2a254eb1..2d9f27a0120f 100644
--- a/tools/bpf/bpftool/Documentation/bpftool-prog.rst
+++ b/tools/bpf/bpftool/Documentation/bpftool-prog.rst
@@ -31,7 +31,7 @@  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*] [**autoattach**]
 |	**bpftool** **prog attach** *PROG* *ATTACH_TYPE* [*MAP*]
 |	**bpftool** **prog detach** *PROG* *ATTACH_TYPE* [*MAP*]
 |	**bpftool** **prog tracelog**
@@ -131,7 +131,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*] [**autoattach**]
 		  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
@@ -150,6 +150,15 @@  DESCRIPTION
 		  Optional **pinmaps** argument can be provided to pin all
 		  maps under *MAP_DIR* directory.
 
+		  If **autoattach** is specified program will be attached
+		  before pin. 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**",
+		  only show in "**bpftool link show -f**". Also, this only works
+		  when bpftool (libbpf) is able to infer all necessary information
+		  from the objectfile, in particular, it's not supported for all
+		  program types.
+
 		  Note: *PATH* must be located in *bpffs* mount. It must not
 		  contain a dot character ('.'), which is reserved for future
 		  extensions of *bpffs*.