mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Drop CheckLocalAddress from LinkAddressCache
PiperOrigin-RevId: 352623277
This commit is contained in:
committed by
gVisor bot
parent
1a072e298e
commit
a2ec1932c9
@@ -138,23 +138,17 @@ func (e *endpoint) HandlePacket(pkt *stack.PacketBuffer) {
|
||||
stats.RequestsReceived.Increment()
|
||||
localAddr := tcpip.Address(h.ProtocolAddressTarget())
|
||||
|
||||
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())
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
addr := tcpip.Address(h.ProtocolAddressSender())
|
||||
linkAddr := tcpip.LinkAddress(h.HardwareAddressSender())
|
||||
e.linkAddrCache.AddLinkAddress(e.nic.ID(), addr, linkAddr)
|
||||
e.linkAddrCache.AddLinkAddress(e.nic.ID(), remoteAddr, remoteLinkAddr)
|
||||
} 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())
|
||||
e.nud.HandleProbe(remoteAddr, ProtocolNumber, remoteLinkAddr, e.protocol)
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -829,10 +829,6 @@ type LinkAddressResolver interface {
|
||||
|
||||
// A LinkAddressCache caches link addresses.
|
||||
type LinkAddressCache interface {
|
||||
// CheckLocalAddress determines if the given local address exists, and if it
|
||||
// does not exist.
|
||||
CheckLocalAddress(nicID tcpip.NICID, protocol tcpip.NetworkProtocolNumber, addr tcpip.Address) tcpip.NICID
|
||||
|
||||
// AddLinkAddress adds a link address to the cache.
|
||||
AddLinkAddress(nicID tcpip.NICID, addr tcpip.Address, linkAddr tcpip.LinkAddress)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user