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
189189 BPF_PROG_TYPE_STRUCT_OPS,
190190 BPF_PROG_TYPE_EXT,
191191 BPF_PROG_TYPE_LSM,
192+ BPF_PROG_TYPE_SK_LOOKUP,
192193 };
193194
194195 enum bpf_attach_type {
@@ -227,6 +228,8 @@ enum bpf_attach_type { · 32 unmodified lines
227228 BPF_CGROUP_INET6_GETSOCKNAME,
228229 BPF_XDP_DEVMAP,
229230 BPF_CGROUP_INET_SOCK_RELEASE,
231+ BPF_XDP_CPUMAP,
232+ BPF_SK_LOOKUP,
230233 __MAX_BPF_ATTACH_TYPE
231234 };
232235
@@ -2419,7 +2422,7 @@ union bpf_attr { · 2186 unmodified lines
24192422 * Look for an IPv6 socket.
24202423 *
24212424 * If the *netns* is a negative signed 32-bit integer, then the
2422− * socket lookup table in the netns associated with the *ctx* will
2425+ * socket lookup table in the netns associated with the *ctx*
24232426 * will be used. For the TC hooks, this is the netns of the device
24242427 * in the skb. For socket hooks, this is the netns of the socket.
24252428 * If *netns* is any other signed 32-bit value greater than or
@@ -2456,7 +2459,7 @@ union bpf_attr { · 30 unmodified lines
24562459 * Look for an IPv6 socket.
24572460 *
24582461 * If the *netns* is a negative signed 32-bit integer, then the
2459− * socket lookup table in the netns associated with the *ctx* will
2462+ * socket lookup table in the netns associated with the *ctx*
24602463 * will be used. For the TC hooks, this is the netns of the device
24612464 * in the skb. For socket hooks, this is the netns of the socket.
24622465 * If *netns* is any other signed 32-bit value greater than or
@@ -3068,6 +3071,10 @@ union bpf_attr { · 605 unmodified lines
30683071 *
30693072 * long bpf_sk_assign(struct sk_buff *skb, struct bpf_sock *sk, u64 flags)
30703073 * 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+ *
30713078 * Assign the *sk* to the *skb*. When combined with appropriate
30723079 * routing configuration to receive the packet towards the socket,
30733080 * will cause *skb* to be delivered to the specified socket.
@@ -3093,6 +3100,56 @@ union bpf_attr { · 19 unmodified lines
30933100 * **-ESOCKTNOSUPPORT** if the socket type is not supported
30943101 * (reuseport).
30953102 *
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+ *
30963153 * u64 bpf_ktime_get_boot_ns(void)
30973154 * Description
30983155 * Return the time elapsed since system boot, in nanoseconds.
@@ -3606,6 +3663,12 @@ enum { · 507 unmodified lines
36063663 BPF_RINGBUF_HDR_SZ = 8,
36073664 };
36083665
3666+/* BPF_FUNC_sk_assign flags in bpf_sk_lookup context. */
3667+enum {
3668+ BPF_SK_LOOKUP_F_REPLACE = (1ULL << 0),
3669+ BPF_SK_LOOKUP_F_NO_REUSEPORT = (1ULL << 1),
3670+};
3671+
36093672 /* Mode for BPF_FUNC_skb_adjust_room helper. */
36103673 enum bpf_adj_room_mode {
36113674 BPF_ADJ_ROOM_NET,
@@ -3849,6 +3912,19 @@ struct bpf_devmap_val { · 237 unmodified lines
38493912 } bpf_prog;
38503913 };
38513914
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+ */
3920+struct 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+
38523928 enum sk_action {
38533929 SK_DROP = 0,
38543930 SK_PASS,
@@ -3986,7 +4062,7 @@ struct bpf_link_info { · 131 unmodified lines
39864062
39874063 /* User bpf_sock_addr struct to access socket fields and sockaddr struct passed
39884064 * by user and intended to be used by socket (e.g. to bind to, depends on
3989− * attach attach type).
4065+ * attach type).
39904066 */
39914067 struct bpf_sock_addr {
39924068 __u32 user_family; /* Allows 4-byte read, but no write. */
@@ -4335,4 +4411,19 @@ struct bpf_pidns_info { · 342 unmodified lines
43354411 __u32 pid;
43364412 __u32 tgid;
43374413 };
4414+
4415+/* User accessible data for SK_LOOKUP programs. Add new fields at the end. */
4416+struct 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+
43384429 #endif /* _UAPI__LINUX_BPF_H__ */