]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: convert interface evpn mh uplink command to NB
authorIgor Ryzhov <iryzhov@nfware.com>
Mon, 22 Jan 2024 20:21:38 +0000 (22:21 +0200)
committerIgor Ryzhov <iryzhov@nfware.com>
Sun, 28 Jan 2024 21:28:39 +0000 (23:28 +0200)
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
yang/frr-zebra.yang
zebra/zebra_evpn_mh.c
zebra/zebra_evpn_mh.h
zebra/zebra_nb.c
zebra/zebra_nb.h
zebra/zebra_nb_config.c

index ed2be1a2bc17b8212ad2be28612f59b936c17f98..95e4fc6db15ff15f25e9587196862304e6b0e026 100644 (file)
@@ -2257,6 +2257,12 @@ module frr-zebra {
           description
             "Bypass mode.";
         }
+        leaf uplink {
+          type boolean;
+          default "false";
+          description
+            "Uplink to the VxLAN core.";
+        }
       }
       container state {
         config false;
index 840ea98e4d39c73d29e11053d6cb47e7dd1c0df7..4a9c0488331a7dda327b650e687efbcf5422e0ae 100644 (file)
@@ -56,7 +56,6 @@ static void zebra_evpn_local_es_del(struct zebra_evpn_es **esp);
 static void zebra_evpn_local_es_update(struct zebra_if *zif);
 static bool zebra_evpn_es_br_port_dplane_update(struct zebra_evpn_es *es,
                                                const char *caller);
-static void zebra_evpn_mh_uplink_cfg_update(struct zebra_if *zif, bool set);
 static void zebra_evpn_mh_update_protodown_es(struct zebra_evpn_es *es,
                                              bool resync_dplane);
 static void zebra_evpn_mh_clear_protodown_es(struct zebra_evpn_es *es);
@@ -3434,16 +3433,21 @@ DEFPY_YANG (zebra_evpn_es_id,
 }
 
 /* CLI for tagging an interface as an uplink */
-DEFPY(zebra_evpn_mh_uplink, zebra_evpn_mh_uplink_cmd, "[no] evpn mh uplink",
-      NO_STR "EVPN\n" EVPN_MH_VTY_STR "uplink to the VxLAN core\n")
+DEFPY_YANG (zebra_evpn_mh_uplink,
+      zebra_evpn_mh_uplink_cmd,
+      "[no] evpn mh uplink",
+      NO_STR
+      "EVPN\n"
+      EVPN_MH_VTY_STR
+      "Uplink to the VxLAN core\n")
 {
-       VTY_DECLVAR_CONTEXT(interface, ifp);
-       struct zebra_if *zif;
-
-       zif = ifp->info;
-       zebra_evpn_mh_uplink_cfg_update(zif, no ? false : true);
-
-       return CMD_SUCCESS;
+       if (!no)
+               nb_cli_enqueue_change(vty, "./frr-zebra:zebra/evpn-mh/uplink",
+                                     NB_OP_MODIFY, "true");
+       else
+               nb_cli_enqueue_change(vty, "./frr-zebra:zebra/evpn-mh/uplink",
+                                     NB_OP_DESTROY, NULL);
+       return nb_cli_apply_changes(vty, NULL);
 }
 
 void zebra_evpn_mh_json(json_object *json)
@@ -3780,7 +3784,7 @@ static void zebra_evpn_mh_uplink_oper_flags_update(struct zebra_if *zif,
        }
 }
 
-static void zebra_evpn_mh_uplink_cfg_update(struct zebra_if *zif, bool set)
+void zebra_evpn_mh_uplink_cfg_update(struct zebra_if *zif, bool set)
 {
        bool old_protodown = zebra_evpn_mh_is_all_uplinks_down();
        bool new_protodown;
index a3e44e1753673f7b610dc2c6e4ee2b359431d388..fe450d4c2b61aba6fe90a9ca90d35d725a5805b0 100644 (file)
@@ -390,6 +390,7 @@ void zebra_evpn_es_type0_esi_update(struct zebra_if *zif, esi_t *esi);
 
 void zebra_evpn_es_df_pref_update(struct zebra_if *zif, uint16_t df_pref);
 void zebra_evpn_es_bypass_cfg_update(struct zebra_if *zif, bool bypass);
+void zebra_evpn_mh_uplink_cfg_update(struct zebra_if *zif, bool set);
 
 void zebra_evpn_mh_if_init(struct zebra_if *zif);
 
index 91e3bc3c3b6f97bae26df76b4993c9346b4ca1ec..15cb9c08585a6f124d092a6e7961f754b5ed3e61 100644 (file)
@@ -540,6 +540,12 @@ const struct frr_yang_module_info frr_zebra_info = {
                                .modify = lib_interface_zebra_evpn_mh_bypass_modify,
                        }
                },
+               {
+                       .xpath = "/frr-interface:lib/interface/frr-zebra:zebra/evpn-mh/uplink",
+                       .cbs = {
+                               .modify = lib_interface_zebra_evpn_mh_uplink_modify,
+                       }
+               },
                {
                        .xpath = "/frr-interface:lib/interface/frr-zebra:zebra/state/up-count",
                        .cbs = {
index e9822617cfc93d057c39ec400d90ac49b4116a0d..1ddc985ffdbb8aeb32a0deb29a30245082b94c1c 100644 (file)
@@ -180,6 +180,7 @@ int lib_interface_zebra_evpn_mh_type_3_local_discriminator_destroy(
 int lib_interface_zebra_evpn_mh_df_preference_modify(
        struct nb_cb_modify_args *args);
 int lib_interface_zebra_evpn_mh_bypass_modify(struct nb_cb_modify_args *args);
+int lib_interface_zebra_evpn_mh_uplink_modify(struct nb_cb_modify_args *args);
 struct yang_data *
 lib_interface_zebra_state_up_count_get_elem(struct nb_cb_get_elem_args *args);
 struct yang_data *
index 68f646098db1fdfbe47e2d3c468f583aaff1821e..eb3d5eec2c2d5857e1b555aef63a7b0961a96204 100644 (file)
@@ -2437,6 +2437,24 @@ int lib_interface_zebra_evpn_mh_bypass_modify(struct nb_cb_modify_args *args)
        return NB_OK;
 }
 
+/*
+ * XPath: /frr-interface:lib/interface/frr-zebra:zebra/evpn-mh/uplink
+ */
+int lib_interface_zebra_evpn_mh_uplink_modify(struct nb_cb_modify_args *args)
+{
+       struct interface *ifp;
+       bool uplink;
+
+       if (args->event != NB_EV_APPLY)
+               return NB_OK;
+
+       ifp = nb_running_get_entry(args->dnode, NULL, true);
+       uplink = yang_dnode_get_bool(args->dnode, NULL);
+       zebra_evpn_mh_uplink_cfg_update(ifp->info, uplink);
+
+       return NB_OK;
+}
+
 /*
  * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/l3vni-id
  */