From acf716660f15f3ae4876ce14acee50ef93870fc2 Mon Sep 17 00:00:00 2001 From: Mitesh Kanjariya Date: Wed, 2 Aug 2017 13:54:17 -0700 Subject: bgpd: show command for martian nexthop db Ticket:CM-17271/CM-16911 Reviewed By: ccr-6542 Testing Done: Manual Signed-off-by: Mitesh Kanjariya --- bgpd/bgp_vty.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'bgpd') diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 01c27920f..de30311e0 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -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); -- cgit v1.2.3