@@ -40,14 +40,16 @@ static __always_inline u32 trace_type_from_meta(http_connection_metadata_t *meta
40
40
return TRACE_TYPE_SERVER ;
41
41
}
42
42
43
- static __always_inline void http_get_or_create_trace_info (http_connection_metadata_t * meta ,
44
- u32 pid ,
45
- connection_info_t * conn ,
46
- void * u_buf ,
47
- int bytes_len ,
48
- s32 capture_header_buffer ,
49
- u8 ssl ,
50
- u16 orig_dport ) {
43
+ static __always_inline void
44
+ http_get_or_create_trace_info (http_connection_metadata_t * meta ,
45
+ u32 pid ,
46
+ connection_info_t * conn ,
47
+ void * u_buf ,
48
+ int bytes_len ,
49
+ s32 capture_header_buffer ,
50
+ u8 ssl ,
51
+ u16 orig_dport ,
52
+ unsigned char * (* tp_loop_fn )(unsigned char * , int )) {
51
53
//TODO use make_key
52
54
egress_key_t e_key = {
53
55
.d_port = conn -> d_port ,
@@ -148,13 +150,7 @@ static __always_inline void http_get_or_create_trace_info(http_connection_metada
148
150
149
151
bpf_probe_read (buf , buf_len , u_buf );
150
152
151
- unsigned char * res = NULL ;
152
- if (bpf_core_enum_value_exists (enum bpf_func_id , BPF_FUNC_loop )) {
153
- res = bpf_strstr_tp_loop (buf , buf_len );
154
- } else {
155
- res = bpf_strstr_tp_loop__legacy (buf );
156
- }
157
-
153
+ unsigned char * res = tp_loop_fn (buf , buf_len );
158
154
if (res ) {
159
155
bpf_dbg_printk ("Found traceparent in headers [%s] overriding what was before" , res );
160
156
unsigned char * t_id = extract_trace_id (res );
@@ -392,13 +388,8 @@ static __always_inline void handle_http_response(unsigned char *small_buf,
392
388
cleanup_http_request_data (pid_conn , info );
393
389
}
394
390
395
- // k_tail_protocol_http
396
- SEC ("kprobe/http" )
397
- int obi_protocol_http (void * ctx ) {
398
- (void )ctx ;
399
-
391
+ static __always_inline int __obi_protocol_http (unsigned char * (* tp_loop_fn )(unsigned char * , int )) {
400
392
call_protocol_args_t * args = protocol_args ();
401
-
402
393
if (!args ) {
403
394
return 0 ;
404
395
}
@@ -450,7 +441,8 @@ int obi_protocol_http(void *ctx) {
450
441
args -> bytes_len ,
451
442
capture_header_buffer ,
452
443
args -> ssl ,
453
- args -> orig_dport );
444
+ args -> orig_dport ,
445
+ tp_loop_fn );
454
446
455
447
if (meta ) {
456
448
u32 type = trace_type_from_meta (meta );
@@ -483,3 +475,17 @@ int obi_protocol_http(void *ctx) {
483
475
484
476
return 0 ;
485
477
}
478
+
479
+ // k_tail_protocol_http
480
+ SEC ("kprobe/http" )
481
+ static int obi_protocol_http (void * ctx ) {
482
+ (void )ctx ;
483
+ return __obi_protocol_http (bpf_strstr_tp_loop );
484
+ }
485
+
486
+ // k_tail_protocol_http
487
+ SEC ("kprobe/http" )
488
+ static int obi_protocol_http_legacy (void * ctx ) {
489
+ (void )ctx ;
490
+ return __obi_protocol_http (bpf_strstr_tp_loop__legacy );
491
+ }
0 commit comments