Skip to content

Commit 7740709

Browse files
jlamannaaboch
authored andcommitted
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
1 parent 8b05c6b commit 7740709

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

neigh.go

+8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ type Neigh struct {
1919
Vlan int
2020
VNI int
2121
MasterIndex int
22+
23+
// These values are expressed as "clock ticks ago". To
24+
// convert these clock ticks to seconds divide by sysconf(_SC_CLK_TCK).
25+
// When _SC_CLK_TCK is 100, for example, the ndm_* times are expressed
26+
// in centiseconds.
27+
Confirmed uint32 // The last time ARP/ND succeeded OR higher layer confirmation was received
28+
Used uint32 // The last time ARP/ND took place for this neighbor
29+
Updated uint32 // The time when the current NUD state was entered
2230
}
2331

2432
// String returns $ip/$hwaddr $label

neigh_linux.go

+4
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,10 @@ func NeighDeserialize(m []byte) (*Neigh, error) {
349349
neigh.VNI = int(native.Uint32(attr.Value[0:4]))
350350
case NDA_MASTER:
351351
neigh.MasterIndex = int(native.Uint32(attr.Value[0:4]))
352+
case NDA_CACHEINFO:
353+
neigh.Confirmed = native.Uint32(attr.Value[0:4])
354+
neigh.Used = native.Uint32(attr.Value[4:8])
355+
neigh.Updated = native.Uint32(attr.Value[8:12])
352356
}
353357
}
354358

0 commit comments

Comments
 (0)