mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Use monotonic time for neighbor entries
PiperOrigin-RevId: 470832047
This commit is contained in:
@@ -61,6 +61,7 @@ func unorderedEventsDiffOpts() []cmp.Option {
|
||||
cmpopts.SortSlices(func(a, b testEntryEventInfo) bool {
|
||||
return strings.Compare(string(a.Entry.Addr), string(b.Entry.Addr)) < 0
|
||||
}),
|
||||
cmp.AllowUnexported(tcpip.MonotonicTime{}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +72,7 @@ func unorderedEntriesDiffOpts() []cmp.Option {
|
||||
cmpopts.SortSlices(func(a, b NeighborEntry) bool {
|
||||
return strings.Compare(string(a.Addr), string(b.Addr)) < 0
|
||||
}),
|
||||
cmp.AllowUnexported(tcpip.MonotonicTime{}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,7 +250,7 @@ func TestNeighborCacheGetConfig(t *testing.T) {
|
||||
// No events should have been dispatched.
|
||||
nudDisp.mu.Lock()
|
||||
defer nudDisp.mu.Unlock()
|
||||
if diff := cmp.Diff([]testEntryEventInfo(nil), nudDisp.mu.events); diff != "" {
|
||||
if diff := cmp.Diff([]testEntryEventInfo(nil), nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{})); diff != "" {
|
||||
t.Errorf("nud dispatcher events mismatch (-want, +got):\n%s", diff)
|
||||
}
|
||||
}
|
||||
@@ -270,7 +272,7 @@ func TestNeighborCacheSetConfig(t *testing.T) {
|
||||
// No events should have been dispatched.
|
||||
nudDisp.mu.Lock()
|
||||
defer nudDisp.mu.Unlock()
|
||||
if diff := cmp.Diff([]testEntryEventInfo(nil), nudDisp.mu.events); diff != "" {
|
||||
if diff := cmp.Diff([]testEntryEventInfo(nil), nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{})); diff != "" {
|
||||
t.Errorf("nud dispatcher events mismatch (-want, +got):\n%s", diff)
|
||||
}
|
||||
}
|
||||
@@ -296,7 +298,7 @@ func addReachableEntryWithRemoved(nudDisp *testNUDDispatcher, clock *faketime.Ma
|
||||
Addr: removedEntry.Addr,
|
||||
LinkAddr: removedEntry.LinkAddr,
|
||||
State: Reachable,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -308,12 +310,12 @@ func addReachableEntryWithRemoved(nudDisp *testNUDDispatcher, clock *faketime.Ma
|
||||
Addr: entry.Addr,
|
||||
LinkAddr: "",
|
||||
State: Incomplete,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
})
|
||||
|
||||
nudDisp.mu.Lock()
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events)
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{}))
|
||||
nudDisp.mu.events = nil
|
||||
nudDisp.mu.Unlock()
|
||||
if diff != "" {
|
||||
@@ -342,12 +344,12 @@ func addReachableEntryWithRemoved(nudDisp *testNUDDispatcher, clock *faketime.Ma
|
||||
Addr: entry.Addr,
|
||||
LinkAddr: entry.LinkAddr,
|
||||
State: Reachable,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
nudDisp.mu.Lock()
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events)
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{}))
|
||||
nudDisp.mu.events = nil
|
||||
nudDisp.mu.Unlock()
|
||||
if diff != "" {
|
||||
@@ -383,7 +385,7 @@ func TestNeighborCacheEntry(t *testing.T) {
|
||||
// No more events should have been dispatched.
|
||||
nudDisp.mu.Lock()
|
||||
defer nudDisp.mu.Unlock()
|
||||
if diff := cmp.Diff([]testEntryEventInfo(nil), nudDisp.mu.events); diff != "" {
|
||||
if diff := cmp.Diff([]testEntryEventInfo(nil), nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{})); diff != "" {
|
||||
t.Errorf("nud dispatcher events mismatch (-want, +got):\n%s", diff)
|
||||
}
|
||||
}
|
||||
@@ -414,12 +416,12 @@ func TestNeighborCacheRemoveEntry(t *testing.T) {
|
||||
Addr: entry.Addr,
|
||||
LinkAddr: entry.LinkAddr,
|
||||
State: Reachable,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
nudDisp.mu.Lock()
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events)
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{}))
|
||||
nudDisp.mu.Unlock()
|
||||
if diff != "" {
|
||||
t.Fatalf("nud dispatcher events mismatch (-want, +got):\n%s", diff)
|
||||
@@ -497,7 +499,7 @@ func (c *testContext) overflowCache(opts overflowOptions) error {
|
||||
Addr: entry.Addr,
|
||||
LinkAddr: entry.LinkAddr,
|
||||
State: Reachable,
|
||||
UpdatedAt: c.clock.Now().Add(-durationReachableNanos),
|
||||
UpdatedAt: c.clock.NowMonotonic().Add(-durationReachableNanos),
|
||||
}
|
||||
wantUnorderedEntries = append(wantUnorderedEntries, wantEntry)
|
||||
}
|
||||
@@ -509,7 +511,7 @@ func (c *testContext) overflowCache(opts overflowOptions) error {
|
||||
// No more events should have been dispatched.
|
||||
c.nudDisp.mu.Lock()
|
||||
defer c.nudDisp.mu.Unlock()
|
||||
if diff := cmp.Diff([]testEntryEventInfo(nil), c.nudDisp.mu.events); diff != "" {
|
||||
if diff := cmp.Diff([]testEntryEventInfo(nil), c.nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{})); diff != "" {
|
||||
return fmt.Errorf("nud dispatcher events mismatch (-want, +got):\n%s", diff)
|
||||
}
|
||||
|
||||
@@ -566,12 +568,12 @@ func TestNeighborCacheRemoveEntryThenOverflow(t *testing.T) {
|
||||
Addr: entry.Addr,
|
||||
LinkAddr: entry.LinkAddr,
|
||||
State: Reachable,
|
||||
UpdatedAt: c.clock.Now(),
|
||||
UpdatedAt: c.clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
c.nudDisp.mu.Lock()
|
||||
diff := cmp.Diff(wantEvents, c.nudDisp.mu.events)
|
||||
diff := cmp.Diff(wantEvents, c.nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{}))
|
||||
c.nudDisp.mu.events = nil
|
||||
c.nudDisp.mu.Unlock()
|
||||
if diff != "" {
|
||||
@@ -611,12 +613,12 @@ func TestNeighborCacheDuplicateStaticEntryWithSameLinkAddress(t *testing.T) {
|
||||
Addr: entry.Addr,
|
||||
LinkAddr: staticLinkAddr,
|
||||
State: Static,
|
||||
UpdatedAt: c.clock.Now(),
|
||||
UpdatedAt: c.clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
c.nudDisp.mu.Lock()
|
||||
diff := cmp.Diff(wantEvents, c.nudDisp.mu.events)
|
||||
diff := cmp.Diff(wantEvents, c.nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{}))
|
||||
c.nudDisp.mu.events = nil
|
||||
c.nudDisp.mu.Unlock()
|
||||
if diff != "" {
|
||||
@@ -629,7 +631,7 @@ func TestNeighborCacheDuplicateStaticEntryWithSameLinkAddress(t *testing.T) {
|
||||
|
||||
c.nudDisp.mu.Lock()
|
||||
defer c.nudDisp.mu.Unlock()
|
||||
if diff := cmp.Diff([]testEntryEventInfo(nil), c.nudDisp.mu.events); diff != "" {
|
||||
if diff := cmp.Diff([]testEntryEventInfo(nil), c.nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{})); diff != "" {
|
||||
t.Errorf("nud dispatcher events mismatch (-want, +got):\n%s", diff)
|
||||
}
|
||||
}
|
||||
@@ -658,12 +660,12 @@ func TestNeighborCacheDuplicateStaticEntryWithDifferentLinkAddress(t *testing.T)
|
||||
Addr: entry.Addr,
|
||||
LinkAddr: staticLinkAddr,
|
||||
State: Static,
|
||||
UpdatedAt: c.clock.Now(),
|
||||
UpdatedAt: c.clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
c.nudDisp.mu.Lock()
|
||||
diff := cmp.Diff(wantEvents, c.nudDisp.mu.events)
|
||||
diff := cmp.Diff(wantEvents, c.nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{}))
|
||||
c.nudDisp.mu.events = nil
|
||||
c.nudDisp.mu.Unlock()
|
||||
if diff != "" {
|
||||
@@ -684,12 +686,12 @@ func TestNeighborCacheDuplicateStaticEntryWithDifferentLinkAddress(t *testing.T)
|
||||
Addr: entry.Addr,
|
||||
LinkAddr: staticLinkAddr,
|
||||
State: Static,
|
||||
UpdatedAt: c.clock.Now(),
|
||||
UpdatedAt: c.clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
c.nudDisp.mu.Lock()
|
||||
diff := cmp.Diff(wantEvents, c.nudDisp.mu.events)
|
||||
diff := cmp.Diff(wantEvents, c.nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{}))
|
||||
c.nudDisp.mu.events = nil
|
||||
c.nudDisp.mu.Unlock()
|
||||
if diff != "" {
|
||||
@@ -728,12 +730,12 @@ func TestNeighborCacheRemoveStaticEntryThenOverflow(t *testing.T) {
|
||||
Addr: entry.Addr,
|
||||
LinkAddr: staticLinkAddr,
|
||||
State: Static,
|
||||
UpdatedAt: c.clock.Now(),
|
||||
UpdatedAt: c.clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
c.nudDisp.mu.Lock()
|
||||
diff := cmp.Diff(wantEvents, c.nudDisp.mu.events)
|
||||
diff := cmp.Diff(wantEvents, c.nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{}))
|
||||
c.nudDisp.mu.events = nil
|
||||
c.nudDisp.mu.Unlock()
|
||||
if diff != "" {
|
||||
@@ -753,12 +755,12 @@ func TestNeighborCacheRemoveStaticEntryThenOverflow(t *testing.T) {
|
||||
Addr: entry.Addr,
|
||||
LinkAddr: staticLinkAddr,
|
||||
State: Static,
|
||||
UpdatedAt: c.clock.Now(),
|
||||
UpdatedAt: c.clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
c.nudDisp.mu.Lock()
|
||||
diff := cmp.Diff(wantEvents, c.nudDisp.mu.events)
|
||||
diff := cmp.Diff(wantEvents, c.nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{}))
|
||||
c.nudDisp.mu.events = nil
|
||||
c.nudDisp.mu.Unlock()
|
||||
if diff != "" {
|
||||
@@ -809,7 +811,7 @@ func TestNeighborCacheOverwriteWithStaticEntryThenOverflow(t *testing.T) {
|
||||
Addr: entry.Addr,
|
||||
LinkAddr: entry.LinkAddr,
|
||||
State: Reachable,
|
||||
UpdatedAt: c.clock.Now(),
|
||||
UpdatedAt: c.clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -819,12 +821,12 @@ func TestNeighborCacheOverwriteWithStaticEntryThenOverflow(t *testing.T) {
|
||||
Addr: entry.Addr,
|
||||
LinkAddr: staticLinkAddr,
|
||||
State: Static,
|
||||
UpdatedAt: c.clock.Now(),
|
||||
UpdatedAt: c.clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
c.nudDisp.mu.Lock()
|
||||
diff := cmp.Diff(wantEvents, c.nudDisp.mu.events)
|
||||
diff := cmp.Diff(wantEvents, c.nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{}))
|
||||
c.nudDisp.mu.events = nil
|
||||
c.nudDisp.mu.Unlock()
|
||||
if diff != "" {
|
||||
@@ -839,7 +841,7 @@ func TestNeighborCacheOverwriteWithStaticEntryThenOverflow(t *testing.T) {
|
||||
Addr: entry.Addr,
|
||||
LinkAddr: staticLinkAddr,
|
||||
State: Static,
|
||||
UpdatedAt: c.clock.Now(),
|
||||
UpdatedAt: c.clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -870,9 +872,9 @@ func TestNeighborCacheAddStaticEntryThenOverflow(t *testing.T) {
|
||||
Addr: entry.Addr,
|
||||
LinkAddr: entry.LinkAddr,
|
||||
State: Static,
|
||||
UpdatedAt: c.clock.Now(),
|
||||
UpdatedAt: c.clock.NowMonotonic(),
|
||||
}
|
||||
if diff := cmp.Diff(want, e); diff != "" {
|
||||
if diff := cmp.Diff(want, e, cmp.AllowUnexported(tcpip.MonotonicTime{})); diff != "" {
|
||||
t.Errorf("c.linkRes.neigh.entry(%s, \"\", nil) mismatch (-want, +got):\n%s", entry.Addr, diff)
|
||||
}
|
||||
|
||||
@@ -885,12 +887,12 @@ func TestNeighborCacheAddStaticEntryThenOverflow(t *testing.T) {
|
||||
Addr: entry.Addr,
|
||||
LinkAddr: entry.LinkAddr,
|
||||
State: Static,
|
||||
UpdatedAt: c.clock.Now(),
|
||||
UpdatedAt: c.clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
c.nudDisp.mu.Lock()
|
||||
diff := cmp.Diff(wantEvents, c.nudDisp.mu.events)
|
||||
diff := cmp.Diff(wantEvents, c.nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{}))
|
||||
c.nudDisp.mu.events = nil
|
||||
c.nudDisp.mu.Unlock()
|
||||
if diff != "" {
|
||||
@@ -905,7 +907,7 @@ func TestNeighborCacheAddStaticEntryThenOverflow(t *testing.T) {
|
||||
Addr: entry.Addr,
|
||||
LinkAddr: entry.LinkAddr,
|
||||
State: Static,
|
||||
UpdatedAt: c.clock.Now(),
|
||||
UpdatedAt: c.clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -942,12 +944,12 @@ func TestNeighborCacheClear(t *testing.T) {
|
||||
Addr: entryTestAddr1,
|
||||
LinkAddr: entryTestLinkAddr1,
|
||||
State: Static,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
nudDisp.mu.Lock()
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events)
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{}))
|
||||
nudDisp.mu.events = nil
|
||||
nudDisp.mu.Unlock()
|
||||
if diff != "" {
|
||||
@@ -968,7 +970,7 @@ func TestNeighborCacheClear(t *testing.T) {
|
||||
Addr: entry.Addr,
|
||||
LinkAddr: entry.LinkAddr,
|
||||
State: Reachable,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -978,7 +980,7 @@ func TestNeighborCacheClear(t *testing.T) {
|
||||
Addr: entryTestAddr1,
|
||||
LinkAddr: entryTestLinkAddr1,
|
||||
State: Static,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -1022,12 +1024,12 @@ func TestNeighborCacheClearThenOverflow(t *testing.T) {
|
||||
Addr: entry.Addr,
|
||||
LinkAddr: entry.LinkAddr,
|
||||
State: Reachable,
|
||||
UpdatedAt: c.clock.Now(),
|
||||
UpdatedAt: c.clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
c.nudDisp.mu.Lock()
|
||||
diff := cmp.Diff(wantEvents, c.nudDisp.mu.events)
|
||||
diff := cmp.Diff(wantEvents, c.nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{}))
|
||||
c.nudDisp.mu.events = nil
|
||||
c.nudDisp.mu.Unlock()
|
||||
if diff != "" {
|
||||
@@ -1054,7 +1056,7 @@ func TestNeighborCacheKeepFrequentlyUsed(t *testing.T) {
|
||||
clock := faketime.NewManualClock()
|
||||
linkRes := newTestNeighborResolver(&nudDisp, config, clock)
|
||||
|
||||
startedAt := clock.Now()
|
||||
startedAt := clock.NowMonotonic()
|
||||
|
||||
// The following logic is very similar to overflowCache, but
|
||||
// periodically refreshes the frequently used entry.
|
||||
@@ -1124,7 +1126,7 @@ func TestNeighborCacheKeepFrequentlyUsed(t *testing.T) {
|
||||
Addr: entry.Addr,
|
||||
LinkAddr: entry.LinkAddr,
|
||||
State: Reachable,
|
||||
UpdatedAt: clock.Now().Add(-durationReachableNanos),
|
||||
UpdatedAt: clock.NowMonotonic().Add(-durationReachableNanos),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1135,7 +1137,7 @@ func TestNeighborCacheKeepFrequentlyUsed(t *testing.T) {
|
||||
// No more events should have been dispatched.
|
||||
nudDisp.mu.Lock()
|
||||
defer nudDisp.mu.Unlock()
|
||||
if diff := cmp.Diff([]testEntryEventInfo(nil), nudDisp.mu.events); diff != "" {
|
||||
if diff := cmp.Diff([]testEntryEventInfo(nil), nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{})); diff != "" {
|
||||
t.Errorf("nud dispatcher events mismatch (-want, +got):\n%s", diff)
|
||||
}
|
||||
}
|
||||
@@ -1187,7 +1189,7 @@ func TestNeighborCacheConcurrent(t *testing.T) {
|
||||
Addr: entry.Addr,
|
||||
LinkAddr: entry.LinkAddr,
|
||||
State: Reachable,
|
||||
UpdatedAt: clock.Now().Add(-durationReachableNanos),
|
||||
UpdatedAt: clock.NowMonotonic().Add(-durationReachableNanos),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1239,9 +1241,9 @@ func TestNeighborCacheReplace(t *testing.T) {
|
||||
Addr: entry.Addr,
|
||||
LinkAddr: updatedLinkAddr,
|
||||
State: Delay,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
}
|
||||
if diff := cmp.Diff(want, e); diff != "" {
|
||||
if diff := cmp.Diff(want, e, cmp.AllowUnexported(tcpip.MonotonicTime{})); diff != "" {
|
||||
t.Errorf("linkRes.neigh.entry(%s, '', nil) mismatch (-want, +got):\n%s", entry.Addr, diff)
|
||||
}
|
||||
}
|
||||
@@ -1258,9 +1260,9 @@ func TestNeighborCacheReplace(t *testing.T) {
|
||||
Addr: entry.Addr,
|
||||
LinkAddr: updatedLinkAddr,
|
||||
State: Reachable,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
}
|
||||
if diff := cmp.Diff(want, e); diff != "" {
|
||||
if diff := cmp.Diff(want, e, cmp.AllowUnexported(tcpip.MonotonicTime{})); diff != "" {
|
||||
t.Errorf("linkRes.neigh.entry(%s, '', nil) mismatch (-want, +got):\n%s", entry.Addr, diff)
|
||||
}
|
||||
}
|
||||
@@ -1296,9 +1298,9 @@ func TestNeighborCacheResolutionFailed(t *testing.T) {
|
||||
Addr: entry.Addr,
|
||||
LinkAddr: entry.LinkAddr,
|
||||
State: Reachable,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
}
|
||||
if diff := cmp.Diff(want, got); diff != "" {
|
||||
if diff := cmp.Diff(want, got, cmp.AllowUnexported(tcpip.MonotonicTime{})); diff != "" {
|
||||
t.Errorf("linkRes.neigh.entry(%s, '', nil) mismatch (-want, +got):\n%s", entry.Addr, diff)
|
||||
}
|
||||
|
||||
@@ -1400,12 +1402,12 @@ func TestNeighborCacheRetryResolution(t *testing.T) {
|
||||
Addr: entry.Addr,
|
||||
LinkAddr: "",
|
||||
State: Incomplete,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
nudDisp.mu.Lock()
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events)
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{}))
|
||||
nudDisp.mu.events = nil
|
||||
nudDisp.mu.Unlock()
|
||||
if diff != "" {
|
||||
@@ -1431,12 +1433,12 @@ func TestNeighborCacheRetryResolution(t *testing.T) {
|
||||
Addr: entry.Addr,
|
||||
LinkAddr: "",
|
||||
State: Unreachable,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
nudDisp.mu.Lock()
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events)
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{}))
|
||||
nudDisp.mu.events = nil
|
||||
nudDisp.mu.Unlock()
|
||||
if diff != "" {
|
||||
@@ -1450,7 +1452,7 @@ func TestNeighborCacheRetryResolution(t *testing.T) {
|
||||
Addr: entry.Addr,
|
||||
LinkAddr: "",
|
||||
State: Unreachable,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
}
|
||||
if diff := cmp.Diff(linkRes.neigh.entries(), wantEntries, unorderedEntriesDiffOpts()...); diff != "" {
|
||||
@@ -1483,12 +1485,12 @@ func TestNeighborCacheRetryResolution(t *testing.T) {
|
||||
Addr: entry.Addr,
|
||||
LinkAddr: "",
|
||||
State: Incomplete,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
nudDisp.mu.Lock()
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events)
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{}))
|
||||
nudDisp.mu.events = nil
|
||||
nudDisp.mu.Unlock()
|
||||
if diff != "" {
|
||||
@@ -1513,12 +1515,12 @@ func TestNeighborCacheRetryResolution(t *testing.T) {
|
||||
Addr: entry.Addr,
|
||||
LinkAddr: entry.LinkAddr,
|
||||
State: Reachable,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
nudDisp.mu.Lock()
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events)
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{}))
|
||||
nudDisp.mu.events = nil
|
||||
nudDisp.mu.Unlock()
|
||||
if diff != "" {
|
||||
@@ -1536,9 +1538,9 @@ func TestNeighborCacheRetryResolution(t *testing.T) {
|
||||
Addr: entry.Addr,
|
||||
LinkAddr: entry.LinkAddr,
|
||||
State: Reachable,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
}
|
||||
if diff := cmp.Diff(gotEntry, wantEntry); diff != "" {
|
||||
if diff := cmp.Diff(gotEntry, wantEntry, cmp.AllowUnexported(tcpip.MonotonicTime{})); diff != "" {
|
||||
t.Fatalf("neighbor entry mismatch (-got, +want):\n%s", diff)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ type NeighborEntry struct {
|
||||
Addr tcpip.Address
|
||||
LinkAddr tcpip.LinkAddress
|
||||
State NeighborState
|
||||
UpdatedAt time.Time
|
||||
UpdatedAt tcpip.MonotonicTime
|
||||
}
|
||||
|
||||
// NeighborState defines the state of a NeighborEntry within the Neighbor
|
||||
@@ -141,7 +141,7 @@ func newStaticNeighborEntry(cache *neighborCache, addr tcpip.Address, linkAddr t
|
||||
Addr: addr,
|
||||
LinkAddr: linkAddr,
|
||||
State: Static,
|
||||
UpdatedAt: cache.nic.stack.clock.Now(),
|
||||
UpdatedAt: cache.nic.stack.clock.NowMonotonic(),
|
||||
}
|
||||
n := &neighborEntry{
|
||||
cache: cache,
|
||||
@@ -230,7 +230,7 @@ func (e *neighborEntry) cancelTimerLocked() {
|
||||
//
|
||||
// Precondition: e.mu MUST be locked.
|
||||
func (e *neighborEntry) removeLocked() {
|
||||
e.mu.neigh.UpdatedAt = e.cache.nic.stack.clock.Now()
|
||||
e.mu.neigh.UpdatedAt = e.cache.nic.stack.clock.NowMonotonic()
|
||||
e.dispatchRemoveEventLocked()
|
||||
e.cancelTimerLocked()
|
||||
// TODO(https://gvisor.dev/issues/5583): test the case where this function is
|
||||
@@ -252,7 +252,7 @@ func (e *neighborEntry) setStateLocked(next NeighborState) {
|
||||
|
||||
prev := e.mu.neigh.State
|
||||
e.mu.neigh.State = next
|
||||
e.mu.neigh.UpdatedAt = e.cache.nic.stack.clock.Now()
|
||||
e.mu.neigh.UpdatedAt = e.cache.nic.stack.clock.NowMonotonic()
|
||||
config := e.nudState.Config()
|
||||
|
||||
switch next {
|
||||
@@ -360,7 +360,7 @@ func (e *neighborEntry) handlePacketQueuedLocked(localAddr tcpip.Address) {
|
||||
case Unknown, Unreachable:
|
||||
prev := e.mu.neigh.State
|
||||
e.mu.neigh.State = Incomplete
|
||||
e.mu.neigh.UpdatedAt = e.cache.nic.stack.clock.Now()
|
||||
e.mu.neigh.UpdatedAt = e.cache.nic.stack.clock.NowMonotonic()
|
||||
|
||||
switch prev {
|
||||
case Unknown:
|
||||
|
||||
@@ -296,7 +296,7 @@ func TestEntryUnknownToUnknownWhenConfirmationWithUnknownAddress(t *testing.T) {
|
||||
|
||||
// No events should have been dispatched.
|
||||
nudDisp.mu.Lock()
|
||||
if diff := cmp.Diff([]testEntryEventInfo(nil), nudDisp.mu.events); diff != "" {
|
||||
if diff := cmp.Diff([]testEntryEventInfo(nil), nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{})); diff != "" {
|
||||
t.Errorf("nud dispatcher events mismatch (-want, +got):\n%s", diff)
|
||||
}
|
||||
nudDisp.mu.Unlock()
|
||||
@@ -352,13 +352,13 @@ func unknownToIncomplete(e *neighborEntry, nudDisp *testNUDDispatcher, linkRes *
|
||||
Addr: entryTestAddr1,
|
||||
LinkAddr: tcpip.LinkAddress(""),
|
||||
State: Incomplete,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
{
|
||||
nudDisp.mu.Lock()
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events)
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{}))
|
||||
nudDisp.mu.events = nil
|
||||
nudDisp.mu.Unlock()
|
||||
if diff != "" {
|
||||
@@ -413,13 +413,13 @@ func unknownToStale(e *neighborEntry, nudDisp *testNUDDispatcher, linkRes *entry
|
||||
Addr: entryTestAddr1,
|
||||
LinkAddr: entryTestLinkAddr1,
|
||||
State: Stale,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
{
|
||||
nudDisp.mu.Lock()
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events)
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{}))
|
||||
nudDisp.mu.events = nil
|
||||
nudDisp.mu.Unlock()
|
||||
if diff != "" {
|
||||
@@ -483,12 +483,12 @@ func TestEntryIncompleteToIncompleteDoesNotChangeUpdatedAt(t *testing.T) {
|
||||
Addr: entryTestAddr1,
|
||||
LinkAddr: tcpip.LinkAddress(""),
|
||||
State: Unreachable,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
nudDisp.mu.Lock()
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events); diff != "" {
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{})); diff != "" {
|
||||
t.Errorf("nud dispatcher events mismatch (-want, +got):\n%s", diff)
|
||||
}
|
||||
nudDisp.mu.Unlock()
|
||||
@@ -545,13 +545,13 @@ func incompleteToReachableWithFlags(e *neighborEntry, nudDisp *testNUDDispatcher
|
||||
Addr: entryTestAddr1,
|
||||
LinkAddr: entryTestLinkAddr1,
|
||||
State: Reachable,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
{
|
||||
nudDisp.mu.Lock()
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events)
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{}))
|
||||
nudDisp.mu.events = nil
|
||||
nudDisp.mu.Unlock()
|
||||
if diff != "" {
|
||||
@@ -642,12 +642,12 @@ func TestEntryIncompleteToStaleWhenUnsolicitedConfirmation(t *testing.T) {
|
||||
Addr: entryTestAddr1,
|
||||
LinkAddr: entryTestLinkAddr1,
|
||||
State: Stale,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
nudDisp.mu.Lock()
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events); diff != "" {
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{})); diff != "" {
|
||||
t.Errorf("nud dispatcher events mismatch (-want, +got):\n%s", diff)
|
||||
}
|
||||
nudDisp.mu.Unlock()
|
||||
@@ -676,12 +676,12 @@ func TestEntryIncompleteToStaleWhenProbe(t *testing.T) {
|
||||
Addr: entryTestAddr1,
|
||||
LinkAddr: entryTestLinkAddr1,
|
||||
State: Stale,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
nudDisp.mu.Lock()
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events); diff != "" {
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{})); diff != "" {
|
||||
t.Errorf("nud dispatcher events mismatch (-want, +got):\n%s", diff)
|
||||
}
|
||||
nudDisp.mu.Unlock()
|
||||
@@ -755,12 +755,12 @@ func incompleteToUnreachable(c NUDConfigurations, e *neighborEntry, nudDisp *tes
|
||||
Addr: entryTestAddr1,
|
||||
LinkAddr: tcpip.LinkAddress(""),
|
||||
State: Unreachable,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
nudDisp.mu.Lock()
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events)
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{}))
|
||||
nudDisp.mu.events = nil
|
||||
nudDisp.mu.Unlock()
|
||||
if diff != "" {
|
||||
@@ -819,7 +819,7 @@ func TestEntryReachableToReachableClearsRouterWhenConfirmationWithoutRouter(t *t
|
||||
|
||||
// No events should have been dispatched.
|
||||
nudDisp.mu.Lock()
|
||||
diff := cmp.Diff([]testEntryEventInfo(nil), nudDisp.mu.events)
|
||||
diff := cmp.Diff([]testEntryEventInfo(nil), nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{}))
|
||||
nudDisp.mu.Unlock()
|
||||
if diff != "" {
|
||||
t.Errorf("nud dispatcher events mismatch (-want, +got):\n%s", diff)
|
||||
@@ -860,7 +860,7 @@ func TestEntryReachableToReachableWhenProbeWithSameAddress(t *testing.T) {
|
||||
|
||||
// No events should have been dispatched.
|
||||
nudDisp.mu.Lock()
|
||||
diff := cmp.Diff([]testEntryEventInfo(nil), nudDisp.mu.events)
|
||||
diff := cmp.Diff([]testEntryEventInfo(nil), nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{}))
|
||||
nudDisp.mu.Unlock()
|
||||
if diff != "" {
|
||||
t.Errorf("nud dispatcher events mismatch (-want, +got):\n%s", diff)
|
||||
@@ -941,14 +941,14 @@ func reachableToStale(c NUDConfigurations, e *neighborEntry, nudDisp *testNUDDis
|
||||
Addr: entryTestAddr1,
|
||||
LinkAddr: entryTestLinkAddr1,
|
||||
State: Stale,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
{
|
||||
|
||||
nudDisp.mu.Lock()
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events)
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{}))
|
||||
nudDisp.mu.events = nil
|
||||
nudDisp.mu.Unlock()
|
||||
if diff != "" {
|
||||
@@ -996,12 +996,12 @@ func TestEntryReachableToStaleWhenProbeWithDifferentAddress(t *testing.T) {
|
||||
Addr: entryTestAddr1,
|
||||
LinkAddr: entryTestLinkAddr2,
|
||||
State: Stale,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
nudDisp.mu.Lock()
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events); diff != "" {
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{})); diff != "" {
|
||||
t.Errorf("nud dispatcher events mismatch (-want, +got):\n%s", diff)
|
||||
}
|
||||
nudDisp.mu.Unlock()
|
||||
@@ -1048,12 +1048,12 @@ func TestEntryReachableToStaleWhenConfirmationWithDifferentAddress(t *testing.T)
|
||||
Addr: entryTestAddr1,
|
||||
LinkAddr: entryTestLinkAddr1,
|
||||
State: Stale,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
nudDisp.mu.Lock()
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events); diff != "" {
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{})); diff != "" {
|
||||
t.Errorf("nud dispatcher events mismatch (-want, +got):\n%s", diff)
|
||||
}
|
||||
nudDisp.mu.Unlock()
|
||||
@@ -1100,12 +1100,12 @@ func TestEntryReachableToStaleWhenConfirmationWithDifferentAddressAndOverride(t
|
||||
Addr: entryTestAddr1,
|
||||
LinkAddr: entryTestLinkAddr2,
|
||||
State: Stale,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
nudDisp.mu.Lock()
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events); diff != "" {
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{})); diff != "" {
|
||||
t.Errorf("nud dispatcher events mismatch (-want, +got):\n%s", diff)
|
||||
}
|
||||
nudDisp.mu.Unlock()
|
||||
@@ -1189,12 +1189,12 @@ func TestEntryStaleToReachableWhenSolicitedOverrideConfirmation(t *testing.T) {
|
||||
Addr: entryTestAddr1,
|
||||
LinkAddr: entryTestLinkAddr2,
|
||||
State: Reachable,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
nudDisp.mu.Lock()
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events); diff != "" {
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{})); diff != "" {
|
||||
t.Errorf("nud dispatcher events mismatch (-want, +got):\n%s", diff)
|
||||
}
|
||||
nudDisp.mu.Unlock()
|
||||
@@ -1241,12 +1241,12 @@ func TestEntryStaleToReachableWhenSolicitedConfirmationWithoutAddress(t *testing
|
||||
Addr: entryTestAddr1,
|
||||
LinkAddr: entryTestLinkAddr1,
|
||||
State: Reachable,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
nudDisp.mu.Lock()
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events); diff != "" {
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{})); diff != "" {
|
||||
t.Errorf("nud dispatcher events mismatch (-want, +got):\n%s", diff)
|
||||
}
|
||||
nudDisp.mu.Unlock()
|
||||
@@ -1282,12 +1282,12 @@ func TestEntryStaleToStaleWhenOverrideConfirmation(t *testing.T) {
|
||||
Addr: entryTestAddr1,
|
||||
LinkAddr: entryTestLinkAddr2,
|
||||
State: Stale,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
nudDisp.mu.Lock()
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events); diff != "" {
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{})); diff != "" {
|
||||
t.Errorf("nud dispatcher events mismatch (-want, +got):\n%s", diff)
|
||||
}
|
||||
nudDisp.mu.Unlock()
|
||||
@@ -1330,12 +1330,12 @@ func TestEntryStaleToStaleWhenProbeUpdateAddress(t *testing.T) {
|
||||
Addr: entryTestAddr1,
|
||||
LinkAddr: entryTestLinkAddr2,
|
||||
State: Stale,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
nudDisp.mu.Lock()
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events); diff != "" {
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{})); diff != "" {
|
||||
t.Errorf("nud dispatcher events mismatch (-want, +got):\n%s", diff)
|
||||
}
|
||||
nudDisp.mu.Unlock()
|
||||
@@ -1389,12 +1389,12 @@ func staleToDelay(e *neighborEntry, nudDisp *testNUDDispatcher, linkRes *entryTe
|
||||
Addr: entryTestAddr1,
|
||||
LinkAddr: entryTestLinkAddr1,
|
||||
State: Delay,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
nudDisp.mu.Lock()
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events)
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{}))
|
||||
nudDisp.mu.events = nil
|
||||
nudDisp.mu.Unlock()
|
||||
if diff != "" {
|
||||
@@ -1441,12 +1441,12 @@ func TestEntryDelayToReachableWhenUpperLevelConfirmation(t *testing.T) {
|
||||
Addr: entryTestAddr1,
|
||||
LinkAddr: entryTestLinkAddr1,
|
||||
State: Reachable,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
nudDisp.mu.Lock()
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events); diff != "" {
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{})); diff != "" {
|
||||
t.Errorf("nud dispatcher events mismatch (-want, +got):\n%s", diff)
|
||||
}
|
||||
nudDisp.mu.Unlock()
|
||||
@@ -1496,12 +1496,12 @@ func TestEntryDelayToReachableWhenSolicitedOverrideConfirmation(t *testing.T) {
|
||||
Addr: entryTestAddr1,
|
||||
LinkAddr: entryTestLinkAddr2,
|
||||
State: Reachable,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
nudDisp.mu.Lock()
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events); diff != "" {
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{})); diff != "" {
|
||||
t.Errorf("nud dispatcher events mismatch (-want, +got):\n%s", diff)
|
||||
}
|
||||
nudDisp.mu.Unlock()
|
||||
@@ -1551,12 +1551,12 @@ func TestEntryDelayToReachableWhenSolicitedConfirmationWithoutAddress(t *testing
|
||||
Addr: entryTestAddr1,
|
||||
LinkAddr: entryTestLinkAddr1,
|
||||
State: Reachable,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
nudDisp.mu.Lock()
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events); diff != "" {
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{})); diff != "" {
|
||||
t.Errorf("nud dispatcher events mismatch (-want, +got):\n%s", diff)
|
||||
}
|
||||
nudDisp.mu.Unlock()
|
||||
@@ -1643,12 +1643,12 @@ func TestEntryDelayToStaleWhenProbeWithDifferentAddress(t *testing.T) {
|
||||
Addr: entryTestAddr1,
|
||||
LinkAddr: entryTestLinkAddr2,
|
||||
State: Stale,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
nudDisp.mu.Lock()
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events); diff != "" {
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{})); diff != "" {
|
||||
t.Errorf("nud dispatcher events mismatch (-want, +got):\n%s", diff)
|
||||
}
|
||||
nudDisp.mu.Unlock()
|
||||
@@ -1695,12 +1695,12 @@ func TestEntryDelayToStaleWhenConfirmationWithDifferentAddress(t *testing.T) {
|
||||
Addr: entryTestAddr1,
|
||||
LinkAddr: entryTestLinkAddr2,
|
||||
State: Stale,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
nudDisp.mu.Lock()
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events); diff != "" {
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{})); diff != "" {
|
||||
t.Errorf("nud dispatcher events mismatch (-want, +got):\n%s", diff)
|
||||
}
|
||||
nudDisp.mu.Unlock()
|
||||
@@ -1768,13 +1768,13 @@ func delayToProbe(c NUDConfigurations, e *neighborEntry, nudDisp *testNUDDispatc
|
||||
Addr: entryTestAddr1,
|
||||
LinkAddr: entryTestLinkAddr1,
|
||||
State: Probe,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
{
|
||||
nudDisp.mu.Lock()
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events)
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{}))
|
||||
nudDisp.mu.events = nil
|
||||
nudDisp.mu.Unlock()
|
||||
if diff != "" {
|
||||
@@ -1825,12 +1825,12 @@ func TestEntryProbeToStaleWhenProbeWithDifferentAddress(t *testing.T) {
|
||||
Addr: entryTestAddr1,
|
||||
LinkAddr: entryTestLinkAddr2,
|
||||
State: Stale,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
nudDisp.mu.Lock()
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events); diff != "" {
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{})); diff != "" {
|
||||
t.Errorf("nud dispatcher events mismatch (-want, +got):\n%s", diff)
|
||||
}
|
||||
nudDisp.mu.Unlock()
|
||||
@@ -1880,12 +1880,12 @@ func TestEntryProbeToStaleWhenConfirmationWithDifferentAddress(t *testing.T) {
|
||||
Addr: entryTestAddr1,
|
||||
LinkAddr: entryTestLinkAddr2,
|
||||
State: Stale,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
nudDisp.mu.Lock()
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events); diff != "" {
|
||||
if diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{})); diff != "" {
|
||||
t.Errorf("nud dispatcher events mismatch (-want, +got):\n%s", diff)
|
||||
}
|
||||
nudDisp.mu.Unlock()
|
||||
@@ -2001,13 +2001,13 @@ func probeToReachableWithFlags(e *neighborEntry, nudDisp *testNUDDispatcher, lin
|
||||
Addr: entryTestAddr1,
|
||||
LinkAddr: linkAddr,
|
||||
State: Reachable,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
{
|
||||
nudDisp.mu.Lock()
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events)
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{}))
|
||||
nudDisp.mu.events = nil
|
||||
nudDisp.mu.Unlock()
|
||||
if diff != "" {
|
||||
@@ -2153,12 +2153,12 @@ func probeToUnreachable(c NUDConfigurations, e *neighborEntry, nudDisp *testNUDD
|
||||
Addr: entryTestAddr1,
|
||||
LinkAddr: entryTestLinkAddr1,
|
||||
State: Unreachable,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
nudDisp.mu.Lock()
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events)
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{}))
|
||||
nudDisp.mu.events = nil
|
||||
nudDisp.mu.Unlock()
|
||||
if diff != "" {
|
||||
@@ -2225,13 +2225,13 @@ func unreachableToIncomplete(e *neighborEntry, nudDisp *testNUDDispatcher, linkR
|
||||
Addr: entryTestAddr1,
|
||||
LinkAddr: tcpip.LinkAddress(""),
|
||||
State: Incomplete,
|
||||
UpdatedAt: clock.Now(),
|
||||
UpdatedAt: clock.NowMonotonic(),
|
||||
},
|
||||
},
|
||||
}
|
||||
{
|
||||
nudDisp.mu.Lock()
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events)
|
||||
diff := cmp.Diff(wantEvents, nudDisp.mu.events, cmp.AllowUnexported(tcpip.MonotonicTime{}))
|
||||
nudDisp.mu.events = nil
|
||||
nudDisp.mu.Unlock()
|
||||
if diff != "" {
|
||||
|
||||
@@ -329,7 +329,7 @@ type NUDState struct {
|
||||
// the algorithm defined in RFC 4861 section 6.3.2.
|
||||
reachableTime time.Duration
|
||||
|
||||
expiration time.Time
|
||||
expiration tcpip.MonotonicTime
|
||||
prevBaseReachableTime time.Duration
|
||||
prevMinRandomFactor float32
|
||||
prevMaxRandomFactor float32
|
||||
@@ -369,7 +369,7 @@ func (s *NUDState) ReachableTime() time.Duration {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
if s.clock.Now().After(s.mu.expiration) ||
|
||||
if s.clock.NowMonotonic().After(s.mu.expiration) ||
|
||||
s.mu.config.BaseReachableTime != s.mu.prevBaseReachableTime ||
|
||||
s.mu.config.MinRandomFactor != s.mu.prevMinRandomFactor ||
|
||||
s.mu.config.MaxRandomFactor != s.mu.prevMaxRandomFactor {
|
||||
@@ -418,5 +418,5 @@ func (s *NUDState) recomputeReachableTimeLocked() {
|
||||
s.mu.reachableTime = time.Duration(reachableTime)
|
||||
}
|
||||
|
||||
s.mu.expiration = s.clock.Now().Add(2 * time.Hour)
|
||||
s.mu.expiration = s.clock.NowMonotonic().Add(2 * time.Hour)
|
||||
}
|
||||
|
||||
@@ -170,8 +170,9 @@ func TestNUDFunctions(t *testing.T) {
|
||||
t.Errorf("s.Neigbors(%d, %d) error mismatch (-want +got):\n%s", test.nicID, ipv6.ProtocolNumber, diff)
|
||||
} else if test.expectedErr == nil {
|
||||
if diff := cmp.Diff(
|
||||
[]stack.NeighborEntry{{Addr: llAddr2, LinkAddr: linkAddr1, State: stack.Static, UpdatedAt: clock.Now()}},
|
||||
[]stack.NeighborEntry{{Addr: llAddr2, LinkAddr: linkAddr1, State: stack.Static, UpdatedAt: clock.NowMonotonic()}},
|
||||
neighbors,
|
||||
cmp.AllowUnexported(tcpip.MonotonicTime{}),
|
||||
); diff != "" {
|
||||
t.Errorf("neighbors mismatch (-want +got):\n%s", diff)
|
||||
}
|
||||
|
||||
@@ -5348,8 +5348,9 @@ func TestClearNeighborCacheOnNICDisable(t *testing.T) {
|
||||
if neighbors, err := s.Neighbors(nicID, addr.proto); err != nil {
|
||||
t.Fatalf("s.Neighbors(%d, %d): %s", nicID, addr.proto, err)
|
||||
} else if diff := cmp.Diff(
|
||||
[]stack.NeighborEntry{{Addr: addr.addr, LinkAddr: linkAddr, State: stack.Static, UpdatedAt: clock.Now()}},
|
||||
[]stack.NeighborEntry{{Addr: addr.addr, LinkAddr: linkAddr, State: stack.Static, UpdatedAt: clock.NowMonotonic()}},
|
||||
neighbors,
|
||||
cmp.AllowUnexported(tcpip.MonotonicTime{}),
|
||||
); diff != "" {
|
||||
t.Fatalf("proto=%d neighbors mismatch (-want +got):\n%s", addr.proto, diff)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user