|
|
@@ -228,12 +228,18 @@ struct __socket_data_buffer {
|
|
|
char data[32760]; // 32760 + len(4bytes) + events_num(4bytes) = 2^15 = 32768
|
|
|
};
|
|
|
// MAP_PERARRAY(data_buf, __u32, struct __socket_data_buffer, 1)
|
|
|
-struct bpf_map_def SEC("maps") data_buf = {
|
|
|
- .type = BPF_MAP_TYPE_HASH, // BPF_MAP_TYPE_PERF_EVENT_ARRAY,
|
|
|
- .key_size = sizeof(__u32),
|
|
|
- .value_size = sizeof(struct __socket_data_buffer),
|
|
|
- .max_entries = 1,
|
|
|
-};
|
|
|
+//struct bpf_map_def SEC("maps") data_buf = {
|
|
|
+// .type = BPF_MAP_TYPE_PERCPU_ARRAY, // BPF_MAP_TYPE_PERF_EVENT_ARRAY,
|
|
|
+// .key_size = sizeof(__u32),
|
|
|
+// .value_size = sizeof(struct __socket_data_buffer),
|
|
|
+// .max_entries = 1,
|
|
|
+//};
|
|
|
+struct {
|
|
|
+ __uint(type, BPF_MAP_TYPE_PERCPU_ARRAY); // IK: BPF_MAP_TYPE_PERCPU_ARRAY类型的map数据是放在内存中的...
|
|
|
+ __type(key, __u32);
|
|
|
+ __type(value, struct __socket_data_buffer);
|
|
|
+ __uint(max_entries, 1);
|
|
|
+} data_buf SEC(".maps");
|
|
|
|
|
|
/*
|
|
|
* 因为ebpf栈只有512字节无法存放http数据,这里使用map做为buffer。
|