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:
Ameya Deshpande
2021-10-10 15:36:40 +05:30
committed by Tommaso Pecorella
parent dcf022ad8b
commit f25866e922
2 changed files with 20 additions and 0 deletions

View File

@@ -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
*****

View File

@@ -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 */