]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - tools/include/uapi/linux/bpf.h
bpf: add bpf_skb_adjust_room helper
[linux.git] / tools / include / uapi / linux / bpf.h
index 9b2c10b45733e4dc66d601ac2ea52fed65f3752d..ce2988be4f0eac843de17f563c360a795943f35e 100644 (file)
@@ -120,12 +120,14 @@ enum bpf_prog_type {
        BPF_PROG_TYPE_LWT_IN,
        BPF_PROG_TYPE_LWT_OUT,
        BPF_PROG_TYPE_LWT_XMIT,
+       BPF_PROG_TYPE_SOCK_OPS,
 };
 
 enum bpf_attach_type {
        BPF_CGROUP_INET_INGRESS,
        BPF_CGROUP_INET_EGRESS,
        BPF_CGROUP_INET_SOCK_CREATE,
+       BPF_CGROUP_SOCK_OPS,
        __MAX_BPF_ATTACH_TYPE
 };
 
@@ -513,6 +515,30 @@ 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 IPROTO_TCP
+ *     @bpf_socket: pointer to bpf_socket
+ *     @level: SOL_SOCKET or IPROTO_TCP
+ *     @optname: option name
+ *     @optval: pointer to option value
+ *     @optlen: length of optval in byes
+ *     Return: 0 or negative error
+ *
+ * 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
  */
 #define __BPF_FUNC_MAPPER(FN)          \
        FN(unspec),                     \
@@ -562,7 +588,10 @@ 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),
 
 /* integer value in 'imm' field of BPF_CALL instruction selects which helper
  * function eBPF program intends to call
@@ -612,6 +641,11 @@ enum bpf_func_id {
 /* 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_OPTS,
+};
+
 /* user accessible mirror of in-kernel sk_buff.
  * new fields can only be added to the end of this structure
  */
@@ -714,4 +748,54 @@ struct bpf_map_info {
        __u32 map_flags;
 } __attribute__((aligned(8)));
 
+/* User bpf_sock_ops struct to access socket values and specify request ops
+ * and their replies.
+ * New fields can only be added at the end of this structure
+ */
+struct bpf_sock_ops {
+       __u32 op;
+       union {
+               __u32 reply;
+               __u32 replylong[4];
+       };
+       __u32 family;
+       __u32 remote_ip4;
+       __u32 local_ip4;
+       __u32 remote_ip6[4];
+       __u32 local_ip6[4];
+       __u32 remote_port;
+       __u32 local_port;
+};
+
+/* 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
+                                        */
+};
+
+#define TCP_BPF_IW             1001    /* Set TCP initial congestion window */
+#define TCP_BPF_SNDCWND_CLAMP  1002    /* Set sndcwnd_clamp */
+
 #endif /* _UAPI__LINUX_BPF_H__ */