#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");
char *bnc_str(struct bgp_nexthop_cache *bnc, char *buf, int size)
{
struct bgp_nexthop_cache *bnc;
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
- bnc = bgp_nexthop_get_node_info(rn);
- if (bnc != NULL) {
- bnc_free(bnc);
- bgp_nexthop_set_node_info(rn, NULL);
- bgp_unlock_node(rn);
+ bnc = bgp_node_get_bgp_nexthop_info(rn);
+ if (!bnc)
+ continue;
+
+ while (!LIST_EMPTY(&(bnc->paths))) {
+ struct bgp_path_info *path = LIST_FIRST(&(bnc->paths));
+
+ path_nh_map(path, bnc, false);
}
+
+ bnc_free(bnc);
+ bgp_node_set_bgp_nexthop_info(rn, NULL);
+ bgp_unlock_node(rn);
}
}
return jhash_1word(addr->addr.s_addr, 0);
}
-static int bgp_tip_hash_cmp(const void *p1, const void *p2)
+static bool bgp_tip_hash_cmp(const void *p1, const void *p2)
{
const struct tip_addr *addr1 = p1;
const struct tip_addr *addr2 = p2;
{
char *data = val;
- XFREE(MTYPE_TMP, data);
+ XFREE(MTYPE_MARTIAN_STRING, data);
}
static void *bgp_address_hash_alloc(void *p)
{
struct bgp_addr *addr = data;
- list_delete_and_null(&addr->ifp_name_list);
+ list_delete(&addr->ifp_name_list);
XFREE(MTYPE_BGP_ADDR, addr);
}
return jhash_1word(addr->addr.s_addr, 0);
}
-static int bgp_address_hash_cmp(const void *p1, const void *p2)
+static bool bgp_address_hash_cmp(const void *p1, const void *p2)
{
const struct bgp_addr *addr1 = p1;
const struct bgp_addr *addr2 = p2;
break;
}
if (!node) {
- name = XSTRDUP(MTYPE_TMP, ifc->ifp->name);
+ name = XSTRDUP(MTYPE_MARTIAN_STRING, ifc->ifp->name);
listnode_add(addr->ifp_name_list, name);
}
}
break;
}
- if (node)
+ if (node) {
list_delete_node(addr->ifp_name_list, node);
+ XFREE(MTYPE_MARTIAN_STRING, name);
+ }
if (addr->ifp_name_list->count == 0) {
hash_release(bgp->address_hash, addr);
- list_delete_and_null(&addr->ifp_name_list);
+ list_delete(&addr->ifp_name_list);
XFREE(MTYPE_BGP_ADDR, addr);
}
}
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)) {
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);
}
}
}
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);
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);
}
}
}
}
-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;
if (CHECK_FLAG(bnc->flags,
BGP_NEXTHOP_CONNECTED))
vty_out(vty, " Must be Connected\n");
- }
+ if (!CHECK_FLAG(bnc->flags,
+ BGP_NEXTHOP_REGISTERED))
+ vty_out(vty, " Is not Registered\n");
+ }
tbuf = time(NULL) - (bgp_clock() - bnc->last_update);
vty_out(vty, " Last update: %s", ctime(&tbuf));
vty_out(vty, "\n");
}
static int show_ip_bgp_nexthop_table(struct vty *vty, const char *name,
- int detail)
+ int detail, bool import_table)
{
struct bgp *bgp;
return CMD_WARNING;
}
- bgp_show_nexthops(vty, bgp, detail);
+ bgp_show_nexthops(vty, bgp, detail, import_table);
return CMD_SUCCESS;
}
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);
}
}
|| 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 [<view|vrf> 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,
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);
}