summaryrefslogtreecommitdiffstats
path: root/isisd
diff options
context:
space:
mode:
authorEmanuele Di Pascale <emanuele@voltanet.io>2018-11-14 12:34:02 +0100
committerEmanuele Di Pascale <emanuele@voltanet.io>2018-12-18 15:23:49 +0100
commit22af6a806d75f603e54748bfc618f033319c5380 (patch)
tree8067eebd0d9d8234629846ede4f9c2154c77922a /isisd
parentisisd: retrofit the 'redistribute' command (diff)
downloadfrr-22af6a806d75f603e54748bfc618f033319c5380.tar.xz
frr-22af6a806d75f603e54748bfc618f033319c5380.zip
isisd: retrofit the 'topology' command
Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
Diffstat (limited to '')
-rw-r--r--isisd/isis_cli.c112
-rw-r--r--isisd/isis_cli.h12
-rw-r--r--isisd/isis_northbound.c144
-rw-r--r--isisd/isisd.c7
4 files changed, 226 insertions, 49 deletions
diff --git a/isisd/isis_cli.c b/isisd/isis_cli.c
index 92e700ca4..130b5096c 100644
--- a/isisd/isis_cli.c
+++ b/isisd/isis_cli.c
@@ -1106,6 +1106,116 @@ void cli_show_isis_redistribute_ipv6(struct vty *vty, struct lyd_node *dnode,
vty_print_redistribute(vty, dnode, "ipv6");
}
+/*
+ * XPath: /frr-isisd:isis/instance/multi-topology
+ */
+DEFPY(isis_topology, isis_topology_cmd,
+ "[no] topology "
+ "<ipv4-unicast"
+ "|ipv4-mgmt"
+ "|ipv6-unicast"
+ "|ipv4-multicast"
+ "|ipv6-multicast"
+ "|ipv6-mgmt"
+ "|ipv6-dstsrc>$topology "
+ "[overload]$overload",
+ NO_STR
+ "Configure IS-IS topologies\n"
+ "IPv4 unicast topology\n"
+ "IPv4 management topology\n"
+ "IPv6 unicast topology\n"
+ "IPv4 multicast topology\n"
+ "IPv6 multicast topology\n"
+ "IPv6 management topology\n"
+ "IPv6 dst-src topology\n"
+ "Set overload bit for topology\n")
+{
+ char base_xpath[XPATH_MAXLEN];
+
+ /* Since IPv4-unicast is not configurable it is not present in the
+ * YANG model, so we need to validate it here
+ */
+ if (strmatch(topology, "ipv4-unicast")) {
+ vty_out(vty, "Cannot configure IPv4 unicast topology\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+
+ if (strmatch(topology, "ipv4-mgmt"))
+ snprintf(base_xpath, XPATH_MAXLEN,
+ "./multi-topology/ipv4-management");
+ else if (strmatch(topology, "ipv6-mgmt"))
+ snprintf(base_xpath, XPATH_MAXLEN,
+ "./multi-topology/ipv6-management");
+ else
+ snprintf(base_xpath, XPATH_MAXLEN, "./multi-topology/%s",
+ topology);
+
+ if (no)
+ nb_cli_enqueue_change(vty, ".", NB_OP_DELETE, NULL);
+ else {
+ nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL);
+ nb_cli_enqueue_change(vty, "./overload",
+ overload ? NB_OP_CREATE : NB_OP_DELETE,
+ NULL);
+ }
+
+ return nb_cli_apply_changes(vty, base_xpath);
+}
+
+void cli_show_isis_mt_ipv4_multicast(struct vty *vty, struct lyd_node *dnode,
+ bool show_defaults)
+{
+ vty_out(vty, " topology ipv4-multicast");
+ if (yang_dnode_exists(dnode, "./overload"))
+ vty_out(vty, " overload");
+ vty_out(vty, "\n");
+}
+
+void cli_show_isis_mt_ipv4_mgmt(struct vty *vty, struct lyd_node *dnode,
+ bool show_defaults)
+{
+ vty_out(vty, " topology ipv4-mgmt");
+ if (yang_dnode_exists(dnode, "./overload"))
+ vty_out(vty, " overload");
+ vty_out(vty, "\n");
+}
+
+void cli_show_isis_mt_ipv6_unicast(struct vty *vty, struct lyd_node *dnode,
+ bool show_defaults)
+{
+ vty_out(vty, " topology ipv6-unicast");
+ if (yang_dnode_exists(dnode, "./overload"))
+ vty_out(vty, " overload");
+ vty_out(vty, "\n");
+}
+
+void cli_show_isis_mt_ipv6_multicast(struct vty *vty, struct lyd_node *dnode,
+ bool show_defaults)
+{
+ vty_out(vty, " topology ipv6-multicast");
+ if (yang_dnode_exists(dnode, "./overload"))
+ vty_out(vty, " overload");
+ vty_out(vty, "\n");
+}
+
+void cli_show_isis_mt_ipv6_mgmt(struct vty *vty, struct lyd_node *dnode,
+ bool show_defaults)
+{
+ vty_out(vty, " topology ipv6-mgmt");
+ if (yang_dnode_exists(dnode, "./overload"))
+ vty_out(vty, " overload");
+ vty_out(vty, "\n");
+}
+
+void cli_show_isis_mt_ipv6_dstsrc(struct vty *vty, struct lyd_node *dnode,
+ bool show_defaults)
+{
+ vty_out(vty, " topology ipv6-dstsrc");
+ if (yang_dnode_exists(dnode, "./overload"))
+ vty_out(vty, " overload");
+ vty_out(vty, "\n");
+}
+
void isis_cli_init(void)
{
install_element(CONFIG_NODE, &router_isis_cmd);
@@ -1155,6 +1265,8 @@ void isis_cli_init(void)
install_element(ISIS_NODE, &isis_default_originate_cmd);
install_element(ISIS_NODE, &isis_redistribute_cmd);
+
+ install_element(ISIS_NODE, &isis_topology_cmd);
}
#endif /* ifndef FABRICD */
diff --git a/isisd/isis_cli.h b/isisd/isis_cli.h
index 3b06202b4..5c2e37741 100644
--- a/isisd/isis_cli.h
+++ b/isisd/isis_cli.h
@@ -69,5 +69,17 @@ void cli_show_isis_redistribute_ipv4(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_redistribute_ipv6(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
+void cli_show_isis_mt_ipv4_multicast(struct vty *vty, struct lyd_node *dnode,
+ bool show_defaults);
+void cli_show_isis_mt_ipv4_mgmt(struct vty *vty, struct lyd_node *dnode,
+ bool show_defaults);
+void cli_show_isis_mt_ipv6_unicast(struct vty *vty, struct lyd_node *dnode,
+ bool show_defaults);
+void cli_show_isis_mt_ipv6_multicast(struct vty *vty, struct lyd_node *dnode,
+ bool show_defaults);
+void cli_show_isis_mt_ipv6_mgmt(struct vty *vty, struct lyd_node *dnode,
+ bool show_defaults);
+void cli_show_isis_mt_ipv6_dstsrc(struct vty *vty, struct lyd_node *dnode,
+ bool show_defaults);
#endif /* ISISD_ISIS_CLI_H_ */
diff --git a/isisd/isis_northbound.c b/isisd/isis_northbound.c
index 0d22e870c..910ae37fc 100644
--- a/isisd/isis_northbound.c
+++ b/isisd/isis_northbound.c
@@ -1209,21 +1209,72 @@ isis_instance_redistribute_ipv6_metric_delete(enum nb_event event,
/*
* XPath: /frr-isisd:isis/instance/multi-topology/ipv4-multicast
*/
+static int isis_multi_topology_common(enum nb_event event,
+ const struct lyd_node *dnode,
+ const char *topology, bool create)
+{
+ struct isis_area *area;
+ struct isis_area_mt_setting *setting;
+ uint16_t mtid = isis_str2mtid(topology);
+
+ switch (event) {
+ case NB_EV_VALIDATE:
+ if (mtid == (uint16_t)-1) {
+ flog_warn(EC_LIB_NB_CB_CONFIG_VALIDATE,
+ "Unknown topology %s", topology);
+ return NB_ERR_VALIDATION;
+ }
+ break;
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ area = yang_dnode_get_entry(dnode, true);
+ setting = area_get_mt_setting(area, mtid);
+ setting->enabled = create;
+ lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0);
+ break;
+ }
+
+ return NB_OK;
+}
+
+static int isis_multi_topology_overload_common(enum nb_event event,
+ const struct lyd_node *dnode,
+ const char *topology,
+ bool create)
+{
+ struct isis_area *area;
+ struct isis_area_mt_setting *setting;
+ uint16_t mtid = isis_str2mtid(topology);
+
+ /* validation is done in isis_multi_topology_common */
+ if (event != NB_EV_APPLY)
+ return NB_OK;
+
+ area = yang_dnode_get_entry(dnode, true);
+ setting = area_get_mt_setting(area, mtid);
+ setting->overload = create;
+ if (setting->enabled)
+ lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0);
+
+ return NB_OK;
+}
+
static int
isis_instance_multi_topology_ipv4_multicast_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource)
{
- /* TODO: implement me. */
- return NB_OK;
+ return isis_multi_topology_common(event, dnode, "ipv4-multicast", true);
}
static int
isis_instance_multi_topology_ipv4_multicast_delete(enum nb_event event,
const struct lyd_node *dnode)
{
- /* TODO: implement me. */
- return NB_OK;
+ return isis_multi_topology_common(event, dnode, "ipv4-multicast",
+ false);
}
/*
@@ -1233,15 +1284,15 @@ static int isis_instance_multi_topology_ipv4_multicast_overload_create(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource)
{
- /* TODO: implement me. */
- return NB_OK;
+ return isis_multi_topology_overload_common(event, dnode,
+ "ipv4-multicast", true);
}
static int isis_instance_multi_topology_ipv4_multicast_overload_delete(
enum nb_event event, const struct lyd_node *dnode)
{
- /* TODO: implement me. */
- return NB_OK;
+ return isis_multi_topology_overload_common(event, dnode,
+ "ipv4-multicast", false);
}
/*
@@ -1251,15 +1302,13 @@ static int isis_instance_multi_topology_ipv4_management_create(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource)
{
- /* TODO: implement me. */
- return NB_OK;
+ return isis_multi_topology_common(event, dnode, "ipv4-mgmt", true);
}
static int isis_instance_multi_topology_ipv4_management_delete(
enum nb_event event, const struct lyd_node *dnode)
{
- /* TODO: implement me. */
- return NB_OK;
+ return isis_multi_topology_common(event, dnode, "ipv4-mgmt", false);
}
/*
@@ -1269,15 +1318,15 @@ static int isis_instance_multi_topology_ipv4_management_overload_create(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource)
{
- /* TODO: implement me. */
- return NB_OK;
+ return isis_multi_topology_overload_common(event, dnode, "ipv4-mgmt",
+ true);
}
static int isis_instance_multi_topology_ipv4_management_overload_delete(
enum nb_event event, const struct lyd_node *dnode)
{
- /* TODO: implement me. */
- return NB_OK;
+ return isis_multi_topology_overload_common(event, dnode, "ipv4-mgmt",
+ false);
}
/*
@@ -1288,16 +1337,14 @@ isis_instance_multi_topology_ipv6_unicast_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource)
{
- /* TODO: implement me. */
- return NB_OK;
+ return isis_multi_topology_common(event, dnode, "ipv6-unicast", true);
}
static int
isis_instance_multi_topology_ipv6_unicast_delete(enum nb_event event,
const struct lyd_node *dnode)
{
- /* TODO: implement me. */
- return NB_OK;
+ return isis_multi_topology_common(event, dnode, "ipv6-unicast", false);
}
/*
@@ -1307,15 +1354,15 @@ static int isis_instance_multi_topology_ipv6_unicast_overload_create(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource)
{
- /* TODO: implement me. */
- return NB_OK;
+ return isis_multi_topology_overload_common(event, dnode, "ipv6-unicast",
+ true);
}
static int isis_instance_multi_topology_ipv6_unicast_overload_delete(
enum nb_event event, const struct lyd_node *dnode)
{
- /* TODO: implement me. */
- return NB_OK;
+ return isis_multi_topology_overload_common(event, dnode, "ipv6-unicast",
+ false);
}
/*
@@ -1326,16 +1373,15 @@ isis_instance_multi_topology_ipv6_multicast_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource)
{
- /* TODO: implement me. */
- return NB_OK;
+ return isis_multi_topology_common(event, dnode, "ipv6-multicast", true);
}
static int
isis_instance_multi_topology_ipv6_multicast_delete(enum nb_event event,
const struct lyd_node *dnode)
{
- /* TODO: implement me. */
- return NB_OK;
+ return isis_multi_topology_common(event, dnode, "ipv6-multicast",
+ false);
}
/*
@@ -1345,15 +1391,15 @@ static int isis_instance_multi_topology_ipv6_multicast_overload_create(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource)
{
- /* TODO: implement me. */
- return NB_OK;
+ return isis_multi_topology_overload_common(event, dnode,
+ "ipv6-multicast", true);
}
static int isis_instance_multi_topology_ipv6_multicast_overload_delete(
enum nb_event event, const struct lyd_node *dnode)
{
- /* TODO: implement me. */
- return NB_OK;
+ return isis_multi_topology_overload_common(event, dnode,
+ "ipv6-multicast", false);
}
/*
@@ -1363,15 +1409,13 @@ static int isis_instance_multi_topology_ipv6_management_create(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource)
{
- /* TODO: implement me. */
- return NB_OK;
+ return isis_multi_topology_common(event, dnode, "ipv6-mgmt", true);
}
static int isis_instance_multi_topology_ipv6_management_delete(
enum nb_event event, const struct lyd_node *dnode)
{
- /* TODO: implement me. */
- return NB_OK;
+ return isis_multi_topology_common(event, dnode, "ipv6-mgmt", false);
}
/*
@@ -1381,15 +1425,15 @@ static int isis_instance_multi_topology_ipv6_management_overload_create(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource)
{
- /* TODO: implement me. */
- return NB_OK;
+ return isis_multi_topology_overload_common(event, dnode, "ipv6-mgmt",
+ true);
}
static int isis_instance_multi_topology_ipv6_management_overload_delete(
enum nb_event event, const struct lyd_node *dnode)
{
- /* TODO: implement me. */
- return NB_OK;
+ return isis_multi_topology_overload_common(event, dnode, "ipv6-mgmt",
+ false);
}
/*
@@ -1400,16 +1444,14 @@ isis_instance_multi_topology_ipv6_dstsrc_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource)
{
- /* TODO: implement me. */
- return NB_OK;
+ return isis_multi_topology_common(event, dnode, "ipv6-dstsrc", true);
}
static int
isis_instance_multi_topology_ipv6_dstsrc_delete(enum nb_event event,
const struct lyd_node *dnode)
{
- /* TODO: implement me. */
- return NB_OK;
+ return isis_multi_topology_common(event, dnode, "ipv6-dstsrc", false);
}
/*
@@ -1419,15 +1461,15 @@ static int isis_instance_multi_topology_ipv6_dstsrc_overload_create(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource)
{
- /* TODO: implement me. */
- return NB_OK;
+ return isis_multi_topology_overload_common(event, dnode, "ipv6-dstsrc",
+ true);
}
static int isis_instance_multi_topology_ipv6_dstsrc_overload_delete(
enum nb_event event, const struct lyd_node *dnode)
{
- /* TODO: implement me. */
- return NB_OK;
+ return isis_multi_topology_overload_common(event, dnode, "ipv6-dstsrc",
+ false);
}
/*
@@ -2384,6 +2426,7 @@ const struct frr_yang_module_info frr_isisd_info = {
.xpath = "/frr-isisd:isis/instance/multi-topology/ipv4-multicast",
.cbs.create = isis_instance_multi_topology_ipv4_multicast_create,
.cbs.delete = isis_instance_multi_topology_ipv4_multicast_delete,
+ .cbs.cli_show = cli_show_isis_mt_ipv4_multicast,
},
{
.xpath = "/frr-isisd:isis/instance/multi-topology/ipv4-multicast/overload",
@@ -2394,6 +2437,7 @@ const struct frr_yang_module_info frr_isisd_info = {
.xpath = "/frr-isisd:isis/instance/multi-topology/ipv4-management",
.cbs.create = isis_instance_multi_topology_ipv4_management_create,
.cbs.delete = isis_instance_multi_topology_ipv4_management_delete,
+ .cbs.cli_show = cli_show_isis_mt_ipv4_mgmt,
},
{
.xpath = "/frr-isisd:isis/instance/multi-topology/ipv4-management/overload",
@@ -2404,6 +2448,7 @@ const struct frr_yang_module_info frr_isisd_info = {
.xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-unicast",
.cbs.create = isis_instance_multi_topology_ipv6_unicast_create,
.cbs.delete = isis_instance_multi_topology_ipv6_unicast_delete,
+ .cbs.cli_show = cli_show_isis_mt_ipv6_unicast,
},
{
.xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-unicast/overload",
@@ -2414,6 +2459,7 @@ const struct frr_yang_module_info frr_isisd_info = {
.xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-multicast",
.cbs.create = isis_instance_multi_topology_ipv6_multicast_create,
.cbs.delete = isis_instance_multi_topology_ipv6_multicast_delete,
+ .cbs.cli_show = cli_show_isis_mt_ipv6_multicast,
},
{
.xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-multicast/overload",
@@ -2424,6 +2470,7 @@ const struct frr_yang_module_info frr_isisd_info = {
.xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-management",
.cbs.create = isis_instance_multi_topology_ipv6_management_create,
.cbs.delete = isis_instance_multi_topology_ipv6_management_delete,
+ .cbs.cli_show = cli_show_isis_mt_ipv6_mgmt,
},
{
.xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-management/overload",
@@ -2434,6 +2481,7 @@ const struct frr_yang_module_info frr_isisd_info = {
.xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-dstsrc",
.cbs.create = isis_instance_multi_topology_ipv6_dstsrc_create,
.cbs.delete = isis_instance_multi_topology_ipv6_dstsrc_delete,
+ .cbs.cli_show = cli_show_isis_mt_ipv6_dstsrc,
},
{
.xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-dstsrc/overload",
diff --git a/isisd/isisd.c b/isisd/isisd.c
index ee4f7e664..b431e3bbd 100644
--- a/isisd/isisd.c
+++ b/isisd/isisd.c
@@ -288,6 +288,7 @@ int isis_area_destroy(const char *area_tag)
return CMD_SUCCESS;
}
+#ifdef FABRICD
static void area_set_mt_enabled(struct isis_area *area, uint16_t mtid,
bool enabled)
{
@@ -313,6 +314,7 @@ static void area_set_mt_overload(struct isis_area *area, uint16_t mtid,
0);
}
}
+#endif /* ifdef FABRICD */
int area_net_title(struct vty *vty, const char *net_title)
{
@@ -1511,6 +1513,7 @@ DEFUN (no_net,
return area_clear_net_title(vty, argv[idx_word]->arg);
}
#endif /* ifdef FABRICD */
+#ifdef FABRICD
DEFUN (isis_topology,
isis_topology_cmd,
"topology " ISIS_MT_NAMES " [overload]",
@@ -1575,6 +1578,7 @@ DEFUN (no_isis_topology,
area_set_mt_overload(area, mtid, false);
return CMD_SUCCESS;
}
+#endif /* ifdef FABRICD */
void isis_area_lsp_mtu_set(struct isis_area *area, unsigned int lsp_mtu)
{
@@ -2190,9 +2194,10 @@ void isis_init()
install_element(ROUTER_NODE, &net_cmd);
install_element(ROUTER_NODE, &no_net_cmd);
#endif /* ifdef FABRICD */
+#ifdef FABRICD
install_element(ROUTER_NODE, &isis_topology_cmd);
install_element(ROUTER_NODE, &no_isis_topology_cmd);
-
+#endif /* ifdef FABRICD */
install_element(ROUTER_NODE, &log_adj_changes_cmd);
install_element(ROUTER_NODE, &no_log_adj_changes_cmd);