zebra: convert interface evpn mh bypass command to NB

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
This commit is contained in:
Igor Ryzhov 2024-01-22 22:21:04 +02:00
parent 7c6e41ecff
commit 4a18818b02
6 changed files with 43 additions and 17 deletions

View 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;

View 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 */

View 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);

View 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 = {

View 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 *

View 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
*/