return pim_show_secondary_helper(vrf, vty);
}
-DEFPY (show_ipv6_pim_cand_rp,
- show_ipv6_pim_cand_rp_cmd,
- "show ipv6 pim candidate-rp [vrf VRF_NAME] [json$uj]",
+DEFPY (show_ipv6_pim_bsr_cand_bsr,
+ show_ipv6_pim_bsr_cand_bsr_cmd,
+ "show ipv6 pim bsr candidate-bsr [vrf NAME$vrfname] [json$json]",
SHOW_STR
IPV6_STR
PIM_STR
- "PIM Candidate RP state\n"
+ BSR_STR
+ "Current PIM router candidate BSR state\n"
VRF_CMD_HELP_STR
JSON_STR)
{
- struct vrf *vrf = pim_cmd_lookup(vty, vrf_name);
- struct pim_instance *pim;
- struct bsm_scope *scope;
- json_object *json = NULL;
+ int idx = 2;
+ struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx, !!json);
if (!vrf || !vrf->info)
return CMD_WARNING;
- pim = (struct pim_instance *)vrf->info;
- scope = &pim->global_scope;
-
- if (!scope->cand_rp_addrsel.run) {
- if (uj)
- vty_out(vty, "{}\n");
- else
- vty_out(vty,
- "This router is not currently operating as Candidate RP\n");
- return CMD_SUCCESS;
- }
-
- if (uj) {
- json = json_object_new_object();
- json_object_string_addf(json, "address", "%pPA",
- &scope->cand_rp_addrsel.run_addr);
- json_object_int_add(json, "priority", scope->cand_rp_prio);
- json_object_int_add(json, "nextAdvertisementMsec",
- event_timer_remain_msec(
- scope->cand_rp_adv_timer));
-
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(json,
- JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- return CMD_SUCCESS;
- }
+ return pim_show_bsr_cand_bsr(vrf, vty, !!json);
+}
- vty_out(vty, "Candidate-RP\nAddress: %pPA\nPriority: %u\n\n",
- &scope->cand_rp_addrsel.run_addr, scope->cand_rp_prio);
- vty_out(vty, "Next adv.: %lu msec\n",
- event_timer_remain_msec(scope->cand_rp_adv_timer));
+DEFPY (show_ipv6_pim_bsr_cand_rp,
+ show_ipv6_pim_bsr_cand_rp_cmd,
+ "show ipv6 pim bsr candidate-rp [vrf VRF_NAME] [json$json]",
+ SHOW_STR
+ IPV6_STR
+ PIM_STR
+ BSR_STR
+ "Current PIM router candidate RP state\n"
+ VRF_CMD_HELP_STR
+ JSON_STR)
+{
+ struct vrf *vrf = pim_cmd_lookup(vty, vrf_name);
+ if (!vrf || !vrf->info)
+ return CMD_WARNING;
- return CMD_SUCCESS;
+ return pim_show_bsr_cand_rp(vrf, vty, !!json);
}
DEFPY (show_ipv6_pim_bsr_rpdb,
show_ipv6_pim_bsr_rpdb_cmd,
- "show ipv6 pim bsr candidate-rps [vrf VRF_NAME] [json$uj]",
+ "show ipv6 pim bsr candidate-rp-database [vrf VRF_NAME] [json$json]",
SHOW_STR
IPV6_STR
PIM_STR
- "boot-strap router information\n"
- "Candidate RPs\n"
+ BSR_STR
+ "Candidate RPs database on this router (if it is the BSR)\n"
VRF_CMD_HELP_STR
JSON_STR)
{
struct pim_instance *pim = vrf->info;
struct bsm_scope *scope = &pim->global_scope;
- return pim_crp_db_show(vty, scope);
+ return pim_crp_db_show(vty, scope, !!json);
}
DEFPY (show_ipv6_pim_bsr_groups,
show_ipv6_pim_bsr_groups_cmd,
- "show ipv6 pim bsr groups [vrf VRF_NAME] [json$uj]",
+ "show ipv6 pim bsr groups [vrf VRF_NAME] [json$json]",
SHOW_STR
IPV6_STR
PIM_STR
struct pim_instance *pim = vrf->info;
struct bsm_scope *scope = &pim->global_scope;
- return pim_crp_groups_show(vty, scope);
+ return pim_crp_groups_show(vty, scope, !!json);
}
install_element(VIEW_NODE, &show_ipv6_pim_rpf_cmd);
install_element(VIEW_NODE, &show_ipv6_pim_rpf_vrf_all_cmd);
install_element(VIEW_NODE, &show_ipv6_pim_secondary_cmd);
- install_element(VIEW_NODE, &show_ipv6_pim_cand_rp_cmd);
+ install_element(VIEW_NODE, &show_ipv6_pim_bsr_cand_bsr_cmd);
+ install_element(VIEW_NODE, &show_ipv6_pim_bsr_cand_rp_cmd);
install_element(VIEW_NODE, &show_ipv6_pim_bsr_rpdb_cmd);
install_element(VIEW_NODE, &show_ipv6_pim_bsr_groups_cmd);
install_element(VIEW_NODE, &show_ipv6_pim_statistics_cmd);
void pim_crp_nht_update(struct pim_instance *pim, struct pim_nexthop_cache *pnc);
void pim_crp_db_clear(struct bsm_scope *scope);
-int pim_crp_db_show(struct vty *vty, struct bsm_scope *scope);
-int pim_crp_groups_show(struct vty *vty, struct bsm_scope *scope);
-
-int pim_crp_process(struct interface *ifp, pim_sgaddr *src_dst, uint8_t *buf,
- uint32_t buf_size);
-
-struct pim_nexthop_cache;
-void pim_crp_nht_update(struct pim_instance *pim, struct pim_nexthop_cache *pnc);
-
-void pim_crp_db_clear(struct bsm_scope *scope);
-int pim_crp_db_show(struct vty *vty, struct bsm_scope *scope);
-int pim_crp_groups_show(struct vty *vty, struct bsm_scope *scope);
-
-int pim_crp_process(struct interface *ifp, pim_sgaddr *src_dst, uint8_t *buf,
- uint32_t buf_size);
-
-struct pim_nexthop_cache;
-void pim_crp_nht_update(struct pim_instance *pim, struct pim_nexthop_cache *pnc);
-
-void pim_crp_db_clear(struct bsm_scope *scope);
-int pim_crp_db_show(struct vty *vty, struct bsm_scope *scope);
-int pim_crp_groups_show(struct vty *vty, struct bsm_scope *scope);
+int pim_crp_db_show(struct vty *vty, struct bsm_scope *scope, bool json);
+int pim_crp_groups_show(struct vty *vty, struct bsm_scope *scope, bool json);
int pim_cand_config_write(struct pim_instance *pim, struct vty *vty);
}
}
-int pim_crp_db_show(struct vty *vty, struct bsm_scope *scope)
+int pim_crp_db_show(struct vty *vty, struct bsm_scope *scope, bool json)
{
struct bsr_crp_rp *rp;
struct bsr_crp_item *item;
return CMD_SUCCESS;
}
-int pim_crp_groups_show(struct vty *vty, struct bsm_scope *scope)
+int pim_crp_groups_show(struct vty *vty, struct bsm_scope *scope, bool json)
{
struct bsr_crp_group *group;
struct bsr_crp_item *item;
.config_write = pim_debug_config_write,
};
-static struct vrf *pim_cmd_lookup_vrf(struct vty *vty, struct cmd_token *argv[],
- const int argc, int *idx, bool uj)
-{
- struct vrf *vrf;
-
- if (argv_find(argv, argc, "NAME", idx))
- vrf = vrf_lookup_by_name(argv[*idx]->arg);
- else
- vrf = vrf_lookup_by_id(VRF_DEFAULT);
-
- if (!vrf) {
- if (uj)
- vty_json_empty(vty, NULL);
- else
- vty_out(vty, "Specified VRF: %s does not exist\n",
- argv[*idx]->arg);
- }
-
- return vrf;
-}
-
static void pim_show_assert_helper(struct vty *vty,
struct pim_interface *pim_ifp,
struct pim_ifchannel *ch, time_t now)
return pim_show_bsm_db_helper(vrf, vty, !!json);
}
-DEFPY (show_ip_pim_bsrp,
+DEFPY_HIDDEN (show_ip_pim_bsrp,
show_ip_pim_bsrp_cmd,
"show ip pim bsrp-info [vrf NAME] [json$json]",
SHOW_STR
return pim_show_group_rp_mappings_info_helper(vrf, vty, !!json);
}
-DEFUN (show_ip_pim_cand_rp,
- show_ip_pim_cand_rp_cmd,
- "show ip pim candidate-rp [vrf NAME] [json]",
+DEFPY (show_ip_pim_bsr_rpinfo,
+ show_ip_pim_bsr_rpinfo_cmd,
+ "show ip pim bsr rp-info [vrf NAME] [json$json]",
SHOW_STR
IP_STR
PIM_STR
- "PIM Candidate RP state\n"
+ BSR_STR
+ "PIM cached group-rp mappings information received from BSR\n"
+ VRF_CMD_HELP_STR
+ JSON_STR)
+{
+ return pim_show_group_rp_mappings_info_helper(vrf, vty, !!json);
+}
+
+DEFPY (show_ip_pim_bsr_cand_bsr,
+ show_ip_pim_bsr_cand_bsr_cmd,
+ "show ip pim bsr candidate-bsr [vrf NAME$vrfname] [json$json]",
+ SHOW_STR
+ IP_STR
+ PIM_STR
+ BSR_STR
+ "Current PIM router candidate BSR state\n"
VRF_CMD_HELP_STR
JSON_STR)
{
- bool uj = use_json(argc, argv);
int idx = 2;
- struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx, uj);
- struct pim_instance *pim;
- struct bsm_scope *scope;
- json_object *json = NULL;
+ struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx, !!json);
if (!vrf || !vrf->info)
return CMD_WARNING;
- pim = (struct pim_instance *)vrf->info;
- scope = &pim->global_scope;
+ return pim_show_bsr_cand_bsr(vrf, vty, !!json);
+}
- if (!scope->cand_rp_addrsel.run) {
- if (uj)
- vty_out(vty, "{}\n");
- else
- vty_out(vty,
- "This router is not currently operating as Candidate RP\n");
- return CMD_SUCCESS;
- }
- if (uj) {
- char buf[INET_ADDRSTRLEN];
+DEFPY (show_ip_pim_bsr_cand_rp,
+ show_ip_pim_bsr_cand_rp_cmd,
+ "show ip pim bsr candidate-rp [vrf NAME$vrfname] [json$json]",
+ SHOW_STR
+ IP_STR
+ PIM_STR
+ BSR_STR
+ "Current PIM router candidate RP state\n"
+ VRF_CMD_HELP_STR
+ JSON_STR)
+{
+ int idx = 2;
+ struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx, !!json);
- json = json_object_new_object();
- inet_ntop(AF_INET, &scope->cand_rp_addrsel.run_addr, buf,
- sizeof(buf));
- json_object_string_add(json, "address", buf);
- json_object_int_add(json, "priority", scope->cand_rp_prio);
- json_object_int_add(json, "nextAdvertisementMsec",
- pim_time_timer_remain_msec(
- scope->cand_rp_adv_timer));
-
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(json,
- JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- return CMD_SUCCESS;
- }
- vty_out(vty, "Candidate-RP\nAddress: %pI4\nPriority: %u\n\n",
- &scope->cand_rp_addrsel.run_addr, scope->cand_rp_prio);
- vty_out(vty, "Next adv.: %lu msec\n",
- pim_time_timer_remain_msec(scope->cand_rp_adv_timer));
+ if (!vrf || !vrf->info)
+ return CMD_WARNING;
- return CMD_SUCCESS;
+ return pim_show_bsr_cand_rp(vrf, vty, !!json);
}
-DEFUN (show_ip_pim_bsr_rpdb,
+DEFPY (show_ip_pim_bsr_rpdb,
show_ip_pim_bsr_rpdb_cmd,
- "show ip pim bsr candidate-rps [vrf NAME] [json]",
+ "show ip pim bsr candidate-rp-database [vrf NAME$vrfname] [json$json]",
SHOW_STR
IP_STR
PIM_STR
- "boot-strap router information\n"
- "Candidate RPs\n"
+ BSR_STR
+ "Candidate RPs database on this router (if it is the BSR)\n"
VRF_CMD_HELP_STR
JSON_STR)
{
int idx = 2;
struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx, false);
- //bool uj = use_json(argc, argv);
if (!vrf || !vrf->info)
return CMD_WARNING;
struct pim_instance *pim = vrf->info;
struct bsm_scope *scope = &pim->global_scope;
- return pim_crp_db_show(vty, scope);
+ return pim_crp_db_show(vty, scope, !!json);
}
-DEFUN (show_ip_pim_bsr_groups,
+DEFPY (show_ip_pim_bsr_groups,
show_ip_pim_bsr_groups_cmd,
- "show ip pim bsr groups [vrf NAME] [json]",
+ "show ip pim bsr groups [vrf NAME$vrfname] [json$json]",
SHOW_STR
IP_STR
PIM_STR
{
int idx = 2;
struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx, false);
- //bool uj = use_json(argc, argv);
if (!vrf || !vrf->info)
return CMD_WARNING;
struct pim_instance *pim = vrf->info;
struct bsm_scope *scope = &pim->global_scope;
- return pim_crp_groups_show(vty, scope);
+ return pim_crp_groups_show(vty, scope, !!json);
}
DEFPY (show_ip_pim_statistics,
NO_STR
BSR_STR
"Make this router a Candidate RP\n"
- "Configure groups to become candidate RP for\n"
+ "Configure groups to become candidate RP for (At least one group must be configured)\n"
"Multicast group prefix\n")
{
return pim_process_bsr_crp_grp_cmd(vty, group_str, no);
install_element(VIEW_NODE, &show_ip_pim_nexthop_lookup_cmd);
install_element(VIEW_NODE, &show_ip_pim_bsrp_cmd);
install_element(VIEW_NODE, &show_ip_pim_bsm_db_cmd);
- install_element(VIEW_NODE, &show_ip_pim_cand_rp_cmd);
+ install_element(VIEW_NODE, &show_ip_pim_bsr_rpinfo_cmd);
+ install_element(VIEW_NODE, &show_ip_pim_bsr_cand_bsr_cmd);
+ install_element(VIEW_NODE, &show_ip_pim_bsr_cand_rp_cmd);
install_element(VIEW_NODE, &show_ip_pim_bsr_rpdb_cmd);
install_element(VIEW_NODE, &show_ip_pim_bsr_groups_cmd);
install_element(VIEW_NODE, &show_ip_pim_statistics_cmd);
return vrf;
}
+struct vrf *pim_cmd_lookup_vrf(struct vty *vty, struct cmd_token *argv[],
+ const int argc, int *idx, bool uj)
+{
+ struct vrf *vrf;
+
+ if (argv_find(argv, argc, "NAME", idx))
+ vrf = vrf_lookup_by_name(argv[*idx]->arg);
+ else
+ vrf = vrf_lookup_by_id(VRF_DEFAULT);
+
+ if (!vrf) {
+ if (uj)
+ vty_json_empty(vty, NULL);
+ else
+ vty_out(vty, "Specified VRF: %s does not exist\n",
+ argv[*idx]->arg);
+ }
+
+ return vrf;
+}
+
void clear_mroute(struct pim_instance *pim)
{
struct pim_upstream *up;
}
else {
- vty_out(vty, "PIMv2 Bootstrap information\n");
+ vty_out(vty, "PIMv2 Bootstrap Router information\n");
vty_out(vty, "Current preferred BSR address: %pPA\n",
&pim->global_scope.current_bsr);
vty_out(vty,
return CMD_SUCCESS;
}
+int pim_show_bsr_cand_rp(const struct vrf *vrf, struct vty *vty, bool uj)
+{
+ struct pim_instance *pim;
+ struct bsm_scope *scope;
+ json_object *jsondata = NULL;
+
+ if (!vrf || !vrf->info)
+ return CMD_WARNING;
+
+ pim = (struct pim_instance *)vrf->info;
+ scope = &pim->global_scope;
+
+ if (!scope->cand_rp_addrsel.run) {
+ if (!!uj)
+ vty_out(vty, "{}\n");
+ else
+ vty_out(vty,
+ "This router is not currently operating as Candidate RP\n");
+ return CMD_SUCCESS;
+ }
+
+ if (!!uj) {
+ jsondata = json_object_new_object();
+ json_object_string_addf(jsondata, "address", "%pPA",
+ &scope->cand_rp_addrsel.run_addr);
+ json_object_int_add(jsondata, "priority", scope->cand_rp_prio);
+ json_object_int_add(jsondata, "nextAdvertisementMsec",
+ event_timer_remain_msec(
+ scope->cand_rp_adv_timer));
+
+ vty_json(vty, jsondata);
+ return CMD_SUCCESS;
+ }
+
+ vty_out(vty, "Candidate-RP\nAddress: %pPA\nPriority: %u\n\n",
+ &scope->cand_rp_addrsel.run_addr, scope->cand_rp_prio);
+ vty_out(vty, "Next adv.: %lu msec\n",
+ event_timer_remain_msec(scope->cand_rp_adv_timer));
+
+
+ return CMD_SUCCESS;
+}
+
+int pim_show_bsr_cand_bsr(const struct vrf *vrf, struct vty *vty, bool uj)
+{
+ struct pim_instance *pim;
+ struct bsm_scope *scope;
+ json_object *jsondata = NULL;
+
+ if (!vrf || !vrf->info)
+ return CMD_WARNING;
+
+ pim = (struct pim_instance *)vrf->info;
+ scope = &pim->global_scope;
+
+ if (!scope->bsr_addrsel.cfg_enable) {
+ if (!!uj)
+ vty_out(vty, "{}\n");
+ else
+ vty_out(vty,
+ "This router is not currently operating as Candidate BSR\n");
+ return CMD_SUCCESS;
+ }
+
+ if (uj) {
+ char buf[INET_ADDRSTRLEN];
+
+ jsondata = json_object_new_object();
+ inet_ntop(AF_INET, &scope->bsr_addrsel.run_addr, buf,
+ sizeof(buf));
+ json_object_string_add(jsondata, "address", buf);
+ json_object_int_add(jsondata, "priority", scope->cand_bsr_prio);
+ json_object_boolean_add(jsondata, "elected",
+ pim->global_scope.state == BSR_ELECTED);
+
+ vty_out(vty, "%s\n",
+ json_object_to_json_string_ext(jsondata,
+ JSON_C_TO_STRING_PRETTY));
+ json_object_free(jsondata);
+ return CMD_SUCCESS;
+ }
+
+ vty_out(vty,
+ "Candidate-BSR\nAddress: %pPA\nPriority: %u\nElected: %s\n",
+ &scope->bsr_addrsel.run_addr, scope->cand_bsr_prio,
+ (pim->global_scope.state == BSR_ELECTED) ? " Yes" : " No");
+
+ if (!pim_addr_cmp(scope->bsr_addrsel.run_addr, PIMADDR_ANY))
+ vty_out(vty,
+ "\nThis router is not currently operating as Candidate BSR\n"
+ "Configure a BSR address to enable this feature\n\n");
+
+ return CMD_SUCCESS;
+}
+
/* Display the bsm database details */
static void pim_show_bsm_db(struct pim_instance *pim, struct vty *vty, bool uj)
{
json_object *json);
int clear_ip_mroute_count_command(struct vty *vty, const char *name);
struct vrf *pim_cmd_lookup(struct vty *vty, const char *name);
+struct vrf *pim_cmd_lookup_vrf(struct vty *vty, struct cmd_token *argv[],
+ const int argc, int *idx, bool uj);
void clear_mroute(struct pim_instance *pim);
void clear_pim_statistics(struct pim_instance *pim);
int clear_pim_interface_traffic(const char *vrf, struct vty *vty);
void clear_pim_interfaces(struct pim_instance *pim);
void pim_show_bsr(struct pim_instance *pim, struct vty *vty, bool uj);
int pim_show_bsr_helper(const char *vrf, struct vty *vty, bool uj);
+int pim_show_bsr_cand_bsr(const struct vrf *vrf, struct vty *vty, bool uj);
+int pim_show_bsr_cand_rp(const struct vrf *vrf, struct vty *vty, bool uj);
int pim_router_config_write(struct vty *vty);
/*
if (!is_mcast) {
if (header->type == PIM_MSG_TYPE_CANDIDATE) {
if (PIM_DEBUG_PIM_PACKETS)
- zlog_debug( "%s %s: Candidate RP PIM message from %pPA on %s",
- __FILE__, __func__, &sg.src, ifp->name);
+ zlog_debug("%s %s: Candidate RP PIM message from %pPA on %s",
+ __FILE__, __func__, &sg.src,
+ ifp->name);
return pim_crp_process(ifp, &sg, pim_msg, pim_msg_len);
}