From 4a18818b02c55c6a5313b5d49c4447daef3a3816 Mon Sep 17 00:00:00 2001 From: Igor Ryzhov Date: Mon, 22 Jan 2024 22:21:04 +0200 Subject: [PATCH] zebra: convert interface evpn mh bypass command to NB Signed-off-by: Igor Ryzhov --- yang/frr-zebra.yang | 6 ++++++ zebra/zebra_evpn_mh.c | 28 +++++++++++----------------- zebra/zebra_evpn_mh.h | 1 + zebra/zebra_nb.c | 6 ++++++ zebra/zebra_nb.h | 1 + zebra/zebra_nb_config.c | 18 ++++++++++++++++++ 6 files changed, 43 insertions(+), 17 deletions(-) diff --git a/yang/frr-zebra.yang b/yang/frr-zebra.yang index a004aaf2aa..ed2be1a2bc 100644 --- a/yang/frr-zebra.yang +++ b/yang/frr-zebra.yang @@ -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; diff --git a/zebra/zebra_evpn_mh.c b/zebra/zebra_evpn_mh.c index 0d5eb6fc17..840ea98e4d 100644 --- a/zebra/zebra_evpn_mh.c +++ b/zebra/zebra_evpn_mh.c @@ -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 */ diff --git a/zebra/zebra_evpn_mh.h b/zebra/zebra_evpn_mh.h index 81a773b87c..a3e44e1753 100644 --- a/zebra/zebra_evpn_mh.h +++ b/zebra/zebra_evpn_mh.h @@ -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); diff --git a/zebra/zebra_nb.c b/zebra/zebra_nb.c index d6a4a41e70..91e3bc3c3b 100644 --- a/zebra/zebra_nb.c +++ b/zebra/zebra_nb.c @@ -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 = { diff --git a/zebra/zebra_nb.h b/zebra/zebra_nb.h index 93df1a83e4..e9822617cf 100644 --- a/zebra/zebra_nb.h +++ b/zebra/zebra_nb.h @@ -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 * diff --git a/zebra/zebra_nb_config.c b/zebra/zebra_nb_config.c index e6eeb60b21..68f646098d 100644 --- a/zebra/zebra_nb_config.c +++ b/zebra/zebra_nb_config.c @@ -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 */ -- 2.39.5