Skip to content

Commit

Permalink
fix example_sock_extract_dist_test.go
Browse files Browse the repository at this point in the history
add missing Sym label update-map
initialise minDist,
change 2 ebpf insruction in DWord load instead of word
  • Loading branch information
kwibus authored and lmb committed Dec 31, 2018
1 parent 3bf4016 commit 0b5947d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions example_sock_extract_dist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func attachBPF(fd int) (*ebpf.Map, error) {
asm.LoadMem(asm.R0, asm.R1, 16, asm.Word),

// Perhaps ipv6
asm.LoadImm(asm.R2, int64(ETH_P_IPV6), asm.Half),
asm.LoadImm(asm.R2, int64(ETH_P_IPV6), asm.DWord),
asm.HostTo(asm.BE, asm.R2, asm.Half),
asm.JEq.Reg(asm.R0, asm.R2, "ipv6"),

Expand Down Expand Up @@ -133,7 +133,7 @@ func attachBPF(fd int) (*ebpf.Map, error) {

// MapUpdate
// r1 has map ptr
asm.LoadImm(asm.R1, int64(ttls.FD()), asm.DWord),
asm.LoadImm(asm.R1, int64(ttls.FD()), asm.DWord).Sym("update-map"),
// r2 has key -> &FP[-4]
asm.Mov.Reg(asm.R2, asm.RFP),
asm.Add.Imm(asm.R2, -4),
Expand Down Expand Up @@ -177,9 +177,10 @@ func detachBPF(fd int) error {

func minDistance(ttls *ebpf.Map) (int, error) {
var (
entries = ttls.Iterate()
ttl, minDist uint32
count uint64
entries = ttls.Iterate()
ttl uint32
minDist uint32 = 255
count uint64
)
for entries.Next(&ttl, &count) {
var dist uint32
Expand Down

0 comments on commit 0b5947d

Please sign in to comment.