Merge pull request #2366 from kinvolk/schu/ebpf-stop-tracker

endpoint/ebpf: implement stop
This commit is contained in:
Alfonso Acosta
2017-03-22 10:17:55 +01:00
committed by GitHub
4 changed files with 24 additions and 18 deletions

View File

@@ -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
}

File diff suppressed because one or more lines are too long

View File

@@ -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
View File

@@ -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
},