Helper function bpf_strtol
Definition
Copyright (c) 2015 The Libbpf Authors. All rights reserved.
Convert the initial part of the string from buffer buf of size buf_len to a long integer according to the given base and save the result in res.
The string may begin with an arbitrary amount of white space (as determined by isspace(3)) followed by a single optional '-' sign.
Five least significant bits of flags encode base, other bits are currently unused.
Base must be either 8, 10, 16 or 0 to detect it automatically similar to user space strtol(3).
Returns
Number of characters consumed on success. Must be positive but no more than buf_len.
-EINVAL if no valid digits were found or unsupported base was provided.
-ERANGE if resulting value was out of range.
static long (* const bpf_strtol)(const char *buf, unsigned long buf_len, __u64 flags, long *res) = (void *) 105;
Usage
Docs could be improved
This part of the docs is incomplete, contributions are very welcome
Program types
This helper call can be used in the following program types:
BPF_PROG_TYPE_CGROUP_DEVICEv6.1BPF_PROG_TYPE_CGROUP_SKBv6.1BPF_PROG_TYPE_CGROUP_SOCKv6.1BPF_PROG_TYPE_CGROUP_SOCKOPTv6.1BPF_PROG_TYPE_CGROUP_SOCK_ADDRv6.1BPF_PROG_TYPE_CGROUP_SYSCTLBPF_PROG_TYPE_FLOW_DISSECTORv6.1BPF_PROG_TYPE_KPROBEv6.1BPF_PROG_TYPE_LSMv6.1BPF_PROG_TYPE_LWT_INv6.1BPF_PROG_TYPE_LWT_OUTv6.1BPF_PROG_TYPE_LWT_SEG6LOCALv6.1BPF_PROG_TYPE_LWT_XMITv6.1BPF_PROG_TYPE_NETFILTERv6.1BPF_PROG_TYPE_PERF_EVENTv6.1BPF_PROG_TYPE_RAW_TRACEPOINTv6.1BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLEv6.1BPF_PROG_TYPE_SCHED_ACTv6.1BPF_PROG_TYPE_SCHED_CLSv6.1BPF_PROG_TYPE_SK_LOOKUPv6.1BPF_PROG_TYPE_SK_MSGv6.1BPF_PROG_TYPE_SK_REUSEPORTv6.1BPF_PROG_TYPE_SK_SKBv6.1BPF_PROG_TYPE_SOCKET_FILTERv6.1BPF_PROG_TYPE_SOCK_OPSv6.1BPF_PROG_TYPE_STRUCT_OPSv6.1BPF_PROG_TYPE_SYSCALLv6.1BPF_PROG_TYPE_TRACEPOINTv6.1BPF_PROG_TYPE_TRACINGv6.1BPF_PROG_TYPE_XDPv6.1
Example
Docs could be improved
This part of the docs is incomplete, contributions are very welcome