]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: show command for martian nexthop db
authorMitesh Kanjariya <mitesh@marvel-07.cumulusnetworks.com>
Wed, 2 Aug 2017 20:54:17 +0000 (13:54 -0700)
committerMitesh Kanjariya <mitesh@marvel-07.cumulusnetworks.com>
Thu, 17 Aug 2017 06:22:49 +0000 (23:22 -0700)
Ticket:CM-17271/CM-16911
Reviewed By: ccr-6542
Testing Done: Manual

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
bgpd/bgp_vty.c

index 01c27920f5bab3fe863825213d629f49e913b7ba..de30311e0100d53080015a5b278c650bc083f241 100644 (file)
@@ -6424,6 +6424,59 @@ DEFUN (show_bgp_vrfs,
        return CMD_SUCCESS;
 }
 
+static void show_address_entry(struct hash_backet *backet, void *args)
+{
+       struct vty      *vty = (struct vty *) args;
+       struct bgp_addr *addr = (struct bgp_addr *) backet->data;
+
+       vty_out(vty, "addr: %s, count: %d\n",
+               inet_ntoa(addr->addr),
+               addr->refcnt);
+}
+
+static void show_tip_entry(struct hash_backet *backet, void *args)
+{
+       struct vty      *vty = (struct vty *)args;
+       struct tip_addr *tip = (struct tip_addr *) backet->data;
+
+       vty_out(vty, "addr: %s, count: %d\n",
+               inet_ntoa(tip->addr),
+               tip->refcnt);
+}
+
+static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp)
+{
+       vty_out(vty, "self nexthop database:\n");
+       hash_iterate(bgp->address_hash,
+                    (void (*)(struct hash_backet *, void *))show_address_entry,
+                    vty);
+
+       vty_out(vty, "Tunnel-ip database:\n");
+       hash_iterate(bgp->tip_hash,
+                    (void (*)(struct hash_backet *, void *))show_tip_entry,
+                    vty);
+}
+
+DEFUN (show_bgp_martian_nexthop_db,
+       show_bgp_martian_nexthop_db_cmd,
+       "show bgp martian next-hop",
+       SHOW_STR
+       BGP_STR
+       "martian next-hops\n"
+       "martian next-hop database\n")
+{
+       struct bgp              *bgp = NULL;
+
+       bgp = bgp_get_default();
+       if (!bgp) {
+               vty_out(vty, "%% No BGP process is configured\n");
+               return CMD_WARNING;
+       }
+       bgp_show_martian_nexthops(vty, bgp);
+
+       return CMD_SUCCESS;
+}
+
 DEFUN (show_bgp_memory,
        show_bgp_memory_cmd,
        "show [ip] bgp memory",
@@ -12285,6 +12338,9 @@ void bgp_vty_init(void)
        /* "show [ip] bgp memory" commands. */
        install_element(VIEW_NODE, &show_bgp_memory_cmd);
 
+       /* "show bgp martian next-hop" */
+       install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd);
+
        /* "show [ip] bgp views" commands. */
        install_element(VIEW_NODE, &show_bgp_views_cmd);