summaryrefslogtreecommitdiff
path: root/ospfd/ospfd.c
diff options
context:
space:
mode:
Diffstat (limited to 'ospfd/ospfd.c')
-rw-r--r--ospfd/ospfd.c70
1 files changed, 31 insertions, 39 deletions
diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c
index 3226d66444..9a421de017 100644
--- a/ospfd/ospfd.c
+++ b/ospfd/ospfd.c
@@ -291,6 +291,16 @@ static int ospf_area_id_cmp(struct ospf_area *a1, struct ospf_area *a2)
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;
@@ -366,6 +376,8 @@ struct ospf *ospf_new_alloc(unsigned short instance, const char *name)
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;
@@ -376,6 +388,8 @@ struct ospf *ospf_new_alloc(unsigned short instance, const char *name)
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);
@@ -390,6 +404,8 @@ struct ospf *ospf_new_alloc(unsigned short instance, const char *name)
ospf_asbr_external_aggregator_init(new);
+ ospf_opaque_type11_lsa_init(new);
+
QOBJ_REG(new, ospf);
new->fd = -1;
@@ -403,23 +419,23 @@ static struct ospf *ospf_new(unsigned short instance, const char *name)
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);
+
/*
* Read from non-volatile memory whether this instance is performing a
* graceful restart or not.
@@ -455,16 +471,6 @@ static int ospf_is_ready(struct ospf *ospf)
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;
@@ -483,16 +489,6 @@ struct ospf *ospf_lookup_by_inst_name(unsigned short instance, const char *name)
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;
@@ -513,12 +509,8 @@ struct ospf *ospf_get(unsigned short instance, const char *name, bool *created)
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;
}
@@ -1130,8 +1122,8 @@ static void update_redistributed(struct ospf *ospf, int add_to_ospf)
if (add_to_ospf) {
if (ospf_external_info_find_lsa(ospf,
&ei->p))
- if (!ospf_distribute_check_connected(
- ospf, ei))
+ if (!ospf_redistribute_check(
+ ospf, ei, NULL))
ospf_external_lsa_flush(
ospf, ei->type,
&ei->p,
@@ -1139,8 +1131,8 @@ static void update_redistributed(struct ospf *ospf, int add_to_ospf)
} else {
if (!ospf_external_info_find_lsa(
ospf, &ei->p))
- if (ospf_distribute_check_connected(
- ospf, ei))
+ if (ospf_redistribute_check(
+ ospf, ei, NULL))
ospf_external_lsa_originate(
ospf, ei);
}