struct ospf_interface *oi;
struct interface *ifp;
struct listnode *node;
- int type;
if (!ospf->oi_running) {
if (IS_DEBUG_OSPF_EVENT)
ospf_nbr_self_reset(oi, router_id);
}
- /* If AS-external-LSA is queued, then flush those LSAs. */
- if (router_id_old.s_addr == 0 && ospf->external_origin) {
- /* Originate each redistributed external route. */
- for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
- if (ospf->external_origin & (1 << type))
- thread_add_event(
- master,
- ospf_external_lsa_originate_timer,
- ospf, type, NULL);
- /* Originate Deafult. */
- if (ospf->external_origin & (1 << ZEBRA_ROUTE_MAX))
- thread_add_event(master,
- ospf_default_originate_timer,
- ospf, 0, NULL);
-
- ospf->external_origin = 0;
- }
-
/* Flush (inline) all external LSAs based on the OSPF_LSA_SELF
* flag */
if (ospf->lsdb) {
}
}
- /* Originate each redistributed external route. */
- for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
- thread_add_event(master,
- ospf_external_lsa_originate_timer,
- ospf, type, NULL);
- thread_add_event(master, ospf_default_originate_timer, ospf, 0,
- NULL);
-
/* update router-lsa's for each area */
ospf_router_lsa_update(ospf);
/* update ospf_interface's */
FOR_ALL_INTERFACES (vrf, ifp)
ospf_if_update(ospf, ifp);
+
+ ospf_external_lsa_rid_change(ospf);
}
}
new->oi_write_q = list_new();
new->write_oi_count = OSPF_WRITE_INTERFACE_COUNT_DEFAULT;
-/* Enable "log-adjacency-changes" */
-#if DFLT_OSPF_LOG_ADJACENCY_CHANGES
- SET_FLAG(new->config, OSPF_LOG_ADJACENCY_CHANGES);
-#endif
-
QOBJ_REG(new, ospf);
new->fd = -1;
return NULL;
}
-struct ospf *ospf_get(unsigned short instance, const char *name)
+struct ospf *ospf_get(unsigned short instance, const char *name, bool *created)
{
struct ospf *ospf;
else
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
+ *created = (ospf == NULL);
if (ospf == NULL) {
ospf = ospf_new(instance, name);
ospf_add(ospf);
return ospf;
}
-struct ospf *ospf_get_instance(unsigned short instance)
+struct ospf *ospf_get_instance(unsigned short instance, bool *created)
{
struct ospf *ospf;
ospf = ospf_lookup_instance(instance);
+ *created = (ospf == NULL);
if (ospf == NULL) {
ospf = ospf_new(instance, NULL /* VRF_DEFAULT*/);
ospf_add(ospf);
- if (ospf->router_id_static.s_addr == 0) {
- if (vrf_lookup_by_id(ospf->vrf_id))
- ospf_router_id_update(ospf);
- else {
- if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "%s: ospf VRF (id %d) is not active yet, skip router id update",
- __PRETTY_FUNCTION__,
- ospf->vrf_id);
- }
+ if (ospf->router_id_static.s_addr == 0)
ospf_router_id_update(ospf);
- }
ospf_opaque_type11_lsa_init(ospf);
}
struct ospf_vl_data *vl_data;
struct listnode *node, *nnode;
int i;
- unsigned short instance = 0;
QOBJ_UNREG(ospf);
ospf_redist_del(ospf, i, red->instance);
}
}
- ospf_redistribute_default_unset(ospf);
+ ospf_redistribute_default_set(ospf, DEFAULT_ORIGINATE_NONE, 0, 0);
for (ALL_LIST_ELEMENTS(ospf->areas, node, nnode, area))
ospf_remove_vls_through_area(ospf, area);
/* Cancel all timers. */
OSPF_TIMER_OFF(ospf->t_read);
OSPF_TIMER_OFF(ospf->t_write);
- OSPF_TIMER_OFF(ospf->t_external_lsa);
OSPF_TIMER_OFF(ospf->t_spf_calc);
OSPF_TIMER_OFF(ospf->t_ase_calc);
OSPF_TIMER_OFF(ospf->t_maxage);
ospf_distance_reset(ospf);
route_table_finish(ospf->distance_table);
- if (!CHECK_FLAG(om->options, OSPF_MASTER_SHUTDOWN))
- instance = ospf->instance;
-
list_delete(&ospf->areas);
list_delete(&ospf->oi_write_q);
}
XFREE(MTYPE_OSPF_TOP, ospf);
-
- if (!CHECK_FLAG(om->options, OSPF_MASTER_SHUTDOWN))
- ospf_get_instance(instance);
}
/* Update connected redistribute. */
update_redistributed(ospf, 1);
+
}
void ospf_remove_vls_through_area(struct ospf *ospf, struct ospf_area *area)
old_vrf_id);
if (old_vrf_id != ospf->vrf_id) {
- frr_elevate_privs(&ospfd_privs) {
+ frr_with_privs(&ospfd_privs) {
/* stop zebra redist to us for old vrf */
zclient_send_dereg_requests(zclient,
old_vrf_id);
void ospf_vrf_init(void)
{
vrf_init(ospf_vrf_new, ospf_vrf_enable, ospf_vrf_disable,
- ospf_vrf_delete, NULL);
+ ospf_vrf_delete, ospf_vrf_enable);
}
void ospf_vrf_terminate(void)
return vrf ? vrf->name : "NIL";
}
+
+const char *ospf_get_name(const struct ospf *ospf)
+{
+ if (ospf->name)
+ return ospf->name;
+ else
+ return VRF_DEFAULT_NAME;
+}