mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-11-23 12:30:46 +01:00
Use native endianness when encoding InetDiagMsg (#2508)
Note however that the InetDiagMsg struct contains a InetDiagSockID member, which itself contains some members which are explicitly specified as big-endian in Linux kernel source: struct inet_diag_sockid { __be16 idiag_sport; __be16 idiag_dport; __be32 idiag_src[4]; __be32 idiag_dst[4]; __u32 idiag_if; __u32 idiag_cookie[2]; }; node_exporter currently does not use these members for anything, so this is acceptable (for now). Signed-off-by: Daniel Swarbrick <daniel.swarbrick@gmail.com>
This commit is contained in:
parent
87b8e3790d
commit
34a498e132
@ -19,13 +19,14 @@ import (
|
||||
"syscall"
|
||||
"testing"
|
||||
|
||||
"github.com/josharian/native"
|
||||
"github.com/mdlayher/netlink"
|
||||
)
|
||||
|
||||
func Test_parseTCPStats(t *testing.T) {
|
||||
encode := func(m InetDiagMsg) []byte {
|
||||
var buf bytes.Buffer
|
||||
err := binary.Write(&buf, binary.LittleEndian, m)
|
||||
err := binary.Write(&buf, native.Endian, m)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
2
go.mod
2
go.mod
@ -12,6 +12,7 @@ require (
|
||||
github.com/hashicorp/go-envparse v0.0.0-20200406174449-d9cfd743a15e
|
||||
github.com/hodgesds/perf-utils v0.5.1
|
||||
github.com/illumos/go-kstat v0.0.0-20210513183136-173c9b0a9973
|
||||
github.com/josharian/native v1.0.0
|
||||
github.com/jsimonetti/rtnetlink v1.2.2
|
||||
github.com/lufia/iostat v1.2.1
|
||||
github.com/mattn/go-xmlrpc v0.0.3
|
||||
@ -39,7 +40,6 @@ require (
|
||||
github.com/go-logfmt/logfmt v0.5.1 // indirect
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/google/go-cmp v0.5.9 // indirect
|
||||
github.com/josharian/native v1.0.0 // indirect
|
||||
github.com/jpillora/backoff v1.0.0 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
|
||||
github.com/mdlayher/genetlink v1.2.0 // indirect
|
||||
|
Loading…
Reference in New Issue
Block a user