ospf6->rmap[type].map = NULL;
}
+static int ospf6_asbr_routemap_update_timer(struct thread *thread)
+{
+ void **arg;
+ int arg_type;
+
+ arg = THREAD_ARG(thread);
+ arg_type = (int)(intptr_t)arg[1];
+
+ ospf6->t_distribute_update = NULL;
+
+ if (ospf6->rmap[arg_type].name)
+ ospf6->rmap[arg_type].map = route_map_lookup_by_name(
+ ospf6->rmap[arg_type].name);
+ if (ospf6->rmap[arg_type].map) {
+ if (IS_OSPF6_DEBUG_ASBR)
+ zlog_debug("%s: route-map %s update, reset redist %s",
+ __PRETTY_FUNCTION__,
+ ospf6->rmap[arg_type].name,
+ ZROUTE_NAME(arg_type));
+
+ ospf6_zebra_no_redistribute(arg_type);
+ ospf6_zebra_redistribute(arg_type);
+ }
+
+ XFREE(MTYPE_OSPF6_DIST_ARGS, arg);
+ return 0;
+}
+
+void ospf6_asbr_distribute_list_update(int type)
+{
+ void **args = NULL;
+
+ if (ospf6->t_distribute_update)
+ return;
+
+ args = XCALLOC(MTYPE_OSPF6_DIST_ARGS, sizeof(void *)*2);
+
+ args[0] = ospf6;
+ args[1] = (void *)((ptrdiff_t)type);
+
+ if (IS_OSPF6_DEBUG_ASBR)
+ zlog_debug("%s: trigger redistribute %s reset thread",
+ __PRETTY_FUNCTION__, ZROUTE_NAME(type));
+
+ ospf6->t_distribute_update = NULL;
+ thread_add_timer_msec(master, ospf6_asbr_routemap_update_timer,
+ (void **)args, OSPF_MIN_LS_INTERVAL,
+ &ospf6->t_distribute_update);
+}
+
static void ospf6_asbr_routemap_update(const char *mapname)
{
int type;
zlog_debug("%s: route-map %s update, reset redist %s",
__PRETTY_FUNCTION__, mapname,
ZROUTE_NAME(type));
-
- ospf6_zebra_no_redistribute(type);
- ospf6_zebra_redistribute(type);
+ ospf6_asbr_distribute_list_update(type);
}
} else
ospf6->rmap[type].map = NULL;
}
}
+static void ospf6_asbr_routemap_event(route_map_event_t event, const char *name)
+{
+ int type;
+
+ if (ospf6 == NULL)
+ return;
+ for (type = 0; type < ZEBRA_ROUTE_MAX; type++) {
+ if ((ospf6->rmap[type].name) &&
+ (strcmp(ospf6->rmap[type].name, name) == 0)) {
+ ospf6_asbr_distribute_list_update(type);
+ }
+ }
+}
+
int ospf6_asbr_is_asbr(struct ospf6 *o)
{
return o->external_table->count;
match = ospf6_route_lookup(prefix, ospf6->external_table);
if (match) {
info = match->route_option;
-
/* copy result of route-map */
if (ospf6->rmap[type].map) {
if (troute.path.metric_type)
if (IS_OSPF6_DEBUG_ASBR) {
inet_ntop(AF_INET, &prefix_id.u.prefix4, ibuf,
sizeof(ibuf));
- zlog_debug("Advertise as AS-External Id:%s", ibuf);
+ prefix2str(prefix, pbuf, sizeof(pbuf));
+ zlog_debug("Advertise as AS-External Id:%s prefix %s metric %u",
+ ibuf, pbuf, match->path.metric_type);
}
match->path.origin.id = htonl(info->id);
if (IS_OSPF6_DEBUG_ASBR) {
inet_ntop(AF_INET, &prefix_id.u.prefix4, ibuf, sizeof(ibuf));
- zlog_debug("Advertise as AS-External Id:%s", ibuf);
+ prefix2str(prefix, pbuf, sizeof(pbuf));
+ zlog_debug("Advertise as AS-External Id:%s prefix %s metric %u",
+ ibuf, pbuf, route->path.metric_type);
}
route->path.origin.id = htonl(info->id);
route_map_add_hook(ospf6_asbr_routemap_update);
route_map_delete_hook(ospf6_asbr_routemap_update);
+ route_map_event_hook(ospf6_asbr_routemap_event);
route_map_set_metric_hook(generic_set_add);
route_map_no_set_metric_hook(generic_set_delete);
void ospf6_asbr_terminate(void)
{
+ /* Cleanup route maps */
+ route_map_add_hook(NULL);
+ route_map_delete_hook(NULL);
+ route_map_event_hook(NULL);
route_map_finish();
}