From 161e083b3239e3904b35b798c617f7be453164ce Mon Sep 17 00:00:00 2001 From: watal Date: Thu, 20 Jul 2023 16:21:08 +0900 Subject: [PATCH] Fix format --- src/main.c | 28 +++++++++++++++------------- src/xdp_consts.h | 2 +- src/xdp_map.h | 5 +++-- src/xdp_struct.h | 11 ++++++----- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/main.c b/src/main.c index e20757e..f32fd4a 100644 --- a/src/main.c +++ b/src/main.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2023 NTT Communications Corporation - * Copyright (c) 2023 Takeru Hayasaka + * Copyright (c) 2023 Takeru Hayasaka */ #define KBUILD_MODNAME "xdp_probe" @@ -18,12 +18,13 @@ #include "xdp_map.h" -SEC("xdp") -int xdp_prog(struct xdp_md *ctx) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; - __u32 probe_key = XDP_PASS; - struct ethhdr *eth = data; +SEC("xdp") +int xdp_prog(struct xdp_md *ctx) +{ + void *data_end = (void *)(long)ctx->data_end; + void *data = (void *)(long)ctx->data; + __u32 probe_key = XDP_PASS; + struct ethhdr *eth = data; if ((void *)(eth + 1) > data_end) return XDP_PASS; @@ -62,11 +63,11 @@ int xdp_prog(struct xdp_md *ctx) { key.flags = srh->flags; key.tag = srh->tag; - for(int i=0; i data_end) break; @@ -74,7 +75,8 @@ int xdp_prog(struct xdp_md *ctx) { } value = bpf_map_lookup_elem(&ipfix_probe_map, &key); - if (!value) { + if (!value) + { bpf_map_update_elem(&ipfix_probe_map, &key, &zero, BPF_NOEXIST); value = bpf_map_lookup_elem(&ipfix_probe_map, &key); if (!value) @@ -82,7 +84,7 @@ int xdp_prog(struct xdp_md *ctx) { } (*value)++; - return XDP_PASS; + return XDP_PASS; } char _license[] SEC("license") = "MIT"; diff --git a/src/xdp_consts.h b/src/xdp_consts.h index 5f4c753..d7b8e73 100644 --- a/src/xdp_consts.h +++ b/src/xdp_consts.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2023 NTT Communications Corporation - * Copyright (c) 2023 Takeru Hayasaka + * Copyright (c) 2023 Takeru Hayasaka */ #ifndef __XDP_CONSTS_H diff --git a/src/xdp_map.h b/src/xdp_map.h index 4371e85..0e6736a 100644 --- a/src/xdp_map.h +++ b/src/xdp_map.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2023 NTT Communications Corporation - * Copyright (c) 2023 Takeru Hayasaka + * Copyright (c) 2023 Takeru Hayasaka */ #ifndef __XDP_MAPS_H @@ -12,7 +12,8 @@ #include #include "xdp_consts.h" #include "xdp_struct.h" -struct { +struct +{ __uint(type, BPF_MAP_TYPE_LRU_HASH); __uint(max_entries, MAX_MAP_ENTRIES); __type(key, struct probe_data); diff --git a/src/xdp_struct.h b/src/xdp_struct.h index 34a01bb..2165448 100644 --- a/src/xdp_struct.h +++ b/src/xdp_struct.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2023 NTT Communications Corporation - * Copyright (c) 2023 Takeru Hayasaka + * Copyright (c) 2023 Takeru Hayasaka */ #ifndef __XDP_STRUCTS_H @@ -25,10 +25,11 @@ struct srhhdr struct in6_addr segments[0]; }; -struct probe_data { - __u8 h_dest[ETH_ALEN]; - __u8 h_source[ETH_ALEN]; - __be16 h_proto; +struct probe_data +{ + __u8 h_dest[ETH_ALEN]; + __u8 h_source[ETH_ALEN]; + __be16 h_proto; struct in6_addr v6_srcaddr; struct in6_addr v6_dstaddr; __u8 nextHdr;