aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYunchih Chen <yunchih.cat@gmail.com>2018-03-20 10:26:27 +0800
committerYunchih Chen <yunchih.cat@gmail.com>2018-03-20 10:28:02 +0800
commite9b3c4ad4a137a77526e90b9d4d3092749cc26de (patch)
treef614dc2fa61dfd232f4dbea4c0ec2a5aa1a2f3b4
parent5a0f59d6b766cd8aa624f07a2b19f2b377ff51d1 (diff)
downloadnfcollect-e9b3c4ad4a137a77526e90b9d4d3092749cc26de.tar
nfcollect-e9b3c4ad4a137a77526e90b9d4d3092749cc26de.tar.gz
nfcollect-e9b3c4ad4a137a77526e90b9d4d3092749cc26de.tar.bz2
nfcollect-e9b3c4ad4a137a77526e90b9d4d3092749cc26de.tar.lz
nfcollect-e9b3c4ad4a137a77526e90b9d4d3092749cc26de.tar.xz
nfcollect-e9b3c4ad4a137a77526e90b9d4d3092749cc26de.tar.zst
nfcollect-e9b3c4ad4a137a77526e90b9d4d3092749cc26de.zip
Minimize nflog netlink socket receive buffer
We only read the meta data and the packet header and ignore packet payload
-rw-r--r--lib/collect.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/collect.c b/lib/collect.c
index 9a4e52b..3e3f7a3 100644
--- a/lib/collect.c
+++ b/lib/collect.c
@@ -139,7 +139,10 @@ void *nfl_collect_worker(void *targs) {
time(&nf->header->start_time);
int rv;
- char buf[4096];
+ // Must have at least 128 to account for sizeof(struct iphdr) +
+ // sizeof(struct tcphdr)
+ // plus the size of meta data needed by the library's data structure
+ char buf[128];
while (*p_cnt_now < cnt_max) {
if ((rv = recv(fd, buf, sizeof(buf), 0)) && rv > 0) {
debug("Recv worker #%u: nflog packet received (len=%u)",