+2003-04-04 Paul Jakma <paul@dishone.st>
+
+ * Sync to Zebra CVS
+ * Fix lib/thread.h leak
+ * Fix small Opaque LSA leak
+ * Do not configure OSPF interfaces for secondary addresses
+ * vtysh fixes from Hasso
+ * Dave Watson's missing ntohs fix
+
2003-03-25 Paul Jakma <paul@dishone.st>
* Sync to Zebra CVS
/* 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
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
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
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];
&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));
{
/* 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);
}
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);
}
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;
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);
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;
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)
#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;
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);
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;
}
/* Initializations. */
- master = thread_master_create ();
+ master = om->master;
/* Library inits. */
signal_init ();
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);
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?");
/* 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",
}
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",
}
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. */
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)
{
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)
{
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)
{
}
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;
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;
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;
ospf_packet_add (oi, op);
/* Hook thread to write packet. */
- OSPF_ISM_WRITE_ON ();
+ OSPF_ISM_WRITE_ON (oi->ospf);
}
void
/* Add packet to the interface output queue. */
ospf_packet_add (oi, op_dup);
- OSPF_ISM_WRITE_ON ();
+ OSPF_ISM_WRITE_ON (oi->ospf);
}
}
ospf_packet_add (oi, op);
/* Hook thread to write packet. */
- OSPF_ISM_WRITE_ON ();
+ OSPF_ISM_WRITE_ON (oi->ospf);
}
}
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)
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. */
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);
ospf_packet_add (oi, op);
/* Hook thread to write packet. */
- OSPF_ISM_WRITE_ON ();
+ OSPF_ISM_WRITE_ON (oi->ospf);
}
static int
ospf_packet_add (oi, op);
/* Hook thread to write packet. */
- OSPF_ISM_WRITE_ON ();
+ OSPF_ISM_WRITE_ON (oi->ospf);
}
static int
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)
struct ospf_area *area;
listnode node;
- if (! ospf_top)
+ if (ospf == NULL)
return NULL;
if (first)
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;
{
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);
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. */
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;
oid *offset;
int offsetlen;
+ ospf = ospf_lookup ();
+
#define OSPF_LSDB_ENTRY_OFFSET \
(IN_ADDR_SIZE + 1 + IN_ADDR_SIZE + IN_ADDR_SIZE)
u_char type;
struct in_addr ls_id;
struct in_addr router_id;
+ struct ospf *ospf;
/* INDEX { ospfLsdbAreaId, ospfLsdbType,
ospfLsdbLsid, ospfLsdbRouterId } */
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,
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. */
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;
{
int len;
struct ospf_nbr_nbma *nbr_nbma;
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
+ ospf = ospf_lookup ();
if (ospf == NULL)
return NULL;
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;
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;
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;
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))
int len;
int first;
struct ospf_neighbor *nbr;
- struct ospf *ospf = ospf_top;
+ struct ospf *ospf;
+
+ ospf = ospf_lookup ();
if (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;
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)
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;
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)
"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;
}
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;
}
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;
}
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;
}
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
{
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);
"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))
"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);
"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;
}
"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)
{
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
"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;
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);
"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))
{
"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))
{
"Interface address\n"
"detail of all neighbors")
{
+ struct ospf *ospf;
struct ospf_interface *oi;
struct in_addr addr;
int ret;
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
{
\f
/* 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;
/* 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)
/* 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)
}
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;
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);
}
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);
}
}
}
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;
"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;
/* Show all LSA. */
if (argc == 0)
{
- show_ip_ospf_database_summary (vty, 0);
+ show_ip_ospf_database_summary (vty, ospf, 0);
return CMD_SUCCESS;
}
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
/* `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);
/* `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)
{
if (!ret)
return CMD_WARNING;
}
- show_lsa_detail (vty, type, &id, &adv_router);
+ show_lsa_detail (vty, ospf, type, &id, &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;
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;
}
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);
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);
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ struct ospf *ospf = vty->index;
int source;
int type = -1;
int metric = -1;
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,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ struct ospf *ospf = vty->index;
int source;
int type = -1;
int metric = -1;
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,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ struct ospf *ospf = vty->index;
int source;
int metric = -1;
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,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ struct ospf *ospf = vty->index;
int source;
int type = -1;
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,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ struct ospf *ospf = vty->index;
int source;
/* Get distribute source. */
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,
"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,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ struct ospf *ospf = vty->index;
int type = -1;
int metric = -1;
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,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ struct ospf *ospf = vty->index;
int metric = -1;
/* Get metric value. */
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. */
"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,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ struct ospf *ospf = vty->index;
int type = -1;
int metric = -1;
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,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ struct ospf *ospf = vty->index;
int type = -1;
/* Get metric type. */
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,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ struct ospf *ospf = vty->index;
int type = -1;
int metric = -1;
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);
}
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ struct ospf *ospf = vty->index;
int metric = -1;
/* Get metric value. */
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,
"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,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ struct ospf *ospf = vty->index;
int type = -1;
int metric = -1;
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);
}
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ struct ospf *ospf = vty->index;
int type = -1;
/* Get metric type. */
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);
}
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,
"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;
}
"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;
}
"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;
}
"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;
}
"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);
}
/* 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);
"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);
{
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);
}
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);
}
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. */
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);
/* Init zebra related vty commands. */
ospf_vty_zebra_init ();
}
-
-
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);
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);
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);
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);
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;
connected_free (c);
- ospf_if_update (ospf);
+ ospf = ospf_lookup ();
+ if (ospf != NULL)
+ ospf_if_update (ospf);
return 0;
}
}
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))
}
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;
}
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)
}
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;
}
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)))
{
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. */
!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.",
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)
/* 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. */
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;
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);
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;
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;
}
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!");
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);
}
- 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);
}
}
}
/* 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);
}
}
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)
}
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)
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;
#include "ospfd/ospf_route.h"
#include "ospfd/ospf_ase.h"
-/* OSPF instance top. */
-struct ospf *ospf_top;
+\f
+/* 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;
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!");
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 ();
}
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;
}
/* 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;)
{
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);
}
\f
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;
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. */
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;
}
/* 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);
}
#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
{
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. */
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
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. */
#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)
} \
} 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[];
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 *);
void ospf_route_map_init ();
void ospf_snmp_init ();
+void ospf_master_init ();
+
#endif /* _ZEBRA_OSPFD_H */