Skip to content

Commit 2836d38

Browse files
committed
convert indents to spaces
1 parent 8e44247 commit 2836d38

File tree

6 files changed

+190
-199
lines changed

6 files changed

+190
-199
lines changed

containers/registry.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ func (r *Registry) handleEvents(ch <-chan ebpftracer.Event) {
206206
if e.L7Request == nil {
207207
continue
208208
}
209-
//klog.Infof("L7 request proto:%s pid:%d fd:%d", e.L7Request.Protocol.String(), e.Pid, e.Fd)
210209
if c := r.containersByPid[e.Pid]; c != nil {
211210
c.onL7Request(e.Pid, e.Fd, e.L7Request)
212211
}

ebpftracer/ebpf.go

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

ebpftracer/ebpf/l7.c

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,29 @@
1414
#define PROTOCOL_MONGO 6
1515

1616
struct l7_event {
17-
__u64 fd;
18-
__u32 pid;
17+
__u64 fd;
18+
__u32 pid;
1919
__u32 status;
2020
__u64 duration;
2121
__u8 protocol;
2222
};
2323

2424
struct {
25-
__uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
26-
__uint(key_size, sizeof(int));
27-
__uint(value_size, sizeof(int));
25+
__uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
26+
__uint(key_size, sizeof(int));
27+
__uint(value_size, sizeof(int));
2828
} l7_events SEC(".maps");
2929

30-
3130
struct rw_args_t {
3231
__u64 fd;
3332
char* buf;
3433
};
3534

3635
struct {
37-
__uint(type, BPF_MAP_TYPE_HASH);
38-
__uint(key_size, sizeof(__u64));
39-
__uint(value_size, sizeof(struct rw_args_t));
40-
__uint(max_entries, 10240);
36+
__uint(type, BPF_MAP_TYPE_HASH);
37+
__uint(key_size, sizeof(__u64));
38+
__uint(value_size, sizeof(struct rw_args_t));
39+
__uint(max_entries, 10240);
4140
} active_reads SEC(".maps");
4241

4342
struct socket_key {
@@ -52,33 +51,26 @@ struct l7_request {
5251
};
5352

5453
struct {
55-
__uint(type, BPF_MAP_TYPE_HASH);
56-
__uint(key_size, sizeof(struct socket_key));
57-
__uint(value_size, sizeof(struct l7_request));
58-
__uint(max_entries, 10240);
54+
__uint(type, BPF_MAP_TYPE_HASH);
55+
__uint(key_size, sizeof(struct socket_key));
56+
__uint(value_size, sizeof(struct l7_request));
57+
__uint(max_entries, 10240);
5958
} active_l7_requests SEC(".maps");
6059

6160
struct trace_event_raw_sys_enter_rw__stub {
62-
__u64 unused;
63-
long int id;
64-
__u64 fd;
65-
char* buf;
66-
__u64 size;
61+
__u64 unused;
62+
long int id;
63+
__u64 fd;
64+
char* buf;
65+
__u64 size;
6766
};
6867

6968
struct trace_event_raw_sys_exit_rw__stub {
70-
__u64 unused;
71-
long int id;
72-
long int ret;
69+
__u64 unused;
70+
long int id;
71+
long int ret;
7372
};
7473

75-
#define bpf_printk(fmt, ...) \
76-
({ \
77-
char ____fmt[] = fmt; \
78-
bpf_trace_printk(____fmt, sizeof(____fmt), \
79-
##__VA_ARGS__); \
80-
})
81-
8274
static inline __attribute__((__always_inline__))
8375
int trace_enter_write(__u64 fd, char *buf, __u64 size) {
8476
__u32 pid = bpf_get_current_pid_tgid() >> 32;

ebpftracer/ebpf/proc.c

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,79 +2,79 @@
22
#define CLONE_THREAD 0x00010000
33

44
struct proc_event {
5-
__u32 type;
6-
__u32 pid;
7-
__u32 reason;
5+
__u32 type;
6+
__u32 pid;
7+
__u32 reason;
88
};
99

1010
struct {
11-
__uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
12-
__uint(key_size, sizeof(int));
13-
__uint(value_size, sizeof(int));
11+
__uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
12+
__uint(key_size, sizeof(int));
13+
__uint(value_size, sizeof(int));
1414
} proc_events SEC(".maps");
1515

1616
struct {
17-
__uint(type, BPF_MAP_TYPE_HASH);
18-
__uint(key_size, sizeof(__u32));
19-
__uint(value_size, sizeof(__u32));
20-
__uint(max_entries, 10240);
17+
__uint(type, BPF_MAP_TYPE_HASH);
18+
__uint(key_size, sizeof(__u32));
19+
__uint(value_size, sizeof(__u32));
20+
__uint(max_entries, 10240);
2121
} oom_info SEC(".maps");
2222

2323
struct trace_event_raw_task_newtask__stub {
24-
__u64 unused;
25-
__u32 pid;
26-
char comm[TASK_COMM_LEN];
27-
long unsigned int clone_flags;
24+
__u64 unused;
25+
__u32 pid;
26+
char comm[TASK_COMM_LEN];
27+
long unsigned int clone_flags;
2828
};
2929

3030
SEC("tracepoint/task/task_newtask")
3131
int task_newtask(struct trace_event_raw_task_newtask__stub *args)
3232
{
33-
if (args->clone_flags & CLONE_THREAD) { // skipping threads
34-
return 0;
35-
}
36-
struct proc_event e = {
37-
.type = EVENT_TYPE_PROCESS_START,
38-
.pid = args->pid,
39-
};
40-
bpf_perf_event_output(args, &proc_events, BPF_F_CURRENT_CPU, &e, sizeof(e));
41-
return 0;
33+
if (args->clone_flags & CLONE_THREAD) { // skipping threads
34+
return 0;
35+
}
36+
struct proc_event e = {
37+
.type = EVENT_TYPE_PROCESS_START,
38+
.pid = args->pid,
39+
};
40+
bpf_perf_event_output(args, &proc_events, BPF_F_CURRENT_CPU, &e, sizeof(e));
41+
return 0;
4242
}
4343

4444
struct trace_event_raw_sched_process_template__stub {
45-
__u64 unused;
46-
char comm[TASK_COMM_LEN];
47-
__u32 pid;
45+
__u64 unused;
46+
char comm[TASK_COMM_LEN];
47+
__u32 pid;
4848
};
4949

5050
SEC("tracepoint/sched/sched_process_exit")
5151
int sched_process_exit(struct trace_event_raw_sched_process_template__stub *args)
5252
{
53-
__u64 id = bpf_get_current_pid_tgid();
54-
if (id >> 32 != (__u32)id) { // skipping threads
55-
return 0;
56-
}
57-
struct proc_event e = {
58-
.type = EVENT_TYPE_PROCESS_EXIT,
59-
.pid = args->pid,
60-
};
61-
if (bpf_map_lookup_elem(&oom_info, &e.pid)) {
62-
e.reason = EVENT_REASON_OOM_KILL;
63-
bpf_map_delete_elem(&oom_info, &e.pid);
64-
}
65-
bpf_perf_event_output(args, &proc_events, BPF_F_CURRENT_CPU, &e, sizeof(e));
66-
return 0;
53+
__u64 id = bpf_get_current_pid_tgid();
54+
if (id >> 32 != (__u32)id) { // skipping threads
55+
return 0;
56+
}
57+
struct proc_event e = {
58+
.type = EVENT_TYPE_PROCESS_EXIT,
59+
.pid = args->pid,
60+
};
61+
if (bpf_map_lookup_elem(&oom_info, &e.pid)) {
62+
e.reason = EVENT_REASON_OOM_KILL;
63+
bpf_map_delete_elem(&oom_info, &e.pid);
64+
}
65+
bpf_perf_event_output(args, &proc_events, BPF_F_CURRENT_CPU, &e, sizeof(e));
66+
return 0;
6767
}
6868

6969
struct trace_event_raw_mark_victim__stub {
70-
__u64 unused;
71-
int pid;
70+
__u64 unused;
71+
int pid;
7272
};
7373

7474
SEC("tracepoint/oom/mark_victim")
7575
int oom_mark_victim(struct trace_event_raw_mark_victim__stub *args)
7676
{
77-
__u32 pid = args->pid;
78-
bpf_map_update_elem(&oom_info, &pid, &pid, BPF_ANY);
79-
return 0;
77+
__u32 pid = args->pid;
78+
bpf_map_update_elem(&oom_info, &pid, &pid, BPF_ANY);
79+
return 0;
8080
}

ebpftracer/ebpf/tcp_retransmit.c

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
struct {
2-
__uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
3-
__uint(key_size, sizeof(int));
4-
__uint(value_size, sizeof(int));
2+
__uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
3+
__uint(key_size, sizeof(int));
4+
__uint(value_size, sizeof(int));
55
} tcp_retransmit_events SEC(".maps");
66

77
struct trace_event_raw_tcp_event_sk_skb__stub {
8-
__u64 unused;
9-
void *sbkaddr;
10-
void *skaddr;
8+
__u64 unused;
9+
void *sbkaddr;
10+
void *skaddr;
1111
#if __KERNEL >= 420
12-
int state;
12+
int state;
1313
#endif
14-
__u16 sport;
15-
__u16 dport;
14+
__u16 sport;
15+
__u16 dport;
1616
#if __KERNEL >= 512
17-
__u16 family;
17+
__u16 family;
1818
#endif
19-
__u8 saddr[4];
20-
__u8 daddr[4];
21-
__u8 saddr_v6[16];
22-
__u8 daddr_v6[16];
19+
__u8 saddr[4];
20+
__u8 daddr[4];
21+
__u8 saddr_v6[16];
22+
__u8 daddr_v6[16];
2323
};
2424

2525
SEC("tracepoint/tcp/tcp_retransmit_skb")
2626
int tcp_retransmit_skb(struct trace_event_raw_tcp_event_sk_skb__stub *args)
2727
{
28-
struct tcp_event e = {
29-
.type = EVENT_TYPE_TCP_RETRANSMIT,
30-
.sport = args->sport,
31-
.dport = args->dport,
32-
};
33-
__builtin_memcpy(&e.saddr, &args->saddr_v6, sizeof(e.saddr));
34-
__builtin_memcpy(&e.daddr, &args->daddr_v6, sizeof(e.daddr));
28+
struct tcp_event e = {
29+
.type = EVENT_TYPE_TCP_RETRANSMIT,
30+
.sport = args->sport,
31+
.dport = args->dport,
32+
};
33+
__builtin_memcpy(&e.saddr, &args->saddr_v6, sizeof(e.saddr));
34+
__builtin_memcpy(&e.daddr, &args->daddr_v6, sizeof(e.daddr));
3535

36-
bpf_perf_event_output(args, &tcp_retransmit_events, BPF_F_CURRENT_CPU, &e, sizeof(e));
36+
bpf_perf_event_output(args, &tcp_retransmit_events, BPF_F_CURRENT_CPU, &e, sizeof(e));
3737

38-
return 0;
38+
return 0;
3939
}

0 commit comments

Comments
 (0)