]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bpf: add new bpf.h header copy from 4.15 kernel
authorLennart Poettering <lennart@poettering.net>
Fri, 16 Feb 2018 10:53:06 +0000 (11:53 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 21 Feb 2018 15:43:36 +0000 (16:43 +0100)
src/shared/linux/bpf.h

index 8477b446097f1a05a7c8978a1eb6a99c94e7d83b..1df9e7e3d064c34bac1d4a87afdfa0a695ef5026 100644 (file)
@@ -1,11 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
 /* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of version 2 of the GNU General Public
  * License as published by the Free Software Foundation.
  */
-#ifndef __LINUX_BPF_H__
-#define __LINUX_BPF_H__
+#ifndef _UAPI__LINUX_BPF_H__
+#define _UAPI__LINUX_BPF_H__
 
 #include <linux/types.h>
 #include <linux/bpf_common.h>
@@ -16,7 +17,7 @@
 #define BPF_ALU64      0x07    /* alu mode in double word width */
 
 /* ld/ldx fields */
-#define BPF_DW         0x18    /* double word */
+#define BPF_DW         0x18    /* double word (64-bit) */
 #define BPF_XADD       0xc0    /* exclusive add */
 
 /* alu/jmp fields */
 #define BPF_FROM_LE    BPF_TO_LE
 #define BPF_FROM_BE    BPF_TO_BE
 
+/* jmp encodings */
 #define BPF_JNE                0x50    /* jump != */
+#define BPF_JLT                0xa0    /* LT is unsigned, '<' */
+#define BPF_JLE                0xb0    /* LE is unsigned, '<=' */
 #define BPF_JSGT       0x60    /* SGT is signed '>', GT in x86 */
 #define BPF_JSGE       0x70    /* SGE is signed '>=', GE in x86 */
+#define BPF_JSLT       0xc0    /* SLT is signed, '<' */
+#define BPF_JSLE       0xd0    /* SLE is signed, '<=' */
 #define BPF_CALL       0x80    /* function call */
 #define BPF_EXIT       0x90    /* function return */
 
@@ -82,6 +88,12 @@ enum bpf_cmd {
         BPF_PROG_ATTACH,
         BPF_PROG_DETACH,
         BPF_PROG_TEST_RUN,
+        BPF_PROG_GET_NEXT_ID,
+        BPF_MAP_GET_NEXT_ID,
+        BPF_PROG_GET_FD_BY_ID,
+        BPF_MAP_GET_FD_BY_ID,
+        BPF_OBJ_GET_INFO_BY_FD,
+        BPF_PROG_QUERY,
 };
 
 enum bpf_map_type {
@@ -99,6 +111,9 @@ enum bpf_map_type {
         BPF_MAP_TYPE_LPM_TRIE,
         BPF_MAP_TYPE_ARRAY_OF_MAPS,
         BPF_MAP_TYPE_HASH_OF_MAPS,
+        BPF_MAP_TYPE_DEVMAP,
+        BPF_MAP_TYPE_SOCKMAP,
+        BPF_MAP_TYPE_CPUMAP,
 };
 
 enum bpf_prog_type {
@@ -115,22 +130,65 @@ enum bpf_prog_type {
         BPF_PROG_TYPE_LWT_IN,
         BPF_PROG_TYPE_LWT_OUT,
         BPF_PROG_TYPE_LWT_XMIT,
+        BPF_PROG_TYPE_SOCK_OPS,
+        BPF_PROG_TYPE_SK_SKB,
+        BPF_PROG_TYPE_CGROUP_DEVICE,
 };
 
 enum bpf_attach_type {
         BPF_CGROUP_INET_INGRESS,
         BPF_CGROUP_INET_EGRESS,
         BPF_CGROUP_INET_SOCK_CREATE,
+        BPF_CGROUP_SOCK_OPS,
+        BPF_SK_SKB_STREAM_PARSER,
+        BPF_SK_SKB_STREAM_VERDICT,
+        BPF_CGROUP_DEVICE,
         __MAX_BPF_ATTACH_TYPE
 };
 
 #define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE
 
-/* If BPF_F_ALLOW_OVERRIDE flag is used in BPF_PROG_ATTACH command
- * to the given target_fd cgroup the descendent cgroup will be able to
- * override effective bpf program that was inherited from this cgroup
+/* cgroup-bpf attach flags used in BPF_PROG_ATTACH command
+ *
+ * NONE(default): No further bpf programs allowed in the subtree.
+ *
+ * BPF_F_ALLOW_OVERRIDE: If a sub-cgroup installs some bpf program,
+ * the program in this cgroup yields to sub-cgroup program.
+ *
+ * BPF_F_ALLOW_MULTI: If a sub-cgroup installs some bpf program,
+ * that cgroup program gets run in addition to the program in this cgroup.
+ *
+ * Only one program is allowed to be attached to a cgroup with
+ * NONE or BPF_F_ALLOW_OVERRIDE flag.
+ * Attaching another program on top of NONE or BPF_F_ALLOW_OVERRIDE will
+ * release old program and attach the new one. Attach flags has to match.
+ *
+ * Multiple programs are allowed to be attached to a cgroup with
+ * BPF_F_ALLOW_MULTI flag. They are executed in FIFO order
+ * (those that were attached first, run first)
+ * The programs of sub-cgroup are executed first, then programs of
+ * this cgroup and then programs of parent cgroup.
+ * When children program makes decision (like picking TCP CA or sock bind)
+ * parent program has a chance to override it.
+ *
+ * A cgroup with MULTI or OVERRIDE flag allows any attach flags in sub-cgroups.
+ * A cgroup with NONE doesn't allow any programs in sub-cgroups.
+ * Ex1:
+ * cgrp1 (MULTI progs A, B) ->
+ *    cgrp2 (OVERRIDE prog C) ->
+ *      cgrp3 (MULTI prog D) ->
+ *        cgrp4 (OVERRIDE prog E) ->
+ *          cgrp5 (NONE prog F)
+ * the event in cgrp5 triggers execution of F,D,A,B in that order.
+ * if prog F is detached, the execution is E,D,A,B
+ * if prog F and D are detached, the execution is E,A,B
+ * if prog F, E and D are detached, the execution is C,A,B
+ *
+ * All eligible programs are executed regardless of return code from
+ * earlier programs.
  */
 #define BPF_F_ALLOW_OVERRIDE   (1U << 0)
+#define BPF_F_ALLOW_MULTI      (1U << 1)
 
 /* If BPF_F_STRICT_ALIGNMENT is used in BPF_PROG_LOAD command, the
  * verifier will perform strict alignment checking as if the kernel
@@ -139,13 +197,20 @@ enum bpf_attach_type {
  */
 #define BPF_F_STRICT_ALIGNMENT (1U << 0)
 
+/* when bpf_ldimm64->src_reg == BPF_PSEUDO_MAP_FD, bpf_ldimm64->imm == fd */
 #define BPF_PSEUDO_MAP_FD      1
 
+/* when bpf_call->src_reg == BPF_PSEUDO_CALL, bpf_call->imm == pc-relative
+ * offset to another bpf function
+ */
+#define BPF_PSEUDO_CALL                1
+
 /* flags for BPF_MAP_UPDATE_ELEM command */
 #define BPF_ANY                0 /* create new element or update existing */
 #define BPF_NOEXIST    1 /* create new element if it didn't exist */
 #define BPF_EXIST      2 /* update existing element */
 
+/* flags for BPF_MAP_CREATE command */
 #define BPF_F_NO_PREALLOC      (1U << 0)
 /* Instead of having one common LRU list in the
  * BPF_MAP_TYPE_LRU_[PERCPU_]HASH map, use a percpu LRU list
@@ -154,6 +219,17 @@ enum bpf_attach_type {
  * across different LRU lists.
  */
 #define BPF_F_NO_COMMON_LRU    (1U << 1)
+/* Specify numa node during map creation */
+#define BPF_F_NUMA_NODE                (1U << 2)
+
+/* flags for BPF_PROG_QUERY */
+#define BPF_F_QUERY_EFFECTIVE  (1U << 0)
+
+#define BPF_OBJ_NAME_LEN 16U
+
+/* Flags for accessing BPF object */
+#define BPF_F_RDONLY           (1U << 3)
+#define BPF_F_WRONLY           (1U << 4)
 
 union bpf_attr {
         struct { /* anonymous struct used by BPF_MAP_CREATE command */
@@ -161,8 +237,15 @@ union bpf_attr {
                 __u32  key_size;       /* size of key in bytes */
                 __u32  value_size;     /* size of value in bytes */
                 __u32  max_entries;    /* max number of entries in a map */
-                __u32  map_flags;      /* prealloc or not */
+                __u32  map_flags;      /* BPF_MAP_CREATE related
+                                         * flags defined above.
+                                         */
                 __u32  inner_map_fd;   /* fd pointing to the inner map */
+                __u32  numa_node;      /* numa node (effective only if
+                                         * BPF_F_NUMA_NODE is set).
+                                         */
+                char   map_name[BPF_OBJ_NAME_LEN];
+                __u32  map_ifindex;    /* ifindex of netdev to create on */
         };
 
         struct { /* anonymous struct used by BPF_MAP_*_ELEM commands */
@@ -185,11 +268,14 @@ union bpf_attr {
                 __aligned_u64  log_buf;        /* user supplied buffer */
                 __u32          kern_version;   /* checked when prog_type=kprobe */
                 __u32          prog_flags;
+                char           prog_name[BPF_OBJ_NAME_LEN];
+                __u32          prog_ifindex;   /* ifindex of netdev to prep for */
         };
 
         struct { /* anonymous struct used by BPF_OBJ_* commands */
                 __aligned_u64  pathname;
                 __u32          bpf_fd;
+                __u32          file_flags;
         };
 
         struct { /* anonymous struct used by BPF_PROG_ATTACH/DETACH commands */
@@ -209,6 +295,31 @@ union bpf_attr {
                 __u32          repeat;
                 __u32          duration;
         } test;
+
+        struct { /* anonymous struct used by BPF_*_GET_*_ID */
+                union {
+                        __u32          start_id;
+                        __u32          prog_id;
+                        __u32          map_id;
+                };
+                __u32          next_id;
+                __u32          open_flags;
+        };
+
+        struct { /* anonymous struct used by BPF_OBJ_GET_INFO_BY_FD */
+                __u32          bpf_fd;
+                __u32          info_len;
+                __aligned_u64  info;
+        } info;
+
+        struct { /* anonymous struct used by BPF_PROG_QUERY command */
+                __u32          target_fd;      /* container object to query */
+                __u32          attach_type;
+                __u32          query_flags;
+                __u32          attach_flags;
+                __aligned_u64  prog_ids;
+                __u32          prog_cnt;
+        } query;
 } __attribute__((aligned(8)));
 
 /* BPF helper function descriptions:
@@ -272,7 +383,7 @@ union bpf_attr {
  *     jump into another BPF program
  *     @ctx: context pointer passed to next program
  *     @prog_array_map: pointer to map which type is BPF_MAP_TYPE_PROG_ARRAY
- *     @index: index inside array that selects specific program to run
+ *     @index: 32-bit index inside array that selects specific program to run
  *     Return: 0 on success or negative error
  *
  * int bpf_clone_redirect(skb, ifindex, flags)
@@ -313,26 +424,40 @@ union bpf_attr {
  *     @flags: room for future extensions
  *     Return: 0 on success or negative error
  *
- * u64 bpf_perf_event_read(&map, index)
- *     Return: Number events read or error code
+ * u64 bpf_perf_event_read(map, flags)
+ *     read perf event counter value
+ *     @map: pointer to perf_event_array map
+ *     @flags: index of event in the map or bitmask flags
+ *     Return: value of perf event counter read or error code
  *
  * int bpf_redirect(ifindex, flags)
  *     redirect to another netdev
  *     @ifindex: ifindex of the net device
- *     @flags: bit 0 - if set, redirect to ingress instead of egress
- *             other bits - reserved
- *     Return: TC_ACT_REDIRECT
+ *     @flags:
+ *       cls_bpf:
+ *          bit 0 - if set, redirect to ingress instead of egress
+ *          other bits - reserved
+ *       xdp_bpf:
+ *         all bits - reserved
+ *     Return: cls_bpf: TC_ACT_REDIRECT on success or TC_ACT_SHOT on error
+ *            xdp_bfp: XDP_REDIRECT on success or XDP_ABORT on error
+ * int bpf_redirect_map(map, key, flags)
+ *     redirect to endpoint in map
+ *     @map: pointer to dev map
+ *     @key: index in map to lookup
+ *     @flags: --
+ *     Return: XDP_REDIRECT on success or XDP_ABORT on error
  *
  * u32 bpf_get_route_realm(skb)
  *     retrieve a dst's tclassid
  *     @skb: pointer to skb
  *     Return: realm if != 0
  *
- * int bpf_perf_event_output(ctx, map, index, data, size)
+ * int bpf_perf_event_output(ctx, map, flags, data, size)
  *     output perf raw sample
  *     @ctx: struct pt_regs*
  *     @map: pointer to perf_event_array map
- *     @index: index of event in the map
+ *     @flags: index of event in the map or bitmask flags
  *     @data: data on stack to be output as raw data
  *     @size: size of data
  *     Return: 0 on success or negative error
@@ -490,6 +615,87 @@ union bpf_attr {
  *     Get the owner uid of the socket stored inside sk_buff.
  *     @skb: pointer to skb
  *     Return: uid of the socket owner on success or overflowuid if failed.
+ *
+ * u32 bpf_set_hash(skb, hash)
+ *     Set full skb->hash.
+ *     @skb: pointer to skb
+ *     @hash: hash to set
+ *
+ * int bpf_setsockopt(bpf_socket, level, optname, optval, optlen)
+ *     Calls setsockopt. Not all opts are available, only those with
+ *     integer optvals plus TCP_CONGESTION.
+ *     Supported levels: SOL_SOCKET and IPPROTO_TCP
+ *     @bpf_socket: pointer to bpf_socket
+ *     @level: SOL_SOCKET or IPPROTO_TCP
+ *     @optname: option name
+ *     @optval: pointer to option value
+ *     @optlen: length of optval in bytes
+ *     Return: 0 or negative error
+ *
+ * int bpf_getsockopt(bpf_socket, level, optname, optval, optlen)
+ *     Calls getsockopt. Not all opts are available.
+ *     Supported levels: IPPROTO_TCP
+ *     @bpf_socket: pointer to bpf_socket
+ *     @level: IPPROTO_TCP
+ *     @optname: option name
+ *     @optval: pointer to option value
+ *     @optlen: length of optval in bytes
+ *     Return: 0 or negative error
+ *
+ * int bpf_sock_ops_cb_flags_set(bpf_sock_ops, flags)
+ *     Set callback flags for sock_ops
+ *     @bpf_sock_ops: pointer to bpf_sock_ops_kern struct
+ *     @flags: flags value
+ *     Return: 0 for no error
+ *             -EINVAL if there is no full tcp socket
+ *             bits in flags that are not supported by current kernel
+ *
+ * int bpf_skb_adjust_room(skb, len_diff, mode, flags)
+ *     Grow or shrink room in sk_buff.
+ *     @skb: pointer to skb
+ *     @len_diff: (signed) amount of room to grow/shrink
+ *     @mode: operation mode (enum bpf_adj_room_mode)
+ *     @flags: reserved for future use
+ *     Return: 0 on success or negative error code
+ *
+ * int bpf_sk_redirect_map(map, key, flags)
+ *     Redirect skb to a sock in map using key as a lookup key for the
+ *     sock in map.
+ *     @map: pointer to sockmap
+ *     @key: key to lookup sock in map
+ *     @flags: reserved for future use
+ *     Return: SK_PASS
+ *
+ * int bpf_sock_map_update(skops, map, key, flags)
+ *     @skops: pointer to bpf_sock_ops
+ *     @map: pointer to sockmap to update
+ *     @key: key to insert/update sock in map
+ *     @flags: same flags as map update elem
+ *
+ * int bpf_xdp_adjust_meta(xdp_md, delta)
+ *     Adjust the xdp_md.data_meta by delta
+ *     @xdp_md: pointer to xdp_md
+ *     @delta: An positive/negative integer to be added to xdp_md.data_meta
+ *     Return: 0 on success or negative on error
+ *
+ * int bpf_perf_event_read_value(map, flags, buf, buf_size)
+ *     read perf event counter value and perf event enabled/running time
+ *     @map: pointer to perf_event_array map
+ *     @flags: index of event in the map or bitmask flags
+ *     @buf: buf to fill
+ *     @buf_size: size of the buf
+ *     Return: 0 on success or negative error code
+ *
+ * int bpf_perf_prog_read_value(ctx, buf, buf_size)
+ *     read perf prog attached perf event counter and enabled/running time
+ *     @ctx: pointer to ctx
+ *     @buf: buf to fill
+ *     @buf_size: size of the buf
+ *     Return : 0 on success or negative error code
+ *
+ * int bpf_override_return(pt_regs, rc)
+ *     @pt_regs: pointer to struct pt_regs
+ *     @rc: the return value to set
  */
 #define __BPF_FUNC_MAPPER(FN)          \
         FN(unspec),                    \
@@ -539,7 +745,19 @@ union bpf_attr {
         FN(xdp_adjust_head),           \
         FN(probe_read_str),            \
         FN(get_socket_cookie),         \
-        FN(get_socket_uid),
+        FN(get_socket_uid),            \
+        FN(set_hash),                  \
+        FN(setsockopt),                        \
+        FN(skb_adjust_room),           \
+        FN(redirect_map),              \
+        FN(sk_redirect_map),           \
+        FN(sock_map_update),           \
+        FN(xdp_adjust_meta),           \
+        FN(perf_event_read_value),     \
+        FN(perf_prog_read_value),      \
+        FN(getsockopt),                        \
+        FN(override_return),           \
+        FN(sock_ops_cb_flags_set),
 
 /* integer value in 'imm' field of BPF_CALL instruction selects which helper
  * function eBPF program intends to call
@@ -583,12 +801,19 @@ enum bpf_func_id {
 #define BPF_F_ZERO_CSUM_TX             (1ULL << 1)
 #define BPF_F_DONT_FRAGMENT            (1ULL << 2)
 
-/* BPF_FUNC_perf_event_output and BPF_FUNC_perf_event_read flags. */
+/* BPF_FUNC_perf_event_output, BPF_FUNC_perf_event_read and
+ * BPF_FUNC_perf_event_read_value flags.
+ */
 #define BPF_F_INDEX_MASK               0xffffffffULL
 #define BPF_F_CURRENT_CPU              BPF_F_INDEX_MASK
 /* BPF_FUNC_perf_event_output for sk_buff input context. */
 #define BPF_F_CTXLEN_MASK              (0xfffffULL << 32)
 
+/* Mode for BPF_FUNC_skb_adjust_room helper. */
+enum bpf_adj_room_mode {
+        BPF_ADJ_ROOM_NET,
+};
+
 /* user accessible mirror of in-kernel sk_buff.
  * new fields can only be added to the end of this structure
  */
@@ -611,6 +836,18 @@ struct __sk_buff {
         __u32 data;
         __u32 data_end;
         __u32 napi_id;
+
+        /* Accessed by BPF_PROG_TYPE_sk_skb types from here to ... */
+        __u32 family;
+        __u32 remote_ip4;      /* Stored in network byte order */
+        __u32 local_ip4;       /* Stored in network byte order */
+        __u32 remote_ip6[4];   /* Stored in network byte order */
+        __u32 local_ip6[4];    /* Stored in network byte order */
+        __u32 remote_port;     /* Stored in network byte order */
+        __u32 local_port;      /* stored in host byte order */
+        /* ... here. */
+
+        __u32 data_meta;
 };
 
 struct bpf_tunnel_key {
@@ -646,20 +883,23 @@ struct bpf_sock {
         __u32 family;
         __u32 type;
         __u32 protocol;
+        __u32 mark;
+        __u32 priority;
 };
 
 #define XDP_PACKET_HEADROOM 256
 
 /* User return codes for XDP prog type.
  * A valid XDP program must return one of these defined values. All other
- * return codes are reserved for future use. Unknown return codes will result
- * in packet drop.
+ * return codes are reserved for future use. Unknown return codes will
+ * result in packet drops and a warning via bpf_warn_invalid_xdp_action().
  */
 enum xdp_action {
         XDP_ABORTED = 0,
         XDP_DROP,
         XDP_PASS,
         XDP_TX,
+        XDP_REDIRECT,
 };
 
 /* user accessible metadata for XDP packet hook
@@ -668,6 +908,202 @@ enum xdp_action {
 struct xdp_md {
         __u32 data;
         __u32 data_end;
+        __u32 data_meta;
+        /* Below access go through struct xdp_rxq_info */
+        __u32 ingress_ifindex; /* rxq->dev->ifindex */
+        __u32 rx_queue_index;  /* rxq->queue_index  */
+};
+
+enum sk_action {
+        SK_DROP = 0,
+        SK_PASS,
+};
+
+#define BPF_TAG_SIZE   8
+
+struct bpf_prog_info {
+        __u32 type;
+        __u32 id;
+        __u8  tag[BPF_TAG_SIZE];
+        __u32 jited_prog_len;
+        __u32 xlated_prog_len;
+        __aligned_u64 jited_prog_insns;
+        __aligned_u64 xlated_prog_insns;
+        __u64 load_time;       /* ns since boottime */
+        __u32 created_by_uid;
+        __u32 nr_map_ids;
+        __aligned_u64 map_ids;
+        char name[BPF_OBJ_NAME_LEN];
+        __u32 ifindex;
+        __u64 netns_dev;
+        __u64 netns_ino;
+} __attribute__((aligned(8)));
+
+struct bpf_map_info {
+        __u32 type;
+        __u32 id;
+        __u32 key_size;
+        __u32 value_size;
+        __u32 max_entries;
+        __u32 map_flags;
+        char  name[BPF_OBJ_NAME_LEN];
+        __u32 ifindex;
+        __u64 netns_dev;
+        __u64 netns_ino;
+} __attribute__((aligned(8)));
+
+/* User bpf_sock_ops struct to access socket values and specify request ops
+ * and their replies.
+ * Some of this fields are in network (bigendian) byte order and may need
+ * to be converted before use (bpf_ntohl() defined in samples/bpf/bpf_endian.h).
+ * New fields can only be added at the end of this structure
+ */
+struct bpf_sock_ops {
+        __u32 op;
+        union {
+                __u32 args[4];         /* Optionally passed to bpf program */
+                __u32 reply;           /* Returned by bpf program          */
+                __u32 replylong[4];    /* Optionally returned by bpf prog  */
+        };
+        __u32 family;
+        __u32 remote_ip4;      /* Stored in network byte order */
+        __u32 local_ip4;       /* Stored in network byte order */
+        __u32 remote_ip6[4];   /* Stored in network byte order */
+        __u32 local_ip6[4];    /* Stored in network byte order */
+        __u32 remote_port;     /* Stored in network byte order */
+        __u32 local_port;      /* stored in host byte order */
+        __u32 is_fullsock;     /* Some TCP fields are only valid if
+                                 * there is a full socket. If not, the
+                                 * fields read as zero.
+                                 */
+        __u32 snd_cwnd;
+        __u32 srtt_us;         /* Averaged RTT << 3 in usecs */
+        __u32 bpf_sock_ops_cb_flags; /* flags defined in uapi/linux/tcp.h */
+        __u32 state;
+        __u32 rtt_min;
+        __u32 snd_ssthresh;
+        __u32 rcv_nxt;
+        __u32 snd_nxt;
+        __u32 snd_una;
+        __u32 mss_cache;
+        __u32 ecn_flags;
+        __u32 rate_delivered;
+        __u32 rate_interval_us;
+        __u32 packets_out;
+        __u32 retrans_out;
+        __u32 total_retrans;
+        __u32 segs_in;
+        __u32 data_segs_in;
+        __u32 segs_out;
+        __u32 data_segs_out;
+        __u32 lost_out;
+        __u32 sacked_out;
+        __u32 sk_txhash;
+        __u64 bytes_received;
+        __u64 bytes_acked;
+};
+
+/* Definitions for bpf_sock_ops_cb_flags */
+#define BPF_SOCK_OPS_RTO_CB_FLAG       (1<<0)
+#define BPF_SOCK_OPS_RETRANS_CB_FLAG   (1<<1)
+#define BPF_SOCK_OPS_STATE_CB_FLAG     (1<<2)
+#define BPF_SOCK_OPS_ALL_CB_FLAGS       0x7            /* Mask of all currently
+                                                         * supported cb flags
+                                                         */
+
+/* List of known BPF sock_ops operators.
+ * New entries can only be added at the end
+ */
+enum {
+        BPF_SOCK_OPS_VOID,
+        BPF_SOCK_OPS_TIMEOUT_INIT,     /* Should return SYN-RTO value to use or
+                                         * -1 if default value should be used
+                                         */
+        BPF_SOCK_OPS_RWND_INIT,                /* Should return initial advertized
+                                         * window (in packets) or -1 if default
+                                         * value should be used
+                                         */
+        BPF_SOCK_OPS_TCP_CONNECT_CB,   /* Calls BPF program right before an
+                                         * active connection is initialized
+                                         */
+        BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB,    /* Calls BPF program when an
+                                                 * active connection is
+                                                 * established
+                                                 */
+        BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB,   /* Calls BPF program when a
+                                                 * passive connection is
+                                                 * established
+                                                 */
+        BPF_SOCK_OPS_NEEDS_ECN,                /* If connection's congestion control
+                                         * needs ECN
+                                         */
+        BPF_SOCK_OPS_BASE_RTT,         /* Get base RTT. The correct value is
+                                         * based on the path and may be
+                                         * dependent on the congestion control
+                                         * algorithm. In general it indicates
+                                         * a congestion threshold. RTTs above
+                                         * this indicate congestion
+                                         */
+        BPF_SOCK_OPS_RTO_CB,           /* Called when an RTO has triggered.
+                                         * Arg1: value of icsk_retransmits
+                                         * Arg2: value of icsk_rto
+                                         * Arg3: whether RTO has expired
+                                         */
+        BPF_SOCK_OPS_RETRANS_CB,       /* Called when skb is retransmitted.
+                                         * Arg1: sequence number of 1st byte
+                                         * Arg2: # segments
+                                         * Arg3: return value of
+                                         *       tcp_transmit_skb (0 => success)
+                                         */
+        BPF_SOCK_OPS_STATE_CB,         /* Called when TCP changes state.
+                                         * Arg1: old_state
+                                         * Arg2: new_state
+                                         */
+};
+
+/* List of TCP states. There is a build check in net/ipv4/tcp.c to detect
+ * changes between the TCP and BPF versions. Ideally this should never happen.
+ * If it does, we need to add code to convert them before calling
+ * the BPF sock_ops function.
+ */
+enum {
+        BPF_TCP_ESTABLISHED = 1,
+        BPF_TCP_SYN_SENT,
+        BPF_TCP_SYN_RECV,
+        BPF_TCP_FIN_WAIT1,
+        BPF_TCP_FIN_WAIT2,
+        BPF_TCP_TIME_WAIT,
+        BPF_TCP_CLOSE,
+        BPF_TCP_CLOSE_WAIT,
+        BPF_TCP_LAST_ACK,
+        BPF_TCP_LISTEN,
+        BPF_TCP_CLOSING,       /* Now a valid state */
+        BPF_TCP_NEW_SYN_RECV,
+
+        BPF_TCP_MAX_STATES     /* Leave at the end! */
+};
+
+#define TCP_BPF_IW             1001    /* Set TCP initial congestion window */
+#define TCP_BPF_SNDCWND_CLAMP  1002    /* Set sndcwnd_clamp */
+
+struct bpf_perf_event_value {
+        __u64 counter;
+        __u64 enabled;
+        __u64 running;
+};
+
+#define BPF_DEVCG_ACC_MKNOD    (1ULL << 0)
+#define BPF_DEVCG_ACC_READ     (1ULL << 1)
+#define BPF_DEVCG_ACC_WRITE    (1ULL << 2)
+
+#define BPF_DEVCG_DEV_BLOCK    (1ULL << 0)
+#define BPF_DEVCG_DEV_CHAR     (1ULL << 1)
+
+struct bpf_cgroup_dev_ctx {
+        /* access_type encoded as (BPF_DEVCG_ACC_* << 16) | BPF_DEVCG_DEV_* */
+        __u32 access_type;
+        __u32 major;
+        __u32 minor;
 };
 
-#endif /* __LINUX_BPF_H__ */
+#endif /* _UAPI__LINUX_BPF_H__ */