Skip to content

Commit 126e90f

Browse files
yinjipingkylewanginchina
authored andcommitted
fix(eBPF): enforce reassembly path when MySQL reassembly is enabled
When MySQL reassembly is enabled, force all related traffic into the reassembly pipeline. Otherwise, single-packet protocol inference may misidentify consecutive same-direction packets as complete MySQL requests or responses. This could lead to MSG_UNKNOWN not being returned, preventing the reassembly logic from being triggered and causing incorrect parsing behavior. Ensure same-direction continuous data is not prematurely treated as independent complete MySQL messages when reassembly is enabled.
1 parent 4b4596e commit 126e90f

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

agent/src/ebpf/kernel/include/protocol_inference.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,30 @@ static __inline enum message_type infer_mysql_message(const char *buf,
782782

783783
bool is_mysqld = is_current_comm("mysqld");
784784
if (is_socket_info_valid(conn_info->socket_info_ptr)) {
785+
/*
786+
* When MySQL reassembly is enabled, all related traffic must be forced into
787+
* the reassembly processing pipeline.
788+
*
789+
* Otherwise, under a single-packet-based protocol detection model, the
790+
* detection capability is limited, and consecutive same-direction packets may
791+
* be incorrectly identified as complete MySQL requests or responses.
792+
*
793+
* In such cases, these packets will continue to be parsed as valid MySQL
794+
* traffic, and MSG_UNKNOWN will not be returned, thus preventing entry into
795+
* the reassembly process.
796+
*
797+
* This leads to behavior inconsistent with expectations, since correct
798+
* reassembly logic relies on returning MSG_UNKNOWN for incomplete packets in
799+
* order to trigger reassembly.
800+
*
801+
* The goal of this design is to ensure that, when reassembly is enabled,
802+
* consecutive same-direction data is not reported as independent complete
803+
* MySQL messages (requests or responses).
804+
*/
805+
if (conn_info->enable_reasm) {
806+
return MSG_UNKNOWN;
807+
}
808+
785809
/*
786810
* Ensure the authentication response packet is captured
787811
* and distinguish it based on the 5th byte (Payload start):

0 commit comments

Comments
 (0)