nix-vector-routing: (fixes #466) Handle loopback IPv4/6 addresses
- Add the condition for handling loopback addresses in `RouteOutput ()`. - Add about this change in "Scope and Limitations" of Nix documentation. Signed-off-by: Ameya Deshpande <ameyanrd@outlook.com>
This commit is contained in:
committed by
Tommaso Pecorella
parent
dcf022ad8b
commit
f25866e922
@@ -74,6 +74,8 @@ When using the IPv6 stack, the link-local address allocation is unique by
|
||||
default over the entire topology. However, if the link-local addresses are
|
||||
assigned manually, the user must ensure uniqueness of link-local addresses.
|
||||
|
||||
NixVectorRouting supports routes to IPv4 and IPv6 loopback addresses on localhost.
|
||||
Although it is not really intended to route to these addresses, it can do so.
|
||||
|
||||
Usage
|
||||
*****
|
||||
|
||||
@@ -681,6 +681,24 @@ NixVectorRouting<T>::RouteOutput (Ptr<Packet> p, const IpHeader &header, Ptr<Net
|
||||
|
||||
NS_LOG_DEBUG ("Dest IP from header: " << destAddress);
|
||||
|
||||
if (destAddress.IsLocalhost ())
|
||||
{
|
||||
rtentry = Create<IpRoute> ();
|
||||
rtentry->SetSource (IpAddress::GetLoopback ());
|
||||
rtentry->SetDestination (destAddress);
|
||||
rtentry->SetGateway (IpAddress::GetZero ());
|
||||
for (uint32_t i = 0 ; i < m_ip->GetNInterfaces (); i++)
|
||||
{
|
||||
Ptr<LoopbackNetDevice> loNetDevice = DynamicCast<LoopbackNetDevice> (m_ip->GetNetDevice (i));
|
||||
if (loNetDevice)
|
||||
{
|
||||
rtentry->SetOutputDevice (loNetDevice);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return rtentry;
|
||||
}
|
||||
|
||||
if constexpr (!IsIpv4::value)
|
||||
{
|
||||
/* when sending on link-local multicast, there have to be interface specified */
|
||||
|
||||
Reference in New Issue
Block a user