From 10757acae605cb8215608fec03e1b1ebcdcfe74d Mon Sep 17 00:00:00 2001 From: Igor Ryzhov Date: Mon, 22 Jan 2024 22:21:38 +0200 Subject: [PATCH] zebra: convert interface evpn mh uplink command to NB Signed-off-by: Igor Ryzhov --- yang/frr-zebra.yang | 6 ++++++ zebra/zebra_evpn_mh.c | 26 +++++++++++++++----------- 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, 47 insertions(+), 11 deletions(-) diff --git a/yang/frr-zebra.yang b/yang/frr-zebra.yang index ed2be1a2bc..95e4fc6db1 100644 --- a/yang/frr-zebra.yang +++ b/yang/frr-zebra.yang @@ -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; diff --git a/zebra/zebra_evpn_mh.c b/zebra/zebra_evpn_mh.c index 840ea98e4d..4a9c048833 100644 --- a/zebra/zebra_evpn_mh.c +++ b/zebra/zebra_evpn_mh.c @@ -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; diff --git a/zebra/zebra_evpn_mh.h b/zebra/zebra_evpn_mh.h index a3e44e1753..fe450d4c2b 100644 --- a/zebra/zebra_evpn_mh.h +++ b/zebra/zebra_evpn_mh.h @@ -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); diff --git a/zebra/zebra_nb.c b/zebra/zebra_nb.c index 91e3bc3c3b..15cb9c0858 100644 --- a/zebra/zebra_nb.c +++ b/zebra/zebra_nb.c @@ -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 = { diff --git a/zebra/zebra_nb.h b/zebra/zebra_nb.h index e9822617cf..1ddc985ffd 100644 --- a/zebra/zebra_nb.h +++ b/zebra/zebra_nb.h @@ -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 * diff --git a/zebra/zebra_nb_config.c b/zebra/zebra_nb_config.c index 68f646098d..eb3d5eec2c 100644 --- a/zebra/zebra_nb_config.c +++ b/zebra/zebra_nb_config.c @@ -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 */ -- 2.39.5