History

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

Alexei Starovoitov says: ==================== pull-request: bpf-next 2020-07-21 The following pull-request contains BPF updates for your *net-next* tree. We've added 46 non-merge commits during the last 6 day(s) which contain a total of 68 files changed, 4929 insertions(+), 526 deletions(-). The main changes are: 1) Run BPF program on socket lookup, from Jakub. 2) Introduce cpumap, from Lorenzo. 3) s390 JIT fixes, from Ilya. 4) teach riscv JIT to emit compressed insns, from Luke. 5) use build time computed BTF ids in bpf iter, from Yonghong. ==================== Purely independent overlapping changes in both filter.h and xdp.h

David S. Miller committed 6 years ago

Commit dee72f82 parents fa56a98 9165e1d68 files · +4930 −526Browse files

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

Unified · Split

include/uapi/linux/bpf.h+94−3
@@ -189,6 +189,7 @@ enum bpf_prog_type { · 188 unmodified lines
189 BPF_PROG_TYPE_STRUCT_OPS,189 BPF_PROG_TYPE_STRUCT_OPS,
190 BPF_PROG_TYPE_EXT,190 BPF_PROG_TYPE_EXT,
191 BPF_PROG_TYPE_LSM,191 BPF_PROG_TYPE_LSM,
192 BPF_PROG_TYPE_SK_LOOKUP,
192};193};
193 194
194enum bpf_attach_type {195enum bpf_attach_type {
@@ -227,6 +228,8 @@ enum bpf_attach_type { · 32 unmodified lines
227 BPF_CGROUP_INET6_GETSOCKNAME,228 BPF_CGROUP_INET6_GETSOCKNAME,
228 BPF_XDP_DEVMAP,229 BPF_XDP_DEVMAP,
229 BPF_CGROUP_INET_SOCK_RELEASE,230 BPF_CGROUP_INET_SOCK_RELEASE,
231 BPF_XDP_CPUMAP,
232 BPF_SK_LOOKUP,
230 __MAX_BPF_ATTACH_TYPE233 __MAX_BPF_ATTACH_TYPE
231};234};
232 235
@@ -2419,7 +2422,7 @@ union bpf_attr { · 2186 unmodified lines
2419 * Look for an IPv6 socket.2422 * Look for an IPv6 socket.
2420 *2423 *
2421 * If the *netns* is a negative signed 32-bit integer, then the2424 * If the *netns* is a negative signed 32-bit integer, then the
2422 * socket lookup table in the netns associated with the *ctx* will2425 * socket lookup table in the netns associated with the *ctx*
2423 * will be used. For the TC hooks, this is the netns of the device2426 * will be used. For the TC hooks, this is the netns of the device
2424 * in the skb. For socket hooks, this is the netns of the socket.2427 * in the skb. For socket hooks, this is the netns of the socket.
2425 * If *netns* is any other signed 32-bit value greater than or2428 * If *netns* is any other signed 32-bit value greater than or
@@ -2456,7 +2459,7 @@ union bpf_attr { · 30 unmodified lines
2456 * Look for an IPv6 socket.2459 * Look for an IPv6 socket.
2457 *2460 *
2458 * If the *netns* is a negative signed 32-bit integer, then the2461 * If the *netns* is a negative signed 32-bit integer, then the
2459 * socket lookup table in the netns associated with the *ctx* will2462 * socket lookup table in the netns associated with the *ctx*
2460 * will be used. For the TC hooks, this is the netns of the device2463 * will be used. For the TC hooks, this is the netns of the device
2461 * in the skb. For socket hooks, this is the netns of the socket.2464 * in the skb. For socket hooks, this is the netns of the socket.
2462 * If *netns* is any other signed 32-bit value greater than or2465 * If *netns* is any other signed 32-bit value greater than or
@@ -3068,6 +3071,10 @@ union bpf_attr { · 605 unmodified lines
3068 *3071 *
3069 * long bpf_sk_assign(struct sk_buff *skb, struct bpf_sock *sk, u64 flags)3072 * long bpf_sk_assign(struct sk_buff *skb, struct bpf_sock *sk, u64 flags)
3070 * Description3073 * Description
3074 * Helper is overloaded depending on BPF program type. This
3075 * description applies to **BPF_PROG_TYPE_SCHED_CLS** and
3076 * **BPF_PROG_TYPE_SCHED_ACT** programs.
3077 *
3071 * Assign the *sk* to the *skb*. When combined with appropriate3078 * Assign the *sk* to the *skb*. When combined with appropriate
3072 * routing configuration to receive the packet towards the socket,3079 * routing configuration to receive the packet towards the socket,
3073 * will cause *skb* to be delivered to the specified socket.3080 * will cause *skb* to be delivered to the specified socket.
@@ -3093,6 +3100,56 @@ union bpf_attr { · 19 unmodified lines
3093 * **-ESOCKTNOSUPPORT** if the socket type is not supported3100 * **-ESOCKTNOSUPPORT** if the socket type is not supported
3094 * (reuseport).3101 * (reuseport).
3095 *3102 *
3103 * long bpf_sk_assign(struct bpf_sk_lookup *ctx, struct bpf_sock *sk, u64 flags)
3104 * Description
3105 * Helper is overloaded depending on BPF program type. This
3106 * description applies to **BPF_PROG_TYPE_SK_LOOKUP** programs.
3107 *
3108 * Select the *sk* as a result of a socket lookup.
3109 *
3110 * For the operation to succeed passed socket must be compatible
3111 * with the packet description provided by the *ctx* object.
3112 *
3113 * L4 protocol (**IPPROTO_TCP** or **IPPROTO_UDP**) must
3114 * be an exact match. While IP family (**AF_INET** or
3115 * **AF_INET6**) must be compatible, that is IPv6 sockets
3116 * that are not v6-only can be selected for IPv4 packets.
3117 *
3118 * Only TCP listeners and UDP unconnected sockets can be
3119 * selected. *sk* can also be NULL to reset any previous
3120 * selection.
3121 *
3122 * *flags* argument can combination of following values:
3123 *
3124 * * **BPF_SK_LOOKUP_F_REPLACE** to override the previous
3125 * socket selection, potentially done by a BPF program
3126 * that ran before us.
3127 *
3128 * * **BPF_SK_LOOKUP_F_NO_REUSEPORT** to skip
3129 * load-balancing within reuseport group for the socket
3130 * being selected.
3131 *
3132 * On success *ctx->sk* will point to the selected socket.
3133 *
3134 * Return
3135 * 0 on success, or a negative errno in case of failure.
3136 *
3137 * * **-EAFNOSUPPORT** if socket family (*sk->family*) is
3138 * not compatible with packet family (*ctx->family*).
3139 *
3140 * * **-EEXIST** if socket has been already selected,
3141 * potentially by another program, and
3142 * **BPF_SK_LOOKUP_F_REPLACE** flag was not specified.
3143 *
3144 * * **-EINVAL** if unsupported flags were specified.
3145 *
3146 * * **-EPROTOTYPE** if socket L4 protocol
3147 * (*sk->protocol*) doesn't match packet protocol
3148 * (*ctx->protocol*).
3149 *
3150 * * **-ESOCKTNOSUPPORT** if socket is not in allowed
3151 * state (TCP listening or UDP unconnected).
3152 *
3096 * u64 bpf_ktime_get_boot_ns(void)3153 * u64 bpf_ktime_get_boot_ns(void)
3097 * Description3154 * Description
3098 * Return the time elapsed since system boot, in nanoseconds.3155 * Return the time elapsed since system boot, in nanoseconds.
@@ -3606,6 +3663,12 @@ enum { · 507 unmodified lines
3606 BPF_RINGBUF_HDR_SZ = 8,3663 BPF_RINGBUF_HDR_SZ = 8,
3607};3664};
3608 3665
3666/* BPF_FUNC_sk_assign flags in bpf_sk_lookup context. */
3667enum {
3668 BPF_SK_LOOKUP_F_REPLACE = (1ULL << 0),
3669 BPF_SK_LOOKUP_F_NO_REUSEPORT = (1ULL << 1),
3670};
3671
3609/* Mode for BPF_FUNC_skb_adjust_room helper. */3672/* Mode for BPF_FUNC_skb_adjust_room helper. */
3610enum bpf_adj_room_mode {3673enum bpf_adj_room_mode {
3611 BPF_ADJ_ROOM_NET,3674 BPF_ADJ_ROOM_NET,
@@ -3849,6 +3912,19 @@ struct bpf_devmap_val { · 237 unmodified lines
3849 } bpf_prog;3912 } bpf_prog;
3850};3913};
3851 3914
3915/* CPUMAP map-value layout
3916 *
3917 * The struct data-layout of map-value is a configuration interface.
3918 * New members can only be added to the end of this structure.
3919 */
3920struct bpf_cpumap_val {
3921 __u32 qsize; /* queue size to remote target CPU */
3922 union {
3923 int fd; /* prog fd on map write */
3924 __u32 id; /* prog id on map read */
3925 } bpf_prog;
3926};
3927
3852enum sk_action {3928enum sk_action {
3853 SK_DROP = 0,3929 SK_DROP = 0,
3854 SK_PASS,3930 SK_PASS,
@@ -3986,7 +4062,7 @@ struct bpf_link_info { · 131 unmodified lines
3986 4062
3987/* User bpf_sock_addr struct to access socket fields and sockaddr struct passed4063/* User bpf_sock_addr struct to access socket fields and sockaddr struct passed
3988 * by user and intended to be used by socket (e.g. to bind to, depends on4064 * by user and intended to be used by socket (e.g. to bind to, depends on
3989 * attach attach type).4065 * attach type).
3990 */4066 */
3991struct bpf_sock_addr {4067struct bpf_sock_addr {
3992 __u32 user_family; /* Allows 4-byte read, but no write. */4068 __u32 user_family; /* Allows 4-byte read, but no write. */
@@ -4335,4 +4411,19 @@ struct bpf_pidns_info { · 342 unmodified lines
4335 __u32 pid;4411 __u32 pid;
4336 __u32 tgid;4412 __u32 tgid;
4337};4413};
4414
4415/* User accessible data for SK_LOOKUP programs. Add new fields at the end. */
4416struct bpf_sk_lookup {
4417 __bpf_md_ptr(struct bpf_sock *, sk); /* Selected socket */
4418
4419 __u32 family; /* Protocol family (AF_INET, AF_INET6) */
4420 __u32 protocol; /* IP protocol (IPPROTO_TCP, IPPROTO_UDP) */
4421 __u32 remote_ip4; /* Network byte order */
4422 __u32 remote_ip6[4]; /* Network byte order */
4423 __u32 remote_port; /* Network byte order */
4424 __u32 local_ip4; /* Network byte order */
4425 __u32 local_ip6[4]; /* Network byte order */
4426 __u32 local_port; /* Host byte order */
4427};
4428
4338#endif /* _UAPI__LINUX_BPF_H__ */4429#endif /* _UAPI__LINUX_BPF_H__ */