summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmytro Shytyi <dmytro.shytyi@6wind.com>2022-12-05 16:58:53 +0100
committerDmytro Shytyi <dmytro.shytyi@6wind.com>2024-06-07 12:33:47 +0200
commitd875dc37ee03acc1fed4e750bbba8f6137e39fba (patch)
tree964fa48d4c4f59517dde125d3f04638dcbd0c96a
parent0cbe6dfc0854e50883bad4069a988b0c31afb2d6 (diff)
zebra: add 'mpls fec nexthop-resolution' command to vtysh
Commands added: r3# configure r3(config)# mpls fec MPLS FEC table label Label configuration ldp Label Distribution Protocol lsp Establish label switched path r3(config)# mpls fec mpls fec nexthop-resolution Authorise nexthop resolution over all labeled routes. r3(config)# mpls fec mpls fec nexthop-resolution r3# configure r3(config)# vrf default r3(config-vrf)# mpls fec MPLS FEC table r3(config-vrf)# mpls fec mpls fec nexthop-resolution Authorise nexthop resolution over all labeled routes. r3(config-vrf)# mpls fec nexthop-resolution east-vm# show running-config Building configuration... ... ! mpls fec nexthop-resolution ! ... Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
-rw-r--r--yang/frr-zebra.yang10
-rw-r--r--zebra/zebra_cli.c38
-rw-r--r--zebra/zebra_mpls.c8
-rw-r--r--zebra/zebra_mpls.h6
-rw-r--r--zebra/zebra_nb.c7
-rw-r--r--zebra/zebra_nb.h4
-rw-r--r--zebra/zebra_nb_config.c53
-rw-r--r--zebra/zebra_vrf.h1
8 files changed, 127 insertions, 0 deletions
diff --git a/yang/frr-zebra.yang b/yang/frr-zebra.yang
index 79c524a40a..4aa368e57f 100644
--- a/yang/frr-zebra.yang
+++ b/yang/frr-zebra.yang
@@ -2855,6 +2855,16 @@ module frr-zebra {
}
}
+ container mpls {
+ description
+ "MPLS Configuration.";
+ leaf fec-nexthop-resolution {
+ type boolean;
+ description
+ "Authorise nexthop resolution over all labeled routes.";
+ }
+ }
+
uses ribs;
uses vrf-vni-mapping;
diff --git a/zebra/zebra_cli.c b/zebra/zebra_cli.c
index 3e03d74775..6ee0fdbb8d 100644
--- a/zebra/zebra_cli.c
+++ b/zebra/zebra_cli.c
@@ -2221,6 +2221,37 @@ static void lib_vrf_zebra_ipv6_resolve_via_default_cli_write(
}
}
+DEFPY_YANG (mpls_fec_nexthop_resolution, mpls_fec_nexthop_resolution_cmd,
+ "[no$no] mpls fec nexthop-resolution",
+ NO_STR
+ MPLS_STR
+ "MPLS FEC table\n"
+ "Authorise nexthop resolution over all labeled routes.\n")
+{
+ nb_cli_enqueue_change(vty,
+ "./frr-zebra:zebra/mpls/fec-nexthop-resolution",
+ NB_OP_MODIFY, no ? "false" : "true");
+
+ if (vty->node == CONFIG_NODE)
+ return nb_cli_apply_changes(vty, "/frr-vrf:lib/vrf[name='%s']",
+ VRF_DEFAULT_NAME);
+
+ return nb_cli_apply_changes(vty, NULL);
+}
+
+static void lib_vrf_mpls_fec_nexthop_resolution_cli_write(
+ struct vty *vty, const struct lyd_node *dnode, bool show_defaults)
+{
+ bool fec_nexthop_resolution = yang_dnode_get_bool(dnode, NULL);
+
+ if (fec_nexthop_resolution || show_defaults) {
+ zebra_vrf_indent_cli_write(vty, dnode);
+
+ vty_out(vty, "%smpls fec nexthop-resolution\n",
+ fec_nexthop_resolution ? "" : "no ");
+ }
+}
+
DEFPY_YANG (vrf_netns,
vrf_netns_cmd,
"[no] netns ![NAME$netns_name]",
@@ -2852,6 +2883,10 @@ const struct frr_yang_module_info frr_zebra_cli_info = {
.cbs.cli_show = lib_vrf_zebra_netns_table_range_cli_write,
},
{
+ .xpath = "/frr-vrf:lib/vrf/frr-zebra:zebra/mpls/fec-nexthop-resolution",
+ .cbs.cli_show = lib_vrf_mpls_fec_nexthop_resolution_cli_write,
+ },
+ {
.xpath = "/frr-vrf:lib/vrf/frr-zebra:zebra/l3vni-id",
.cbs.cli_show = lib_vrf_zebra_l3vni_id_cli_write,
},
@@ -2957,6 +2992,9 @@ void zebra_cli_init(void)
install_element(VRF_NODE, &ip_nht_default_route_cmd);
install_element(VRF_NODE, &ipv6_nht_default_route_cmd);
+ install_element(CONFIG_NODE, &mpls_fec_nexthop_resolution_cmd);
+ install_element(VRF_NODE, &mpls_fec_nexthop_resolution_cmd);
+
install_element(CONFIG_NODE, &vni_mapping_cmd);
install_element(VRF_NODE, &vni_mapping_cmd);
diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c
index d1c9cd54af..6cee3aa39f 100644
--- a/zebra/zebra_mpls.c
+++ b/zebra/zebra_mpls.c
@@ -448,6 +448,14 @@ static int fec_send(struct zebra_fec *fec, struct zserv *client)
}
/*
+ * Upon reconfiguring nexthop-resolution updates, update the
+ * lsp entries accordingly.
+ */
+void zebra_mpls_fec_nexthop_resolution_update(struct zebra_vrf *zvrf)
+{
+}
+
+/*
* Update all registered clients about this FEC. Caller should've updated
* FEC and ensure no duplicate updates.
*/
diff --git a/zebra/zebra_mpls.h b/zebra/zebra_mpls.h
index dd6f960146..1f97c94347 100644
--- a/zebra/zebra_mpls.h
+++ b/zebra/zebra_mpls.h
@@ -257,6 +257,12 @@ void zebra_mpls_zapi_labels_process(bool add_p, struct zebra_vrf *zvrf,
const struct zapi_labels *zl);
/*
+ * Upon reconfiguring nexthop-resolution updates, update the
+ * lsp entries accordingly.
+ */
+void zebra_mpls_fec_nexthop_resolution_update(struct zebra_vrf *zvrf);
+
+/*
* Uninstall all NHLFEs bound to a single FEC.
*
* mpls_ftn_uninstall -> Called to enqueue into early label processing
diff --git a/zebra/zebra_nb.c b/zebra/zebra_nb.c
index eee9323082..0a7ed5db41 100644
--- a/zebra/zebra_nb.c
+++ b/zebra/zebra_nb.c
@@ -884,6 +884,13 @@ const struct frr_yang_module_info frr_zebra_info = {
}
},
{
+ .xpath = "/frr-vrf:lib/vrf/frr-zebra:zebra/mpls/fec-nexthop-resolution",
+ .cbs = {
+ .modify = lib_vrf_zebra_mpls_fec_nexthop_resolution_modify,
+ .destroy = lib_vrf_zebra_mpls_fec_nexthop_resolution_destroy,
+ }
+ },
+ {
.xpath = "/frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib",
.cbs = {
.get_next = lib_vrf_zebra_ribs_rib_get_next,
diff --git a/zebra/zebra_nb.h b/zebra/zebra_nb.h
index b40ed68229..785291bc68 100644
--- a/zebra/zebra_nb.h
+++ b/zebra/zebra_nb.h
@@ -309,6 +309,10 @@ int lib_vrf_zebra_netns_table_range_create(struct nb_cb_create_args *args);
int lib_vrf_zebra_netns_table_range_destroy(struct nb_cb_destroy_args *args);
int lib_vrf_zebra_netns_table_range_start_modify(struct nb_cb_modify_args *args);
int lib_vrf_zebra_netns_table_range_end_modify(struct nb_cb_modify_args *args);
+int lib_vrf_zebra_mpls_fec_nexthop_resolution_modify(
+ struct nb_cb_modify_args *args);
+int lib_vrf_zebra_mpls_fec_nexthop_resolution_destroy(
+ struct nb_cb_destroy_args *args);
const void *lib_vrf_zebra_ribs_rib_get_next(struct nb_cb_get_next_args *args);
int lib_vrf_zebra_ribs_rib_get_keys(struct nb_cb_get_keys_args *args);
const void *
diff --git a/zebra/zebra_nb_config.c b/zebra/zebra_nb_config.c
index ae6232a1bb..09c0091ec6 100644
--- a/zebra/zebra_nb_config.c
+++ b/zebra/zebra_nb_config.c
@@ -3781,6 +3781,59 @@ int lib_vrf_zebra_netns_table_range_end_modify(struct nb_cb_modify_args *args)
}
/*
+ * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/mpls/fec-nexthop-resolution
+ */
+int lib_vrf_zebra_mpls_fec_nexthop_resolution_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct vrf *vrf;
+ struct zebra_vrf *zvrf;
+ bool fec_nexthop_resolution;
+
+ if (args->event != NB_EV_APPLY)
+ return NB_OK;
+
+ vrf = nb_running_get_entry(args->dnode, NULL, true);
+ zvrf = vrf->info;
+
+ fec_nexthop_resolution = yang_dnode_get_bool(args->dnode, NULL);
+
+ if (zvrf->zebra_mpls_fec_nexthop_resolution == fec_nexthop_resolution)
+ return NB_OK;
+
+ zvrf->zebra_mpls_fec_nexthop_resolution = fec_nexthop_resolution;
+
+ zebra_mpls_fec_nexthop_resolution_update(zvrf);
+
+ return NB_OK;
+}
+
+int lib_vrf_zebra_mpls_fec_nexthop_resolution_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ struct vrf *vrf;
+ struct zebra_vrf *zvrf;
+ bool fec_nexthop_resolution;
+
+ if (args->event != NB_EV_APPLY)
+ return NB_OK;
+
+ vrf = nb_running_get_entry(args->dnode, NULL, true);
+ zvrf = vrf->info;
+
+ fec_nexthop_resolution = DFLT_ZEBRA_IP_NHT_RESOLVE_VIA_DEFAULT;
+
+ if (zvrf->zebra_mpls_fec_nexthop_resolution == fec_nexthop_resolution)
+ return NB_OK;
+
+ zvrf->zebra_mpls_fec_nexthop_resolution = fec_nexthop_resolution;
+
+ zebra_mpls_fec_nexthop_resolution_update(zvrf);
+
+ return NB_OK;
+}
+
+/*
* XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/l3vni-id
*/
int lib_vrf_zebra_l3vni_id_modify(struct nb_cb_modify_args *args)
diff --git a/zebra/zebra_vrf.h b/zebra/zebra_vrf.h
index 5cbfab1ddc..f97138c811 100644
--- a/zebra/zebra_vrf.h
+++ b/zebra/zebra_vrf.h
@@ -173,6 +173,7 @@ struct zebra_vrf {
bool zebra_rnh_ip_default_route;
bool zebra_rnh_ipv6_default_route;
+ bool zebra_mpls_fec_nexthop_resolution;
};
#define PROTO_RM_NAME(zvrf, afi, rtype) zvrf->proto_rm[afi][rtype].name
#define NHT_RM_NAME(zvrf, afi, rtype) zvrf->nht_rm[afi][rtype].name