aboutsummaryrefslogtreecommitdiffstats
path: root/include/uapi/linux/bpf.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/uapi/linux/bpf.h')
-rw-r--r--include/uapi/linux/bpf.h56
1 files changed, 37 insertions, 19 deletions
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index 852dc17ab47a..72c453a8bf50 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -2170,7 +2170,7 @@ union bpf_attr {
2170 * Return 2170 * Return
2171 * 0 on success, or a negative error in case of failure. 2171 * 0 on success, or a negative error in case of failure.
2172 * 2172 *
2173 * struct bpf_sock *bpf_sk_lookup_tcp(void *ctx, struct bpf_sock_tuple *tuple, u32 tuple_size, u32 netns, u64 flags) 2173 * struct bpf_sock *bpf_sk_lookup_tcp(void *ctx, struct bpf_sock_tuple *tuple, u32 tuple_size, u64 netns, u64 flags)
2174 * Description 2174 * Description
2175 * Look for TCP socket matching *tuple*, optionally in a child 2175 * Look for TCP socket matching *tuple*, optionally in a child
2176 * network namespace *netns*. The return value must be checked, 2176 * network namespace *netns*. The return value must be checked,
@@ -2187,12 +2187,14 @@ union bpf_attr {
2187 * **sizeof**\ (*tuple*\ **->ipv6**) 2187 * **sizeof**\ (*tuple*\ **->ipv6**)
2188 * Look for an IPv6 socket. 2188 * Look for an IPv6 socket.
2189 * 2189 *
2190 * If the *netns* is zero, then the socket lookup table in the 2190 * If the *netns* is a negative signed 32-bit integer, then the
2191 * netns associated with the *ctx* will be used. For the TC hooks, 2191 * socket lookup table in the netns associated with the *ctx* will
2192 * this in the netns of the device in the skb. For socket hooks, 2192 * will be used. For the TC hooks, this is the netns of the device
2193 * this in the netns of the socket. If *netns* is non-zero, then 2193 * in the skb. For socket hooks, this is the netns of the socket.
2194 * it specifies the ID of the netns relative to the netns 2194 * If *netns* is any other signed 32-bit value greater than or
2195 * associated with the *ctx*. 2195 * equal to zero then it specifies the ID of the netns relative to
2196 * the netns associated with the *ctx*. *netns* values beyond the
2197 * range of 32-bit integers are reserved for future use.
2196 * 2198 *
2197 * All values for *flags* are reserved for future usage, and must 2199 * All values for *flags* are reserved for future usage, and must
2198 * be left at zero. 2200 * be left at zero.
@@ -2201,8 +2203,10 @@ union bpf_attr {
2201 * **CONFIG_NET** configuration option. 2203 * **CONFIG_NET** configuration option.
2202 * Return 2204 * Return
2203 * Pointer to *struct bpf_sock*, or NULL in case of failure. 2205 * Pointer to *struct bpf_sock*, or NULL in case of failure.
2206 * For sockets with reuseport option, the *struct bpf_sock*
2207 * result is from reuse->socks[] using the hash of the tuple.
2204 * 2208 *
2205 * struct bpf_sock *bpf_sk_lookup_udp(void *ctx, struct bpf_sock_tuple *tuple, u32 tuple_size, u32 netns, u64 flags) 2209 * struct bpf_sock *bpf_sk_lookup_udp(void *ctx, struct bpf_sock_tuple *tuple, u32 tuple_size, u64 netns, u64 flags)
2206 * Description 2210 * Description
2207 * Look for UDP socket matching *tuple*, optionally in a child 2211 * Look for UDP socket matching *tuple*, optionally in a child
2208 * network namespace *netns*. The return value must be checked, 2212 * network namespace *netns*. The return value must be checked,
@@ -2219,12 +2223,14 @@ union bpf_attr {
2219 * **sizeof**\ (*tuple*\ **->ipv6**) 2223 * **sizeof**\ (*tuple*\ **->ipv6**)
2220 * Look for an IPv6 socket. 2224 * Look for an IPv6 socket.
2221 * 2225 *
2222 * If the *netns* is zero, then the socket lookup table in the 2226 * If the *netns* is a negative signed 32-bit integer, then the
2223 * netns associated with the *ctx* will be used. For the TC hooks, 2227 * socket lookup table in the netns associated with the *ctx* will
2224 * this in the netns of the device in the skb. For socket hooks, 2228 * will be used. For the TC hooks, this is the netns of the device
2225 * this in the netns of the socket. If *netns* is non-zero, then 2229 * in the skb. For socket hooks, this is the netns of the socket.
2226 * it specifies the ID of the netns relative to the netns 2230 * If *netns* is any other signed 32-bit value greater than or
2227 * associated with the *ctx*. 2231 * equal to zero then it specifies the ID of the netns relative to
2232 * the netns associated with the *ctx*. *netns* values beyond the
2233 * range of 32-bit integers are reserved for future use.
2228 * 2234 *
2229 * All values for *flags* are reserved for future usage, and must 2235 * All values for *flags* are reserved for future usage, and must
2230 * be left at zero. 2236 * be left at zero.
@@ -2233,6 +2239,8 @@ union bpf_attr {
2233 * **CONFIG_NET** configuration option. 2239 * **CONFIG_NET** configuration option.
2234 * Return 2240 * Return
2235 * Pointer to *struct bpf_sock*, or NULL in case of failure. 2241 * Pointer to *struct bpf_sock*, or NULL in case of failure.
2242 * For sockets with reuseport option, the *struct bpf_sock*
2243 * result is from reuse->socks[] using the hash of the tuple.
2236 * 2244 *
2237 * int bpf_sk_release(struct bpf_sock *sk) 2245 * int bpf_sk_release(struct bpf_sock *sk)
2238 * Description 2246 * Description
@@ -2405,6 +2413,9 @@ enum bpf_func_id {
2405/* BPF_FUNC_perf_event_output for sk_buff input context. */ 2413/* BPF_FUNC_perf_event_output for sk_buff input context. */
2406#define BPF_F_CTXLEN_MASK (0xfffffULL << 32) 2414#define BPF_F_CTXLEN_MASK (0xfffffULL << 32)
2407 2415
2416/* Current network namespace */
2417#define BPF_F_CURRENT_NETNS (-1L)
2418
2408/* Mode for BPF_FUNC_skb_adjust_room helper. */ 2419/* Mode for BPF_FUNC_skb_adjust_room helper. */
2409enum bpf_adj_room_mode { 2420enum bpf_adj_room_mode {
2410 BPF_ADJ_ROOM_NET, 2421 BPF_ADJ_ROOM_NET,
@@ -2422,6 +2433,12 @@ enum bpf_lwt_encap_mode {
2422 BPF_LWT_ENCAP_SEG6_INLINE 2433 BPF_LWT_ENCAP_SEG6_INLINE
2423}; 2434};
2424 2435
2436#define __bpf_md_ptr(type, name) \
2437union { \
2438 type name; \
2439 __u64 :64; \
2440} __attribute__((aligned(8)))
2441
2425/* user accessible mirror of in-kernel sk_buff. 2442/* user accessible mirror of in-kernel sk_buff.
2426 * new fields can only be added to the end of this structure 2443 * new fields can only be added to the end of this structure
2427 */ 2444 */
@@ -2456,7 +2473,7 @@ struct __sk_buff {
2456 /* ... here. */ 2473 /* ... here. */
2457 2474
2458 __u32 data_meta; 2475 __u32 data_meta;
2459 struct bpf_flow_keys *flow_keys; 2476 __bpf_md_ptr(struct bpf_flow_keys *, flow_keys);
2460}; 2477};
2461 2478
2462struct bpf_tunnel_key { 2479struct bpf_tunnel_key {
@@ -2572,8 +2589,8 @@ enum sk_action {
2572 * be added to the end of this structure 2589 * be added to the end of this structure
2573 */ 2590 */
2574struct sk_msg_md { 2591struct sk_msg_md {
2575 void *data; 2592 __bpf_md_ptr(void *, data);
2576 void *data_end; 2593 __bpf_md_ptr(void *, data_end);
2577 2594
2578 __u32 family; 2595 __u32 family;
2579 __u32 remote_ip4; /* Stored in network byte order */ 2596 __u32 remote_ip4; /* Stored in network byte order */
@@ -2589,8 +2606,9 @@ struct sk_reuseport_md {
2589 * Start of directly accessible data. It begins from 2606 * Start of directly accessible data. It begins from
2590 * the tcp/udp header. 2607 * the tcp/udp header.
2591 */ 2608 */
2592 void *data; 2609 __bpf_md_ptr(void *, data);
2593 void *data_end; /* End of directly accessible data */ 2610 /* End of directly accessible data */
2611 __bpf_md_ptr(void *, data_end);
2594 /* 2612 /*
2595 * Total length of packet (starting from the tcp/udp header). 2613 * Total length of packet (starting from the tcp/udp header).
2596 * Note that the directly accessible bytes (data_end - data) 2614 * Note that the directly accessible bytes (data_end - data)