From ae83c6545e31e8cc1a691adf0e65906507420e9a Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Mon, 14 Oct 2019 08:22:21 +0000 Subject: [PATCH] fix(probe/ebpf): feed initial connections synchronously on restart If we run `getInitialState()` async there is some chance we will see another ebpf failure and call `useProcfs()` before `getInitialState()` gets to the last line, whereupon it will crash on nil pointer. Also it seems pointless to call `performEbpfTrack()` without waiting for something to feed in, so I suspect this is what the original author had in mind. It will slow down this one `Report()` on machines with a lot of processes or connections, but ebpfTracker restart is supposed to be a rare event. --- probe/endpoint/connection_tracker.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/probe/endpoint/connection_tracker.go b/probe/endpoint/connection_tracker.go index ce39ced15..92fe84b58 100644 --- a/probe/endpoint/connection_tracker.go +++ b/probe/endpoint/connection_tracker.go @@ -86,7 +86,7 @@ func (t *connectionTracker) ReportConnections(rpt *report.Report) { log.Warnf("ebpf tracker died, restarting it") err := t.ebpfTracker.restart() if err == nil { - go t.getInitialState() + t.getInitialState() t.performEbpfTrack(rpt, hostNodeID) return }