]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib, bgpd: Log next hops
authorvivek <vivek@cumulusnetworks.com>
Thu, 8 Sep 2016 16:38:53 +0000 (09:38 -0700)
committervivek <vivek@cumulusnetworks.com>
Thu, 8 Sep 2016 16:53:26 +0000 (09:53 -0700)
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
Ticket: CM-12390
Reviewed By: CCR-5156
Testing Done: Manual

bgpd/bgp_nht.c
lib/nexthop.c
lib/nexthop.h

index 23c64731aa058661e21ca0027096933c4b254fd6..caf6fc2b41b79b3b7cfb8da40d2106bcc952fd50 100644 (file)
@@ -370,8 +370,8 @@ bgp_parse_nexthop_update (int command, vrf_id_t vrf_id)
     {
       char buf[PREFIX2STR_BUFFER];
       prefix2str(&p, buf, sizeof (buf));
-      zlog_debug("parse nexthop update(%s): metric=%d, #nexthop=%d", buf,
-                metric, nexthop_num);
+      zlog_debug("%d: NH update for %s - metric %d (cur %d) #nhops %d (cur %d)",
+                 vrf_id, buf, metric, bnc->metric, nexthop_num, bnc->nexthop_num);
     }
 
   if (metric != bnc->metric)
@@ -420,6 +420,13 @@ bgp_parse_nexthop_update (int command, vrf_id_t vrf_id)
               break;
            }
 
+          if (BGP_DEBUG(nht, NHT))
+            {
+              char buf[NEXTHOP_STRLEN];
+              zlog_debug("    nhop via %s",
+                         nexthop2str (nexthop, buf, sizeof (buf)));
+            }
+
          if (nhlist_tail)
            {
              nhlist_tail->next = nexthop;
@@ -642,6 +649,14 @@ evaluate_paths (struct bgp_nexthop_cache *bnc)
   int afi;
   struct peer *peer = (struct peer *)bnc->nht_info;
 
+  if (BGP_DEBUG(nht, NHT))
+    {
+      char buf[PREFIX2STR_BUFFER];
+      bnc_str(bnc, buf, PREFIX2STR_BUFFER);
+      zlog_debug("NH update for %s - flags 0x%x chgflags 0x%x - evaluate paths",
+                 buf, bnc->flags, bnc->change_flags);
+    }
+
   LIST_FOREACH(path, &(bnc->paths), nh_thread)
     {
       if (!(path->type == ZEBRA_ROUTE_BGP &&
index 5853884218fe1d180f658611af1e130352ffa238..14486ea157f95c8f1a9ae53d1d8cbd708143be8b 100644 (file)
@@ -153,3 +153,36 @@ nexthops_free (struct nexthop *nexthop)
       nexthop_free (nh);
     }
 }
+
+const char *
+nexthop2str (struct nexthop *nexthop, char *str, int size)
+{
+  switch (nexthop->type)
+    {
+      case NEXTHOP_TYPE_IFINDEX:
+        snprintf (str, size, "if %u", nexthop->ifindex);
+        break;
+      case NEXTHOP_TYPE_IPV4:
+        snprintf (str, size, "%s", inet_ntoa (nexthop->gate.ipv4));
+        break;
+      case NEXTHOP_TYPE_IPV4_IFINDEX:
+        snprintf (str, size, "%s if %u",
+                  inet_ntoa (nexthop->gate.ipv4), nexthop->ifindex);
+        break;
+      case NEXTHOP_TYPE_IPV6:
+        snprintf (str, size, "%s", inet6_ntoa (nexthop->gate.ipv6));
+        break;
+      case NEXTHOP_TYPE_IPV6_IFINDEX:
+        snprintf (str, size, "%s if %u",
+                  inet6_ntoa (nexthop->gate.ipv6), nexthop->ifindex);
+        break;
+      case NEXTHOP_TYPE_BLACKHOLE:
+        snprintf (str, size, "blackhole");
+        break;
+      default:
+        snprintf (str, size, "unknown");
+        break;
+    }
+
+  return str;
+}
index eb9b27ea9e3250957e247471c36b219d68d7fbab..725eb537af7098f4394dccf6fe4e975f8db89436 100644 (file)
@@ -26,6 +26,9 @@
 
 #include "prefix.h"
 
+/* Maximum next hop string length - gateway + ifindex */
+#define NEXTHOP_STRLEN (INET6_ADDRSTRLEN + 30)
+
 union g_addr {
   struct in_addr ipv4;
   struct in6_addr ipv6;
@@ -97,4 +100,5 @@ void nexthops_free (struct nexthop *nexthop);
 extern const char *nexthop_type_to_str (enum nexthop_types_t nh_type);
 extern int nexthop_same_no_recurse (struct nexthop *next1, struct nexthop *next2);
 
+extern const char * nexthop2str (struct nexthop *nexthop, char *str, int size);
 #endif /*_LIB_NEXTHOP_H */