From e77d40fc16540e3ace4601aa2b1a44e20f1a4db2 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Sun, 30 Jul 2017 09:04:34 +0100 Subject: [PATCH] refactor: inline connectionTracker.performFlowWalk --- probe/endpoint/connection_tracker.go | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/probe/endpoint/connection_tracker.go b/probe/endpoint/connection_tracker.go index 1c944a1c17..136ee59f58 100644 --- a/probe/endpoint/connection_tracker.go +++ b/probe/endpoint/connection_tracker.go @@ -91,24 +91,17 @@ func (t *connectionTracker) ReportConnections(rpt *report.Report) { t.useProcfs() } - // 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) - } -} - -// performFlowWalk consults the flowWalker for short-lived connections -func (t *connectionTracker) performFlowWalk(rpt *report.Report) map[string]fourTuple { + // consult the flowWalker for short-lived (conntracked) connections seenTuples := map[string]fourTuple{} t.flowWalker.walkFlows(func(f flow, alive bool) { tuple := flowToTuple(f) seenTuples[tuple.key()] = tuple t.addConnection(rpt, false, tuple, "", nil, nil) }) - return seenTuples + + if t.conf.WalkProc && t.conf.Scanner != nil { + t.performWalkProc(rpt, hostNodeID, seenTuples) + } } func (t *connectionTracker) existingFlows() map[string]fourTuple {