pathd: add dynamic candidate path metric [computed] keyword

Add the 'computed' keyword for a given metric.

> [..]
> metric te computed

When set by the PCC, the PCE must send back a computed metric
value in the PCResponse value.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
This commit is contained in:
Philippe Guibert 2024-01-02 11:49:57 +01:00
parent 353ee7bb81
commit 784c93cc62
2 changed files with 18 additions and 8 deletions

View File

@ -327,7 +327,7 @@ Configuration Commands
Delete or specify a bandwidth constraint for a dynamic candidate path. Delete or specify a bandwidth constraint for a dynamic candidate path.
.. clicmd:: metric [bound] METRIC VALUE [required] .. clicmd:: metric [bound] METRIC VALUE [required] [computed]
Delete or specify a metric constraint for a dynamic candidate path. Delete or specify a metric constraint for a dynamic candidate path.

View File

@ -860,7 +860,7 @@ DEFPY(srte_candidate_no_affinity_filter, srte_candidate_no_affinity_filter_cmd,
DEFPY(srte_candidate_metric, DEFPY(srte_candidate_metric,
srte_candidate_metric_cmd, srte_candidate_metric_cmd,
"metric [bound$bound] <igp|te|hc|abc|lmll|cigp|cte|pigp|pte|phc|msd|pd|pdv|pl|ppd|ppdv|ppl|nap|nlp|dc|bnc>$type METRIC$value [required$required]", "metric [bound$bound] <igp|te|hc|abc|lmll|cigp|cte|pigp|pte|phc|msd|pd|pdv|pl|ppd|ppdv|ppl|nap|nlp|dc|bnc>$type METRIC$value [required$required] [computed$computed]",
"Define a metric constraint\n" "Define a metric constraint\n"
"If the metric is bounded\n" "If the metric is bounded\n"
"IGP metric\n" "IGP metric\n"
@ -885,7 +885,8 @@ DEFPY(srte_candidate_metric,
"Domain Count metric\n" "Domain Count metric\n"
"Border Node Count metric\n" "Border Node Count metric\n"
"Metric value\n" "Metric value\n"
"Required constraint\n") "Required constraint\n"
"Force the PCE to provide the computed path metric\n")
{ {
char xpath[XPATH_CANDIDATE_MAXLEN]; char xpath[XPATH_CANDIDATE_MAXLEN];
snprintf(xpath, sizeof(xpath), "./constraints/metrics[type='%s']/value", snprintf(xpath, sizeof(xpath), "./constraints/metrics[type='%s']/value",
@ -899,12 +900,16 @@ DEFPY(srte_candidate_metric,
"./constraints/metrics[type='%s']/required", type); "./constraints/metrics[type='%s']/required", type);
nb_cli_enqueue_change(vty, xpath, NB_OP_MODIFY, nb_cli_enqueue_change(vty, xpath, NB_OP_MODIFY,
required ? "true" : "false"); required ? "true" : "false");
snprintf(xpath, sizeof(xpath),
"./constraints/metrics[type='%s']/is-computed", type);
nb_cli_enqueue_change(vty, xpath, NB_OP_MODIFY,
computed ? "true" : "false");
return nb_cli_apply_changes(vty, NULL); return nb_cli_apply_changes(vty, NULL);
} }
DEFPY(srte_candidate_no_metric, DEFPY(srte_candidate_no_metric,
srte_candidate_no_metric_cmd, srte_candidate_no_metric_cmd,
"no metric [bound] <igp|te|hc|abc|lmll|cigp|cte|pigp|pte|phc|msd|pd|pdv|pl|ppd|ppdv|ppl|nap|nlp|dc|bnc>$type [METRIC$value] [required$required]", "no metric [bound] <igp|te|hc|abc|lmll|cigp|cte|pigp|pte|phc|msd|pd|pdv|pl|ppd|ppdv|ppl|nap|nlp|dc|bnc>$type [METRIC$value] [required$required] [computed$computed]",
NO_STR NO_STR
"Remove a metric constraint\n" "Remove a metric constraint\n"
"If the metric is bounded\n" "If the metric is bounded\n"
@ -930,7 +935,8 @@ DEFPY(srte_candidate_no_metric,
"Domain Count metric\n" "Domain Count metric\n"
"Border Node Count metric\n" "Border Node Count metric\n"
"Metric value\n" "Metric value\n"
"Required constraint\n") "Required constraint\n"
"Force the PCE to provide the computed path metric\n")
{ {
char xpath[XPATH_CANDIDATE_MAXLEN]; char xpath[XPATH_CANDIDATE_MAXLEN];
snprintf(xpath, sizeof(xpath), "./constraints/metrics[type='%s']", snprintf(xpath, sizeof(xpath), "./constraints/metrics[type='%s']",
@ -1164,7 +1170,8 @@ static void config_write_float(struct vty *vty, float value)
static void config_write_metric(struct vty *vty, static void config_write_metric(struct vty *vty,
enum srte_candidate_metric_type type, enum srte_candidate_metric_type type,
float value, bool required, bool is_bound) float value, bool required, bool is_bound,
bool is_computed)
{ {
const char *name = metric_type_name(type); const char *name = metric_type_name(type);
if (name == NULL) if (name == NULL)
@ -1173,6 +1180,7 @@ static void config_write_metric(struct vty *vty,
metric_type_name(type)); metric_type_name(type));
config_write_float(vty, value); config_write_float(vty, value);
vty_out(vty, required ? " required" : ""); vty_out(vty, required ? " required" : "");
vty_out(vty, is_computed ? " computed" : "");
vty_out(vty, "\n"); vty_out(vty, "\n");
} }
@ -1180,7 +1188,7 @@ static int config_write_metric_cb(const struct lyd_node *dnode, void *arg)
{ {
struct vty *vty = arg; struct vty *vty = arg;
enum srte_candidate_metric_type type; enum srte_candidate_metric_type type;
bool required, is_bound = false; bool required, is_bound = false, is_computed = false;
float value; float value;
type = yang_dnode_get_enum(dnode, "type"); type = yang_dnode_get_enum(dnode, "type");
@ -1188,8 +1196,10 @@ static int config_write_metric_cb(const struct lyd_node *dnode, void *arg)
required = yang_dnode_get_bool(dnode, "required"); required = yang_dnode_get_bool(dnode, "required");
if (yang_dnode_exists(dnode, "is-bound")) if (yang_dnode_exists(dnode, "is-bound"))
is_bound = yang_dnode_get_bool(dnode, "is-bound"); is_bound = yang_dnode_get_bool(dnode, "is-bound");
if (yang_dnode_exists(dnode, "is-computed"))
is_computed = yang_dnode_get_bool(dnode, "is-computed");
config_write_metric(vty, type, value, required, is_bound); config_write_metric(vty, type, value, required, is_bound, is_computed);
return YANG_ITER_CONTINUE; return YANG_ITER_CONTINUE;
} }