jsimonetti/rtnetlink

Support big endian cpu architectures

eclipseo opened this issue · 5 comments

I'm trying to build rtnetlink on Fedora and I'm encountering issues running tests on s390x:

Testing    in: /builddir/build/BUILD/rtnetlink-9527aa82566a98cba454092e94cddf4dd943e960/_build/src
         PATH: /builddir/build/BUILD/rtnetlink-9527aa82566a98cba454092e94cddf4dd943e960/_build/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin
       GOPATH: /builddir/build/BUILD/rtnetlink-9527aa82566a98cba454092e94cddf4dd943e960/_build:/usr/share/gocode
  GO111MODULE: off
      command: go test -buildmode pie -compiler gc -ldflags "-X github.com/jsimonetti/rtnetlink/version.commit=9527aa82566a98cba454092e94cddf4dd943e960 -X github.com/jsimonetti/rtnetlink/version=0 -extldflags '-Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld '"
      testing: github.com/jsimonetti/rtnetlink
github.com/jsimonetti/rtnetlink
--- FAIL: TestAddressMessageMarshalBinary (0.00s)
    --- FAIL: TestAddressMessageMarshalBinary/empty (0.00s)
        address_test.go:80: unexpected Message bytes:
            - want: [0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x06 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x04 0x00 0x01 0x00 0x04 0x00 0x04 0x00 0x04 0x00 0x05 0x00 0x04 0x00 0x07 0x00 0x08 0x00 0x08 0x00 0x00 0x00 0x00 0x00]
            -  got: [0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x06 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x04 0x00 0x01 0x00 0x04 0x00 0x04 0x00 0x04 0x00 0x05 0x00 0x04 0x00 0x07 0x00 0x08 0x00 0x08 0x00 0x00 0x00 0x00]
    --- FAIL: TestAddressMessageMarshalBinary/no_attributes (0.00s)
        address_test.go:80: unexpected Message bytes:
            - want: [0x02 0x08 0x00 0x00 0x01 0x00 0x00 0x00 0x06 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x04 0x00 0x01 0x00 0x04 0x00 0x04 0x00 0x04 0x00 0x05 0x00 0x04 0x00 0x07 0x00 0x08 0x00 0x08 0x00 0x00 0x00 0x00 0x00]
            -  got: [0x02 0x08 0x00 0x00 0x00 0x00 0x00 0x01 0x00 0x06 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x04 0x00 0x01 0x00 0x04 0x00 0x04 0x00 0x04 0x00 0x05 0x00 0x04 0x00 0x07 0x00 0x08 0x00 0x08 0x00 0x00 0x00 0x00]
    --- FAIL: TestAddressMessageMarshalBinary/attributes (0.00s)
        address_test.go:80: unexpected Message bytes:
            - want: [0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x06 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x0a 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x0a 0x00 0x04 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x04 0x00 0x05 0x00 0x04 0x00 0x07 0x00 0x08 0x00 0x08 0x00 0x00 0x00 0x00 0x00]
            -  got: [0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x06 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x0a 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x0a 0x00 0x04 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x04 0x00 0x05 0x00 0x04 0x00 0x07 0x00 0x08 0x00 0x08 0x00 0x00 0x00 0x00]
--- FAIL: TestAddressMessageUnmarshalBinary (0.00s)
    --- FAIL: TestAddressMessageUnmarshalBinary/invalid_attr (0.00s)
        address_test.go:159: unexpected error:
            - want: rtnetlink AddressMessage has a wrong attribute data length
            -  got: invalid attribute; length too short or too large
    --- FAIL: TestAddressMessageUnmarshalBinary/data (0.00s)
        address_test.go:159: unexpected error:
            - want: <nil>
            -  got: invalid attribute; length too short or too large
--- FAIL: TestConnExecute (0.00s)
    conn_test.go:66: unexpected replies:
        - want: []rtnetlink.LinkMessage{rtnetlink.LinkMessage{Family:0x101, Type:0x0, Index:0x4030201, Flags:0x101, Change:0x4030201, Attributes:(*rtnetlink.LinkAttributes)(nil)}}
        -  got: []rtnetlink.LinkMessage{rtnetlink.LinkMessage{Family:0x101, Type:0x0, Index:0x1020304, Flags:0x1010000, Change:0x1020304, Attributes:(*rtnetlink.LinkAttributes)(nil)}}
