소스 검색

Feature #TASK_QT-18250 修改bug

rock.wu 9 달 전
부모
커밋
1ff912aa55
1개의 변경된 파일43개의 추가작업 그리고 42개의 파일을 삭제
  1. 43 42
      ebpftracer/ebpf/utrace/go/net/server.probe.bpf.c

+ 43 - 42
ebpftracer/ebpf/utrace/go/net/server.probe.bpf.c

@@ -507,6 +507,49 @@ static __always_inline struct map_bucket *get_map_bucket(void *headers_ptr_ptr)
 	return NULL;
 }
 
+// 获取 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;
+}
+
 // 简化的overflow bucket搜索函数
 static __always_inline char *get_header_val_with_overflow_simple(void *headers_ptr_ptr) {
 	void *headers_ptr;
@@ -585,48 +628,6 @@ static __always_inline char *get_header_val_with_overflow_simple(void *headers_p
 	return NULL;
 }
 
-// 获取 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;
-}
 
 
 // This instrumentation attaches uprobe to the following function: