diff options
-rw-r--r-- | bgpd/bgp_routemap.c | 6 | ||||
-rw-r--r-- | lib/routemap_cli.c | 26 | ||||
-rw-r--r-- | lib/routemap_northbound.c | 21 | ||||
-rw-r--r-- | yang/frr-route-map.yang | 8 |
4 files changed, 47 insertions, 14 deletions
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index 0e6ba4ead..23e83f9bd 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -127,6 +127,7 @@ o Local extensions #define RMAP_VALUE_TYPE_RTT 1 #define RMAP_VALUE_TYPE_IGP 2 +#define RMAP_VALUE_TYPE_AIGP 3 struct rmap_value { 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: value = bpi->extra ? bpi->extra->igpmetric : 0; break; + case RMAP_VALUE_TYPE_AIGP: + value = MIN(bpi->attr->aigp_metric, UINT32_MAX); + break; default: value = rv->value; break; @@ -198,6 +202,8 @@ static void *route_value_compile(const char *arg) var = RMAP_VALUE_TYPE_RTT; } else if (strmatch(arg, "igp")) { var = RMAP_VALUE_TYPE_IGP; + } else if (strmatch(arg, "aigp")) { + var = RMAP_VALUE_TYPE_AIGP; } else { return NULL; } diff --git a/lib/routemap_cli.c b/lib/routemap_cli.c index 3e4893310..432805c8d 100644 --- a/lib/routemap_cli.c +++ b/lib/routemap_cli.c @@ -922,14 +922,15 @@ DEFPY_YANG( DEFPY_YANG( 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 "Metric value for destination routing protocol\n" "Metric value (use +/- for additions or subtractions)\n" "Assign round trip time\n" "Add 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']"; char xpath_value[XPATH_MAXLEN]; @@ -943,6 +944,9 @@ DEFPY_YANG( } else if (igp) { snprintf(xpath_value, sizeof(xpath_value), "%s/rmap-set-action/use-igp", xpath); 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) { snprintf(xpath_value, sizeof(xpath_value), "%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"); } else if (yang_dnode_get(dnode, "./rmap-set-action/use-igp")) { vty_out(vty, " set metric igp\n"); - } else if (yang_dnode_get( - dnode, - "./rmap-set-action/add-round-trip-time")) { + } else if (yang_dnode_get(dnode, "./rmap-set-action/use-aigp")) { + vty_out(vty, " set metric aigp\n"); + } else if (yang_dnode_get(dnode, "./rmap-set-action/add-round-trip-time")) { vty_out(vty, " set metric +rtt\n"); - } else if ( - yang_dnode_get( - dnode, - "./rmap-set-action/subtract-round-trip-time")) { + } else if (yang_dnode_get(dnode, "./rmap-set-action/subtract-round-trip-time")) { vty_out(vty, " set metric -rtt\n"); - } else if (yang_dnode_get(dnode, - "./rmap-set-action/add-metric")) { + } else if (yang_dnode_get(dnode, "./rmap-set-action/add-metric")) { vty_out(vty, " set metric +%s\n", yang_dnode_get_string( dnode, "./rmap-set-action/add-metric")); - } else if (yang_dnode_get( - dnode, - "./rmap-set-action/subtract-metric")) { + } else if (yang_dnode_get(dnode, "./rmap-set-action/subtract-metric")) { vty_out(vty, " set metric -%s\n", yang_dnode_get_string( dnode, diff --git a/lib/routemap_northbound.c b/lib/routemap_northbound.c index a868a80f3..0ee055e65 100644 --- a/lib/routemap_northbound.c +++ b/lib/routemap_northbound.c @@ -1228,6 +1228,20 @@ static int lib_route_map_entry_set_action_use_igp_destroy(struct nb_cb_destroy_a } /* + * 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 */ static int lib_route_map_entry_set_action_add_round_trip_time_modify( @@ -1538,6 +1552,13 @@ const struct frr_yang_module_info frr_route_map_info = { } }, { + .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", .cbs = { .modify = lib_route_map_entry_set_action_add_round_trip_time_modify, diff --git a/yang/frr-route-map.yang b/yang/frr-route-map.yang index b83047cae..244c353a6 100644 --- a/yang/frr-route-map.yang +++ b/yang/frr-route-map.yang @@ -363,6 +363,14 @@ module frr-route-map { "Use metric from IGP procotol"; } } + + case use-aigp { + leaf use-aigp { + type boolean; + description + "Use metric from AIGP (Accumulated IGP)"; + } + } } } |