|
@@ -110,6 +110,13 @@ struct {
|
|
|
__uint(max_entries, MAX_CONCURRENT);
|
|
__uint(max_entries, MAX_CONCURRENT);
|
|
|
} http_server_context_headers SEC(".maps");
|
|
} http_server_context_headers SEC(".maps");
|
|
|
|
|
|
|
|
|
|
+struct {
|
|
|
|
|
+ __uint(type, BPF_MAP_TYPE_LRU_HASH);
|
|
|
|
|
+ __uint(key_size, sizeof(u64));
|
|
|
|
|
+ __uint(value_size, sizeof(char [CW_SYS_HEADER_VAL_LENGTH]));
|
|
|
|
|
+ __uint(max_entries, MAX_CONCURRENT);
|
|
|
|
|
+} http_server_context_sys_headers SEC(".maps");
|
|
|
|
|
+
|
|
|
// Injected in init
|
|
// Injected in init
|
|
|
// volatile const u64 ctx_ptr_pos;
|
|
// volatile const u64 ctx_ptr_pos;
|
|
|
// volatile const u64 headers_ptr_pos;
|
|
// volatile const u64 headers_ptr_pos;
|
|
@@ -124,196 +131,6 @@ struct {
|
|
|
//}
|
|
//}
|
|
|
//}
|
|
//}
|
|
|
|
|
|
|
|
-static __always_inline struct span_context *extract_context_from_req_headers_del(void *headers_ptr_ptr) {
|
|
|
|
|
- void *headers_ptr;
|
|
|
|
|
- long res;
|
|
|
|
|
- res = bpf_probe_read(&headers_ptr, sizeof(headers_ptr), headers_ptr_ptr);
|
|
|
|
|
- if (res < 0) {
|
|
|
|
|
- return NULL;
|
|
|
|
|
- }
|
|
|
|
|
- u64 headers_count = 0;
|
|
|
|
|
- res = bpf_probe_read(&headers_count, sizeof(headers_count), headers_ptr);
|
|
|
|
|
- if (res < 0) {
|
|
|
|
|
- return NULL;
|
|
|
|
|
- }
|
|
|
|
|
- if (headers_count == 0) {
|
|
|
|
|
- return NULL;
|
|
|
|
|
- }
|
|
|
|
|
- unsigned char log_2_bucket_count;
|
|
|
|
|
- res = bpf_probe_read(&log_2_bucket_count, sizeof(log_2_bucket_count), headers_ptr + 9);
|
|
|
|
|
- if (res < 0) {
|
|
|
|
|
- return NULL;
|
|
|
|
|
- }
|
|
|
|
|
- u64 bucket_count = 1 << log_2_bucket_count;
|
|
|
|
|
- __u64 pid_tgid = bpf_get_current_pid_tgid();
|
|
|
|
|
- __u32 tgid = pid_tgid >> 32;
|
|
|
|
|
- struct ebpf_proc_info *proc_info =
|
|
|
|
|
- bpf_map_lookup_elem(&proc_info_map, &tgid);
|
|
|
|
|
- if(!proc_info)
|
|
|
|
|
- {
|
|
|
|
|
- return 0;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // Check if Go version >= 1.24 (Swiss Tables)
|
|
|
|
|
- if (proc_info->version >= GO_VERSION(1, 24, 0)) {
|
|
|
|
|
- // Swiss Tables uses dirPtr instead of buckets, structure is incompatible
|
|
|
|
|
- // Skip header reading for Go 1.24+
|
|
|
|
|
- return NULL;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- void *header_buckets;
|
|
|
|
|
- res = bpf_probe_read(&header_buckets, sizeof(header_buckets), (void *) (headers_ptr + proc_info->buckets_ptr_pos));
|
|
|
|
|
- if (res < 0) {
|
|
|
|
|
- return NULL;
|
|
|
|
|
- }
|
|
|
|
|
- u32 map_id = 0;
|
|
|
|
|
- struct map_bucket *map_value = bpf_map_lookup_elem(&golang_mapbucket_storage_map, &map_id);
|
|
|
|
|
- if (!map_value) {
|
|
|
|
|
- return NULL;
|
|
|
|
|
- }
|
|
|
|
|
- for (u32 j = 0; j < MAX_BUCKETS; j++) {
|
|
|
|
|
- if (j >= bucket_count) {
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- res = bpf_probe_read(map_value, sizeof(struct map_bucket), header_buckets + (j * sizeof(struct map_bucket)));
|
|
|
|
|
- if (res < 0) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-// for (u32 i = 0; i < 8; i++) {
|
|
|
|
|
- u32 i = 0;
|
|
|
|
|
- if (map_value->tophash[i] != 0 && map_value->keys[i].len == CW_HEADER_KEY_LENGTH) {
|
|
|
|
|
-// char current_header_key[CW_HEADER_KEY_LENGTH];
|
|
|
|
|
-// bpf_probe_read(current_header_key, sizeof(current_header_key), map_value->keys[i].str);
|
|
|
|
|
- for (int ii = 0; ii < CW_HEADER_KEY_LENGTH; ii++) {
|
|
|
|
|
- if (map_value->keys[i].str[ii] != CW_HEADER_KEY_VAL[i] && map_value->keys[i].str[ii] != CW_HEADER_KEY_UFIRST_VAL[ii]) {
|
|
|
|
|
-// goto outer_loop;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-// continue;
|
|
|
|
|
- }
|
|
|
|
|
-// if (map_value->keys[i].len != CW_HEADER_KEY_LENGTH) {
|
|
|
|
|
-// continue;
|
|
|
|
|
-// }
|
|
|
|
|
-
|
|
|
|
|
-// char current_header_key[CW_HEADER_KEY_LENGTH];
|
|
|
|
|
-// bpf_probe_read(current_header_key, sizeof(current_header_key), map_value->keys[i].str);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-//
|
|
|
|
|
-// struct header_key * current_header_key = bpf_map_lookup_elem(&header_keys_map, &map_id);
|
|
|
|
|
-// if (current_header_key) {
|
|
|
|
|
-// bpf_probe_read(current_header_key->str, sizeof(current_header_key->str), map_value->keys[i].str);
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// for (int i = 0; i < CW_HEADER_KEY_LENGTH; i++) {
|
|
|
|
|
-// if (current_header_key[i] != CW_HEADER_KEY_VAL[i] && current_header_key[i] != CW_HEADER_KEY_UFIRST_VAL[i]) {
|
|
|
|
|
-// goto outer_loop;
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// void *traceparent_header_value_ptr = map_value->values[i].array;
|
|
|
|
|
-// struct go_string_ot traceparent_header_value_go_str;
|
|
|
|
|
-// res = bpf_probe_read(&traceparent_header_value_go_str, sizeof(traceparent_header_value_go_str),
|
|
|
|
|
-// traceparent_header_value_ptr);
|
|
|
|
|
-// // 00-95b5ec2b81e2374a4a27ce36ab71d349-18f65a5a3ab22213-02
|
|
|
|
|
-// cw_bpf_debug("traceparent_header_value_go_str.str:%s", traceparent_header_value_go_str.str);
|
|
|
|
|
-//
|
|
|
|
|
-// if (res < 0) {
|
|
|
|
|
-// return NULL;
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// // char traceparent_header_value[130];
|
|
|
|
|
-// int key = 0;
|
|
|
|
|
-// char *traceparent_header_value;
|
|
|
|
|
-// traceparent_header_value = bpf_map_lookup_elem(&go_large_array_map, &key);
|
|
|
|
|
-//
|
|
|
|
|
-// res = bpf_probe_read(&traceparent_header_value, sizeof(traceparent_header_value),
|
|
|
|
|
-// traceparent_header_value_go_str.str);
|
|
|
|
|
-//
|
|
|
|
|
-//
|
|
|
|
|
-// if (res < 0) {
|
|
|
|
|
-// return NULL;
|
|
|
|
|
-// }
|
|
|
|
|
-// struct span_context *parent_span_context = bpf_map_lookup_elem(&parent_span_context_storage_map, &map_id);
|
|
|
|
|
-// if (!parent_span_context) {
|
|
|
|
|
-// cw_bpf_debug("no parent_span_context");
|
|
|
|
|
-// return NULL;
|
|
|
|
|
-// }
|
|
|
|
|
-// struct apm_span_context *cw_parent_span_context = bpf_map_lookup_elem(&cw_parent_span_context_storage_map, &map_id);
|
|
|
|
|
-// if (!cw_parent_span_context) {
|
|
|
|
|
-// cw_bpf_debug("no cw_parent_span_context");
|
|
|
|
|
-// return NULL;
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// w3c_string_to_span_context(traceparent_header_value, parent_span_context);
|
|
|
|
|
-//
|
|
|
|
|
-// cw_string_to_span_context(traceparent_header_value, cw_parent_span_context);
|
|
|
|
|
-//
|
|
|
|
|
-// // 保存sc
|
|
|
|
|
-// cw_save_parent_tracking_span(cw_parent_span_context);
|
|
|
|
|
-//
|
|
|
|
|
-// return parent_span_context;
|
|
|
|
|
-// outer_loop:
|
|
|
|
|
-// continue;
|
|
|
|
|
-// }
|
|
|
|
|
- }
|
|
|
|
|
- return NULL;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-// 获取 get_map_bucket
|
|
|
|
|
-static __always_inline struct map_bucket *get_map_bucket(void *headers_ptr_ptr) {
|
|
|
|
|
- void *headers_ptr;
|
|
|
|
|
- long res;
|
|
|
|
|
- res = bpf_probe_read(&headers_ptr, sizeof(headers_ptr), headers_ptr_ptr);
|
|
|
|
|
- if (res < 0) {
|
|
|
|
|
- return NULL;
|
|
|
|
|
- }
|
|
|
|
|
- u64 headers_count = 0;
|
|
|
|
|
- res = bpf_probe_read(&headers_count, sizeof(headers_count), headers_ptr);
|
|
|
|
|
- if (res < 0) {
|
|
|
|
|
- return NULL;
|
|
|
|
|
- }
|
|
|
|
|
- if (headers_count == 0) {
|
|
|
|
|
- return NULL;
|
|
|
|
|
- }
|
|
|
|
|
- unsigned char log_2_bucket_count;
|
|
|
|
|
- res = bpf_probe_read(&log_2_bucket_count, sizeof(log_2_bucket_count), headers_ptr + 9);
|
|
|
|
|
- if (res < 0) {
|
|
|
|
|
- return NULL;
|
|
|
|
|
- }
|
|
|
|
|
- u64 bucket_count = 1 << log_2_bucket_count;
|
|
|
|
|
- __u64 pid_tgid = bpf_get_current_pid_tgid();
|
|
|
|
|
- __u32 tgid = pid_tgid >> 32;
|
|
|
|
|
- struct ebpf_proc_info *proc_info =
|
|
|
|
|
- bpf_map_lookup_elem(&proc_info_map, &tgid);
|
|
|
|
|
- if(!proc_info)
|
|
|
|
|
- {
|
|
|
|
|
- return NULL;
|
|
|
|
|
- }
|
|
|
|
|
- void *header_buckets;
|
|
|
|
|
- res = bpf_probe_read(&header_buckets, sizeof(header_buckets), (void *) (headers_ptr + proc_info->buckets_ptr_pos));
|
|
|
|
|
- if (res < 0) {
|
|
|
|
|
- return NULL;
|
|
|
|
|
- }
|
|
|
|
|
- u32 map_id = 0;
|
|
|
|
|
- struct map_bucket *map_value = bpf_map_lookup_elem(&golang_mapbucket_storage_map, &map_id);
|
|
|
|
|
- if (!map_value) {
|
|
|
|
|
- return NULL;
|
|
|
|
|
- }
|
|
|
|
|
- __builtin_memset(map_value, 0, sizeof(struct map_bucket));
|
|
|
|
|
-
|
|
|
|
|
- for (u32 j = 0; j < 8; j++) {
|
|
|
|
|
- if (j >= bucket_count) {
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- res = bpf_probe_read(map_value, sizeof(struct map_bucket), header_buckets + (j * sizeof(struct map_bucket)));
|
|
|
|
|
- if (res == 0) {
|
|
|
|
|
- return map_value;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- return NULL;
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MAP_BUCKET_DEFINITION(go_string_ot, go_slice_ot)
|
|
MAP_BUCKET_DEFINITION(go_string_ot, go_slice_ot)
|
|
@@ -329,159 +146,13 @@ extract_context_from_req_headers_pre_parsed(void *key) {
|
|
|
return header_val;
|
|
return header_val;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static __always_inline char *extract_context_from_req_headers_go_map(void *headers_ptr_ptr)
|
|
|
|
|
-{
|
|
|
|
|
- void *headers_ptr;
|
|
|
|
|
- long res;
|
|
|
|
|
- res = bpf_probe_read(&headers_ptr, sizeof(headers_ptr), headers_ptr_ptr);
|
|
|
|
|
- if (res < 0)
|
|
|
|
|
- {
|
|
|
|
|
- return NULL;
|
|
|
|
|
- }
|
|
|
|
|
- u64 headers_count = 0;
|
|
|
|
|
- res = bpf_probe_read(&headers_count, sizeof(headers_count), headers_ptr);
|
|
|
|
|
- if (res < 0)
|
|
|
|
|
- {
|
|
|
|
|
- return NULL;
|
|
|
|
|
- }
|
|
|
|
|
- if (headers_count == 0)
|
|
|
|
|
- {
|
|
|
|
|
- return NULL;
|
|
|
|
|
- }
|
|
|
|
|
- unsigned char log_2_bucket_count;
|
|
|
|
|
- res = bpf_probe_read(&log_2_bucket_count, sizeof(log_2_bucket_count), headers_ptr + 9);
|
|
|
|
|
- if (res < 0)
|
|
|
|
|
- {
|
|
|
|
|
- return NULL;
|
|
|
|
|
- }
|
|
|
|
|
- u64 bucket_count = 1 << log_2_bucket_count;
|
|
|
|
|
- void *header_buckets;
|
|
|
|
|
- /**/
|
|
|
|
|
- __u64 pid_tgid = bpf_get_current_pid_tgid();
|
|
|
|
|
- __u32 tgid = pid_tgid >> 32;
|
|
|
|
|
- struct ebpf_proc_info *proc_info =
|
|
|
|
|
- bpf_map_lookup_elem(&proc_info_map, &tgid);
|
|
|
|
|
- if(!proc_info)
|
|
|
|
|
- {
|
|
|
|
|
- return NULL;
|
|
|
|
|
- }
|
|
|
|
|
- /**/
|
|
|
|
|
-
|
|
|
|
|
- res = bpf_probe_read(&header_buckets, sizeof(header_buckets), (void*)(headers_ptr + proc_info->buckets_ptr_pos));
|
|
|
|
|
- if (res < 0)
|
|
|
|
|
- {
|
|
|
|
|
- return NULL;
|
|
|
|
|
- }
|
|
|
|
|
- u32 map_id = 0;
|
|
|
|
|
- MAP_BUCKET_TYPE(go_string_ot, go_slice_ot) *map_value = bpf_map_lookup_elem(&golang_mapbucket_storage_map, &map_id);
|
|
|
|
|
- if (!map_value)
|
|
|
|
|
- {
|
|
|
|
|
- return NULL;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- for (u64 j = 0; j < MAX_BUCKETS; j++)
|
|
|
|
|
- {
|
|
|
|
|
- if (j >= bucket_count)
|
|
|
|
|
- {
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- res = bpf_probe_read(map_value, sizeof(MAP_BUCKET_TYPE(go_string_ot, go_slice_ot)), header_buckets + (j * sizeof(MAP_BUCKET_TYPE(go_string_ot, go_slice_ot))));
|
|
|
|
|
- if (res < 0)
|
|
|
|
|
- {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- for (u64 i = 0; i < 8; i++)
|
|
|
|
|
- {
|
|
|
|
|
- if (map_value->tophash[i] == 0)
|
|
|
|
|
- {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- if (map_value->keys[i].len != CW_HEADER_KEY_LENGTH)
|
|
|
|
|
- {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- char current_header_key[CW_HEADER_KEY_LENGTH];
|
|
|
|
|
- bpf_probe_read(current_header_key, sizeof(current_header_key), map_value->keys[i].str);
|
|
|
|
|
- if (!bpf_memcmp(current_header_key, CW_HEADER_KEY_VAL, CW_HEADER_KEY_LENGTH) && !bpf_memcmp(current_header_key, CW_HEADER_KEY_UFIRST_VAL, CW_HEADER_KEY_LENGTH))
|
|
|
|
|
- {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- void *traceparent_header_value_ptr = map_value->values[i].array;
|
|
|
|
|
- struct go_string_ot traceparent_header_value_go_str;
|
|
|
|
|
- res = bpf_probe_read(&traceparent_header_value_go_str, sizeof(traceparent_header_value_go_str), traceparent_header_value_ptr);
|
|
|
|
|
- if (res < 0)
|
|
|
|
|
- {
|
|
|
|
|
- return NULL;
|
|
|
|
|
- }
|
|
|
|
|
- if (traceparent_header_value_go_str.len != CW_HEADER_VAL_LENGTH)
|
|
|
|
|
- {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- char traceparent_header_value2[CW_HEADER_VAL_LENGTH];
|
|
|
|
|
- res = bpf_probe_read(&traceparent_header_value2, sizeof(traceparent_header_value2), traceparent_header_value_go_str.str);
|
|
|
|
|
- if (res < 0)
|
|
|
|
|
- {
|
|
|
|
|
- return NULL;
|
|
|
|
|
- }
|
|
|
|
|
-// bpf_printk("has cw header111 j=%d i=%d %s", j, i,traceparent_header_value_go_str.str);
|
|
|
|
|
-
|
|
|
|
|
- return traceparent_header_value_go_str.str;
|
|
|
|
|
-// w3c_string_to_span_context(traceparent_header_value, parent_span_context);
|
|
|
|
|
-// return 0;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- return NULL;
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
static __always_inline char *
|
|
static __always_inline char *
|
|
|
extract_context_from_req_headers(void *key, void *headers_ptr_ptr, __u64 use_swiss) {
|
|
extract_context_from_req_headers(void *key, void *headers_ptr_ptr, __u64 use_swiss) {
|
|
|
- if (use_swiss == 1) {
|
|
|
|
|
|
|
+// if (use_swiss == 1) {
|
|
|
return extract_context_from_req_headers_pre_parsed(key);
|
|
return extract_context_from_req_headers_pre_parsed(key);
|
|
|
- }
|
|
|
|
|
- return extract_context_from_req_headers_go_map(headers_ptr_ptr);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-// 获取 header_val
|
|
|
|
|
-static __always_inline char *get_header_val(struct map_bucket *map_value,u32 off,u32 count) {
|
|
|
|
|
- for (u32 i = off; i < count; i++) {
|
|
|
|
|
- if (map_value->tophash[i] != 0 && map_value->keys[i].len == CW_HEADER_KEY_LENGTH) {
|
|
|
|
|
- char current_header_key[CW_HEADER_KEY_LENGTH];
|
|
|
|
|
- bpf_probe_read(current_header_key, sizeof(current_header_key), map_value->keys[i].str);
|
|
|
|
|
- if ((current_header_key[0] == CW_HEADER_KEY_VAL[0]
|
|
|
|
|
- || current_header_key[0] == CW_HEADER_KEY_UFIRST_VAL[0])
|
|
|
|
|
- && current_header_key[1] == CW_HEADER_KEY_UFIRST_VAL[1]
|
|
|
|
|
- && current_header_key[2] == CW_HEADER_KEY_UFIRST_VAL[2]
|
|
|
|
|
- && current_header_key[3] == CW_HEADER_KEY_UFIRST_VAL[3]
|
|
|
|
|
- && current_header_key[4] == CW_HEADER_KEY_UFIRST_VAL[4]
|
|
|
|
|
- && current_header_key[5] == CW_HEADER_KEY_UFIRST_VAL[5]
|
|
|
|
|
- && current_header_key[6] == CW_HEADER_KEY_UFIRST_VAL[6]) {
|
|
|
|
|
- void *traceparent_header_value_ptr = map_value->values[i].array;
|
|
|
|
|
- struct go_string_ot traceparent_header_value_go_str;
|
|
|
|
|
- long res = bpf_probe_read(&traceparent_header_value_go_str, sizeof(traceparent_header_value_go_str),
|
|
|
|
|
- traceparent_header_value_ptr);
|
|
|
|
|
- if (res == 0) {
|
|
|
|
|
- cw_bpf_debug("get_header_val %d-%d %s",off,count,traceparent_header_value_go_str.str);
|
|
|
|
|
- return traceparent_header_value_go_str.str;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- return NULL;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-// 分段获取 header_val
|
|
|
|
|
-static __always_inline char *get_header_val_off(struct map_bucket *map_value) {
|
|
|
|
|
- char *val = get_header_val(map_value, 0, 2);
|
|
|
|
|
- if (val == NULL) {
|
|
|
|
|
- val = get_header_val(map_value, 2, 4);
|
|
|
|
|
- }
|
|
|
|
|
- if (val == NULL) {
|
|
|
|
|
- val = get_header_val(map_value, 4, 6);
|
|
|
|
|
- }
|
|
|
|
|
- if (val == NULL) {
|
|
|
|
|
- val = get_header_val(map_value, 6, 8);
|
|
|
|
|
- }
|
|
|
|
|
- return val;
|
|
|
|
|
|
|
+// }
|
|
|
|
|
+// return extract_context_from_req_headers_go_map(headers_ptr_ptr);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -542,6 +213,14 @@ int uprobe_HandlerFunc_ServeHTTP(struct pt_regs *ctx) {
|
|
|
}
|
|
}
|
|
|
__builtin_memset(cw_parent_span_context, 0, sizeof(struct apm_span_context));
|
|
__builtin_memset(cw_parent_span_context, 0, sizeof(struct apm_span_context));
|
|
|
|
|
|
|
|
|
|
+ // parentSys parentService
|
|
|
|
|
+ char *header_sys_val = bpf_map_lookup_elem(&http_server_context_sys_headers, &key);
|
|
|
|
|
+ if (header_sys_val) {
|
|
|
|
|
+ bpf_printk("has sys");
|
|
|
|
|
+ bpf_probe_read(&cw_parent_span_context->sysvs, sizeof(cw_parent_span_context->sysvs), header_sys_val);
|
|
|
|
|
+ bpf_printk("has sys %s", cw_parent_span_context->sysvs);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (traceparent_header_value != NULL) {
|
|
if (traceparent_header_value != NULL) {
|
|
|
cw_bpf_debug("traceparent_header_value != NULL");
|
|
cw_bpf_debug("traceparent_header_value != NULL");
|
|
|
|
|
|
|
@@ -618,10 +297,12 @@ int uprobe_HandlerFunc_ServeHTTP_Returns(struct pt_regs *ctx) {
|
|
|
if (uprobe_data == NULL) {
|
|
if (uprobe_data == NULL) {
|
|
|
cw_bpf_debug("uprobe/HandlerFunc_ServeHTTP_Returns: entry_state is NULL");
|
|
cw_bpf_debug("uprobe/HandlerFunc_ServeHTTP_Returns: entry_state is NULL");
|
|
|
bpf_map_delete_elem(&http_server_context_headers, &key);
|
|
bpf_map_delete_elem(&http_server_context_headers, &key);
|
|
|
|
|
+ bpf_map_delete_elem(&http_server_context_sys_headers, &key);
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
bpf_map_delete_elem(&http_server_uprobes, &key);
|
|
bpf_map_delete_elem(&http_server_uprobes, &key);
|
|
|
bpf_map_delete_elem(&http_server_context_headers, &key);
|
|
bpf_map_delete_elem(&http_server_context_headers, &key);
|
|
|
|
|
+ bpf_map_delete_elem(&http_server_context_sys_headers, &key);
|
|
|
struct http_server_span_t *http_server_span = &uprobe_data->span;
|
|
struct http_server_span_t *http_server_span = &uprobe_data->span;
|
|
|
// void *resp_ptr = (void *) uprobe_data->resp_ptr;
|
|
// void *resp_ptr = (void *) uprobe_data->resp_ptr;
|
|
|
// void *req_ptr = NULL;
|
|
// void *req_ptr = NULL;
|
|
@@ -673,5 +354,18 @@ int uprobe_textproto_Reader_readContinuedLineSlice_Returns(struct pt_regs *ctx)
|
|
|
bpf_map_update_elem(&http_server_context_headers, &key, &header_val, BPF_ANY);
|
|
bpf_map_update_elem(&http_server_context_headers, &key, &header_val, BPF_ANY);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ // cwother: 08:service:03:tag
|
|
|
|
|
+ // 解析 cwother header (变长,需要检查是否匹配)
|
|
|
|
|
+ if (len >= (CW_SYS_HEADER_KEY_LENGTH + 2 + 8)) { // 至少 "cwother: NN:name:MM " 的长度
|
|
|
|
|
+ long cw_sys_header_native = 0x3A726568746F7763LL; // 小端序下的 "cwother:"
|
|
|
|
|
+ __u64 key64 = 0;
|
|
|
|
|
+ bpf_probe_read_user(&key64, sizeof(key64), buf);
|
|
|
|
|
+ if (key64 == cw_sys_header_native) {
|
|
|
|
|
+ char header_val[CW_SYS_HEADER_VAL_LENGTH] = {};
|
|
|
|
|
+ bpf_probe_read_user(header_val, sizeof(header_val), buf + CW_SYS_HEADER_KEY_LENGTH + 2);
|
|
|
|
|
+ cw_bpf_debug("Swiss Map:%s key %llu", header_val,key);
|
|
|
|
|
+ bpf_map_update_elem(&http_server_context_sys_headers, &key, &header_val, BPF_ANY);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|