]> git.puffer.fish Git - matthieu/frr.git/commitdiff
pimd: Northbound support for pim passive enable
authorsarita patra <saritap@vmware.com>
Wed, 4 May 2022 13:05:43 +0000 (06:05 -0700)
committersarita patra <saritap@vmware.com>
Fri, 13 May 2022 06:51:21 +0000 (23:51 -0700)
Added nothbound callbacks for pim-passive-enable

Signed-off-by: sarita patra <saritap@vmware.com>
pimd/pim6_cmd.c
pimd/pim_cmd.c
pimd/pim_cmd_common.c
pimd/pim_cmd_common.h
pimd/pim_nb.c
pimd/pim_nb.h
pimd/pim_nb_config.c
yang/frr-pim.yang

index 0f40b35bc5329e4557f48c9ca2258d43855363e6..ecff2173d4e92bae5df8800c5d17fc1e75141215 100644 (file)
@@ -222,20 +222,14 @@ DEFPY (interface_ipv6_pim,
        "Disable exchange of protocol packets\n")
 {
        int ret;
-       VTY_DECLVAR_CONTEXT(interface, ifp);
-       struct pim_interface *pim_ifp;
 
        ret = pim_process_ip_pim_cmd(vty);
 
        if (ret != NB_OK)
                return ret;
 
-       pim_ifp = ifp->info;
-       if (!pim_ifp)
-               return CMD_WARNING_CONFIG_FAILED;
-
        if (passive)
-               pim_ifp->pim_passive_enable = true;
+               return pim_process_ip_pim_passive_cmd(vty, true);
 
        return CMD_SUCCESS;
 }
@@ -248,23 +242,10 @@ DEFPY (interface_no_ipv6_pim,
        PIM_STR
        "Disable exchange of protocol packets\n")
 {
-       int ret;
-       VTY_DECLVAR_CONTEXT(interface, ifp);
-       struct pim_interface *pim_ifp;
-
-       ret = pim_process_no_ip_pim_cmd(vty);
-
-       if (ret != NB_OK)
-               return ret;
-
-       pim_ifp = ifp->info;
-       if (!pim_ifp)
-               return CMD_WARNING_CONFIG_FAILED;
-
        if (passive)
-               pim_ifp->pim_passive_enable = false;
+               return pim_process_ip_pim_passive_cmd(vty, false);
 
-       return CMD_SUCCESS;
+       return pim_process_no_ip_pim_cmd(vty);
 }
 
 DEFPY (interface_ipv6_pim_drprio,
index d89d1afea1e84873e56e17856ffc596b4e8ec8be..7e9ce5f933773fbd3c54ed53cb0c904ff12af1b6 100644 (file)
@@ -5269,8 +5269,6 @@ DEFPY (interface_ip_pim,
        PIM_STR
        "Disable exchange of protocol packets\n")
 {
-       VTY_DECLVAR_CONTEXT(interface, ifp);
-       struct pim_interface *pim_ifp;
        int ret;
 
        ret = pim_process_ip_pim_cmd(vty);
@@ -5278,12 +5276,8 @@ DEFPY (interface_ip_pim,
        if (ret != NB_OK)
                return ret;
 
-       pim_ifp = ifp->info;
-       if (!pim_ifp)
-               return CMD_WARNING_CONFIG_FAILED;
-
        if (passive)
-               pim_ifp->pim_passive_enable = true;
+               return pim_process_ip_pim_passive_cmd(vty, true);
 
        return CMD_SUCCESS;
 }
@@ -5318,23 +5312,10 @@ DEFPY (interface_no_ip_pim,
        PIM_STR
        "Disable exchange of protocol packets\n")
 {
-       int ret;
-       VTY_DECLVAR_CONTEXT(interface, ifp);
-       struct pim_interface *pim_ifp;
-
-       ret = pim_process_no_ip_pim_cmd(vty);
-
-       if (ret != NB_OK)
-               return ret;
-
-       pim_ifp = ifp->info;
-       if (!pim_ifp)
-               return CMD_WARNING_CONFIG_FAILED;
-
        if (passive)
-               pim_ifp->pim_passive_enable = false;
+               return pim_process_ip_pim_passive_cmd(vty, false);
 
-       return CMD_SUCCESS;
+       return pim_process_no_ip_pim_cmd(vty);
 }
 
 /* boundaries */
index 817afd60d93dbbbaa80bbc5fe6c2546d87df6c15..6cff3a077e16e8bb9462ac5d2b223a9beaeb3b3f 100644 (file)
@@ -352,6 +352,19 @@ int pim_process_ip_pim_cmd(struct vty *vty)
                                    FRR_PIM_AF_XPATH_VAL);
 }
 
