diff --git a/ospfd/ospf_asbr.c b/ospfd/ospf_asbr.c index 7befcc1086..516ee80c5b 100644 --- a/ospfd/ospf_asbr.c +++ b/ospfd/ospf_asbr.c @@ -94,7 +94,7 @@ int ospf_route_map_set_compare(struct route_map_set_values *values1, struct external_info * ospf_external_info_add(struct ospf *ospf, uint8_t type, unsigned short instance, struct prefix_ipv4 p, ifindex_t ifindex, - struct in_addr nexthop, route_tag_t tag) + struct in_addr nexthop, route_tag_t tag, uint32_t metric) { struct external_info *new; struct route_node *rn; @@ -131,6 +131,7 @@ ospf_external_info_add(struct ospf *ospf, uint8_t type, unsigned short instance, new->tag = tag; new->orig_tag = tag; new->aggr_route = NULL; + new->metric = metric; /* we don't unlock rn from the get() because we're attaching the info */ if (rn) @@ -138,9 +139,9 @@ ospf_external_info_add(struct ospf *ospf, uint8_t type, unsigned short instance, if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) { zlog_debug( - "Redistribute[%s][%u]: %pFX external info created, with NH %pI4", + "Redistribute[%s][%u]: %pFX external info created, with NH %pI4, metric:%u", ospf_redist_string(type), ospf->vrf_id, &p, - &nexthop.s_addr); + &nexthop.s_addr, metric); } return new; } diff --git a/ospfd/ospf_asbr.h b/ospfd/ospf_asbr.h index 6b427c5fd2..256a6c8b5b 100644 --- a/ospfd/ospf_asbr.h +++ b/ospfd/ospf_asbr.h @@ -36,6 +36,8 @@ struct external_info { /* Actual tag received from zebra*/ route_tag_t orig_tag; + uint32_t metric; + struct route_map_set_values route_map_set; #define ROUTEMAP_METRIC(E) (E)->route_map_set.metric #define ROUTEMAP_METRIC_TYPE(E) (E)->route_map_set.metric_type @@ -99,11 +101,10 @@ extern struct external_info *ospf_external_info_new(struct ospf *, uint8_t, extern void ospf_reset_route_map_set_values(struct route_map_set_values *); extern int ospf_route_map_set_compare(struct route_map_set_values *, struct route_map_set_values *); -extern struct external_info *ospf_external_info_add(struct ospf *, uint8_t, - unsigned short, - struct prefix_ipv4, - ifindex_t, struct in_addr, - route_tag_t); +extern struct external_info * +ospf_external_info_add(struct ospf *, uint8_t, unsigned short, + struct prefix_ipv4, ifindex_t, struct in_addr, + route_tag_t, uint32_t metric); extern void ospf_external_info_delete(struct ospf *, uint8_t, unsigned short, struct prefix_ipv4); extern struct external_info *ospf_external_info_lookup(struct ospf *, uint8_t, diff --git a/ospfd/ospf_ase.c b/ospfd/ospf_ase.c index 80390af505..cc2110d433 100644 --- a/ospfd/ospf_ase.c +++ b/ospfd/ospf_ase.c @@ -159,7 +159,9 @@ ospf_ase_calculate_new_route(struct ospf_lsa *lsa, if (!IS_EXTERNAL_METRIC(al->e[0].tos)) { if (IS_DEBUG_OSPF(lsa, LSA)) - zlog_debug("Route[External]: type-1 created."); + zlog_debug( + "Route[External]: type-1 created, asbr cost:%d metric:%d.", + asbr_route->cost, metric); new->path_type = OSPF_PATH_TYPE1_EXTERNAL; new->cost = asbr_route->cost + metric; /* X + Y */ } else { diff --git a/ospfd/ospf_routemap.c b/ospfd/ospf_routemap.c index 3d5c5aa2d5..9656867745 100644 --- a/ospfd/ospf_routemap.c +++ b/ospfd/ospf_routemap.c @@ -398,7 +398,7 @@ route_set_metric(void *rule, const struct prefix *prefix, void *object) if (!metric->used) return RMAP_OKAY; - ei->route_map_set.metric = DEFAULT_DEFAULT_METRIC; + ei->route_map_set.metric = ei->metric; if (metric->type == metric_increment) ei->route_map_set.metric += metric->metric; diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index 3f967e41e4..0b770a8364 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -956,8 +956,8 @@ int ospf_redistribute_default_set(struct ospf *ospf, int originate, int mtype, type_str = "always"; ospf->redistribute++; ospf_external_add(ospf, DEFAULT_ROUTE, 0); - ospf_external_info_add(ospf, DEFAULT_ROUTE, 0, p, 0, nexthop, - 0); + ospf_external_info_add(ospf, DEFAULT_ROUTE, 0, p, 0, nexthop, 0, + DEFAULT_DEFAULT_METRIC); break; } @@ -1303,9 +1303,11 @@ static int ospf_zebra_read_route(ZAPI_CALLBACK_ARGS) rt_type = DEFAULT_ROUTE; if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) - zlog_debug("%s: cmd %s from client %s: vrf_id %d, p %pFX", - __func__, zserv_command_string(cmd), - zebra_route_string(api.type), vrf_id, &api.prefix); + zlog_debug( + "%s: cmd %s from client %s: vrf_id %d, p %pFX, metric %d", + __func__, zserv_command_string(cmd), + zebra_route_string(api.type), vrf_id, &api.prefix, + api.metric); if (cmd == ZEBRA_REDISTRIBUTE_ROUTE_ADD) { /* XXX|HACK|TODO|FIXME: @@ -1332,7 +1334,8 @@ static int ospf_zebra_read_route(ZAPI_CALLBACK_ARGS) p); ei = ospf_external_info_add(ospf, rt_type, api.instance, p, - ifindex, nexthop, api.tag); + ifindex, nexthop, api.tag, + api.metric); if (ei == NULL) { /* Nothing has changed, so nothing to do; return */ return 0;