File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import (
1010 "time"
1111
1212 "github.com/cilium/ebpf"
13+ "github.com/cilium/ebpf/link"
1314 "github.com/vishvananda/netlink"
1415 "golang.org/x/sys/unix"
1516
@@ -576,6 +577,22 @@ func (p *Probe) attach() error {
576577 return nil
577578}
578579
580+ func (p * Probe ) Iterator () (io.ReadCloser , error ) {
581+ p .stateLock .RLock ()
582+ defer p .stateLock .RUnlock ()
583+ if p .state <= paused || ! p .Enabled {
584+ return nil , ErrManagerNotStarted
585+ }
586+ if p .programSpec .AttachType != ebpf .AttachTraceIter {
587+ return nil , fmt .Errorf ("invalid program attach type %s" , p .programSpec .AttachType )
588+ }
589+ it , ok := p .progLink .(* link.Iter )
590+ if ! ok {
591+ return nil , fmt .Errorf ("invalid program attach type %T" , p .progLink )
592+ }
593+ return it .Open ()
594+ }
595+
579596// cleanupProgramSpec - Cleans up the internal ProgramSpec attribute to free up some memory
580597func (p * Probe ) cleanupProgramSpec () {
581598 if p .KeepProgramSpec {
Original file line number Diff line number Diff line change @@ -3,15 +3,22 @@ package manager
33import (
44 "fmt"
55
6+ "github.com/cilium/ebpf"
67 "github.com/cilium/ebpf/link"
78)
89
910func (p * Probe ) attachTracing () error {
1011 var err error
11- p .progLink , err = link .AttachTracing (link.TracingOptions {
12- Program : p .program ,
13- AttachType : p .programSpec .AttachType ,
14- })
12+ if p .programSpec .AttachType == ebpf .AttachTraceIter {
13+ p .progLink , err = link .AttachIter (link.IterOptions {
14+ Program : p .program ,
15+ })
16+ } else {
17+ p .progLink , err = link .AttachTracing (link.TracingOptions {
18+ Program : p .program ,
19+ AttachType : p .programSpec .AttachType ,
20+ })
21+ }
1522 if err != nil {
1623 return fmt .Errorf ("link tracing: %w" , err )
1724 }
You can’t perform that action at this time.
0 commit comments