Skip to content

Commit 306ce7b

Browse files
lorenzaboch
authored andcommitted
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 <[email protected]>
1 parent d237ee1 commit 306ce7b

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

link.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ type LinkAttrs struct {
5555
GROIPv4MaxSize uint32
5656
Vfs []VfInfo // virtual functions available on link
5757
Group uint32
58+
PermHWAddr net.HardwareAddr
5859
Slave LinkSlave
5960
}
6061

link_linux.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,6 +2246,13 @@ func LinkDeserialize(hdr *unix.NlMsghdr, m []byte) (Link, error) {
22462246
base.NumRxQueues = int(native.Uint32(attr.Value[0:4]))
22472247
case unix.IFLA_GROUP:
22482248
base.Group = native.Uint32(attr.Value[0:4])
2249+
case unix.IFLA_PERM_ADDRESS:
2250+
for _, b := range attr.Value {
2251+
if b != 0 {
2252+
base.PermHWAddr = attr.Value[:]
2253+
break
2254+
}
2255+
}
22492256
}
22502257
}
22512258

0 commit comments

Comments
 (0)