diff options
| author | Igor Ryzhov <iryzhov@nfware.com> | 2021-03-10 17:31:57 +0300 | 
|---|---|---|
| committer | Igor Ryzhov <iryzhov@nfware.com> | 2021-03-16 22:14:57 +0300 | 
| commit | 4df3e31c3d09f83340e7c1a0d7645d0bdddcb68f (patch) | |
| tree | 01b36a351e9a10d91d25d5dd802bb7f09a69108c /bfdd/bfdd_cli.c | |
| parent | 81ef5048dd229570f27c524d6d6268caecf3b663 (diff) | |
bfdd: separate echo rx/tx timers
Currently there is a single interval for both RX and TX echo functions.
This commit introduces separate RX and TX timers for echo packets.
The main advantage is to be able to set the receive interval to zero
when we don't want to receive echo packets from the remote system.
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'bfdd/bfdd_cli.c')
| -rw-r--r-- | bfdd/bfdd_cli.c | 100 | 
1 files changed, 93 insertions, 7 deletions
diff --git a/bfdd/bfdd_cli.c b/bfdd/bfdd_cli.c index 206f6c7d0c..44e94eb898 100644 --- a/bfdd/bfdd_cli.c +++ b/bfdd/bfdd_cli.c @@ -451,8 +451,8 @@ void bfd_cli_show_echo(struct vty *vty, struct lyd_node *dnode,  DEFPY_YANG(  	bfd_peer_echo_interval, bfd_peer_echo_interval_cmd,  	"echo-interval (10-60000)$interval", -	"Configure peer echo interval\n" -	"Configure peer echo interval value in milliseconds\n") +	"Configure peer echo intervals\n" +	"Configure peer echo rx/tx intervals value in milliseconds\n")  {  	char value[32]; @@ -464,21 +464,88 @@ DEFPY_YANG(  	snprintf(value, sizeof(value), "%ld", interval * 1000);  	nb_cli_enqueue_change(vty, "./desired-echo-transmission-interval",  			      NB_OP_MODIFY, value); +	nb_cli_enqueue_change(vty, "./required-echo-receive-interval", +			      NB_OP_MODIFY, value); + +	return nb_cli_apply_changes(vty, NULL); +} + +DEFPY_YANG( +	bfd_peer_echo_transmit_interval, bfd_peer_echo_transmit_interval_cmd, +	"echo transmit-interval (10-60000)$interval", +	"Configure peer echo intervals\n" +	"Configure desired transmit interval\n" +	"Configure interval value in milliseconds\n") +{ +	char value[32]; + +	if (!bfd_cli_is_profile(vty) && !bfd_cli_is_single_hop(vty)) { +		vty_out(vty, "%% Echo mode is only available for single hop sessions.\n"); +		return CMD_WARNING_CONFIG_FAILED; +	} + +	snprintf(value, sizeof(value), "%ld", interval * 1000); +	nb_cli_enqueue_change(vty, "./desired-echo-transmission-interval", +			      NB_OP_MODIFY, value); + +	return nb_cli_apply_changes(vty, NULL); +} + +void bfd_cli_show_desired_echo_transmission_interval(struct vty *vty, +	struct lyd_node *dnode, bool show_defaults) +{ +	uint32_t value; + +	if (show_defaults) +		vty_out(vty, "  echo transmit-interval %d\n", +			BFD_DEF_DES_MIN_ECHO_TX); +	else { +		value = yang_dnode_get_uint32(dnode, NULL); +		vty_out(vty, "  echo transmit-interval %u\n", value / 1000); +	} +} + +DEFPY_YANG( +	bfd_peer_echo_receive_interval, bfd_peer_echo_receive_interval_cmd, +	"echo receive-interval <disabled$disabled|(10-60000)$interval>", +	"Configure peer echo intervals\n" +	"Configure required receive interval\n" +	"Disable echo packets receive\n" +	"Configure interval value in milliseconds\n") +{ +	char value[32]; + +	if (!bfd_cli_is_profile(vty) && !bfd_cli_is_single_hop(vty)) { +		vty_out(vty, "%% Echo mode is only available for single hop sessions.\n"); +		return CMD_WARNING_CONFIG_FAILED; +	} + +	if (disabled) +		snprintf(value, sizeof(value), "0"); +	else +		snprintf(value, sizeof(value), "%ld", interval * 1000); +	 +	nb_cli_enqueue_change(vty, "./required-echo-receive-interval", +			      NB_OP_MODIFY, value);  	return nb_cli_apply_changes(vty, NULL);  } -void bfd_cli_show_echo_interval(struct vty *vty, struct lyd_node *dnode, -				bool show_defaults) +void bfd_cli_show_required_echo_receive_interval(struct vty *vty, +	struct lyd_node *dnode, bool show_defaults)  {  	uint32_t value;  	if (show_defaults) -		vty_out(vty, "  echo-interval %d\n", -			BFD_DEF_REQ_MIN_ECHO); +		vty_out(vty, "  echo receive-interval %d\n", +			BFD_DEF_REQ_MIN_ECHO_RX);  	else {  		value = yang_dnode_get_uint32(dnode, NULL); -		vty_out(vty, "  echo-interval %u\n", value / 1000); +		if (value) +			vty_out(vty, "  echo receive-interval %u\n", +				value / 1000); +		else +			vty_out(vty, "  echo receive-interval disabled\n");  	}  } @@ -575,6 +642,21 @@ ALIAS_YANG(bfd_peer_echo_interval, bfd_profile_echo_interval_cmd,        "Configure peer echo interval\n"        "Configure peer echo interval value in milliseconds\n") +ALIAS_YANG( +	bfd_peer_echo_transmit_interval, bfd_profile_echo_transmit_interval_cmd, +	"echo transmit-interval (10-60000)$interval", +	"Configure peer echo intervals\n" +	"Configure desired transmit interval\n" +	"Configure interval value in milliseconds\n") + +ALIAS_YANG( +	bfd_peer_echo_receive_interval, bfd_profile_echo_receive_interval_cmd, +	"echo receive-interval <disabled$disabled|(10-60000)$interval>", +	"Configure peer echo intervals\n" +	"Configure required receive interval\n" +	"Disable echo packets receive\n" +	"Configure interval value in milliseconds\n") +  DEFPY_YANG(bfd_peer_profile, bfd_peer_profile_cmd,        "[no] profile BFDPROF$pname",        NO_STR @@ -632,6 +714,8 @@ bfdd_cli_init(void)  	install_element(BFD_PEER_NODE, &bfd_peer_tx_cmd);  	install_element(BFD_PEER_NODE, &bfd_peer_echo_cmd);  	install_element(BFD_PEER_NODE, &bfd_peer_echo_interval_cmd); +	install_element(BFD_PEER_NODE, &bfd_peer_echo_transmit_interval_cmd); +	install_element(BFD_PEER_NODE, &bfd_peer_echo_receive_interval_cmd);  	install_element(BFD_PEER_NODE, &bfd_peer_profile_cmd);  	install_element(BFD_PEER_NODE, &bfd_peer_passive_cmd);  	install_element(BFD_PEER_NODE, &bfd_peer_minimum_ttl_cmd); @@ -652,6 +736,8 @@ bfdd_cli_init(void)  	install_element(BFD_PROFILE_NODE, &bfd_profile_shutdown_cmd);  	install_element(BFD_PROFILE_NODE, &bfd_profile_echo_cmd);  	install_element(BFD_PROFILE_NODE, &bfd_profile_echo_interval_cmd); +	install_element(BFD_PROFILE_NODE, &bfd_profile_echo_transmit_interval_cmd); +	install_element(BFD_PROFILE_NODE, &bfd_profile_echo_receive_interval_cmd);  	install_element(BFD_PROFILE_NODE, &bfd_profile_passive_cmd);  	install_element(BFD_PROFILE_NODE, &bfd_profile_minimum_ttl_cmd);  	install_element(BFD_PROFILE_NODE, &no_bfd_profile_minimum_ttl_cmd);  | 