--- FAIL: TestConnReceive (0.00s)
    conn_test.go:168: unexpected Messages from Conn.Receive:
        - want: []rtnetlink.LinkMessage{rtnetlink.LinkMessage{Family:0x0, Type:0x0, Index:0x0, Flags:0x0, Change:0x0, Attributes:(*rtnetlink.LinkAttributes)(nil)}, rtnetlink.LinkMessage{Family:0x102, Type:0x0, Index:0x4030201, Flags:0x102, Change:0x4030201, Attributes:(*rtnetlink.LinkAttributes)(nil)}}
        -  got: []rtnetlink.LinkMessage{rtnetlink.LinkMessage{Family:0x0, Type:0x0, Index:0x0, Flags:0x0, Change:0x0, Attributes:(*rtnetlink.LinkAttributes)(nil)}, rtnetlink.LinkMessage{Family:0x201, Type:0x0, Index:0x1020304, Flags:0x2010000, Change:0x1020304, Attributes:(*rtnetlink.LinkAttributes)(nil)}}
--- FAIL: TestLinkMessageMarshalBinary (0.00s)
    --- FAIL: TestLinkMessageMarshalBinary/no_attributes (0.00s)
        link_test.go:168: unexpected Message bytes:
            - want: [0x00 0x00 0x01 0x00 0x02 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
            -  got: [0x00 0x00 0x00 0x01 0x00 0x00 0x00 0x02 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
    --- FAIL: TestLinkMessageMarshalBinary/no_attributes_with_flags (0.00s)
        link_test.go:168: unexpected Message bytes:
            - want: [0x00 0x00 0x01 0x00 0x02 0x00 0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
            -  got: [0x00 0x00 0x00 0x01 0x00 0x00 0x00 0x02 0x00 0x00 0x00 0x01 0x00 0x00 0x00 0x00]
    --- FAIL: TestLinkMessageMarshalBinary/attributes (0.00s)
        link_test.go:168: unexpected Message bytes:
            - want: [0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x06 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x07 0x00 0x03 0x00 0x6c 0x6f 0x00 0x00 0x08 0x00 0x05 0x00 0x00 0x00 0x00 0x00 0x05 0x00 0x06 0x00 0x00 0x00 0x00 0x00 0x0a 0x00 0x01 0x00 0x40 0x41 0x42 0x43 0x44 0x45 0x00 0x00 0x0a 0x00 0x02 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0x00 0x00]
            -  got: [0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x06 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x07 0x00 0x03 0x6c 0x6f 0x00 0x00 0x00 0x08 0x00 0x05 0x00 0x00 0x00 0x00 0x00 0x05 0x00 0x06 0x00 0x00 0x00 0x00 0x00 0x0a 0x00 0x01 0x40 0x41 0x42 0x43 0x44 0x45 0x00 0x00 0x00 0x0a 0x00 0x02 0xff 0xff 0xff 0xff 0xff 0xff 0x00 0x00]
    --- FAIL: TestLinkMessageMarshalBinary/attributes_ipip (0.00s)
        link_test.go:168: unexpected Message bytes:
            - want: [0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x06 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x09 0x00 0x03 0x00 0x69 0x70 0x69 0x70 0x00 0x00 0x00 0x00 0x08 0x00 0x05 0x00 0x00 0x00 0x00 0x00 0x05 0x00 0x06 0x00 0x00 0x00 0x00 0x00 0x08 0x00 0x01 0x00 0x0a 0x00 0x00 0x01 0x08 0x00 0x02 0x00 0xff 0xff 0xff 0xff]
            -  got: [0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x06 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x09 0x00 0x03 0x69 0x70 0x69 0x70 0x00 0x00 0x00 0x00 0x00 0x08 0x00 0x05 0x00 0x00 0x00 0x00 0x00 0x05 0x00 0x06 0x00 0x00 0x00 0x00 0x00 0x08 0x00 0x01 0x0a 0x00 0x00 0x01 0x00 0x08 0x00 0x02 0xff 0xff 0xff 0xff]
    --- FAIL: TestLinkMessageMarshalBinary/info (0.00s)
        link_test.go:168: unexpected Message bytes:
            - want: [0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x06 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x07 0x00 0x03 0x00 0x6c 0x6f 0x00 0x00 0x08 0x00 0x05 0x00 0x00 0x00 0x00 0x00 0x05 0x00 0x06 0x00 0x00 0x00 0x00 0x00 0x0a 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x0a 0x00 0x02 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x38 0x00 0x12 0x00 0x09 0x00 0x01 0x00 0x64 0x61 0x74 0x61 0x00 0x00 0x00 0x00 0x0d 0x00 0x02 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x00 0x00 0x00 0x08 0x00 0x04 0x00 0x66 0x6f 0x6f 0x00 0x0d 0x00 0x05 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x00 0x00 0x00]
            -  got: [0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x06 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x07 0x00 0x03 0x6c 0x6f 0x00 0x00 0x00 0x08 0x00 0x05 0x00 0x00 0x00 0x00 0x00 0x05 0x00 0x06 0x00 0x00 0x00 0x00 0x00 0x0a 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x0a 0x00 0x02 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x38 0x00 0x12 0x00 0x09 0x00 0x01 0x64 0x61 0x74 0x61 0x00 0x00 0x00 0x00 0x00 0x0d 0x00 0x02 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x00 0x00 0x00 0x00 0x08 0x00 0x04 0x66 0x6f 0x6f 0x00 0x00 0x0d 0x00 0x05 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x00 0x00 0x00]
    --- FAIL: TestLinkMessageMarshalBinary/operational_state (0.00s)
        link_test.go:168: unexpected Message bytes:
            - want: [0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x06 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x09 0x00 0x03 0x00 0x69 0x70 0x69 0x70 0x00 0x00 0x00 0x00 0x08 0x00 0x05 0x00 0x00 0x00 0x00 0x00 0x05 0x00 0x06 0x00 0x00 0x00 0x00 0x00 0x08 0x00 0x01 0x00 0x0a 0x00 0x00 0x01 0x08 0x00 0x02 0x00 0xff 0xff 0xff 0xff 0x05 0x00 0x10 0x00 0x06 0x00 0x00 0x00]
            -  got: [0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x06 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x09 0x00 0x03 0x69 0x70 0x69 0x70 0x00 0x00 0x00 0x00 0x00 0x08 0x00 0x05 0x00 0x00 0x00 0x00 0x00 0x05 0x00 0x06 0x00 0x00 0x00 0x00 0x00 0x08 0x00 0x01 0x0a 0x00 0x00 0x01 0x00 0x08 0x00 0x02 0xff 0xff 0xff 0xff 0x00 0x05 0x00 0x10 0x06 0x00 0x00 0x00]
--- FAIL: TestLinkMessageUnmarshalBinary (0.00s)
    --- FAIL: TestLinkMessageUnmarshalBinary/invalid_attr (0.00s)
        link_test.go:362: unexpected error:
            - want: rtnetlink LinkMessage has a wrong attribute data length
            -  got: invalid attribute; length too short or too large
    --- FAIL: TestLinkMessageUnmarshalBinary/zero_value (0.00s)
        link_test.go:362: unexpected error:
            - want: <nil>
            -  got: invalid attribute; length too short or too large
    --- FAIL: TestLinkMessageUnmarshalBinary/no_data (0.00s)
        link_test.go:362: unexpected error:
            - want: <nil>
            -  got: invalid attribute; length too short or too large
    --- FAIL: TestLinkMessageUnmarshalBinary/data (0.00s)
        link_test.go:362: unexpected error:
            - want: <nil>
            -  got: invalid attribute; length too short or too large
    --- FAIL: TestLinkMessageUnmarshalBinary/attributes_ipip (0.00s)
        link_test.go:362: unexpected error:
            - want: <nil>
            -  got: invalid attribute; length too short or too large
    --- FAIL: TestLinkMessageUnmarshalBinary/info (0.00s)
        link_test.go:362: unexpected error:
            - want: <nil>
            -  got: invalid attribute; length too short or too large
    --- FAIL: TestLinkMessageUnmarshalBinary/operational_state (0.00s)
        link_test.go:362: unexpected error:
            - want: <nil>
            -  got: invalid attribute; length too short or too large
--- FAIL: TestLinkStats64UnmarshalBinary (0.00s)
    --- FAIL: TestLinkStats64UnmarshalBinary/kernel_<4.6 (0.00s)
        link_test.go:656: unexpected Message:
            - want: &rtnetlink.LinkStats64{RXPackets:0x1b650, TXPackets:0xc906, RXBytes:0x9cd41a9, TXBytes:0x2a9696, RXErrors:0x0, TXErrors:0x0, RXDropped:0x0, TXDropped:0x0, Multicast:0x0, Collisions:0x0, RXLengthErrors:0x0, RXOverErrors:0x0, RXCRCErrors:0x0, RXFrameErrors:0x0, RXFIFOErrors:0x0, RXMissedErrors:0x0, TXAbortedErrors:0x0, TXCarrierErrors:0x0, TXFIFOErrors:0x0, TXHeartbeatErrors:0x0, TXWindowErrors:0x0, RXCompressed:0x0, TXCompressed:0x0, RXNoHandler:0x0}
            -  got: &rtnetlink.LinkStats64{RXPackets:0x50b6010000000000, TXPackets:0x6c9000000000000, RXBytes:0xa941cd0900000000, TXBytes:0x96962a0000000000, RXErrors:0x0, TXErrors:0x0, RXDropped:0x0, TXDropped:0x0, Multicast:0x0, Collisions:0x0, RXLengthErrors:0x0, RXOverErrors:0x0, RXCRCErrors:0x0, RXFrameErrors:0x0, RXFIFOErrors:0x0, RXMissedErrors:0x0, TXAbortedErrors:0x0, TXCarrierErrors:0x0, TXFIFOErrors:0x0, TXHeartbeatErrors:0x0, TXWindowErrors:0x0, RXCompressed:0x0, TXCompressed:0x0, RXNoHandler:0x0}
    --- FAIL: TestLinkStats64UnmarshalBinary/kernel_4.6+ (0.00s)
        link_test.go:656: unexpected Message:
BUILDSTDERR:             - want: &rtnetlink.LinkStats64{RXPackets:0x1b650, TXPackets:0xc906, RXBytes:0x9cd41a9, TXBytes:0x2a9696, RXErrors:0x0, TXErrors:0x0, RXDropped:0x0, TXDropped:0x0, Multicast:0x0, Collisions:0x0, RXLengthErrors:0x0, RXOverErrors:0x0, RXCRCErrors:0x0, RXFrameErrors:0x0, RXFIFOErrors:0x0, RXMissedErrors:0x0, TXAbortedErrors:0x0, TXCarrierErrors:0x0, TXFIFOErrors:0x0, TXHeartbeatErrors:0x0, TXWindowErrorerror: Bad exit status from /var/tmp/rpm-tmp.rtrREm (%check)
BUILDSTDERR:     Bad exit status from /var/tmp/rpm-tmp.rtrREm (%check)
s:0x0, RXCompressed:0x0, TXCompressed:0x0, RXNoHandler:0x0}
            -  got: &rtnetlink.LinkStats64{RXPackets:0x50b6010000000000, TXPackets:0x6c9000000000000, RXBytes:0xa941cd0900000000, TXBytes:0x96962a0000000000, RXErrors:0x0, TXErrors:0x0, RXDropped:0x0, TXDropped:0x0, Multicast:0x0, Collisions:0x0, RXLengthErrors:0x0, RXOverErrors:0x0, RXCRCErrors:0x0, RXFrameErrors:0x0, RXFIFOErrors:0x0, RXMissedErrors:0x0, TXAbortedErrors:0x0, TXCarrierErrors:0x0, TXFIFOErrors:0x0, TXHeartbeatErrors:0x0, TXWindowErrors:0x0, RXCompressed:0x0, TXCompressed:0x0, RXNoHandler:0x0}
--- FAIL: TestNeighMessageMarshalBinary (0.00s)
    --- FAIL: TestNeighMessageMarshalBinary/no_attributes (0.00s)
        neigh_test.go:79: unexpected Message bytes:
            - want: [0x00 0x00 0x00 0x00 0x02 0x00 0x00 0x00 0x40 0x00 0x00 0x08]
            -  got: [0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x02 0x00 0x40 0x00 0x08]
    --- FAIL: TestNeighMessageMarshalBinary/attributes (0.00s)
        neigh_test.go:79: unexpected Message bytes:
            - want: [0x00 0x00 0x00 0x00 0x02 0x00 0x00 0x00 0x40 0x00 0x00 0x08 0x06 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x14 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xff 0xff 0x0a 0x00 0x00 0x00 0x0a 0x00 0x02 0x00 0x33 0x33 0x00 0x00 0x00 0x16 0x00 0x00 0x08 0x00 0x08 0x00 0x00 0x00 0x00 0x00]
            -  got: [0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x02 0x00 0x40 0x00 0x08 0x00 0x06 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x14 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xff 0xff 0x0a 0x00 0x00 0x00 0x00 0x0a 0x00 0x02 0x33 0x33 0x00 0x00 0x00 0x16 0x00 0x00 0x00 0x08 0x00 0x08 0x00 0x00 0x00 0x00]
--- FAIL: TestNeighMessageUnmarshalBinary (0.00s)
    --- FAIL: TestNeighMessageUnmarshalBinary/invalid_attr (0.00s)
        neigh_test.go:135: unexpected error:
            - want: rtnetlink NeighMessage has a wrong attribute data length
            -  got: invalid attribute; length too short or too large
    --- FAIL: TestNeighMessageUnmarshalBinary/data (0.00s)
        neigh_test.go:142: unexpected Message:
            - want: &rtnetlink.NeighMessage{Family:0x0, Index:0x2, State:0x40, Flags:0x0, Type:0x8, Attributes:(*rtnetlink.NeighAttributes)(nil)}
            -  got: &rtnetlink.NeighMessage{Family:0x0, Index:0x2000000, State:0x4000, Flags:0x0, Type:0x8, Attributes:(*rtnetlink.NeighAttributes)(nil)}
--- FAIL: TestRouteMessageMarshalBinary (0.00s)
    --- FAIL: TestRouteMessageMarshalBinary/attributes (0.00s)
        route_test.go:72: unexpected Message bytes:
            - want: [0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x08 0x00 0x01 0x00 0x0a 0x00 0x00 0x00 0x08 0x00 0x05 0x00 0x0a 0x0a 0x0a 0x0a 0x08 0x00 0x04 0x00 0x04 0x00 0x00 0x00]
            -  got: [0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x08 0x00 0x01 0x0a 0x00 0x00 0x00 0x00 0x08 0x00 0x05 0x0a 0x0a 0x0a 0x0a 0x00 0x08 0x00 0x04 0x00 0x00 0x00 0x04]
--- FAIL: TestRouteMessageUnmarshalBinary (0.00s)
    --- FAIL: TestRouteMessageUnmarshalBinary/invalid_attr (0.00s)
        route_test.go:139: unexpected error:
            - want: rtnetlink RouteMessage has a wrong attribute data length
            -  got: invalid attribute; length too short or too large
    --- FAIL: TestRouteMessageUnmarshalBinary/data (0.00s)
        route_test.go:139: unexpected error:
            - want: <nil>
            -  got: invalid attribute; length too short or too large
FAIL
exit status 1
FAIL	github.com/jsimonetti/rtnetlink	0.008s

netlink uses native byte order; see this blog post series.

I need to have a closer look at this and find an endian independant way of decoding the messages.
Currently the byte order is fixed for use on little endian machines only.

This issue should now be fixed with the addition of nativeEndian de-/encoding.

Unfortunately the tests assume a little endian system and are therefor skipped if a bigendian architecture is detected.

At this time I have no way of actually confirming wether this is fixed. Please confirm @eclipseo

Ill close this for now. Should the need arise we can reopen this issue.