From a2ec1932c9b76d80d3af93aa74acf945829cd582 Mon Sep 17 00:00:00 2001 From: Ghanan Gowripalan Date: Tue, 19 Jan 2021 12:06:08 -0800 Subject: Drop CheckLocalAddress from LinkAddressCache PiperOrigin-RevId: 352623277 --- pkg/tcpip/network/arp/arp.go | 24 +++++++++--------------- pkg/tcpip/network/ipv6/icmp_test.go | 11 +++-------- 2 files changed, 12 insertions(+), 23 deletions(-) (limited to 'pkg/tcpip/network') diff --git a/pkg/tcpip/network/arp/arp.go b/pkg/tcpip/network/arp/arp.go index 3259d052f..d54e7fe86 100644 --- a/pkg/tcpip/network/arp/arp.go +++ b/pkg/tcpip/network/arp/arp.go @@ -138,23 +138,17 @@ func (e *endpoint) HandlePacket(pkt *stack.PacketBuffer) { stats.RequestsReceived.Increment() localAddr := tcpip.Address(h.ProtocolAddressTarget()) - if e.nud == nil { - if e.linkAddrCache.CheckLocalAddress(e.nic.ID(), header.IPv4ProtocolNumber, localAddr) == 0 { - stats.RequestsReceivedUnknownTargetAddress.Increment() - return // we have no useful answer, ignore the request - } + if e.protocol.stack.CheckLocalAddress(e.nic.ID(), header.IPv4ProtocolNumber, localAddr) == 0 { + stats.RequestsReceivedUnknownTargetAddress.Increment() + return // we have no useful answer, ignore the request + } - addr := tcpip.Address(h.ProtocolAddressSender()) - linkAddr := tcpip.LinkAddress(h.HardwareAddressSender()) - e.linkAddrCache.AddLinkAddress(e.nic.ID(), addr, linkAddr) - } else { - if e.protocol.stack.CheckLocalAddress(e.nic.ID(), header.IPv4ProtocolNumber, localAddr) == 0 { - stats.RequestsReceivedUnknownTargetAddress.Increment() - return // we have no useful answer, ignore the request - } + remoteAddr := tcpip.Address(h.ProtocolAddressSender()) + remoteLinkAddr := tcpip.LinkAddress(h.HardwareAddressSender()) - remoteAddr := tcpip.Address(h.ProtocolAddressSender()) - remoteLinkAddr := tcpip.LinkAddress(h.HardwareAddressSender()) + if e.nud == nil { + e.linkAddrCache.AddLinkAddress(e.nic.ID(), remoteAddr, remoteLinkAddr) + } else { e.nud.HandleProbe(remoteAddr, ProtocolNumber, remoteLinkAddr, e.protocol) } diff --git a/pkg/tcpip/network/ipv6/icmp_test.go b/pkg/tcpip/network/ipv6/icmp_test.go index b1e6a70a2..a660a1cea 100644 --- a/pkg/tcpip/network/ipv6/icmp_test.go +++ b/pkg/tcpip/network/ipv6/icmp_test.go @@ -91,16 +91,11 @@ func (*stubDispatcher) DeliverTransportPacket(tcpip.TransportProtocolNumber, *st return stack.TransportPacketHandled } -type stubLinkAddressCache struct { - stack.LinkAddressCache -} +var _ stack.LinkAddressCache = (*stubLinkAddressCache)(nil) -func (*stubLinkAddressCache) CheckLocalAddress(tcpip.NICID, tcpip.NetworkProtocolNumber, tcpip.Address) tcpip.NICID { - return 0 -} +type stubLinkAddressCache struct{} -func (*stubLinkAddressCache) AddLinkAddress(tcpip.NICID, tcpip.Address, tcpip.LinkAddress) { -} +func (*stubLinkAddressCache) AddLinkAddress(tcpip.NICID, tcpip.Address, tcpip.LinkAddress) {} type stubNUDHandler struct { probeCount int -- cgit v1.2.3