mirror of
https://github.com/FRRouting/frr.git
synced 2025-04-30 13:37:17 +02:00
bgpd: Implement set metric aigp
command
Same as `set metric igp`, but in this case accumulated IGP metric is being sent as MED attribute. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
This commit is contained in:
parent
8d39cfd613
commit
e94f48498d
|
@ -127,6 +127,7 @@ o Local extensions
|
||||||
|
|
||||||
#define RMAP_VALUE_TYPE_RTT 1
|
#define RMAP_VALUE_TYPE_RTT 1
|
||||||
#define RMAP_VALUE_TYPE_IGP 2
|
#define RMAP_VALUE_TYPE_IGP 2
|
||||||
|
#define RMAP_VALUE_TYPE_AIGP 3
|
||||||
|
|
||||||
struct rmap_value {
|
struct rmap_value {
|
||||||
uint8_t action;
|
uint8_t action;
|
||||||
|
@ -155,6 +156,9 @@ static uint32_t route_value_adjust(struct rmap_value *rv, uint32_t current,
|
||||||
case RMAP_VALUE_TYPE_IGP:
|
case RMAP_VALUE_TYPE_IGP:
|
||||||
value = bpi->extra ? bpi->extra->igpmetric : 0;
|
value = bpi->extra ? bpi->extra->igpmetric : 0;
|
||||||
break;
|
break;
|
||||||
|
case RMAP_VALUE_TYPE_AIGP:
|
||||||
|
value = MIN(bpi->attr->aigp_metric, UINT32_MAX);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
value = rv->value;
|
value = rv->value;
|
||||||
break;
|
break;
|
||||||
|
@ -198,6 +202,8 @@ static void *route_value_compile(const char *arg)
|
||||||
var = RMAP_VALUE_TYPE_RTT;
|
var = RMAP_VALUE_TYPE_RTT;
|
||||||
} else if (strmatch(arg, "igp")) {
|
} else if (strmatch(arg, "igp")) {
|
||||||
var = RMAP_VALUE_TYPE_IGP;
|
var = RMAP_VALUE_TYPE_IGP;
|
||||||
|
} else if (strmatch(arg, "aigp")) {
|
||||||
|
var = RMAP_VALUE_TYPE_AIGP;
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -922,14 +922,15 @@ DEFPY_YANG(
|
||||||
|
|
||||||
DEFPY_YANG(
|
DEFPY_YANG(
|
||||||
set_metric, set_metric_cmd,
|
set_metric, set_metric_cmd,
|
||||||
"set metric <(-4294967295-4294967295)$metric|rtt$rtt|+rtt$artt|-rtt$srtt|igp$igp>",
|
"set metric <(-4294967295-4294967295)$metric|rtt$rtt|+rtt$artt|-rtt$srtt|igp$igp|aigp$aigp>",
|
||||||
SET_STR
|
SET_STR
|
||||||
"Metric value for destination routing protocol\n"
|
"Metric value for destination routing protocol\n"
|
||||||
"Metric value (use +/- for additions or subtractions)\n"
|
"Metric value (use +/- for additions or subtractions)\n"
|
||||||
"Assign round trip time\n"
|
"Assign round trip time\n"
|
||||||
"Add round trip time\n"
|
"Add round trip time\n"
|
||||||
"Subtract round trip time\n"
|
"Subtract round trip time\n"
|
||||||
"Metric value from IGP protocol\n")
|
"Metric value from IGP protocol\n"
|
||||||
|
"Metric value from AIGP (Accumulated IGP)\n")
|
||||||
{
|
{
|
||||||
const char *xpath = "./set-action[action='frr-route-map:set-metric']";
|
const char *xpath = "./set-action[action='frr-route-map:set-metric']";
|
||||||
char xpath_value[XPATH_MAXLEN];
|
char xpath_value[XPATH_MAXLEN];
|
||||||
|
@ -943,6 +944,9 @@ DEFPY_YANG(
|
||||||
} else if (igp) {
|
} else if (igp) {
|
||||||
snprintf(xpath_value, sizeof(xpath_value), "%s/rmap-set-action/use-igp", xpath);
|
snprintf(xpath_value, sizeof(xpath_value), "%s/rmap-set-action/use-igp", xpath);
|
||||||
snprintf(value, sizeof(value), "true");
|
snprintf(value, sizeof(value), "true");
|
||||||
|
} else if (aigp) {
|
||||||
|
snprintf(xpath_value, sizeof(xpath_value), "%s/rmap-set-action/use-aigp", xpath);
|
||||||
|
snprintf(value, sizeof(value), "true");
|
||||||
} else if (artt) {
|
} else if (artt) {
|
||||||
snprintf(xpath_value, sizeof(xpath_value),
|
snprintf(xpath_value, sizeof(xpath_value),
|
||||||
"%s/rmap-set-action/add-round-trip-time", xpath);
|
"%s/rmap-set-action/add-round-trip-time", xpath);
|
||||||
|
@ -1154,23 +1158,17 @@ void route_map_action_show(struct vty *vty, const struct lyd_node *dnode,
|
||||||
vty_out(vty, " set metric rtt\n");
|
vty_out(vty, " set metric rtt\n");
|
||||||
} else if (yang_dnode_get(dnode, "./rmap-set-action/use-igp")) {
|
} else if (yang_dnode_get(dnode, "./rmap-set-action/use-igp")) {
|
||||||
vty_out(vty, " set metric igp\n");
|
vty_out(vty, " set metric igp\n");
|
||||||
} else if (yang_dnode_get(
|
} else if (yang_dnode_get(dnode, "./rmap-set-action/use-aigp")) {
|
||||||
dnode,
|
vty_out(vty, " set metric aigp\n");
|
||||||
"./rmap-set-action/add-round-trip-time")) {
|
} else if (yang_dnode_get(dnode, "./rmap-set-action/add-round-trip-time")) {
|
||||||
vty_out(vty, " set metric +rtt\n");
|
vty_out(vty, " set metric +rtt\n");
|
||||||
} else if (
|
} else if (yang_dnode_get(dnode, "./rmap-set-action/subtract-round-trip-time")) {
|
||||||
yang_dnode_get(
|
|
||||||
dnode,
|
|
||||||
"./rmap-set-action/subtract-round-trip-time")) {
|
|
||||||
vty_out(vty, " set metric -rtt\n");
|
vty_out(vty, " set metric -rtt\n");
|
||||||
} else if (yang_dnode_get(dnode,
|
} else if (yang_dnode_get(dnode, "./rmap-set-action/add-metric")) {
|
||||||
"./rmap-set-action/add-metric")) {
|
|
||||||
vty_out(vty, " set metric +%s\n",
|
vty_out(vty, " set metric +%s\n",
|
||||||
yang_dnode_get_string(
|
yang_dnode_get_string(
|
||||||
dnode, "./rmap-set-action/add-metric"));
|
dnode, "./rmap-set-action/add-metric"));
|
||||||
} else if (yang_dnode_get(
|
} else if (yang_dnode_get(dnode, "./rmap-set-action/subtract-metric")) {
|
||||||
dnode,
|
|
||||||
"./rmap-set-action/subtract-metric")) {
|
|
||||||
vty_out(vty, " set metric -%s\n",
|
vty_out(vty, " set metric -%s\n",
|
||||||
yang_dnode_get_string(
|
yang_dnode_get_string(
|
||||||
dnode,
|
dnode,
|
||||||
|
|
|
@ -1227,6 +1227,20 @@ static int lib_route_map_entry_set_action_use_igp_destroy(struct nb_cb_destroy_a
|
||||||
return lib_route_map_entry_set_action_value_destroy(args);
|
return lib_route_map_entry_set_action_value_destroy(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XPath: /frr-route-map:lib/route-map/entry/set-action/use-aigp
|
||||||
|
*/
|
||||||
|
static int lib_route_map_entry_set_action_use_aigp_modify(struct nb_cb_modify_args *args)
|
||||||
|
{
|
||||||
|
return set_action_modify(args->event, args->dnode, args->resource, "aigp", args->errmsg,
|
||||||
|
args->errmsg_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int lib_route_map_entry_set_action_use_aigp_destroy(struct nb_cb_destroy_args *args)
|
||||||
|
{
|
||||||
|
return lib_route_map_entry_set_action_value_destroy(args);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XPath: /frr-route-map:lib/route-map/entry/set-action/add-round-trip-time
|
* XPath: /frr-route-map:lib/route-map/entry/set-action/add-round-trip-time
|
||||||
*/
|
*/
|
||||||
|
@ -1537,6 +1551,13 @@ const struct frr_yang_module_info frr_route_map_info = {
|
||||||
.destroy = lib_route_map_entry_set_action_use_igp_destroy,
|
.destroy = lib_route_map_entry_set_action_use_igp_destroy,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/use-aigp",
|
||||||
|
.cbs = {
|
||||||
|
.modify = lib_route_map_entry_set_action_use_aigp_modify,
|
||||||
|
.destroy = lib_route_map_entry_set_action_use_aigp_destroy,
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/add-round-trip-time",
|
.xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/add-round-trip-time",
|
||||||
.cbs = {
|
.cbs = {
|
||||||
|
|
|
@ -363,6 +363,14 @@ module frr-route-map {
|
||||||
"Use metric from IGP procotol";
|
"Use metric from IGP procotol";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case use-aigp {
|
||||||
|
leaf use-aigp {
|
||||||
|
type boolean;
|
||||||
|
description
|
||||||
|
"Use metric from AIGP (Accumulated IGP)";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue