History

Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next

Daniel Borkmann says: ==================== pull-request: bpf-next 2018-03-31 The following pull-request contains BPF updates for your *net-next* tree. The main changes are: 1) Add raw BPF tracepoint API in order to have a BPF program type that can access kernel internal arguments of the tracepoints in their raw form similar to kprobes based BPF programs. This infrastructure also adds a new BPF_RAW_TRACEPOINT_OPEN command to BPF syscall which returns an anon-inode backed fd for the tracepoint object that allows for automatic detach of the BPF program resp. unregistering of the tracepoint probe on fd release, from Alexei. 2) Add new BPF cgroup hooks at bind() and connect() entry in order to allow BPF programs to reject, inspect or modify user space passed struct sockaddr, and as well a hook at post bind time once the port has been allocated. They are used in FB's container management engine for implementing policy, replacing fragile LD_PRELOAD wrapper intercepting bind() and connect() calls that only works in limited scenarios like glibc based apps but not for other runtimes in containerized applications, from Andrey. 3) BPF_F_INGRESS flag support has been added to sockmap programs for their redirect helper call bringing it in line with cls_bpf based programs. Support is added for both variants of sockmap programs, meaning for tx ULP hooks as well as recv skb hooks, from John. 4) Various improvements on BPF side for the nfp driver, besides others this work adds BPF map update and delete helper call support from the datapath, JITing of 32 and 64 bit XADD instructions as well as offload support of bpf_get_prandom_u32() call. Initial implementation of nfp packet cache has been tackled that optimizes memory access (see merge commit for further details), from Jakub and Jiong. 5) Removal of struct bpf_verifier_env argument from the print_bpf_insn() API has been done in order to prepare to use print_bpf_insn() soon out of perf tool directly. This makes the print_bpf_insn() API more generic and pushes the env into private data. bpftool is adjusted as well with the print_bpf_insn() argument removal, from Jiri. 6) Couple of cleanups and prep work for the upcoming BTF (BPF Type Format). The latter will reuse the current BPF verifier log as well, thus bpf_verifier_log() is further generalized, from Martin. 7) For bpf_getsockopt() and bpf_setsockopt() helpers, IPv4 IP_TOS read and write support has been added in similar fashion to existing IPv6 IPV6_TCLASS socket option we already have, from Nikita. 8) Fixes in recent sockmap scatterlist API usage, which did not use sg_init_table() for initialization thus triggering a BUG_ON() in scatterlist API when CONFIG_DEBUG_SG was enabled. This adds and uses a small helper sg_init_marker() to properly handle the affected cases, from Prashant. 9) Let the BPF core follow IDR code convention and therefore use the idr_preload() and idr_preload_end() helpers, which would also help idr_alloc_cyclic() under GFP_ATOMIC to better succeed under memory pressure, from Shaohua. 10) Last but not least, a spelling fix in an error message for the BPF cookie UID helper under BPF sample code, from Colin. ====================

David S. Miller committed 8 years ago

Commit d4069fe2 parents 70ae722 7828f2077 files · +4265 −399Browse files

Showing the changes to include/uapi/linux (1 of 77 files). Show all

Unified · Split

