mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-05 19:21:46 +00:00
Merge pull request #2366 from kinvolk/schu/ebpf-stop-tracker
endpoint/ebpf: implement stop
This commit is contained in:
@@ -209,15 +209,8 @@ func (t *EbpfTracker) isDead() bool {
|
||||
}
|
||||
|
||||
func (t *EbpfTracker) stop() {
|
||||
// TODO: implement proper stopping logic
|
||||
//
|
||||
// Even if we stop the go routine, it's not enough since we disabled the
|
||||
// async proc parser. We leave this uninmplemented for now because:
|
||||
//
|
||||
// * Ebpf parsing is optional (need to be enabled explicitly with
|
||||
// --probe.ebpf.connections=true), if a user enables it we assume they
|
||||
// check on the logs whether it works or not
|
||||
//
|
||||
// * It's unlikely that the ebpf tracker stops working if it started
|
||||
// successfully and if it does, we probaby want it to fail hard
|
||||
if t.tracer != nil {
|
||||
t.tracer.Stop()
|
||||
}
|
||||
t.dead = true
|
||||
}
|
||||
|
||||
4
vendor/github.com/weaveworks/tcptracer-bpf/pkg/tracer/tcptracer-ebpf.go
generated
vendored
4
vendor/github.com/weaveworks/tcptracer-bpf/pkg/tracer/tcptracer-ebpf.go
generated
vendored
File diff suppressed because one or more lines are too long
21
vendor/github.com/weaveworks/tcptracer-bpf/pkg/tracer/tracer.go
generated
vendored
21
vendor/github.com/weaveworks/tcptracer-bpf/pkg/tracer/tracer.go
generated
vendored
@@ -13,6 +13,7 @@ type Tracer struct {
|
||||
m *bpflib.Module
|
||||
perfMapIPV4 *bpflib.PerfMap
|
||||
perfMapIPV6 *bpflib.PerfMap
|
||||
stopChan chan struct{}
|
||||
}
|
||||
|
||||
func TracerAsset() ([]byte, error) {
|
||||
@@ -61,17 +62,27 @@ func NewTracer(tcpEventCbV4 func(TcpV4), tcpEventCbV6 func(TcpV6)) (*Tracer, err
|
||||
perfMapIPV4.SetTimestampFunc(tcpV4Timestamp)
|
||||
perfMapIPV6.SetTimestampFunc(tcpV6Timestamp)
|
||||
|
||||
stopChan := make(chan struct{})
|
||||
|
||||
go func() {
|
||||
for {
|
||||
data := <-channelV4
|
||||
tcpEventCbV4(tcpV4ToGo(&data))
|
||||
select {
|
||||
case <-stopChan:
|
||||
return
|
||||
case data := <-channelV4:
|
||||
tcpEventCbV4(tcpV4ToGo(&data))
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
go func() {
|
||||
for {
|
||||
data := <-channelV6
|
||||
tcpEventCbV6(tcpV6ToGo(&data))
|
||||
select {
|
||||
case <-stopChan:
|
||||
return
|
||||
case data := <-channelV6:
|
||||
tcpEventCbV6(tcpV6ToGo(&data))
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -82,10 +93,12 @@ func NewTracer(tcpEventCbV4 func(TcpV4), tcpEventCbV6 func(TcpV6)) (*Tracer, err
|
||||
m: m,
|
||||
perfMapIPV4: perfMapIPV4,
|
||||
perfMapIPV6: perfMapIPV6,
|
||||
stopChan: stopChan,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (t *Tracer) Stop() {
|
||||
close(t.stopChan)
|
||||
t.perfMapIPV4.PollStop()
|
||||
t.perfMapIPV6.PollStop()
|
||||
}
|
||||
|
||||
2
vendor/manifest
vendored
2
vendor/manifest
vendored
@@ -1454,7 +1454,7 @@
|
||||
"importpath": "github.com/weaveworks/tcptracer-bpf",
|
||||
"repository": "https://github.com/weaveworks/tcptracer-bpf",
|
||||
"vcs": "git",
|
||||
"revision": "9065e4672b606b5f8d2f2d664938641fa0ee0d0f",
|
||||
"revision": "d4a42f2cc89eb19e60113f7e35945a29b97c695f",
|
||||
"branch": "master",
|
||||
"notests": true
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user