diff options
| author | David S. Miller <davem@davemloft.net> | 2018-05-24 22:20:51 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2018-05-24 22:20:51 -0400 |
| commit | 90fed9c94625718a3a10db7d1e8e4efe093bbf5f (patch) | |
| tree | 09b3bc9ea679316372b139338179a230105306dc /tools/include/uapi/linux | |
| parent | 49a473f5b5f54f33e0bd8618158d33f83153c921 (diff) | |
| parent | 10f678683e4026e43524b0492068a371d00fdeed (diff) | |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next
Alexei Starovoitov says:
====================
pull-request: bpf-next 2018-05-24
The following pull-request contains BPF updates for your *net-next* tree.
The main changes are:
1) Björn Töpel cleans up AF_XDP (removes rebind, explicit cache alignment from uapi, etc).
2) David Ahern adds mtu checks to bpf_ipv{4,6}_fib_lookup() helpers.
3) Jesper Dangaard Brouer adds bulking support to ndo_xdp_xmit.
4) Jiong Wang adds support for indirect and arithmetic shifts to NFP
5) Martin KaFai Lau cleans up BTF uapi and makes the btf_header extensible.
6) Mathieu Xhonneux adds an End.BPF action to seg6local with BPF helpers allowing
to edit/grow/shrink a SRH and apply on a packet generic SRv6 actions.
7) Sandipan Das adds support for bpf2bpf function calls in ppc64 JIT.
8) Yonghong Song adds BPF_TASK_FD_QUERY command for introspection of tracing events.
9) other misc fixes from Gustavo A. R. Silva, Sirio Balmelli, John Fastabend, and Magnus Karlsson
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/include/uapi/linux')
| -rw-r--r-- | tools/include/uapi/linux/bpf.h | 143 | ||||
| -rw-r--r-- | tools/include/uapi/linux/btf.h | 37 |
2 files changed, 149 insertions, 31 deletions
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index d94d333a8225..9b8c6e310e9a 100644 --- a/tools/include/uapi/linux/bpf.h +++ b/tools/include/uapi/linux/bpf.h | |||
| @@ -97,6 +97,7 @@ enum bpf_cmd { | |||
| 97 | BPF_RAW_TRACEPOINT_OPEN, | 97 | BPF_RAW_TRACEPOINT_OPEN, |
| 98 | BPF_BTF_LOAD, | 98 | BPF_BTF_LOAD, |
| 99 | BPF_BTF_GET_FD_BY_ID, | 99 | BPF_BTF_GET_FD_BY_ID, |
| 100 | BPF_TASK_FD_QUERY, | ||
| 100 | }; | 101 | }; |
| 101 | 102 | ||
| 102 | enum bpf_map_type { | 103 | enum bpf_map_type { |
| @@ -141,6 +142,7 @@ enum bpf_prog_type { | |||
| 141 | BPF_PROG_TYPE_SK_MSG, | 142 | BPF_PROG_TYPE_SK_MSG, |
| 142 | BPF_PROG_TYPE_RAW_TRACEPOINT, | 143 | BPF_PROG_TYPE_RAW_TRACEPOINT, |
| 143 | BPF_PROG_TYPE_CGROUP_SOCK_ADDR, | 144 | BPF_PROG_TYPE_CGROUP_SOCK_ADDR, |
| 145 | BPF_PROG_TYPE_LWT_SEG6LOCAL, | ||
| 144 | }; | 146 | }; |
| 145 | 147 | ||
| 146 | enum bpf_attach_type { | 148 | enum bpf_attach_type { |
| @@ -284,8 +286,8 @@ union bpf_attr { | |||
| 284 | char map_name[BPF_OBJ_NAME_LEN]; | 286 | char map_name[BPF_OBJ_NAME_LEN]; |
| 285 | __u32 map_ifindex; /* ifindex of netdev to create on */ | 287 | __u32 map_ifindex; /* ifindex of netdev to create on */ |
| 286 | __u32 btf_fd; /* fd pointing to a BTF type data */ | 288 | __u32 btf_fd; /* fd pointing to a BTF type data */ |
| 287 | __u32 btf_key_id; /* BTF type_id of the key */ | 289 | __u32 btf_key_type_id; /* BTF type_id of the key */ |
| 288 | __u32 btf_value_id; /* BTF type_id of the value */ | 290 | __u32 btf_value_type_id; /* BTF type_id of the value */ |
| 289 | }; | 291 | }; |
| 290 | 292 | ||
| 291 | struct { /* anonymous struct used by BPF_MAP_*_ELEM commands */ | 293 | struct { /* anonymous struct used by BPF_MAP_*_ELEM commands */ |
| @@ -379,6 +381,22 @@ union bpf_attr { | |||
| 379 | __u32 btf_log_size; | 381 | __u32 btf_log_size; |
| 380 | __u32 btf_log_level; | 382 | __u32 btf_log_level; |
| 381 | }; | 383 | }; |
| 384 | |||
| 385 | struct { | ||
| 386 | __u32 pid; /* input: pid */ | ||
| 387 | __u32 fd; /* input: fd */ | ||
| 388 | __u32 flags; /* input: flags */ | ||
| 389 | __u32 buf_len; /* input/output: buf len */ | ||
| 390 | __aligned_u64 buf; /* input/output: | ||
| 391 | * tp_name for tracepoint | ||
| 392 | * symbol for kprobe | ||
| 393 | * filename for uprobe | ||
| 394 | */ | ||
| 395 | __u32 prog_id; /* output: prod_id */ | ||
| 396 | __u32 fd_type; /* output: BPF_FD_TYPE_* */ | ||
| 397 | __u64 probe_offset; /* output: probe_offset */ | ||
| 398 | __u64 probe_addr; /* output: probe_addr */ | ||
| 399 | } task_fd_query; | ||
| 382 | } __attribute__((aligned(8))); | 400 | } __attribute__((aligned(8))); |
| 383 | 401 | ||
| 384 | /* The description below is an attempt at providing documentation to eBPF | 402 | /* The description below is an attempt at providing documentation to eBPF |
| @@ -1902,6 +1920,90 @@ union bpf_attr { | |||
| 1902 | * egress otherwise). This is the only flag supported for now. | 1920 | * egress otherwise). This is the only flag supported for now. |
| 1903 | * Return | 1921 | * Return |
| 1904 | * **SK_PASS** on success, or **SK_DROP** on error. | 1922 | * **SK_PASS** on success, or **SK_DROP** on error. |
| 1923 | * | ||
| 1924 | * int bpf_lwt_push_encap(struct sk_buff *skb, u32 type, void *hdr, u32 len) | ||
| 1925 | * Description | ||
| 1926 | * Encapsulate the packet associated to *skb* within a Layer 3 | ||
| 1927 | * protocol header. This header is provided in the buffer at | ||
| 1928 | * address *hdr*, with *len* its size in bytes. *type* indicates | ||
| 1929 | * the protocol of the header and can be one of: | ||
| 1930 | * | ||
| 1931 | * **BPF_LWT_ENCAP_SEG6** | ||
| 1932 | * IPv6 encapsulation with Segment Routing Header | ||
| 1933 | * (**struct ipv6_sr_hdr**). *hdr* only contains the SRH, | ||
| 1934 | * the IPv6 header is computed by the kernel. | ||
| 1935 | * **BPF_LWT_ENCAP_SEG6_INLINE** | ||
| 1936 | * Only works if *skb* contains an IPv6 packet. Insert a | ||
| 1937 | * Segment Routing Header (**struct ipv6_sr_hdr**) inside | ||
| 1938 | * the IPv6 header. | ||
| 1939 | * | ||
| 1940 | * A call to this helper is susceptible to change the underlaying | ||
| 1941 | * packet buffer. Therefore, at load time, all checks on pointers | ||
| 1942 | * previously done by the verifier are invalidated and must be | ||
| 1943 | * performed again, if the helper is used in combination with | ||
| 1944 | * direct packet access. | ||
| 1945 | * Return | ||
| 1946 | * 0 on success, or a negative error in case of failure. | ||
| 1947 | * | ||
| 1948 | * int bpf_lwt_seg6_store_bytes(struct sk_buff *skb, u32 offset, const void *from, u32 len) | ||
| 1949 | * Description | ||
| 1950 | * Store *len* bytes from address *from* into the packet | ||
| 1951 | * associated to *skb*, at *offset*. Only the flags, tag and TLVs | ||
| 1952 | * inside the outermost IPv6 Segment Routing Header can be | ||
| 1953 | * modified through this helper. | ||
| 1954 | * | ||
| 1955 | * A call to this helper is susceptible to change the underlaying | ||
| 1956 | * packet buffer. Therefore, at load time, all checks on pointers | ||
| 1957 | * previously done by the verifier are invalidated and must be | ||
| 1958 | * performed again, if the helper is used in combination with | ||
| 1959 | * direct packet access. | ||
| 1960 | * Return | ||
| 1961 | * 0 on success, or a negative error in case of failure. | ||
| 1962 | * | ||
| 1963 | * int bpf_lwt_seg6_adjust_srh(struct sk_buff *skb, u32 offset, s32 delta) | ||
| 1964 | * Description | ||
| 1965 | * Adjust the size allocated to TLVs in the outermost IPv6 | ||
| 1966 | * Segment Routing Header contained in the packet associated to | ||
| 1967 | * *skb*, at position *offset* by *delta* bytes. Only offsets | ||
| 1968 | * after the segments are accepted. *delta* can be as well | ||
| 1969 | * positive (growing) as negative (shrinking). | ||
| 1970 | * | ||
| 1971 | * A call to this helper is susceptible to change the underlaying | ||
| 1972 | * packet buffer. Therefore, at load time, all checks on pointers | ||
| 1973 | * previously done by the verifier are invalidated and must be | ||
| 1974 | * performed again, if the helper is used in combination with | ||
| 1975 | * direct packet access. | ||
| 1976 | * Return | ||
| 1977 | * 0 on success, or a negative error in case of failure. | ||
| 1978 | * | ||
| 1979 | * int bpf_lwt_seg6_action(struct sk_buff *skb, u32 action, void *param, u32 param_len) | ||
| 1980 | * Description | ||
| 1981 | * Apply an IPv6 Segment Routing action of type *action* to the | ||
| 1982 | * packet associated to *skb*. Each action takes a parameter | ||
| 1983 | * contained at address *param*, and of length *param_len* bytes. | ||
| 1984 | * *action* can be one of: | ||
| 1985 | * | ||
| 1986 | * **SEG6_LOCAL_ACTION_END_X** | ||
| 1987 | * End.X action: Endpoint with Layer-3 cross-connect. | ||
| 1988 | * Type of *param*: **struct in6_addr**. | ||
| 1989 | * **SEG6_LOCAL_ACTION_END_T** | ||
| 1990 | * End.T action: Endpoint with specific IPv6 table lookup. | ||
| 1991 | * Type of *param*: **int**. | ||
| 1992 | * **SEG6_LOCAL_ACTION_END_B6** | ||
| 1993 | * End.B6 action: Endpoint bound to an SRv6 policy. | ||
| 1994 | * Type of param: **struct ipv6_sr_hdr**. | ||
| 1995 | * **SEG6_LOCAL_ACTION_END_B6_ENCAP** | ||
| 1996 | * End.B6.Encap action: Endpoint bound to an SRv6 | ||
| 1997 | * encapsulation policy. | ||
| 1998 | * Type of param: **struct ipv6_sr_hdr**. | ||
| 1999 | * | ||
| 2000 | * A call to this helper is susceptible to change the underlaying | ||
| 2001 | * packet buffer. Therefore, at load time, all checks on pointers | ||
| 2002 | * previously done by the verifier are invalidated and must be | ||
| 2003 | * performed again, if the helper is used in combination with | ||
| 2004 | * direct packet access. | ||
| 2005 | * Return | ||
| 2006 | * 0 on success, or a negative error in case of failure. | ||
| 1905 | */ | 2007 | */ |
| 1906 | #define __BPF_FUNC_MAPPER(FN) \ | 2008 | #define __BPF_FUNC_MAPPER(FN) \ |
| 1907 | FN(unspec), \ | 2009 | FN(unspec), \ |
| @@ -1976,7 +2078,11 @@ union bpf_attr { | |||
| 1976 | FN(fib_lookup), \ | 2078 | FN(fib_lookup), \ |
| 1977 | FN(sock_hash_update), \ | 2079 | FN(sock_hash_update), \ |
| 1978 | FN(msg_redirect_hash), \ | 2080 | FN(msg_redirect_hash), \ |
| 1979 | FN(sk_redirect_hash), | 2081 | FN(sk_redirect_hash), \ |
| 2082 | FN(lwt_push_encap), \ | ||
| 2083 | FN(lwt_seg6_store_bytes), \ | ||
| 2084 | FN(lwt_seg6_adjust_srh), \ | ||
| 2085 | FN(lwt_seg6_action), | ||
| 1980 | 2086 | ||
| 1981 | /* integer value in 'imm' field of BPF_CALL instruction selects which helper | 2087 | /* integer value in 'imm' field of BPF_CALL instruction selects which helper |
| 1982 | * function eBPF program intends to call | 2088 | * function eBPF program intends to call |
| @@ -2043,6 +2149,12 @@ enum bpf_hdr_start_off { | |||
| 2043 | BPF_HDR_START_NET, | 2149 | BPF_HDR_START_NET, |
| 2044 | }; | 2150 | }; |
| 2045 | 2151 | ||
| 2152 | /* Encapsulation type for BPF_FUNC_lwt_push_encap helper. */ | ||
| 2153 | enum bpf_lwt_encap_mode { | ||
| 2154 | BPF_LWT_ENCAP_SEG6, | ||
| 2155 | BPF_LWT_ENCAP_SEG6_INLINE | ||
| 2156 | }; | ||
| 2157 | |||
| 2046 | /* user accessible mirror of in-kernel sk_buff. | 2158 | /* user accessible mirror of in-kernel sk_buff. |
| 2047 | * new fields can only be added to the end of this structure | 2159 | * new fields can only be added to the end of this structure |
| 2048 | */ | 2160 | */ |
| @@ -2176,6 +2288,14 @@ enum sk_action { | |||
| 2176 | struct sk_msg_md { | 2288 | struct sk_msg_md { |
| 2177 | void *data; | 2289 | void *data; |
| 2178 | void *data_end; | 2290 | void *data_end; |
| 2291 | |||
| 2292 | __u32 family; | ||
| 2293 | __u32 remote_ip4; /* Stored in network byte order */ | ||
| 2294 | __u32 local_ip4; /* Stored in network byte order */ | ||
| 2295 | __u32 remote_ip6[4]; /* Stored in network byte order */ | ||
| 2296 | __u32 local_ip6[4]; /* Stored in network byte order */ | ||
| 2297 | __u32 remote_port; /* Stored in network byte order */ | ||
| 2298 | __u32 local_port; /* stored in host byte order */ | ||
| 2179 | }; | 2299 | }; |
| 2180 | 2300 | ||
| 2181 | #define BPF_TAG_SIZE 8 | 2301 | #define BPF_TAG_SIZE 8 |
| @@ -2197,6 +2317,10 @@ struct bpf_prog_info { | |||
| 2197 | __u32 gpl_compatible:1; | 2317 | __u32 gpl_compatible:1; |
| 2198 | __u64 netns_dev; | 2318 | __u64 netns_dev; |
| 2199 | __u64 netns_ino; | 2319 | __u64 netns_ino; |
| 2320 | __u32 nr_jited_ksyms; | ||
| 2321 | __u32 nr_jited_func_lens; | ||
| 2322 | __aligned_u64 jited_ksyms; | ||
| 2323 | __aligned_u64 jited_func_lens; | ||
| 2200 | } __attribute__((aligned(8))); | 2324 | } __attribute__((aligned(8))); |
| 2201 | 2325 | ||
| 2202 | struct bpf_map_info { | 2326 | struct bpf_map_info { |
| @@ -2211,8 +2335,8 @@ struct bpf_map_info { | |||
| 2211 | __u64 netns_dev; | 2335 | __u64 netns_dev; |
| 2212 | __u64 netns_ino; | 2336 | __u64 netns_ino; |
| 2213 | __u32 btf_id; | 2337 | __u32 btf_id; |
| 2214 | __u32 btf_key_id; | 2338 | __u32 btf_key_type_id; |
| 2215 | __u32 btf_value_id; | 2339 | __u32 btf_value_type_id; |
| 2216 | } __attribute__((aligned(8))); | 2340 | } __attribute__((aligned(8))); |
| 2217 | 2341 | ||
| 2218 | struct bpf_btf_info { | 2342 | struct bpf_btf_info { |
| @@ -2450,4 +2574,13 @@ struct bpf_fib_lookup { | |||
| 2450 | __u8 dmac[6]; /* ETH_ALEN */ | 2574 | __u8 dmac[6]; /* ETH_ALEN */ |
| 2451 | }; | 2575 | }; |
| 2452 | 2576 | ||
| 2577 | enum bpf_task_fd_type { | ||
| 2578 | BPF_FD_TYPE_RAW_TRACEPOINT, /* tp name */ | ||
| 2579 | BPF_FD_TYPE_TRACEPOINT, /* tp name */ | ||
| 2580 | BPF_FD_TYPE_KPROBE, /* (symbol + offset) or addr */ | ||
| 2581 | BPF_FD_TYPE_KRETPROBE, /* (symbol + offset) or addr */ | ||
| 2582 | BPF_FD_TYPE_UPROBE, /* filename + offset */ | ||
| 2583 | BPF_FD_TYPE_URETPROBE, /* filename + offset */ | ||
| 2584 | }; | ||
| 2585 | |||
| 2453 | #endif /* _UAPI__LINUX_BPF_H__ */ | 2586 | #endif /* _UAPI__LINUX_BPF_H__ */ |
diff --git a/tools/include/uapi/linux/btf.h b/tools/include/uapi/linux/btf.h index bcb56ee47014..0b5ddbe135a4 100644 --- a/tools/include/uapi/linux/btf.h +++ b/tools/include/uapi/linux/btf.h | |||
| @@ -12,42 +12,29 @@ struct btf_header { | |||
| 12 | __u16 magic; | 12 | __u16 magic; |
| 13 | __u8 version; | 13 | __u8 version; |
| 14 | __u8 flags; | 14 | __u8 flags; |
| 15 | 15 | __u32 hdr_len; | |
| 16 | __u32 parent_label; | ||
| 17 | __u32 parent_name; | ||
| 18 | 16 | ||
| 19 | /* All offsets are in bytes relative to the end of this header */ | 17 | /* All offsets are in bytes relative to the end of this header */ |
| 20 | __u32 label_off; /* offset of label section */ | ||
| 21 | __u32 object_off; /* offset of data object section*/ | ||
| 22 | __u32 func_off; /* offset of function section */ | ||
| 23 | __u32 type_off; /* offset of type section */ | 18 | __u32 type_off; /* offset of type section */ |
| 19 | __u32 type_len; /* length of type section */ | ||
| 24 | __u32 str_off; /* offset of string section */ | 20 | __u32 str_off; /* offset of string section */ |
| 25 | __u32 str_len; /* length of string section */ | 21 | __u32 str_len; /* length of string section */ |
| 26 | }; | 22 | }; |
| 27 | 23 | ||
| 28 | /* Max # of type identifier */ | 24 | /* Max # of type identifier */ |
| 29 | #define BTF_MAX_TYPE 0x7fffffff | 25 | #define BTF_MAX_TYPE 0x0000ffff |
| 30 | /* Max offset into the string section */ | 26 | /* Max offset into the string section */ |
| 31 | #define BTF_MAX_NAME_OFFSET 0x7fffffff | 27 | #define BTF_MAX_NAME_OFFSET 0x0000ffff |
| 32 | /* Max # of struct/union/enum members or func args */ | 28 | /* Max # of struct/union/enum members or func args */ |
| 33 | #define BTF_MAX_VLEN 0xffff | 29 | #define BTF_MAX_VLEN 0xffff |
| 34 | 30 | ||
| 35 | /* The type id is referring to a parent BTF */ | ||
| 36 | #define BTF_TYPE_PARENT(id) (((id) >> 31) & 0x1) | ||
| 37 | #define BTF_TYPE_ID(id) ((id) & BTF_MAX_TYPE) | ||
| 38 | |||
| 39 | /* String is in the ELF string section */ | ||
| 40 | #define BTF_STR_TBL_ELF_ID(ref) (((ref) >> 31) & 0x1) | ||
| 41 | #define BTF_STR_OFFSET(ref) ((ref) & BTF_MAX_NAME_OFFSET) | ||
| 42 | |||
| 43 | struct btf_type { | 31 | struct btf_type { |
| 44 | __u32 name_off; | 32 | __u32 name_off; |
| 45 | /* "info" bits arrangement | 33 | /* "info" bits arrangement |
| 46 | * bits 0-15: vlen (e.g. # of struct's members) | 34 | * bits 0-15: vlen (e.g. # of struct's members) |
| 47 | * bits 16-23: unused | 35 | * bits 16-23: unused |
| 48 | * bits 24-28: kind (e.g. int, ptr, array...etc) | 36 | * bits 24-27: kind (e.g. int, ptr, array...etc) |
| 49 | * bits 29-30: unused | 37 | * bits 28-31: unused |
| 50 | * bits 31: root | ||
| 51 | */ | 38 | */ |
| 52 | __u32 info; | 39 | __u32 info; |
| 53 | /* "size" is used by INT, ENUM, STRUCT and UNION. | 40 | /* "size" is used by INT, ENUM, STRUCT and UNION. |
| @@ -62,8 +49,7 @@ struct btf_type { | |||
| 62 | }; | 49 | }; |
| 63 | }; | 50 | }; |
| 64 | 51 | ||
| 65 | #define BTF_INFO_KIND(info) (((info) >> 24) & 0x1f) | 52 | #define BTF_INFO_KIND(info) (((info) >> 24) & 0x0f) |
| 66 | #define BTF_INFO_ISROOT(info) (!!(((info) >> 24) & 0x80)) | ||
| 67 | #define BTF_INFO_VLEN(info) ((info) & 0xffff) | 53 | #define BTF_INFO_VLEN(info) ((info) & 0xffff) |
| 68 | 54 | ||
| 69 | #define BTF_KIND_UNKN 0 /* Unknown */ | 55 | #define BTF_KIND_UNKN 0 /* Unknown */ |
| @@ -88,15 +74,14 @@ struct btf_type { | |||
| 88 | /* BTF_KIND_INT is followed by a u32 and the following | 74 | /* BTF_KIND_INT is followed by a u32 and the following |
| 89 | * is the 32 bits arrangement: | 75 | * is the 32 bits arrangement: |
| 90 | */ | 76 | */ |
| 91 | #define BTF_INT_ENCODING(VAL) (((VAL) & 0xff000000) >> 24) | 77 | #define BTF_INT_ENCODING(VAL) (((VAL) & 0x0f000000) >> 24) |
| 92 | #define BTF_INT_OFFSET(VAL) (((VAL & 0x00ff0000)) >> 16) | 78 | #define BTF_INT_OFFSET(VAL) (((VAL & 0x00ff0000)) >> 16) |
| 93 | #define BTF_INT_BITS(VAL) ((VAL) & 0x0000ffff) | 79 | #define BTF_INT_BITS(VAL) ((VAL) & 0x0000ffff) |
| 94 | 80 | ||
| 95 | /* Attributes stored in the BTF_INT_ENCODING */ | 81 | /* Attributes stored in the BTF_INT_ENCODING */ |
| 96 | #define BTF_INT_SIGNED 0x1 | 82 | #define BTF_INT_SIGNED (1 << 0) |
| 97 | #define BTF_INT_CHAR 0x2 | 83 | #define BTF_INT_CHAR (1 << 1) |
| 98 | #define BTF_INT_BOOL 0x4 | 84 | #define BTF_INT_BOOL (1 << 2) |
| 99 | #define BTF_INT_VARARGS 0x8 | ||
| 100 | 85 | ||
| 101 | /* BTF_KIND_ENUM is followed by multiple "struct btf_enum". | 86 | /* BTF_KIND_ENUM is followed by multiple "struct btf_enum". |
| 102 | * The exact number of btf_enum is stored in the vlen (of the | 87 | * The exact number of btf_enum is stored in the vlen (of the |
