@@ -1031,14 +1031,16 @@ static __always_inline bool create_conn_info(void* ctx, struct conn_info_t *conn
1031
1031
uint16_t one = 1 ;
1032
1032
uint8_t * enable_local_port_filter = bpf_map_lookup_elem (& enabled_local_port_map , & one );
1033
1033
if (enable_local_port_filter != NULL ) {
1034
- uint8_t * enabled_local_port = bpf_map_lookup_elem (& enabled_local_port_map , & conn_info -> laddr .in4 .sin_port );
1034
+ u16 port = conn_info -> laddr .in4 .sin_port ;
1035
+ uint8_t * enabled_local_port = bpf_map_lookup_elem (& enabled_local_port_map , & port );
1035
1036
if (enabled_local_port == NULL ) {
1036
1037
return false;
1037
1038
}
1038
1039
}
1039
1040
uint8_t * enable_remote_port_filter = bpf_map_lookup_elem (& enabled_remote_port_map , & one );
1040
1041
if (enable_remote_port_filter != NULL ) {
1041
- uint8_t * enabled_remote_port = bpf_map_lookup_elem (& enabled_remote_port_map , & conn_info -> raddr .in4 .sin_port );
1042
+ u16 port = conn_info -> raddr .in4 .sin_port ;
1043
+ uint8_t * enabled_remote_port = bpf_map_lookup_elem (& enabled_remote_port_map , & port );
1042
1044
if (enabled_remote_port == NULL ) {
1043
1045
return false;
1044
1046
}
@@ -1047,7 +1049,8 @@ static __always_inline bool create_conn_info(void* ctx, struct conn_info_t *conn
1047
1049
if (conn_info -> raddr .in4 .sin_family == AF_INET ) {
1048
1050
uint8_t * enable_remote_ipv4_filter = bpf_map_lookup_elem (& enabled_remote_ipv4_map , & one32 );
1049
1051
if (enable_remote_ipv4_filter != NULL ) {
1050
- uint8_t * enabled_remote_ipv4 = bpf_map_lookup_elem (& enabled_remote_ipv4_map , & conn_info -> raddr .in4 .sin_addr .s_addr );
1052
+ u32 addr = conn_info -> raddr .in4 .sin_addr .s_addr ;
1053
+ uint8_t * enabled_remote_ipv4 = bpf_map_lookup_elem (& enabled_remote_ipv4_map , & addr );
1051
1054
if (enabled_remote_ipv4 == NULL || conn_info -> raddr .in4 .sin_addr .s_addr == 0 ) {
1052
1055
return false;
1053
1056
}
@@ -1238,12 +1241,12 @@ static __always_inline void process_syscall_data_vecs(void* ctx, struct data_arg
1238
1241
if (!conn_info ) {
1239
1242
tcp_sk = get_socket_from_fd (args -> fd );
1240
1243
if (tcp_sk ) {
1241
- struct sock_key key ;
1242
1244
int zero = 0 ;
1243
- struct conn_info_t * new_conn_info = bpf_map_lookup_elem (& conn_info_t_map , & zero );
1245
+ // struct conn_info_t *new_conn_info = bpf_map_lookup_elem(&conn_info_t_map, &zero);
1246
+ struct conn_info_t _new_conn_info = {};
1247
+ struct conn_info_t * new_conn_info = & _new_conn_info ;
1244
1248
if (new_conn_info ) {
1245
1249
new_conn_info -> protocol = kProtocolUnset ;
1246
- parse_sock_key_sk ((struct sock * )tcp_sk , & key );
1247
1250
bool created = create_conn_info_in_data_syscall (ctx , tcp_sk , tgid_fd , direct , bytes_count , new_conn_info );
1248
1251
if (created ) {
1249
1252
conn_info = bpf_map_lookup_elem (& conn_info_map , & tgid_fd );
@@ -1317,12 +1320,12 @@ static __always_inline void process_syscall_data(void* ctx, struct data_args *ar
1317
1320
if (!conn_info ) {
1318
1321
tcp_sk = get_socket_from_fd (args -> fd );
1319
1322
if (tcp_sk ) {
1320
- struct sock_key key ;
1321
1323
int zero = 0 ;
1322
- struct conn_info_t * new_conn_info = bpf_map_lookup_elem (& conn_info_t_map , & zero );
1324
+ // struct conn_info_t *new_conn_info = bpf_map_lookup_elem(&conn_info_t_map, &zero);
1325
+ struct conn_info_t _new_conn_info = {};
1326
+ struct conn_info_t * new_conn_info = & _new_conn_info ;
1323
1327
if (new_conn_info ) {
1324
1328
new_conn_info -> protocol = kProtocolUnset ;
1325
- parse_sock_key_sk ((struct sock * )tcp_sk , & key );
1326
1329
bool created = create_conn_info_in_data_syscall (ctx , tcp_sk , tgid_fd , direct , bytes_count , new_conn_info );
1327
1330
if (created ) {
1328
1331
conn_info = bpf_map_lookup_elem (& conn_info_map , & tgid_fd );
@@ -1336,8 +1339,8 @@ static __always_inline void process_syscall_data(void* ctx, struct data_args *ar
1336
1339
if (conn_info -> protocol == kProtocolUnset || conn_info -> protocol == kProtocolUnknown ) {
1337
1340
enum traffic_protocol_t before_infer = conn_info -> protocol ;
1338
1341
// bpf_printk("[protocol infer]:start, bc:%d", bytes_count);
1339
- struct protocol_message_t protocol_message = infer_protocol (args -> buf , bytes_count , conn_info );
1340
1342
// conn_info->protocol = protocol_message.protocol;
1343
+ struct protocol_message_t protocol_message = infer_protocol (args -> buf , bytes_count , conn_info );
1341
1344
if (before_infer != protocol_message .protocol ) {
1342
1345
conn_info -> protocol = protocol_message .protocol ;
1343
1346
// bpf_printk("[protocol infer]: %d", conn_info->protocol);
0 commit comments