mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-06-14 19:05:37 +00:00
isisd: don't use operational data in "ip/ipv6 router isis"
Currently the operational data is used for two things: - to inherit the is-type from the isis instance - to set passive flag for loopback interfaces This commit implements the first one using only the config data. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
This commit is contained in:
parent
95018cdaa5
commit
aaf8e80994
169
isisd/isis_cli.c
169
isisd/isis_cli.c
@ -159,78 +159,43 @@ DEFPY_YANG(ip_router_isis, ip_router_isis_cmd,
|
|||||||
"IS-IS routing protocol\n"
|
"IS-IS routing protocol\n"
|
||||||
"Routing process tag\n" VRF_CMD_HELP_STR)
|
"Routing process tag\n" VRF_CMD_HELP_STR)
|
||||||
{
|
{
|
||||||
char temp_xpath[XPATH_MAXLEN];
|
char inst_xpath[XPATH_MAXLEN];
|
||||||
const char *circ_type;
|
struct lyd_node *if_dnode, *inst_dnode;
|
||||||
struct isis_area *area = NULL;
|
const char *circ_type = NULL;
|
||||||
struct interface *ifp;
|
struct interface *ifp;
|
||||||
struct vrf *vrf;
|
|
||||||
|
|
||||||
/* area will be created if it is not present. make sure the yang model
|
if_dnode = yang_dnode_get(vty->candidate_config->dnode, VTY_CURR_XPATH);
|
||||||
* is synced with FRR and call the appropriate NB cb.
|
if (!if_dnode) {
|
||||||
*/
|
vty_out(vty, "%% Failed to get iface dnode in candidate DB\n");
|
||||||
|
|
||||||
if (!im) {
|
|
||||||
return CMD_SUCCESS;
|
|
||||||
}
|
|
||||||
ifp = nb_running_get_entry(NULL, VTY_CURR_XPATH, false);
|
|
||||||
if (!vrf_name) {
|
|
||||||
if (ifp) {
|
|
||||||
if (ifp->vrf_id == VRF_DEFAULT)
|
|
||||||
vrf_name = VRF_DEFAULT_NAME;
|
|
||||||
else {
|
|
||||||
vrf = vrf_lookup_by_id(ifp->vrf_id);
|
|
||||||
if (vrf && !vrf_name)
|
|
||||||
vrf_name = vrf->name;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
vrf_name = VRF_DEFAULT_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
area = isis_area_lookup_by_vrf(tag, vrf_name);
|
|
||||||
if (!area) {
|
|
||||||
snprintf(temp_xpath, XPATH_MAXLEN,
|
|
||||||
"/frr-isisd:isis/instance[area-tag='%s'][vrf='%s']",
|
|
||||||
tag, vrf_name);
|
|
||||||
nb_cli_enqueue_change(vty, temp_xpath, NB_OP_CREATE, tag);
|
|
||||||
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");
|
|
||||||
} else {
|
|
||||||
/* area exists, circuit type defaults to its area's is_type */
|
|
||||||
switch (area->is_type) {
|
|
||||||
case IS_LEVEL_1:
|
|
||||||
circ_type = "level-1";
|
|
||||||
break;
|
|
||||||
case IS_LEVEL_2:
|
|
||||||
circ_type = "level-2";
|
|
||||||
break;
|
|
||||||
case IS_LEVEL_1_AND_2:
|
|
||||||
circ_type = "level-1-2";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
/* just to silence compiler warnings */
|
|
||||||
return CMD_WARNING_CONFIG_FAILED;
|
return CMD_WARNING_CONFIG_FAILED;
|
||||||
}
|
}
|
||||||
nb_cli_enqueue_change(vty, "./frr-isisd:isis", NB_OP_CREATE,
|
|
||||||
NULL);
|
vrf_name = yang_dnode_get_string(if_dnode, "vrf");
|
||||||
nb_cli_enqueue_change(vty, "./frr-isisd:isis/area-tag",
|
|
||||||
NB_OP_MODIFY, tag);
|
snprintf(inst_xpath, XPATH_MAXLEN,
|
||||||
nb_cli_enqueue_change(vty, "./frr-isisd:isis/vrf", NB_OP_MODIFY,
|
"/frr-isisd:isis/instance[area-tag='%s'][vrf='%s']", tag,
|
||||||
vrf_name);
|
vrf_name);
|
||||||
|
|
||||||
|
/* if instance exists then inherit its type, create it otherwise */
|
||||||
|
inst_dnode = yang_dnode_get(vty->candidate_config->dnode, inst_xpath);
|
||||||
|
if (inst_dnode)
|
||||||
|
circ_type = yang_dnode_get_string(inst_dnode, "is-type");
|
||||||
|
else
|
||||||
|
nb_cli_enqueue_change(vty, inst_xpath, NB_OP_CREATE, 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_cli_enqueue_change(vty, "./frr-isisd:isis/ipv4-routing",
|
||||||
NB_OP_MODIFY, "true");
|
NB_OP_MODIFY, "true");
|
||||||
|
if (circ_type)
|
||||||
nb_cli_enqueue_change(vty, "./frr-isisd:isis/circuit-type",
|
nb_cli_enqueue_change(vty, "./frr-isisd:isis/circuit-type",
|
||||||
NB_OP_MODIFY, circ_type);
|
NB_OP_MODIFY, circ_type);
|
||||||
}
|
|
||||||
|
|
||||||
/* check if the interface is a loopback and if so set it as passive */
|
/* 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))
|
if (ifp && if_is_loopback(ifp))
|
||||||
nb_cli_enqueue_change(vty, "./frr-isisd:isis/passive",
|
nb_cli_enqueue_change(vty, "./frr-isisd:isis/passive",
|
||||||
NB_OP_MODIFY, "true");
|
NB_OP_MODIFY, "true");
|
||||||
@ -245,77 +210,43 @@ DEFPY_YANG(ip6_router_isis, ip6_router_isis_cmd,
|
|||||||
"IS-IS routing protocol\n"
|
"IS-IS routing protocol\n"
|
||||||
"Routing process tag\n" VRF_CMD_HELP_STR)
|
"Routing process tag\n" VRF_CMD_HELP_STR)
|
||||||
{
|
{
|
||||||
char temp_xpath[XPATH_MAXLEN];
|
char inst_xpath[XPATH_MAXLEN];
|
||||||
const char *circ_type;
|
struct lyd_node *if_dnode, *inst_dnode;
|
||||||
|
const char *circ_type = NULL;
|
||||||
struct interface *ifp;
|
struct interface *ifp;
|
||||||
struct isis_area *area;
|
|
||||||
struct vrf *vrf;
|
|
||||||
|
|
||||||
/* area will be created if it is not present. make sure the yang model
|
if_dnode = yang_dnode_get(vty->candidate_config->dnode, VTY_CURR_XPATH);
|
||||||
* is synced with FRR and call the appropriate NB cb.
|
if (!if_dnode) {
|
||||||
*/
|
vty_out(vty, "%% Failed to get iface dnode in candidate DB\n");
|
||||||
|
|
||||||
if (!im)
|
|
||||||
return CMD_SUCCESS;
|
|
||||||
|
|
||||||
ifp = nb_running_get_entry(NULL, VTY_CURR_XPATH, false);
|
|
||||||
if (!vrf_name) {
|
|
||||||
if (ifp) {
|
|
||||||
if (ifp->vrf_id == VRF_DEFAULT)
|
|
||||||
vrf_name = VRF_DEFAULT_NAME;
|
|
||||||
else {
|
|
||||||
vrf = vrf_lookup_by_id(ifp->vrf_id);
|
|
||||||
if (vrf && !vrf_name)
|
|
||||||
vrf_name = vrf->name;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
vrf_name = VRF_DEFAULT_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
area = isis_area_lookup_by_vrf(tag, vrf_name);
|
|
||||||
if (!area) {
|
|
||||||
snprintf(temp_xpath, XPATH_MAXLEN,
|
|
||||||
"/frr-isisd:isis/instance[area-tag='%s'][vrf='%s']",
|
|
||||||
tag, vrf_name);
|
|
||||||
nb_cli_enqueue_change(vty, temp_xpath, NB_OP_CREATE, tag);
|
|
||||||
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");
|
|
||||||
} else {
|
|
||||||
/* area exists, circuit type defaults to its area's is_type */
|
|
||||||
switch (area->is_type) {
|
|
||||||
case IS_LEVEL_1:
|
|
||||||
circ_type = "level-1";
|
|
||||||
break;
|
|
||||||
case IS_LEVEL_2:
|
|
||||||
circ_type = "level-2";
|
|
||||||
break;
|
|
||||||
case IS_LEVEL_1_AND_2:
|
|
||||||
circ_type = "level-1-2";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
/* just to silence compiler warnings */
|
|
||||||
return CMD_WARNING_CONFIG_FAILED;
|
return CMD_WARNING_CONFIG_FAILED;
|
||||||
}
|
}
|
||||||
nb_cli_enqueue_change(vty, "./frr-isisd:isis", NB_OP_CREATE,
|
|
||||||
NULL);
|
vrf_name = yang_dnode_get_string(if_dnode, "vrf");
|
||||||
nb_cli_enqueue_change(vty, "./frr-isisd:isis/area-tag",
|
|
||||||
NB_OP_MODIFY, tag);
|
snprintf(inst_xpath, XPATH_MAXLEN,
|
||||||
|
"/frr-isisd:isis/instance[area-tag='%s'][vrf='%s']", tag,
|
||||||
|
vrf_name);
|
||||||
|
|
||||||
|
/* if instance exists then inherit its type, create it otherwise */
|
||||||
|
inst_dnode = yang_dnode_get(vty->candidate_config->dnode, inst_xpath);
|
||||||
|
if (inst_dnode)
|
||||||
|
circ_type = yang_dnode_get_string(inst_dnode, "is-type");
|
||||||
|
else
|
||||||
|
nb_cli_enqueue_change(vty, inst_xpath, NB_OP_CREATE, 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,
|
nb_cli_enqueue_change(vty, "./frr-isisd:isis/vrf", NB_OP_MODIFY,
|
||||||
vrf_name);
|
vrf_name);
|
||||||
nb_cli_enqueue_change(vty, "./frr-isisd:isis/ipv6-routing",
|
nb_cli_enqueue_change(vty, "./frr-isisd:isis/ipv6-routing",
|
||||||
NB_OP_MODIFY, "true");
|
NB_OP_MODIFY, "true");
|
||||||
|
if (circ_type)
|
||||||
nb_cli_enqueue_change(vty, "./frr-isisd:isis/circuit-type",
|
nb_cli_enqueue_change(vty, "./frr-isisd:isis/circuit-type",
|
||||||
NB_OP_MODIFY, circ_type);
|
NB_OP_MODIFY, circ_type);
|
||||||
}
|
|
||||||
|
|
||||||
/* check if the interface is a loopback and if so set it as passive */
|
/* 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))
|
if (ifp && if_is_loopback(ifp))
|
||||||
nb_cli_enqueue_change(vty, "./frr-isisd:isis/passive",
|
nb_cli_enqueue_change(vty, "./frr-isisd:isis/passive",
|
||||||
NB_OP_MODIFY, "true");
|
NB_OP_MODIFY, "true");
|
||||||
|
Loading…
Reference in New Issue
Block a user