Add field for permanent hardware address

Linux 5.6 and higher support IFLA_PERM_ADDRESS, which contains the
permanent hardware address of the interface if an interface has such an
address. This can be used to identify interfaces even when the normal
hardware address has been changed.

Signed-off-by: Lorenz Brun <lorenz@monogon.tech>
This commit is contained in:
Lorenz Brun 2023-03-06 18:23:14 +01:00 committed by Alessandro Boch
parent d237ee16c3
commit 306ce7b5b2
2 changed files with 8 additions and 0 deletions

View File

@ -55,6 +55,7 @@ type LinkAttrs struct {
GROIPv4MaxSize uint32
Vfs []VfInfo // virtual functions available on link
Group uint32
PermHWAddr net.HardwareAddr
Slave LinkSlave
}

View File

@ -2246,6 +2246,13 @@ func LinkDeserialize(hdr *unix.NlMsghdr, m []byte) (Link, error) {
base.NumRxQueues = int(native.Uint32(attr.Value[0:4]))
case unix.IFLA_GROUP:
base.Group = native.Uint32(attr.Value[0:4])
case unix.IFLA_PERM_ADDRESS:
for _, b := range attr.Value {
if b != 0 {
base.PermHWAddr = attr.Value[:]
break
}
}
}
}