diff options
Diffstat (limited to 'pimd/pim_cmd.c')
| -rw-r--r-- | pimd/pim_cmd.c | 436 |
1 files changed, 104 insertions, 332 deletions
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 55e58f2d9a..2d6ce24381 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -1303,27 +1303,6 @@ static void pim_show_group_rp_mappings_info(struct pim_instance *pim, vty_json(vty, json); } -static void clear_pim_statistics(struct pim_instance *pim) -{ - struct interface *ifp; - - pim->bsm_rcvd = 0; - pim->bsm_sent = 0; - pim->bsm_dropped = 0; - - /* scan interfaces */ - FOR_ALL_INTERFACES (pim->vrf, ifp) { - struct pim_interface *pim_ifp = ifp->info; - - if (!pim_ifp) - continue; - - pim_ifp->pim_ifstat_bsm_cfg_miss = 0; - pim_ifp->pim_ifstat_ucast_bsm_cfg_miss = 0; - pim_ifp->pim_ifstat_bsm_invalid_sz = 0; - } -} - static void igmp_show_groups(struct pim_instance *pim, struct vty *vty, bool uj) { struct interface *ifp; @@ -1842,79 +1821,39 @@ DEFUN (clear_ip_igmp_interfaces, return CMD_SUCCESS; } -DEFUN (clear_ip_pim_statistics, +DEFPY (clear_ip_pim_statistics, clear_ip_pim_statistics_cmd, - "clear ip pim statistics [vrf NAME]", + "clear ip pim statistics [vrf NAME]$name", CLEAR_STR IP_STR CLEAR_IP_PIM_STR VRF_CMD_HELP_STR "Reset PIM statistics\n") { - int idx = 2; - struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); + struct vrf *v = pim_cmd_lookup(vty, name); - if (!vrf) + if (!v) return CMD_WARNING; - clear_pim_statistics(vrf->info); - return CMD_SUCCESS; -} - -static void clear_mroute(struct pim_instance *pim) -{ - struct pim_upstream *up; - struct interface *ifp; - - /* scan interfaces */ - FOR_ALL_INTERFACES (pim->vrf, ifp) { - struct pim_interface *pim_ifp = ifp->info; - struct pim_ifchannel *ch; - - if (!pim_ifp) - continue; - - /* deleting all ifchannels */ - while (!RB_EMPTY(pim_ifchannel_rb, &pim_ifp->ifchannel_rb)) { - ch = RB_ROOT(pim_ifchannel_rb, &pim_ifp->ifchannel_rb); - - pim_ifchannel_delete(ch); - } - -#if PIM_IPV == 4 - /* clean up all igmp groups */ - struct gm_group *grp; - - if (pim_ifp->gm_group_list) { - while (pim_ifp->gm_group_list->count) { - grp = listnode_head(pim_ifp->gm_group_list); - igmp_group_delete(grp); - } - } -#endif - } - - /* clean up all upstreams*/ - while ((up = rb_pim_upstream_first(&pim->upstream_head))) - pim_upstream_del(pim, up, __func__); + clear_pim_statistics(v->info); + return CMD_SUCCESS; } -DEFUN (clear_ip_mroute, +DEFPY (clear_ip_mroute, clear_ip_mroute_cmd, - "clear ip mroute [vrf NAME]", + "clear ip mroute [vrf NAME]$name", CLEAR_STR IP_STR "Reset multicast routes\n" VRF_CMD_HELP_STR) { - int idx = 2; - struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); + struct vrf *v = pim_cmd_lookup(vty, name); - if (!vrf) + if (!v) return CMD_WARNING; - clear_mroute(vrf->info); + clear_mroute(v->info); return CMD_SUCCESS; } @@ -1985,22 +1924,21 @@ DEFUN (clear_ip_pim_interface_traffic, return CMD_SUCCESS; } -DEFUN (clear_ip_pim_oil, +DEFPY (clear_ip_pim_oil, clear_ip_pim_oil_cmd, - "clear ip pim [vrf NAME] oil", + "clear ip pim [vrf NAME]$name oil", CLEAR_STR IP_STR CLEAR_IP_PIM_STR VRF_CMD_HELP_STR "Rescan PIM OIL (output interface list)\n") { - int idx = 2; - struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); + struct vrf *v = pim_cmd_lookup(vty, name); - if (!vrf) + if (!v) return CMD_WARNING; - pim_scan_oil(vrf->info); + pim_scan_oil(v->info); return CMD_SUCCESS; } @@ -3848,47 +3786,16 @@ DEFPY (show_ip_mroute_vrf_all, return CMD_SUCCESS; } -DEFUN (clear_ip_mroute_count, +DEFPY (clear_ip_mroute_count, clear_ip_mroute_count_cmd, - "clear ip mroute [vrf NAME] count", + "clear ip mroute [vrf NAME]$name count", CLEAR_STR IP_STR MROUTE_STR VRF_CMD_HELP_STR "Route and packet count data\n") { - int idx = 2; - struct listnode *node; - struct channel_oil *c_oil; - struct static_route *sr; - struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); - struct pim_instance *pim; - - if (!vrf) - return CMD_WARNING; - - pim = vrf->info; - frr_each(rb_pim_oil, &pim->channel_oil_head, c_oil) { - if (!c_oil->installed) - continue; - - pim_mroute_update_counters(c_oil); - c_oil->cc.origpktcnt = c_oil->cc.pktcnt; - c_oil->cc.origbytecnt = c_oil->cc.bytecnt; - c_oil->cc.origwrong_if = c_oil->cc.wrong_if; - } - - for (ALL_LIST_ELEMENTS_RO(pim->static_routes, node, sr)) { - if (!sr->c_oil.installed) - continue; - - pim_mroute_update_counters(&sr->c_oil); - - sr->c_oil.cc.origpktcnt = sr->c_oil.cc.pktcnt; - sr->c_oil.cc.origbytecnt = sr->c_oil.cc.bytecnt; - sr->c_oil.cc.origwrong_if = sr->c_oil.cc.wrong_if; - } - return CMD_SUCCESS; + return clear_ip_mroute_count_command(vty, name); } DEFPY (show_ip_mroute_count, @@ -5262,13 +5169,24 @@ DEFUN_HIDDEN (interface_ip_pim_sm, return pim_process_ip_pim_cmd(vty); } -DEFUN (interface_ip_pim, +DEFPY (interface_ip_pim, interface_ip_pim_cmd, - "ip pim", + "ip pim [passive$passive]", IP_STR - PIM_STR) + PIM_STR + "Disable exchange of protocol packets\n") { - return pim_process_ip_pim_cmd(vty); + int ret; + + ret = pim_process_ip_pim_cmd(vty); + + if (ret != NB_OK) + return ret; + + if (passive) + return pim_process_ip_pim_passive_cmd(vty, true); + + return CMD_SUCCESS; } DEFUN_HIDDEN (interface_no_ip_pim_ssm, @@ -5293,13 +5211,17 @@ DEFUN_HIDDEN (interface_no_ip_pim_sm, return pim_process_no_ip_pim_cmd(vty); } -DEFUN (interface_no_ip_pim, +DEFPY (interface_no_ip_pim, interface_no_ip_pim_cmd, - "no ip pim", + "no ip pim [passive$passive]", NO_STR IP_STR - PIM_STR) + PIM_STR + "Disable exchange of protocol packets\n") { + if (passive) + return pim_process_ip_pim_passive_cmd(vty, false); + return pim_process_no_ip_pim_cmd(vty); } @@ -5600,88 +5522,47 @@ DEFUN (no_debug_pim_static, } -DEFUN (debug_pim, +DEFPY (debug_pim, debug_pim_cmd, - "debug pim", - DEBUG_STR - DEBUG_PIM_STR) -{ - PIM_DO_DEBUG_PIM_EVENTS; - PIM_DO_DEBUG_PIM_PACKETS; - PIM_DO_DEBUG_PIM_TRACE; - PIM_DO_DEBUG_MSDP_EVENTS; - PIM_DO_DEBUG_MSDP_PACKETS; - PIM_DO_DEBUG_BSM; - PIM_DO_DEBUG_VXLAN; - return CMD_SUCCESS; -} - -DEFUN (no_debug_pim, - no_debug_pim_cmd, - "no debug pim", + "[no] debug pim", NO_STR DEBUG_STR DEBUG_PIM_STR) { - PIM_DONT_DEBUG_PIM_EVENTS; - PIM_DONT_DEBUG_PIM_PACKETS; - PIM_DONT_DEBUG_PIM_TRACE; - PIM_DONT_DEBUG_MSDP_EVENTS; - PIM_DONT_DEBUG_MSDP_PACKETS; - - PIM_DONT_DEBUG_PIM_PACKETDUMP_SEND; - PIM_DONT_DEBUG_PIM_PACKETDUMP_RECV; - PIM_DONT_DEBUG_BSM; - PIM_DONT_DEBUG_VXLAN; - - return CMD_SUCCESS; + if (!no) + return pim_debug_pim_cmd(); + else + return pim_no_debug_pim_cmd(); } -DEFUN (debug_pim_nht, +DEFPY (debug_pim_nht, debug_pim_nht_cmd, - "debug pim nht", - DEBUG_STR - DEBUG_PIM_STR - "Nexthop Tracking\n") -{ - PIM_DO_DEBUG_PIM_NHT; - return CMD_SUCCESS; -} - -DEFUN (no_debug_pim_nht, - no_debug_pim_nht_cmd, - "no debug pim nht", + "[no] debug pim nht", NO_STR DEBUG_STR DEBUG_PIM_STR "Nexthop Tracking\n") { - PIM_DONT_DEBUG_PIM_NHT; + if (!no) + PIM_DO_DEBUG_PIM_NHT; + else + PIM_DONT_DEBUG_PIM_NHT; return CMD_SUCCESS; } -DEFUN (debug_pim_nht_det, +DEFPY (debug_pim_nht_det, debug_pim_nht_det_cmd, - "debug pim nht detail", - DEBUG_STR - DEBUG_PIM_STR - "Nexthop Tracking\n" - "Detailed Information\n") -{ - PIM_DO_DEBUG_PIM_NHT_DETAIL; - return CMD_SUCCESS; -} - -DEFUN (no_debug_pim_nht_det, - no_debug_pim_nht_det_cmd, - "no debug pim nht detail", + "[no] debug pim nht detail", NO_STR DEBUG_STR DEBUG_PIM_STR "Nexthop Tracking\n" "Detailed Information\n") { - PIM_DONT_DEBUG_PIM_NHT_DETAIL; + if (!no) + PIM_DO_DEBUG_PIM_NHT_DETAIL; + else + PIM_DONT_DEBUG_PIM_NHT_DETAIL; return CMD_SUCCESS; } @@ -5710,179 +5591,98 @@ DEFUN (no_debug_pim_nht_rp, return CMD_SUCCESS; } -DEFUN (debug_pim_events, +DEFPY (debug_pim_events, debug_pim_events_cmd, - "debug pim events", - DEBUG_STR - DEBUG_PIM_STR - DEBUG_PIM_EVENTS_STR) -{ - PIM_DO_DEBUG_PIM_EVENTS; - return CMD_SUCCESS; -} - -DEFUN (no_debug_pim_events, - no_debug_pim_events_cmd, - "no debug pim events", + "[no] debug pim events", NO_STR DEBUG_STR DEBUG_PIM_STR DEBUG_PIM_EVENTS_STR) { - PIM_DONT_DEBUG_PIM_EVENTS; + if (!no) + PIM_DO_DEBUG_PIM_EVENTS; + else + PIM_DONT_DEBUG_PIM_EVENTS; return CMD_SUCCESS; } -DEFUN (debug_pim_packets, +DEFPY (debug_pim_packets, debug_pim_packets_cmd, - "debug pim packets [<hello|joins|register>]", - DEBUG_STR + "[no] debug pim packets [<hello$hello|joins$joins|register$registers>]", + NO_STR DEBUG_STR DEBUG_PIM_STR DEBUG_PIM_PACKETS_STR DEBUG_PIM_HELLO_PACKETS_STR DEBUG_PIM_J_P_PACKETS_STR DEBUG_PIM_PIM_REG_PACKETS_STR) { - int idx = 0; - if (argv_find(argv, argc, "hello", &idx)) { - PIM_DO_DEBUG_PIM_HELLO; - vty_out(vty, "PIM Hello debugging is on\n"); - } else if (argv_find(argv, argc, "joins", &idx)) { - PIM_DO_DEBUG_PIM_J_P; - vty_out(vty, "PIM Join/Prune debugging is on\n"); - } else if (argv_find(argv, argc, "register", &idx)) { - PIM_DO_DEBUG_PIM_REG; - vty_out(vty, "PIM Register debugging is on\n"); - } else { - PIM_DO_DEBUG_PIM_PACKETS; - vty_out(vty, "PIM Packet debugging is on \n"); - } - return CMD_SUCCESS; -} - -DEFUN (no_debug_pim_packets, - no_debug_pim_packets_cmd, - "no debug pim packets [<hello|joins|register>]", - NO_STR - DEBUG_STR - DEBUG_PIM_STR - DEBUG_PIM_PACKETS_STR - DEBUG_PIM_HELLO_PACKETS_STR - DEBUG_PIM_J_P_PACKETS_STR - DEBUG_PIM_PIM_REG_PACKETS_STR) -{ - int idx = 0; - if (argv_find(argv, argc, "hello", &idx)) { - PIM_DONT_DEBUG_PIM_HELLO; - vty_out(vty, "PIM Hello debugging is off \n"); - } else if (argv_find(argv, argc, "joins", &idx)) { - PIM_DONT_DEBUG_PIM_J_P; - vty_out(vty, "PIM Join/Prune debugging is off \n"); - } else if (argv_find(argv, argc, "register", &idx)) { - PIM_DONT_DEBUG_PIM_REG; - vty_out(vty, "PIM Register debugging is off\n"); - } else - PIM_DONT_DEBUG_PIM_PACKETS; - - return CMD_SUCCESS; + if (!no) + return pim_debug_pim_packets_cmd(hello, joins, registers, vty); + else + return pim_no_debug_pim_packets_cmd(hello, joins, registers, + vty); } - -DEFUN (debug_pim_packetdump_send, +DEFPY (debug_pim_packetdump_send, debug_pim_packetdump_send_cmd, - "debug pim packet-dump send", - DEBUG_STR - DEBUG_PIM_STR - DEBUG_PIM_PACKETDUMP_STR - DEBUG_PIM_PACKETDUMP_SEND_STR) -{ - PIM_DO_DEBUG_PIM_PACKETDUMP_SEND; - return CMD_SUCCESS; -} - -DEFUN (no_debug_pim_packetdump_send, - no_debug_pim_packetdump_send_cmd, - "no debug pim packet-dump send", + "[no] debug pim packet-dump send", NO_STR DEBUG_STR DEBUG_PIM_STR DEBUG_PIM_PACKETDUMP_STR DEBUG_PIM_PACKETDUMP_SEND_STR) { - PIM_DONT_DEBUG_PIM_PACKETDUMP_SEND; + if (!no) + PIM_DO_DEBUG_PIM_PACKETDUMP_SEND; + else + PIM_DONT_DEBUG_PIM_PACKETDUMP_SEND; return CMD_SUCCESS; } -DEFUN (debug_pim_packetdump_recv, +DEFPY (debug_pim_packetdump_recv, debug_pim_packetdump_recv_cmd, - "debug pim packet-dump receive", - DEBUG_STR - DEBUG_PIM_STR - DEBUG_PIM_PACKETDUMP_STR - DEBUG_PIM_PACKETDUMP_RECV_STR) -{ - PIM_DO_DEBUG_PIM_PACKETDUMP_RECV; - return CMD_SUCCESS; -} - -DEFUN (no_debug_pim_packetdump_recv, - no_debug_pim_packetdump_recv_cmd, - "no debug pim packet-dump receive", + "[no] debug pim packet-dump receive", NO_STR DEBUG_STR DEBUG_PIM_STR DEBUG_PIM_PACKETDUMP_STR DEBUG_PIM_PACKETDUMP_RECV_STR) { - PIM_DONT_DEBUG_PIM_PACKETDUMP_RECV; + if (!no) + PIM_DO_DEBUG_PIM_PACKETDUMP_RECV; + else + PIM_DONT_DEBUG_PIM_PACKETDUMP_RECV; return CMD_SUCCESS; } -DEFUN (debug_pim_trace, +DEFPY (debug_pim_trace, debug_pim_trace_cmd, - "debug pim trace", - DEBUG_STR - DEBUG_PIM_STR - DEBUG_PIM_TRACE_STR) -{ - PIM_DO_DEBUG_PIM_TRACE; - return CMD_SUCCESS; -} - -DEFUN (debug_pim_trace_detail, - debug_pim_trace_detail_cmd, - "debug pim trace detail", - DEBUG_STR - DEBUG_PIM_STR - DEBUG_PIM_TRACE_STR - "Detailed Information\n") -{ - PIM_DO_DEBUG_PIM_TRACE_DETAIL; - return CMD_SUCCESS; -} - -DEFUN (no_debug_pim_trace, - no_debug_pim_trace_cmd, - "no debug pim trace", + "[no] debug pim trace", NO_STR DEBUG_STR DEBUG_PIM_STR DEBUG_PIM_TRACE_STR) { - PIM_DONT_DEBUG_PIM_TRACE; + if (!no) + PIM_DO_DEBUG_PIM_TRACE; + else + PIM_DONT_DEBUG_PIM_TRACE; return CMD_SUCCESS; } -DEFUN (no_debug_pim_trace_detail, - no_debug_pim_trace_detail_cmd, - "no debug pim trace detail", +DEFPY (debug_pim_trace_detail, + debug_pim_trace_detail_cmd, + "[no] debug pim trace detail", NO_STR DEBUG_STR DEBUG_PIM_STR DEBUG_PIM_TRACE_STR "Detailed Information\n") { - PIM_DONT_DEBUG_PIM_TRACE_DETAIL; + if (!no) + PIM_DO_DEBUG_PIM_TRACE_DETAIL; + else + PIM_DONT_DEBUG_PIM_TRACE_DETAIL; return CMD_SUCCESS; } @@ -5907,26 +5707,18 @@ DEFUN (no_debug_ssmpingd, return CMD_SUCCESS; } -DEFUN (debug_pim_zebra, +DEFPY (debug_pim_zebra, debug_pim_zebra_cmd, - "debug pim zebra", - DEBUG_STR - DEBUG_PIM_STR - DEBUG_PIM_ZEBRA_STR) -{ - PIM_DO_DEBUG_ZEBRA; - return CMD_SUCCESS; -} - -DEFUN (no_debug_pim_zebra, - no_debug_pim_zebra_cmd, - "no debug pim zebra", + "[no] debug pim zebra", NO_STR DEBUG_STR DEBUG_PIM_STR DEBUG_PIM_ZEBRA_STR) { - PIM_DONT_DEBUG_ZEBRA; + if (!no) + PIM_DO_DEBUG_ZEBRA; + else + PIM_DONT_DEBUG_ZEBRA; return CMD_SUCCESS; } @@ -7950,29 +7742,19 @@ void pim_cmd_init(void) install_element(ENABLE_NODE, &debug_pim_static_cmd); install_element(ENABLE_NODE, &no_debug_pim_static_cmd); install_element(ENABLE_NODE, &debug_pim_cmd); - install_element(ENABLE_NODE, &no_debug_pim_cmd); install_element(ENABLE_NODE, &debug_pim_nht_cmd); - install_element(ENABLE_NODE, &no_debug_pim_nht_cmd); install_element(ENABLE_NODE, &debug_pim_nht_det_cmd); - install_element(ENABLE_NODE, &no_debug_pim_nht_det_cmd); install_element(ENABLE_NODE, &debug_pim_nht_rp_cmd); install_element(ENABLE_NODE, &no_debug_pim_nht_rp_cmd); install_element(ENABLE_NODE, &debug_pim_events_cmd); - install_element(ENABLE_NODE, &no_debug_pim_events_cmd); install_element(ENABLE_NODE, &debug_pim_packets_cmd); - install_element(ENABLE_NODE, &no_debug_pim_packets_cmd); install_element(ENABLE_NODE, &debug_pim_packetdump_send_cmd); - install_element(ENABLE_NODE, &no_debug_pim_packetdump_send_cmd); install_element(ENABLE_NODE, &debug_pim_packetdump_recv_cmd); - install_element(ENABLE_NODE, &no_debug_pim_packetdump_recv_cmd); install_element(ENABLE_NODE, &debug_pim_trace_cmd); - install_element(ENABLE_NODE, &no_debug_pim_trace_cmd); install_element(ENABLE_NODE, &debug_pim_trace_detail_cmd); - install_element(ENABLE_NODE, &no_debug_pim_trace_detail_cmd); install_element(ENABLE_NODE, &debug_ssmpingd_cmd); install_element(ENABLE_NODE, &no_debug_ssmpingd_cmd); install_element(ENABLE_NODE, &debug_pim_zebra_cmd); - install_element(ENABLE_NODE, &no_debug_pim_zebra_cmd); install_element(ENABLE_NODE, &debug_pim_mlag_cmd); install_element(ENABLE_NODE, &no_debug_pim_mlag_cmd); install_element(ENABLE_NODE, &debug_pim_vxlan_cmd); @@ -8005,29 +7787,19 @@ void pim_cmd_init(void) install_element(CONFIG_NODE, &debug_pim_static_cmd); install_element(CONFIG_NODE, &no_debug_pim_static_cmd); install_element(CONFIG_NODE, &debug_pim_cmd); - install_element(CONFIG_NODE, &no_debug_pim_cmd); install_element(CONFIG_NODE, &debug_pim_nht_cmd); - install_element(CONFIG_NODE, &no_debug_pim_nht_cmd); install_element(CONFIG_NODE, &debug_pim_nht_det_cmd); - install_element(CONFIG_NODE, &no_debug_pim_nht_det_cmd); install_element(CONFIG_NODE, &debug_pim_nht_rp_cmd); install_element(CONFIG_NODE, &no_debug_pim_nht_rp_cmd); install_element(CONFIG_NODE, &debug_pim_events_cmd); - install_element(CONFIG_NODE, &no_debug_pim_events_cmd); install_element(CONFIG_NODE, &debug_pim_packets_cmd); - install_element(CONFIG_NODE, &no_debug_pim_packets_cmd); install_element(CONFIG_NODE, &debug_pim_packetdump_send_cmd); - install_element(CONFIG_NODE, &no_debug_pim_packetdump_send_cmd); install_element(CONFIG_NODE, &debug_pim_packetdump_recv_cmd); - install_element(CONFIG_NODE, &no_debug_pim_packetdump_recv_cmd); install_element(CONFIG_NODE, &debug_pim_trace_cmd); - install_element(CONFIG_NODE, &no_debug_pim_trace_cmd); install_element(CONFIG_NODE, &debug_pim_trace_detail_cmd); - install_element(CONFIG_NODE, &no_debug_pim_trace_detail_cmd); install_element(CONFIG_NODE, &debug_ssmpingd_cmd); install_element(CONFIG_NODE, &no_debug_ssmpingd_cmd); install_element(CONFIG_NODE, &debug_pim_zebra_cmd); - install_element(CONFIG_NODE, &no_debug_pim_zebra_cmd); install_element(CONFIG_NODE, &debug_pim_mlag_cmd); install_element(CONFIG_NODE, &no_debug_pim_mlag_cmd); install_element(CONFIG_NODE, &debug_pim_vxlan_cmd); |
