[Ns-bugs] [Bug 862] New: NotifyInterfaceUp() Adds network route even when netmask is /32

code@nsnam.ece.gatech.edu code at nsnam.ece.gatech.edu
Tue Apr 6 01:45:17 PDT 2010


http://www.nsnam.org/bugzilla/show_bug.cgi?id=862

           Summary: NotifyInterfaceUp() Adds network route even when
                    netmask is /32
           Product: ns-3
           Version: pre-release
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P5
         Component: routing
        AssignedTo: ns-bugs at isi.edu
        ReportedBy: zarhan at cc.hut.fi
   Estimated Hours: 0.0


When configuring an interface with netmask of /32, (using with VirtualNetDevice
and tunnels), and Ptr<Ipv4>->Setup(i) is called, this, in turn calls
NotifyInterfaceUp() of all routing protocols.

In e.g. 

void
Ipv4StaticRouting::NotifyInterfaceUp (uint32_t i)
{
  NS_LOG_FUNCTION (this << i);
  // If interface address and network mask have been set, add a route
  // to the network of the interface (like e.g. ifconfig does on a
  // Linux box)
  for (uint32_t j = 0; j < m_ipv4->GetNAddresses (i); j++)
    {
      if (m_ipv4->GetAddress (i,j).GetLocal () != Ipv4Address () &&
          m_ipv4->GetAddress (i,j).GetMask () != Ipv4Mask ())
        {
          AddNetworkRouteTo (m_ipv4->GetAddress (i,j).GetLocal ().CombineMask
(m
_ipv4->GetAddress (i,j).GetMask ()),
                             m_ipv4->GetAddress (i,j).GetMask (), i);
        }
    }
}

the network is added even when the mask is /32. This leads to same entry being
in routing table twice (both the if-addr and as "network", even if the
"network" size is /32!). 

Even in Linux, if you add an ip address with mask of 255.255.255.255, nothing
gets added to routing table.

Proposed line to add:

if (m_ipv4->GetAddress (i,j).GetMask()==Ipv4Mask::GetOnes()) 
  { 
    return; 
  }

However, not submitting a patch yet - should this be added to ALL routing
protocols, or perhaps just list-routing?

In Linux (just a quick test with my wireless interface that I'm not using right
now, also omitting lines pertaining to my wired Internet connection). 

# ifconfig wlan up
# ifconfig wlan 4.4.4.4 netmask 255.255.255.255
# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo
# ifconfig wlan 4.4.4.4 netmask 255.255.255.0
# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
4.4.4.0         0.0.0.0         255.255.255.0   U     0      0        0 wlan
127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo

-- 
Configure bugmail: http://www.nsnam.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the Ns-bugs mailing list