From 4bcd220a1f0b78568a9633acde6ea7d6f019f1c5 Mon Sep 17 00:00:00 2001 From: Brenden Blanco Date: Thu, 5 Nov 2015 13:28:32 -0800 Subject: [PATCH] Change indentation in bpf/helpers.h Signed-off-by: Brenden Blanco --- src/cc/export/helpers.h | 86 ++++++++++++++++++++++++------------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/src/cc/export/helpers.h b/src/cc/export/helpers.h index cb2aa6c..5c916e6 100644 --- a/src/cc/export/helpers.h +++ b/src/cc/export/helpers.h @@ -79,76 +79,76 @@ unsigned _version SEC("version") = LINUX_VERSION_CODE; /* helper functions called from eBPF programs written in C */ static void *(*bpf_map_lookup_elem)(void *map, void *key) = - (void *) BPF_FUNC_map_lookup_elem; + (void *) BPF_FUNC_map_lookup_elem; static int (*bpf_map_update_elem)(void *map, void *key, void *value, u64 flags) = - (void *) BPF_FUNC_map_update_elem; + (void *) BPF_FUNC_map_update_elem; static int (*bpf_map_delete_elem)(void *map, void *key) = - (void *) BPF_FUNC_map_delete_elem; + (void *) BPF_FUNC_map_delete_elem; static int (*bpf_probe_read)(void *dst, u64 size, void *unsafe_ptr) = - (void *) BPF_FUNC_probe_read; + (void *) BPF_FUNC_probe_read; static u64 (*bpf_ktime_get_ns)(void) = - (void *) BPF_FUNC_ktime_get_ns; + (void *) BPF_FUNC_ktime_get_ns; static int (*bpf_trace_printk_)(const char *fmt, u64 fmt_size, ...) = - (void *) BPF_FUNC_trace_printk; + (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 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_clone_redirect)(void *ctx, u64 ifindex, u64 flags) = - (void *) BPF_FUNC_clone_redirect; +static int (*bpf_clone_redirect)(void *ctx, int ifindex, u32 flags) = + (void *) BPF_FUNC_clone_redirect; static u64 (*bpf_get_smp_processor_id)(void) = - (void *) BPF_FUNC_get_smp_processor_id; + (void *) BPF_FUNC_get_smp_processor_id; static u64 (*bpf_get_current_pid_tgid)(void) = - (void *) BPF_FUNC_get_current_pid_tgid; + (void *) BPF_FUNC_get_current_pid_tgid; static u64 (*bpf_get_current_uid_gid)(void) = - (void *) BPF_FUNC_get_current_uid_gid; + (void *) BPF_FUNC_get_current_uid_gid; static int (*bpf_get_current_comm)(void *buf, int buf_size) = - (void *) BPF_FUNC_get_current_comm; + (void *) BPF_FUNC_get_current_comm; +#endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0) static u64 (*bpf_get_cgroup_classid)(void *ctx) = - (void *) BPF_FUNC_get_cgroup_classid; + (void *) BPF_FUNC_get_cgroup_classid; static u64 (*bpf_skb_vlan_push)(void *ctx, u16 proto, u16 vlan_tci) = - (void *) BPF_FUNC_skb_vlan_push; + (void *) BPF_FUNC_skb_vlan_push; static u64 (*bpf_skb_vlan_pop)(void *ctx) = - (void *) BPF_FUNC_skb_vlan_pop; + (void *) BPF_FUNC_skb_vlan_pop; static int (*bpf_skb_get_tunnel_key)(void *ctx, void *to, u32 size, u64 flags) = (void *) BPF_FUNC_skb_get_tunnel_key; static int (*bpf_skb_set_tunnel_key)(void *ctx, void *from, u32 size, u64 flags) = (void *) BPF_FUNC_skb_set_tunnel_key; #endif -#endif /* llvm builtin functions that eBPF C program may use to * emit BPF_LD_ABS and BPF_LD_IND instructions */ struct sk_buff; unsigned long long load_byte(void *skb, - unsigned long long off) asm("llvm.bpf.load.byte"); + unsigned long long off) asm("llvm.bpf.load.byte"); unsigned long long load_half(void *skb, - unsigned long long off) asm("llvm.bpf.load.half"); + unsigned long long off) asm("llvm.bpf.load.half"); unsigned long long load_word(void *skb, - unsigned long long off) asm("llvm.bpf.load.word"); + unsigned long long off) asm("llvm.bpf.load.word"); /* a helper structure used by eBPF C program * to describe map attributes to elf_bpf loader */ struct bpf_map_def { - unsigned int type; - unsigned int key_size; - unsigned int value_size; - unsigned int max_entries; + unsigned int type; + unsigned int key_size; + unsigned int value_size; + unsigned int max_entries; }; static int (*bpf_skb_store_bytes)(void *ctx, unsigned long long off, void *from, - unsigned long long len, unsigned long long flags) = - (void *) BPF_FUNC_skb_store_bytes; + unsigned long long len, unsigned long long flags) = + (void *) BPF_FUNC_skb_store_bytes; static int (*bpf_l3_csum_replace)(void *ctx, unsigned long long off, unsigned long long from, - unsigned long long to, unsigned long long flags) = - (void *) BPF_FUNC_l3_csum_replace; + unsigned long long to, unsigned long long flags) = + (void *) BPF_FUNC_l3_csum_replace; static int (*bpf_l4_csum_replace)(void *ctx, unsigned long long off, unsigned long long from, - unsigned long long to, unsigned long long flags) = - (void *) BPF_FUNC_l4_csum_replace; + unsigned long long to, unsigned long long flags) = + (void *) BPF_FUNC_l4_csum_replace; static inline u16 bpf_ntohs(u16 val) { /* will be recognized by gcc into rotate insn and eventually rolw 8 */ @@ -201,24 +201,24 @@ static inline void bpf_store_dword(void *skb, u64 off, u64 val) { static unsigned int bpf_log2(unsigned int v) { - unsigned int r; - unsigned int shift; - - r = (v > 0xFFFF) << 4; v >>= r; - shift = (v > 0xFF) << 3; v >>= shift; r |= shift; - shift = (v > 0xF) << 2; v >>= shift; r |= shift; - shift = (v > 0x3) << 1; v >>= shift; r |= shift; - r |= (v >> 1); - return r; + unsigned int r; + unsigned int shift; + + r = (v > 0xFFFF) << 4; v >>= r; + shift = (v > 0xFF) << 3; v >>= shift; r |= shift; + shift = (v > 0xF) << 2; v >>= shift; r |= shift; + shift = (v > 0x3) << 1; v >>= shift; r |= shift; + r |= (v >> 1); + return r; } static unsigned int bpf_log2l(unsigned long v) { - unsigned int hi = v >> 32; - if (hi) - return bpf_log2(hi) + 32 + 1; - else - return bpf_log2(v) + 1; + unsigned int hi = v >> 32; + if (hi) + return bpf_log2(hi) + 32 + 1; + else + return bpf_log2(v) + 1; } struct bpf_context; -- 2.7.4