diff options
author | gVisor bot <gvisor-bot@google.com> | 2021-01-20 01:12:32 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-01-20 01:12:32 +0000 |
commit | 49541ed7a08d77c428d918665c8643b23099facf (patch) | |
tree | d5ca0932299b923cabb611429d2f06577304410d /pkg/tcpip/stack/stack.go | |
parent | e6b0beddc84f0c2b71cafef208b1618c80fa0a40 (diff) | |
parent | 7ff5ceaeae66303ed6a2199963c00cb08b2fe7ca (diff) |
Merge release-20210112.0-47-g7ff5ceaea (automated)
Diffstat (limited to 'pkg/tcpip/stack/stack.go')
-rw-r--r-- | pkg/tcpip/stack/stack.go | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/pkg/tcpip/stack/stack.go b/pkg/tcpip/stack/stack.go index b4878669c..4685fa4cf 100644 --- a/pkg/tcpip/stack/stack.go +++ b/pkg/tcpip/stack/stack.go @@ -382,8 +382,6 @@ type Stack struct { stats tcpip.Stats - linkAddrCache *linkAddrCache - mu sync.RWMutex nics map[tcpip.NICID]*NIC @@ -636,7 +634,6 @@ func New(opts Options) *Stack { linkAddrResolvers: make(map[tcpip.NetworkProtocolNumber]LinkAddressResolver), nics: make(map[tcpip.NICID]*NIC), cleanupEndpoints: make(map[TransportEndpoint]struct{}), - linkAddrCache: newLinkAddrCache(ageLimit, resolutionTimeout, resolutionAttempts), PortManager: ports.NewPortManager(), clock: clock, stats: opts.Stats.FillIn(), @@ -1516,12 +1513,18 @@ func (s *Stack) SetSpoofing(nicID tcpip.NICID, enable bool) *tcpip.Error { return nil } -// AddLinkAddress adds a link address to the stack link cache. -func (s *Stack) AddLinkAddress(nicID tcpip.NICID, addr tcpip.Address, linkAddr tcpip.LinkAddress) { - fullAddr := tcpip.FullAddress{NIC: nicID, Addr: addr} - s.linkAddrCache.add(fullAddr, linkAddr) - // TODO: provide a way for a transport endpoint to receive a signal - // that AddLinkAddress for a particular address has been called. +// AddLinkAddress adds a link address for the neighbor on the specified NIC. +func (s *Stack) AddLinkAddress(nicID tcpip.NICID, neighbor tcpip.Address, linkAddr tcpip.LinkAddress) *tcpip.Error { + s.mu.RLock() + defer s.mu.RUnlock() + + nic, ok := s.nics[nicID] + if !ok { + return tcpip.ErrUnknownNICID + } + + nic.linkAddrCache.AddLinkAddress(neighbor, linkAddr) + return nil } // GetLinkAddress finds the link address corresponding to a neighbor's address. |