History

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 ====================

David S. Miller committed 8 years ago

Commit 90fed9c2 parents 49a473f 10f678690 files · +5213 −812Browse files

Showing the changes to include/uapi/linux (4 of 90 files). Show all

Unified · Split

4 files
  1. include/uapi/linux/bpf.h +138 −5
  2. include/uapi/linux/btf.h +11 −26
  3. include/uapi/linux/if_xdp.h +25 −34
  4. include/uapi/linux/seg6_local.h +12 −0
include/uapi/linux/bpf.h+138−5
@@ -97,6 +97,7 @@ enum bpf_cmd { · 96 unmodified lines
9797 BPF_RAW_TRACEPOINT_OPEN,
9898 BPF_BTF_LOAD,
9999 BPF_BTF_GET_FD_BY_ID,
100+ BPF_TASK_FD_QUERY,
100101 };
101102
102103 enum bpf_map_type {
@@ -141,6 +142,7 @@ enum bpf_prog_type { · 38 unmodified lines
141142 BPF_PROG_TYPE_SK_MSG,
142143 BPF_PROG_TYPE_RAW_TRACEPOINT,
143144 BPF_PROG_TYPE_CGROUP_SOCK_ADDR,
145+ BPF_PROG_TYPE_LWT_SEG6LOCAL,
144146 };
145147
146148 enum bpf_attach_type {
@@ -284,8 +286,8 @@ union bpf_attr { · 137 unmodified lines
284286 char map_name[BPF_OBJ_NAME_LEN];
285287 __u32 map_ifindex; /* ifindex of netdev to create on */
286288 __u32 btf_fd; /* fd pointing to a BTF type data */
287− __u32 btf_key_id; /* BTF type_id of the key */
288− __u32 btf_value_id; /* BTF type_id of the value */
289+ __u32 btf_key_type_id; /* BTF type_id of the key */
290+ __u32 btf_value_type_id; /* BTF type_id of the value */
289291 };
290292
291293 struct { /* anonymous struct used by BPF_MAP_*_ELEM commands */
@@ -379,6 +381,22 @@ union bpf_attr { · 87 unmodified lines
379381 __u32 btf_log_size;
380382 __u32 btf_log_level;
381383 };
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;
382400 } __attribute__((aligned(8)));
383401
384402 /* The description below is an attempt at providing documentation to eBPF
@@ -1902,6 +1920,90 @@ union bpf_attr { · 1517 unmodified lines
19021920 * egress otherwise). This is the only flag supported for now.
19031921 * Return
19041922 * **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.
19052007 */
19062008 #define __BPF_FUNC_MAPPER(FN) \
19072009 FN(unspec), \
@@ -1976,7 +2078,11 @@ union bpf_attr { · 68 unmodified lines
19762078 FN(fib_lookup), \
19772079 FN(sock_hash_update), \
19782080 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),
19802086
19812087 /* integer value in 'imm' field of BPF_CALL instruction selects which helper
19822088 * function eBPF program intends to call
@@ -2043,6 +2149,12 @@ enum bpf_hdr_start_off { · 60 unmodified lines
20432149 BPF_HDR_START_NET,
20442150 };
20452151
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+
20462158 /* user accessible mirror of in-kernel sk_buff.
20472159 * new fields can only be added to the end of this structure
20482160 */
@@ -2176,6 +2288,14 @@ enum sk_action { · 127 unmodified lines
21762288 struct sk_msg_md {
21772289 void *data;
21782290 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 */
21792299 };
21802300
21812301 #define BPF_TAG_SIZE 8
@@ -2197,6 +2317,10 @@ struct bpf_prog_info { · 15 unmodified lines
21972317 __u32 gpl_compatible:1;
21982318 __u64 netns_dev;
21992319 __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;
22002324 } __attribute__((aligned(8)));
22012325
22022326 struct bpf_map_info {
@@ -2211,8 +2335,8 @@ struct bpf_map_info { · 8 unmodified lines
22112335 __u64 netns_dev;
22122336 __u64 netns_ino;
22132337 __u32 btf_id;
2214− __u32 btf_key_id;
2215− __u32 btf_value_id;
2338+ __u32 btf_key_type_id;
2339+ __u32 btf_value_type_id;
22162340 } __attribute__((aligned(8)));
22172341
22182342 struct bpf_btf_info {
@@ -2450,4 +2574,13 @@ struct bpf_fib_lookup { · 231 unmodified lines
24502574 __u8 dmac[6]; /* ETH_ALEN */
24512575 };
24522576
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+
24532586 #endif /* _UAPI__LINUX_BPF_H__ */
include/uapi/linux/btf.h+11−26
@@ -12,42 +12,29 @@ struct btf_header { · 11 unmodified lines
1212 __u16 magic;
1313 __u8 version;
1414 __u8 flags;
15−
16− __u32 parent_label;
17− __u32 parent_name;
15+ __u32 hdr_len;
1816
1917 /* 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 */
2318 __u32 type_off; /* offset of type section */
19+ __u32 type_len; /* length of type section */
2420 __u32 str_off; /* offset of string section */
2521 __u32 str_len; /* length of string section */
2622 };
2723
2824 /* Max # of type identifier */
29−#define BTF_MAX_TYPE 0x7fffffff
25+#define BTF_MAX_TYPE 0x0000ffff
3026 /* Max offset into the string section */
31−#define BTF_MAX_NAME_OFFSET 0x7fffffff
27+#define BTF_MAX_NAME_OFFSET 0x0000ffff
3228 /* Max # of struct/union/enum members or func args */
3329 #define BTF_MAX_VLEN 0xffff
3430
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−
4331 struct btf_type {
4432 __u32 name_off;
4533 /* "info" bits arrangement
4634 * bits 0-15: vlen (e.g. # of struct's members)
4735 * bits 16-23: unused
48− * bits 24-28: kind (e.g. int, ptr, array...etc)
49− * bits 29-30: unused
50− * bits 31: root
36+ * bits 24-27: kind (e.g. int, ptr, array...etc)
37+ * bits 28-31: unused
5138 */
5239 __u32 info;
5340 /* "size" is used by INT, ENUM, STRUCT and UNION.
@@ -62,8 +49,7 @@ struct btf_type { · 8 unmodified lines
6249 };
6350 };
6451
65−#define BTF_INFO_KIND(info) (((info) >> 24) & 0x1f)
66−#define BTF_INFO_ISROOT(info) (!!(((info) >> 24) & 0x80))
52+#define BTF_INFO_KIND(info) (((info) >> 24) & 0x0f)
6753 #define BTF_INFO_VLEN(info) ((info) & 0xffff)
6854
6955 #define BTF_KIND_UNKN 0 /* Unknown */
@@ -88,15 +74,14 @@ struct btf_type { · 18 unmodified lines
8874 /* BTF_KIND_INT is followed by a u32 and the following
8975 * is the 32 bits arrangement:
9076 */
91−#define BTF_INT_ENCODING(VAL) (((VAL) & 0xff000000) >> 24)
77+#define BTF_INT_ENCODING(VAL) (((VAL) & 0x0f000000) >> 24)
9278 #define BTF_INT_OFFSET(VAL) (((VAL & 0x00ff0000)) >> 16)
9379 #define BTF_INT_BITS(VAL) ((VAL) & 0x0000ffff)
9480
9581 /* Attributes stored in the BTF_INT_ENCODING */
96−#define BTF_INT_SIGNED 0x1
97−#define BTF_INT_CHAR 0x2
98−#define BTF_INT_BOOL 0x4
99−#define BTF_INT_VARARGS 0x8
82+#define BTF_INT_SIGNED (1 << 0)
83+#define BTF_INT_CHAR (1 << 1)
84+#define BTF_INT_BOOL (1 << 2)
10085
10186 /* BTF_KIND_ENUM is followed by multiple "struct btf_enum".
10287 * The exact number of btf_enum is stored in the vlen (of the
include/uapi/linux/if_xdp.h+25−34
@@ -1,17 +1,8 @@
1−/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
2− *
1+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2+/*
33 * if_xdp: XDP socket user-space interface
44 * Copyright(c) 2018 Intel Corporation.
55 *
6− * This program is free software; you can redistribute it and/or modify it
7− * under the terms and conditions of the GNU General Public License,
8− * version 2, as published by the Free Software Foundation.
9− *
10− * This program is distributed in the hope it will be useful, but WITHOUT
11− * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12− * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13− * more details.
14− *
156 * Author(s): Björn Töpel <bjorn.topel@intel.com>
167 * Magnus Karlsson <magnus.karlsson@intel.com>
178 */
@@ -26,19 +17,33 @@ · 8 unmodified lines
2617
2718 struct sockaddr_xdp {
2819 __u16 sxdp_family;
20+ __u16 sxdp_flags;
2921 __u32 sxdp_ifindex;
3022 __u32 sxdp_queue_id;
3123 __u32 sxdp_shared_umem_fd;
32− __u16 sxdp_flags;
24+};
25+
26+struct xdp_ring_offset {
27+ __u64 producer;
28+ __u64 consumer;
29+ __u64 desc;
30+};
31+
32+struct xdp_mmap_offsets {
33+ struct xdp_ring_offset rx;
34+ struct xdp_ring_offset tx;
35+ struct xdp_ring_offset fr; /* Fill */
36+ struct xdp_ring_offset cr; /* Completion */
3337 };
3438
3539 /* XDP socket options */
36−#define XDP_RX_RING 1
37−#define XDP_TX_RING 2
38−#define XDP_UMEM_REG 3
39−#define XDP_UMEM_FILL_RING 4
40−#define XDP_UMEM_COMPLETION_RING 5
41−#define XDP_STATISTICS 6
40+#define XDP_MMAP_OFFSETS 1
41+#define XDP_RX_RING 2
42+#define XDP_TX_RING 3
43+#define XDP_UMEM_REG 4
44+#define XDP_UMEM_FILL_RING 5
45+#define XDP_UMEM_COMPLETION_RING 6
46+#define XDP_STATISTICS 7
4247
4348 struct xdp_umem_reg {
4449 __u64 addr; /* Start of packet data area */
@@ -59,6 +64,7 @@ struct xdp_statistics { · 14 unmodified lines
5964 #define XDP_UMEM_PGOFF_FILL_RING 0x100000000
6065 #define XDP_UMEM_PGOFF_COMPLETION_RING 0x180000000
6166
67+/* Rx/Tx descriptor */
6268 struct xdp_desc {
6369 __u32 idx;
6470 __u32 len;
@@ -67,21 +73,6 @@ struct xdp_desc { · 2 unmodified lines
6773 __u8 padding[5];
6874 };
6975
70−struct xdp_ring {
71− __u32 producer __attribute__((aligned(64)));
72− __u32 consumer __attribute__((aligned(64)));
73−};
74−
75−/* Used for the RX and TX queues for packets */
76−struct xdp_rxtx_ring {
77− struct xdp_ring ptrs;
78− struct xdp_desc desc[0] __attribute__((aligned(64)));
79−};
80−
81−/* Used for the fill and completion queues for buffers */
82−struct xdp_umem_ring {
83− struct xdp_ring ptrs;
84− __u32 desc[0] __attribute__((aligned(64)));
85−};
76+/* UMEM descriptor is __u32 */
8677
8778 #endif /* _LINUX_IF_XDP_H */
include/uapi/linux/seg6_local.h+12−0
@@ -25,6 +25,7 @@ enum { · 24 unmodified lines
2525 SEG6_LOCAL_NH6,
2626 SEG6_LOCAL_IIF,
2727 SEG6_LOCAL_OIF,
28+ SEG6_LOCAL_BPF,
2829 __SEG6_LOCAL_MAX,
2930 };
3031 #define SEG6_LOCAL_MAX (__SEG6_LOCAL_MAX - 1)
@@ -59,10 +60,21 @@ enum { · 28 unmodified lines
5960 SEG6_LOCAL_ACTION_END_AS = 13,
6061 /* forward to SR-unaware VNF with masquerading */
6162 SEG6_LOCAL_ACTION_END_AM = 14,
63+ /* custom BPF action */
64+ SEG6_LOCAL_ACTION_END_BPF = 15,
6265
6366 __SEG6_LOCAL_ACTION_MAX,
6467 };
6568
6669 #define SEG6_LOCAL_ACTION_MAX (__SEG6_LOCAL_ACTION_MAX - 1)
6770
71+enum {
72+ SEG6_LOCAL_BPF_PROG_UNSPEC,
73+ SEG6_LOCAL_BPF_PROG,
74+ SEG6_LOCAL_BPF_PROG_NAME,
75+ __SEG6_LOCAL_BPF_PROG_MAX,
76+};
77+
78+#define SEG6_LOCAL_BPF_PROG_MAX (__SEG6_LOCAL_BPF_PROG_MAX - 1)
79+
6880 #endif

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t