Kaynağa Gözat

Fixed #TSB-1234 test

ilucky.si 1 yıl önce
ebeveyn
işleme
47c2f9a47c
1 değiştirilmiş dosya ile 12 ekleme ve 6 silme
  1. 12 6
      ebpftracer/ebpf/l7/l7.c

+ 12 - 6
ebpftracer/ebpf/l7/l7.c

@@ -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。