From 07e7adbd631e15b13b825f28a8210cc6f94f8591 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Mon, 10 Jul 2017 07:22:12 +0100 Subject: [PATCH] refactor: make performFlowWalk data flow more obvious --- probe/endpoint/connection_tracker.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/probe/endpoint/connection_tracker.go b/probe/endpoint/connection_tracker.go index 7d6f7ea2c..b7c38f263 100644 --- a/probe/endpoint/connection_tracker.go +++ b/probe/endpoint/connection_tracker.go @@ -91,16 +91,18 @@ func (t *connectionTracker) ReportConnections(rpt *report.Report) { t.useProcfs() } - // seenTuples contains information about connections seen by conntrack and it will be passed to the /proc parser - seenTuples := map[string]fourTuple{} - t.performFlowWalk(rpt, seenTuples) + // seenTuples contains information about connections seen by + // conntrack + seenTuples := t.performFlowWalk(rpt) + if t.conf.WalkProc && t.conf.Scanner != nil { t.performWalkProc(rpt, hostNodeID, seenTuples) } } -func (t *connectionTracker) performFlowWalk(rpt *report.Report, seenTuples map[string]fourTuple) { - // Consult the flowWalker for short-lived connections +// performFlowWalk consults the flowWalker for short-lived connections +func (t *connectionTracker) performFlowWalk(rpt *report.Report) map[string]fourTuple { + seenTuples := map[string]fourTuple{} extraNodeInfo := map[string]string{ Conntracked: "true", } @@ -109,6 +111,7 @@ func (t *connectionTracker) performFlowWalk(rpt *report.Report, seenTuples map[s seenTuples[tuple.key()] = tuple t.addConnection(rpt, tuple, "", extraNodeInfo, extraNodeInfo) }) + return seenTuples } func (t *connectionTracker) performWalkProc(rpt *report.Report, hostNodeID string, seenTuples map[string]fourTuple) error {