From e22f63ffe4e40153c45c65f034b82d4f1684f563 Mon Sep 17 00:00:00 2001 From: Tommaso Pecorella Date: Tue, 31 Dec 2013 19:48:09 +0100 Subject: [PATCH] Bug 1821 - Setting an interface to Down state will cause various asserts in IPv6 --- RELEASE_NOTES | 1 + src/internet/model/ipv4-static-routing.cc | 29 +++++++++++--------- src/internet/model/ipv6-interface.cc | 1 + src/internet/model/ipv6-static-routing.cc | 32 +++++++++++------------ 4 files changed, 34 insertions(+), 29 deletions(-) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 628029d87..703671ef6 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -29,6 +29,7 @@ New user-visible features Bugs fixed ---------- +- Bug 1821 - Setting an interface to Down state will cause various asserts in IPv6 Release 3.19 diff --git a/src/internet/model/ipv4-static-routing.cc b/src/internet/model/ipv4-static-routing.cc index 7cdaa4b5f..e8defff83 100644 --- a/src/internet/model/ipv4-static-routing.cc +++ b/src/internet/model/ipv4-static-routing.cc @@ -627,17 +627,16 @@ Ipv4StaticRouting::NotifyInterfaceDown (uint32_t i) { NS_LOG_FUNCTION (this << i); // Remove all static routes that are going through this interface - uint32_t j = 0; - while (j < GetNRoutes ()) + for (NetworkRoutesI it = m_networkRoutes.begin (); it != m_networkRoutes.end (); ) { - Ipv4RoutingTableEntry route = GetRoute (j); - if (route.GetInterface () == i) + if (it->first->GetInterface () == i) { - RemoveRoute (j); + delete it->first; + it = m_networkRoutes.erase (it); } else { - j++; + it++; } } } @@ -672,15 +671,19 @@ Ipv4StaticRouting::NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress Ipv4Mask networkMask = address.GetMask (); // Remove all static routes that are going through this interface // which reference this network - for (uint32_t j = 0; j < GetNRoutes (); j++) + for (NetworkRoutesI it = m_networkRoutes.begin (); it != m_networkRoutes.end (); ) { - Ipv4RoutingTableEntry route = GetRoute (j); - if (route.GetInterface () == interface && - route.IsNetwork () && - route.GetDestNetwork () == networkAddress && - route.GetDestNetworkMask () == networkMask) + if (it->first->GetInterface () == interface + && it->first->IsNetwork () + && it->first->GetDestNetwork () == networkAddress + && it->first->GetDestNetworkMask () == networkMask) { - RemoveRoute (j); + delete it->first; + it = m_networkRoutes.erase (it); + } + else + { + it++; } } } diff --git a/src/internet/model/ipv6-interface.cc b/src/internet/model/ipv6-interface.cc index 6928e92da..96b5798e1 100644 --- a/src/internet/model/ipv6-interface.cc +++ b/src/internet/model/ipv6-interface.cc @@ -183,6 +183,7 @@ void Ipv6Interface::SetDown () NS_LOG_FUNCTION_NOARGS (); m_ifup = false; m_addresses.clear (); + m_ndCache->Flush (); } bool Ipv6Interface::IsForwarding () const diff --git a/src/internet/model/ipv6-static-routing.cc b/src/internet/model/ipv6-static-routing.cc index 861d96a08..4094c0460 100644 --- a/src/internet/model/ipv6-static-routing.cc +++ b/src/internet/model/ipv6-static-routing.cc @@ -684,21 +684,18 @@ void Ipv6StaticRouting::NotifyInterfaceUp (uint32_t i) void Ipv6StaticRouting::NotifyInterfaceDown (uint32_t i) { NS_LOG_FUNCTION (this << i); - uint32_t j = 0; - uint32_t max = GetNRoutes (); /* remove all static routes that are going through this interface */ - while (j < max) + for (NetworkRoutesI it = m_networkRoutes.begin (); it != m_networkRoutes.end (); ) { - Ipv6RoutingTableEntry route = GetRoute (j); - - if (route.GetInterface () == i) + if (it->first->GetInterface () == i) { - RemoveRoute (j); + delete it->first; + it = m_networkRoutes.erase (it); } else { - j++; + it++; } } } @@ -731,16 +728,19 @@ void Ipv6StaticRouting::NotifyRemoveAddress (uint32_t interface, Ipv6InterfaceAd // Remove all static routes that are going through this interface // which reference this network - for (uint32_t j = 0; j < GetNRoutes (); j++) + for (NetworkRoutesI it = m_networkRoutes.begin (); it != m_networkRoutes.end (); ) { - Ipv6RoutingTableEntry route = GetRoute (j); - - if (route.GetInterface () == interface - && route.IsNetwork () - && route.GetDestNetwork () == networkAddress - && route.GetDestNetworkPrefix () == networkMask) + if (it->first->GetInterface () == interface + && it->first->IsNetwork () + && it->first->GetDestNetwork () == networkAddress + && it->first->GetDestNetworkPrefix () == networkMask) { - RemoveRoute (j); + delete it->first; + it = m_networkRoutes.erase (it); + } + else + { + it++; } } }