summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_snmp.c8
-rw-r--r--lib/smux.c4
-rw-r--r--lib/smux.h2
-rw-r--r--ospfd/ospf_abr.c44
-rw-r--r--ospfd/ospf_asbr.c8
-rw-r--r--ospfd/ospf_ia.c2
-rw-r--r--ospfd/ospf_interface.c1
-rw-r--r--ospfd/ospf_ism.h10
-rw-r--r--ospfd/ospf_lsa.c19
-rw-r--r--ospfd/ospf_lsdb.c15
-rw-r--r--ospfd/ospf_lsdb.h2
-rw-r--r--ospfd/ospf_main.c5
-rw-r--r--ospfd/ospf_nsm.h27
-rw-r--r--ospfd/ospf_opaque.c24
-rw-r--r--ospfd/ospf_packet.c27
-rw-r--r--ospfd/ospf_route.c5
-rw-r--r--ospfd/ospf_routemap.c20
-rw-r--r--ospfd/ospf_snmp.c63
-rw-r--r--ospfd/ospf_spf.c2
-rw-r--r--ospfd/ospf_vty.c306
-rw-r--r--ospfd/ospf_zebra.c138
-rw-r--r--ospfd/ospf_zebra.h18
-rw-r--r--ospfd/ospfd.c90
-rw-r--r--ospfd/ospfd.h47
24 files changed, 520 insertions, 367 deletions
diff --git a/bgpd/bgp_snmp.c b/bgpd/bgp_snmp.c
index 6215edee..8a4dfb64 100644
--- a/bgpd/bgp_snmp.c
+++ b/bgpd/bgp_snmp.c
@@ -42,6 +42,10 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
/* BGP4-MIB described in RFC1657. */
#define BGP4MIB 1,3,6,1,2,1,15
+/* BGP TRAP. */
+#define BGPESTABLISHED 1
+#define BGPBACKWARDTRANSITION 2
+
/* Zebra enterprise BGP MIB. This variable is used for register
OSPF MIB to SNMP agent under SMUX protocol. */
#define BGPDMIB 1,3,6,1,4,1,3317,1,2,2
@@ -843,7 +847,7 @@ bgpTrapEstablished (struct peer *peer)
smux_trap (bgp_oid, sizeof bgp_oid / sizeof (oid),
index, IN_ADDR_SIZE,
bgpTrapList, sizeof bgpTrapList / sizeof (struct trap_object),
- bm->start_time - time (NULL));
+ bm->start_time - time (NULL), BGPESTABLISHED);
}
void
@@ -862,7 +866,7 @@ bgpTrapBackwardTransition (struct peer *peer)
smux_trap (bgp_oid, sizeof bgp_oid / sizeof (oid),
index, IN_ADDR_SIZE,
bgpTrapList, sizeof bgpTrapList / sizeof (struct trap_object),
- bm->start_time - time (NULL));
+ bm->start_time - time (NULL), BGPBACKWARDTRANSITION);
}
void
diff --git a/lib/smux.c b/lib/smux.c
index 32f8c8ff..3d30a261 100644
--- a/lib/smux.c
+++ b/lib/smux.c
@@ -997,7 +997,7 @@ int
smux_trap (oid *name, size_t namelen,
oid *iname, size_t inamelen,
struct trap_object *trapobj, size_t trapobjlen,
- unsigned int tick)
+ unsigned int tick, u_char sptrap)
{
int i;
u_char buf[BUFSIZ];
@@ -1038,7 +1038,7 @@ smux_trap (oid *name, size_t namelen,
&val, sizeof (int));
/* Specific trap integer. */
- val = 2;
+ val = sptrap;
ptr = asn_build_int (ptr, &len,
(u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
&val, sizeof (int));
diff --git a/lib/smux.h b/lib/smux.h
index 91c3d46f..27f36447 100644
--- a/lib/smux.h
+++ b/lib/smux.h
@@ -149,7 +149,7 @@ void smux_start (void);
void smux_register_mib(char *, struct variable *, size_t, int, oid [], size_t);
int smux_header_generic (struct variable *, oid [], size_t *, int, size_t *,
WriteMethod **);
-int smux_trap (oid *, size_t, oid *, size_t, struct trap_object *, size_t, unsigned int);
+int smux_trap (oid *, size_t, oid *, size_t, struct trap_object *, size_t, unsigned int, u_char);
int oid_compare (oid *, int, oid *, int);
void oid2in_addr (oid [], int, struct in_addr *);
diff --git a/ospfd/ospf_abr.c b/ospfd/ospf_abr.c
index 6799c836..181fe190 100644
--- a/ospfd/ospf_abr.c
+++ b/ospfd/ospf_abr.c
@@ -1145,30 +1145,21 @@ ospf_abr_process_router_rt (struct ospf *ospf, struct route_table *rt)
}
#ifdef HAVE_NSSA
-int
-ospf_abr_unapprove_translates_apply (struct ospf_lsa *lsa, void *p_arg,
- int int_arg)
-{
- /* Could be a mix of Normal Type-5's, self-originated, or Type-7s
- that are Locally ABR Translated */
-
- if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
- UNSET_FLAG (lsa->flags, OSPF_LSA_APPROVED);
-
- return 0;
-}
-
void
ospf_abr_unapprove_translates (struct ospf *ospf) /* For NSSA Translations */
{
+ struct ospf_lsa *lsa;
+ struct route_node *rn;
+
if (IS_DEBUG_OSPF_NSSA)
zlog_info ("ospf_abr_unapprove_translates(): Start");
/* NSSA Translator is not checked, because it may have gone away,
and we would want to flush any residuals anyway */
- foreach_lsa (EXTERNAL_LSDB (ospf), NULL, 0,
- ospf_abr_unapprove_translates_apply);
+ LSDB_LOOP (EXTERNAL_LSDB (ospf), rn, lsa)
+ if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
+ UNSET_FLAG (lsa->flags, OSPF_LSA_APPROVED);
if (IS_DEBUG_OSPF_NSSA)
zlog_info ("ospf_abr_unapprove_translates(): Stop");
@@ -1390,7 +1381,7 @@ ospf_abr_announce_nssa_defaults (struct ospf *ospf) /* By ABR-Translator */
struct ospf_area *area;
struct prefix_ipv4 p;
- if (! OSPF_IS_ABR)
+ if (! IS_OSPF_ABR (ospf))
return;
if (IS_DEBUG_OSPF_NSSA)
@@ -1432,7 +1423,7 @@ ospf_abr_announce_stub_defaults (struct ospf *ospf)
struct ospf_area *area;
struct prefix_ipv4 p;
- if (! OSPF_IS_ABR)
+ if (! IS_OSPF_ABR (ospf))
return;
if (IS_DEBUG_OSPF_EVENT)
@@ -1471,11 +1462,9 @@ ospf_abr_announce_stub_defaults (struct ospf *ospf)
#ifdef HAVE_NSSA
int
-ospf_abr_remove_unapproved_translates_apply (struct ospf_lsa *lsa, void *p_arg,
- int int_arg)
+ospf_abr_remove_unapproved_translates_apply (struct ospf *ospf,
+ struct ospf_lsa *lsa)
{
- struct ospf *ospf = ospf_top;
-
if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)
&& ! CHECK_FLAG (lsa->flags, OSPF_LSA_APPROVED))
{
@@ -1492,15 +1481,18 @@ ospf_abr_remove_unapproved_translates_apply (struct ospf_lsa *lsa, void *p_arg,
}
void
-ospf_abr_remove_unapproved_translates (struct ospf *ospf) /* For NSSA Translations */
+ospf_abr_remove_unapproved_translates (struct ospf *ospf)
{
+ struct route_node *rn;
+ struct ospf_lsa *lsa;
+
/* All AREA PROCESS should have APPROVED necessary LSAs */
/* Remove any left over and not APPROVED */
if (IS_DEBUG_OSPF_NSSA)
zlog_info ("ospf_abr_remove_unapproved_translates(): Start");
- foreach_lsa (EXTERNAL_LSDB (ospf), NULL, 0,
- ospf_abr_remove_unapproved_translates_apply);
+ LSDB_LOOP (EXTERNAL_LSDB (ospf), rn, lsa)
+ ospf_abr_remove_unapproved_translates_apply (ospf, lsa);
if (IS_DEBUG_OSPF_NSSA)
zlog_info ("ospf_abr_remove_unapproved_translates(): Stop");
@@ -1595,7 +1587,7 @@ ospf_abr_nssa_task (struct ospf *ospf) /* called only if any_nssa */
if (IS_DEBUG_OSPF_NSSA)
zlog_info ("Check for NSSA-ABR Tasks():");
- if (! OSPF_IS_ABR)
+ if (! IS_OSPF_ABR (ospf))
return;
if (! ospf->anyNSSA)
@@ -1673,7 +1665,7 @@ ospf_abr_task (struct ospf *ospf)
zlog_info ("ospf_abr_task(): prepare aggregates");
ospf_abr_prepare_aggregates (ospf);
- if (OSPF_IS_ABR)
+ if (IS_OSPF_ABR (ospf))
{
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_abr_task(): process network RT");
diff --git a/ospfd/ospf_asbr.c b/ospfd/ospf_asbr.c
index c5d199fb..fda32ae1 100644
--- a/ospfd/ospf_asbr.c
+++ b/ospfd/ospf_asbr.c
@@ -245,7 +245,7 @@ ospf_asbr_status_update (struct ospf *ospf, u_char status)
if (status)
{
/* Already ASBR. */
- if (OSPF_IS_ASBR)
+ if (IS_OSPF_ASBR (ospf))
{
zlog_info ("ASBR[Status:%d]: Already ASBR", status);
return;
@@ -255,7 +255,7 @@ ospf_asbr_status_update (struct ospf *ospf, u_char status)
else
{
/* Already non ASBR. */
- if (! OSPF_IS_ASBR)
+ if (! IS_OSPF_ASBR (ospf))
{
zlog_info ("ASBR[Status:%d]: Already non ASBR", status);
return;
@@ -272,10 +272,12 @@ ospf_asbr_status_update (struct ospf *ospf, u_char status)
void
ospf_redistribute_withdraw (u_char type)
{
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
struct route_node *rn;
struct external_info *ei;
+ ospf = ospf_lookup ();
+
/* Delete external info for specified type. */
if (EXTERNAL_INFO (type))
for (rn = route_top (EXTERNAL_INFO (type)); rn; rn = route_next (rn))
diff --git a/ospfd/ospf_ia.c b/ospfd/ospf_ia.c
index 4dd90dc1..59f86669 100644
--- a/ospfd/ospf_ia.c
+++ b/ospfd/ospf_ia.c
@@ -617,7 +617,7 @@ ospf_ia_routing (struct ospf *ospf,
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_ia_routing():start");
- if (OSPF_IS_ABR)
+ if (IS_OSPF_ABR (ospf))
{
listnode node;
struct ospf_area *area;
diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c
index 6a4a4273..80538d57 100644
--- a/ospfd/ospf_interface.c
+++ b/ospfd/ospf_interface.c
@@ -1063,6 +1063,7 @@ ospf_if_init ()
{
/* Initialize Zebra interface data structure. */
if_init ();
+ om->iflist = iflist;
if_add_hook (IF_NEW_HOOK, ospf_if_new_hook);
if_add_hook (IF_DELETE_HOOK, ospf_if_delete_hook);
}
diff --git a/ospfd/ospf_ism.h b/ospfd/ospf_ism.h
index b04865af..6de8b8e2 100644
--- a/ospfd/ospf_ism.h
+++ b/ospfd/ospf_ism.h
@@ -46,17 +46,17 @@
#define ISM_InterfaceDown 7
#define OSPF_ISM_EVENT_MAX 8
-#define OSPF_ISM_WRITE_ON() \
+#define OSPF_ISM_WRITE_ON(O) \
do \
{ \
if (oi->on_write_q == 0) \
{ \
- listnode_add (ospf_top->oi_write_q, oi); \
+ listnode_add ((O)->oi_write_q, oi); \
oi->on_write_q = 1; \
} \
- if (ospf_top->t_write == NULL) \
- ospf_top->t_write = \
- thread_add_write (master, ospf_write, ospf_top, ospf_top->fd); \
+ if ((O)->t_write == NULL) \
+ (O)->t_write = \
+ thread_add_write (master, ospf_write, (O), (O)->fd); \
} while (0)
/* Macro for OSPF ISM timer turn on. */
diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c
index 7d91e63a..5d5ad08a 100644
--- a/ospfd/ospf_lsa.c
+++ b/ospfd/ospf_lsa.c
@@ -1637,7 +1637,7 @@ ospf_install_flood_nssa (struct ospf *ospf,
new2->data->type = OSPF_AS_NSSA_LSA;
/* set P-bit if not ABR */
- if (! OSPF_IS_ABR)
+ if (! IS_OSPF_ABR (ospf))
{
SET_FLAG(new2->data->options, OSPF_OPTION_NP);
@@ -1798,12 +1798,11 @@ ospf_external_lsa_originate_timer (struct thread *thread)
}
struct external_info *
-ospf_default_external_info ()
+ospf_default_external_info (struct ospf *ospf)
{
int type;
struct route_node *rn;
struct prefix_ipv4 p;
- struct ospf *ospf = ospf_top;
p.family = AF_INET;
p.prefix.s_addr = 0;
@@ -1833,8 +1832,10 @@ ospf_default_originate_timer (struct thread *thread)
struct prefix_ipv4 p;
struct in_addr nexthop;
struct external_info *ei;
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
+ ospf = ospf_lookup ();
+
/* Get originate flags. */
origin = THREAD_ARG (thread);
@@ -1850,7 +1851,7 @@ ospf_default_originate_timer (struct thread *thread)
ospf_external_info_add (DEFAULT_ROUTE, p, 0, nexthop);
}
- if ((ei = ospf_default_external_info ()))
+ if ((ei = ospf_default_external_info (ospf)))
ospf_external_lsa_originate (ospf, ei);
return 0;
@@ -1910,7 +1911,7 @@ ospf_external_lsa_refresh_default (struct ospf *ospf)
p.prefixlen = 0;
p.prefix.s_addr = 0;
- ei = ospf_default_external_info ();
+ ei = ospf_default_external_info (ospf);
lsa = ospf_external_info_find_lsa (ospf, &p);
if (ei)
@@ -2694,7 +2695,7 @@ ospf_lsa_lookup (struct ospf_area *area, u_int32_t type,
#ifdef HAVE_OPAQUE_LSA
case OSPF_OPAQUE_AS_LSA:
#endif /* HAVE_OPAQUE_LSA */
- return ospf_lsdb_lookup_by_id (ospf_top->lsdb, type, id, adv_router);
+ return ospf_lsdb_lookup_by_id (area->ospf->lsdb, type, id, adv_router);
break;
default:
break;
@@ -3117,7 +3118,9 @@ int
ospf_lsa_action (struct thread *t)
{
struct lsa_action *data;
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
+
+ ospf = ospf_lookup ();
data = THREAD_ARG (t);
diff --git a/ospfd/ospf_lsdb.c b/ospfd/ospf_lsdb.c
index 46d8d705..71a98ddc 100644
--- a/ospfd/ospf_lsdb.c
+++ b/ospfd/ospf_lsdb.c
@@ -282,18 +282,3 @@ ospf_lsdb_isempty (struct ospf_lsdb *lsdb)
{
return (lsdb->total == 0);
}
-
-struct ospf_lsa *
-foreach_lsa (struct route_table *table, void *p_arg, int int_arg,
- int (*callback) (struct ospf_lsa *, void *, int))
-{
- struct route_node *rn;
- struct ospf_lsa *lsa;
-
- for (rn = route_top (table); rn; rn = route_next (rn))
- if ((lsa = rn->info) != NULL)
- if (callback (lsa, p_arg, int_arg))
- return lsa;
-
- return NULL;
-}
diff --git a/ospfd/ospf_lsdb.h b/ospfd/ospf_lsdb.h
index dba1236a..302dddea 100644
--- a/ospfd/ospf_lsdb.h
+++ b/ospfd/ospf_lsdb.h
@@ -78,7 +78,5 @@ unsigned long ospf_lsdb_count_all (struct ospf_lsdb *);
unsigned long ospf_lsdb_count (struct ospf_lsdb *, int);
unsigned long ospf_lsdb_count_self (struct ospf_lsdb *, int);
unsigned long ospf_lsdb_isempty (struct ospf_lsdb *);
-struct ospf_lsa *foreach_lsa (struct route_table *, void *, int,
- int (*callback) (struct ospf_lsa *, void *, int));
#endif /* _ZEBRA_OSPF_LSDB_H */
diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c
index 82960b24..e649c17b 100644
--- a/ospfd/ospf_main.c
+++ b/ospfd/ospf_main.c
@@ -193,6 +193,9 @@ main (int argc, char **argv)
zlog_default = openzlog (progname, ZLOG_NOLOG, ZLOG_OSPF,
LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON);
+ /* OSPF master init. */
+ ospf_master_init ();
+
while (1)
{
int opt;
@@ -235,7 +238,7 @@ main (int argc, char **argv)
}
/* Initializations. */
- master = thread_master_create ();
+ master = om->master;
/* Library inits. */
signal_init ();
diff --git a/ospfd/ospf_nsm.h b/ospfd/ospf_nsm.h
index 3d257305..6c3dc4dd 100644
--- a/ospfd/ospf_nsm.h
+++ b/ospfd/ospf_nsm.h
@@ -54,28 +54,28 @@
#define OSPF_NSM_EVENT_MAX 14
/* Macro for OSPF NSM timer turn on. */
-#define OSPF_NSM_TIMER_ON(T,F,V) \
- do { \
- if (!(T)) \
- (T) = thread_add_timer (master, (F), nbr, (V)); \
+#define OSPF_NSM_TIMER_ON(T,F,V) \
+ do { \
+ if (!(T)) \
+ (T) = thread_add_timer (master, (F), nbr, (V)); \
} while (0)
/* Macro for OSPF NSM timer turn off. */
-#define OSPF_NSM_TIMER_OFF(X) \
- do { \
- if (X) \
- { \
- thread_cancel (X); \
- (X) = NULL; \
- } \
+#define OSPF_NSM_TIMER_OFF(X) \
+ do { \
+ if (X) \
+ { \
+ thread_cancel (X); \
+ (X) = NULL; \
+ } \
} while (0)
/* Macro for OSPF NSM schedule event. */
-#define OSPF_NSM_EVENT_SCHEDULE(N,E) \
+#define OSPF_NSM_EVENT_SCHEDULE(N,E) \
thread_add_event (master, ospf_nsm_event, (N), (E))
/* Macro for OSPF NSM execute event. */
-#define OSPF_NSM_EVENT_EXECUTE(N,E) \
+#define OSPF_NSM_EVENT_EXECUTE(N,E) \
thread_execute (master, ospf_nsm_event, (N), (E))
/* Prototypes. */
@@ -85,7 +85,6 @@ void ospf_check_nbr_loading (struct ospf_neighbor *);
int ospf_db_summary_isempty (struct ospf_neighbor *);
int ospf_db_summary_count (struct ospf_neighbor *);
void ospf_db_summary_clear (struct ospf_neighbor *);
-/* void ospf_db_summary_delete_all (struct ospf_neighbor *); */
#endif /* _ZEBRA_OSPF_NSM_H */
diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c
index eee62438..1ce70462 100644
--- a/ospfd/ospf_opaque.c
+++ b/ospfd/ospf_opaque.c
@@ -530,7 +530,7 @@ register_opaque_info_per_type (struct ospf_opaque_functab *functab,
listnode_add (new->area->opaque_lsa_self, oipt);
break;
case OSPF_OPAQUE_AS_LSA:
- top = ospf_top;
+ top = ospf_lookup ();
if (new->area != NULL && (top = new->area->ospf) == NULL)
{
free_opaque_info_per_type ((void *) oipt);
@@ -638,7 +638,7 @@ lookup_opaque_info_by_type (struct ospf_lsa *lsa)
zlog_warn ("Type-10 Opaque-LSA: Reference to AREA is missing?");
break;
case OSPF_OPAQUE_AS_LSA:
- top = ospf_top;
+ top = ospf_lookup ();
if ((area = lsa->area) != NULL && (top = area->ospf) == NULL)
{
zlog_warn ("Type-11 Opaque-LSA: Reference to OSPF is missing?");
@@ -1165,7 +1165,8 @@ show_opaque_info_detail (struct vty *vty, struct ospf_lsa *lsa)
/* Switch output functionality by vty address. */
if (vty != NULL)
{
- vty_out (vty, " Opaque-Type %u (%s)%s", opaque_type, ospf_opaque_type_name (opaque_type), VTY_NEWLINE);
+ vty_out (vty, " Opaque-Type %u (%s)%s", opaque_type,
+ ospf_opaque_type_name (opaque_type), VTY_NEWLINE);
vty_out (vty, " Opaque-ID 0x%x%s", opaque_id, VTY_NEWLINE);
vty_out (vty, " Opaque-Info: %u octets of data%s%s",
@@ -1175,7 +1176,8 @@ show_opaque_info_detail (struct vty *vty, struct ospf_lsa *lsa)
}
else
{
- zlog_info (" Opaque-Type %u (%s)", opaque_type, ospf_opaque_type_name (opaque_type));
+ zlog_info (" Opaque-Type %u (%s)", opaque_type,
+ ospf_opaque_type_name (opaque_type));
zlog_info (" Opaque-ID 0x%x", opaque_id);
zlog_info (" Opaque-Info: %u octets of data%s",
@@ -1566,7 +1568,7 @@ ospf_opaque_lsa_install (struct ospf_lsa *lsa, int rt_recalc)
}
break;
case OSPF_OPAQUE_AS_LSA:
- top = ospf_top;
+ top = ospf_lookup ();
if (lsa->area != NULL && (top = lsa->area->ospf) == NULL)
{
/* Above conditions must have passed. */
@@ -1589,9 +1591,11 @@ out:
void
ospf_opaque_lsa_refresh (struct ospf_lsa *lsa)
{
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
struct ospf_opaque_functab *functab;
+ ospf = ospf_lookup ();
+
if ((functab = ospf_opaque_functab_lookup (lsa)) == NULL
|| functab->lsa_refresher == NULL)
{
@@ -1934,12 +1938,14 @@ extern int ospf_lsa_refresh_delay (struct ospf_lsa *); /* ospf_lsa.c */
void
ospf_opaque_lsa_refresh_schedule (struct ospf_lsa *lsa0)
{
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf = ospf;
struct opaque_info_per_type *oipt;
struct opaque_info_per_id *oipi;
struct ospf_lsa *lsa;
int delay;
+ ospf = ospf_lookup ();
+
if ((oipt = lookup_opaque_info_by_type (lsa0)) == NULL
|| (oipi = lookup_opaque_info_by_id (oipt, lsa0)) == NULL)
{
@@ -2011,11 +2017,13 @@ ospf_opaque_lsa_refresh_timer (struct thread *t)
void
ospf_opaque_lsa_flush_schedule (struct ospf_lsa *lsa0)
{
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf = ospf;
struct opaque_info_per_type *oipt;
struct opaque_info_per_id *oipi;
struct ospf_lsa *lsa;
+ ospf = ospf_lookup ();
+
if ((oipt = lookup_opaque_info_by_type (lsa0)) == NULL
|| (oipi = lookup_opaque_info_by_id (oipt, lsa0)) == NULL)
{
diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c
index 9e445328..90782174 100644
--- a/ospfd/ospf_packet.c
+++ b/ospfd/ospf_packet.c
@@ -1961,7 +1961,8 @@ ospf_recv_packet (int fd, struct interface **ifp)
}
struct ospf_interface *
-ospf_associate_packet_vl (struct interface *ifp, struct ospf_interface *oi,
+ospf_associate_packet_vl (struct ospf *ospf,
+ struct interface *ifp, struct ospf_interface *oi,
struct ip *iph, struct ospf_header *ospfh)
{
struct ospf_interface *rcv_oi;
@@ -1975,17 +1976,17 @@ ospf_associate_packet_vl (struct interface *ifp, struct ospf_interface *oi,
if ((rcv_oi = oi) == NULL)
{
- if ((rcv_oi = ospf_if_lookup_by_local_addr (oi->ospf, ifp,
+ if ((rcv_oi = ospf_if_lookup_by_local_addr (ospf, ifp,
iph->ip_dst)) == NULL)
return NULL;
}
- for (node = listhead (oi->ospf->vlinks); node; nextnode (node))
+ for (node = listhead (ospf->vlinks); node; nextnode (node))
{
if ((vl_data = getdata (node)) == NULL)
continue;
- vl_area = ospf_area_lookup_by_area_id (oi->ospf, vl_data->vl_area_id);
+ vl_area = ospf_area_lookup_by_area_id (ospf, vl_data->vl_area_id);
if (!vl_area)
continue;
@@ -2237,7 +2238,7 @@ ospf_read (struct thread *thread)
return 0;
}
- if ((oi = ospf_associate_packet_vl (ifp, oi, iph, ospfh)) == NULL)
+ if ((oi = ospf_associate_packet_vl (ospf, ifp, oi, iph, ospfh)) == NULL)
{
stream_free (ibuf);
return 0;
@@ -2773,7 +2774,7 @@ ospf_hello_send_sub (struct ospf_interface *oi, struct in_addr *addr)
ospf_packet_add (oi, op);
/* Hook thread to write packet. */
- OSPF_ISM_WRITE_ON ();
+ OSPF_ISM_WRITE_ON (oi->ospf);
}
void
@@ -2908,7 +2909,7 @@ ospf_hello_send (struct ospf_interface *oi)
/* Add packet to the interface output queue. */
ospf_packet_add (oi, op_dup);
- OSPF_ISM_WRITE_ON ();
+ OSPF_ISM_WRITE_ON (oi->ospf);
}
}
@@ -2926,7 +2927,7 @@ ospf_hello_send (struct ospf_interface *oi)
ospf_packet_add (oi, op);
/* Hook thread to write packet. */
- OSPF_ISM_WRITE_ON ();
+ OSPF_ISM_WRITE_ON (oi->ospf);
}
}
@@ -2960,7 +2961,7 @@ ospf_db_desc_send (struct ospf_neighbor *nbr)
ospf_packet_add (oi, op);
/* Hook thread to write packet. */
- OSPF_ISM_WRITE_ON ();
+ OSPF_ISM_WRITE_ON (oi->ospf);
/* Remove old DD packet, then copy new one and keep in neighbor structure. */
if (nbr->last_send)
@@ -2981,7 +2982,7 @@ ospf_db_desc_resend (struct ospf_neighbor *nbr)
ospf_packet_add (oi, ospf_packet_dup (nbr->last_send));
/* Hook thread to write packet. */
- OSPF_ISM_WRITE_ON ();
+ OSPF_ISM_WRITE_ON (oi->ospf);
}
/* Send Link State Request. */
@@ -3019,7 +3020,7 @@ ospf_ls_req_send (struct ospf_neighbor *nbr)
ospf_packet_add (oi, op);
/* Hook thread to write packet. */
- OSPF_ISM_WRITE_ON ();
+ OSPF_ISM_WRITE_ON (oi->ospf);
/* Add Link State Request Retransmission Timer. */
OSPF_NSM_TIMER_ON (nbr->t_ls_req, ospf_ls_req_timer, nbr->v_ls_req);
@@ -3072,7 +3073,7 @@ ospf_ls_upd_queue_send (struct ospf_interface *oi, list update,
ospf_packet_add (oi, op);
/* Hook thread to write packet. */
- OSPF_ISM_WRITE_ON ();
+ OSPF_ISM_WRITE_ON (oi->ospf);
}
static int
@@ -3181,7 +3182,7 @@ ospf_ls_ack_send_list (struct ospf_interface *oi, list ack, struct in_addr dst)
ospf_packet_add (oi, op);
/* Hook thread to write packet. */
- OSPF_ISM_WRITE_ON ();
+ OSPF_ISM_WRITE_ON (oi->ospf);
}
static int
diff --git a/ospfd/ospf_route.c b/ospfd/ospf_route.c
index cc3b6787..3733ca55 100644
--- a/ospfd/ospf_route.c
+++ b/ospfd/ospf_route.c
@@ -676,9 +676,10 @@ ospf_route_table_dump (struct route_table *rt)
void
ospf_terminate ()
{
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
+ listnode node;
- if (ospf)
+ LIST_LOOP (om->ospf, ospf, node)
{
if (ospf->new_table)
ospf_route_delete (ospf->new_table);
diff --git a/ospfd/ospf_routemap.c b/ospfd/ospf_routemap.c
index a4d05a13..017acb2b 100644
--- a/ospfd/ospf_routemap.c
+++ b/ospfd/ospf_routemap.c
@@ -43,26 +43,29 @@
void
ospf_route_map_update (char *name)
{
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
int type;
/* If OSPF instatnce does not exist, return right now. */
+ ospf = ospf_lookup ();
if (ospf == NULL)
return;
/* Update route-map */
for (type = 0; type <= ZEBRA_ROUTE_MAX; type++)
{
- if (ROUTEMAP_NAME (type) && strcmp (ROUTEMAP_NAME (type), name) == 0)
+ if (ROUTEMAP_NAME (ospf, type)
+ && strcmp (ROUTEMAP_NAME (ospf, type), name) == 0)
{
/* Keep old route-map. */
- struct route_map *old = ROUTEMAP (type);
+ struct route_map *old = ROUTEMAP (ospf, type);
/* Update route-map. */
- ROUTEMAP (type) = route_map_lookup_by_name (ROUTEMAP_NAME (type));
+ ROUTEMAP (ospf, type) =
+ route_map_lookup_by_name (ROUTEMAP_NAME (ospf, type));
/* No update for this distribute type. */
- if (old == NULL && ROUTEMAP (type) == NULL)
+ if (old == NULL && ROUTEMAP (ospf, type) == NULL)
continue;
ospf_distribute_list_update (ospf, type);
@@ -73,18 +76,19 @@ ospf_route_map_update (char *name)
void
ospf_route_map_event (route_map_event_t event, char *name)
{
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
int type;
/* If OSPF instatnce does not exist, return right now. */
+ ospf = ospf_lookup ();
if (ospf == NULL)
return;
/* Update route-map. */
for (type = 0; type <= ZEBRA_ROUTE_MAX; type++)
{
- if (ROUTEMAP_NAME (type) && ROUTEMAP (type) &&
- !strcmp (ROUTEMAP_NAME (type), name))
+ if (ROUTEMAP_NAME (ospf, type) && ROUTEMAP (ospf, type)
+ && !strcmp (ROUTEMAP_NAME (ospf, type), name))
{
ospf_distribute_list_update (ospf, type);
}
diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c
index 389fd73c..0fe9cae6 100644
--- a/ospfd/ospf_snmp.c
+++ b/ospfd/ospf_snmp.c
@@ -515,7 +515,9 @@ static u_char *
ospfGeneralGroup (struct variable *v, oid *name, size_t *length,
int exact, size_t *var_len, WriteMethod **write_method)
{
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
+
+ ospf = ospf_lookup ();
/* Check whether the instance identifier is valid */
if (smux_header_generic (v, name, length, exact, var_len, write_method)
@@ -616,7 +618,7 @@ ospf_area_lookup_next (struct ospf *ospf, struct in_addr *area_id, int first)
struct ospf_area *area;
listnode node;
- if (! ospf_top)
+ if (ospf == NULL)
return NULL;
if (first)
@@ -647,10 +649,11 @@ struct ospf_area *
ospfAreaLookup (struct variable *v, oid name[], size_t *length,
struct in_addr *addr, int exact)
{
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
struct ospf_area *area;
int len;
+ ospf = ospf_lookup ();
if (ospf == NULL)
return NULL;
@@ -750,11 +753,13 @@ ospf_stub_area_lookup_next (struct in_addr *area_id, int first)
{
struct ospf_area *area;
listnode node;
+ struct ospf *ospf;
- if (! ospf_top)
+ ospf = ospf_lookup ();
+ if (ospf == NULL)
return NULL;
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
{
area = getdata (node);
@@ -779,11 +784,12 @@ struct ospf_area *
ospfStubAreaLookup (struct variable *v, oid name[], size_t *length,
struct in_addr *addr, int exact)
{
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
struct ospf_area *area;
int len;
- if (! ospf_top)
+ ospf = ospf_lookup ();
+ if (ospf == NULL)
return NULL;
/* Exact lookup. */
@@ -907,7 +913,7 @@ ospfLsdbLookup (struct variable *v, oid *name, size_t *length,
struct in_addr *area_id, u_char *type,
struct in_addr *ls_id, struct in_addr *router_id, int exact)
{
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
struct ospf_area *area;
struct ospf_lsa *lsa;
int len;
@@ -917,6 +923,8 @@ ospfLsdbLookup (struct variable *v, oid *name, size_t *length,
oid *offset;
int offsetlen;
+ ospf = ospf_lookup ();
+
#define OSPF_LSDB_ENTRY_OFFSET \
(IN_ADDR_SIZE + 1 + IN_ADDR_SIZE + IN_ADDR_SIZE)
@@ -1055,6 +1063,7 @@ ospfLsdbEntry (struct variable *v, oid *name, size_t *length, int exact,
u_char type;
struct in_addr ls_id;
struct in_addr router_id;
+ struct ospf *ospf;
/* INDEX { ospfLsdbAreaId, ospfLsdbType,
ospfLsdbLsid, ospfLsdbRouterId } */
@@ -1065,7 +1074,8 @@ ospfLsdbEntry (struct variable *v, oid *name, size_t *length, int exact,
memset (&router_id, 0, sizeof (struct in_addr));
/* Check OSPF instance. */
- if (! ospf_top)
+ ospf = ospf_lookup ();
+ if (ospf == NULL)
return NULL;
lsa = ospfLsdbLookup (v, name, length, &area_id, &type, &ls_id, &router_id,
@@ -1118,13 +1128,15 @@ ospfAreaRangeLookup (struct variable *v, oid *name, size_t *length,
oid *offset;
int offsetlen;
int len;
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
struct ospf_area *area;
struct ospf_area_range *range;
struct prefix_ipv4 p;
p.family = AF_INET;
p.prefixlen = IPV4_MAX_BITLEN;
+ ospf = ospf_lookup ();
+
if (exact)
{
/* Area ID + Range Network. */
@@ -1213,9 +1225,10 @@ ospfAreaRangeEntry (struct variable *v, oid *name, size_t *length, int exact,
struct in_addr area_id;
struct in_addr range_net;
struct in_addr mask;
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
/* Check OSPF instance. */
+ ospf = ospf_lookup ();
if (ospf == NULL)
return NULL;
@@ -1262,8 +1275,9 @@ ospfHostLookup (struct variable *v, oid *name, size_t *length,
{
int len;
struct ospf_nbr_nbma *nbr_nbma;
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
+ ospf = ospf_lookup ();
if (ospf == NULL)
return NULL;
@@ -1315,9 +1329,10 @@ ospfHostEntry (struct variable *v, oid *name, size_t *length, int exact,
struct ospf_nbr_nbma *nbr_nbma;
struct ospf_interface *oi;
struct in_addr addr;
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
/* Check OSPF instance. */
+ ospf = ospf_lookup ();
if (ospf == NULL)
return NULL;
@@ -1606,12 +1621,13 @@ ospfIfEntry (struct variable *v, oid *name, size_t *length, int exact,
unsigned int ifindex;
struct in_addr ifaddr;
struct ospf_interface *oi;
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
ifindex = 0;
memset (&ifaddr, 0, sizeof (struct in_addr));
/* Check OSPF instance. */
+ ospf = ospf_lookup ();
if (ospf == NULL)
return NULL;
@@ -1778,12 +1794,13 @@ ospfIfMetricEntry (struct variable *v, oid *name, size_t *length, int exact,
unsigned int ifindex;
struct in_addr ifaddr;
struct ospf_interface *oi;
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
ifindex = 0;
memset (&ifaddr, 0, sizeof (struct in_addr));
/* Check OSPF instance. */
+ ospf = ospf_lookup ();
if (ospf == NULL)
return NULL;
@@ -2068,8 +2085,9 @@ ospf_snmp_nbr_lookup_next (struct in_addr *nbr_addr, unsigned int *ifindex,
struct ospf_neighbor *nbr;
struct route_node *rn;
struct ospf_neighbor *min = NULL;
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf = ospf;
+ ospf = ospf_lookup ();
LIST_LOOP (ospf->oiflist, oi, nn)
{
for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
@@ -2110,7 +2128,9 @@ ospfNbrLookup (struct variable *v, oid *name, size_t *length,
int len;
int first;
struct ospf_neighbor *nbr;
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
+
+ ospf = ospf_lookup ();
if (exact)
{
@@ -2221,12 +2241,13 @@ ospfVirtNbrEntry (struct variable *v, oid *name, size_t *length, int exact,
struct ospf_vl_data *vl_data;
struct in_addr area_id;
struct in_addr neighbor;
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
memset (&area_id, 0, sizeof (struct in_addr));
memset (&neighbor, 0, sizeof (struct in_addr));
/* Check OSPF instance. */
+ ospf = ospf_lookup ();
if (ospf == NULL)
return NULL;
@@ -2278,8 +2299,9 @@ ospfExtLsdbLookup (struct variable *v, oid *name, size_t *length, u_char *type,
u_char lsa_type;
int len;
struct ospf_lsa *lsa;
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
+ ospf = ospf_lookup ();
if (exact)
{
if (*length != v->namelen + 1 + IN_ADDR_SIZE + IN_ADDR_SIZE)
@@ -2367,13 +2389,14 @@ ospfExtLsdbEntry (struct variable *v, oid *name, size_t *length, int exact,
u_char type;
struct in_addr ls_id;
struct in_addr router_id;
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
type = OSPF_AS_EXTERNAL_LSA;
memset (&ls_id, 0, sizeof (struct in_addr));
memset (&router_id, 0, sizeof (struct in_addr));
/* Check OSPF instance. */
+ ospf = ospf_lookup ();
if (ospf == NULL)
return NULL;
diff --git a/ospfd/ospf_spf.c b/ospfd/ospf_spf.c
index 759304c8..412e44d7 100644
--- a/ospfd/ospf_spf.c
+++ b/ospfd/ospf_spf.c
@@ -1057,7 +1057,7 @@ ospf_spf_calculate_timer (struct thread *thread)
ospf->old_rtrs = ospf->new_rtrs;
ospf->new_rtrs = new_rtrs;
- if (OSPF_IS_ABR)
+ if (IS_OSPF_ABR (ospf))
ospf_abr_task (ospf);
if (IS_DEBUG_OSPF_EVENT)
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index 2bb24b8c..4896d352 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -181,13 +181,16 @@ DEFUN (no_router_ospf,
"Enable a routing process\n"
"Start OSPF configuration\n")
{
- if (ospf_top == NULL)
+ struct ospf *ospf;
+
+ ospf = ospf_lookup ();
+ if (ospf == NULL)
{
- vty_out (vty, "There isn't active ospf instance.%s", VTY_NEWLINE);
+ vty_out (vty, "There isn't active ospf instance%s", VTY_NEWLINE);
return CMD_WARNING;
}
- ospf_finish (ospf_top);
+ ospf_finish (ospf);
return CMD_SUCCESS;
}
@@ -213,9 +216,8 @@ DEFUN (ospf_router_id,
ospf->router_id_static = router_id;
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);
return CMD_SUCCESS;
}
@@ -2298,8 +2300,8 @@ DEFUN (auto_cost_reference_bandwidth,
vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
- for (node = listhead (ospf->iflist); node; nextnode (node))
- ospf_if_recalculate_output_cost (getdata (node));
+ for (node = listhead (om->iflist); node; nextnode (node))
+ ospf_if_recalculate_output_cost (getdata (node));
return CMD_SUCCESS;
}
@@ -2321,8 +2323,8 @@ DEFUN (no_auto_cost_reference_bandwidth,
vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
- for (node = listhead (ospf->iflist); node; nextnode (node))
- ospf_if_recalculate_output_cost (getdata (node));
+ for (node = listhead (om->iflist); node; nextnode (node))
+ ospf_if_recalculate_output_cost (getdata (node));
return CMD_SUCCESS;
}
@@ -2386,7 +2388,7 @@ show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
if (area->external_routing == OSPF_AREA_NSSA)
{
vty_out (vty, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE, VTY_NEWLINE);
- if (! OSPF_IS_ABR)
+ if (! IS_OSPF_ABR (area->ospf))
vty_out (vty, " It is not ABR, therefore not Translator. %s",
VTY_NEWLINE);
else
@@ -2435,9 +2437,10 @@ DEFUN (show_ip_ospf,
{
listnode node;
struct ospf_area * area;
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
/* Check OSPF is enable. */
+ ospf = ospf_lookup ();
if (ospf == NULL)
{
vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
@@ -2619,9 +2622,11 @@ DEFUN (show_ip_ospf_interface,
"Interface name\n")
{
struct interface *ifp;
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
listnode node;
+ ospf = ospf_lookup ();
+
/* Show All Interfaces. */
if (argc == 0)
for (node = listhead (iflist); node; nextnode (node))
@@ -2679,9 +2684,10 @@ DEFUN (show_ip_ospf_neighbor,
"OSPF information\n"
"Neighbor list\n")
{
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
listnode node;
+ ospf = ospf_lookup ();
if (ospf == NULL)
{
vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
@@ -2694,7 +2700,7 @@ DEFUN (show_ip_ospf_neighbor,
"RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
for (node = listhead (ospf->oiflist); node; nextnode (node))
- show_ip_ospf_neighbor_sub (vty, getdata (node));
+ show_ip_ospf_neighbor_sub (vty, getdata (node));
return CMD_SUCCESS;
}
@@ -2760,17 +2766,11 @@ DEFUN (show_ip_ospf_neighbor_int,
"Neighbor list\n"
"Interface name\n")
{
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
struct ospf_interface *oi;
struct in_addr addr;
int ret;
- if (ospf == NULL)
- {
- vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
- return CMD_SUCCESS;
- }
-
ret = inet_aton (argv[0], &addr);
if (!ret)
{
@@ -2779,6 +2779,13 @@ DEFUN (show_ip_ospf_neighbor_int,
return CMD_WARNING;
}
+ ospf = ospf_lookup ();
+ if (ospf == NULL)
+ {
+ vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
+ return CMD_SUCCESS;
+ }
+
if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL)
vty_out (vty, "No such interface address%s", VTY_NEWLINE);
else
@@ -2891,7 +2898,7 @@ DEFUN (show_ip_ospf_neighbor_id,
"Neighbor list\n"
"Neighbor ID\n")
{
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
listnode node;
struct ospf_neighbor *nbr;
struct in_addr router_id;
@@ -2904,6 +2911,13 @@ DEFUN (show_ip_ospf_neighbor_id,
return CMD_WARNING;
}
+ ospf = ospf_lookup ();
+ if (ospf == NULL)
+ {
+ vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
+ return CMD_SUCCESS;
+ }
+
for (node = listhead (ospf->oiflist); node; nextnode (node))
{
struct ospf_interface *oi = getdata (node);
@@ -2928,11 +2942,15 @@ DEFUN (show_ip_ospf_neighbor_detail,
"Neighbor list\n"
"detail of all neighbors\n")
{
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
listnode node;
+ ospf = ospf_lookup ();
if (ospf == NULL)
- return CMD_SUCCESS;
+ {
+ vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
+ return CMD_SUCCESS;
+ }
for (node = listhead (ospf->oiflist); node; nextnode (node))
{
@@ -2960,11 +2978,15 @@ DEFUN (show_ip_ospf_neighbor_detail_all,
"detail of all neighbors\n"
"include down status neighbor\n")
{
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
listnode node;
+ ospf = ospf_lookup ();
if (ospf == NULL)
- return CMD_SUCCESS;
+ {
+ vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
+ return CMD_SUCCESS;
+ }
for (node = listhead (ospf->oiflist); node; nextnode (node))
{
@@ -3005,6 +3027,7 @@ DEFUN (show_ip_ospf_neighbor_int_detail,
"Interface address\n"
"detail of all neighbors")
{
+ struct ospf *ospf;
struct ospf_interface *oi;
struct in_addr addr;
int ret;
@@ -3017,10 +3040,14 @@ DEFUN (show_ip_ospf_neighbor_int_detail,
return CMD_WARNING;
}
- if (ospf_top == NULL)
- return CMD_WARNING;
+ ospf = ospf_lookup ();
+ if (ospf == NULL)
+ {
+ vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
+ return CMD_SUCCESS;
+ }
- if ((oi = ospf_if_is_configured (ospf_top, &addr)) == NULL)
+ if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL)
vty_out (vty, "No such interface address%s", VTY_NEWLINE);
else
{
@@ -3040,9 +3067,8 @@ DEFUN (show_ip_ospf_neighbor_int_detail,
/* Show functions */
int
-show_lsa_summary (struct ospf_lsa *lsa, void *v, int self)
+show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
{
- struct vty *vty = (struct vty *) v;
struct router_lsa *rl;
struct summary_lsa *sl;
struct as_external_lsa *asel;
@@ -3501,10 +3527,9 @@ show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
/* Show detail LSA information
-- if id is NULL then show all LSAs. */
void
-show_lsa_detail (struct vty *vty, int type,
+show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
struct in_addr *id, struct in_addr *adv_router)
{
- struct ospf *ospf = ospf_top;
listnode node;
switch (type)
@@ -3553,10 +3578,9 @@ show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
/* Show detail LSA information. */
void
-show_lsa_detail_adv_router (struct vty *vty, int type,
+show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
struct in_addr *adv_router)
{
- struct ospf *ospf = ospf_top;
listnode node;
switch (type)
@@ -3586,9 +3610,10 @@ show_lsa_detail_adv_router (struct vty *vty, int type,
}
void
-show_ip_ospf_database_summary (struct vty *vty, int self)
+show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
{
- struct ospf *ospf = ospf_top;
+ struct ospf_lsa *lsa;
+ struct route_node *rn;
listnode node;
int type;
@@ -3616,7 +3641,8 @@ show_ip_ospf_database_summary (struct vty *vty, int self)
VTY_NEWLINE, VTY_NEWLINE);
vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
- foreach_lsa (AREA_LSDB (area, type), vty, self, show_lsa_summary);
+ LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
+ show_lsa_summary (vty, lsa, self);
vty_out (vty, "%s", VTY_NEWLINE);
}
@@ -3643,7 +3669,10 @@ show_ip_ospf_database_summary (struct vty *vty, int self)
VTY_NEWLINE, VTY_NEWLINE);
vty_out (vty, "%s%s", show_database_header[type],
VTY_NEWLINE);
- foreach_lsa (AS_LSDB (ospf, type), vty, self, show_lsa_summary);
+
+ LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
+ show_lsa_summary (vty, lsa, self);
+
vty_out (vty, "%s", VTY_NEWLINE);
}
}
@@ -3652,9 +3681,8 @@ show_ip_ospf_database_summary (struct vty *vty, int self)
}
void
-show_ip_ospf_database_maxage (struct vty *vty)
+show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
{
- struct ospf *ospf = ospf_top;
listnode node;
struct ospf_lsa *lsa;
@@ -3718,10 +3746,11 @@ DEFUN (show_ip_ospf_database,
"OSPF information\n"
"Database summary\n")
{
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
int type, ret;
struct in_addr id, adv_router;
+ ospf = ospf_lookup ();
if (ospf == NULL)
return CMD_SUCCESS;
@@ -3731,7 +3760,7 @@ DEFUN (show_ip_ospf_database,
/* Show all LSA. */
if (argc == 0)
{
- show_ip_ospf_database_summary (vty, 0);
+ show_ip_ospf_database_summary (vty, ospf, 0);
return CMD_SUCCESS;
}
@@ -3752,12 +3781,12 @@ DEFUN (show_ip_ospf_database,
type = OSPF_AS_EXTERNAL_LSA;
else if (strncmp (argv[0], "se", 2) == 0)
{
- show_ip_ospf_database_summary (vty, 1);
+ show_ip_ospf_database_summary (vty, ospf, 1);
return CMD_SUCCESS;
}
else if (strncmp (argv[0], "m", 1) == 0)
{
- show_ip_ospf_database_maxage (vty);
+ show_ip_ospf_database_maxage (vty, ospf);
return CMD_SUCCESS;
}
#ifdef HAVE_OPAQUE_LSA
@@ -3773,7 +3802,7 @@ DEFUN (show_ip_ospf_database,
/* `show ip ospf database LSA'. */
if (argc == 1)
- show_lsa_detail (vty, type, NULL, NULL);
+ show_lsa_detail (vty, ospf, type, NULL, NULL);
else if (argc >= 2)
{
ret = inet_aton (argv[1], &id);
@@ -3782,7 +3811,7 @@ DEFUN (show_ip_ospf_database,
/* `show ip ospf database LSA ID'. */
if (argc == 2)
- show_lsa_detail (vty, type, &id, NULL);
+ show_lsa_detail (vty, ospf, type, &id, NULL);
/* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
else if (argc == 3)
{
@@ -3794,7 +3823,7 @@ DEFUN (show_ip_ospf_database,
if (!ret)
return CMD_WARNING;
}
- show_lsa_detail (vty, type, &id, &adv_router);
+ show_lsa_detail (vty, ospf, type, &id, &adv_router);
}
}
@@ -3857,10 +3886,11 @@ DEFUN (show_ip_ospf_database_type_adv_router,
"Advertising Router link states\n"
"Advertising Router (as an IP address)\n")
{
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
int type, ret;
struct in_addr adv_router;
+ ospf = ospf_lookup ();
if (ospf == NULL)
return CMD_SUCCESS;
@@ -3906,7 +3936,7 @@ DEFUN (show_ip_ospf_database_type_adv_router,
return CMD_WARNING;
}
- show_lsa_detail_adv_router (vty, type, &adv_router);
+ show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
return CMD_SUCCESS;
}
@@ -4489,8 +4519,10 @@ DEFUN (ip_ospf_dead_interval,
struct ospf_if_params *params;
struct ospf_interface *oi;
struct route_node *rn;
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
+ ospf = ospf_lookup ();
+
params = IF_DEF_PARAMS (ifp);
seconds = strtol (argv[0], NULL, 10);
@@ -4569,8 +4601,10 @@ DEFUN (no_ip_ospf_dead_interval,
struct ospf_if_params *params;
struct ospf_interface *oi;
struct route_node *rn;
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
+ ospf = ospf_lookup ();
+
ifp = vty->index;
params = IF_DEF_PARAMS (ifp);
@@ -5263,6 +5297,7 @@ DEFUN (ospf_redistribute_source_metric_type,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ struct ospf *ospf = vty->index;
int source;
int type = -1;
int metric = -1;
@@ -5282,11 +5317,11 @@ DEFUN (ospf_redistribute_source_metric_type,
return CMD_WARNING;
if (argc == 4)
- ospf_routemap_set (source, argv[3]);
+ ospf_routemap_set (ospf, source, argv[3]);
else
- ospf_routemap_unset (source);
+ ospf_routemap_unset (ospf, source);
- return ospf_redistribute_set (source, type, metric);
+ return ospf_redistribute_set (ospf, source, type, metric);
}
ALIAS (ospf_redistribute_source_metric_type,
@@ -5333,6 +5368,7 @@ DEFUN (ospf_redistribute_source_type_metric,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ struct ospf *ospf = vty->index;
int source;
int type = -1;
int metric = -1;
@@ -5352,11 +5388,11 @@ DEFUN (ospf_redistribute_source_type_metric,
return CMD_WARNING;
if (argc == 4)
- ospf_routemap_set (source, argv[3]);
+ ospf_routemap_set (ospf, source, argv[3]);
else
- ospf_routemap_unset (source);
+ ospf_routemap_unset (ospf, source);
- return ospf_redistribute_set (source, type, metric);
+ return ospf_redistribute_set (ospf, source, type, metric);
}
ALIAS (ospf_redistribute_source_type_metric,
@@ -5411,6 +5447,7 @@ DEFUN (ospf_redistribute_source_metric_routemap,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ struct ospf *ospf = vty->index;
int source;
int metric = -1;
@@ -5424,11 +5461,11 @@ DEFUN (ospf_redistribute_source_metric_routemap,
return CMD_WARNING;
if (argc == 3)
- ospf_routemap_set (source, argv[2]);
+ ospf_routemap_set (ospf, source, argv[2]);
else
- ospf_routemap_unset (source);
+ ospf_routemap_unset (ospf, source);
- return ospf_redistribute_set (source, -1, metric);
+ return ospf_redistribute_set (ospf, source, -1, metric);
}
DEFUN (ospf_redistribute_source_type_routemap,
@@ -5446,6 +5483,7 @@ DEFUN (ospf_redistribute_source_type_routemap,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ struct ospf *ospf = vty->index;
int source;
int type = -1;
@@ -5459,11 +5497,11 @@ DEFUN (ospf_redistribute_source_type_routemap,
return CMD_WARNING;
if (argc == 3)
- ospf_routemap_set (source, argv[2]);
+ ospf_routemap_set (ospf, source, argv[2]);
else
- ospf_routemap_unset (source);
+ ospf_routemap_unset (ospf, source);
- return ospf_redistribute_set (source, type, -1);
+ return ospf_redistribute_set (ospf, source, type, -1);
}
DEFUN (ospf_redistribute_source_routemap,
@@ -5478,6 +5516,7 @@ DEFUN (ospf_redistribute_source_routemap,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ struct ospf *ospf = vty->index;
int source;
/* Get distribute source. */
@@ -5485,11 +5524,11 @@ DEFUN (ospf_redistribute_source_routemap,
return CMD_WARNING;
if (argc == 2)
- ospf_routemap_set (source, argv[1]);
+ ospf_routemap_set (ospf, source, argv[1]);
else
- ospf_routemap_unset (source);
+ ospf_routemap_unset (ospf, source);
- return ospf_redistribute_set (source, -1, -1);
+ return ospf_redistribute_set (ospf, source, -1, -1);
}
DEFUN (no_ospf_redistribute_source,
@@ -5503,13 +5542,14 @@ DEFUN (no_ospf_redistribute_source,
"Routing Information Protocol (RIP)\n"
"Border Gateway Protocol (BGP)\n")
{
+ struct ospf *ospf = vty->index;
int source;
if (!str2distribute_source (argv[0], &source))
return CMD_WARNING;
- ospf_routemap_unset (source);
- return ospf_redistribute_unset (source);
+ ospf_routemap_unset (ospf, source);
+ return ospf_redistribute_unset (ospf, source);
}
DEFUN (ospf_distribute_list_out,
@@ -5570,6 +5610,7 @@ DEFUN (ospf_default_information_originate_metric_type_routemap,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ struct ospf *ospf = vty->index;
int type = -1;
int metric = -1;
@@ -5584,11 +5625,12 @@ DEFUN (ospf_default_information_originate_metric_type_routemap,
return CMD_WARNING;
if (argc == 3)
- ospf_routemap_set (DEFAULT_ROUTE, argv[2]);
+ ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
else
- ospf_routemap_unset (DEFAULT_ROUTE);
+ ospf_routemap_unset (ospf, DEFAULT_ROUTE);
- return ospf_redistribute_default_set (DEFAULT_ORIGINATE_ZEBRA, type, metric);
+ return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
+ type, metric);
}
ALIAS (ospf_default_information_originate_metric_type_routemap,
@@ -5627,6 +5669,7 @@ DEFUN (ospf_default_information_originate_metric_routemap,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ struct ospf *ospf = vty->index;
int metric = -1;
/* Get metric value. */
@@ -5635,11 +5678,12 @@ DEFUN (ospf_default_information_originate_metric_routemap,
return CMD_WARNING;
if (argc == 2)
- ospf_routemap_set (DEFAULT_ROUTE, argv[1]);
+ ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
else
- ospf_routemap_unset (DEFAULT_ROUTE);
+ ospf_routemap_unset (ospf, DEFAULT_ROUTE);
- return ospf_redistribute_default_set (DEFAULT_ORIGINATE_ZEBRA, -1, metric);
+ return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
+ -1, metric);
}
/* Default information originate. */
@@ -5651,12 +5695,14 @@ DEFUN (ospf_default_information_originate_routemap,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ struct ospf *ospf = vty->index;
+
if (argc == 1)
- ospf_routemap_set (DEFAULT_ROUTE, argv[0]);
+ ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
else
- ospf_routemap_unset (DEFAULT_ROUTE);
+ ospf_routemap_unset (ospf, DEFAULT_ROUTE);
- return ospf_redistribute_default_set (DEFAULT_ORIGINATE_ZEBRA, -1, -1);
+ return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
}
DEFUN (ospf_default_information_originate_type_metric_routemap,
@@ -5672,6 +5718,7 @@ DEFUN (ospf_default_information_originate_type_metric_routemap,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ struct ospf *ospf = vty->index;
int type = -1;
int metric = -1;
@@ -5686,11 +5733,12 @@ DEFUN (ospf_default_information_originate_type_metric_routemap,
return CMD_WARNING;
if (argc == 3)
- ospf_routemap_set (DEFAULT_ROUTE, argv[2]);
+ ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
else
- ospf_routemap_unset (DEFAULT_ROUTE);
+ ospf_routemap_unset (ospf, DEFAULT_ROUTE);
- return ospf_redistribute_default_set (DEFAULT_ORIGINATE_ZEBRA, type, metric);
+ return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
+ type, metric);
}
ALIAS (ospf_default_information_originate_type_metric_routemap,
@@ -5724,6 +5772,7 @@ DEFUN (ospf_default_information_originate_type_routemap,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ struct ospf *ospf = vty->index;
int type = -1;
/* Get metric type. */
@@ -5732,11 +5781,12 @@ DEFUN (ospf_default_information_originate_type_routemap,
return CMD_WARNING;
if (argc == 2)
- ospf_routemap_set (DEFAULT_ROUTE, argv[1]);
+ ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
else
- ospf_routemap_unset (DEFAULT_ROUTE);
+ ospf_routemap_unset (ospf, DEFAULT_ROUTE);
- return ospf_redistribute_default_set (DEFAULT_ORIGINATE_ZEBRA, type, -1);
+ return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
+ type, -1);
}
DEFUN (ospf_default_information_originate_always_metric_type_routemap,
@@ -5753,6 +5803,7 @@ DEFUN (ospf_default_information_originate_always_metric_type_routemap,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ struct ospf *ospf = vty->index;
int type = -1;
int metric = -1;
@@ -5767,11 +5818,11 @@ DEFUN (ospf_default_information_originate_always_metric_type_routemap,
return CMD_WARNING;
if (argc == 3)
- ospf_routemap_set (DEFAULT_ROUTE, argv[2]);
+ ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
else
- ospf_routemap_unset (DEFAULT_ROUTE);
+ ospf_routemap_unset (ospf, DEFAULT_ROUTE);
- return ospf_redistribute_default_set (DEFAULT_ORIGINATE_ALWAYS,
+ return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
type, metric);
}
@@ -5815,6 +5866,7 @@ DEFUN (ospf_default_information_originate_always_metric_routemap,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ struct ospf *ospf = vty->index;
int metric = -1;
/* Get metric value. */
@@ -5823,11 +5875,12 @@ DEFUN (ospf_default_information_originate_always_metric_routemap,
return CMD_WARNING;
if (argc == 2)
- ospf_routemap_set (DEFAULT_ROUTE, argv[1]);
+ ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
else
- ospf_routemap_unset (DEFAULT_ROUTE);
+ ospf_routemap_unset (ospf, DEFAULT_ROUTE);
- return ospf_redistribute_default_set (DEFAULT_ORIGINATE_ALWAYS, -1, metric);
+ return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
+ -1, metric);
}
DEFUN (ospf_default_information_originate_always_routemap,
@@ -5839,12 +5892,14 @@ DEFUN (ospf_default_information_originate_always_routemap,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ struct ospf *ospf = vty->index;
+
if (argc == 1)
- ospf_routemap_set (DEFAULT_ROUTE, argv[0]);
+ ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
else
- ospf_routemap_unset (DEFAULT_ROUTE);
+ ospf_routemap_unset (ospf, DEFAULT_ROUTE);
- return ospf_redistribute_default_set (DEFAULT_ORIGINATE_ALWAYS, -1, -1);
+ return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
}
DEFUN (ospf_default_information_originate_always_type_metric_routemap,
@@ -5861,6 +5916,7 @@ DEFUN (ospf_default_information_originate_always_type_metric_routemap,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ struct ospf *ospf = vty->index;
int type = -1;
int metric = -1;
@@ -5875,11 +5931,11 @@ DEFUN (ospf_default_information_originate_always_type_metric_routemap,
return CMD_WARNING;
if (argc == 3)
- ospf_routemap_set (DEFAULT_ROUTE, argv[2]);
+ ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
else
- ospf_routemap_unset (DEFAULT_ROUTE);
+ ospf_routemap_unset (ospf, DEFAULT_ROUTE);
- return ospf_redistribute_default_set (DEFAULT_ORIGINATE_ALWAYS,
+ return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
type, metric);
}
@@ -5917,6 +5973,7 @@ DEFUN (ospf_default_information_originate_always_type_routemap,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ struct ospf *ospf = vty->index;
int type = -1;
/* Get metric type. */
@@ -5925,11 +5982,11 @@ DEFUN (ospf_default_information_originate_always_type_routemap,
return CMD_WARNING;
if (argc == 2)
- ospf_routemap_set (DEFAULT_ROUTE, argv[1]);
+ ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
else
- ospf_routemap_unset (DEFAULT_ROUTE);
+ ospf_routemap_unset (ospf, DEFAULT_ROUTE);
- return ospf_redistribute_default_set (DEFAULT_ORIGINATE_ALWAYS,
+ return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
type, -1);
}
@@ -5956,8 +6013,8 @@ DEFUN (no_ospf_default_information_originate,
EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
}
- ospf_routemap_unset (DEFAULT_ROUTE);
- return ospf_redistribute_default_unset ();
+ ospf_routemap_unset (ospf, DEFAULT_ROUTE);
+ return ospf_redistribute_default_unset (ospf);
}
DEFUN (ospf_default_metric,
@@ -6327,7 +6384,9 @@ DEFUN (ospf_distance_source,
"Distance value\n"
"IP source prefix\n")
{
- ospf_distance_set (vty, argv[0], argv[1], NULL);
+ struct ospf *ospf = vty->index;
+
+ ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
return CMD_SUCCESS;
}
@@ -6340,7 +6399,10 @@ DEFUN (no_ospf_distance_source,
"Distance value\n"
"IP source prefix\n")
{
- ospf_distance_unset (vty, argv[0], argv[1], NULL);
+ struct ospf *ospf = vty->index;
+
+ ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
+
return CMD_SUCCESS;
}
@@ -6352,7 +6414,10 @@ DEFUN (ospf_distance_source_access_list,
"IP source prefix\n"
"Access list name\n")
{
- ospf_distance_set (vty, argv[0], argv[1], argv[2]);
+ struct ospf *ospf = vty->index;
+
+ ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
+
return CMD_SUCCESS;
}
@@ -6365,7 +6430,10 @@ DEFUN (no_ospf_distance_source_access_list,
"IP source prefix\n"
"Access list name\n")
{
- ospf_distance_unset (vty, argv[0], argv[1], argv[2]);
+ struct ospf *ospf = vty->index;
+
+ ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
+
return CMD_SUCCESS;
}
@@ -6528,8 +6596,9 @@ DEFUN (show_ip_ospf_border_routers,
"show all the ABR's and ASBR's\n"
"for this area\n")
{
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
+ ospf = ospf_lookup ();
if (ospf == NULL)
{
vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
@@ -6543,7 +6612,7 @@ DEFUN (show_ip_ospf_border_routers,
}
/* Show Network routes.
- show_ip_ospf_route_network (vty, ospf_top->new_table); */
+ show_ip_ospf_route_network (vty, ospf->new_table); */
/* Show Router routes. */
show_ip_ospf_route_router (vty, ospf->new_rtrs);
@@ -6560,8 +6629,9 @@ DEFUN (show_ip_ospf_route,
"OSPF information\n"
"OSPF routing table\n")
{
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
+ ospf = ospf_lookup ();
if (ospf == NULL)
{
vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
@@ -7033,13 +7103,13 @@ config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
{
vty_out (vty, " redistribute %s", distribute_str[type]);
if (ospf->dmetric[type].value >= 0)
- vty_out (vty, " metric %d", ospf_top->dmetric[type].value);
+ vty_out (vty, " metric %d", ospf->dmetric[type].value);
if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
vty_out (vty, " metric-type 1");
- if (ROUTEMAP_NAME (type))
- vty_out (vty, " route-map %s", ROUTEMAP_NAME (type));
+ if (ROUTEMAP_NAME (ospf, type))
+ vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
vty_out (vty, "%s", VTY_NEWLINE);
}
@@ -7084,8 +7154,9 @@ config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
vty_out (vty, " metric-type 1");
- if (ROUTEMAP_NAME (DEFAULT_ROUTE))
- vty_out (vty, " route-map %s", ROUTEMAP_NAME (DEFAULT_ROUTE));
+ if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
+ vty_out (vty, " route-map %s",
+ ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
vty_out (vty, "%s", VTY_NEWLINE);
}
@@ -7135,10 +7206,11 @@ config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
int
ospf_config_write (struct vty *vty)
{
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
listnode node;
int write = 0;
+ ospf = ospf_lookup ();
if (ospf != NULL)
{
/* `router ospf' print. */
@@ -7183,7 +7255,7 @@ ospf_config_write (struct vty *vty)
config_write_ospf_redistribute (vty, ospf);
/* passive-interface print. */
- for (node = listhead (ospf->iflist); node; nextnode (node))
+ for (node = listhead (om->iflist); node; nextnode (node))
{
struct interface *ifp = getdata (node);
@@ -7643,5 +7715,3 @@ ospf_vty_init ()
/* Init zebra related vty commands. */
ospf_vty_zebra_init ();
}
-
-
diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c
index 1f11369b..833dd706 100644
--- a/ospfd/ospf_zebra.c
+++ b/ospfd/ospf_zebra.c
@@ -59,7 +59,7 @@ int
ospf_interface_add (int command, struct zclient *zclient, zebra_size_t length)
{
struct interface *ifp;
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
ifp = zebra_interface_add_read (zclient->ibuf);
@@ -80,7 +80,9 @@ ospf_interface_add (int command, struct zclient *zclient, zebra_size_t length)
IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_LOOPBACK;
}
- ospf_if_update (ospf);
+ ospf = ospf_lookup ();
+ if (ospf != NULL)
+ ospf_if_update (ospf);
#ifdef HAVE_SNMP
ospf_snmp_if_update (ifp);
@@ -243,7 +245,7 @@ int
ospf_interface_address_add (int command, struct zclient *zclient,
zebra_size_t length)
{
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
struct connected *c;
c = zebra_interface_address_add_read (zclient->ibuf);
@@ -251,7 +253,9 @@ ospf_interface_address_add (int command, struct zclient *zclient,
if (c == NULL)
return 0;
- ospf_if_update (ospf);
+ ospf = ospf_lookup ();
+ if (ospf != NULL)
+ ospf_if_update (ospf);
#ifdef HAVE_SNMP
ospf_snmp_if_update (c->ifp);
@@ -264,7 +268,7 @@ int
ospf_interface_address_delete (int command, struct zclient *zclient,
zebra_size_t length)
{
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
struct connected *c;
struct interface *ifp;
struct ospf_interface *oi;
@@ -296,7 +300,9 @@ ospf_interface_address_delete (int command, struct zclient *zclient,
connected_free (c);
- ospf_if_update (ospf);
+ ospf = ospf_lookup ();
+ if (ospf != NULL)
+ ospf_if_update (ospf);
return 0;
}
@@ -468,9 +474,8 @@ ospf_is_type_redistributed (int type)
}
int
-ospf_redistribute_set (int type, int mtype, int mvalue)
+ospf_redistribute_set (struct ospf *ospf, int type, int mtype, int mvalue)
{
- struct ospf *ospf = ospf_top;
int force = 0;
if (ospf_is_type_redistributed (type))
@@ -512,10 +517,8 @@ ospf_redistribute_set (int type, int mtype, int mvalue)
}
int
-ospf_redistribute_unset (int type)
+ospf_redistribute_unset (struct ospf *ospf, int type)
{
- struct ospf *ospf = ospf_top;
-
if (type == zclient->redist_default)
return CMD_SUCCESS;
@@ -540,11 +543,11 @@ ospf_redistribute_unset (int type)
}
int
-ospf_redistribute_default_set (int originate, int mtype, int mvalue)
+ospf_redistribute_default_set (struct ospf *ospf, int originate,
+ int mtype, int mvalue)
{
- struct ospf *ospf = ospf_top;
-
int force = 0;
+
if (ospf_is_type_redistributed (DEFAULT_ROUTE))
{
if (mtype != ospf->dmetric[DEFAULT_ROUTE].type)
@@ -591,10 +594,8 @@ ospf_redistribute_default_set (int originate, int mtype, int mvalue)
}
int
-ospf_redistribute_default_unset ()
+ospf_redistribute_default_unset (struct ospf *ospf)
{
- struct ospf *ospf = ospf_top;
-
if (!ospf_is_type_redistributed (DEFAULT_ROUTE))
return CMD_SUCCESS;
@@ -613,10 +614,9 @@ ospf_redistribute_default_unset ()
}
int
-ospf_external_lsa_originate_check (struct external_info *ei)
+ospf_external_lsa_originate_check (struct ospf *ospf,
+ struct external_info *ei)
{
- struct ospf *ospf = ospf_top;
-
/* If prefix is multicast, then do not originate LSA. */
if (IN_MULTICAST (htonl (ei->p.prefix.s_addr)))
{
@@ -667,7 +667,7 @@ ospf_redistribute_check (struct ospf *ospf,
if (changed)
*changed = 0;
- if (!ospf_external_lsa_originate_check (ei))
+ if (!ospf_external_lsa_originate_check (ospf, ei))
return 0;
/* Take care connected route. */
@@ -675,10 +675,10 @@ ospf_redistribute_check (struct ospf *ospf,
!ospf_distribute_check_connected (ospf, ei))
return 0;
- if (!DEFAULT_ROUTE_TYPE (type) && DISTRIBUTE_NAME (type))
+ if (!DEFAULT_ROUTE_TYPE (type) && DISTRIBUTE_NAME (ospf, type))
/* distirbute-list exists, but access-list may not? */
- if (DISTRIBUTE_LIST (type))
- if (access_list_apply (DISTRIBUTE_LIST (type), p) == FILTER_DENY)
+ if (DISTRIBUTE_LIST (ospf, type))
+ if (access_list_apply (DISTRIBUTE_LIST (ospf, type), p) == FILTER_DENY)
{
if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
zlog_info ("Redistribute[%s]: %s/%d filtered by ditribute-list.",
@@ -691,11 +691,11 @@ ospf_redistribute_check (struct ospf *ospf,
ospf_reset_route_map_set_values (&ei->route_map_set);
/* apply route-map if needed */
- if (ROUTEMAP_NAME (type))
+ if (ROUTEMAP_NAME (ospf, type))
{
int ret;
- ret = route_map_apply (ROUTEMAP (type), (struct prefix *)p,
+ ret = route_map_apply (ROUTEMAP (ospf, type), (struct prefix *)p,
RMAP_OSPF, ei);
if (ret == RMAP_DENYMATCH)
@@ -719,23 +719,23 @@ ospf_redistribute_check (struct ospf *ospf,
/* OSPF route-map set for redistribution */
void
-ospf_routemap_set (int type, char *name)
+ospf_routemap_set (struct ospf *ospf, int type, char *name)
{
- if (ROUTEMAP_NAME (type))
- free (ROUTEMAP_NAME (type));
+ if (ROUTEMAP_NAME (ospf, type))
+ free (ROUTEMAP_NAME (ospf, type));
- ROUTEMAP_NAME (type) = strdup (name);
- ROUTEMAP (type) = route_map_lookup_by_name (name);
+ ROUTEMAP_NAME (ospf, type) = strdup (name);
+ ROUTEMAP (ospf, type) = route_map_lookup_by_name (name);
}
void
-ospf_routemap_unset (int type)
+ospf_routemap_unset (struct ospf *ospf, int type)
{
- if (ROUTEMAP_NAME (type))
- free (ROUTEMAP_NAME (type));
+ if (ROUTEMAP_NAME (ospf, type))
+ free (ROUTEMAP_NAME (ospf, type));
- ROUTEMAP_NAME (type) = NULL;
- ROUTEMAP (type) = NULL;
+ ROUTEMAP_NAME (ospf, type) = NULL;
+ ROUTEMAP (ospf, type) = NULL;
}
/* Zebra route add and delete treatment. */
@@ -749,7 +749,7 @@ ospf_zebra_read_ipv4 (int command, struct zclient *zclient,
struct in_addr nexthop;
struct prefix_ipv4 p;
struct external_info *ei;
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
s = zclient->ibuf;
ifindex = 0;
@@ -782,6 +782,10 @@ ospf_zebra_read_ipv4 (int command, struct zclient *zclient,
if (CHECK_FLAG (api.message, ZAPI_MESSAGE_METRIC))
api.metric = stream_getl (s);
+ ospf = ospf_lookup ();
+ if (ospf == NULL)
+ return 0;
+
if (command == ZEBRA_IPV4_ROUTE_ADD)
{
ei = ospf_external_info_add (api.type, p, ifindex, nexthop);
@@ -830,17 +834,17 @@ int
ospf_distribute_list_out_set (struct ospf *ospf, int type, char *name)
{
/* Lookup access-list for distribute-list. */
- DISTRIBUTE_LIST (type) = access_list_lookup (AFI_IP, name);
+ DISTRIBUTE_LIST (ospf, type) = access_list_lookup (AFI_IP, name);
/* Clear previous distribute-name. */
- if (DISTRIBUTE_NAME (type))
- free (DISTRIBUTE_NAME (type));
+ if (DISTRIBUTE_NAME (ospf, type))
+ free (DISTRIBUTE_NAME (ospf, type));
/* Set distribute-name. */
- DISTRIBUTE_NAME (type) = strdup (name);
+ DISTRIBUTE_NAME (ospf, type) = strdup (name);
/* If access-list have been set, schedule update timer. */
- if (DISTRIBUTE_LIST (type))
+ if (DISTRIBUTE_LIST (ospf, type))
ospf_distribute_list_update (ospf, type);
return CMD_SUCCESS;
@@ -850,17 +854,17 @@ int
ospf_distribute_list_out_unset (struct ospf *ospf, int type, char *name)
{
/* Schedule update timer. */
- if (DISTRIBUTE_LIST (type))
+ if (DISTRIBUTE_LIST (ospf, type))
ospf_distribute_list_update (ospf, type);
/* Unset distribute-list. */
- DISTRIBUTE_LIST (type) = NULL;
+ DISTRIBUTE_LIST (ospf, type) = NULL;
/* Clear distribute-name. */
- if (DISTRIBUTE_NAME (type))
- free (DISTRIBUTE_NAME (type));
+ if (DISTRIBUTE_NAME (ospf, type))
+ free (DISTRIBUTE_NAME (ospf, type));
- DISTRIBUTE_NAME (type) = NULL;
+ DISTRIBUTE_NAME (ospf, type) = NULL;
return CMD_SUCCESS;
}
@@ -874,11 +878,15 @@ ospf_distribute_list_update_timer (struct thread *thread)
struct route_table *rt;
struct ospf_lsa *lsa;
u_char type;
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
type = (int) THREAD_ARG (thread);
rt = EXTERNAL_INFO (type);
+ ospf = ospf_lookup ();
+ if (ospf == NULL)
+ return 0;
+
ospf->t_distribute_update = NULL;
zlog_info ("Zebra[Redistribute]: distribute-list update timer fired!");
@@ -924,20 +932,21 @@ ospf_distribute_list_update (struct ospf *ospf, int type)
void
ospf_filter_update (struct access_list *access)
{
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
int type;
int abr_inv = 0;
struct ospf_area *area;
listnode node;
/* If OSPF instatnce does not exist, return right now. */
+ ospf = ospf_lookup ();
if (ospf == NULL)
return;
/* Update distribute-list, and apply filter. */
for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
{
- if (ROUTEMAP (type) != NULL)
+ if (ROUTEMAP (ospf, type) != NULL)
{
/* if route-map is not NULL it may be using this access list */
ospf_distribute_list_update (ospf, type);
@@ -945,22 +954,22 @@ ospf_filter_update (struct access_list *access)
}
- if (DISTRIBUTE_NAME (type))
+ if (DISTRIBUTE_NAME (ospf, type))
{
/* Keep old access-list for distribute-list. */
- struct access_list *old = DISTRIBUTE_LIST (type);
+ struct access_list *old = DISTRIBUTE_LIST (ospf, type);
/* Update access-list for distribute-list. */
- DISTRIBUTE_LIST (type) =
- access_list_lookup (AFI_IP, DISTRIBUTE_NAME (type));
+ DISTRIBUTE_LIST (ospf, type) =
+ access_list_lookup (AFI_IP, DISTRIBUTE_NAME (ospf, type));
/* No update for this distribute type. */
- if (old == NULL && DISTRIBUTE_LIST (type) == NULL)
+ if (old == NULL && DISTRIBUTE_LIST (ospf, type) == NULL)
continue;
/* Schedule distribute-list update timer. */
- if (DISTRIBUTE_LIST (type) == NULL ||
- strcmp (DISTRIBUTE_NAME (type), access->name) == 0)
+ if (DISTRIBUTE_LIST (ospf, type) == NULL ||
+ strcmp (DISTRIBUTE_NAME (ospf, type), access->name) == 0)
ospf_distribute_list_update (ospf, type);
}
}
@@ -983,7 +992,7 @@ ospf_filter_update (struct access_list *access)
}
/* Schedule ABR tasks -- this will be changed -- takada. */
- if (OSPF_IS_ABR && abr_inv)
+ if (IS_OSPF_ABR (ospf) && abr_inv)
ospf_schedule_abr_task (ospf);
}
@@ -1004,15 +1013,14 @@ ospf_distance_free (struct ospf_distance *odistance)
}
int
-ospf_distance_set (struct vty *vty, char *distance_str, char *ip_str,
- char *access_list_str)
+ospf_distance_set (struct vty *vty, struct ospf *ospf, char *distance_str,
+ char *ip_str, char *access_list_str)
{
int ret;
struct prefix_ipv4 p;
u_char distance;
struct route_node *rn;
struct ospf_distance *odistance;
- struct ospf *ospf = ospf_top;
ret = str2prefix_ipv4 (ip_str, &p);
if (ret == 0)
@@ -1052,15 +1060,14 @@ ospf_distance_set (struct vty *vty, char *distance_str, char *ip_str,
}
int
-ospf_distance_unset (struct vty *vty, char *distance_str, char *ip_str,
- char *access_list_str)
+ospf_distance_unset (struct vty *vty, struct ospf *ospf, char *distance_str,
+ char *ip_str, char *access_list_str)
{
int ret;
struct prefix_ipv4 p;
u_char distance;
struct route_node *rn;
struct ospf_distance *odistance;
- struct ospf *ospf = ospf_top;
ret = str2prefix_ipv4 (ip_str, &p);
if (ret == 0)
@@ -1111,8 +1118,9 @@ ospf_distance_reset (struct ospf *ospf)
u_char
ospf_distance_apply (struct prefix_ipv4 *p, struct ospf_route *or)
{
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
+ ospf = ospf_lookup ();
if (ospf == NULL)
return 0;
diff --git a/ospfd/ospf_zebra.h b/ospfd/ospf_zebra.h
index 8c00c9d7..6e91f042 100644
--- a/ospfd/ospf_zebra.h
+++ b/ospfd/ospf_zebra.h
@@ -55,23 +55,21 @@ int ospf_distribute_check_connected (struct ospf *, struct external_info *);
void ospf_distribute_list_update (struct ospf *, int);
int ospf_is_type_redistributed (int);
-int ospf_redistribute_unset (int);
-
void ospf_distance_reset (struct ospf *);
u_char ospf_distance_apply (struct prefix_ipv4 *, struct ospf_route *);
struct vty;
-int ospf_redistribute_set (int, int, int);
-int ospf_redistribute_unset (int);
-int ospf_redistribute_default_set (int, int, int);
-int ospf_redistribute_default_unset ();
+int ospf_redistribute_set (struct ospf *, int, int, int);
+int ospf_redistribute_unset (struct ospf *, int);
+int ospf_redistribute_default_set (struct ospf *, int, int, int);
+int ospf_redistribute_default_unset (struct ospf *);
int ospf_distribute_list_out_set (struct ospf *, int, char *);
int ospf_distribute_list_out_unset (struct ospf *, int, char *);
-void ospf_routemap_set (int, char *);
-void ospf_routemap_unset (int);
-int ospf_distance_set (struct vty *, char *, char *, char *);
-int ospf_distance_unset (struct vty *, char *, char *, char *);
+void ospf_routemap_set (struct ospf *, int, char *);
+void ospf_routemap_unset (struct ospf *, int);
+int ospf_distance_set (struct vty *, struct ospf *, char *, char *, char *);
+int ospf_distance_unset (struct vty *, struct ospf *, char *, char *, char *);
void ospf_zebra_init ();
#endif /* _ZEBRA_OSPF_ZEBRA_H */
diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c
index 6064a138..9b6b4877 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);
}
@@ -691,13 +715,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;
@@ -828,9 +851,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. */
@@ -1572,12 +1595,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;
@@ -1606,16 +1630,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);
}
diff --git a/ospfd/ospfd.h b/ospfd/ospfd.h
index 81790c8e..e960b83e 100644
--- a/ospfd/ospfd.h
+++ b/ospfd/ospfd.h
@@ -125,6 +125,29 @@
#define OSPF_LS_REFRESH_SHIFT (60 * 15)
#define OSPF_LS_REFRESH_JITTER 60
+/* OSPF master for system wide configuration and variables. */
+struct ospf_master
+{
+ /* OSPF instance. */
+ struct list *ospf;
+
+ /* OSPF thread master. */
+ struct thread_master *master;
+
+ /* Zebra interface list. */
+ struct list *iflist;
+
+ /* Redistributed external information. */
+ struct route_table *external_info[ZEBRA_ROUTE_MAX + 1];
+#define EXTERNAL_INFO(T) om->external_info[T]
+
+ /* OSPF start time. */
+ time_t start_time;
+
+ /* Various OSPF global configuration. */
+ u_char options;
+};
+
/* OSPF instance structure. */
struct ospf
{
@@ -175,16 +198,11 @@ struct ospf
struct route_table *nbr_nbma;
struct ospf_area *backbone; /* Pointer to the Backbone Area. */
- list iflist; /* Zebra derived interfaces. */
list oiflist; /* ospf interfaces */
/* LSDB of AS-external-LSAs. */
struct ospf_lsdb *lsdb;
- /* Redistributed external information. */
- struct route_table *external_info[ZEBRA_ROUTE_MAX + 1];
-#define EXTERNAL_INFO(T) ospf_top->external_info[T]
-
/* Flags. */
int external_origin; /* AS-external-LSA origin flag. */
int ase_calc; /* ASE calculation flag. */
@@ -238,8 +256,8 @@ struct ospf
char *name;
struct access_list *list;
} dlist[ZEBRA_ROUTE_MAX];
-#define DISTRIBUTE_NAME(T) ospf_top->dlist[T].name
-#define DISTRIBUTE_LIST(T) ospf_top->dlist[T].list
+#define DISTRIBUTE_NAME(O,T) (O)->dlist[T].name
+#define DISTRIBUTE_LIST(O,T) (O)->dlist[T].list
/* Redistribute metric info. */
struct
@@ -255,8 +273,8 @@ struct ospf
char *name;
struct route_map *map;
} route_map [ZEBRA_ROUTE_MAX + 1]; /* +1 is for default-information */
-#define ROUTEMAP_NAME(T) ospf_top->route_map[T].name
-#define ROUTEMAP(T) ospf_top->route_map[T].map
+#define ROUTEMAP_NAME(O,T) (O)->route_map[T].name
+#define ROUTEMAP(O,T) (O)->route_map[T].map
int default_metric; /* Default metric for redistribute. */
@@ -438,8 +456,8 @@ struct ospf_nbr_nbma
#define OSPF_AREA_SAME(X,Y) \
(memcmp ((X->area_id), (Y->area_id), IPV4_MAX_BYTELEN) == 0)
-#define OSPF_IS_ABR (ospf_top->flags & OSPF_FLAG_ABR)
-#define OSPF_IS_ASBR (ospf_top->flags & OSPF_FLAG_ASBR)
+#define IS_OSPF_ABR(O) ((O)->flags & OSPF_FLAG_ABR)
+#define IS_OSPF_ASBR(O) ((O)->flags & OSPF_FLAG_ASBR)
#define OSPF_IS_AREA_ID_BACKBONE(I) ((I).s_addr == OSPF_AREA_BACKBONE)
#define OSPF_IS_AREA_BACKBONE(A) OSPF_IS_AREA_ID_BACKBONE ((A)->area_id)
@@ -487,7 +505,8 @@ struct ospf_nbr_nbma
} \
} while (0)
-/* Messages */
+/* Extern variables. */
+extern struct ospf_master *om;
extern struct message ospf_ism_state_msg[];
extern struct message ospf_nsm_state_msg[];
extern struct message ospf_lsa_type_msg[];
@@ -502,10 +521,10 @@ extern int ospf_redistributed_proto_max;
extern int ospf_network_type_msg_max;
extern struct zclient *zclient;
extern struct thread_master *master;
-extern struct ospf *ospf_top;
extern int ospf_zlog;
/* Prototypes. */
+struct ospf *ospf_lookup ();
struct ospf *ospf_get ();
void ospf_finish (struct ospf *);
int ospf_router_id_update_timer (struct thread *);
@@ -555,4 +574,6 @@ void ospf_area_del_if (struct ospf_area *, struct ospf_interface *);
void ospf_route_map_init ();
void ospf_snmp_init ();
+void ospf_master_init ();
+
#endif /* _ZEBRA_OSPFD_H */