bpf: support flow label for bpf_skb_{set, get}_tunnel_key
[cascardo/linux.git] / include / uapi / linux / bpf.h
index aa6f857..924f537 100644 (file)
@@ -81,6 +81,9 @@ enum bpf_map_type {
        BPF_MAP_TYPE_ARRAY,
        BPF_MAP_TYPE_PROG_ARRAY,
        BPF_MAP_TYPE_PERF_EVENT_ARRAY,
+       BPF_MAP_TYPE_PERCPU_HASH,
+       BPF_MAP_TYPE_PERCPU_ARRAY,
+       BPF_MAP_TYPE_STACK_TRACE,
 };
 
 enum bpf_prog_type {
@@ -98,12 +101,15 @@ enum bpf_prog_type {
 #define BPF_NOEXIST    1 /* create new element if it didn't exist */
 #define BPF_EXIST      2 /* update existing element */
 
+#define BPF_F_NO_PREALLOC      (1U << 0)
+
 union bpf_attr {
        struct { /* anonymous struct used by BPF_MAP_CREATE command */
                __u32   map_type;       /* one of enum bpf_map_type */
                __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 */
        };
 
        struct { /* anonymous struct used by BPF_MAP_*_ELEM commands */
@@ -270,6 +276,42 @@ enum bpf_func_id {
         */
        BPF_FUNC_perf_event_output,
        BPF_FUNC_skb_load_bytes,
+
+       /**
+        * bpf_get_stackid(ctx, map, flags) - walk user or kernel stack and return id
+        * @ctx: struct pt_regs*
+        * @map: pointer to stack_trace map
+        * @flags: bits 0-7 - numer of stack frames to skip
+        *         bit 8 - collect user stack instead of kernel
+        *         bit 9 - compare stacks by hash only
+        *         bit 10 - if two different stacks hash into the same stackid
+        *                  discard old
+        *         other bits - reserved
+        * Return: >= 0 stackid on success or negative error
+        */
+       BPF_FUNC_get_stackid,
+
+       /**
+        * bpf_csum_diff(from, from_size, to, to_size, seed) - calculate csum diff
+        * @from: raw from buffer
+        * @from_size: length of from buffer
+        * @to: raw to buffer
+        * @to_size: length of to buffer
+        * @seed: optional seed
+        * Return: csum result
+        */
+       BPF_FUNC_csum_diff,
+
+       /**
+        * bpf_skb_[gs]et_tunnel_opt(skb, opt, size)
+        * retrieve or populate tunnel options metadata
+        * @skb: pointer to skb
+        * @opt: pointer to raw tunnel option data
+        * @size: size of @opt
+        * Return: 0 on success for set, option size for get
+        */
+       BPF_FUNC_skb_get_tunnel_opt,
+       BPF_FUNC_skb_set_tunnel_opt,
        __BPF_FUNC_MAX_ID,
 };
 
@@ -277,6 +319,7 @@ enum bpf_func_id {
 
 /* BPF_FUNC_skb_store_bytes flags. */
 #define BPF_F_RECOMPUTE_CSUM           (1ULL << 0)
+#define BPF_F_INVALIDATE_HASH          (1ULL << 1)
 
 /* BPF_FUNC_l3_csum_replace and BPF_FUNC_l4_csum_replace flags.
  * First 4 bits are for passing the header field size.
@@ -285,6 +328,7 @@ enum bpf_func_id {
 
 /* BPF_FUNC_l4_csum_replace flags. */
 #define BPF_F_PSEUDO_HDR               (1ULL << 4)
+#define BPF_F_MARK_MANGLED_0           (1ULL << 5)
 
 /* BPF_FUNC_clone_redirect and BPF_FUNC_redirect flags. */
 #define BPF_F_INGRESS                  (1ULL << 0)
@@ -292,6 +336,16 @@ enum bpf_func_id {
 /* BPF_FUNC_skb_set_tunnel_key and BPF_FUNC_skb_get_tunnel_key flags. */
 #define BPF_F_TUNINFO_IPV6             (1ULL << 0)
 
+/* BPF_FUNC_get_stackid flags. */
+#define BPF_F_SKIP_FIELD_MASK          0xffULL
+#define BPF_F_USER_STACK               (1ULL << 8)
+#define BPF_F_FAST_STACK_CMP           (1ULL << 9)
+#define BPF_F_REUSE_STACKID            (1ULL << 10)
+
+/* BPF_FUNC_skb_set_tunnel_key flags. */
+#define BPF_F_ZERO_CSUM_TX             (1ULL << 1)
+#define BPF_F_DONT_FRAGMENT            (1ULL << 2)
+
 /* user accessible mirror of in-kernel sk_buff.
  * new fields can only be added to the end of this structure
  */
@@ -321,6 +375,7 @@ struct bpf_tunnel_key {
        };
        __u8 tunnel_tos;
        __u8 tunnel_ttl;
+       __u32 tunnel_label;
 };
 
 #endif /* _UAPI__LINUX_BPF_H__ */