Don't trigger ARP/NDP if already resolved
This commit is contained in:
parent
4a1b41670c
commit
1c2e833c4a
@ -186,10 +186,10 @@ void Device::transmitPacket(PacketBuffer *pktBuf)
|
||||
|
||||
void Device::resolveGateway()
|
||||
{
|
||||
if (hasIp4_)
|
||||
if (hasIp4_ && !isResolved(ip4Gateway_))
|
||||
sendArpRequest(ip4Gateway_);
|
||||
|
||||
if (hasIp6_)
|
||||
if (hasIp6_ && !isResolved(ip6Gateway_))
|
||||
sendNeighborSolicit(ip6Gateway_);
|
||||
}
|
||||
|
||||
@ -368,7 +368,8 @@ void Device::sendArpRequest(PacketBuffer *pktBuf)
|
||||
|
||||
tgtIp = ((dstIp & ip4Mask_) == ip4Subnet_) ? dstIp : ip4Gateway_;
|
||||
|
||||
sendArpRequest(tgtIp);
|
||||
if (!isResolved(tgtIp))
|
||||
sendArpRequest(tgtIp);
|
||||
|
||||
}
|
||||
|
||||
@ -390,7 +391,18 @@ void Device::sendNeighborSolicit(PacketBuffer *pktBuf)
|
||||
|
||||
tgtIp = ((dstIp & ip6Mask_) == ip6Subnet_) ? dstIp : ip6Gateway_;
|
||||
|
||||
sendNeighborSolicit(tgtIp);
|
||||
if (!isResolved(tgtIp))
|
||||
sendNeighborSolicit(tgtIp);
|
||||
}
|
||||
|
||||
bool Device::isResolved(quint32 ip)
|
||||
{
|
||||
return arpLookup(ip) > 0;
|
||||
}
|
||||
|
||||
bool Device::isResolved(UInt128 ip)
|
||||
{
|
||||
return ndpLookup(ip) > 0;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -106,6 +106,8 @@ protected: // data
|
||||
private: // methods
|
||||
void sendArpRequest(PacketBuffer *pktBuf);
|
||||
void sendNeighborSolicit(PacketBuffer *pktBuf);
|
||||
bool isResolved(quint32 ip);
|
||||
bool isResolved(UInt128 ip);
|
||||
|
||||
};
|
||||
|
||||
|
@ -303,14 +303,14 @@ void EmulDevice::sendArpRequest(quint32 tgtIp)
|
||||
if (!tgtIp)
|
||||
return;
|
||||
|
||||
// FIXME: Now that the caller does a isResolved check, re-evaluate
|
||||
// the below behaviour
|
||||
// This function will be called once per unique stream - which
|
||||
// may all have the same dst IP; even if dst IP are different the
|
||||
// gateway for the different dst IP may all be same. However,
|
||||
// we don't want to send duplicate ARP requests, so we check
|
||||
// if the tgtIP is already in the cache (resolved or unresolved)
|
||||
// and if so, we don't resend it
|
||||
// FIXME: this check needs to happen at caller so that HostDevices
|
||||
// can also benefit from this check
|
||||
if (arpTable_.contains(tgtIp))
|
||||
return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user