Skip to content

Instantly share code, notes, and snippets.

@alban
Created August 8, 2017 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alban/cb4b899e9558e231d080ec7e7b3abbc5 to your computer and use it in GitHub Desktop.
Save alban/cb4b899e9558e231d080ec7e7b3abbc5 to your computer and use it in GitHub Desktop.
gobpf.patch
diff --git a/vendor/github.com/weaveworks/tcptracer-bpf/pkg/tracer/tracer.go b/vendor/github.com/weaveworks/tcptracer-bpf/pkg/tracer/tracer.go
index 8d725a3..90e32c3 100644
--- a/vendor/github.com/weaveworks/tcptracer-bpf/pkg/tracer/tracer.go
+++ b/vendor/github.com/weaveworks/tcptracer-bpf/pkg/tracer/tracer.go
@@ -15,6 +15,10 @@ type Tracer struct {
perfMapIPV4 *bpflib.PerfMap
perfMapIPV6 *bpflib.PerfMap
stopChan chan struct{}
+ channelV4 chan []byte
+ channelV6 chan []byte
+ lostChanV4 chan uint64
+ lostChanV6 chan uint64
}
// maxActive configures the maximum number of instances of the probed functions
@@ -106,6 +110,10 @@ func NewTracer(cb Callback) (*Tracer, error) {
perfMapIPV4: perfMapIPV4,
perfMapIPV6: perfMapIPV6,
stopChan: stopChan,
+ channelV4: channelV4,
+ channelV6: channelV6,
+ lostChanV4: lostChanV4,
+ lostChanV6: lostChanV6,
}, nil
}
@@ -129,8 +137,15 @@ func (t *Tracer) RemoveFdInstallWatcher(pid uint32) (err error) {
func (t *Tracer) Stop() {
close(t.stopChan)
+
t.perfMapIPV4.PollStop()
+ close(t.channelV4)
+ close(t.lostChanV4)
+
t.perfMapIPV6.PollStop()
+ close(t.channelV6)
+ close(t.lostChanV6)
+
t.m.Close()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment