mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-13 21:10:28 +00:00
zebra: convert interface link-params delay commands to NB
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
This commit is contained in:
parent
217b65e5bf
commit
0a5b944aef
@ -2165,6 +2165,47 @@ module frr-zebra {
|
||||
"IPv4 Remote ASBR ID (RFC 5316 & RFC 5392)";
|
||||
}
|
||||
}
|
||||
leaf delay {
|
||||
type uint32 {
|
||||
range "0..16777215";
|
||||
}
|
||||
description
|
||||
"Average Unidirectional Link Delay";
|
||||
}
|
||||
container min-max-delay {
|
||||
description
|
||||
"Min/Max Unidirectional Link Delay";
|
||||
presence "Activates min/max delay.";
|
||||
leaf delay-min {
|
||||
type uint32 {
|
||||
range "0..16777215";
|
||||
}
|
||||
must '. <= ../../delay' {
|
||||
error-message "Min delay must be less than or equal to delay";
|
||||
}
|
||||
mandatory true;
|
||||
description
|
||||
"Min Delay";
|
||||
}
|
||||
leaf delay-max {
|
||||
type uint32 {
|
||||
range "0..16777215";
|
||||
}
|
||||
must '. >= ../../delay' {
|
||||
error-message "Max delay must be greater than or equal to delay";
|
||||
}
|
||||
mandatory true;
|
||||
description
|
||||
"Max Delay";
|
||||
}
|
||||
}
|
||||
leaf delay-variation {
|
||||
type uint32 {
|
||||
range "0..16777215";
|
||||
}
|
||||
description
|
||||
"Unidirectional Delay Variation";
|
||||
}
|
||||
// TODO -- other link-params options
|
||||
// for (experimental/partial TE use in IGP extensions)
|
||||
}
|
||||
|
@ -4155,9 +4155,10 @@ DEFPY_YANG (link_params_inter_as,
|
||||
|
||||
/* RFC7471: OSPF Traffic Engineering (TE) Metric extensions &
|
||||
* draft-ietf-isis-metric-extensions-07.txt */
|
||||
DEFUN (link_params_delay,
|
||||
DEFPY_YANG (link_params_delay,
|
||||
link_params_delay_cmd,
|
||||
"delay (0-16777215) [min (0-16777215) max (0-16777215)]",
|
||||
"[no] delay ![(0-16777215)$delay [min (0-16777215)$min max (0-16777215)$max]]",
|
||||
NO_STR
|
||||
"Unidirectional Average Link Delay\n"
|
||||
"Average delay in micro-second as decimal (0...16777215)\n"
|
||||
"Minimum delay\n"
|
||||
@ -4165,149 +4166,43 @@ DEFUN (link_params_delay,
|
||||
"Maximum delay\n"
|
||||
"Maximum delay in micro-second as decimal (0...16777215)\n")
|
||||
{
|
||||
/* Get and Check new delay values */
|
||||
uint32_t delay = 0, low = 0, high = 0;
|
||||
delay = strtoul(argv[1]->arg, NULL, 10);
|
||||
if (argc == 6) {
|
||||
low = strtoul(argv[3]->arg, NULL, 10);
|
||||
high = strtoul(argv[5]->arg, NULL, 10);
|
||||
}
|
||||
|
||||
VTY_DECLVAR_CONTEXT(interface, ifp);
|
||||
struct if_link_params *iflp = if_link_params_get(ifp);
|
||||
uint8_t update = 0;
|
||||
|
||||
if (argc == 2) {
|
||||
/*
|
||||
* Check new delay value against old Min and Max delays if set
|
||||
*
|
||||
* RFC 7471 Section 4.2.7:
|
||||
* It is possible for min delay and max delay to be
|
||||
* the same value.
|
||||
*
|
||||
* Therefore, it is also allowed that the average
|
||||
* delay be equal to the min delay or max delay.
|
||||
*/
|
||||
if (iflp && IS_PARAM_SET(iflp, LP_MM_DELAY) &&
|
||||
(delay < iflp->min_delay || delay > iflp->max_delay)) {
|
||||
vty_out(vty,
|
||||
"Average delay should be in range Min (%d) - Max (%d) delay\n",
|
||||
iflp->min_delay, iflp->max_delay);
|
||||
return CMD_WARNING_CONFIG_FAILED;
|
||||
}
|
||||
|
||||
if (!iflp)
|
||||
iflp = if_link_params_enable(ifp);
|
||||
|
||||
/* Update delay if value is not set or change */
|
||||
if (IS_PARAM_UNSET(iflp, LP_DELAY) || iflp->av_delay != delay) {
|
||||
iflp->av_delay = delay;
|
||||
SET_PARAM(iflp, LP_DELAY);
|
||||
update = 1;
|
||||
}
|
||||
/* Unset Min and Max delays if already set */
|
||||
if (IS_PARAM_SET(iflp, LP_MM_DELAY)) {
|
||||
iflp->min_delay = 0;
|
||||
iflp->max_delay = 0;
|
||||
UNSET_PARAM(iflp, LP_MM_DELAY);
|
||||
update = 1;
|
||||
if (!no) {
|
||||
nb_cli_enqueue_change(vty, "./delay", NB_OP_MODIFY, delay_str);
|
||||
if (min_str && max_str) {
|
||||
nb_cli_enqueue_change(vty, "./min-max-delay",
|
||||
NB_OP_CREATE, NULL);
|
||||
nb_cli_enqueue_change(vty, "./min-max-delay/delay-min",
|
||||
NB_OP_MODIFY, min_str);
|
||||
nb_cli_enqueue_change(vty, "./min-max-delay/delay-max",
|
||||
NB_OP_MODIFY, max_str);
|
||||
} else {
|
||||
nb_cli_enqueue_change(vty, "./min-max-delay",
|
||||
NB_OP_DESTROY, NULL);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Check new delays value coherency. See above note
|
||||
* regarding average delay equal to min/max allowed
|
||||
*/
|
||||
if (delay < low || delay > high) {
|
||||
vty_out(vty,
|
||||
"Average delay should be in range Min (%d) - Max (%d) delay\n",
|
||||
low, high);
|
||||
return CMD_WARNING_CONFIG_FAILED;
|
||||
}
|
||||
|
||||
if (!iflp)
|
||||
iflp = if_link_params_enable(ifp);
|
||||
|
||||
/* Update Delays if needed */
|
||||
if (IS_PARAM_UNSET(iflp, LP_DELAY)
|
||||
|| IS_PARAM_UNSET(iflp, LP_MM_DELAY)
|
||||
|| iflp->av_delay != delay || iflp->min_delay != low
|
||||
|| iflp->max_delay != high) {
|
||||
iflp->av_delay = delay;
|
||||
SET_PARAM(iflp, LP_DELAY);
|
||||
iflp->min_delay = low;
|
||||
iflp->max_delay = high;
|
||||
SET_PARAM(iflp, LP_MM_DELAY);
|
||||
update = 1;
|
||||
}
|
||||
nb_cli_enqueue_change(vty, "./delay", NB_OP_DESTROY, NULL);
|
||||
nb_cli_enqueue_change(vty, "./min-max-delay", NB_OP_DESTROY,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/* force protocols to update LINK STATE due to parameters change */
|
||||
if (update == 1 && if_is_operative(ifp))
|
||||
zebra_interface_parameters_update(ifp);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
return nb_cli_apply_changes(vty, NULL);
|
||||
}
|
||||
|
||||
DEFUN (no_link_params_delay,
|
||||
no_link_params_delay_cmd,
|
||||
"no delay",
|
||||
NO_STR
|
||||
"Disable Unidirectional Average, Min & Max Link Delay on this interface\n")
|
||||
{
|
||||
VTY_DECLVAR_CONTEXT(interface, ifp);
|
||||
struct if_link_params *iflp = if_link_params_get(ifp);
|
||||
|
||||
if (!iflp)
|
||||
return CMD_SUCCESS;
|
||||
|
||||
/* Unset Delays */
|
||||
iflp->av_delay = 0;
|
||||
UNSET_PARAM(iflp, LP_DELAY);
|
||||
iflp->min_delay = 0;
|
||||
iflp->max_delay = 0;
|
||||
UNSET_PARAM(iflp, LP_MM_DELAY);
|
||||
|
||||
/* force protocols to update LINK STATE due to parameters change */
|
||||
if (if_is_operative(ifp))
|
||||
zebra_interface_parameters_update(ifp);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN (link_params_delay_var,
|
||||
DEFPY_YANG (link_params_delay_var,
|
||||
link_params_delay_var_cmd,
|
||||
"delay-variation (0-16777215)",
|
||||
"[no] delay-variation ![(0-16777215)$delay_var]",
|
||||
NO_STR
|
||||
"Unidirectional Link Delay Variation\n"
|
||||
"delay variation in micro-second as decimal (0...16777215)\n")
|
||||
{
|
||||
int idx_number = 1;
|
||||
VTY_DECLVAR_CONTEXT(interface, ifp);
|
||||
struct if_link_params *iflp = if_link_params_get(ifp);
|
||||
uint32_t value;
|
||||
if (!no)
|
||||
nb_cli_enqueue_change(vty, "./delay-variation", NB_OP_MODIFY,
|
||||
delay_var_str);
|
||||
else
|
||||
nb_cli_enqueue_change(vty, "./delay-variation", NB_OP_DESTROY,
|
||||
NULL);
|
||||
|
||||
value = strtoul(argv[idx_number]->arg, NULL, 10);
|
||||
|
||||
if (!iflp)
|
||||
iflp = if_link_params_enable(ifp);
|
||||
|
||||
/* Update Delay Variation if needed */
|
||||
link_param_cmd_set_uint32(ifp, &iflp->delay_var, LP_DELAY_VAR, value);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN (no_link_params_delay_var,
|
||||
no_link_params_delay_var_cmd,
|
||||
"no delay-variation",
|
||||
NO_STR
|
||||
"Disable Unidirectional Delay Variation on this interface\n")
|
||||
{
|
||||
VTY_DECLVAR_CONTEXT(interface, ifp);
|
||||
|
||||
/* Unset Delay Variation */
|
||||
link_param_cmd_unset(ifp, LP_DELAY_VAR);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
return nb_cli_apply_changes(vty, NULL);
|
||||
}
|
||||
|
||||
DEFUN (link_params_pkt_loss,
|
||||
@ -5001,9 +4896,7 @@ void zebra_if_init(void)
|
||||
install_element(LINK_PARAMS_NODE, &no_link_params_admin_grp_cmd);
|
||||
install_element(LINK_PARAMS_NODE, &link_params_inter_as_cmd);
|
||||
install_element(LINK_PARAMS_NODE, &link_params_delay_cmd);
|
||||
install_element(LINK_PARAMS_NODE, &no_link_params_delay_cmd);
|
||||
install_element(LINK_PARAMS_NODE, &link_params_delay_var_cmd);
|
||||
install_element(LINK_PARAMS_NODE, &no_link_params_delay_var_cmd);
|
||||
install_element(LINK_PARAMS_NODE, &link_params_pkt_loss_cmd);
|
||||
install_element(LINK_PARAMS_NODE, &no_link_params_pkt_loss_cmd);
|
||||
install_element(LINK_PARAMS_NODE, &link_params_ava_bw_cmd);
|
||||
|
@ -467,6 +467,39 @@ const struct frr_yang_module_info frr_zebra_info = {
|
||||
.modify = lib_interface_zebra_link_params_neighbor_ipv4_remote_id_modify,
|
||||
}
|
||||
},
|
||||
{
|
||||
.xpath = "/frr-interface:lib/interface/frr-zebra:zebra/link-params/delay",
|
||||
.cbs = {
|
||||
.modify = lib_interface_zebra_link_params_delay_modify,
|
||||
.destroy = lib_interface_zebra_link_params_delay_destroy,
|
||||
}
|
||||
},
|
||||
{
|
||||
.xpath = "/frr-interface:lib/interface/frr-zebra:zebra/link-params/min-max-delay",
|
||||
.cbs = {
|
||||
.create = lib_interface_zebra_link_params_min_max_delay_create,
|
||||
.destroy = lib_interface_zebra_link_params_min_max_delay_destroy,
|
||||
}
|
||||
},
|
||||
{
|
||||
.xpath = "/frr-interface:lib/interface/frr-zebra:zebra/link-params/min-max-delay/delay-min",
|
||||
.cbs = {
|
||||
.modify = lib_interface_zebra_link_params_min_max_delay_delay_min_modify,
|
||||
}
|
||||
},
|
||||
{
|
||||
.xpath = "/frr-interface:lib/interface/frr-zebra:zebra/link-params/min-max-delay/delay-max",
|
||||
.cbs = {
|
||||
.modify = lib_interface_zebra_link_params_min_max_delay_delay_max_modify,
|
||||
}
|
||||
},
|
||||
{
|
||||
.xpath = "/frr-interface:lib/interface/frr-zebra:zebra/link-params/delay-variation",
|
||||
.cbs = {
|
||||
.modify = lib_interface_zebra_link_params_delay_variation_modify,
|
||||
.destroy = lib_interface_zebra_link_params_delay_variation_destroy,
|
||||
}
|
||||
},
|
||||
{
|
||||
.xpath = "/frr-interface:lib/interface/frr-zebra:zebra/state/up-count",
|
||||
.cbs = {
|
||||
|
@ -147,6 +147,21 @@ int lib_interface_zebra_link_params_neighbor_remote_as_modify(
|
||||
struct nb_cb_modify_args *args);
|
||||
int lib_interface_zebra_link_params_neighbor_ipv4_remote_id_modify(
|
||||
struct nb_cb_modify_args *args);
|
||||
int lib_interface_zebra_link_params_delay_modify(struct nb_cb_modify_args *args);
|
||||
int lib_interface_zebra_link_params_delay_destroy(
|
||||
struct nb_cb_destroy_args *args);
|
||||
int lib_interface_zebra_link_params_min_max_delay_create(
|
||||
struct nb_cb_create_args *args);
|
||||
int lib_interface_zebra_link_params_min_max_delay_destroy(
|
||||
struct nb_cb_destroy_args *args);
|
||||
int lib_interface_zebra_link_params_min_max_delay_delay_min_modify(
|
||||
struct nb_cb_modify_args *args);
|
||||
int lib_interface_zebra_link_params_min_max_delay_delay_max_modify(
|
||||
struct nb_cb_modify_args *args);
|
||||
int lib_interface_zebra_link_params_delay_variation_modify(
|
||||
struct nb_cb_modify_args *args);
|
||||
int lib_interface_zebra_link_params_delay_variation_destroy(
|
||||
struct nb_cb_destroy_args *args);
|
||||
struct yang_data *
|
||||
lib_interface_zebra_state_up_count_get_elem(struct nb_cb_get_elem_args *args);
|
||||
struct yang_data *
|
||||
|
@ -1979,6 +1979,187 @@ int lib_interface_zebra_link_params_neighbor_ipv4_remote_id_modify(
|
||||
return NB_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* XPath: /frr-interface:lib/interface/frr-zebra:zebra/link-params/delay
|
||||
*/
|
||||
int lib_interface_zebra_link_params_delay_modify(struct nb_cb_modify_args *args)
|
||||
{
|
||||
struct interface *ifp;
|
||||
struct if_link_params *iflp;
|
||||
uint32_t delay;
|
||||
|
||||
if (args->event != NB_EV_APPLY)
|
||||
return NB_OK;
|
||||
|
||||
delay = yang_dnode_get_uint32(args->dnode, NULL);
|
||||
|
||||
ifp = nb_running_get_entry(args->dnode, NULL, true);
|
||||
iflp = if_link_params_get(ifp);
|
||||
|
||||
link_param_cmd_set_uint32(ifp, &iflp->av_delay, LP_DELAY, delay);
|
||||
|
||||
return NB_OK;
|
||||
}
|
||||
|
||||
int lib_interface_zebra_link_params_delay_destroy(struct nb_cb_destroy_args *args)
|
||||
{
|
||||
struct interface *ifp;
|
||||
struct if_link_params *iflp;
|
||||
|
||||
if (args->event != NB_EV_APPLY)
|
||||
return NB_OK;
|
||||
|
||||
ifp = nb_running_get_entry(args->dnode, NULL, true);
|
||||
iflp = if_link_params_get(ifp);
|
||||
|
||||
iflp->av_delay = 0;
|
||||
link_param_cmd_unset(ifp, LP_DELAY);
|
||||
|
||||
return NB_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* XPath: /frr-interface:lib/interface/frr-zebra:zebra/link-params/min-max-delay
|
||||
*/
|
||||
int lib_interface_zebra_link_params_min_max_delay_create(
|
||||
struct nb_cb_create_args *args)
|
||||
{
|
||||
struct interface *ifp;
|
||||
struct if_link_params *iflp;
|
||||
uint32_t delay_min, delay_max;
|
||||
|
||||
if (args->event != NB_EV_APPLY)
|
||||
return NB_OK;
|
||||
|
||||
delay_min = yang_dnode_get_uint32(args->dnode, "delay-min");
|
||||
delay_max = yang_dnode_get_uint32(args->dnode, "delay-max");
|
||||
|
||||
ifp = nb_running_get_entry(args->dnode, NULL, true);
|
||||
iflp = if_link_params_get(ifp);
|
||||
|
||||
iflp->min_delay = delay_min;
|
||||
iflp->max_delay = delay_max;
|
||||
SET_PARAM(iflp, LP_MM_DELAY);
|
||||
|
||||
if (if_is_operative(ifp))
|
||||
zebra_interface_parameters_update(ifp);
|
||||
|
||||
return NB_OK;
|
||||
}
|
||||
|
||||
int lib_interface_zebra_link_params_min_max_delay_destroy(
|
||||
struct nb_cb_destroy_args *args)
|
||||
{
|
||||
struct interface *ifp;
|
||||
struct if_link_params *iflp;
|
||||
|
||||
if (args->event != NB_EV_APPLY)
|
||||
return NB_OK;
|
||||
|
||||
ifp = nb_running_get_entry(args->dnode, NULL, true);
|
||||
iflp = if_link_params_get(ifp);
|
||||
|
||||
iflp->min_delay = 0;
|
||||
iflp->max_delay = 0;
|
||||
UNSET_PARAM(iflp, LP_MM_DELAY);
|
||||
|
||||
if (if_is_operative(ifp))
|
||||
zebra_interface_parameters_update(ifp);
|
||||
|
||||
return NB_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* XPath: /frr-interface:lib/interface/frr-zebra:zebra/link-params/min-max-delay/delay-min
|
||||
*/
|
||||
int lib_interface_zebra_link_params_min_max_delay_delay_min_modify(
|
||||
struct nb_cb_modify_args *args)
|
||||
{
|
||||
struct interface *ifp;
|
||||
struct if_link_params *iflp;
|
||||
uint32_t delay_min;
|
||||
|
||||
if (args->event != NB_EV_APPLY)
|
||||
return NB_OK;
|
||||
|
||||
delay_min = yang_dnode_get_uint32(args->dnode, NULL);
|
||||
|
||||
ifp = nb_running_get_entry(args->dnode, NULL, true);
|
||||
iflp = if_link_params_get(ifp);
|
||||
|
||||
iflp->min_delay = delay_min;
|
||||
|
||||
if (if_is_operative(ifp))
|
||||
zebra_interface_parameters_update(ifp);
|
||||
|
||||
return NB_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* XPath: /frr-interface:lib/interface/frr-zebra:zebra/link-params/min-max-delay/delay-max
|
||||
*/
|
||||
int lib_interface_zebra_link_params_min_max_delay_delay_max_modify(
|
||||
struct nb_cb_modify_args *args)
|
||||
{
|
||||
struct interface *ifp;
|
||||
struct if_link_params *iflp;
|
||||
uint32_t delay_max;
|
||||
|
||||
if (args->event != NB_EV_APPLY)
|
||||
return NB_OK;
|
||||
|
||||
delay_max = yang_dnode_get_uint32(args->dnode, NULL);
|
||||
|
||||
ifp = nb_running_get_entry(args->dnode, NULL, true);
|
||||
iflp = if_link_params_get(ifp);
|
||||
|
||||
iflp->max_delay = delay_max;
|
||||
|
||||
if (if_is_operative(ifp))
|
||||
zebra_interface_parameters_update(ifp);
|
||||
|
||||
return NB_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* XPath: /frr-interface:lib/interface/frr-zebra:zebra/link-params/delay-variation
|
||||
*/
|
||||
int lib_interface_zebra_link_params_delay_variation_modify(
|
||||
struct nb_cb_modify_args *args)
|
||||
{
|
||||
struct interface *ifp;
|
||||
struct if_link_params *iflp;
|
||||
uint32_t delay_var;
|
||||
|
||||
if (args->event != NB_EV_APPLY)
|
||||
return NB_OK;
|
||||
|
||||
delay_var = yang_dnode_get_uint32(args->dnode, NULL);
|
||||
|
||||
ifp = nb_running_get_entry(args->dnode, NULL, true);
|
||||
iflp = if_link_params_get(ifp);
|
||||
|
||||
link_param_cmd_set_uint32(ifp, &iflp->delay_var, LP_DELAY_VAR,
|
||||
delay_var);
|
||||
|
||||
return NB_OK;
|
||||
}
|
||||
|
||||
int lib_interface_zebra_link_params_delay_variation_destroy(
|
||||
struct nb_cb_destroy_args *args)
|
||||
{
|
||||
struct interface *ifp;
|
||||
|
||||
if (args->event != NB_EV_APPLY)
|
||||
return NB_OK;
|
||||
|
||||
ifp = nb_running_get_entry(args->dnode, NULL, true);
|
||||
|
||||
link_param_cmd_unset(ifp, LP_DELAY_VAR);
|
||||
|
||||
return NB_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/l3vni-id
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user