Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next
Daniel Borkmann says: ==================== pull-request: bpf-next 2020-10-01 The following pull-request contains BPF updates for your *net-next* tree. We've added 90 non-merge commits during the last 8 day(s) which contain a total of 103 files changed, 7662 insertions(+), 1894 deletions(-). Note that once bpf(/net) tree gets merged into net-next, there will be a small merge conflict in tools/lib/bpf/btf.c between commit1245008122("libbpf: Fix native endian assumption when parsing BTF") from the bpf tree and the commit3289959b97("libbpf: Support BTF loading and raw data output in both endianness") from the bpf-next tree. Correct resolution would be to stick with bpf-next, it should look like: [...] /* check BTF magic */ if (fread(&magic, 1, sizeof(magic), f) < sizeof(magic)) { err = -EIO; goto err_out; } if (magic != BTF_MAGIC && magic != bswap_16(BTF_MAGIC)) { /* definitely not a raw BTF */ err = -EPROTO; goto err_out; } /* get file size */ [...] The main changes are: 1) Add bpf_snprintf_btf() and bpf_seq_printf_btf() helpers to support displaying BTF-based kernel data structures out of BPF programs, from Alan Maguire. 2) Speed up RCU tasks trace grace periods by a factor of 50 & fix a few race conditions exposed by it. It was discussed to take these via BPF and networking tree to get better testing exposure, from Paul E. McKenney. 3) Support multi-attach for freplace programs, needed for incremental attachment of multiple XDP progs using libxdp dispatcher model, from Toke Høiland-Jørgensen. 4) libbpf support for appending new BTF types at the end of BTF object, allowing intrusive changes of prog's BTF (useful for future linking), from Andrii Nakryiko. 5) Several BPF helper improvements e.g. avoid atomic op in cookie generator and add a redirect helper into neighboring subsys, from Daniel Borkmann. 6) Allow map updates on sockmaps from bpf_iter context in order to migrate sockmaps from one to another, from Lorenz Bauer. 7) Fix 32 bit to 64 bit assignment from latest alu32 bounds tracking which caused a verifier issue due to type downgrade to scalar, from John Fastabend. 8) Follow-up on tail-call support in BPF subprogs which optimizes x64 JIT prologue and epilogue sections, from Maciej Fijalkowski. 9) Add an option to perf RB map to improve sharing of event entries by avoiding remove- on-close behavior. Also, add BPF_PROG_TEST_RUN for raw_tracepoint, from Song Liu. 10) Fix a crash in AF_XDP's socket_release when memory allocation for UMEMs fails, from Magnus Karlsson. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
@@ -414,6 +414,9 @@ enum {
|
||||
|
||||
/* Enable memory-mapping BPF map */
|
||||
BPF_F_MMAPABLE = (1U << 10),
|
||||
|
||||
/* Share perf_event among processes */
|
||||
BPF_F_PRESERVE_ELEMS = (1U << 11),
|
||||
};
|
||||
|
||||
/* Flags for BPF_PROG_QUERY. */
|
||||
@@ -424,6 +427,11 @@ enum {
|
||||
*/
|
||||
#define BPF_F_QUERY_EFFECTIVE (1U << 0)
|
||||
|
||||
/* Flags for BPF_PROG_TEST_RUN */
|
||||
|
||||
/* If set, run the test on the cpu specified by bpf_attr.test.cpu */
|
||||
#define BPF_F_TEST_RUN_ON_CPU (1U << 0)
|
||||
|
||||
/* type for BPF_ENABLE_STATS */
|
||||
enum bpf_stats_type {
|
||||
/* enabled run_time_ns and run_cnt */
|
||||
@@ -566,6 +574,8 @@ union bpf_attr {
|
||||
*/
|
||||
__aligned_u64 ctx_in;
|
||||
__aligned_u64 ctx_out;
|
||||
__u32 flags;
|
||||
__u32 cpu;
|
||||
} test;
|
||||
|
||||
struct { /* anonymous struct used by BPF_*_GET_*_ID */
|
||||
@@ -632,8 +642,13 @@ union bpf_attr {
|
||||
};
|
||||
__u32 attach_type; /* attach type */
|
||||
__u32 flags; /* extra flags */
|
||||
__aligned_u64 iter_info; /* extra bpf_iter_link_info */
|
||||
__u32 iter_info_len; /* iter_info length */
|
||||
union {
|
||||
__u32 target_btf_id; /* btf_id of target to attach to */
|
||||
struct {
|
||||
__aligned_u64 iter_info; /* extra bpf_iter_link_info */
|
||||
__u32 iter_info_len; /* iter_info length */
|
||||
};
|
||||
};
|
||||
} link_create;
|
||||
|
||||
struct { /* struct used by BPF_LINK_UPDATE command */
|
||||
@@ -2512,7 +2527,7 @@ union bpf_attr {
|
||||
* result is from *reuse*\ **->socks**\ [] using the hash of the
|
||||
* tuple.
|
||||
*
|
||||
* long bpf_sk_release(struct bpf_sock *sock)
|
||||
* long bpf_sk_release(void *sock)
|
||||
* Description
|
||||
* Release the reference held by *sock*. *sock* must be a
|
||||
* non-**NULL** pointer that was returned from
|
||||
@@ -2692,7 +2707,7 @@ union bpf_attr {
|
||||
* result is from *reuse*\ **->socks**\ [] using the hash of the
|
||||
* tuple.
|
||||
*
|
||||
* long bpf_tcp_check_syncookie(struct bpf_sock *sk, void *iph, u32 iph_len, struct tcphdr *th, u32 th_len)
|
||||
* long bpf_tcp_check_syncookie(void *sk, void *iph, u32 iph_len, struct tcphdr *th, u32 th_len)
|
||||
* Description
|
||||
* Check whether *iph* and *th* contain a valid SYN cookie ACK for
|
||||
* the listening socket in *sk*.
|
||||
@@ -2861,6 +2876,7 @@ union bpf_attr {
|
||||
* 0 on success.
|
||||
*
|
||||
* **-ENOENT** if the bpf-local-storage cannot be found.
|
||||
* **-EINVAL** if sk is not a fullsock (e.g. a request_sock).
|
||||
*
|
||||
* long bpf_send_signal(u32 sig)
|
||||
* Description
|
||||
@@ -2877,7 +2893,7 @@ union bpf_attr {
|
||||
*
|
||||
* **-EAGAIN** if bpf program can try again.
|
||||
*
|
||||
* s64 bpf_tcp_gen_syncookie(struct bpf_sock *sk, void *iph, u32 iph_len, struct tcphdr *th, u32 th_len)
|
||||
* s64 bpf_tcp_gen_syncookie(void *sk, void *iph, u32 iph_len, struct tcphdr *th, u32 th_len)
|
||||
* Description
|
||||
* Try to issue a SYN cookie for the packet with corresponding
|
||||
* IP/TCP headers, *iph* and *th*, on the listening socket in *sk*.
|
||||
@@ -3106,7 +3122,7 @@ union bpf_attr {
|
||||
* Return
|
||||
* The id is returned or 0 in case the id could not be retrieved.
|
||||
*
|
||||
* long bpf_sk_assign(struct sk_buff *skb, struct bpf_sock *sk, u64 flags)
|
||||
* long bpf_sk_assign(struct sk_buff *skb, void *sk, u64 flags)
|
||||
* Description
|
||||
* Helper is overloaded depending on BPF program type. This
|
||||
* description applies to **BPF_PROG_TYPE_SCHED_CLS** and
|
||||
@@ -3234,11 +3250,11 @@ union bpf_attr {
|
||||
*
|
||||
* **-EOVERFLOW** if an overflow happened: The same object will be tried again.
|
||||
*
|
||||
* u64 bpf_sk_cgroup_id(struct bpf_sock *sk)
|
||||
* u64 bpf_sk_cgroup_id(void *sk)
|
||||
* Description
|
||||
* Return the cgroup v2 id of the socket *sk*.
|
||||
*
|
||||
* *sk* must be a non-**NULL** pointer to a full socket, e.g. one
|
||||
* *sk* must be a non-**NULL** pointer to a socket, e.g. one
|
||||
* returned from **bpf_sk_lookup_xxx**\ (),
|
||||
* **bpf_sk_fullsock**\ (), etc. The format of returned id is
|
||||
* same as in **bpf_skb_cgroup_id**\ ().
|
||||
@@ -3248,7 +3264,7 @@ union bpf_attr {
|
||||
* Return
|
||||
* The id is returned or 0 in case the id could not be retrieved.
|
||||
*
|
||||
* u64 bpf_sk_ancestor_cgroup_id(struct bpf_sock *sk, int ancestor_level)
|
||||
* u64 bpf_sk_ancestor_cgroup_id(void *sk, int ancestor_level)
|
||||
* Description
|
||||
* Return id of cgroup v2 that is ancestor of cgroup associated
|
||||
* with the *sk* at the *ancestor_level*. The root cgroup is at
|
||||
@@ -3586,6 +3602,72 @@ union bpf_attr {
|
||||
* the data in *dst*. This is a wrapper of **copy_from_user**\ ().
|
||||
* Return
|
||||
* 0 on success, or a negative error in case of failure.
|
||||
*
|
||||
* long bpf_snprintf_btf(char *str, u32 str_size, struct btf_ptr *ptr, u32 btf_ptr_size, u64 flags)
|
||||
* Description
|
||||
* Use BTF to store a string representation of *ptr*->ptr in *str*,
|
||||
* using *ptr*->type_id. This value should specify the type
|
||||
* that *ptr*->ptr points to. LLVM __builtin_btf_type_id(type, 1)
|
||||
* can be used to look up vmlinux BTF type ids. Traversing the
|
||||
* data structure using BTF, the type information and values are
|
||||
* stored in the first *str_size* - 1 bytes of *str*. Safe copy of
|
||||
* the pointer data is carried out to avoid kernel crashes during
|
||||
* operation. Smaller types can use string space on the stack;
|
||||
* larger programs can use map data to store the string
|
||||
* representation.
|
||||
*
|
||||
* The string can be subsequently shared with userspace via
|
||||
* bpf_perf_event_output() or ring buffer interfaces.
|
||||
* bpf_trace_printk() is to be avoided as it places too small
|
||||
* a limit on string size to be useful.
|
||||
*
|
||||
* *flags* is a combination of
|
||||
*
|
||||
* **BTF_F_COMPACT**
|
||||
* no formatting around type information
|
||||
* **BTF_F_NONAME**
|
||||
* no struct/union member names/types
|
||||
* **BTF_F_PTR_RAW**
|
||||
* show raw (unobfuscated) pointer values;
|
||||
* equivalent to printk specifier %px.
|
||||
* **BTF_F_ZERO**
|
||||
* show zero-valued struct/union members; they
|
||||
* are not displayed by default
|
||||
*
|
||||
* Return
|
||||
* The number of bytes that were written (or would have been
|
||||
* written if output had to be truncated due to string size),
|
||||
* or a negative error in cases of failure.
|
||||
*
|
||||
* long bpf_seq_printf_btf(struct seq_file *m, struct btf_ptr *ptr, u32 ptr_size, u64 flags)
|
||||
* Description
|
||||
* Use BTF to write to seq_write a string representation of
|
||||
* *ptr*->ptr, using *ptr*->type_id as per bpf_snprintf_btf().
|
||||
* *flags* are identical to those used for bpf_snprintf_btf.
|
||||
* Return
|
||||
* 0 on success or a negative error in case of failure.
|
||||
*
|
||||
* u64 bpf_skb_cgroup_classid(struct sk_buff *skb)
|
||||
* Description
|
||||
* See **bpf_get_cgroup_classid**\ () for the main description.
|
||||
* This helper differs from **bpf_get_cgroup_classid**\ () in that
|
||||
* the cgroup v1 net_cls class is retrieved only from the *skb*'s
|
||||
* associated socket instead of the current process.
|
||||
* Return
|
||||
* The id is returned or 0 in case the id could not be retrieved.
|
||||
*
|
||||
* long bpf_redirect_neigh(u32 ifindex, u64 flags)
|
||||
* Description
|
||||
* Redirect the packet to another net device of index *ifindex*
|
||||
* and fill in L2 addresses from neighboring subsystem. This helper
|
||||
* is somewhat similar to **bpf_redirect**\ (), except that it
|
||||
* fills in e.g. MAC addresses based on the L3 information from
|
||||
* the packet. This helper is supported for IPv4 and IPv6 protocols.
|
||||
* The *flags* argument is reserved and must be 0. The helper is
|
||||
* currently only supported for tc BPF program types.
|
||||
* Return
|
||||
* The helper returns **TC_ACT_REDIRECT** on success or
|
||||
* **TC_ACT_SHOT** on error.
|
||||
*/
|
||||
#define __BPF_FUNC_MAPPER(FN) \
|
||||
FN(unspec), \
|
||||
@@ -3737,6 +3819,10 @@ union bpf_attr {
|
||||
FN(inode_storage_delete), \
|
||||
FN(d_path), \
|
||||
FN(copy_from_user), \
|
||||
FN(snprintf_btf), \
|
||||
FN(seq_printf_btf), \
|
||||
FN(skb_cgroup_classid), \
|
||||
FN(redirect_neigh), \
|
||||
/* */
|
||||
|
||||
/* integer value in 'imm' field of BPF_CALL instruction selects which helper
|
||||
@@ -4845,4 +4931,34 @@ struct bpf_sk_lookup {
|
||||
__u32 local_port; /* Host byte order */
|
||||
};
|
||||
|
||||
/*
|
||||
* struct btf_ptr is used for typed pointer representation; the
|
||||
* type id is used to render the pointer data as the appropriate type
|
||||
* via the bpf_snprintf_btf() helper described above. A flags field -
|
||||
* potentially to specify additional details about the BTF pointer
|
||||
* (rather than its mode of display) - is included for future use.
|
||||
* Display flags - BTF_F_* - are passed to bpf_snprintf_btf separately.
|
||||
*/
|
||||
struct btf_ptr {
|
||||
void *ptr;
|
||||
__u32 type_id;
|
||||
__u32 flags; /* BTF ptr flags; unused at present. */
|
||||
};
|
||||
|
||||
/*
|
||||
* Flags to control bpf_snprintf_btf() behaviour.
|
||||
* - BTF_F_COMPACT: no formatting around type information
|
||||
* - BTF_F_NONAME: no struct/union member names/types
|
||||
* - BTF_F_PTR_RAW: show raw (unobfuscated) pointer values;
|
||||
* equivalent to %px.
|
||||
* - BTF_F_ZERO: show zero-valued struct/union members; they
|
||||
* are not displayed by default
|
||||
*/
|
||||
enum {
|
||||
BTF_F_COMPACT = (1ULL << 0),
|
||||
BTF_F_NONAME = (1ULL << 1),
|
||||
BTF_F_PTR_RAW = (1ULL << 2),
|
||||
BTF_F_ZERO = (1ULL << 3),
|
||||
};
|
||||
|
||||
#endif /* _UAPI__LINUX_BPF_H__ */
|
||||
|
||||
Reference in New Issue
Block a user