summaryrefslogtreecommitdiff
path: root/ospfd/ospfd.c
diff options
context:
space:
mode:
Diffstat (limited to 'ospfd/ospfd.c')
-rw-r--r--ospfd/ospfd.c90
1 files changed, 61 insertions, 29 deletions
diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c
index a98d5be0..099af558 100644
--- a/ospfd/ospfd.c
+++ b/ospfd/ospfd.c
@@ -52,8 +52,12 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "ospfd/ospf_route.h"
#include "ospfd/ospf_ase.h"
-/* OSPF instance top. */
-struct ospf *ospf_top;
+
+/* OSPF process wide configuration. */
+static struct ospf_master ospf_master;
+
+/* OSPF process wide configuration pointer to export. */
+struct ospf_master *om;
extern struct zclient *zclient;
@@ -148,7 +152,7 @@ ospf_router_id_update (struct ospf *ospf)
int
ospf_router_id_update_timer (struct thread *thread)
{
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf = THREAD_ARG (thread);
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("Router-ID: Update timer fired!");
@@ -182,7 +186,6 @@ ospf_new ()
new->router_id_static.s_addr = htonl (0);
new->abr_type = OSPF_ABR_STAND;
- new->iflist = iflist;
new->oiflist = list_new ();
new->vlinks = list_new ();
new->areas = list_new ();
@@ -235,23 +238,44 @@ ospf_new ()
}
struct ospf *
-ospf_get ()
+ospf_lookup ()
{
- struct ospf *ospf = ospf_top;
+ if (listcount (om->ospf) == 0)
+ return NULL;
- if (ospf != NULL)
- return ospf;
+ return getdata (listhead (om->ospf));
+}
+
+void
+ospf_add (struct ospf *ospf)
+{
+ listnode_add (om->ospf, ospf);
+}
- ospf = ospf_new ();
+void
+ospf_delete (struct ospf *ospf)
+{
+ listnode_delete (om->ospf, ospf);
+}
- if (ospf->router_id_static.s_addr == 0)
- ospf_router_id_update (ospf);
+struct ospf *
+ospf_get ()
+{
+ struct ospf *ospf;
+
+ ospf = ospf_lookup ();
+ if (ospf == NULL)
+ {
+ ospf = ospf_new ();
+ ospf_add (ospf);
+
+ if (ospf->router_id_static.s_addr == 0)
+ ospf_router_id_update (ospf);
#ifdef HAVE_OPAQUE_LSA
- ospf_opaque_type11_lsa_init (ospf);
+ ospf_opaque_type11_lsa_init (ospf);
#endif /* HAVE_OPAQUE_LSA */
-
- ospf_top = ospf;
+ }
return ospf;
}
@@ -271,7 +295,7 @@ ospf_finish (struct ospf *ospf)
/* Unredister redistribution */
for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
- ospf_redistribute_unset (i);
+ ospf_redistribute_unset (ospf, i);
for (node = listhead (ospf->areas); node;)
{
@@ -420,9 +444,9 @@ ospf_finish (struct ospf *ospf)
ospf_distance_reset (ospf);
route_table_finish (ospf->distance_table);
- XFREE (MTYPE_OSPF_TOP, ospf);
+ ospf_delete (ospf);
- ospf_top = NULL;
+ XFREE (MTYPE_OSPF_TOP, ospf);
}
@@ -706,13 +730,12 @@ ospf_network_run (struct ospf *ospf, struct prefix *p, struct ospf_area *area)
if (ospf->router_id_static.s_addr == 0)
if (ospf->t_router_id_update == NULL)
{
- ospf->t_router_id_update =
- thread_add_timer (master, ospf_router_id_update_timer, ospf,
- OSPF_ROUTER_ID_UPDATE_DELAY);
+ OSPF_TIMER_ON (ospf->t_router_id_update, ospf_router_id_update_timer,
+ OSPF_ROUTER_ID_UPDATE_DELAY);
}
/* Get target interface. */
- for (node = listhead (ospf->iflist); node; nextnode (node))
+ for (node = listhead (om->iflist); node; nextnode (node))
{
listnode cn;
@@ -845,9 +868,9 @@ ospf_if_update (struct ospf *ospf)
if (ospf->router_id_static.s_addr == 0)
if (ospf->t_router_id_update == NULL)
{
- ospf->t_router_id_update =
- thread_add_timer (master, ospf_router_id_update_timer, NULL,
- OSPF_ROUTER_ID_UPDATE_DELAY);
+ OSPF_TIMER_ON (ospf->t_router_id_update,
+ ospf_router_id_update_timer,
+ OSPF_ROUTER_ID_UPDATE_DELAY);
}
/* Find interfaces that not configured already. */
@@ -1586,12 +1609,13 @@ ospf_nbr_nbma_poll_interval_unset (struct ospf *ospf, struct in_addr addr)
void
ospf_prefix_list_update (struct prefix_list *plist)
{
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
struct ospf_area *area;
listnode node;
int abr_inv = 0;
/* If OSPF instatnce does not exist, return right now. */
+ ospf = ospf_lookup ();
if (ospf == NULL)
return;
@@ -1620,16 +1644,24 @@ ospf_prefix_list_update (struct prefix_list *plist)
}
/* Schedule ABR tasks. */
- if (OSPF_IS_ABR && abr_inv)
+ if (IS_OSPF_ABR (ospf) && abr_inv)
ospf_schedule_abr_task (ospf);
}
void
-ospf_init ()
+ospf_master_init ()
{
- /* Make empty list of ospf list. */
- ospf_top = NULL;
+ memset (&ospf_master, 0, sizeof (struct ospf_master));
+
+ om = &ospf_master;
+ om->ospf = list_new ();
+ om->master = thread_master_create ();
+ om->start_time = time (NULL);
+}
+void
+ospf_init ()
+{
prefix_list_add_hook (ospf_prefix_list_update);
prefix_list_delete_hook (ospf_prefix_list_update);
}