Skip to content

Commit b457e55

Browse files
rdnaAlexei Starovoitov
authored andcommitted
bpf: Sync bpf.h to tools/
Sync bpf_strtoX related bpf UAPI changes to tools/. Signed-off-by: Andrey Ignatov <rdna@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent d7a4cb9 commit b457e55

1 file changed

Lines changed: 50 additions & 1 deletion

File tree

  • tools/include/uapi/linux

‎tools/include/uapi/linux/bpf.h‎

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2575,6 +2575,53 @@ union bpf_attr {
25752575
* **-E2BIG** if the *buf_len* is too big.
25762576
*
25772577
* **-EINVAL** if sysctl is being read.
2578+
*
2579+
* int bpf_strtol(const char *buf, size_t buf_len, u64 flags, long *res)
2580+
* Description
2581+
* Convert the initial part of the string from buffer *buf* of
2582+
* size *buf_len* to a long integer according to the given base
2583+
* and save the result in *res*.
2584+
*
2585+
* The string may begin with an arbitrary amount of white space
2586+
* (as determined by isspace(3)) followed by a single optional '-'
2587+
* sign.
2588+
*
2589+
* Five least significant bits of *flags* encode base, other bits
2590+
* are currently unused.
2591+
*
2592+
* Base must be either 8, 10, 16 or 0 to detect it automatically
2593+
* similar to user space strtol(3).
2594+
* Return
2595+
* Number of characters consumed on success. Must be positive but
2596+
* no more than buf_len.
2597+
*
2598+
* **-EINVAL** if no valid digits were found or unsupported base
2599+
* was provided.
2600+
*
2601+
* **-ERANGE** if resulting value was out of range.
2602+
*
2603+
* int bpf_strtoul(const char *buf, size_t buf_len, u64 flags, unsigned long *res)
2604+
* Description
2605+
* Convert the initial part of the string from buffer *buf* of
2606+
* size *buf_len* to an unsigned long integer according to the
2607+
* given base and save the result in *res*.
2608+
*
2609+
* The string may begin with an arbitrary amount of white space
2610+
* (as determined by isspace(3)).
2611+
*
2612+
* Five least significant bits of *flags* encode base, other bits
2613+
* are currently unused.
2614+
*
2615+
* Base must be either 8, 10, 16 or 0 to detect it automatically
2616+
* similar to user space strtoul(3).
2617+
* Return
2618+
* Number of characters consumed on success. Must be positive but
2619+
* no more than buf_len.
2620+
*
2621+
* **-EINVAL** if no valid digits were found or unsupported base
2622+
* was provided.
2623+
*
2624+
* **-ERANGE** if resulting value was out of range.
25782625
*/
25792626
#define __BPF_FUNC_MAPPER(FN) \
25802627
FN(unspec), \
@@ -2681,7 +2728,9 @@ union bpf_attr {
26812728
FN(sysctl_get_name), \
26822729
FN(sysctl_get_current_value), \
26832730
FN(sysctl_get_new_value), \
2684-
FN(sysctl_set_new_value),
2731+
FN(sysctl_set_new_value), \
2732+
FN(strtol), \
2733+
FN(strtoul),
26852734

26862735
/* integer value in 'imm' field of BPF_CALL instruction selects which helper
26872736
* function eBPF program intends to call

0 commit comments

Comments
 (0)