diff options
Diffstat (limited to 'pimd/pim_cmd.c')
| -rw-r--r-- | pimd/pim_cmd.c | 235 |
1 files changed, 169 insertions, 66 deletions
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index af25d930d1..f6af98598b 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -70,10 +70,19 @@ #endif static struct cmd_node interface_node = { - INTERFACE_NODE, "%s(config-if)# ", 1 /* vtysh ? yes */ + .name = "interface", + .node = INTERFACE_NODE, + .parent_node = CONFIG_NODE, + .prompt = "%s(config-if)# ", + .config_write = pim_interface_config_write, }; -static struct cmd_node debug_node = {DEBUG_NODE, "", 1}; +static struct cmd_node debug_node = { + .name = "debug", + .node = DEBUG_NODE, + .prompt = "", + .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) @@ -1520,6 +1529,10 @@ static void pim_show_interface_traffic(struct pim_instance *pim, pim_ifp->pim_ifstat_join_recv); json_object_int_add(json_row, "joinTx", pim_ifp->pim_ifstat_join_send); + json_object_int_add(json_row, "pruneTx", + pim_ifp->pim_ifstat_prune_send); + json_object_int_add(json_row, "pruneRx", + pim_ifp->pim_ifstat_prune_recv); json_object_int_add(json_row, "registerRx", pim_ifp->pim_ifstat_reg_recv); json_object_int_add(json_row, "registerTx", @@ -3019,7 +3032,7 @@ static void pim_show_bsm_db(struct pim_instance *pim, struct vty *vty, bool uj) } for (ALL_LIST_ELEMENTS_RO(pim->global_scope.bsm_list, bsmnode, bsm)) { - char grp_str[INET_ADDRSTRLEN]; + char grp_str[PREFIX_STRLEN]; char rp_str[INET_ADDRSTRLEN]; char bsr_str[INET_ADDRSTRLEN]; struct bsmmsg_grpinfo *group; @@ -3188,7 +3201,7 @@ static void pim_show_group_rp_mappings_info(struct pim_instance *pim, if (!bsgrp) continue; - char grp_str[INET_ADDRSTRLEN]; + char grp_str[PREFIX_STRLEN]; prefix2str(&bsgrp->group, grp_str, sizeof(grp_str)); @@ -3315,12 +3328,9 @@ static void pim_show_statistics(struct pim_instance *pim, struct vty *vty, if (uj) { json = json_object_new_object(); - json_object_int_add(json, "Number of Received BSMs", - pim->bsm_rcvd); - json_object_int_add(json, "Number of Forwared BSMs", - pim->bsm_sent); - json_object_int_add(json, "Number of Dropped BSMs", - pim->bsm_dropped); + json_object_int_add(json, "bsmRx", pim->bsm_rcvd); + json_object_int_add(json, "bsmTx", pim->bsm_sent); + json_object_int_add(json, "bsmDropped", pim->bsm_dropped); } else { vty_out(vty, "BSM Statistics :\n"); vty_out(vty, "----------------\n"); @@ -3362,15 +3372,13 @@ static void pim_show_statistics(struct pim_instance *pim, struct vty *vty, json_row = json_object_new_object(); json_object_string_add(json_row, "If Name", ifp->name); + json_object_int_add(json_row, "bsmDroppedConfig", + pim_ifp->pim_ifstat_bsm_cfg_miss); json_object_int_add( - json_row, - "Number of BSMs dropped due to config miss", - pim_ifp->pim_ifstat_bsm_cfg_miss); - json_object_int_add( - json_row, "Number of unicast BSMs dropped", + json_row, "bsmDroppedUnicast", pim_ifp->pim_ifstat_ucast_bsm_cfg_miss); json_object_int_add(json_row, - "Number of BSMs dropped due to invalid scope zone", + "bsmDroppedInvalidScopeZone", pim_ifp->pim_ifstat_bsm_invalid_sz); json_object_object_add(json, ifp->name, json_row); } @@ -3411,15 +3419,24 @@ static void igmp_show_groups(struct pim_instance *pim, struct vty *vty, bool uj) time_t now; json_object *json = NULL; json_object *json_iface = NULL; - json_object *json_row = NULL; + json_object *json_group = NULL; + json_object *json_groups = NULL; now = pim_time_monotonic_sec(); - if (uj) + if (uj) { json = json_object_new_object(); - else + json_object_int_add(json, "totalGroups", pim->igmp_group_count); + json_object_int_add(json, "watermarkLimit", + pim->igmp_watermark_limit); + } else { + vty_out(vty, "Total IGMP groups: %u\n", pim->igmp_group_count); + vty_out(vty, "Watermark warn limit(%s): %u\n", + pim->igmp_watermark_limit ? "Set" : "Not Set", + pim->igmp_watermark_limit); vty_out(vty, "Interface Address Group Mode Timer Srcs V Uptime \n"); + } /* scan interfaces */ FOR_ALL_INTERFACES (pim->vrf, ifp) { @@ -3466,37 +3483,44 @@ static void igmp_show_groups(struct pim_instance *pim, struct vty *vty, bool uj) json_object_object_add( json, ifp->name, json_iface); + json_groups = + json_object_new_array(); + json_object_object_add( + json_iface, + "groups", + json_groups); } - json_row = json_object_new_object(); - json_object_string_add( - json_row, "source", ifaddr_str); - json_object_string_add( - json_row, "group", group_str); + json_group = json_object_new_object(); + json_object_string_add(json_group, + "source", + ifaddr_str); + json_object_string_add(json_group, + "group", + group_str); if (grp->igmp_version == 3) json_object_string_add( - json_row, "mode", + json_group, "mode", grp->group_filtermode_isexcl ? "EXCLUDE" : "INCLUDE"); - json_object_string_add(json_row, + json_object_string_add(json_group, "timer", hhmmss); json_object_int_add( - json_row, "sourcesCount", + json_group, "sourcesCount", grp->group_source_list ? listcount( grp->group_source_list) : 0); - json_object_int_add(json_row, "version", - grp->igmp_version); + json_object_int_add( + json_group, "version", + grp->igmp_version); json_object_string_add( - json_row, "uptime", uptime); - json_object_object_add(json_iface, - group_str, - json_row); - + json_group, "uptime", uptime); + json_object_array_add(json_groups, + json_group); } else { vty_out(vty, "%-16s %-15s %-15s %4s %8s %4d %d %8s\n", @@ -3772,11 +3796,11 @@ static void pim_show_bsr(struct pim_instance *pim, json_object_string_add(json, "bsr", bsr_str); json_object_int_add(json, "priority", pim->global_scope.current_bsr_prio); - json_object_int_add(json, "fragment_tag", + json_object_int_add(json, "fragmentTag", pim->global_scope.bsm_frag_tag); json_object_string_add(json, "state", bsr_state); json_object_string_add(json, "upTime", uptime); - json_object_string_add(json, "last_bsm_seen", last_bsm_seen); + json_object_string_add(json, "lastBsmSeen", last_bsm_seen); } else { @@ -5803,7 +5827,7 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty, vty_out(vty, " R - RP-bit set, F - Register flag, T - SPT-bit set\n"); vty_out(vty, - "\nSource Group Flags Proto Input Output TTL Uptime\n"); + "\nSource Group Flags Proto Input Output TTL Uptime\n"); } now = pim_time_monotonic_sec(); @@ -6857,6 +6881,35 @@ DEFUN (no_ip_pim_packets, return CMD_SUCCESS; } +DEFPY (igmp_group_watermark, + igmp_group_watermark_cmd, + "ip igmp watermark-warn (10-60000)$limit", + IP_STR + IGMP_STR + "Configure group limit for watermark warning\n" + "Group count to generate watermark warning\n") +{ + PIM_DECLVAR_CONTEXT(vrf, pim); + pim->igmp_watermark_limit = limit; + + return CMD_SUCCESS; +} + +DEFPY (no_igmp_group_watermark, + no_igmp_group_watermark_cmd, + "no ip igmp watermark-warn [(10-60000)$limit]", + NO_STR + IP_STR + IGMP_STR + "Unconfigure group limit for watermark warning\n" + "Group count to generate watermark warning\n") +{ + PIM_DECLVAR_CONTEXT(vrf, pim); + pim->igmp_watermark_limit = 0; + + return CMD_SUCCESS; +} + DEFUN (ip_pim_v6_secondary, ip_pim_v6_secondary_cmd, "ip pim send-v6-secondary", @@ -7285,11 +7338,20 @@ DEFUN (no_ip_pim_ecmp_rebalance, static int pim_cmd_igmp_start(struct vty *vty, struct interface *ifp) { struct pim_interface *pim_ifp; + struct pim_instance *pim; uint8_t need_startup = 0; pim_ifp = ifp->info; if (!pim_ifp) { + pim = pim_get_pim_instance(ifp->vrf_id); + /* Limit mcast interfaces to number of vifs available */ + if (pim->mcast_if_count == MAXVIFS) { + vty_out(vty, + "Max multicast interfaces(%d) Reached. Could not enable IGMP on interface %s\n", + MAXVIFS, ifp->name); + return CMD_WARNING_CONFIG_FAILED; + } (void)pim_if_new(ifp, true, false, false, false); need_startup = 1; } else { @@ -8039,13 +8101,21 @@ DEFPY_HIDDEN (interface_ip_igmp_query_generate, return CMD_SUCCESS; } -static int pim_cmd_interface_add(struct interface *ifp) +static int pim_cmd_interface_add(struct vty *vty, struct interface *ifp) { struct pim_interface *pim_ifp = ifp->info; + struct pim_instance *pim; - if (!pim_ifp) + if (!pim_ifp) { + pim = pim_get_pim_instance(ifp->vrf_id); + /* Limiting mcast interfaces to number of VIFs */ + if (pim->mcast_if_count == MAXVIFS) { + vty_out(vty, "Max multicast interfaces(%d) reached.", + MAXVIFS); + return 0; + } pim_ifp = pim_if_new(ifp, false, true, false, false); - else + } else PIM_IF_DO_PIM(pim_ifp->options); pim_if_addr_add_all(ifp); @@ -8116,15 +8186,17 @@ DEFPY (interface_ip_pim_activeactive, VTY_DECLVAR_CONTEXT(interface, ifp); struct pim_interface *pim_ifp; - if (!no && !pim_cmd_interface_add(ifp)) { - vty_out(vty, "Could not enable PIM SM active-active on interface\n"); + if (!no && !pim_cmd_interface_add(vty, ifp)) { + vty_out(vty, + "Could not enable PIM SM active-active on interface %s\n", + ifp->name); return CMD_WARNING_CONFIG_FAILED; } - if (PIM_DEBUG_MLAG) - zlog_debug("%sConfiguring PIM active-active on Interface: %s", - no ? "Un-":" ", ifp->name); + if (PIM_DEBUG_MLAG) + zlog_debug("%sConfiguring PIM active-active on Interface: %s", + no ? "Un-" : " ", ifp->name); pim_ifp = ifp->info; if (no) @@ -8144,8 +8216,9 @@ DEFUN_HIDDEN (interface_ip_pim_ssm, { VTY_DECLVAR_CONTEXT(interface, ifp); - if (!pim_cmd_interface_add(ifp)) { - vty_out(vty, "Could not enable PIM SM on interface\n"); + if (!pim_cmd_interface_add(vty, ifp)) { + vty_out(vty, "Could not enable PIM SM on interface %s\n", + ifp->name); return CMD_WARNING_CONFIG_FAILED; } @@ -8161,8 +8234,9 @@ static int interface_ip_pim_helper(struct vty *vty) VTY_DECLVAR_CONTEXT(interface, ifp); - if (!pim_cmd_interface_add(ifp)) { - vty_out(vty, "Could not enable PIM SM on interface\n"); + if (!pim_cmd_interface_add(vty, ifp)) { + vty_out(vty, "Could not enable PIM SM on interface %s\n", + ifp->name); return CMD_WARNING_CONFIG_FAILED; } @@ -8450,8 +8524,10 @@ DEFUN (interface_ip_pim_hello, struct pim_interface *pim_ifp = ifp->info; if (!pim_ifp) { - if (!pim_cmd_interface_add(ifp)) { - vty_out(vty, "Could not enable PIM SM on interface\n"); + if (!pim_cmd_interface_add(vty, ifp)) { + vty_out(vty, + "Could not enable PIM SM on interface %s\n", + ifp->name); return CMD_WARNING_CONFIG_FAILED; } } @@ -9193,8 +9269,10 @@ DEFUN (ip_pim_bfd, struct bfd_info *bfd_info = NULL; if (!pim_ifp) { - if (!pim_cmd_interface_add(ifp)) { - vty_out(vty, "Could not enable PIM SM on interface\n"); + if (!pim_cmd_interface_add(vty, ifp)) { + vty_out(vty, + "Could not enable PIM SM on interface %s\n", + ifp->name); return CMD_WARNING; } } @@ -9244,8 +9322,10 @@ DEFUN (ip_pim_bsm, struct pim_interface *pim_ifp = ifp->info; if (!pim_ifp) { - if (!pim_cmd_interface_add(ifp)) { - vty_out(vty, "Could not enable PIM SM on interface\n"); + if (!pim_cmd_interface_add(vty, ifp)) { + vty_out(vty, + "Could not enable PIM SM on interface %s\n", + ifp->name); return CMD_WARNING; } } @@ -9288,8 +9368,10 @@ DEFUN (ip_pim_ucast_bsm, struct pim_interface *pim_ifp = ifp->info; if (!pim_ifp) { - if (!pim_cmd_interface_add(ifp)) { - vty_out(vty, "Could not enable PIM SM on interface\n"); + if (!pim_cmd_interface_add(vty, ifp)) { + vty_out(vty, + "Could not enable PIM SM on interface %s\n", + ifp->name); return CMD_WARNING; } } @@ -9356,8 +9438,10 @@ DEFUN( struct pim_interface *pim_ifp = ifp->info; if (!pim_ifp) { - if (!pim_cmd_interface_add(ifp)) { - vty_out(vty, "Could not enable PIM SM on interface\n"); + if (!pim_cmd_interface_add(vty, ifp)) { + vty_out(vty, + "Could not enable PIM SM on interface %s\n", + ifp->name); return CMD_WARNING; } } @@ -9682,11 +9766,25 @@ DEFUN (no_ip_msdp_mesh_group_source, "mesh group local address\n") { PIM_DECLVAR_CONTEXT(vrf, pim); - if (argc == 7) - return ip_no_msdp_mesh_group_cmd_worker(pim, vty, argv[6]->arg); + + return ip_no_msdp_mesh_group_source_cmd_worker(pim, vty, argv[4]->arg); +} + +DEFUN (no_ip_msdp_mesh_group, + no_ip_msdp_mesh_group_cmd, + "no ip msdp mesh-group [WORD]", + NO_STR + IP_STR + CFG_MSDP_STR + "Delete MSDP mesh-group\n" + "mesh group name") +{ + PIM_DECLVAR_CONTEXT(vrf, pim); + + if (argc == 5) + return ip_no_msdp_mesh_group_cmd_worker(pim, vty, argv[4]->arg); else - return ip_no_msdp_mesh_group_source_cmd_worker(pim, vty, - argv[4]->arg); + return ip_no_msdp_mesh_group_cmd_worker(pim, vty, NULL); } static void print_empty_json_obj(struct vty *vty) @@ -10783,11 +10881,10 @@ DEFUN_HIDDEN (ip_pim_mlag, void pim_cmd_init(void) { - install_node(&interface_node, - pim_interface_config_write); /* INTERFACE_NODE */ + install_node(&interface_node); /* INTERFACE_NODE */ if_cmd_init(); - install_node(&debug_node, pim_debug_config_write); + install_node(&debug_node); install_element(ENABLE_NODE, &pim_test_sg_keepalive_cmd); @@ -10858,6 +10955,10 @@ void pim_cmd_init(void) install_element(VRF_NODE, &no_ip_pim_ecmp_rebalance_cmd); install_element(CONFIG_NODE, &ip_pim_mlag_cmd); install_element(CONFIG_NODE, &no_ip_pim_mlag_cmd); + install_element(CONFIG_NODE, &igmp_group_watermark_cmd); + install_element(VRF_NODE, &igmp_group_watermark_cmd); + install_element(CONFIG_NODE, &no_igmp_group_watermark_cmd); + install_element(VRF_NODE, &no_igmp_group_watermark_cmd); install_element(INTERFACE_NODE, &interface_ip_igmp_cmd); install_element(INTERFACE_NODE, &interface_no_ip_igmp_cmd); @@ -11074,6 +11175,8 @@ void pim_cmd_init(void) install_element(VRF_NODE, &ip_msdp_mesh_group_source_cmd); install_element(CONFIG_NODE, &no_ip_msdp_mesh_group_source_cmd); install_element(VRF_NODE, &no_ip_msdp_mesh_group_source_cmd); + install_element(CONFIG_NODE, &no_ip_msdp_mesh_group_cmd); + install_element(VRF_NODE, &no_ip_msdp_mesh_group_cmd); install_element(VIEW_NODE, &show_ip_msdp_peer_detail_cmd); install_element(VIEW_NODE, &show_ip_msdp_peer_detail_vrf_all_cmd); install_element(VIEW_NODE, &show_ip_msdp_sa_detail_cmd); |
