bgpd: show command for martian nexthop db

Ticket:CM-17271/CM-16911
Reviewed By: ccr-6542
Testing Done: Manual

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
This commit is contained in:
Mitesh Kanjariya 2017-08-02 13:54:17 -07:00
parent db0e1937ca
commit acf716660f

View 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);