From: Sai Gomathi N Date: Tue, 12 Apr 2022 11:36:35 +0000 (-0700) Subject: pimd: Moving the common functions from pim_cmd.c file X-Git-Tag: base_8.3~60^2~6 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=58d5712048f2a5518dd315648ae8b3d60abf62d6;p=mirror%2Ffrr.git pimd: Moving the common functions from pim_cmd.c file Moving the functions that are used by both IPV4 and IPV6 to a common file pim_cmd_common.c file. Signed-off-by: Sai Gomathi N --- diff --git a/pimd/pim6_cmd.h b/pimd/pim6_cmd.h index d6853a7410..b7804c0db2 100644 --- a/pimd/pim6_cmd.h +++ b/pimd/pim6_cmd.h @@ -39,6 +39,7 @@ #define IFACE_PIM_HELLO_TIME_STR "Time in seconds for Hello Interval\n" #define IFACE_PIM_HELLO_HOLD_STR "Time in seconds for Hold Interval\n" #define MROUTE_STR "IP multicast routing table\n" +#define CLEAR_IP_PIM_STR "PIM clear commands\n" #define DEBUG_MLD_STR "MLD protocol activity\n" #define DEBUG_MLD_EVENTS_STR "MLD protocol events\n" #define DEBUG_MLD_PACKETS_STR "MLD protocol packets\n" diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 7e9ce5f933..bdf015642f 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; @@ -1861,45 +1840,6 @@ DEFUN (clear_ip_pim_statistics, 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__); - -} - DEFUN (clear_ip_mroute, clear_ip_mroute_cmd, "clear ip mroute [vrf NAME]", diff --git a/pimd/pim_cmd_common.c b/pimd/pim_cmd_common.c index 6cff3a077e..f4479abfab 100644 --- a/pimd/pim_cmd_common.c +++ b/pimd/pim_cmd_common.c @@ -3563,3 +3563,62 @@ void show_mroute_summary(struct pim_instance *pim, struct vty *vty, sg_hw_mroute_cnt); } } + +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__); +} + +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; + } +} diff --git a/pimd/pim_cmd_common.h b/pimd/pim_cmd_common.h index 4457ea57a9..1431ce32e1 100644 --- a/pimd/pim_cmd_common.h +++ b/pimd/pim_cmd_common.h @@ -121,6 +121,8 @@ void show_mroute_count(struct pim_instance *pim, struct vty *vty, json_object *json); void show_mroute_summary(struct pim_instance *pim, struct vty *vty, json_object *json); +void clear_mroute(struct pim_instance *pim); +void clear_pim_statistics(struct pim_instance *pim); /* * Special Macro to allow us to get the correct pim_instance;