diff options
author | Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> | 2021-12-22 19:54:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-22 19:54:06 +0100 |
commit | 91bb77a8806ee2987e856f66674cf3aa8b1d60db (patch) | |
tree | 0f2a06cc9b64a8af221552e87ae771ac882ab4b5 /src/lib/protocols/mail_imap.c | |
parent | 02da143e4567cbfe32b139561ec3a702ce380fc7 (diff) |
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 (see 22241a1d, 227e586e,
730c2360, a8ffcd8b) aiming to reduce library memory consumption.
Before, at nDPI 4.0 (more precisly, at a6b10cf7, 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.
Diffstat (limited to 'src/lib/protocols/mail_imap.c')
-rw-r--r-- | src/lib/protocols/mail_imap.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/lib/protocols/mail_imap.c b/src/lib/protocols/mail_imap.c index 8a4e8fa2e..317ac1848 100644 --- a/src/lib/protocols/mail_imap.c +++ b/src/lib/protocols/mail_imap.c @@ -177,16 +177,16 @@ void ndpi_search_mail_imap_tcp(struct ndpi_detection_module_struct *ndpi_struct, if(user) { char *pwd; - snprintf(flow->ftp_imap_pop_smtp.username, - sizeof(flow->ftp_imap_pop_smtp.username), + snprintf(flow->l4.tcp.ftp_imap_pop_smtp.username, + sizeof(flow->l4.tcp.ftp_imap_pop_smtp.username), "%s", user); ndpi_set_risk(ndpi_struct, flow, NDPI_CLEAR_TEXT_CREDENTIALS); pwd = strtok_r(NULL, " \"\r\n", &saveptr); if(pwd) { - snprintf(flow->ftp_imap_pop_smtp.password, - sizeof(flow->ftp_imap_pop_smtp.password), + snprintf(flow->l4.tcp.ftp_imap_pop_smtp.password, + sizeof(flow->l4.tcp.ftp_imap_pop_smtp.password), "%s", pwd); } } @@ -320,7 +320,7 @@ void ndpi_search_mail_imap_tcp(struct ndpi_detection_module_struct *ndpi_struct, || (flow->l4.tcp.mail_imap_stage == 5) || (flow->l4.tcp.mail_imap_stage == 7) ) { - if((flow->ftp_imap_pop_smtp.username[0] != '\0') + if((flow->l4.tcp.ftp_imap_pop_smtp.username[0] != '\0') || (flow->l4.tcp.mail_imap_stage >= 7)) { NDPI_LOG_INFO(ndpi_struct, "found MAIL_IMAP\n"); ndpi_int_mail_imap_add_connection(ndpi_struct, flow); |