include/uapi/linux/bpf.h+61−1
@@ -94,6 +94,7 @@ enum bpf_cmd { · 93 unmodified lines
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 BPF_PROG_QUERY,
97 BPF_RAW_TRACEPOINT_OPEN,
97};98};
98 99
99enum bpf_map_type {100enum bpf_map_type {
@@ -134,6 +135,8 @@ enum bpf_prog_type { · 34 unmodified lines
134 BPF_PROG_TYPE_SK_SKB,135 BPF_PROG_TYPE_SK_SKB,
135 BPF_PROG_TYPE_CGROUP_DEVICE,136 BPF_PROG_TYPE_CGROUP_DEVICE,
136 BPF_PROG_TYPE_SK_MSG,137 BPF_PROG_TYPE_SK_MSG,
138 BPF_PROG_TYPE_RAW_TRACEPOINT,
139 BPF_PROG_TYPE_CGROUP_SOCK_ADDR,
137};140};
138 141
139enum bpf_attach_type {142enum bpf_attach_type {
@@ -145,6 +148,12 @@ enum bpf_attach_type { · 5 unmodified lines
145 BPF_SK_SKB_STREAM_VERDICT,148 BPF_SK_SKB_STREAM_VERDICT,
146 BPF_CGROUP_DEVICE,149 BPF_CGROUP_DEVICE,
147 BPF_SK_MSG_VERDICT,150 BPF_SK_MSG_VERDICT,
151 BPF_CGROUP_INET4_BIND,
152 BPF_CGROUP_INET6_BIND,
153 BPF_CGROUP_INET4_CONNECT,
154 BPF_CGROUP_INET6_CONNECT,
155 BPF_CGROUP_INET4_POST_BIND,
156 BPF_CGROUP_INET6_POST_BIND,
148 __MAX_BPF_ATTACH_TYPE157 __MAX_BPF_ATTACH_TYPE
149};158};
150 159
@@ -294,6 +303,11 @@ union bpf_attr { · 143 unmodified lines
294 __u32 prog_flags;303 __u32 prog_flags;
295 char prog_name[BPF_OBJ_NAME_LEN];304 char prog_name[BPF_OBJ_NAME_LEN];
296 __u32 prog_ifindex; /* ifindex of netdev to prep for */305 __u32 prog_ifindex; /* ifindex of netdev to prep for */
306 /* For some prog types expected attach type must be known at
307 * load time to verify attach type specific parts of prog
308 * (context accesses, allowed helpers, etc).
309 */
310 __u32 expected_attach_type;
297 };311 };
298 312
299 struct { /* anonymous struct used by BPF_OBJ_* commands */313 struct { /* anonymous struct used by BPF_OBJ_* commands */
@@ -344,6 +358,11 @@ union bpf_attr { · 44 unmodified lines
344 __aligned_u64 prog_ids;358 __aligned_u64 prog_ids;
345 __u32 prog_cnt;359 __u32 prog_cnt;
346 } query;360 } query;
361
362 struct {
363 __u64 name;
364 __u32 prog_fd;
365 } raw_tracepoint;
347} __attribute__((aligned(8)));366} __attribute__((aligned(8)));
348 367
349/* BPF helper function descriptions:368/* BPF helper function descriptions:
@@ -729,6 +748,13 @@ union bpf_attr { · 379 unmodified lines
729 * @flags: reserved for future use748 * @flags: reserved for future use
730 * Return: SK_PASS749 * Return: SK_PASS
731 *750 *
751 * int bpf_bind(ctx, addr, addr_len)
752 * Bind socket to address. Only binding to IP is supported, no port can be
753 * set in addr.
754 * @ctx: pointer to context of type bpf_sock_addr
755 * @addr: pointer to struct sockaddr to bind socket to
756 * @addr_len: length of sockaddr structure
757 * Return: 0 on success or negative error code
732 */758 */
733#define __BPF_FUNC_MAPPER(FN) \759#define __BPF_FUNC_MAPPER(FN) \
734 FN(unspec), \760 FN(unspec), \
@@ -794,7 +820,8 @@ union bpf_attr { · 59 unmodified lines
794 FN(msg_redirect_map), \820 FN(msg_redirect_map), \
795 FN(msg_apply_bytes), \821 FN(msg_apply_bytes), \
796 FN(msg_cork_bytes), \822 FN(msg_cork_bytes), \
797 FN(msg_pull_data),823 FN(msg_pull_data), \
824 FN(bind),
798 825
799/* integer value in 'imm' field of BPF_CALL instruction selects which helper826/* integer value in 'imm' field of BPF_CALL instruction selects which helper
800 * function eBPF program intends to call827 * function eBPF program intends to call
@@ -923,6 +950,15 @@ struct bpf_sock { · 122 unmodified lines
923 __u32 protocol;950 __u32 protocol;
924 __u32 mark;951 __u32 mark;
925 __u32 priority;952 __u32 priority;
953 __u32 src_ip4; /* Allows 1,2,4-byte read.
954 * Stored in network byte order.
955 */
956 __u32 src_ip6[4]; /* Allows 1,2,4-byte read.
957 * Stored in network byte order.
958 */
959 __u32 src_port; /* Allows 4-byte read.
960 * Stored in host byte order
961 */
926};962};
927 963
928#define XDP_PACKET_HEADROOM 256964#define XDP_PACKET_HEADROOM 256
@@ -998,6 +1034,26 @@ struct bpf_map_info { · 69 unmodified lines
998 __u64 netns_ino;1034 __u64 netns_ino;
999} __attribute__((aligned(8)));1035} __attribute__((aligned(8)));
1000 1036
1037/* User bpf_sock_addr struct to access socket fields and sockaddr struct passed
1038 * by user and intended to be used by socket (e.g. to bind to, depends on
1039 * attach attach type).
1040 */
1041struct bpf_sock_addr {
1042 __u32 user_family; /* Allows 4-byte read, but no write. */
1043 __u32 user_ip4; /* Allows 1,2,4-byte read and 4-byte write.
1044 * Stored in network byte order.
1045 */
1046 __u32 user_ip6[4]; /* Allows 1,2,4-byte read an 4-byte write.
1047 * Stored in network byte order.
1048 */
1049 __u32 user_port; /* Allows 4-byte read and write.
1050 * Stored in network byte order
1051 */
1052 __u32 family; /* Allows 4-byte read, but no write */
1053 __u32 type; /* Allows 4-byte read, but no write */
1054 __u32 protocol; /* Allows 4-byte read, but no write */
1055};
1056
1001/* User bpf_sock_ops struct to access socket values and specify request ops1057/* User bpf_sock_ops struct to access socket values and specify request ops
1002 * and their replies.1058 * and their replies.
1003 * Some of this fields are in network (bigendian) byte order and may need1059 * Some of this fields are in network (bigendian) byte order and may need
@@ -1152,4 +1208,8 @@ struct bpf_cgroup_dev_ctx { · 148 unmodified lines
1152 __u32 minor;1208 __u32 minor;
1153};1209};
1154 1210
1211struct bpf_raw_tracepoint_args {
1212 __u64 args[0];
1213};
1214
1155#endif /* _UAPI__LINUX_BPF_H__ */1215#endif /* _UAPI__LINUX_BPF_H__ */