From 70f2ea6e921a52d478494c42191986683cc3854b Mon Sep 17 00:00:00 2001 From: Guowang Shi Date: Wed, 19 Jun 2013 09:10:31 +0200 Subject: [PATCH] Bug 1688 - Routers should advertise themselves from the link-local address --- RELEASE_NOTES | 1 + examples/ipv6/icmpv6-redirect.cc | 2 +- src/internet/helper/ipv6-interface-container.cc | 4 ++-- src/internet/model/ipv6-static-routing.cc | 4 ++++ src/internet/model/ipv6-static-routing.h | 4 ++-- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index ae3e8ee61..6052b48ed 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -30,6 +30,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 1688 - Routers should advertise themselves from the link-local address - Bug 1689 - IPv6 shouldn't add a default gateway without checking the Router lifetime - Bug 1700 - Ipv6RawSocket does not honor the bound address when sending packets - Bug 1701 - Ipv6StaticRouting: the source address should match the destination scope diff --git a/examples/ipv6/icmpv6-redirect.cc b/examples/ipv6/icmpv6-redirect.cc index 2353a984b..7c80022c9 100644 --- a/examples/ipv6/icmpv6-redirect.cc +++ b/examples/ipv6/icmpv6-redirect.cc @@ -155,7 +155,7 @@ int main (int argc, char **argv) Ipv6InterfaceContainer iic2 = ipv6.Assign (ndc2); iic2.SetRouter (0, true); - stackHelper.AddHostRouteTo (r1, iic2.GetAddress (1, 1), iic1.GetAddress (2, 1), iic1.GetInterfaceIndex (1)); + stackHelper.AddHostRouteTo (r1, iic2.GetAddress (1, 1), iic1.GetAddress (2, 0), iic1.GetInterfaceIndex (1)); Simulator::Schedule (Seconds (0.0), &StackHelper::PrintRoutingTable, &stackHelper, r1); Simulator::Schedule (Seconds (3.0), &StackHelper::PrintRoutingTable, &stackHelper, sta1); diff --git a/src/internet/helper/ipv6-interface-container.cc b/src/internet/helper/ipv6-interface-container.cc index 57d559923..09853dbbd 100644 --- a/src/internet/helper/ipv6-interface-container.cc +++ b/src/internet/helper/ipv6-interface-container.cc @@ -88,7 +88,7 @@ void Ipv6InterfaceContainer::SetRouter (uint32_t i, bool router) { uint32_t other; /* assume first global address is index 1 (0 is link-local) */ - Ipv6Address routerAddress = ipv6->GetAddress (m_interfaces[i].second, 1).GetAddress (); + Ipv6Address routerAddress = ipv6->GetAddress (m_interfaces[i].second, 0).GetAddress (); for (other = 0; other < m_interfaces.size (); other++) { @@ -109,7 +109,7 @@ void Ipv6InterfaceContainer::SetDefaultRoute (uint32_t i, uint32_t router) { Ptr ipv6 = m_interfaces[i].first; Ptr ipv6Router = m_interfaces[router].first; - Ipv6Address routerAddress = ipv6Router->GetAddress (m_interfaces[router].second, 1).GetAddress (); + Ipv6Address routerAddress = ipv6Router->GetAddress (m_interfaces[router].second, 0).GetAddress (); Ptr routing = 0; Ipv6StaticRoutingHelper routingHelper; diff --git a/src/internet/model/ipv6-static-routing.cc b/src/internet/model/ipv6-static-routing.cc index 2eb41f5a9..ef0745a65 100644 --- a/src/internet/model/ipv6-static-routing.cc +++ b/src/internet/model/ipv6-static-routing.cc @@ -97,6 +97,8 @@ Ipv6StaticRouting::PrintRoutingTable (Ptr stream) const void Ipv6StaticRouting::AddHostRouteTo (Ipv6Address dst, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse, uint32_t metric) { NS_LOG_FUNCTION (this << dst << nextHop << interface << prefixToUse << metric); + NS_ASSERT_MSG(nextHop.IsLinkLocal(), "Ipv6StaticRouting::AddHostRouteTo - Next hop must be link-local"); + AddNetworkRouteTo (dst, Ipv6Prefix::GetOnes (), nextHop, interface, prefixToUse, metric); } @@ -117,6 +119,8 @@ void Ipv6StaticRouting::AddNetworkRouteTo (Ipv6Address network, Ipv6Prefix netwo void Ipv6StaticRouting::AddNetworkRouteTo (Ipv6Address network, Ipv6Prefix networkPrefix, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse, uint32_t metric) { NS_LOG_FUNCTION (this << network << networkPrefix << nextHop << interface << prefixToUse << metric); + NS_ASSERT_MSG(nextHop.IsLinkLocal(), "Ipv6StaticRouting::AddNetworkRouteTo - Next hop must be link-local"); + Ipv6RoutingTableEntry* route = new Ipv6RoutingTableEntry (); *route = Ipv6RoutingTableEntry::CreateNetworkRouteTo (network, networkPrefix, nextHop, interface, prefixToUse); m_networkRoutes.push_back (std::make_pair (route, metric)); diff --git a/src/internet/model/ipv6-static-routing.h b/src/internet/model/ipv6-static-routing.h index 8e075a68f..b6669a82e 100644 --- a/src/internet/model/ipv6-static-routing.h +++ b/src/internet/model/ipv6-static-routing.h @@ -74,7 +74,7 @@ public: /** * \brief Add route to host. * \param dest destination address - * \param nextHop next hop address to route the packet + * \param nextHop next hop address to route the packet. Must be a link-local address * \param interface interface index * \param prefixToUse prefix that should be used for source address for this destination * \param metric metric of route in case of multiple routes to same destination @@ -103,7 +103,7 @@ public: * \brief Add route to network. * \param network network address * \param networkPrefix network prefix* - * \param nextHop next hop address to route the packet + * \param nextHop next hop address to route the packet. Must be a link-local address * \param interface interface index * \param prefixToUse prefix that should be used for source address for this destination * \param metric metric of route in case of multiple routes to same destination