summaryrefslogtreecommitdiff
path: root/isisd/isis_cli.c
diff options
context:
space:
mode:
Diffstat (limited to 'isisd/isis_cli.c')
-rw-r--r--isisd/isis_cli.c203
1 files changed, 142 insertions, 61 deletions
diff --git a/isisd/isis_cli.c b/isisd/isis_cli.c
index cd75116c50..31fe41db82 100644
--- a/isisd/isis_cli.c
+++ b/isisd/isis_cli.c
@@ -46,23 +46,33 @@
/*
* XPath: /frr-isisd:isis/instance
*/
-DEFPY_YANG_NOSH(router_isis, router_isis_cmd, "router isis WORD$tag",
- ROUTER_STR
- "ISO IS-IS\n"
- "ISO Routing area tag\n")
+DEFPY_YANG_NOSH(router_isis, router_isis_cmd,
+ "router isis WORD$tag [vrf NAME$vrf_name]",
+ ROUTER_STR
+ "ISO IS-IS\n"
+ "ISO Routing area tag\n" VRF_CMD_HELP_STR)
{
int ret;
char base_xpath[XPATH_MAXLEN];
+ if (!vrf_name)
+ vrf_name = VRF_DEFAULT_NAME;
+
snprintf(base_xpath, XPATH_MAXLEN,
- "/frr-isisd:isis/instance[area-tag='%s']", tag);
+ "/frr-isisd:isis/instance[area-tag='%s'][vrf='%s']", tag,
+ vrf_name);
nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL);
/* default value in yang for is-type is level-1, but in FRR
* the first instance is assigned is-type level-1-2. We
* need to make sure to set it in the yang model so that it
* is consistent with what FRR sees.
*/
- if (listcount(isis->area_list) == 0)
+
+ if (!im) {
+ return CMD_SUCCESS;
+ }
+
+ if (listcount(im->isis) == 0)
nb_cli_enqueue_change(vty, "./is-type", NB_OP_MODIFY,
"level-1-2");
ret = nb_cli_apply_changes(vty, base_xpath);
@@ -72,25 +82,30 @@ DEFPY_YANG_NOSH(router_isis, router_isis_cmd, "router isis WORD$tag",
return ret;
}
-DEFPY_YANG(no_router_isis, no_router_isis_cmd, "no router isis WORD$tag",
- NO_STR ROUTER_STR
- "ISO IS-IS\n"
- "ISO Routing area tag\n")
+DEFPY_YANG(no_router_isis, no_router_isis_cmd,
+ "no router isis WORD$tag [vrf NAME$vrf_name]",
+ NO_STR ROUTER_STR
+ "ISO IS-IS\n"
+ "ISO Routing area tag\n" VRF_CMD_HELP_STR)
{
char temp_xpath[XPATH_MAXLEN];
struct listnode *node, *nnode;
struct isis_circuit *circuit = NULL;
struct isis_area *area = NULL;
- if (!yang_dnode_exists(vty->candidate_config->dnode,
- "/frr-isisd:isis/instance[area-tag='%s']",
- tag)) {
+ if (!vrf_name)
+ vrf_name = VRF_DEFAULT_NAME;
+
+ if (!yang_dnode_exists(
+ vty->candidate_config->dnode,
+ "/frr-isisd:isis/instance[area-tag='%s'][vrf='%s']", tag,
+ vrf_name)) {
vty_out(vty, "ISIS area %s not found.\n", tag);
return CMD_ERR_NOTHING_TODO;
}
nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL);
- area = isis_area_lookup(tag);
+ area = isis_area_lookup_by_vrf(tag, vrf_name);
if (area && area->circuit_list && listcount(area->circuit_list)) {
for (ALL_LIST_ELEMENTS(area->circuit_list, node, nnode,
circuit)) {
@@ -109,15 +124,23 @@ DEFPY_YANG(no_router_isis, no_router_isis_cmd, "no router isis WORD$tag",
}
return nb_cli_apply_changes(
- vty, "/frr-isisd:isis/instance[area-tag='%s']", tag);
+ vty, "/frr-isisd:isis/instance[area-tag='%s'][vrf='%s']", tag,
+ vrf_name);
}
void cli_show_router_isis(struct vty *vty, struct lyd_node *dnode,
bool show_defaults)
{
+ const char *vrf = NULL;
+
+ vrf = yang_dnode_get_string(dnode, "./vrf");
+
vty_out(vty, "!\n");
- vty_out(vty, "router isis %s\n",
+ vty_out(vty, "router isis %s ",
yang_dnode_get_string(dnode, "./area-tag"));
+ if (!strmatch(vrf, VRF_DEFAULT_NAME))
+ vty_out(vty, "vrf %s", yang_dnode_get_string(dnode, "./vrf"));
+ vty_out(vty, "\n");
}
/*
@@ -126,41 +149,62 @@ void cli_show_router_isis(struct vty *vty, struct lyd_node *dnode,
* XPath: /frr-interface:lib/interface/frr-isisd:isis/ipv6-routing
* XPath: /frr-isisd:isis/instance
*/
-DEFPY_YANG(ip_router_isis, ip_router_isis_cmd, "ip router isis WORD$tag",
- "Interface Internet Protocol config commands\n"
- "IP router interface commands\n"
- "IS-IS routing protocol\n"
- "Routing process tag\n")
+DEFPY_YANG(ip_router_isis, ip_router_isis_cmd,
+ "ip router isis WORD$tag [vrf NAME$vrf_name]",
+ "Interface Internet Protocol config commands\n"
+ "IP router interface commands\n"
+ "IS-IS routing protocol\n"
+ "Routing process tag\n" VRF_CMD_HELP_STR)
{
char temp_xpath[XPATH_MAXLEN];
const char *circ_type;
- struct isis_area *area;
+ struct isis_area *area = NULL;
struct interface *ifp;
+ struct vrf *vrf;
/* area will be created if it is not present. make sure the yang model
* is synced with FRR and call the appropriate NB cb.
*/
- area = isis_area_lookup(tag);
+
+ if (!im) {
+ return CMD_SUCCESS;
+ }
+ ifp = nb_running_get_entry(NULL, VTY_CURR_XPATH, false);
+
+ if (!vrf_name && ifp->vrf_id == VRF_DEFAULT)
+ vrf_name = VRF_DEFAULT_NAME;
+
+ if (ifp->vrf_id != VRF_DEFAULT) {
+ vrf = vrf_lookup_by_id(ifp->vrf_id);
+ if (vrf && !vrf_name)
+ vrf_name = vrf->name;
+ }
+ area = isis_area_lookup_by_vrf(tag, vrf_name);
if (!area) {
+ isis_global_instance_create(vrf_name);
snprintf(temp_xpath, XPATH_MAXLEN,
- "/frr-isisd:isis/instance[area-tag='%s']", tag);
+ "/frr-isisd:isis/instance[area-tag='%s'][vrf='%s']",
+ tag, vrf_name);
nb_cli_enqueue_change(vty, temp_xpath, NB_OP_CREATE, tag);
- snprintf(temp_xpath, XPATH_MAXLEN,
- "/frr-isisd:isis/instance[area-tag='%s']/is-type",
- tag);
- nb_cli_enqueue_change(
- vty, temp_xpath, NB_OP_MODIFY,
- listcount(isis->area_list) == 0 ? "level-1-2" : NULL);
+ snprintf(
+ temp_xpath, XPATH_MAXLEN,
+ "/frr-isisd:isis/instance[area-tag='%s'][vrf='%s']/is-type",
+ tag, vrf_name);
+ nb_cli_enqueue_change(vty, temp_xpath, NB_OP_MODIFY,
+ listcount(im->isis) == 0 ? "level-1-2"
+ : NULL);
nb_cli_enqueue_change(vty, "./frr-isisd:isis", NB_OP_CREATE,
NULL);
nb_cli_enqueue_change(vty, "./frr-isisd:isis/area-tag",
NB_OP_MODIFY, tag);
+
+ nb_cli_enqueue_change(vty, "./frr-isisd:isis/vrf", NB_OP_MODIFY,
+ vrf_name);
nb_cli_enqueue_change(vty, "./frr-isisd:isis/ipv4-routing",
NB_OP_MODIFY, "true");
nb_cli_enqueue_change(
vty, "./frr-isisd:isis/circuit-type", NB_OP_MODIFY,
- listcount(isis->area_list) == 0 ? "level-1-2"
- : "level-1");
+ listcount(im->isis) == 0 ? "level-1-2" : "level-1");
} else {
/* area exists, circuit type defaults to its area's is_type */
switch (area->is_type) {
@@ -181,6 +225,9 @@ DEFPY_YANG(ip_router_isis, ip_router_isis_cmd, "ip router isis WORD$tag",
NULL);
nb_cli_enqueue_change(vty, "./frr-isisd:isis/area-tag",
NB_OP_MODIFY, tag);
+ nb_cli_enqueue_change(vty, "./frr-isisd:isis/vrf", NB_OP_MODIFY,
+ vrf_name);
+
nb_cli_enqueue_change(vty, "./frr-isisd:isis/ipv4-routing",
NB_OP_MODIFY, "true");
nb_cli_enqueue_change(vty, "./frr-isisd:isis/circuit-type",
@@ -188,7 +235,6 @@ DEFPY_YANG(ip_router_isis, ip_router_isis_cmd, "ip router isis WORD$tag",
}
/* check if the interface is a loopback and if so set it as passive */
- ifp = nb_running_get_entry(NULL, VTY_CURR_XPATH, false);
if (ifp && if_is_loopback(ifp))
nb_cli_enqueue_change(vty, "./frr-isisd:isis/passive",
NB_OP_MODIFY, "true");
@@ -196,41 +242,61 @@ DEFPY_YANG(ip_router_isis, ip_router_isis_cmd, "ip router isis WORD$tag",
return nb_cli_apply_changes(vty, NULL);
}
-DEFPY_YANG(ip6_router_isis, ip6_router_isis_cmd, "ipv6 router isis WORD$tag",
- "Interface Internet Protocol config commands\n"
- "IP router interface commands\n"
- "IS-IS routing protocol\n"
- "Routing process tag\n")
+DEFPY_YANG(ip6_router_isis, ip6_router_isis_cmd,
+ "ipv6 router isis WORD$tag [vrf NAME$vrf_name]",
+ "Interface Internet Protocol config commands\n"
+ "IP router interface commands\n"
+ "IS-IS routing protocol\n"
+ "Routing process tag\n" VRF_CMD_HELP_STR)
{
char temp_xpath[XPATH_MAXLEN];
const char *circ_type;
- struct isis_area *area;
struct interface *ifp;
+ struct isis_area *area;
+ struct vrf *vrf;
/* area will be created if it is not present. make sure the yang model
* is synced with FRR and call the appropriate NB cb.
*/
- area = isis_area_lookup(tag);
+
+ if (!im)
+ return CMD_SUCCESS;
+
+ ifp = nb_running_get_entry(NULL, VTY_CURR_XPATH, false);
+ if (!vrf_name && ifp->vrf_id == VRF_DEFAULT)
+ vrf_name = VRF_DEFAULT_NAME;
+
+ if (ifp->vrf_id != VRF_DEFAULT) {
+ vrf = vrf_lookup_by_id(ifp->vrf_id);
+ if (vrf && !vrf_name)
+ vrf_name = vrf->name;
+ }
+ area = isis_area_lookup_by_vrf(tag, vrf_name);
if (!area) {
+ isis_global_instance_create(vrf_name);
snprintf(temp_xpath, XPATH_MAXLEN,
- "/frr-isisd:isis/instance[area-tag='%s']", tag);
+ "/frr-isisd:isis/instance[area-tag='%s'][vrf='%s']",
+ tag, vrf_name);
nb_cli_enqueue_change(vty, temp_xpath, NB_OP_CREATE, tag);
- snprintf(temp_xpath, XPATH_MAXLEN,
- "/frr-isisd:isis/instance[area-tag='%s']/is-type",
- tag);
- nb_cli_enqueue_change(
- vty, temp_xpath, NB_OP_MODIFY,
- listcount(isis->area_list) == 0 ? "level-1-2" : NULL);
+ snprintf(
+ temp_xpath, XPATH_MAXLEN,
+ "/frr-isisd:isis/instance[area-tag='%s'][vrf='%s']/is-type",
+ tag, vrf_name);
+ nb_cli_enqueue_change(vty, temp_xpath, NB_OP_MODIFY,
+ listcount(im->isis) == 0 ? "level-1-2"
+ : NULL);
nb_cli_enqueue_change(vty, "./frr-isisd:isis", NB_OP_CREATE,
NULL);
nb_cli_enqueue_change(vty, "./frr-isisd:isis/area-tag",
NB_OP_MODIFY, tag);
+ nb_cli_enqueue_change(vty, "./frr-isisd:isis/vrf", NB_OP_MODIFY,
+ vrf_name);
+
nb_cli_enqueue_change(vty, "./frr-isisd:isis/ipv6-routing",
NB_OP_MODIFY, "true");
nb_cli_enqueue_change(
vty, "./frr-isisd:isis/circuit-type", NB_OP_MODIFY,
- listcount(isis->area_list) == 0 ? "level-1-2"
- : "level-1");
+ listcount(im->isis) == 0 ? "level-1-2" : "level-1");
} else {
/* area exists, circuit type defaults to its area's is_type */
switch (area->is_type) {
@@ -251,6 +317,8 @@ DEFPY_YANG(ip6_router_isis, ip6_router_isis_cmd, "ipv6 router isis WORD$tag",
NULL);
nb_cli_enqueue_change(vty, "./frr-isisd:isis/area-tag",
NB_OP_MODIFY, tag);
+ nb_cli_enqueue_change(vty, "./frr-isisd:isis/vrf", NB_OP_MODIFY,
+ vrf_name);
nb_cli_enqueue_change(vty, "./frr-isisd:isis/ipv6-routing",
NB_OP_MODIFY, "true");
nb_cli_enqueue_change(vty, "./frr-isisd:isis/circuit-type",
@@ -258,7 +326,6 @@ DEFPY_YANG(ip6_router_isis, ip6_router_isis_cmd, "ipv6 router isis WORD$tag",
}
/* check if the interface is a loopback and if so set it as passive */
- ifp = nb_running_get_entry(NULL, VTY_CURR_XPATH, false);
if (ifp && if_is_loopback(ifp))
nb_cli_enqueue_change(vty, "./frr-isisd:isis/passive",
NB_OP_MODIFY, "true");
@@ -267,13 +334,13 @@ DEFPY_YANG(ip6_router_isis, ip6_router_isis_cmd, "ipv6 router isis WORD$tag",
}
DEFPY_YANG(no_ip_router_isis, no_ip_router_isis_cmd,
- "no <ip|ipv6>$ip router isis [WORD]$tag",
- NO_STR
- "Interface Internet Protocol config commands\n"
- "IP router interface commands\n"
- "IP router interface commands\n"
- "IS-IS routing protocol\n"
- "Routing process tag\n")
+ "no <ip|ipv6>$ip router isis [WORD]$tag [vrf NAME$vrf_name]",
+ NO_STR
+ "Interface Internet Protocol config commands\n"
+ "IP router interface commands\n"
+ "IP router interface commands\n"
+ "IS-IS routing protocol\n"
+ "Routing process tag\n")
{
const struct lyd_node *dnode;
@@ -309,19 +376,33 @@ DEFPY_YANG(no_ip_router_isis, no_ip_router_isis_cmd,
void cli_show_ip_isis_ipv4(struct vty *vty, struct lyd_node *dnode,
bool show_defaults)
{
+ const char *vrf;
+
+ vrf = yang_dnode_get_string(dnode, "../vrf");
+
if (!yang_dnode_get_bool(dnode, NULL))
vty_out(vty, " no");
- vty_out(vty, " ip router isis %s\n",
+ vty_out(vty, " ip router isis %s ",
yang_dnode_get_string(dnode, "../area-tag"));
+ if (!strmatch(vrf, VRF_DEFAULT_NAME))
+ vty_out(vty, "vrf %s", vrf);
+ vty_out(vty, "\n");
}
void cli_show_ip_isis_ipv6(struct vty *vty, struct lyd_node *dnode,
bool show_defaults)
{
+ const char *vrf;
+
+ vrf = yang_dnode_get_string(dnode, "../vrf");
+
if (!yang_dnode_get_bool(dnode, NULL))
vty_out(vty, " no");
- vty_out(vty, " ipv6 router isis %s\n",
+ vty_out(vty, " ipv6 router isis %s ",
yang_dnode_get_string(dnode, "../area-tag"));
+ if (!strmatch(vrf, VRF_DEFAULT_NAME))
+ vty_out(vty, "vrf %s", vrf);
+ vty_out(vty, "\n");
}
/*
@@ -1154,7 +1235,7 @@ DEFPY_YANG(isis_default_originate, isis_default_originate_cmd,
"Distribute default route into level-2\n"
"Always advertise default route\n"
"Metric for default route\n"
- "ISIS default metric\n"
+ "IS-IS default metric\n"
"Route map reference\n"
"Pointer to route-map entries\n")
{
@@ -1228,7 +1309,7 @@ DEFPY_YANG(isis_redistribute, isis_redistribute_cmd,
"Redistribute into level-1\n"
"Redistribute into level-2\n"
"Metric for redistributed routes\n"
- "ISIS default metric\n"
+ "IS-IS default metric\n"
"Route map reference\n"
"Pointer to route-map entries\n")
{