Skip to content

Commit

Permalink
avoid and debug bogus ipv6 connection info on go_nethttp and go_grpc …
Browse files Browse the repository at this point in the history
…connections
  • Loading branch information
esara committed Jul 17, 2024
1 parent 27dc018 commit ee3f85f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions pkg/internal/ebpf/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,21 @@ func cstr(chars []uint8) string {
}

func (connInfo *BPFConnInfo) reqHostInfo() (source, target string) {
oneAddress := [16]uint8{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}

src := make(net.IP, net.IPv6len)
dst := make(net.IP, net.IPv6len)
copy(src, connInfo.S_addr[:])
copy(dst, connInfo.D_addr[:])

switch {
case bytes.Equal(connInfo.S_addr[:], oneAddress[:]) ||
bytes.Equal(connInfo.D_addr[:], oneAddress[:]):
// If the address is not valid, return an empty string
return "", ""
default:
// If the address is valid, copy the entire address
copy(src, connInfo.S_addr[:])
copy(dst, connInfo.D_addr[:])
}

srcStr := src.String()
dstStr := dst.String()
Expand Down

0 comments on commit ee3f85f

Please sign in to comment.