History

tools, bpf: Synchronise BPF UAPI header with tools

Synchronise the bpf.h header under tools, to report the fixes recently brought to the documentation for the BPF helpers.

Quentin Monnet committed 6 years ago

Commit ff204601 parent ab8d7801 file · +59 −50Browse files

Unified · Split

tools/include/uapi/linux/bpf.h+59−50
@@ -675,8 +675,8 @@ union bpf_attr { · 674 unmodified lines
675675 * For tracing programs, safely attempt to read *size* bytes from
676676 * kernel space address *unsafe_ptr* and store the data in *dst*.
677677 *
678− * Generally, use bpf_probe_read_user() or bpf_probe_read_kernel()
679− * instead.
678+ * Generally, use **bpf_probe_read_user**\ () or
679+ * **bpf_probe_read_kernel**\ () instead.
680680 * Return
681681 * 0 on success, or a negative error in case of failure.
682682 *
@@ -684,7 +684,7 @@ union bpf_attr { · 1 unmodified line
684684 * Description
685685 * Return the time elapsed since system boot, in nanoseconds.
686686 * Does not include time the system was suspended.
687− * See: clock_gettime(CLOCK_MONOTONIC)
687+ * See: **clock_gettime**\ (**CLOCK_MONOTONIC**)
688688 * Return
689689 * Current *ktime*.
690690 *
@@ -1543,11 +1543,11 @@ union bpf_attr { · 852 unmodified lines
15431543 * int bpf_probe_read_str(void *dst, u32 size, const void *unsafe_ptr)
15441544 * Description
15451545 * Copy a NUL terminated string from an unsafe kernel address
1546− * *unsafe_ptr* to *dst*. See bpf_probe_read_kernel_str() for
1546+ * *unsafe_ptr* to *dst*. See **bpf_probe_read_kernel_str**\ () for
15471547 * more details.
15481548 *
1549− * Generally, use bpf_probe_read_user_str() or bpf_probe_read_kernel_str()
1550− * instead.
1549+ * Generally, use **bpf_probe_read_user_str**\ () or
1550+ * **bpf_probe_read_kernel_str**\ () instead.
15511551 * Return
15521552 * On success, the strictly positive length of the string,
15531553 * including the trailing NUL character. On error, a negative
@@ -1575,7 +1575,7 @@ union bpf_attr { · 21 unmodified lines
15751575 *
15761576 * u64 bpf_get_socket_cookie(struct bpf_sock_ops *ctx)
15771577 * Description
1578− * Equivalent to bpf_get_socket_cookie() helper that accepts
1578+ * Equivalent to **bpf_get_socket_cookie**\ () helper that accepts
15791579 * *skb*, but gets socket from **struct bpf_sock_ops** context.
15801580 * Return
15811581 * A 8-byte long non-decreasing number.
@@ -1604,6 +1604,7 @@ union bpf_attr { · 22 unmodified lines
16041604 * The option value of length *optlen* is pointed by *optval*.
16051605 *
16061606 * *bpf_socket* should be one of the following:
1607+ *
16071608 * * **struct bpf_sock_ops** for **BPF_PROG_TYPE_SOCK_OPS**.
16081609 * * **struct bpf_sock_addr** for **BPF_CGROUP_INET4_CONNECT**
16091610 * and **BPF_CGROUP_INET6_CONNECT**.
@@ -1672,12 +1673,12 @@ union bpf_attr { · 62 unmodified lines
16721673 *
16731674 * The lower two bits of *flags* are used as the return code if
16741675 * the map lookup fails. This is so that the return value can be
1675− * one of the XDP program return codes up to XDP_TX, as chosen by
1676− * the caller. Any higher bits in the *flags* argument must be
1676+ * one of the XDP program return codes up to **XDP_TX**, as chosen
1677+ * by the caller. Any higher bits in the *flags* argument must be
16771678 * unset.
16781679 *
1679− * See also bpf_redirect(), which only supports redirecting to an
1680− * ifindex, but doesn't require a map to do so.
1680+ * See also **bpf_redirect**\ (), which only supports redirecting
1681+ * to an ifindex, but doesn't require a map to do so.
16811682 * Return
16821683 * **XDP_REDIRECT** on success, or the value of the two lower bits
16831684 * of the *flags* argument on error.
@@ -1785,7 +1786,7 @@ union bpf_attr { · 101 unmodified lines
17851786 * the time running for event since last normalization. The
17861787 * enabled and running times are accumulated since the perf event
17871788 * open. To achieve scaling factor between two invocations of an
1788− * eBPF program, users can can use CPU id as the key (which is
1789+ * eBPF program, users can use CPU id as the key (which is
17891790 * typical for perf array usage model) to remember the previous
17901791 * value and do the calculation inside the eBPF program.
17911792 * Return
@@ -1812,6 +1813,7 @@ union bpf_attr { · 20 unmodified lines
18121813 * *opval* and of length *optlen*.
18131814 *
18141815 * *bpf_socket* should be one of the following:
1816+ *
18151817 * * **struct bpf_sock_ops** for **BPF_PROG_TYPE_SOCK_OPS**.
18161818 * * **struct bpf_sock_addr** for **BPF_CGROUP_INET4_CONNECT**
18171819 * and **BPF_CGROUP_INET6_CONNECT**.
@@ -1833,7 +1835,7 @@ union bpf_attr { · 15 unmodified lines
18331835 * The first argument is the context *regs* on which the kprobe
18341836 * works.
18351837 *
1836− * This helper works by setting setting the PC (program counter)
1838+ * This helper works by setting the PC (program counter)
18371839 * to an override function which is run in place of the original
18381840 * probed function. This means the probed function is not run at
18391841 * all. The replacement function just returns with the required
@@ -2300,7 +2302,7 @@ union bpf_attr { · 460 unmodified lines
23002302 * **bpf_rc_keydown**\ () again with the same values, or calling
23012303 * **bpf_rc_repeat**\ ().
23022304 *
2303− * Some protocols include a toggle bit, in case the button was
2305+ * Some protocols include a toggle bit, in case the button was
23042306 * released and pressed again between consecutive scancodes.
23052307 *
23062308 * The *ctx* should point to the lirc sample as passed into
@@ -2646,7 +2648,6 @@ union bpf_attr { · 339 unmodified lines
26462648 *
26472649 * *th* points to the start of the TCP header, while *th_len*
26482650 * contains **sizeof**\ (**struct tcphdr**).
2649− *
26502651 * Return
26512652 * 0 if *iph* and *th* are a valid SYN cookie ACK, or a negative
26522653 * error otherwise.
@@ -2829,7 +2830,6 @@ union bpf_attr { · 176 unmodified lines
28292830 *
28302831 * *th* points to the start of the TCP header, while *th_len*
28312832 * contains the length of the TCP header.
2832− *
28332833 * Return
28342834 * On success, lower 32 bits hold the generated SYN cookie in
28352835 * followed by 16 bits which hold the MSS value for that cookie,
@@ -2912,7 +2912,7 @@ union bpf_attr { · 76 unmodified lines
29122912 * // size, after checking its boundaries.
29132913 * }
29142914 *
2915− * In comparison, using **bpf_probe_read_user()** helper here
2915+ * In comparison, using **bpf_probe_read_user**\ () helper here
29162916 * instead to read the string would require to estimate the length
29172917 * at compile time, and would often result in copying more memory
29182918 * than necessary.
@@ -2930,14 +2930,14 @@ union bpf_attr { · 11 unmodified lines
29302930 * int bpf_probe_read_kernel_str(void *dst, u32 size, const void *unsafe_ptr)
29312931 * Description
29322932 * Copy a NUL terminated string from an unsafe kernel address *unsafe_ptr*
2933− * to *dst*. Same semantics as with bpf_probe_read_user_str() apply.
2933+ * to *dst*. Same semantics as with **bpf_probe_read_user_str**\ () apply.
29342934 * Return
2935− * On success, the strictly positive length of the string, including
2935+ * On success, the strictly positive length of the string, including
29362936 * the trailing NUL character. On error, a negative value.
29372937 *
29382938 * int bpf_tcp_send_ack(void *tp, u32 rcv_nxt)
29392939 * Description
2940− * Send out a tcp-ack. *tp* is the in-kernel struct tcp_sock.
2940+ * Send out a tcp-ack. *tp* is the in-kernel struct **tcp_sock**.
29412941 * *rcv_nxt* is the ack_seq to be sent out.
29422942 * Return
29432943 * 0 on success, or a negative error in case of failure.
@@ -2965,19 +2965,19 @@ union bpf_attr { · 21 unmodified lines
29652965 * int bpf_read_branch_records(struct bpf_perf_event_data *ctx, void *buf, u32 size, u64 flags)
29662966 * Description
29672967 * For an eBPF program attached to a perf event, retrieve the
2968− * branch records (struct perf_branch_entry) associated to *ctx*
2969− * and store it in the buffer pointed by *buf* up to size
2968+ * branch records (**struct perf_branch_entry**) associated to *ctx*
2969+ * and store it in the buffer pointed by *buf* up to size
29702970 * *size* bytes.
29712971 * Return
29722972 * On success, number of bytes written to *buf*. On error, a
29732973 * negative value.
29742974 *
29752975 * The *flags* can be set to **BPF_F_GET_BRANCH_RECORDS_SIZE** to
2976− * instead return the number of bytes required to store all the
2976+ * instead return the number of bytes required to store all the
29772977 * branch entries. If this flag is set, *buf* may be NULL.
29782978 *
29792979 * **-EINVAL** if arguments invalid or **size** not a multiple
2980− * of sizeof(struct perf_branch_entry).
2980+ * of **sizeof**\ (**struct perf_branch_entry**\ ).
29812981 *
29822982 * **-ENOENT** if architecture does not support branch records.
29832983 *
@@ -2985,8 +2985,8 @@ union bpf_attr { · 1 unmodified line
29852985 * Description
29862986 * Returns 0 on success, values for *pid* and *tgid* as seen from the current
29872987 * *namespace* will be returned in *nsdata*.
2988− *
2989− * On failure, the returned value is one of the following:
2988+ * Return
2989+ * 0 on success, or one of the following in case of failure:
29902990 *
29912991 * **-EINVAL** if dev and inum supplied don't match dev_t and inode number
29922992 * with nsfs of current task, or if dev conversion to dev_t lost high bits.
@@ -3025,8 +3025,8 @@ union bpf_attr { · 32 unmodified lines
30253025 * a global identifier that can be assumed unique. If *ctx* is
30263026 * NULL, then the helper returns the cookie for the initial
30273027 * network namespace. The cookie itself is very similar to that
3028− * of bpf_get_socket_cookie() helper, but for network namespaces
3029− * instead of sockets.
3028+ * of **bpf_get_socket_cookie**\ () helper, but for network
3029+ * namespaces instead of sockets.
30303030 * Return
30313031 * A 8-byte long opaque number.
30323032 *
@@ -3061,57 +3061,66 @@ union bpf_attr { · 28 unmodified lines
30613061 *
30623062 * The *flags* argument must be zero.
30633063 * Return
3064− * 0 on success, or a negative errno in case of failure.
3064+ * 0 on success, or a negative error in case of failure:
30653065 *
3066− * * **-EINVAL** Unsupported flags specified.
3067− * * **-ENOENT** Socket is unavailable for assignment.
3068− * * **-ENETUNREACH** Socket is unreachable (wrong netns).
3069− * * **-EOPNOTSUPP** Unsupported operation, for example a
3070− * call from outside of TC ingress.
3071− * * **-ESOCKTNOSUPPORT** Socket type not supported (reuseport).
3066+ * **-EINVAL** if specified *flags* are not supported.
3067+ *
3068+ * **-ENOENT** if the socket is unavailable for assignment.
3069+ *
3070+ * **-ENETUNREACH** if the socket is unreachable (wrong netns).
3071+ *
3072+ * **-EOPNOTSUPP** if the operation is not supported, for example
3073+ * a call from outside of TC ingress.
3074+ *
3075+ * **-ESOCKTNOSUPPORT** if the socket type is not supported
3076+ * (reuseport).
30723077 *
30733078 * u64 bpf_ktime_get_boot_ns(void)
30743079 * Description
30753080 * Return the time elapsed since system boot, in nanoseconds.
30763081 * Does include the time the system was suspended.
3077− * See: clock_gettime(CLOCK_BOOTTIME)
3082+ * See: **clock_gettime**\ (**CLOCK_BOOTTIME**)
30783083 * Return
30793084 * Current *ktime*.
30803085 *
30813086 * int bpf_seq_printf(struct seq_file *m, const char *fmt, u32 fmt_size, const void *data, u32 data_len)
30823087 * Description
3083− * seq_printf uses seq_file seq_printf() to print out the format string.
3088+ * **bpf_seq_printf**\ () uses seq_file **seq_printf**\ () to print
3089+ * out the format string.
30843090 * The *m* represents the seq_file. The *fmt* and *fmt_size* are for
30853091 * the format string itself. The *data* and *data_len* are format string
3086− * arguments. The *data* are a u64 array and corresponding format string
3092+ * arguments. The *data* are a **u64** array and corresponding format string
30873093 * values are stored in the array. For strings and pointers where pointees
30883094 * are accessed, only the pointer values are stored in the *data* array.
3089− * The *data_len* is the *data* size in term of bytes.
3095+ * The *data_len* is the size of *data* in bytes.
30903096 *
30913097 * Formats **%s**, **%p{i,I}{4,6}** requires to read kernel memory.
30923098 * Reading kernel memory may fail due to either invalid address or
30933099 * valid address but requiring a major memory fault. If reading kernel memory
30943100 * fails, the string for **%s** will be an empty string, and the ip
30953101 * address for **%p{i,I}{4,6}** will be 0. Not returning error to
3096− * bpf program is consistent with what bpf_trace_printk() does for now.
3102+ * bpf program is consistent with what **bpf_trace_printk**\ () does for now.
30973103 * Return
3098− * 0 on success, or a negative errno in case of failure.
3104+ * 0 on success, or a negative error in case of failure:
3105+ *
3106+ * **-EBUSY** if per-CPU memory copy buffer is busy, can try again
3107+ * by returning 1 from bpf program.
3108+ *
3109+ * **-EINVAL** if arguments are invalid, or if *fmt* is invalid/unsupported.
3110+ *
3111+ * **-E2BIG** if *fmt* contains too many format specifiers.
30993112 *
3100− * * **-EBUSY** Percpu memory copy buffer is busy, can try again
3101− * by returning 1 from bpf program.
3102− * * **-EINVAL** Invalid arguments, or invalid/unsupported formats.
3103− * * **-E2BIG** Too many format specifiers.
3104− * * **-EOVERFLOW** Overflow happens, the same object will be tried again.
3113+ * **-EOVERFLOW** if an overflow happened: The same object will be tried again.
31053114 *
31063115 * int bpf_seq_write(struct seq_file *m, const void *data, u32 len)
31073116 * Description
3108− * seq_write uses seq_file seq_write() to write the data.
3117+ * **bpf_seq_write**\ () uses seq_file **seq_write**\ () to write the data.
31093118 * The *m* represents the seq_file. The *data* and *len* represent the
3110− * data to write in bytes.
3119+ * data to write in bytes.
31113120 * Return
3112− * 0 on success, or a negative errno in case of failure.
3121+ * 0 on success, or a negative error in case of failure:
31133122 *
3114− * * **-EOVERFLOW** Overflow happens, the same object will be tried again.
3123+ * **-EOVERFLOW** if an overflow happened: The same object will be tried again.
31153124 */
31163125 #define __BPF_FUNC_MAPPER(FN) \
31173126 FN(unspec), \