]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Add ability to dump the bgp peerhash
authorDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 8 Oct 2018 00:47:42 +0000 (20:47 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 8 Oct 2018 00:55:52 +0000 (20:55 -0400)
The bgp->peerhash is a secretive bit of data that we use
to quickly lookup data about peers.  Unfortunately
since we had not way to look at it, we had no way
of knowing if it had gotten in or out of sync.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
bgpd/bgp_route.c

index 715393b91db62ffdc6cc2fb265a78e5606aaecd5..49c547c5bffecd663a4315ad517dbf9ec8f7ca27 100644 (file)
@@ -11285,6 +11285,36 @@ DEFUN (clear_ip_bgp_dampening_address_mask,
                                    NULL, 0);
 }
 
+static void show_bgp_peerhash_entry(struct hash_backet *backet, void *arg)
+{
+       struct vty *vty = arg;
+       struct peer *peer = backet->data;
+       char buf[SU_ADDRSTRLEN];
+
+       vty_out(vty, "\tPeer: %s %s\n", peer->host,
+              sockunion2str(&peer->su, buf, sizeof(buf)));
+}
+
+DEFUN (show_bgp_peerhash,
+       show_bgp_peerhash_cmd,
+       "show bgp peerhash",
+       SHOW_STR
+       BGP_STR
+       "Display information about the BGP peerhash\n")
+{
+       struct list *instances = bm->bgp;
+       struct listnode *node;
+       struct bgp *bgp;
+
+       for (ALL_LIST_ELEMENTS_RO(instances, node, bgp)) {
+               vty_out(vty, "BGP: %s\n", bgp->name);
+               hash_iterate(bgp->peerhash, show_bgp_peerhash_entry,
+                            vty);
+       }
+
+       return CMD_SUCCESS;
+}
+
 /* also used for encap safi */
 static void bgp_config_write_network_vpn(struct vty *vty, struct bgp *bgp,
                                         afi_t afi, safi_t safi)
@@ -11679,6 +11709,7 @@ void bgp_route_init(void)
        /* show bgp ipv4 flowspec detailed */
        install_element(VIEW_NODE, &show_ip_bgp_flowspec_routes_detailed_cmd);
 
+       install_element(VIEW_NODE, &show_bgp_peerhash_cmd);
 }
 
 void bgp_route_finish(void)