A final(?) effort to reduce memory usage per flow (#1389)
Remove some unused fields and re-organize other ones. In particular: * Update the parameters of `ndpi_ssl_version2str()` function * Zattoo, Thunder: these timestamps aren't really used. * Ftp/mail: these protocols are dissected only over TCP. * Attention must be paid to TLS.Bittorrent flows to avoid invalid read/write to `flow->protos.bittorrent.hash` field. This is the last(?) commit of a long series (see22241a1d,227e586e,730c2360,a8ffcd8b) aiming to reduce library memory consumption. Before, at nDPI 4.0 (more precisly, ata6b10cf7, because memory stats were wrong until that commit): ``` nDPI Memory statistics: nDPI Memory (once): 221.15 KB Flow Memory (per flow): 2.94 KB ``` Now: ``` nDPI Memory statistics: nDPI Memory (once): 231.71 KB Flow Memory (per flow): 1008 B <--------- ``` i.e. memory usage per flow has been reduced by 66%, dropping below the psychological threshold of 1 KB. To further reduce this value, we probably need to look into #1279: let's fight this battle another day.
This commit is contained in:
@@ -77,8 +77,8 @@ static int ndpi_int_mail_pop_check_for_client_commands(struct ndpi_detection_mod
|
||||
&& (packet->payload[1] == 'S' || packet->payload[1] == 's')
|
||||
&& (packet->payload[2] == 'E' || packet->payload[2] == 'e')
|
||||
&& (packet->payload[3] == 'R' || packet->payload[3] == 'r')) {
|
||||
ndpi_user_pwd_payload_copy((u_int8_t*)flow->ftp_imap_pop_smtp.username,
|
||||
sizeof(flow->ftp_imap_pop_smtp.username), 5,
|
||||
ndpi_user_pwd_payload_copy((u_int8_t*)flow->l4.tcp.ftp_imap_pop_smtp.username,
|
||||
sizeof(flow->l4.tcp.ftp_imap_pop_smtp.username), 5,
|
||||
packet->payload, packet->payload_packet_len);
|
||||
|
||||
ndpi_set_risk(ndpi_struct, flow, NDPI_CLEAR_TEXT_CREDENTIALS);
|
||||
@@ -88,8 +88,8 @@ static int ndpi_int_mail_pop_check_for_client_commands(struct ndpi_detection_mod
|
||||
&& (packet->payload[1] == 'A' || packet->payload[1] == 'a')
|
||||
&& (packet->payload[2] == 'S' || packet->payload[2] == 's')
|
||||
&& (packet->payload[3] == 'S' || packet->payload[3] == 's')) {
|
||||
ndpi_user_pwd_payload_copy((u_int8_t*)flow->ftp_imap_pop_smtp.password,
|
||||
sizeof(flow->ftp_imap_pop_smtp.password), 5,
|
||||
ndpi_user_pwd_payload_copy((u_int8_t*)flow->l4.tcp.ftp_imap_pop_smtp.password,
|
||||
sizeof(flow->l4.tcp.ftp_imap_pop_smtp.password), 5,
|
||||
packet->payload, packet->payload_packet_len);
|
||||
|
||||
ndpi_set_risk(ndpi_struct, flow, NDPI_CLEAR_TEXT_CREDENTIALS);
|
||||
@@ -182,7 +182,7 @@ void ndpi_search_mail_pop_tcp(struct ndpi_detection_module_struct
|
||||
if(flow->l4.tcp.mail_pop_stage > 0) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "mail_pop identified\n");
|
||||
|
||||
if((flow->ftp_imap_pop_smtp.password[0] != '\0')
|
||||
if((flow->l4.tcp.ftp_imap_pop_smtp.password[0] != '\0')
|
||||
|| (flow->l4.tcp.mail_pop_stage > 3)) {
|
||||
ndpi_int_mail_pop_add_connection(ndpi_struct, flow);
|
||||
popInitExtraPacketProcessing(flow);
|
||||
@@ -222,7 +222,7 @@ int ndpi_extra_search_mail_pop_tcp(struct ndpi_detection_module_struct *ndpi_str
|
||||
|
||||
ndpi_search_mail_pop_tcp(ndpi_struct, flow);
|
||||
|
||||
rc = (flow->ftp_imap_pop_smtp.password[0] == '\0') ? 1 : 0;
|
||||
rc = (flow->l4.tcp.ftp_imap_pop_smtp.password[0] == '\0') ? 1 : 0;
|
||||
|
||||
#ifdef POP_DEBUG
|
||||
printf("**** %s() [rc: %d]\n", __FUNCTION__, rc);
|
||||
|
||||
Reference in New Issue
Block a user