mirror of
git://git.code.sf.net/p/xtables-addons/xtables-addons
synced 2025-09-07 13:15:12 +02:00
xt_ACCOUNT: make counters 64-bit wide
The Smoothwall Express traffic stats collector (traffiClogger) does not handle counter rollovers well and does not perform read&flush. (Yes, the code is somewhat aged.) To change it to perform read&flush is non-trivial. Then, it occurred to me that it might be easier to change ipt_ACCOUNT in xtables-addons to use 64-bit counters, considering it was designed around single kernel pages. The following submission counts to at least 100 GB, produces no obvious kernel gripes, and adjacent counters do not seem to interfere with each other. Yes, it uses more memory, but RAM costs much less than bugs that grown out of complex software. The theory: - Use two kernel pages for the counters for each group of 256 addresses. - Change counters to 64-bit. - Change to __get_free_pages/free_pages, using order=2 (two consecutive pages), and zero both pages. - Change "%u" to "%llu" as needed. - Everything else pretty much stays the same. I also changed tmpbuf to two pages (Justin Case's idea), but I do not know if that's really necessary.
This commit is contained in:

committed by
Jan Engelhardt

parent
a576f4d43e
commit
1324442bce
@@ -200,11 +200,11 @@ int main(int argc, char *argv[])
|
||||
while ((entry = ipt_ACCOUNT_get_next_entry(&ctx)) != NULL)
|
||||
{
|
||||
if (doCSV)
|
||||
printf("%s;%u;%u;%u;%u\n",
|
||||
printf("%s;%llu;%llu;%llu;%llu\n",
|
||||
addr_to_dotted(entry->ip), entry->src_packets, entry->src_bytes,
|
||||
entry->dst_packets, entry->dst_bytes);
|
||||
else
|
||||
printf("IP: %s SRC packets: %u bytes: %u DST packets: %u bytes: %u\n",
|
||||
printf("IP: %s SRC packets: %llu bytes: %llu DST packets: %llu bytes: %llu\n",
|
||||
addr_to_dotted(entry->ip), entry->src_packets, entry->src_bytes,
|
||||
entry->dst_packets, entry->dst_bytes);
|
||||
}
|
||||
|
Reference in New Issue
Block a user