From 0da95b2fd813d0de07eb5ce960f6b465e76951e9 Mon Sep 17 00:00:00 2001 From: Sai Gomathi N Date: Wed, 19 Jan 2022 05:00:56 -0800 Subject: [PATCH] pimd: Moving ipv4 running-configs to a separate function Co-authored-by: Sai Gomathi Signed-off-by: Mobashshera Rasool --- pimd/pim_vty.c | 259 +++++++++++++++++++++++-------------------------- pimd/pim_vty.h | 5 +- 2 files changed, 125 insertions(+), 139 deletions(-) diff --git a/pimd/pim_vty.c b/pimd/pim_vty.c index b452b024ed..a70479d3da 100644 --- a/pimd/pim_vty.c +++ b/pimd/pim_vty.c @@ -281,6 +281,124 @@ int pim_global_config_write_worker(struct pim_instance *pim, struct vty *vty) return writes; } +#if PIM_IPV == 4 +int pim_config_write(struct vty *vty, int writes, struct interface *ifp, + struct pim_instance *pim) +{ + struct pim_interface *pim_ifp = ifp->info; + + if (PIM_IF_TEST_PIM(pim_ifp->options)) { + vty_out(vty, " ip pim\n"); + ++writes; + } + + /* IF ip pim drpriority */ + if (pim_ifp->pim_dr_priority != PIM_DEFAULT_DR_PRIORITY) { + vty_out(vty, " ip pim drpriority %u\n", + pim_ifp->pim_dr_priority); + ++writes; + } + + /* IF ip pim hello */ + if (pim_ifp->pim_hello_period != PIM_DEFAULT_HELLO_PERIOD) { + vty_out(vty, " ip pim hello %d", pim_ifp->pim_hello_period); + if (pim_ifp->pim_default_holdtime != -1) + vty_out(vty, " %d", pim_ifp->pim_default_holdtime); + vty_out(vty, "\n"); + ++writes; + } + + /* update source */ + if (!pim_addr_is_any(pim_ifp->update_source)) { + vty_out(vty, " ip pim use-source %pPA\n", + &pim_ifp->update_source); + ++writes; + } + + /* IF ip igmp */ + if (PIM_IF_TEST_IGMP(pim_ifp->options)) { + vty_out(vty, " ip igmp\n"); + ++writes; + } + + /* ip igmp version */ + if (pim_ifp->igmp_version != IGMP_DEFAULT_VERSION) { + vty_out(vty, " ip igmp version %d\n", pim_ifp->igmp_version); + ++writes; + } + + /* IF ip igmp query-max-response-time */ + if (pim_ifp->gm_query_max_response_time_dsec != + IGMP_QUERY_MAX_RESPONSE_TIME_DSEC) { + vty_out(vty, " ip igmp query-max-response-time %d\n", + pim_ifp->gm_query_max_response_time_dsec); + ++writes; + } + + /* IF ip igmp query-interval */ + if (pim_ifp->gm_default_query_interval != IGMP_GENERAL_QUERY_INTERVAL) { + vty_out(vty, " ip igmp query-interval %d\n", + pim_ifp->gm_default_query_interval); + ++writes; + } + + /* IF ip igmp last-member_query-count */ + if (pim_ifp->gm_last_member_query_count != + IGMP_DEFAULT_ROBUSTNESS_VARIABLE) { + vty_out(vty, " ip igmp last-member-query-count %d\n", + pim_ifp->gm_last_member_query_count); + ++writes; + } + + /* IF ip igmp last-member_query-interval */ + if (pim_ifp->gm_specific_query_max_response_time_dsec != + IGMP_SPECIFIC_QUERY_MAX_RESPONSE_TIME_DSEC) { + vty_out(vty, " ip igmp last-member-query-interval %d\n", + pim_ifp->gm_specific_query_max_response_time_dsec); + ++writes; + } + + /* IF ip igmp join */ + if (pim_ifp->gm_join_list) { + struct listnode *node; + struct gm_join *ij; + for (ALL_LIST_ELEMENTS_RO(pim_ifp->gm_join_list, node, ij)) { + char group_str[INET_ADDRSTRLEN]; + char source_str[INET_ADDRSTRLEN]; + pim_inet4_dump("", ij->group_addr, group_str, + sizeof(group_str)); + if (ij->source_addr.s_addr == INADDR_ANY) { + vty_out(vty, " ip igmp join %s\n", group_str); + } else { + inet_ntop(AF_INET, &ij->source_addr, source_str, + sizeof(source_str)); + vty_out(vty, " ip igmp join %s %s\n", group_str, + source_str); + } + ++writes; + } + } + + if (pim_ifp->activeactive) + vty_out(vty, " ip pim active-active\n"); + + /* boundary */ + if (pim_ifp->boundary_oil_plist) { + vty_out(vty, " ip multicast boundary oil %s\n", + pim_ifp->boundary_oil_plist); + ++writes; + } + + writes += pim_static_write_mroute(pim, vty, ifp); + pim_bsm_write_config(vty, ifp); + ++writes; + pim_bfd_write_config(vty, ifp); + ++writes; + + return writes; +} +#endif + int pim_interface_config_write(struct vty *vty) { struct pim_instance *pim; @@ -310,145 +428,10 @@ int pim_interface_config_write(struct vty *vty) vty_out(vty, " description %s\n", ifp->desc); ++writes; } - - if (ifp->info) { - struct pim_interface *pim_ifp = ifp->info; - - if (PIM_IF_TEST_PIM(pim_ifp->options)) { - vty_out(vty, " ip pim\n"); - ++writes; - } - - /* IF ip pim drpriority */ - if (pim_ifp->pim_dr_priority - != PIM_DEFAULT_DR_PRIORITY) { - vty_out(vty, " ip pim drpriority %u\n", - pim_ifp->pim_dr_priority); - ++writes; - } - - /* IF ip pim hello */ - if (pim_ifp->pim_hello_period - != PIM_DEFAULT_HELLO_PERIOD) { - vty_out(vty, " ip pim hello %d", - pim_ifp->pim_hello_period); - if (pim_ifp->pim_default_holdtime != -1) - vty_out(vty, " %d", - pim_ifp->pim_default_holdtime); - vty_out(vty, "\n"); - ++writes; - } - - /* update source */ - if (!pim_addr_is_any(pim_ifp->update_source)) { - vty_out(vty, - " ip pim use-source %pPA\n", - &pim_ifp->update_source); - ++writes; - } - - /* IF ip igmp */ - if (PIM_IF_TEST_IGMP(pim_ifp->options)) { - vty_out(vty, " ip igmp\n"); - ++writes; - } - - /* ip igmp version */ - if (pim_ifp->igmp_version - != IGMP_DEFAULT_VERSION) { - vty_out(vty, " ip igmp version %d\n", - pim_ifp->igmp_version); - ++writes; - } - - /* IF ip igmp query-max-response-time */ - if (pim_ifp->gm_query_max_response_time_dsec != - IGMP_QUERY_MAX_RESPONSE_TIME_DSEC) { - vty_out(vty, - " ip igmp query-max-response-time %d\n", - pim_ifp->gm_query_max_response_time_dsec); - ++writes; - } - - /* IF ip igmp query-interval */ - if (pim_ifp->gm_default_query_interval != - IGMP_GENERAL_QUERY_INTERVAL) { - vty_out(vty, - " ip igmp query-interval %d\n", - pim_ifp->gm_default_query_interval); - ++writes; - } - - /* IF ip igmp last-member_query-count */ - if (pim_ifp->gm_last_member_query_count != - IGMP_DEFAULT_ROBUSTNESS_VARIABLE) { - vty_out(vty, - " ip igmp last-member-query-count %d\n", - pim_ifp->gm_last_member_query_count); - ++writes; - } - - /* IF ip igmp last-member_query-interval */ - if (pim_ifp->gm_specific_query_max_response_time_dsec != - IGMP_SPECIFIC_QUERY_MAX_RESPONSE_TIME_DSEC) { - vty_out(vty, - " ip igmp last-member-query-interval %d\n", - pim_ifp->gm_specific_query_max_response_time_dsec); - ++writes; - } - #if PIM_IPV == 4 - /* IF ip igmp join */ - if (pim_ifp->gm_join_list) { - struct listnode *node; - struct gm_join *ij; - for (ALL_LIST_ELEMENTS_RO( - pim_ifp->gm_join_list, - node, ij)) { - char group_str[INET_ADDRSTRLEN]; - char source_str - [INET_ADDRSTRLEN]; - pim_inet4_dump( - "", - ij->group_addr, - group_str, - sizeof(group_str)); - if (ij->source_addr.s_addr == INADDR_ANY) { - vty_out(vty, - " ip igmp join %s\n", - group_str); - } else { - inet_ntop(AF_INET, - &ij->source_addr, - source_str, - sizeof(source_str)); - vty_out(vty, - " ip igmp join %s %s\n", - group_str, source_str); - } - ++writes; - } - } -#endif /* PIM_IPV == 4 */ - - if (pim_ifp->activeactive) - vty_out(vty, " ip pim active-active\n"); - - /* boundary */ - if (pim_ifp->boundary_oil_plist) { - vty_out(vty, - " ip multicast boundary oil %s\n", - pim_ifp->boundary_oil_plist); - ++writes; - } - - writes += - pim_static_write_mroute(pim, vty, ifp); - pim_bsm_write_config(vty, ifp); - ++writes; - pim_bfd_write_config(vty, ifp); - ++writes; - } + if (ifp->info) + pim_config_write(vty, writes, ifp, pim); +#endif if_vty_config_end(vty); ++writes; } diff --git a/pimd/pim_vty.h b/pimd/pim_vty.h index 22ac3333e4..0e86727fdf 100644 --- a/pimd/pim_vty.h +++ b/pimd/pim_vty.h @@ -25,5 +25,8 @@ int pim_debug_config_write(struct vty *vty); int pim_global_config_write_worker(struct pim_instance *pim, struct vty *vty); int pim_interface_config_write(struct vty *vty); - +#if PIM_IPV == 4 +int pim_config_write(struct vty *vty, int writes, struct interface *ifp, + struct pim_instance *pim); +#endif #endif /* PIM_VTY_H */ -- 2.39.5