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;
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)
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;
}
/* 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
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,
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 {
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;
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;
}
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:
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;