From d481465e72029938af3cd7fffc7824c472dfa42e Mon Sep 17 00:00:00 2001 From: Simone Mainardi Date: Fri, 12 Jun 2020 10:59:20 +0200 Subject: [PATCH] Fixes flow exporter filtering Fixes #4033 --- include/Flow.h | 12 +++--------- src/NetworkInterface.cpp | 2 +- src/ParserInterface.cpp | 14 +++----------- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/include/Flow.h b/include/Flow.h index d6684c13dc..e810e55402 100644 --- a/include/Flow.h +++ b/include/Flow.h @@ -637,15 +637,9 @@ class Flow : public GenericHashEntry { +((float)(serverNwLatency.tv_usec + clientNwLatency.tv_usec)) / (float)1000000; } inline void setFlowApplLatency(float latency_msecs) { applLatencyMsec = latency_msecs; } - inline bool setFlowDevice(u_int32_t device_ip, u_int16_t inidx, u_int16_t outidx) { - if((flow_device.device_ip > 0 && flow_device.device_ip != device_ip) - || (flow_device.in_index > 0 && flow_device.in_index != inidx) - || (flow_device.out_index > 0 && flow_device.out_index != outidx)) - return false; - if(device_ip) flow_device.device_ip = device_ip; - if(inidx) flow_device.in_index = inidx; - if(outidx) flow_device.out_index = outidx; - return true; + inline void setFlowDevice(u_int32_t device_ip, u_int16_t inidx, u_int16_t outidx) { + flow_device.device_ip = device_ip; + flow_device.in_index = inidx, flow_device.out_index = outidx; } inline u_int32_t getFlowDeviceIp() { return flow_device.device_ip; }; inline u_int16_t getFlowDeviceInIndex() { return flow_device.in_index; }; diff --git a/src/NetworkInterface.cpp b/src/NetworkInterface.cpp index 5ea1fd4bd7..e36b0a8130 100644 --- a/src/NetworkInterface.cpp +++ b/src/NetworkInterface.cpp @@ -3343,7 +3343,7 @@ static bool flow_matches(Flow *f, struct flowHostRetriever *retriever) { u_int32_t asn_filter; char* username_filter; char* pidname_filter; - u_int32_t deviceIP; + u_int32_t deviceIP = 0; u_int16_t inIndex, outIndex; u_int8_t icmp_type, icmp_code; #ifdef NTOPNG_PRO diff --git a/src/ParserInterface.cpp b/src/ParserInterface.cpp index a1f2d2823a..32fa32d747 100755 --- a/src/ParserInterface.cpp +++ b/src/ParserInterface.cpp @@ -236,17 +236,9 @@ void ParserInterface::processFlow(ParsedFlow *zflow) { flow->updateSeen(); } - /* Update flow device stats */ - if(!flow->setFlowDevice(zflow->device_ip, - src2dst_direction ? zflow->inIndex : zflow->outIndex, - src2dst_direction ? zflow->outIndex : zflow->inIndex)) { - static bool flow_device_already_set = false; - if(!flow_device_already_set) { - ntop->getTrace()->traceEvent(TRACE_WARNING, "A flow has been seen from multiple exporters or from " - "multiple IN/OUT interfaces. Check exporters configuration."); - flow_device_already_set = true; - } - } + flow->setFlowDevice(zflow->device_ip, + src2dst_direction ? zflow->inIndex : zflow->outIndex, + src2dst_direction ? zflow->outIndex : zflow->inIndex); #ifdef MAC_DEBUG char bufm1[32], bufm2[32];