Commit ddf2bf8e authored by Brenden Blanco's avatar Brenden Blanco

Add bpf_tunnel_info and helpers

* Update compat.h
* Move bpf_clone_redirect to signed int, matching the implementation.
  This allows error codes to be compared to < 0.
Signed-off-by: default avatarBrenden Blanco <bblanco@plumgrid.com>
parent 62cc8b76
......@@ -258,6 +258,17 @@ enum bpf_func_id {
BPF_FUNC_get_cgroup_classid,
BPF_FUNC_skb_vlan_push, /* bpf_skb_vlan_push(skb, vlan_proto, vlan_tci) */
BPF_FUNC_skb_vlan_pop, /* bpf_skb_vlan_pop(skb) */
/**
* bpf_skb_[gs]et_tunnel_key(skb, struct bpf_tunnel_key *key, int size)
* retrieve or populate tunnel metadata
* @skb: pointer to skb
* @key: pointer to 'struct bpf_tunnel_key'
* @size: size of 'struct bpf_tunnel_key'
* Retrun: 0 on success
*/
BPF_FUNC_skb_get_tunnel_key,
BPF_FUNC_skb_set_tunnel_key,
__BPF_FUNC_MAX_ID,
};
......@@ -280,4 +291,9 @@ struct __sk_buff {
__u32 cb[5];
};
struct bpf_tunnel_key {
__u32 tunnel_id;
__u32 remote_ipv4;
};
#endif /* _UAPI__LINUX_BPF_H__ */
......@@ -64,7 +64,7 @@ static int (*bpf_trace_printk_)(const char *fmt, u64 fmt_size, ...) =
(void *) BPF_FUNC_trace_printk;
int bpf_trace_printk(const char *fmt, ...) asm("llvm.bpf.extra");
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)
static u64 (*bpf_clone_redirect)(void *ctx, u64 ifindex, u64 flags) =
static int (*bpf_clone_redirect)(void *ctx, u64 ifindex, u64 flags) =
(void *) BPF_FUNC_clone_redirect;
static u64 (*bpf_get_smp_processor_id)(void) =
(void *) BPF_FUNC_get_smp_processor_id;
......@@ -83,6 +83,10 @@ static u64 (*bpf_skb_vlan_pop)(void *ctx) =
static void bpf_tail_call_(u64 map_fd, void *ctx, int index) {
((void (*)(void *, u64, int))BPF_FUNC_tail_call)(ctx, map_fd, index);
}
static int (*bpf_skb_get_tunnel_key)(void *ctx, void *to, u32 size) =
(void *) BPF_FUNC_skb_get_tunnel_key;
static int (*bpf_skb_set_tunnel_key)(void *ctx, void *from, u32 size) =
(void *) BPF_FUNC_skb_set_tunnel_key;
#endif
/* llvm builtin functions that eBPF C program may use to
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment