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