]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: store nexthop info for redistributed IPV6 routes
authorStephen Hemminger <shemminger@vyatta.com>
Tue, 6 Dec 2011 10:51:10 +0000 (14:51 +0400)
committerDenis Ovsienko <infrastation@yandex.ru>
Mon, 2 Jan 2012 13:15:19 +0000 (17:15 +0400)
BGP was ignoring nexthop info for static and other redistributed
routes for IPv6.  Build extra attribute info to store the nexthop.
See also:
  https://bugzilla.vyatta.com/show_bug.cgi?id=6073

bgpd/bgp_route.c
bgpd/bgp_route.h
bgpd/bgp_zebra.c

index b771633069903cedc89d2e886e11bbb036e07821..98e49bcdc35e118857efa03dc4a98ef17629158b 100644 (file)
@@ -5238,7 +5238,8 @@ ALIAS (no_ipv6_aggregate_address_summary_only,
 \f
 /* Redistribute route treatment. */
 void
-bgp_redistribute_add (struct prefix *p, struct in_addr *nexthop,
+bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop,
+                     const struct in6_addr *nexthop6,
                      u_int32_t metric, u_char type)
 {
   struct bgp *bgp;
@@ -5258,6 +5259,15 @@ bgp_redistribute_add (struct prefix *p, struct in_addr *nexthop,
   if (nexthop)
     attr.nexthop = *nexthop;
 
+#ifdef HAVE_IPV6
+  if (nexthop6)
+    {
+      struct attr_extra *extra = bgp_attr_extra_get(&attr);
+      extra->mp_nexthop_global = *nexthop6;
+      extra->mp_nexthop_len = 16;
+    }
+#endif
+
   attr.med = metric;
   attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
 
index 3e5285965588aece04c1f33fa7b2bab31759c6ae..7adc573b8861084341e903a0e8750a0c6d46044d 100644 (file)
@@ -192,7 +192,9 @@ extern int bgp_nlri_parse (struct peer *, struct attr *, struct bgp_nlri *);
 
 extern int bgp_maximum_prefix_overflow (struct peer *, afi_t, safi_t, int);
 
-extern void bgp_redistribute_add (struct prefix *, struct in_addr *, u_int32_t, u_char);
+extern void bgp_redistribute_add (struct prefix *, const struct in_addr *,
+                                 const struct in6_addr *,
+                                 u_int32_t, u_char);
 extern void bgp_redistribute_delete (struct prefix *, u_char);
 extern void bgp_redistribute_withdraw (struct bgp *, afi_t, int);
 
index f3baeee0e6dd19fbe6600083c11f06477db70940..d7af349aacc804c3b01367ee3d29e247c67f6451 100644 (file)
@@ -281,7 +281,8 @@ zebra_read_ipv4 (int command, struct zclient *zclient, zebra_size_t length)
                     inet_ntop(AF_INET, &nexthop, buf[1], sizeof(buf[1])),
                     api.metric);
        }
-      bgp_redistribute_add((struct prefix *)&p, &nexthop, api.metric, api.type);
+      bgp_redistribute_add((struct prefix *)&p, &nexthop, NULL,
+                          api.metric, api.type);
     }
   else
     {
@@ -356,23 +357,29 @@ zebra_read_ipv6 (int command, struct zclient *zclient, zebra_size_t length)
     {
       if (BGP_DEBUG(zebra, ZEBRA))
        {
-         char buf[INET6_ADDRSTRLEN];
-         zlog_debug("Zebra rcvd: IPv6 route add %s %s/%d metric %u",
+         char buf[2][INET6_ADDRSTRLEN];
+         zlog_debug("Zebra rcvd: IPv6 route add %s %s/%d nexthop %s metric %u",
                     zebra_route_string(api.type),
-                    inet_ntop(AF_INET6, &p.prefix, buf, sizeof(buf)),
-                    p.prefixlen, api.metric);
+                    inet_ntop(AF_INET6, &p.prefix, buf[0], sizeof(buf[0])),
+                    p.prefixlen,
+                    inet_ntop(AF_INET, &nexthop, buf[1], sizeof(buf[1])),
+                    api.metric);
        }
-      bgp_redistribute_add ((struct prefix *)&p, NULL, api.metric, api.type);
+      bgp_redistribute_add ((struct prefix *)&p, NULL, &nexthop,
+                           api.metric, api.type);
     }
   else
     {
       if (BGP_DEBUG(zebra, ZEBRA))
        {
-         char buf[INET6_ADDRSTRLEN];
-         zlog_debug("Zebra rcvd: IPv6 route delete %s %s/%d metric %u",
+         char buf[2][INET6_ADDRSTRLEN];
+         zlog_debug("Zebra rcvd: IPv6 route delete %s %s/%d "
+                    "nexthop %s metric %u",
                     zebra_route_string(api.type),
-                    inet_ntop(AF_INET6, &p.prefix, buf, sizeof(buf)),
-                    p.prefixlen, api.metric);
+                    inet_ntop(AF_INET6, &p.prefix, buf[0], sizeof(buf[0])),
+                    p.prefixlen,
+                    inet_ntop(AF_INET6, &nexthop, buf[1], sizeof(buf[1])),
+                    api.metric);
        }
       bgp_redistribute_delete ((struct prefix *) &p, api.type);
     }