]> git.puffer.fish Git - mirror/frr.git/commitdiff
pimd: Moving ipv4 running-configs to a separate function
authorSai Gomathi N <nsaigomathi@vmware.com>
Wed, 19 Jan 2022 13:00:56 +0000 (05:00 -0800)
committerMobashshera Rasool <mrasool@vmware.com>
Mon, 28 Feb 2022 09:38:41 +0000 (01:38 -0800)
Co-authored-by: Sai Gomathi <nsaogimathi@vmware.com>
Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
pimd/pim_vty.c
pimd/pim_vty.h

index b452b024edada24493b7e444829c3ebc0a59c6b1..a70479d3da5d87c020a0866372d1f8c86ffacadb 100644 (file)
@@ -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("<grp?>", 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(
-                                                       "<grp?>",
-                                                       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;
                }
index 22ac3333e4d9a8b41d25ca1ab1e1b8398b4574c2..0e86727fdf7523c15b21c51060a8b9b7a4ca430c 100644 (file)
@@ -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 */