mirror of
https://github.com/vishvananda/netlink.git
synced 2025-09-26 20:01:13 +08:00
Add support for ARP/ND Timestamps when retriving neighbors
On Linux, Netlink provides NDA_CACHEINFO which carries timestamps about when ARP/ND was updated, used, and confirmed. Expose these fields in the Neigh type
This commit is contained in:

committed by
Alessandro Boch

parent
8b05c6bd4c
commit
7740709424
8
neigh.go
8
neigh.go
@@ -19,6 +19,14 @@ type Neigh struct {
|
|||||||
Vlan int
|
Vlan int
|
||||||
VNI int
|
VNI int
|
||||||
MasterIndex int
|
MasterIndex int
|
||||||
|
|
||||||
|
// These values are expressed as "clock ticks ago". To
|
||||||
|
// convert these clock ticks to seconds divide by sysconf(_SC_CLK_TCK).
|
||||||
|
// When _SC_CLK_TCK is 100, for example, the ndm_* times are expressed
|
||||||
|
// in centiseconds.
|
||||||
|
Confirmed uint32 // The last time ARP/ND succeeded OR higher layer confirmation was received
|
||||||
|
Used uint32 // The last time ARP/ND took place for this neighbor
|
||||||
|
Updated uint32 // The time when the current NUD state was entered
|
||||||
}
|
}
|
||||||
|
|
||||||
// String returns $ip/$hwaddr $label
|
// String returns $ip/$hwaddr $label
|
||||||
|
@@ -349,6 +349,10 @@ func NeighDeserialize(m []byte) (*Neigh, error) {
|
|||||||
neigh.VNI = int(native.Uint32(attr.Value[0:4]))
|
neigh.VNI = int(native.Uint32(attr.Value[0:4]))
|
||||||
case NDA_MASTER:
|
case NDA_MASTER:
|
||||||
neigh.MasterIndex = int(native.Uint32(attr.Value[0:4]))
|
neigh.MasterIndex = int(native.Uint32(attr.Value[0:4]))
|
||||||
|
case NDA_CACHEINFO:
|
||||||
|
neigh.Confirmed = native.Uint32(attr.Value[0:4])
|
||||||
|
neigh.Used = native.Uint32(attr.Value[4:8])
|
||||||
|
neigh.Updated = native.Uint32(attr.Value[8:12])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user