]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: convert interface evpn mh bypass command to NB
authorIgor Ryzhov <iryzhov@nfware.com>
Mon, 22 Jan 2024 20:21:04 +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 a004aaf2aa3bf57879c0305b65a664c5ab4ad7b0..ed2be1a2bc17b8212ad2be28612f59b936c17f98 100644 (file)
@@ -2251,6 +2251,12 @@ module frr-zebra {
           description
             "Preference value used for DF election.";
         }
+        leaf bypass {
+          type boolean;
+          default "false";
+          description
+            "Bypass mode.";
+        }
       }
       container state {
         config false;
index 0d5eb6fc177912c012262b74aa82eeb1f37e46df..840ea98e4d39c73d29e11053d6cb47e7dd1c0df7 100644 (file)
@@ -2808,7 +2808,7 @@ void zebra_evpn_es_bypass_update(struct zebra_evpn_es *es,
                zebra_evpn_es_br_port_dplane_update(es, __func__);
 }
 
-static void zebra_evpn_es_bypass_cfg_update(struct zebra_if *zif, bool bypass)
+void zebra_evpn_es_bypass_cfg_update(struct zebra_if *zif, bool bypass)
 {
        bool old_bypass = !!(zif->es_info.flags & ZIF_CFG_ES_FLAG_BYPASS);
 
@@ -3331,6 +3331,9 @@ int zebra_evpn_mh_if_write(struct vty *vty, struct interface *ifp)
        if (zif->flags & ZIF_FLAG_EVPN_MH_UPLINK)
                vty_out(vty, " evpn mh uplink\n");
 
+       if (zif->es_info.flags & ZIF_CFG_ES_FLAG_BYPASS)
+               vty_out(vty, " evpn mh bypass\n");
+
        return 0;
 }
 
@@ -3345,22 +3348,13 @@ DEFPY_HIDDEN(zebra_evpn_es_bypass, zebra_evpn_es_bypass_cmd,
             "[no] evpn mh bypass",
             NO_STR "EVPN\n" EVPN_MH_VTY_STR "set bypass mode\n")
 {
-       VTY_DECLVAR_CONTEXT(interface, ifp);
-       struct zebra_if *zif;
-
-       zif = ifp->info;
-
-       if (no) {
-               zebra_evpn_es_bypass_cfg_update(zif, false);
-       } else {
-               if (!zebra_evpn_is_if_es_capable(zif)) {
-                       vty_out(vty,
-                               "%% DF bypass cannot be associated with this interface type\n");
-                       return CMD_WARNING;
-               }
-               zebra_evpn_es_bypass_cfg_update(zif, true);
-       }
-       return CMD_SUCCESS;
+       if (!no)
+               nb_cli_enqueue_change(vty, "./frr-zebra:zebra/evpn-mh/bypass",
+                                     NB_OP_MODIFY, "true");
+       else
+               nb_cli_enqueue_change(vty, "./frr-zebra:zebra/evpn-mh/bypass",
+                                     NB_OP_DESTROY, NULL);
+       return nb_cli_apply_changes(vty, NULL);
 }
 
 /* CLI for configuring DF preference part for an ES */
index 81a773b87cfe1f4bd990b081bb21c85fe9bc15c1..a3e44e1753673f7b610dc2c6e4ee2b359431d388 100644 (file)
@@ -389,6 +389,7 @@ void zebra_evpn_es_lid_update(struct zebra_if *zif, uint32_t lid);
 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_if_init(struct zebra_if *zif);
 
index d6a4a41e70834c1bafeb90988f75b754b41fd79a..91e3bc3c3b6f97bae26df76b4993c9346b4ca1ec 100644 (file)
@@ -534,6 +534,12 @@ const struct frr_yang_module_info frr_zebra_info = {
                                .modify = lib_interface_zebra_evpn_mh_df_preference_modify,
                        }
                },
+               {
+                       .xpath = "/frr-interface:lib/interface/frr-zebra:zebra/evpn-mh/bypass",
+                       .cbs = {
+                               .modify = lib_interface_zebra_evpn_mh_bypass_modify,
+                       }
+               },
                {
                        .xpath = "/frr-interface:lib/interface/frr-zebra:zebra/state/up-count",
                        .cbs = {
index 93df1a83e4e072099bc7f6cd417249550698d6b5..e9822617cfc93d057c39ec400d90ac49b4116a0d 100644 (file)
@@ -179,6 +179,7 @@ int lib_interface_zebra_evpn_mh_type_3_local_discriminator_destroy(
        struct nb_cb_destroy_args *args);
 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);
 struct yang_data *
 lib_interface_zebra_state_up_count_get_elem(struct nb_cb_get_elem_args *args);
 struct yang_data *
index e6eeb60b216c4d27a3fa16c0fede1ff9089a4fff..68f646098db1fdfbe47e2d3c468f583aaff1821e 100644 (file)
@@ -2419,6 +2419,24 @@ int lib_interface_zebra_evpn_mh_df_preference_modify(
        return NB_OK;
 }
 
+/*
+ * XPath: /frr-interface:lib/interface/frr-zebra:zebra/evpn-mh/bypass
+ */
+int lib_interface_zebra_evpn_mh_bypass_modify(struct nb_cb_modify_args *args)
+{
+       struct interface *ifp;
+       bool bypass;
+
+       if (args->event != NB_EV_APPLY)
+               return NB_OK;
+
+       ifp = nb_running_get_entry(args->dnode, NULL, true);
+       bypass = yang_dnode_get_bool(args->dnode, NULL);
+       zebra_evpn_es_bypass_cfg_update(ifp->info, bypass);
+
+       return NB_OK;
+}
+
 /*
  * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/l3vni-id
  */