aboutsummaryrefslogtreecommitdiffstats
path: root/tools/include/uapi/linux
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-11-15 14:56:19 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-11-15 14:56:19 -0500
commit5bbcc0f595fadb4cac0eddc4401035ec0bd95b09 (patch)
tree3b65e490cc36a6c6fecac1fa24d9e0ac9ced4455 /tools/include/uapi/linux
parent892204e06cb9e89fbc4b299a678f9ca358e97cac (diff)
parent50895b9de1d3e0258e015e8e55128d835d9a9f19 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
Pull networking updates from David Miller: "Highlights: 1) Maintain the TCP retransmit queue using an rbtree, with 1GB windows at 100Gb this really has become necessary. From Eric Dumazet. 2) Multi-program support for cgroup+bpf, from Alexei Starovoitov. 3) Perform broadcast flooding in hardware in mv88e6xxx, from Andrew Lunn. 4) Add meter action support to openvswitch, from Andy Zhou. 5) Add a data meta pointer for BPF accessible packets, from Daniel Borkmann. 6) Namespace-ify almost all TCP sysctl knobs, from Eric Dumazet. 7) Turn on Broadcom Tags in b53 driver, from Florian Fainelli. 8) More work to move the RTNL mutex down, from Florian Westphal. 9) Add 'bpftool' utility, to help with bpf program introspection. From Jakub Kicinski. 10) Add new 'cpumap' type for XDP_REDIRECT action, from Jesper Dangaard Brouer. 11) Support 'blocks' of transformations in the packet scheduler which can span multiple network devices, from Jiri Pirko. 12) TC flower offload support in cxgb4, from Kumar Sanghvi. 13) Priority based stream scheduler for SCTP, from Marcelo Ricardo Leitner. 14) Thunderbolt networking driver, from Amir Levy and Mika Westerberg. 15) Add RED qdisc offloadability, and use it in mlxsw driver. From Nogah Frankel. 16) eBPF based device controller for cgroup v2, from Roman Gushchin. 17) Add some fundamental tracepoints for TCP, from Song Liu. 18) Remove garbage collection from ipv6 route layer, this is a significant accomplishment. From Wei Wang. 19) Add multicast route offload support to mlxsw, from Yotam Gigi" * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (2177 commits) tcp: highest_sack fix geneve: fix fill_info when link down bpf: fix lockdep splat net: cdc_ncm: GetNtbFormat endian fix openvswitch: meter: fix NULL pointer dereference in ovs_meter_cmd_reply_start netem: remove unnecessary 64 bit modulus netem: use 64 bit divide by rate tcp: Namespace-ify sysctl_tcp_default_congestion_control net: Protect iterations over net::fib_notifier_ops in fib_seq_sum() ipv6: set all.accept_dad to 0 by default uapi: fix linux/tls.h userspace compilation error usbnet: ipheth: prevent TX queue timeouts when device not ready vhost_net: conditionally enable tx polling uapi: fix linux/rxrpc.h userspace compilation errors net: stmmac: fix LPI transitioning for dwmac4 atm: horizon: Fix irq release error net-sysfs: trigger netlink notification on ifalias change via sysfs openvswitch: Using kfree_rcu() to simplify the code openvswitch: Make local function ovs_nsh_key_attr_size() static openvswitch: Fix return value check in ovs_meter_cmd_features() ...
Diffstat (limited to 'tools/include/uapi/linux')
-rw-r--r--tools/include/uapi/linux/bpf.h158
1 files changed, 150 insertions, 8 deletions
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index 30f2ce76b517..e880ae6434ee 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -93,6 +93,7 @@ enum bpf_cmd {
93 BPF_PROG_GET_FD_BY_ID, 93 BPF_PROG_GET_FD_BY_ID,
94 BPF_MAP_GET_FD_BY_ID, 94 BPF_MAP_GET_FD_BY_ID,
95 BPF_OBJ_GET_INFO_BY_FD, 95 BPF_OBJ_GET_INFO_BY_FD,
96 BPF_PROG_QUERY,
96}; 97};
97 98
98enum bpf_map_type { 99enum bpf_map_type {
@@ -112,6 +113,7 @@ enum bpf_map_type {
112 BPF_MAP_TYPE_HASH_OF_MAPS, 113 BPF_MAP_TYPE_HASH_OF_MAPS,
113 BPF_MAP_TYPE_DEVMAP, 114 BPF_MAP_TYPE_DEVMAP,
114 BPF_MAP_TYPE_SOCKMAP, 115 BPF_MAP_TYPE_SOCKMAP,
116 BPF_MAP_TYPE_CPUMAP,
115}; 117};
116 118
117enum bpf_prog_type { 119enum bpf_prog_type {
@@ -130,6 +132,7 @@ enum bpf_prog_type {
130 BPF_PROG_TYPE_LWT_XMIT, 132 BPF_PROG_TYPE_LWT_XMIT,
131 BPF_PROG_TYPE_SOCK_OPS, 133 BPF_PROG_TYPE_SOCK_OPS,
132 BPF_PROG_TYPE_SK_SKB, 134 BPF_PROG_TYPE_SK_SKB,
135 BPF_PROG_TYPE_CGROUP_DEVICE,
133}; 136};
134 137
135enum bpf_attach_type { 138enum bpf_attach_type {
@@ -139,16 +142,53 @@ enum bpf_attach_type {
139 BPF_CGROUP_SOCK_OPS, 142 BPF_CGROUP_SOCK_OPS,
140 BPF_SK_SKB_STREAM_PARSER, 143 BPF_SK_SKB_STREAM_PARSER,
141 BPF_SK_SKB_STREAM_VERDICT, 144 BPF_SK_SKB_STREAM_VERDICT,
145 BPF_CGROUP_DEVICE,
142 __MAX_BPF_ATTACH_TYPE 146 __MAX_BPF_ATTACH_TYPE
143}; 147};
144 148
145#define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE 149#define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE
146 150
147/* If BPF_F_ALLOW_OVERRIDE flag is used in BPF_PROG_ATTACH command 151/* cgroup-bpf attach flags used in BPF_PROG_ATTACH command
148 * to the given target_fd cgroup the descendent cgroup will be able to 152 *
149 * override effective bpf program that was inherited from this cgroup 153 * NONE(default): No further bpf programs allowed in the subtree.
154 *
155 * BPF_F_ALLOW_OVERRIDE: If a sub-cgroup installs some bpf program,
156 * the program in this cgroup yields to sub-cgroup program.
157 *
158 * BPF_F_ALLOW_MULTI: If a sub-cgroup installs some bpf program,
159 * that cgroup program gets run in addition to the program in this cgroup.
160 *
161 * Only one program is allowed to be attached to a cgroup with
162 * NONE or BPF_F_ALLOW_OVERRIDE flag.
163 * Attaching another program on top of NONE or BPF_F_ALLOW_OVERRIDE will
164 * release old program and attach the new one. Attach flags has to match.
165 *
166 * Multiple programs are allowed to be attached to a cgroup with
167 * BPF_F_ALLOW_MULTI flag. They are executed in FIFO order
168 * (those that were attached first, run first)
169 * The programs of sub-cgroup are executed first, then programs of
170 * this cgroup and then programs of parent cgroup.
171 * When children program makes decision (like picking TCP CA or sock bind)
172 * parent program has a chance to override it.
173 *
174 * A cgroup with MULTI or OVERRIDE flag allows any attach flags in sub-cgroups.
175 * A cgroup with NONE doesn't allow any programs in sub-cgroups.
176 * Ex1:
177 * cgrp1 (MULTI progs A, B) ->
178 * cgrp2 (OVERRIDE prog C) ->
179 * cgrp3 (MULTI prog D) ->
180 * cgrp4 (OVERRIDE prog E) ->
181 * cgrp5 (NONE prog F)
182 * the event in cgrp5 triggers execution of F,D,A,B in that order.
183 * if prog F is detached, the execution is E,D,A,B
184 * if prog F and D are detached, the execution is E,A,B
185 * if prog F, E and D are detached, the execution is C,A,B
186 *
187 * All eligible programs are executed regardless of return code from
188 * earlier programs.
150 */ 189 */
151#define BPF_F_ALLOW_OVERRIDE (1U << 0) 190#define BPF_F_ALLOW_OVERRIDE (1U << 0)
191#define BPF_F_ALLOW_MULTI (1U << 1)
152 192
153/* If BPF_F_STRICT_ALIGNMENT is used in BPF_PROG_LOAD command, the 193/* If BPF_F_STRICT_ALIGNMENT is used in BPF_PROG_LOAD command, the
154 * verifier will perform strict alignment checking as if the kernel 194 * verifier will perform strict alignment checking as if the kernel
@@ -176,6 +216,15 @@ enum bpf_attach_type {
176/* Specify numa node during map creation */ 216/* Specify numa node during map creation */
177#define BPF_F_NUMA_NODE (1U << 2) 217#define BPF_F_NUMA_NODE (1U << 2)
178 218
219/* flags for BPF_PROG_QUERY */
220#define BPF_F_QUERY_EFFECTIVE (1U << 0)
221
222#define BPF_OBJ_NAME_LEN 16U
223
224/* Flags for accessing BPF object */
225#define BPF_F_RDONLY (1U << 3)
226#define BPF_F_WRONLY (1U << 4)
227
179union bpf_attr { 228union bpf_attr {
180 struct { /* anonymous struct used by BPF_MAP_CREATE command */ 229 struct { /* anonymous struct used by BPF_MAP_CREATE command */
181 __u32 map_type; /* one of enum bpf_map_type */ 230 __u32 map_type; /* one of enum bpf_map_type */
@@ -189,6 +238,7 @@ union bpf_attr {
189 __u32 numa_node; /* numa node (effective only if 238 __u32 numa_node; /* numa node (effective only if
190 * BPF_F_NUMA_NODE is set). 239 * BPF_F_NUMA_NODE is set).
191 */ 240 */
241 char map_name[BPF_OBJ_NAME_LEN];
192 }; 242 };
193 243
194 struct { /* anonymous struct used by BPF_MAP_*_ELEM commands */ 244 struct { /* anonymous struct used by BPF_MAP_*_ELEM commands */
@@ -211,11 +261,14 @@ union bpf_attr {
211 __aligned_u64 log_buf; /* user supplied buffer */ 261 __aligned_u64 log_buf; /* user supplied buffer */
212 __u32 kern_version; /* checked when prog_type=kprobe */ 262 __u32 kern_version; /* checked when prog_type=kprobe */
213 __u32 prog_flags; 263 __u32 prog_flags;
264 char prog_name[BPF_OBJ_NAME_LEN];
265 __u32 prog_target_ifindex; /* ifindex of netdev to prep for */
214 }; 266 };
215 267
216 struct { /* anonymous struct used by BPF_OBJ_* commands */ 268 struct { /* anonymous struct used by BPF_OBJ_* commands */
217 __aligned_u64 pathname; 269 __aligned_u64 pathname;
218 __u32 bpf_fd; 270 __u32 bpf_fd;
271 __u32 file_flags;
219 }; 272 };
220 273
221 struct { /* anonymous struct used by BPF_PROG_ATTACH/DETACH commands */ 274 struct { /* anonymous struct used by BPF_PROG_ATTACH/DETACH commands */
@@ -243,6 +296,7 @@ union bpf_attr {
243 __u32 map_id; 296 __u32 map_id;
244 }; 297 };
245 __u32 next_id; 298 __u32 next_id;
299 __u32 open_flags;
246 }; 300 };
247 301
248 struct { /* anonymous struct used by BPF_OBJ_GET_INFO_BY_FD */ 302 struct { /* anonymous struct used by BPF_OBJ_GET_INFO_BY_FD */
@@ -250,6 +304,15 @@ union bpf_attr {
250 __u32 info_len; 304 __u32 info_len;
251 __aligned_u64 info; 305 __aligned_u64 info;
252 } info; 306 } info;
307
308 struct { /* anonymous struct used by BPF_PROG_QUERY command */
309 __u32 target_fd; /* container object to query */
310 __u32 attach_type;
311 __u32 query_flags;
312 __u32 attach_flags;
313 __aligned_u64 prog_ids;
314 __u32 prog_cnt;
315 } query;
253} __attribute__((aligned(8))); 316} __attribute__((aligned(8)));
254 317
255/* BPF helper function descriptions: 318/* BPF helper function descriptions:
@@ -554,12 +617,22 @@ union bpf_attr {
554 * int bpf_setsockopt(bpf_socket, level, optname, optval, optlen) 617 * int bpf_setsockopt(bpf_socket, level, optname, optval, optlen)
555 * Calls setsockopt. Not all opts are available, only those with 618 * Calls setsockopt. Not all opts are available, only those with
556 * integer optvals plus TCP_CONGESTION. 619 * integer optvals plus TCP_CONGESTION.
557 * Supported levels: SOL_SOCKET and IPROTO_TCP 620 * Supported levels: SOL_SOCKET and IPPROTO_TCP
621 * @bpf_socket: pointer to bpf_socket
622 * @level: SOL_SOCKET or IPPROTO_TCP
623 * @optname: option name
624 * @optval: pointer to option value
625 * @optlen: length of optval in bytes
626 * Return: 0 or negative error
627 *
628 * int bpf_getsockopt(bpf_socket, level, optname, optval, optlen)
629 * Calls getsockopt. Not all opts are available.
630 * Supported levels: IPPROTO_TCP
558 * @bpf_socket: pointer to bpf_socket 631 * @bpf_socket: pointer to bpf_socket
559 * @level: SOL_SOCKET or IPROTO_TCP 632 * @level: IPPROTO_TCP
560 * @optname: option name 633 * @optname: option name
561 * @optval: pointer to option value 634 * @optval: pointer to option value
562 * @optlen: length of optval in byes 635 * @optlen: length of optval in bytes
563 * Return: 0 or negative error 636 * Return: 0 or negative error
564 * 637 *
565 * int bpf_skb_adjust_room(skb, len_diff, mode, flags) 638 * int bpf_skb_adjust_room(skb, len_diff, mode, flags)
@@ -583,6 +656,27 @@ union bpf_attr {
583 * @map: pointer to sockmap to update 656 * @map: pointer to sockmap to update
584 * @key: key to insert/update sock in map 657 * @key: key to insert/update sock in map
585 * @flags: same flags as map update elem 658 * @flags: same flags as map update elem
659 *
660 * int bpf_xdp_adjust_meta(xdp_md, delta)
661 * Adjust the xdp_md.data_meta by delta
662 * @xdp_md: pointer to xdp_md
663 * @delta: An positive/negative integer to be added to xdp_md.data_meta
664 * Return: 0 on success or negative on error
665 *
666 * int bpf_perf_event_read_value(map, flags, buf, buf_size)
667 * read perf event counter value and perf event enabled/running time
668 * @map: pointer to perf_event_array map
669 * @flags: index of event in the map or bitmask flags
670 * @buf: buf to fill
671 * @buf_size: size of the buf
672 * Return: 0 on success or negative error code
673 *
674 * int bpf_perf_prog_read_value(ctx, buf, buf_size)
675 * read perf prog attached perf event counter and enabled/running time
676 * @ctx: pointer to ctx
677 * @buf: buf to fill
678 * @buf_size: size of the buf
679 * Return : 0 on success or negative error code
586 */ 680 */
587#define __BPF_FUNC_MAPPER(FN) \ 681#define __BPF_FUNC_MAPPER(FN) \
588 FN(unspec), \ 682 FN(unspec), \
@@ -639,6 +733,10 @@ union bpf_attr {
639 FN(redirect_map), \ 733 FN(redirect_map), \
640 FN(sk_redirect_map), \ 734 FN(sk_redirect_map), \
641 FN(sock_map_update), \ 735 FN(sock_map_update), \
736 FN(xdp_adjust_meta), \
737 FN(perf_event_read_value), \
738 FN(perf_prog_read_value), \
739 FN(getsockopt),
642 740
643/* integer value in 'imm' field of BPF_CALL instruction selects which helper 741/* integer value in 'imm' field of BPF_CALL instruction selects which helper
644 * function eBPF program intends to call 742 * function eBPF program intends to call
@@ -682,7 +780,9 @@ enum bpf_func_id {
682#define BPF_F_ZERO_CSUM_TX (1ULL << 1) 780#define BPF_F_ZERO_CSUM_TX (1ULL << 1)
683#define BPF_F_DONT_FRAGMENT (1ULL << 2) 781#define BPF_F_DONT_FRAGMENT (1ULL << 2)
684 782
685/* BPF_FUNC_perf_event_output and BPF_FUNC_perf_event_read flags. */ 783/* BPF_FUNC_perf_event_output, BPF_FUNC_perf_event_read and
784 * BPF_FUNC_perf_event_read_value flags.
785 */
686#define BPF_F_INDEX_MASK 0xffffffffULL 786#define BPF_F_INDEX_MASK 0xffffffffULL
687#define BPF_F_CURRENT_CPU BPF_F_INDEX_MASK 787#define BPF_F_CURRENT_CPU BPF_F_INDEX_MASK
688/* BPF_FUNC_perf_event_output for sk_buff input context. */ 788/* BPF_FUNC_perf_event_output for sk_buff input context. */
@@ -716,7 +816,7 @@ struct __sk_buff {
716 __u32 data_end; 816 __u32 data_end;
717 __u32 napi_id; 817 __u32 napi_id;
718 818
719 /* accessed by BPF_PROG_TYPE_sk_skb types */ 819 /* Accessed by BPF_PROG_TYPE_sk_skb types from here to ... */
720 __u32 family; 820 __u32 family;
721 __u32 remote_ip4; /* Stored in network byte order */ 821 __u32 remote_ip4; /* Stored in network byte order */
722 __u32 local_ip4; /* Stored in network byte order */ 822 __u32 local_ip4; /* Stored in network byte order */
@@ -724,6 +824,9 @@ struct __sk_buff {
724 __u32 local_ip6[4]; /* Stored in network byte order */ 824 __u32 local_ip6[4]; /* Stored in network byte order */
725 __u32 remote_port; /* Stored in network byte order */ 825 __u32 remote_port; /* Stored in network byte order */
726 __u32 local_port; /* stored in host byte order */ 826 __u32 local_port; /* stored in host byte order */
827 /* ... here. */
828
829 __u32 data_meta;
727}; 830};
728 831
729struct bpf_tunnel_key { 832struct bpf_tunnel_key {
@@ -784,6 +887,7 @@ enum xdp_action {
784struct xdp_md { 887struct xdp_md {
785 __u32 data; 888 __u32 data;
786 __u32 data_end; 889 __u32 data_end;
890 __u32 data_meta;
787}; 891};
788 892
789enum sk_action { 893enum sk_action {
@@ -793,6 +897,10 @@ enum sk_action {
793 897
794#define BPF_TAG_SIZE 8 898#define BPF_TAG_SIZE 8
795 899
900enum bpf_prog_status {
901 BPF_PROG_STATUS_DEV_BOUND = (1 << 0),
902};
903
796struct bpf_prog_info { 904struct bpf_prog_info {
797 __u32 type; 905 __u32 type;
798 __u32 id; 906 __u32 id;
@@ -801,6 +909,13 @@ struct bpf_prog_info {
801 __u32 xlated_prog_len; 909 __u32 xlated_prog_len;
802 __aligned_u64 jited_prog_insns; 910 __aligned_u64 jited_prog_insns;
803 __aligned_u64 xlated_prog_insns; 911 __aligned_u64 xlated_prog_insns;
912 __u64 load_time; /* ns since boottime */
913 __u32 created_by_uid;
914 __u32 nr_map_ids;
915 __aligned_u64 map_ids;
916 char name[BPF_OBJ_NAME_LEN];
917 __u32 ifindex;
918 __u32 status;
804} __attribute__((aligned(8))); 919} __attribute__((aligned(8)));
805 920
806struct bpf_map_info { 921struct bpf_map_info {
@@ -810,6 +925,7 @@ struct bpf_map_info {
810 __u32 value_size; 925 __u32 value_size;
811 __u32 max_entries; 926 __u32 max_entries;
812 __u32 map_flags; 927 __u32 map_flags;
928 char name[BPF_OBJ_NAME_LEN];
813} __attribute__((aligned(8))); 929} __attribute__((aligned(8)));
814 930
815/* User bpf_sock_ops struct to access socket values and specify request ops 931/* User bpf_sock_ops struct to access socket values and specify request ops
@@ -859,9 +975,35 @@ enum {
859 BPF_SOCK_OPS_NEEDS_ECN, /* If connection's congestion control 975 BPF_SOCK_OPS_NEEDS_ECN, /* If connection's congestion control
860 * needs ECN 976 * needs ECN
861 */ 977 */
978 BPF_SOCK_OPS_BASE_RTT, /* Get base RTT. The correct value is
979 * based on the path and may be
980 * dependent on the congestion control
981 * algorithm. In general it indicates
982 * a congestion threshold. RTTs above
983 * this indicate congestion
984 */
862}; 985};
863 986
864#define TCP_BPF_IW 1001 /* Set TCP initial congestion window */ 987#define TCP_BPF_IW 1001 /* Set TCP initial congestion window */
865#define TCP_BPF_SNDCWND_CLAMP 1002 /* Set sndcwnd_clamp */ 988#define TCP_BPF_SNDCWND_CLAMP 1002 /* Set sndcwnd_clamp */
866 989
990struct bpf_perf_event_value {
991 __u64 counter;
992 __u64 enabled;
993 __u64 running;
994};
995
996#define BPF_DEVCG_ACC_MKNOD (1ULL << 0)
997#define BPF_DEVCG_ACC_READ (1ULL << 1)
998#define BPF_DEVCG_ACC_WRITE (1ULL << 2)
999
1000#define BPF_DEVCG_DEV_BLOCK (1ULL << 0)
1001#define BPF_DEVCG_DEV_CHAR (1ULL << 1)
1002
1003struct bpf_cgroup_dev_ctx {
1004 __u32 access_type; /* (access << 16) | type */
1005 __u32 major;
1006 __u32 minor;
1007};
1008
867#endif /* _UAPI__LINUX_BPF_H__ */ 1009#endif /* _UAPI__LINUX_BPF_H__ */