mirror of
https://github.com/torvalds/linux.git
synced 2024-12-27 13:22:23 +00:00
bpf: Document BPF_PROG_PIN syscall command
Commitb2197755b2
("bpf: add support for persistent maps/progs") contains the original implementation and git logs, used as reference for this documentation. Also pull in the filename restriction as documented in commit6d8cb045cd
("bpf: comment why dots in filenames under BPF virtual FS are not allowed") Signed-off-by: Joe Stringer <joe@cilium.io> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Reviewed-by: Quentin Monnet <quentin@isovalent.com> Acked-by: Toke Høiland-Jørgensen <toke@redhat.com> Acked-by: Yonghong Song <yhs@fb.com> Link: https://lore.kernel.org/bpf/20210302171947.2268128-5-joe@cilium.io
This commit is contained in:
parent
6690523bcc
commit
8aacb3c8d1
@ -219,6 +219,22 @@ union bpf_iter_link_info {
|
|||||||
* Pin an eBPF program or map referred by the specified *bpf_fd*
|
* Pin an eBPF program or map referred by the specified *bpf_fd*
|
||||||
* to the provided *pathname* on the filesystem.
|
* to the provided *pathname* on the filesystem.
|
||||||
*
|
*
|
||||||
|
* The *pathname* argument must not contain a dot (".").
|
||||||
|
*
|
||||||
|
* On success, *pathname* retains a reference to the eBPF object,
|
||||||
|
* preventing deallocation of the object when the original
|
||||||
|
* *bpf_fd* is closed. This allow the eBPF object to live beyond
|
||||||
|
* **close**\ (\ *bpf_fd*\ ), and hence the lifetime of the parent
|
||||||
|
* process.
|
||||||
|
*
|
||||||
|
* Applying **unlink**\ (2) or similar calls to the *pathname*
|
||||||
|
* unpins the object from the filesystem, removing the reference.
|
||||||
|
* If no other file descriptors or filesystem nodes refer to the
|
||||||
|
* same object, it will be deallocated (see NOTES).
|
||||||
|
*
|
||||||
|
* The filesystem type for the parent directory of *pathname* must
|
||||||
|
* be **BPF_FS_MAGIC**.
|
||||||
|
*
|
||||||
* Return
|
* Return
|
||||||
* Returns zero on success. On error, -1 is returned and *errno*
|
* Returns zero on success. On error, -1 is returned and *errno*
|
||||||
* is set appropriately.
|
* is set appropriately.
|
||||||
@ -584,13 +600,19 @@ union bpf_iter_link_info {
|
|||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* eBPF objects (maps and programs) can be shared between processes.
|
* eBPF objects (maps and programs) can be shared between processes.
|
||||||
* For example, after **fork**\ (2), the child inherits file descriptors
|
*
|
||||||
* referring to the same eBPF objects. In addition, file descriptors
|
* * After **fork**\ (2), the child inherits file descriptors
|
||||||
* referring to eBPF objects can be transferred over UNIX domain sockets.
|
* referring to the same eBPF objects.
|
||||||
* File descriptors referring to eBPF objects can be duplicated in the
|
* * File descriptors referring to eBPF objects can be transferred over
|
||||||
* usual way, using **dup**\ (2) and similar calls. An eBPF object is
|
* **unix**\ (7) domain sockets.
|
||||||
* deallocated only after all file descriptors referring to the object
|
* * File descriptors referring to eBPF objects can be duplicated in the
|
||||||
* have been closed.
|
* usual way, using **dup**\ (2) and similar calls.
|
||||||
|
* * File descriptors referring to eBPF objects can be pinned to the
|
||||||
|
* filesystem using the **BPF_OBJ_PIN** command of **bpf**\ (2).
|
||||||
|
*
|
||||||
|
* An eBPF object is deallocated only after all file descriptors referring
|
||||||
|
* to the object have been closed and no references remain pinned to the
|
||||||
|
* filesystem or attached (for example, bound to a program or device).
|
||||||
*/
|
*/
|
||||||
enum bpf_cmd {
|
enum bpf_cmd {
|
||||||
BPF_MAP_CREATE,
|
BPF_MAP_CREATE,
|
||||||
|
Loading…
Reference in New Issue
Block a user