Skip to content

Commit

Permalink
pathd: add dynamic candidate path metric [computed] keyword
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
pguibert6WIND committed Jan 2, 2024
1 parent 353ee7b commit 784c93c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion doc/user/pathd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ Configuration Commands
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.

Expand Down
24 changes: 17 additions & 7 deletions pathd/path_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ DEFPY(srte_candidate_no_affinity_filter, srte_candidate_no_affinity_filter_cmd,

DEFPY(srte_candidate_metric,
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"
"If the metric is bounded\n"
"IGP metric\n"
Expand All @@ -885,7 +885,8 @@ DEFPY(srte_candidate_metric,
"Domain Count metric\n"
"Border Node Count metric\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];
snprintf(xpath, sizeof(xpath), "./constraints/metrics[type='%s']/value",
Expand All @@ -899,12 +900,16 @@ DEFPY(srte_candidate_metric,
"./constraints/metrics[type='%s']/required", type);
nb_cli_enqueue_change(vty, xpath, NB_OP_MODIFY,
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);
}

DEFPY(srte_candidate_no_metric,
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
"Remove a metric constraint\n"
"If the metric is bounded\n"
Expand All @@ -930,7 +935,8 @@ DEFPY(srte_candidate_no_metric,
"Domain Count metric\n"
"Border Node Count metric\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];
snprintf(xpath, sizeof(xpath), "./constraints/metrics[type='%s']",
Expand Down Expand Up @@ -1164,7 +1170,8 @@ static void config_write_float(struct vty *vty, float value)

static void config_write_metric(struct vty *vty,
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);
if (name == NULL)
Expand All @@ -1173,23 +1180,26 @@ static void config_write_metric(struct vty *vty,
metric_type_name(type));
config_write_float(vty, value);
vty_out(vty, required ? " required" : "");
vty_out(vty, is_computed ? " computed" : "");
vty_out(vty, "\n");
}

static int config_write_metric_cb(const struct lyd_node *dnode, void *arg)
{
struct vty *vty = arg;
enum srte_candidate_metric_type type;
bool required, is_bound = false;
bool required, is_bound = false, is_computed = false;
float value;

type = yang_dnode_get_enum(dnode, "type");
value = (float)yang_dnode_get_dec64(dnode, "value");
required = yang_dnode_get_bool(dnode, "required");
if (yang_dnode_exists(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;
}

Expand Down

0 comments on commit 784c93c

Please sign in to comment.