diff options
author | Ghanan Gowripalan <ghanan@google.com> | 2021-01-15 18:12:50 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-01-15 18:15:26 -0800 |
commit | 2814a032be7b34e4cc0c0607dba8030e74e11208 (patch) | |
tree | fc6a023766f5ad1ae5818abd710c997ba657e8bd /pkg/tcpip/stack/nic.go | |
parent | fd5b52c87ff8fbabf2b293fc95ec9f9f04e5621c (diff) |
Support GetLinkAddress with neighborCache
Test: integration_test.TestGetLinkAddress
PiperOrigin-RevId: 352119404
Diffstat (limited to 'pkg/tcpip/stack/nic.go')
-rw-r--r-- | pkg/tcpip/stack/nic.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/pkg/tcpip/stack/nic.go b/pkg/tcpip/stack/nic.go index c8d0323cb..9e106a161 100644 --- a/pkg/tcpip/stack/nic.go +++ b/pkg/tcpip/stack/nic.go @@ -547,6 +547,15 @@ func (n *NIC) removeAddress(addr tcpip.Address) *tcpip.Error { return tcpip.ErrBadLocalAddress } +func (n *NIC) getNeighborLinkAddress(addr, localAddr tcpip.Address, linkRes LinkAddressResolver, onResolve func(tcpip.LinkAddress, bool)) (tcpip.LinkAddress, <-chan struct{}, *tcpip.Error) { + if n.neigh != nil { + entry, ch, err := n.neigh.entry(addr, localAddr, linkRes, onResolve) + return entry.LinkAddr, ch, err + } + + return n.stack.linkAddrCache.get(tcpip.FullAddress{NIC: n.ID(), Addr: addr}, linkRes, localAddr, n, onResolve) +} + func (n *NIC) neighbors() ([]NeighborEntry, *tcpip.Error) { if n.neigh == nil { return nil, tcpip.ErrNotSupported |