From: Dinesh Dutt <[email protected]>

IPv6 multipath is broken in BGP if nexthop contains only global address.
IPv6 always uses both nextop IPv6 address and ifIndex in sending routes down to
zebra. In cases where only the global IPv6 address is present in the nexthop
information, the existing code doesn't set the ifIndex. An example of such a
case is when a route-map isused with "set ipv6 next-hop" and only global
address is specified. This code causes the ifIndex to be determined and
set thereby fixing the multipath programming.

Signed-off-by: Dinesh G Dutt <[email protected]>
Reviewed-by: Shrijeet Mukherjee <[email protected]>
---
 bgpd/bgp_zebra.c |   45 ++++++++++++++++++++++++---------------------
 1 file changed, 24 insertions(+), 21 deletions(-)

diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index 5e25da9..127f086 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -829,7 +829,7 @@ bgp_zebra_announce (struct prefix *p, struct bgp_info 
*info, struct bgp *bgp, sa
       if (nexthop == NULL)
        return;
 
-      if (IN6_IS_ADDR_LINKLOCAL (nexthop) && ! ifindex)
+      if (!ifindex)
        {
          if (info->peer->ifname)
            ifindex = ifname2ifindex (info->peer->ifname);
@@ -843,13 +843,14 @@ bgp_zebra_announce (struct prefix *p, struct bgp_info 
*info, struct bgp *bgp, sa
       for (mpinfo = bgp_info_mpath_first (info); mpinfo;
            mpinfo = bgp_info_mpath_next (mpinfo))
        {
+         ifindex = 0;
+
           /* Only global address nexthop exists. */
           if (mpinfo->attr->extra->mp_nexthop_len == 16)
-            {
               nexthop = &mpinfo->attr->extra->mp_nexthop_global;
-            }
+
           /* If both global and link-local address present. */
-                 if (mpinfo->attr->extra->mp_nexthop_len == 32)
+         if (mpinfo->attr->extra->mp_nexthop_len == 32)
             {
               /* Workaround for Cisco's nexthop bug.  */
               if (IN6_IS_ADDR_UNSPECIFIED 
(&mpinfo->attr->extra->mp_nexthop_global)
@@ -867,26 +868,28 @@ bgp_zebra_announce (struct prefix *p, struct bgp_info 
*info, struct bgp *bgp, sa
                   ifindex = mpinfo->peer->nexthop.ifp->ifindex;
                 }
             }
-             if (nexthop == NULL)
-               {
-                 continue;
-               }
 
-          if (IN6_IS_ADDR_LINKLOCAL (nexthop) && ! ifindex)
-               {
-                 if (mpinfo->peer->ifname)
-                {
-                   ifindex = if_nametoindex (mpinfo->peer->ifname);
+         if (nexthop == NULL)
+           {
+             continue;
+           }
+
+          if (!ifindex)
+           {
+             if (mpinfo->peer->ifname)
+               {
+                 ifindex = if_nametoindex (mpinfo->peer->ifname);
                }
-                 else if (mpinfo->peer->nexthop.ifp)
-                       {
-                          ifindex = mpinfo->peer->nexthop.ifp->ifindex;
-                       }
-                }
-             if (ifindex == 0)
-               {
-                 continue;
+             else if (mpinfo->peer->nexthop.ifp)
+               {
+                 ifindex = mpinfo->peer->nexthop.ifp->ifindex;
                }
+           }
+
+         if (ifindex == 0)
+           {
+             continue;
+           }
 
           stream_put (bgp_nexthop_buf, &nexthop, sizeof (struct in6_addr *));
           stream_put (bgp_ifindices_buf, &ifindex, sizeof (unsigned int));
-- 
1.7.10.4


_______________________________________________
Quagga-dev mailing list
[email protected]
https://lists.quagga.net/mailman/listinfo/quagga-dev

Reply via email to