Bug 1689 - IPv6 shouldn't add a default gateway without checking the Router lifetime
authorTommaso Pecorella <tommaso.pecorella@unifi.it>
Sat, 25 May 2013 21:36:10 +0200
changeset 9817 cfb7c304cf2d
parent 9816 e86da132e7e9
child 9818 cfb12f56257a
Bug 1689 - IPv6 shouldn't add a default gateway without checking the Router lifetime
RELEASE_NOTES
src/internet/model/icmpv6-l4-protocol.cc
src/internet/model/ipv6-l3-protocol.cc
--- a/RELEASE_NOTES	Sat May 25 18:18:00 2013 +0200
+++ b/RELEASE_NOTES	Sat May 25 21:36:10 2013 +0200
@@ -29,6 +29,7 @@
 - Bug 1678 - C++11 compliance problem with std::pair"
 - Bug 1683 - IPv6 autoconfigured don't use *infinite* lifetimes
 - Bug 1669 - ns-3 should support binding two and three (possibly more) arguments
+- Bug 1689 - IPv6 shouldn't add a default gateway without checking the Router lifetime
 
 Known issues
 ------------
--- a/src/internet/model/icmpv6-l4-protocol.cc	Sat May 25 18:18:00 2013 +0200
+++ b/src/internet/model/icmpv6-l4-protocol.cc	Sat May 25 21:36:10 2013 +0200
@@ -292,9 +292,15 @@
   bool next = true;
   bool hasLla = false;
   bool hasMtu = false;
+  Ipv6Address defaultRouter = Ipv6Address::GetZero ();
 
   p->RemoveHeader (raHeader);
 
+  if (raHeader.GetLifeTime())
+    {
+      defaultRouter = src;
+    }
+
   while (next == true)
     {
       uint8_t type = 0;
@@ -305,7 +311,7 @@
         case Icmpv6Header::ICMPV6_OPT_PREFIX:
           p->RemoveHeader (prefixHdr);
           ipv6->AddAutoconfiguredAddress (ipv6->GetInterfaceForDevice (interface->GetDevice ()), prefixHdr.GetPrefix (), prefixHdr.GetPrefixLength (),
-                                          prefixHdr.GetFlags (), prefixHdr.GetValidTime (), prefixHdr.GetPreferredTime (), src);
+                                          prefixHdr.GetFlags (), prefixHdr.GetValidTime (), prefixHdr.GetPreferredTime (), defaultRouter);
           break;
         case Icmpv6Header::ICMPV6_OPT_MTU:
           /* take in account the first MTU option */
--- a/src/internet/model/ipv6-l3-protocol.cc	Sat May 25 18:18:00 2013 +0200
+++ b/src/internet/model/ipv6-l3-protocol.cc	Sat May 25 21:36:10 2013 +0200
@@ -293,7 +293,10 @@
       /* add default router
        * if a previous default route exists, the new ones is simply added
        */
-      GetRoutingProtocol ()->NotifyAddRoute (Ipv6Address::GetAny (), Ipv6Prefix ((uint8_t)0), defaultRouter, interface, network);
+      if (!defaultRouter.IsAny())
+        {
+          GetRoutingProtocol ()->NotifyAddRoute (Ipv6Address::GetAny (), Ipv6Prefix ((uint8_t)0), defaultRouter, interface, network);
+        }
 
       Ptr<Ipv6AutoconfiguredPrefix> aPrefix = CreateObject<Ipv6AutoconfiguredPrefix> (m_node, interface, network, mask, preferredTime, validTime, defaultRouter);
       aPrefix->StartPreferredTimer ();