bpf: Document BPF_PROG_ATTACH syscall command
authorJoe Stringer <joe@cilium.io>
Tue, 2 Mar 2021 17:19:37 +0000 (09:19 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 5 Mar 2021 02:39:44 +0000 (18:39 -0800)
Document the prog attach command in more detail, based on git commits:
* commit f4324551489e ("bpf: add BPF_PROG_ATTACH and BPF_PROG_DETACH
  commands")
* commit 4f738adba30a ("bpf: create tcp_bpf_ulp allowing BPF to monitor
  socket TX/RX data")
* commit f4364dcfc86d ("media: rc: introduce BPF_PROG_LIRC_MODE2")
* commit d58e468b1112 ("flow_dissector: implements flow dissector BPF
  hook")

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-6-joe@cilium.io
include/uapi/linux/bpf.h

index 6946dde..a8f2964 100644 (file)
@@ -253,6 +253,43 @@ union bpf_iter_link_info {
  *             Attach an eBPF program to a *target_fd* at the specified
  *             *attach_type* hook.
  *
+ *             The *attach_type* specifies the eBPF attachment point to
+ *             attach the program to, and must be one of *bpf_attach_type*
+ *             (see below).
+ *
+ *             The *attach_bpf_fd* must be a valid file descriptor for a
+ *             loaded eBPF program of a cgroup, flow dissector, LIRC, sockmap
+ *             or sock_ops type corresponding to the specified *attach_type*.
+ *
+ *             The *target_fd* must be a valid file descriptor for a kernel
+ *             object which depends on the attach type of *attach_bpf_fd*:
+ *
+ *             **BPF_PROG_TYPE_CGROUP_DEVICE**,
+ *             **BPF_PROG_TYPE_CGROUP_SKB**,
+ *             **BPF_PROG_TYPE_CGROUP_SOCK**,
+ *             **BPF_PROG_TYPE_CGROUP_SOCK_ADDR**,
+ *             **BPF_PROG_TYPE_CGROUP_SOCKOPT**,
+ *             **BPF_PROG_TYPE_CGROUP_SYSCTL**,
+ *             **BPF_PROG_TYPE_SOCK_OPS**
+ *
+ *                     Control Group v2 hierarchy with the eBPF controller
+ *                     enabled. Requires the kernel to be compiled with
+ *                     **CONFIG_CGROUP_BPF**.
+ *
+ *             **BPF_PROG_TYPE_FLOW_DISSECTOR**
+ *
+ *                     Network namespace (eg /proc/self/ns/net).
+ *
+ *             **BPF_PROG_TYPE_LIRC_MODE2**
+ *
+ *                     LIRC device path (eg /dev/lircN). Requires the kernel
+ *                     to be compiled with **CONFIG_BPF_LIRC_MODE2**.
+ *
+ *             **BPF_PROG_TYPE_SK_SKB**,
+ *             **BPF_PROG_TYPE_SK_MSG**
+ *
+ *                     eBPF map of socket type (eg **BPF_MAP_TYPE_SOCKHASH**).
+ *
  *     Return
  *             Returns zero on success. On error, -1 is returned and *errno*
  *             is set appropriately.