diff --git a/neigh.go b/neigh.go index df123a4..d167c7c 100644 --- a/neigh.go +++ b/neigh.go @@ -191,7 +191,10 @@ func (a *NeighAttributes) decode(ad *netlink.AttributeDecoder) error { } a.Address = ad.Bytes() case unix.NDA_LLADDR: - if len(ad.Bytes()) != 6 { + // Allow IEEE 802 MAC-48, EUI-48, EUI-64, or 20-octet + // IP over InfiniBand link-layer addresses + l := len(ad.Bytes()) + if l != 6 && l != 8 && l != 20 { return errInvalidNeighMessageAttr } a.LLAddress = ad.Bytes() diff --git a/neigh_test.go b/neigh_test.go index e49e66e..5bc9f8a 100644 --- a/neigh_test.go +++ b/neigh_test.go @@ -64,6 +64,45 @@ func TestNeighMessageMarshalBinary(t *testing.T) { 0x00, 0x00, 0x00, 0x00, }, }, + { + name: "infiniband LL address", + m: &NeighMessage{ + Index: 2, + State: 64, + Type: unix.NTF_PROXY, + Attributes: &NeighAttributes{ + LLAddress: []byte{0x0, 0x0, 0x0, 0x0, 0xfe, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x02, 0x0, 0x5e, 0x10, 0x0, 0x0, 0x0, 0x01}, + }, + }, + b: []byte{ + 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x40, 0x00, 0x00, 0x08, 0x06, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x01, 0x00, + 0x18, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x5e, 0x10, 0x00, 0x00, 0x00, 0x01, + 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + }, + { + name: "EUI-64 LL", + m: &NeighMessage{ + Index: 2, + State: 64, + Type: unix.NTF_PROXY, + Attributes: &NeighAttributes{ + LLAddress: []byte{0x0, 0x0, 0x0, 0x0, 0xfe, 0x80, 0x0, 0xd}, + }, + }, + b: []byte{ + 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x40, 0x00, 0x00, 0x08, 0x06, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x01, 0x00, + 0x0c, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xfe, 0x80, 0x00, 0x0d, 0x08, 0x00, 0x08, 0x00, + 0x00, 0x00, 0x00, 0x00, + }, + }, } for _, tt := range tests {