History

bpf: update bpf_{g,s}et_retval documentation

* replace 'syscall' with 'upper layers', still mention that it's being exported via syscall errno * describe what happens in set_retval(-EPERM) + return 1 * describe what happens with bind's 'return 3'

Stanislav Fomichev committed 4 years ago

Commit 2172fb81 parent 8a67f2d2 files · +34 −10Browse files

Showing the changes to tools/include/uapi/linux (1 of 2 files). Show all

Unified · Split

tools/include/uapi/linux/bpf.h+17−5
@@ -5085,17 +5085,29 @@ union bpf_attr { · 5084 unmodified lines
50855085 *
50865086 * int bpf_get_retval(void)
50875087 * Description
5088− * Get the syscall's return value that will be returned to userspace.
5088+ * Get the BPF program's return value that will be returned to the upper layers.
50895089 *
5090− * This helper is currently supported by cgroup programs only.
5090+ * This helper is currently supported by cgroup programs and only by the hooks
5091+ * where BPF program's return value is returned to the userspace via errno.
50915092 * Return
5092− * The syscall's return value.
5093+ * The BPF program's return value.
50935094 *
50945095 * int bpf_set_retval(int retval)
50955096 * Description
5096− * Set the syscall's return value that will be returned to userspace.
5097+ * Set the BPF program's return value that will be returned to the upper layers.
5098+ *
5099+ * This helper is currently supported by cgroup programs and only by the hooks
5100+ * where BPF program's return value is returned to the userspace via errno.
5101+ *
5102+ * Note that there is the following corner case where the program exports an error
5103+ * via bpf_set_retval but signals success via 'return 1':
5104+ *
5105+ * bpf_set_retval(-EPERM);
5106+ * return 1;
5107+ *
5108+ * In this case, the BPF program's return value will use helper's -EPERM. This
5109+ * still holds true for cgroup/bind{4,6} which supports extra 'return 3' success case.
50975110 *
5098− * This helper is currently supported by cgroup programs only.
50995111 * Return
51005112 * 0 on success, or a negative error in case of failure.
51015113 *