X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=bgpd%2Fbgp_nexthop.c;h=70d3d7b69c601934db29458ee7b8f81bc0c988d9;hb=c52e2ecf95a9be318912caacc0851d9307e679f7;hp=2ef792e12901244aac28724307ff96ef1a59729c;hpb=55123eb040781bda93b4055d09d7c303af2e38ac;p=mirror_frr.git diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c index 2ef792e12..70d3d7b69 100644 --- a/bgpd/bgp_nexthop.c +++ b/bgpd/bgp_nexthop.c @@ -44,8 +44,6 @@ #include "bgpd/bgp_damp.h" #include "bgpd/bgp_fsm.h" #include "bgpd/bgp_vty.h" -#include "zebra/rib.h" -#include "zebra/zserv.h" /* For ZEBRA_SERV_PATH. */ DEFINE_MTYPE_STATIC(BGPD, MARTIAN_STRING, "BGP Martian Address Intf String"); @@ -83,7 +81,7 @@ static void bgp_nexthop_cache_reset(struct bgp_table *table) struct bgp_nexthop_cache *bnc; for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) { - bnc = bgp_nexthop_get_node_info(rn); + bnc = bgp_node_get_bgp_nexthop_info(rn); if (!bnc) continue; @@ -94,7 +92,7 @@ static void bgp_nexthop_cache_reset(struct bgp_table *table) } bnc_free(bnc); - bgp_nexthop_set_node_info(rn, NULL); + bgp_node_set_bgp_nexthop_info(rn, NULL); bgp_unlock_node(rn); } } @@ -351,14 +349,14 @@ void bgp_connected_add(struct bgp *bgp, struct connected *ifc) rn = bgp_node_get(bgp->connected_table[AFI_IP], (struct prefix *)&p); - bc = bgp_connected_get_node_info(rn); + bc = bgp_node_get_bgp_connected_ref_info(rn); if (bc) bc->refcnt++; else { bc = XCALLOC(MTYPE_BGP_CONN, sizeof(struct bgp_connected_ref)); bc->refcnt = 1; - bgp_connected_set_node_info(rn, bc); + bgp_node_set_bgp_connected_ref_info(rn, bc); } for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { @@ -384,14 +382,14 @@ void bgp_connected_add(struct bgp *bgp, struct connected *ifc) rn = bgp_node_get(bgp->connected_table[AFI_IP6], (struct prefix *)&p); - bc = bgp_connected_get_node_info(rn); + bc = bgp_node_get_bgp_connected_ref_info(rn); if (bc) bc->refcnt++; else { bc = XCALLOC(MTYPE_BGP_CONN, sizeof(struct bgp_connected_ref)); bc->refcnt = 1; - bgp_connected_set_node_info(rn, bc); + bgp_node_set_bgp_connected_ref_info(rn, bc); } } } @@ -428,11 +426,11 @@ void bgp_connected_delete(struct bgp *bgp, struct connected *ifc) if (!rn) return; - bc = bgp_connected_get_node_info(rn); + bc = bgp_node_get_bgp_connected_ref_info(rn); bc->refcnt--; if (bc->refcnt == 0) { XFREE(MTYPE_BGP_CONN, bc); - bgp_connected_set_node_info(rn, NULL); + bgp_node_set_bgp_connected_ref_info(rn, NULL); } bgp_unlock_node(rn); bgp_unlock_node(rn); @@ -444,14 +442,14 @@ static void bgp_connected_cleanup(struct route_table *table, struct bgp_connected_ref *bc; struct bgp_node *bn = bgp_node_from_rnode(rn); - bc = bgp_connected_get_node_info(bn); + bc = bgp_node_get_bgp_connected_ref_info(bn); if (!bc) return; bc->refcnt--; if (bc->refcnt == 0) { XFREE(MTYPE_BGP_CONN, bc); - bgp_connected_set_node_info(bn, NULL); + bgp_node_set_bgp_connected_ref_info(bn, NULL); } } @@ -588,22 +586,30 @@ static void bgp_show_nexthops_detail(struct vty *vty, struct bgp *bgp, } } -static void bgp_show_nexthops(struct vty *vty, struct bgp *bgp, int detail) +static void bgp_show_nexthops(struct vty *vty, struct bgp *bgp, int detail, + bool import_table) { struct bgp_node *rn; struct bgp_nexthop_cache *bnc; char buf[PREFIX2STR_BUFFER]; time_t tbuf; afi_t afi; + struct bgp_table **table; - vty_out(vty, "Current BGP nexthop cache:\n"); + if (import_table) + vty_out(vty, "Current BGP import check cache:\n"); + else + vty_out(vty, "Current BGP nexthop cache:\n"); + if (import_table) + table = bgp->import_check_table; + else + table = bgp->nexthop_cache_table; for (afi = AFI_IP; afi < AFI_MAX; afi++) { - if (!bgp->nexthop_cache_table[afi]) + if (!table || !table[afi]) continue; - - for (rn = bgp_table_top(bgp->nexthop_cache_table[afi]); rn; + for (rn = bgp_table_top(table[afi]); rn; rn = bgp_route_next(rn)) { - bnc = bgp_nexthop_get_node_info(rn); + bnc = bgp_node_get_bgp_nexthop_info(rn); if (!bnc) continue; @@ -640,7 +646,7 @@ static void bgp_show_nexthops(struct vty *vty, struct bgp *bgp, int detail) } static int show_ip_bgp_nexthop_table(struct vty *vty, const char *name, - int detail) + int detail, bool import_table) { struct bgp *bgp; @@ -653,7 +659,7 @@ static int show_ip_bgp_nexthop_table(struct vty *vty, const char *name, return CMD_WARNING; } - bgp_show_nexthops(vty, bgp, detail); + bgp_show_nexthops(vty, bgp, detail, import_table); return CMD_SUCCESS; } @@ -666,9 +672,9 @@ static void bgp_show_all_instances_nexthops_vty(struct vty *vty) for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { vty_out(vty, "\nInstance %s:\n", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) - ? "Default" + ? VRF_DEFAULT_NAME : bgp->name); - bgp_show_nexthops(vty, bgp, 0); + bgp_show_nexthops(vty, bgp, 0, false); } } @@ -689,7 +695,28 @@ DEFUN (show_ip_bgp_nexthop, || argv_find(argv, argc, "vrf", &idx)) vrf = argv[++idx]->arg; int detail = argv_find(argv, argc, "detail", &idx) ? 1 : 0; - return show_ip_bgp_nexthop_table(vty, vrf, detail); + + return show_ip_bgp_nexthop_table(vty, vrf, detail, false); +} + +DEFUN (show_ip_bgp_import_check, + show_ip_bgp_import_check_cmd, + "show [ip] bgp [ VIEWVRFNAME] import-check-table [detail]", + SHOW_STR + IP_STR + BGP_STR + BGP_INSTANCE_HELP_STR + "BGP import check table\n" + "Show detailed information\n") +{ + int idx = 0; + char *vrf = NULL; + + if (argv_find(argv, argc, "view", &idx) + || argv_find(argv, argc, "vrf", &idx)) + vrf = argv[++idx]->arg; + int detail = argv_find(argv, argc, "detail", &idx) ? 1 : 0; + return show_ip_bgp_nexthop_table(vty, vrf, detail, true); } DEFUN (show_ip_bgp_instance_all_nexthop, @@ -722,6 +749,7 @@ void bgp_scan_init(struct bgp *bgp) void bgp_scan_vty_init(void) { install_element(VIEW_NODE, &show_ip_bgp_nexthop_cmd); + install_element(VIEW_NODE, &show_ip_bgp_import_check_cmd); install_element(VIEW_NODE, &show_ip_bgp_instance_all_nexthop_cmd); }