diff options
| author | Emanuele Di Pascale <emanuele@voltanet.io> | 2018-11-14 12:56:49 +0100 | 
|---|---|---|
| committer | Emanuele Di Pascale <emanuele@voltanet.io> | 2018-12-18 15:23:49 +0100 | 
| commit | be49219c546ab7e533cae7ba2e540ce7d4d3c245 (patch) | |
| tree | 670253f726acd0d83801261f699a0106e1c9900c /isisd/isis_vty_fabricd.c | |
| parent | 3e20c83affb657cb9cc792ac86843df75343ca47 (diff) | |
isisd: retrofit the 'isis metric' command
Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
Diffstat (limited to 'isisd/isis_vty_fabricd.c')
| -rw-r--r-- | isisd/isis_vty_fabricd.c | 66 | 
1 files changed, 66 insertions, 0 deletions
diff --git a/isisd/isis_vty_fabricd.c b/isisd/isis_vty_fabricd.c index 0dcf12aa05..63dd646cb4 100644 --- a/isisd/isis_vty_fabricd.c +++ b/isisd/isis_vty_fabricd.c @@ -770,6 +770,69 @@ DEFUN (no_isis_passwd,  	return CMD_SUCCESS;  } +DEFUN (isis_metric, +       isis_metric_cmd, +       PROTO_NAME " metric (0-16777215)", +       PROTO_HELP +       "Set default metric for circuit\n" +       "Default metric value\n") +{ +	int idx_number = 2; +	int met; +	struct isis_circuit *circuit = isis_circuit_lookup(vty); +	if (!circuit) +		return CMD_ERR_NO_MATCH; + +	met = atoi(argv[idx_number]->arg); + +	/* RFC3787 section 5.1 */ +	if (circuit->area && circuit->area->oldmetric == 1 +	    && met > MAX_NARROW_LINK_METRIC) { +		vty_out(vty, +			"Invalid metric %d - should be <0-63> " +			"when narrow metric type enabled\n", +			met); +		return CMD_WARNING_CONFIG_FAILED; +	} + +	/* RFC4444 */ +	if (circuit->area && circuit->area->newmetric == 1 +	    && met > MAX_WIDE_LINK_METRIC) { +		vty_out(vty, +			"Invalid metric %d - should be <0-16777215> " +			"when wide metric type enabled\n", +			met); +		return CMD_WARNING_CONFIG_FAILED; +	} + +	CMD_FERR_RETURN(isis_circuit_metric_set(circuit, IS_LEVEL_1, met), +			"Failed to set L1 metric: $ERR"); +	CMD_FERR_RETURN(isis_circuit_metric_set(circuit, IS_LEVEL_2, met), +			"Failed to set L2 metric: $ERR"); +	return CMD_SUCCESS; +} + +DEFUN (no_isis_metric, +       no_isis_metric_cmd, +       "no " PROTO_NAME " metric [(0-16777215)]", +       NO_STR +       PROTO_HELP +       "Set default metric for circuit\n" +       "Default metric value\n") +{ +	struct isis_circuit *circuit = isis_circuit_lookup(vty); +	if (!circuit) +		return CMD_ERR_NO_MATCH; + +	CMD_FERR_RETURN(isis_circuit_metric_set(circuit, IS_LEVEL_1, +						DEFAULT_CIRCUIT_METRIC), +			"Failed to set L1 metric: $ERR"); +	CMD_FERR_RETURN(isis_circuit_metric_set(circuit, IS_LEVEL_2, +						DEFAULT_CIRCUIT_METRIC), +			"Failed to set L2 metric: $ERR"); +	return CMD_SUCCESS; +} +  void isis_vty_daemon_init(void)  {  	install_element(ROUTER_NODE, &fabric_tier_cmd); @@ -814,4 +877,7 @@ void isis_vty_daemon_init(void)  	install_element(INTERFACE_NODE, &isis_passwd_cmd);  	install_element(INTERFACE_NODE, &no_isis_passwd_cmd); + +	install_element(INTERFACE_NODE, &isis_metric_cmd); +	install_element(INTERFACE_NODE, &no_isis_metric_cmd);  }  | 
