Skip to content

Commit

Permalink
zebra: add default MPLS interface settings framework
Browse files Browse the repository at this point in the history
By default, MPLS configuration per interface is unspecified,
but can not be changed by compilation.
Add the framework to change the MPLS settings.

Signed-off-by: Philippe Guibert <[email protected]>
  • Loading branch information
pguibert6WIND committed Dec 22, 2023
1 parent c95b8dc commit c9eb206
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
24 changes: 18 additions & 6 deletions zebra/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ DEFINE_HOOK(zebra_if_config_wr, (struct vty * vty, struct interface *ifp),

DEFINE_MTYPE(ZEBRA, ZIF_DESC, "Intf desc");

FRR_CFG_DEFAULT_UINT8_T(ZEBRA_MPLS,
{ .val_uint8_t = IF_ZEBRA_DATA_UNSPEC},
);

static void if_down_del_nbr_connected(struct interface *ifp);

static void if_zebra_speed_update(struct event *thread)
Expand Down Expand Up @@ -135,7 +139,7 @@ static int if_zebra_new_hook(struct interface *ifp)
zebra_if->ifp = ifp;

zebra_if->multicast = IF_ZEBRA_DATA_UNSPEC;
zebra_if->mpls_config = IF_ZEBRA_DATA_UNSPEC;
if_mpls_set_default(zebra_if);
zebra_if->shutdown = IF_ZEBRA_DATA_OFF;

zebra_if->link_nsid = NS_UNKNOWN;
Expand Down Expand Up @@ -247,6 +251,11 @@ static void if_build_key(uint32_t ifindex, struct prefix *p)
p->u.prefix4.s_addr = ifindex;
}

void if_mpls_set_default(struct zebra_if *zif)
{
zif->mpls_config = DFLT_ZEBRA_MPLS;
}

/* Link an interface in a per NS interface tree */
struct interface *if_link_per_ns(struct zebra_ns *ns, struct interface *ifp)
{
Expand Down Expand Up @@ -5577,11 +5586,14 @@ static int if_config_write(struct vty *vty)
? ""
: "no ");

if (if_data->mpls_config == IF_ZEBRA_DATA_ON)
vty_out(vty, " mpls enable\n");
else if (if_data->mpls_config ==
IF_ZEBRA_DATA_OFF)
vty_out(vty, " mpls disable\n");
if (if_data->mpls_config != DFLT_ZEBRA_MPLS) {
if (if_data->mpls_config ==
IF_ZEBRA_DATA_ON)
vty_out(vty, " mpls enable\n");
else if (if_data->mpls_config ==
IF_ZEBRA_DATA_OFF)
vty_out(vty, " mpls disable\n");
}
}

hook_call(zebra_if_config_wr, vty, ifp);
Expand Down
1 change: 1 addition & 0 deletions zebra/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ extern void zebra_l2_unmap_slave_from_bond(struct zebra_if *zif);
extern const char *zebra_protodown_rc_str(uint32_t protodown_rc, char *pd_buf,
uint32_t pd_buf_len);
void zebra_if_dplane_result(struct zebra_dplane_ctx *ctx);
extern void if_mpls_set_default(struct zebra_if *zif);

#ifdef HAVE_PROC_NET_DEV
extern void ifstat_update_proc(void);
Expand Down
2 changes: 1 addition & 1 deletion zebra/zebra_nb_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@ int lib_interface_zebra_mpls_destroy(struct nb_cb_destroy_args *args)
ifp = nb_running_get_entry(args->dnode, NULL, true);
zif = ifp->info;

zif->mpls_config = IF_ZEBRA_DATA_UNSPEC;
if_mpls_set_default(zif);

/* keep the state as it is */

Expand Down

0 comments on commit c9eb206

Please sign in to comment.