struct listnode *node, *nnode;
struct ospf6_area *oa;
struct ospf6_route *def, *route;
+ int type = DEFAULT_ROUTE;
if (!o->backbone)
return;
def->path.type = OSPF6_PATH_TYPE_INTER;
def->path.subtype = OSPF6_PATH_SUBTYPE_DEFAULT_RT;
def->path.area_id = o->backbone->area_id;
+ def->path.metric_type = metric_type(o, type, 0);
+ def->path.cost = metric_value(o, type, 0);
for (ALL_LIST_ELEMENTS(o->area_list, node, nnode, oa)) {
if (!IS_AREA_STUB(oa)) {
sizeof(struct in6_addr));
info->tag = tinfo.tag;
} else {
- /* If there is no route-map, simply update the tag */
+ /* If there is no route-map, simply update the tag and
+ * metric fields
+ */
+ match->path.metric_type = metric_type(ospf6, type, 0);
+ match->path.cost = metric_value(ospf6, type, 0);
info->tag = tag;
}
sizeof(struct in6_addr));
info->tag = tinfo.tag;
} else {
- /* If there is no route-map, simply set the tag */
+ /* If there is no route-map, simply update the tag and metric
+ * fields
+ */
+ route->path.metric_type = metric_type(ospf6, type, 0);
+ route->path.cost = metric_value(ospf6, type, 0);
info->tag = tag;
}
#include "ospf6_lsa.h"
#include "ospf6_lsdb.h"
#include "ospf6_message.h"
+#include "ospf6_asbr.h"
+#include "ospf6_zebra.h"
#include "ospf6_top.h"
#include "ospf6_area.h"
return handler->lh_debug;
}
+int metric_type(struct ospf6 *ospf6, int type, uint8_t instance)
+{
+ struct ospf6_redist *red;
+
+ red = ospf6_redist_lookup(ospf6, type, instance);
+
+ return ((!red || red->dmetric.type < 0) ? DEFAULT_METRIC_TYPE
+ : red->dmetric.type);
+}
+
+int metric_value(struct ospf6 *ospf6, int type, uint8_t instance)
+{
+ struct ospf6_redist *red;
+
+ red = ospf6_redist_lookup(ospf6, type, instance);
+ if (!red || red->dmetric.value < 0) {
+ if (type == DEFAULT_ROUTE) {
+ if (ospf6->default_originate == DEFAULT_ORIGINATE_ZEBRA)
+ return DEFAULT_DEFAULT_ORIGINATE_METRIC;
+ else
+ return DEFAULT_DEFAULT_ALWAYS_METRIC;
+ } else
+ return DEFAULT_DEFAULT_METRIC;
+ }
+
+ return red->dmetric.value;
+}
+
/* RFC2328: Section 13.2 */
int ospf6_lsa_is_differ(struct ospf6_lsa *lsa1, struct ospf6_lsa *lsa2)
{
#define OSPF6_LSA_DEBUG_EXAMIN 0x04
#define OSPF6_LSA_DEBUG_FLOOD 0x08
+/* OSPF LSA Default metric values */
+#define DEFAULT_DEFAULT_METRIC 20
+#define DEFAULT_DEFAULT_ORIGINATE_METRIC 10
+#define DEFAULT_DEFAULT_ALWAYS_METRIC 1
+#define DEFAULT_METRIC_TYPE 2
+
#define IS_OSPF6_DEBUG_LSA(name) \
(ospf6_lstype_debug(htons(OSPF6_LSTYPE_##name)) & OSPF6_LSA_DEBUG)
#define IS_OSPF6_DEBUG_ORIGINATE(name) \
extern const char *ospf6_lstype_name(uint16_t type);
extern const char *ospf6_lstype_short_name(uint16_t type);
extern uint8_t ospf6_lstype_debug(uint16_t type);
+extern int metric_type(struct ospf6 *ospf6, int type, uint8_t instance);
+extern int metric_value(struct ospf6 *ospf6, int type, uint8_t instance);
extern int ospf6_lsa_is_differ(struct ospf6_lsa *lsa1, struct ospf6_lsa *lsa2);
extern int ospf6_lsa_is_changed(struct ospf6_lsa *lsa1, struct ospf6_lsa *lsa2);
extern uint16_t ospf6_lsa_age_current(struct ospf6_lsa *);