+int pim_process_ip_pim_passive_cmd(struct vty *vty, bool enable)
+{
+       if (enable)
+               nb_cli_enqueue_change(vty, "./pim-passive-enable", NB_OP_MODIFY,
+                                     "true");
+       else
+               nb_cli_enqueue_change(vty, "./pim-passive-enable", NB_OP_MODIFY,
+                                     "false");
+
+       return nb_cli_apply_changes(vty, FRR_PIM_INTERFACE_XPATH,
+                                   FRR_PIM_AF_XPATH_VAL);
+}
+
 int pim_process_no_ip_pim_cmd(struct vty *vty)
 {
        const struct lyd_node *mld_enable_dnode;
index 206a2248f8f6c6991007d09eb08817ea05c9fdad..4457ea57a97b232c003b4df6cf3b5d7b077810e8 100644 (file)
@@ -52,6 +52,7 @@ int pim_process_no_rp_plist_cmd(struct vty *vty, const char *rp_str,
 
 int pim_process_ip_pim_cmd(struct vty *vty);
 int pim_process_no_ip_pim_cmd(struct vty *vty);
+int pim_process_ip_pim_passive_cmd(struct vty *vty, bool enable);
 int pim_process_ip_pim_drprio_cmd(struct vty *vty, const char *drpriority_str);
 int pim_process_no_ip_pim_drprio_cmd(struct vty *vty);
 int pim_process_ip_pim_hello_cmd(struct vty *vty, const char *hello_str,
index 86dd8c490c8e6aa02111ba738f097f130b27b3b9..94696bb4c76ffa38ac021f497e3a69fc553bf421 100644 (file)
@@ -230,6 +230,12 @@ const struct frr_yang_module_info frr_pim_info = {
                                .modify = lib_interface_pim_address_family_pim_enable_modify,
                        }
                },
+               {
+                       .xpath = "/frr-interface:lib/interface/frr-pim:pim/address-family/pim-passive-enable",
+                       .cbs = {
+                               .modify = lib_interface_pim_address_family_pim_passive_enable_modify,
+                       }
+               },
                {
                        .xpath = "/frr-interface:lib/interface/frr-pim:pim/address-family/dr-priority",
                        .cbs = {
index 273c7e8a6101ef56fdf34739538cdba69887af10..be3cab66ce5a5ddb3ce5fb28e000af5c7d805403 100644 (file)
@@ -106,6 +106,8 @@ int lib_interface_pim_address_family_create(struct nb_cb_create_args *args);
 int lib_interface_pim_address_family_destroy(struct nb_cb_destroy_args *args);
 int lib_interface_pim_address_family_pim_enable_modify(
        struct nb_cb_modify_args *args);
+int lib_interface_pim_address_family_pim_passive_enable_modify(
+       struct nb_cb_modify_args *args);
 int lib_interface_pim_address_family_hello_interval_modify(
        struct nb_cb_modify_args *args);
 int lib_interface_pim_address_family_hello_holdtime_modify(
index d174b8a0af7eb649cc758367c6de4b519556222b..34438120b9ab497b79916f065fae9e3f1b1985d1 100644 (file)
@@ -1623,6 +1623,32 @@ int lib_interface_pim_address_family_pim_enable_modify(struct nb_cb_modify_args
        return NB_OK;
 }
 
+/*
+ * XPath:
+ * /frr-interface:lib/interface/frr-pim:pim/address-family/pim-passive-enable
+ */
+int lib_interface_pim_address_family_pim_passive_enable_modify(
+       struct nb_cb_modify_args *args)
+{
+       struct interface *ifp;
+       struct pim_interface *pim_ifp;
+
+       switch (args->event) {
+       case NB_EV_VALIDATE:
+       case NB_EV_ABORT:
+       case NB_EV_PREPARE:
+               break;
+       case NB_EV_APPLY:
+               ifp = nb_running_get_entry(args->dnode, NULL, true);
+               pim_ifp = ifp->info;
+               pim_ifp->pim_passive_enable =
+                       yang_dnode_get_bool(args->dnode, NULL);
+               break;
+       }
+
+       return NB_OK;
+}
+
 /*
  * XPath: /frr-interface:lib/interface/frr-pim:pim/address-family/hello-interval
  */
index 08bc9ce0a6eb3eb23e706026bbd88e01d064ef80..9e40d786020f11f2d077b4e9bec75ce3c2ee5f97 100644 (file)
@@ -334,6 +334,13 @@ module frr-pim {
         "Enable PIM flag on the interface.";
     }
 
+    leaf pim-passive-enable {
+      type boolean;
+      default "false";
+      description
+        "Disable exchange of protocol packets.";
+    }
+
     leaf hello-interval {
       type uint8 {
         range "1..max";