Skip to content

Commit

Permalink
examples: avoid depending on internal packages
Browse files Browse the repository at this point in the history
Technically this builds fine in CI, but these are supposed to function from
outside the repo's ebpf module as well. These internal references were added
after we removed the separate Go module from examples/.

Signed-off-by: antoniomerlin <[email protected]>
Signed-off-by: Timo Beckers <[email protected]>
  • Loading branch information
antoniomerlin authored and ti-mo committed Mar 22, 2024
1 parent 9a277ae commit cef96c3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
5 changes: 2 additions & 3 deletions examples/tcprtt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"os/signal"
"syscall"

"github.com/cilium/ebpf/internal"
"github.com/cilium/ebpf/link"
"github.com/cilium/ebpf/ringbuf"
"github.com/cilium/ebpf/rlimit"
Expand Down Expand Up @@ -90,7 +89,7 @@ func readLoop(rd *ringbuf.Reader) {
}

// Parse the ringbuf event entry into a bpfEvent structure.
if err := binary.Read(bytes.NewBuffer(record.RawSample), internal.NativeEndian, &event); err != nil {
if err := binary.Read(bytes.NewBuffer(record.RawSample), binary.NativeEndian, &event); err != nil {
log.Printf("parsing ringbuf event: %s", err)
continue
}
Expand All @@ -108,6 +107,6 @@ func readLoop(rd *ringbuf.Reader) {
// intToIP converts IPv4 number to net.IP
func intToIP(ipNum uint32) net.IP {
ip := make(net.IP, 4)
internal.NativeEndian.PutUint32(ip, ipNum)
binary.NativeEndian.PutUint32(ip, ipNum)
return ip
}
3 changes: 1 addition & 2 deletions examples/tcprtt_sockops/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
"syscall"

"github.com/cilium/ebpf"
"github.com/cilium/ebpf/internal"
"github.com/cilium/ebpf/link"
"github.com/cilium/ebpf/ringbuf"
"github.com/cilium/ebpf/rlimit"
Expand Down Expand Up @@ -126,7 +125,7 @@ func readLoop(rd *ringbuf.Reader) {
}

// Parse the ringbuf event entry into a bpfRttEvent structure.
if err := binary.Read(bytes.NewBuffer(record.RawSample), internal.NativeEndian, &event); err != nil {
if err := binary.Read(bytes.NewBuffer(record.RawSample), binary.NativeEndian, &event); err != nil {
log.Printf("parsing ringbuf event: %s", err)
continue
}
Expand Down

0 comments on commit cef96c3

Please sign in to comment.