From 306ce7b5b261cf68a73d495aa281022cb2caf913 Mon Sep 17 00:00:00 2001 From: Lorenz Brun Date: Mon, 6 Mar 2023 18:23:14 +0100 Subject: [PATCH] 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 --- link.go | 1 + link_linux.go | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/link.go b/link.go index 0e46eee..28780d1 100644 --- a/link.go +++ b/link.go @@ -55,6 +55,7 @@ type LinkAttrs struct { GROIPv4MaxSize uint32 Vfs []VfInfo // virtual functions available on link Group uint32 + PermHWAddr net.HardwareAddr Slave LinkSlave } diff --git a/link_linux.go b/link_linux.go index 717be79..989abea 100644 --- a/link_linux.go +++ b/link_linux.go @@ -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 + } + } } }