mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-06-14 01:09:15 +00:00
isisd: retrofit the 'isis network' command
remove the return value and redundant validations from isis_circuit_circ_type_set(), since they are no longer needed. Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
This commit is contained in:
parent
9302fbb693
commit
d082076585
@ -1261,35 +1261,22 @@ struct cmd_node interface_node = {
|
||||
INTERFACE_NODE, "%s(config-if)# ", 1,
|
||||
};
|
||||
|
||||
ferr_r isis_circuit_circ_type_set(struct isis_circuit *circuit, int circ_type)
|
||||
void isis_circuit_circ_type_set(struct isis_circuit *circuit, int circ_type)
|
||||
{
|
||||
if (circuit->circ_type == circ_type)
|
||||
return ferr_ok();
|
||||
|
||||
/* Changing the network type to/of loopback or unknown interfaces
|
||||
* is not supported. */
|
||||
if (circ_type == CIRCUIT_T_UNKNOWN || circ_type == CIRCUIT_T_LOOPBACK
|
||||
|| circuit->circ_type == CIRCUIT_T_LOOPBACK) {
|
||||
return ferr_cfg_invalid(
|
||||
"cannot change network type on unknown interface");
|
||||
}
|
||||
return;
|
||||
|
||||
if (circuit->state != C_STATE_UP) {
|
||||
circuit->circ_type = circ_type;
|
||||
circuit->circ_type_config = circ_type;
|
||||
} else {
|
||||
struct isis_area *area = circuit->area;
|
||||
if (circ_type == CIRCUIT_T_BROADCAST
|
||||
&& !if_is_broadcast(circuit->interface))
|
||||
return ferr_cfg_reality(
|
||||
"cannot configure non-broadcast interface for broadcast operation");
|
||||
|
||||
isis_csm_state_change(ISIS_DISABLE, circuit, area);
|
||||
circuit->circ_type = circ_type;
|
||||
circuit->circ_type_config = circ_type;
|
||||
isis_csm_state_change(ISIS_ENABLE, circuit, area);
|
||||
}
|
||||
return ferr_ok();
|
||||
}
|
||||
|
||||
int isis_circuit_mt_enabled_set(struct isis_circuit *circuit, uint16_t mtid,
|
||||
|
@ -184,7 +184,7 @@ void isis_circuit_af_set(struct isis_circuit *circuit, bool ip_router,
|
||||
bool ipv6_router);
|
||||
ferr_r isis_circuit_passive_set(struct isis_circuit *circuit, bool passive);
|
||||
void isis_circuit_is_type_set(struct isis_circuit *circuit, int is_type);
|
||||
ferr_r isis_circuit_circ_type_set(struct isis_circuit *circuit, int circ_type);
|
||||
void isis_circuit_circ_type_set(struct isis_circuit *circuit, int circ_type);
|
||||
|
||||
ferr_r isis_circuit_metric_set(struct isis_circuit *circuit, int level,
|
||||
int metric);
|
||||
|
@ -1799,6 +1799,31 @@ void cli_show_ip_isis_circ_type(struct vty *vty, struct lyd_node *dnode,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* XPath: /frr-interface:lib/interface/frr-isisd:isis/network-type
|
||||
*/
|
||||
DEFPY(isis_network, isis_network_cmd, "[no] isis network point-to-point",
|
||||
NO_STR
|
||||
"IS-IS routing protocol\n"
|
||||
"Set network type\n"
|
||||
"point-to-point network type\n")
|
||||
{
|
||||
nb_cli_enqueue_change(vty, "./frr-isisd:isis/network-type",
|
||||
NB_OP_MODIFY,
|
||||
no ? "broadcast" : "point-to-point");
|
||||
|
||||
return nb_cli_apply_changes(vty, NULL);
|
||||
}
|
||||
|
||||
void cli_show_ip_isis_network_type(struct vty *vty, struct lyd_node *dnode,
|
||||
bool show_defaults)
|
||||
{
|
||||
if (yang_dnode_get_enum(dnode, NULL) != CIRCUIT_T_P2P)
|
||||
vty_out(vty, " no");
|
||||
|
||||
vty_out(vty, " isis network point-to-point\n");
|
||||
}
|
||||
|
||||
void isis_cli_init(void)
|
||||
{
|
||||
install_element(CONFIG_NODE, &router_isis_cmd);
|
||||
@ -1879,6 +1904,8 @@ void isis_cli_init(void)
|
||||
|
||||
install_element(INTERFACE_NODE, &isis_circuit_type_cmd);
|
||||
install_element(INTERFACE_NODE, &no_isis_circuit_type_cmd);
|
||||
|
||||
install_element(INTERFACE_NODE, &isis_network_cmd);
|
||||
}
|
||||
|
||||
#endif /* ifndef FABRICD */
|
||||
|
@ -115,5 +115,7 @@ void cli_show_ip_isis_mt_ipv6_dstsrc(struct vty *vty, struct lyd_node *dnode,
|
||||
bool show_defaults);
|
||||
void cli_show_ip_isis_circ_type(struct vty *vty, struct lyd_node *dnode,
|
||||
bool show_defaults);
|
||||
void cli_show_ip_isis_network_type(struct vty *vty, struct lyd_node *dnode,
|
||||
bool show_defaults);
|
||||
|
||||
#endif /* ISISD_ISIS_CLI_H_ */
|
||||
|
@ -2092,14 +2092,48 @@ static int lib_interface_isis_network_type_modify(enum nb_event event,
|
||||
const struct lyd_node *dnode,
|
||||
union nb_resource *resource)
|
||||
{
|
||||
/* TODO: implement me. */
|
||||
struct isis_circuit *circuit;
|
||||
int net_type = yang_dnode_get_enum(dnode, NULL);
|
||||
|
||||
switch (event) {
|
||||
case NB_EV_VALIDATE:
|
||||
circuit = yang_dnode_get_entry(dnode, false);
|
||||
if (!circuit)
|
||||
break;
|
||||
if (circuit->circ_type == CIRCUIT_T_LOOPBACK
|
||||
|| circuit->circ_type == CIRCUIT_T_UNKNOWN) {
|
||||
flog_warn(
|
||||
EC_LIB_NB_CB_CONFIG_VALIDATE,
|
||||
"Cannot change network type on unknown or loopback interface");
|
||||
return NB_ERR_VALIDATION;
|
||||
}
|
||||
if (net_type == CIRCUIT_T_BROADCAST
|
||||
&& circuit->state == C_STATE_UP
|
||||
&& !if_is_broadcast(circuit->interface)) {
|
||||
flog_warn(
|
||||
EC_LIB_NB_CB_CONFIG_VALIDATE,
|
||||
"Cannot configure non-broadcast interface for broadcast operation");
|
||||
return NB_ERR_VALIDATION;
|
||||
}
|
||||
break;
|
||||
case NB_EV_PREPARE:
|
||||
case NB_EV_ABORT:
|
||||
break;
|
||||
case NB_EV_APPLY:
|
||||
circuit = yang_dnode_get_entry(dnode, true);
|
||||
isis_circuit_circ_type_set(circuit, net_type);
|
||||
break;
|
||||
}
|
||||
|
||||
return NB_OK;
|
||||
}
|
||||
|
||||
static int lib_interface_isis_network_type_delete(enum nb_event event,
|
||||
const struct lyd_node *dnode)
|
||||
{
|
||||
/* TODO: implement me. */
|
||||
/* FIXME: This cannot be done in FRR. Not sure what the intended
|
||||
* behavior is.
|
||||
*/
|
||||
return NB_OK;
|
||||
}
|
||||
|
||||
@ -2813,6 +2847,7 @@ const struct frr_yang_module_info frr_isisd_info = {
|
||||
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/network-type",
|
||||
.cbs.modify = lib_interface_isis_network_type_modify,
|
||||
.cbs.delete = lib_interface_isis_network_type_delete,
|
||||
.cbs.cli_show = cli_show_ip_isis_network_type,
|
||||
},
|
||||
{
|
||||
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/passive",
|
||||
|
@ -43,47 +43,6 @@ static int level_for_arg(const char *arg)
|
||||
return IS_LEVEL_2;
|
||||
}
|
||||
|
||||
DEFUN (isis_network,
|
||||
isis_network_cmd,
|
||||
"isis network point-to-point",
|
||||
"IS-IS routing protocol\n"
|
||||
"Set network type\n"
|
||||
"point-to-point network type\n")
|
||||
{
|
||||
struct isis_circuit *circuit = isis_circuit_lookup(vty);
|
||||
if (!circuit)
|
||||
return CMD_ERR_NO_MATCH;
|
||||
|
||||
if (isis_circuit_circ_type_set(circuit, CIRCUIT_T_P2P)) {
|
||||
vty_out(vty,
|
||||
"isis network point-to-point is valid only on broadcast interfaces\n");
|
||||
return CMD_WARNING_CONFIG_FAILED;
|
||||
}
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN (no_isis_network,
|
||||
no_isis_network_cmd,
|
||||
"no isis network point-to-point",
|
||||
NO_STR
|
||||
"IS-IS routing protocol\n"
|
||||
"Set network type for circuit\n"
|
||||
"point-to-point network type\n")
|
||||
{
|
||||
struct isis_circuit *circuit = isis_circuit_lookup(vty);
|
||||
if (!circuit)
|
||||
return CMD_ERR_NO_MATCH;
|
||||
|
||||
if (isis_circuit_circ_type_set(circuit, CIRCUIT_T_BROADCAST)) {
|
||||
vty_out(vty,
|
||||
"isis network point-to-point is valid only on broadcast interfaces\n");
|
||||
return CMD_WARNING_CONFIG_FAILED;
|
||||
}
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN (isis_priority,
|
||||
isis_priority_cmd,
|
||||
"isis priority (0-127)",
|
||||
@ -161,9 +120,6 @@ DEFUN (no_isis_priority_level,
|
||||
|
||||
void isis_vty_daemon_init(void)
|
||||
{
|
||||
install_element(INTERFACE_NODE, &isis_network_cmd);
|
||||
install_element(INTERFACE_NODE, &no_isis_network_cmd);
|
||||
|
||||
install_element(INTERFACE_NODE, &isis_priority_cmd);
|
||||
install_element(INTERFACE_NODE, &no_isis_priority_cmd);
|
||||
install_element(INTERFACE_NODE, &isis_priority_level_cmd);
|
||||
|
Loading…
Reference in New Issue
Block a user