Skip to content

Commit fd41fc4

Browse files
authored
bpf: correctly initialize classification protocol (#290)
1 parent 5a26131 commit fd41fc4

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

bpf/generictracer/k_tracer_defs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ make_protocol_args(void *u_buf, int bytes_len, u8 ssl, u8 direction, u16 orig_dp
3636
args->direction = direction;
3737
args->orig_dport = orig_dport;
3838
args->u_buf = (u64)u_buf;
39+
args->protocol_type = k_protocol_type_unknown;
3940

4041
return args;
4142
}

bpf/generictracer/protocol_mysql.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,12 @@ static __always_inline u8 is_mysql(connection_info_t *conn_info,
267267
// +------------+-------------+----------------------+
268268
// | 3B | 1B | 1B | 4B |
269269
// +------------+-------------+----------------------+
270-
*packet_type = PACKET_TYPE_REQUEST;
270+
if (*protocol_type == k_protocol_type_mysql) {
271+
// Already identified, mark this as a request.
272+
// NOTE: Trying to classify the connection based on this command
273+
// would be unreliable, as the check is too shallow.
274+
*packet_type = PACKET_TYPE_REQUEST;
275+
}
271276
break;
272277
default:
273278
if (*protocol_type == k_protocol_type_mysql) {

0 commit comments

Comments
 (0)