return 0;
}
+static void ospf_add(struct ospf *ospf)
+{
+ listnode_add(om->ospf, ospf);
+}
+
+static void ospf_delete(struct ospf *ospf)
+{
+ listnode_delete(om->ospf, ospf);
+}
+
struct ospf *ospf_new_alloc(unsigned short instance, const char *name)
{
int i;
new->maxage_delay = OSPF_LSA_MAXAGE_REMOVE_DELAY_DEFAULT;
new->maxage_lsa = route_table_init();
new->t_maxage_walker = NULL;
+ thread_add_timer(master, ospf_lsa_maxage_walker, new,
+ OSPF_LSA_MAXAGE_CHECK_INTERVAL, &new->t_maxage_walker);
/* Max paths initialization */
new->max_multipath = MULTIPATH_NUM;
new->lsa_refresh_queue.index = 0;
new->lsa_refresh_interval = OSPF_LSA_REFRESH_INTERVAL_DEFAULT;
new->t_lsa_refresher = NULL;
+ thread_add_timer(master, ospf_lsa_refresh_walker, new,
+ new->lsa_refresh_interval, &new->t_lsa_refresher);
new->lsa_refresher_started = monotime(NULL);
new->ibuf = stream_new(OSPF_MAX_PACKET_SIZE + 1);
ospf_asbr_external_aggregator_init(new);
+ ospf_opaque_type11_lsa_init(new);
+
QOBJ_REG(new, ospf);
new->fd = -1;
struct ospf *new;
new = ospf_new_alloc(instance, name);
+ ospf_add(new);
+
+ if (new->vrf_id == VRF_UNKNOWN)
+ return new;
if ((ospf_sock_init(new)) < 0) {
- if (new->vrf_id != VRF_UNKNOWN)
- flog_err(
- EC_LIB_SOCKET,
- "%s: ospf_sock_init is unable to open a socket",
- __func__);
+ flog_err(EC_LIB_SOCKET,
+ "%s: ospf_sock_init is unable to open a socket",
+ __func__);
return new;
}
- thread_add_timer(master, ospf_lsa_maxage_walker, new,
- OSPF_LSA_MAXAGE_CHECK_INTERVAL, &new->t_maxage_walker);
- thread_add_timer(master, ospf_lsa_refresh_walker, new,
- new->lsa_refresh_interval, &new->t_lsa_refresher);
-
thread_add_read(master, ospf_read, new, new->fd, &new->t_read);
+ new->oi_running = 1;
+ ospf_router_id_update(new);
+
return new;
}
return 1;
}
-static void ospf_add(struct ospf *ospf)
-{
- listnode_add(om->ospf, ospf);
-}
-
-static void ospf_delete(struct ospf *ospf)
-{
- listnode_delete(om->ospf, ospf);
-}
-
struct ospf *ospf_lookup_by_inst_name(unsigned short instance, const char *name)
{
struct ospf *ospf = NULL;
return NULL;
}
-static void ospf_init(struct ospf *ospf)
-{
- ospf_opaque_type11_lsa_init(ospf);
-
- if (ospf->vrf_id != VRF_UNKNOWN)
- ospf->oi_running = 1;
-
- ospf_router_id_update(ospf);
-}
-
struct ospf *ospf_lookup(unsigned short instance, const char *name)
{
struct ospf *ospf;
ospf = ospf_lookup(instance, name);
*created = (ospf == NULL);
- if (ospf == NULL) {
+ if (ospf == NULL)
ospf = ospf_new(instance, name);
- ospf_add(ospf);
-
- ospf_init(ospf);
- }
return ospf;
}