From d7e61e2f49939daab75281b5ff59cebbb3383d25 Mon Sep 17 00:00:00 2001 From: Tommaso Pecorella Date: Sat, 25 May 2013 21:36:10 +0200 Subject: [PATCH] Bug 1689 - IPv6 shouldn't add a default gateway without checking the Router lifetime --- RELEASE_NOTES | 1 + src/internet/model/icmpv6-l4-protocol.cc | 8 +++++++- src/internet/model/ipv6-l3-protocol.cc | 5 ++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 7ebdc6873..115d5bace 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -29,6 +29,7 @@ Bugs fixed - 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 ------------ diff --git a/src/internet/model/icmpv6-l4-protocol.cc b/src/internet/model/icmpv6-l4-protocol.cc index fd08751eb..55785a17e 100644 --- a/src/internet/model/icmpv6-l4-protocol.cc +++ b/src/internet/model/icmpv6-l4-protocol.cc @@ -292,9 +292,15 @@ void Icmpv6L4Protocol::HandleRA (Ptr packet, Ipv6Address const &src, Ipv 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 @@ void Icmpv6L4Protocol::HandleRA (Ptr packet, Ipv6Address const &src, Ipv 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 */ diff --git a/src/internet/model/ipv6-l3-protocol.cc b/src/internet/model/ipv6-l3-protocol.cc index 823ee5ff8..a03688f12 100644 --- a/src/internet/model/ipv6-l3-protocol.cc +++ b/src/internet/model/ipv6-l3-protocol.cc @@ -293,7 +293,10 @@ void Ipv6L3Protocol::AddAutoconfiguredAddress (uint32_t interface, Ipv6Address n /* 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 aPrefix = CreateObject (m_node, interface, network, mask, preferredTime, validTime, defaultRouter); aPrefix->StartPreferredTimer ();