1 /* OSPF version 2 daemon program.
2 Copyright (C) 1999, 2000 Toshiaki Takada
4 This file is part of GNU Zebra.
6 GNU Zebra is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 GNU Zebra is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Zebra; see the file COPYING. If not, write to the Free
18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
33 #include "sockunion.h" /* for inet_aton () */
38 #include "ospfd/ospfd.h"
39 #include "ospfd/ospf_network.h"
40 #include "ospfd/ospf_interface.h"
41 #include "ospfd/ospf_ism.h"
42 #include "ospfd/ospf_asbr.h"
43 #include "ospfd/ospf_lsa.h"
44 #include "ospfd/ospf_lsdb.h"
45 #include "ospfd/ospf_neighbor.h"
46 #include "ospfd/ospf_nsm.h"
47 #include "ospfd/ospf_spf.h"
48 #include "ospfd/ospf_packet.h"
49 #include "ospfd/ospf_dump.h"
50 #include "ospfd/ospf_zebra.h"
51 #include "ospfd/ospf_abr.h"
52 #include "ospfd/ospf_flood.h"
53 #include "ospfd/ospf_route.h"
54 #include "ospfd/ospf_ase.h"
58 /* OSPF process wide configuration. */
59 static struct ospf_master ospf_master;
61 /* OSPF process wide configuration pointer to export. */
62 struct ospf_master *om;
64 extern struct zclient *zclient;
65 extern struct in_addr router_id_zebra;
68 static void ospf_remove_vls_through_area (struct ospf *, struct ospf_area *);
69 static void ospf_network_free (struct ospf *, struct ospf_network *);
70 static void ospf_area_free (struct ospf_area *);
71 static void ospf_network_run (struct prefix *, struct ospf_area *);
72 static void ospf_network_run_interface (struct ospf *, struct interface *,
73 struct prefix *, struct ospf_area *);
74 static void ospf_network_run_subnet (struct ospf *, struct connected *,
75 struct prefix *, struct ospf_area *);
76 static int ospf_network_match_iface (const struct connected *,
77 const struct prefix *);
78 static void ospf_finish_final (struct ospf *);
80 #define OSPF_EXTERNAL_LSA_ORIGINATE_DELAY 1
83 ospf_router_id_update (struct ospf *ospf)
85 struct in_addr router_id, router_id_old;
86 struct ospf_interface *oi;
87 struct interface *ifp;
88 struct listnode *node;
90 if (IS_DEBUG_OSPF_EVENT)
91 zlog_debug ("Router-ID[OLD:%s]: Update", inet_ntoa (ospf->router_id));
93 router_id_old = ospf->router_id;
95 /* Select the router ID based on these priorities:
96 1. Statically assigned router ID is always the first choice.
97 2. If there is no statically assigned router ID, then try to stick
98 with the most recent value, since changing router ID's is very
100 3. Last choice: just go with whatever the zebra daemon recommends.
102 if (ospf->router_id_static.s_addr != 0)
103 router_id = ospf->router_id_static;
104 else if (ospf->router_id.s_addr != 0)
105 router_id = ospf->router_id;
107 router_id = router_id_zebra;
109 ospf->router_id = router_id;
111 if (IS_DEBUG_OSPF_EVENT)
112 zlog_debug ("Router-ID[NEW:%s]: Update", inet_ntoa (ospf->router_id));
114 if (!IPV4_ADDR_SAME (&router_id_old, &router_id))
116 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
118 /* Some nbrs are identified by router_id, these needs
119 * to be rebuilt. Possible optimization would be to do
120 * oi->nbr_self->router_id = router_id for
121 * !(virtual | ptop) links
123 ospf_nbr_self_reset (oi);
126 /* If AS-external-LSA is queued, then flush those LSAs. */
127 if (router_id_old.s_addr == 0 && ospf->external_origin)
130 /* Originate each redistributed external route. */
131 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
132 if (ospf->external_origin & (1 << type))
133 thread_add_event (master, ospf_external_lsa_originate_timer,
135 /* Originate Deafult. */
136 if (ospf->external_origin & (1 << ZEBRA_ROUTE_MAX))
137 thread_add_event (master, ospf_default_originate_timer, ospf, 0);
139 ospf->external_origin = 0;
142 /* update router-lsa's for each area */
143 ospf_router_lsa_update (ospf);
145 /* update ospf_interface's */
146 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
147 ospf_if_update (ospf, ifp);
151 /* For OSPF area sort by area id. */
153 ospf_area_id_cmp (struct ospf_area *a1, struct ospf_area *a2)
155 if (ntohl (a1->area_id.s_addr) > ntohl (a2->area_id.s_addr))
157 if (ntohl (a1->area_id.s_addr) < ntohl (a2->area_id.s_addr))
162 /* Allocate new ospf structure. */
168 struct ospf *new = XCALLOC (MTYPE_OSPF_TOP, sizeof (struct ospf));
170 new->router_id.s_addr = htonl (0);
171 new->router_id_static.s_addr = htonl (0);
173 new->abr_type = OSPF_ABR_DEFAULT;
174 new->oiflist = list_new ();
175 new->vlinks = list_new ();
176 new->areas = list_new ();
177 new->areas->cmp = (int (*)(void *, void *)) ospf_area_id_cmp;
178 new->networks = route_table_init ();
179 new->nbr_nbma = route_table_init ();
181 new->lsdb = ospf_lsdb_new ();
183 new->default_originate = DEFAULT_ORIGINATE_NONE;
185 new->passive_interface_default = OSPF_IF_ACTIVE;
187 new->new_external_route = route_table_init ();
188 new->old_external_route = route_table_init ();
189 new->external_lsas = route_table_init ();
191 new->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
192 new->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
193 new->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET;
195 /* Distribute parameter init. */
196 for (i = 0; i <= ZEBRA_ROUTE_MAX; i++)
198 new->dmetric[i].type = -1;
199 new->dmetric[i].value = -1;
202 new->default_metric = -1;
203 new->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
206 new->min_ls_interval = OSPF_MIN_LS_INTERVAL;
207 new->min_ls_arrival = OSPF_MIN_LS_ARRIVAL;
209 /* SPF timer value init. */
210 new->spf_delay = OSPF_SPF_DELAY_DEFAULT;
211 new->spf_holdtime = OSPF_SPF_HOLDTIME_DEFAULT;
212 new->spf_max_holdtime = OSPF_SPF_MAX_HOLDTIME_DEFAULT;
213 new->spf_hold_multiplier = 1;
216 new->maxage_delay = OSPF_LSA_MAXAGE_REMOVE_DELAY_DEFAULT;
217 new->maxage_lsa = route_table_init();
218 new->t_maxage_walker =
219 thread_add_timer (master, ospf_lsa_maxage_walker,
220 new, OSPF_LSA_MAXAGE_CHECK_INTERVAL);
222 /* Distance table init. */
223 new->distance_table = route_table_init ();
225 new->lsa_refresh_queue.index = 0;
226 new->lsa_refresh_interval = OSPF_LSA_REFRESH_INTERVAL_DEFAULT;
227 new->t_lsa_refresher = thread_add_timer (master, ospf_lsa_refresh_walker,
228 new, new->lsa_refresh_interval);
229 new->lsa_refresher_started = quagga_time (NULL);
231 if ((new->fd = ospf_sock_init()) < 0)
233 zlog_err("ospf_new: fatal error: ospf_sock_init was unable to open "
237 new->maxsndbuflen = getsockopt_so_sendbuf (new->fd);
238 if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
239 zlog_debug ("%s: starting with OSPF send buffer size %u",
240 __func__, new->maxsndbuflen);
241 if ((new->ibuf = stream_new(OSPF_MAX_PACKET_SIZE+1)) == NULL)
243 zlog_err("ospf_new: fatal error: stream_new(%u) failed allocating ibuf",
244 OSPF_MAX_PACKET_SIZE+1);
247 new->t_read = thread_add_read (master, ospf_read, new, new->fd);
248 new->oi_write_q = list_new ();
256 if (listcount (om->ospf) == 0)
259 return listgetdata ((struct listnode *)listhead (om->ospf));
263 ospf_is_ready (struct ospf *ospf)
265 /* OSPF must be on and Router-ID must be configured. */
266 if (!ospf || ospf->router_id.s_addr == 0)
273 ospf_add (struct ospf *ospf)
275 listnode_add (om->ospf, ospf);
279 ospf_delete (struct ospf *ospf)
281 listnode_delete (om->ospf, ospf);
289 ospf = ospf_lookup ();
295 if (ospf->router_id_static.s_addr == 0)
296 ospf_router_id_update (ospf);
298 ospf_opaque_type11_lsa_init (ospf);
304 /* Handle the second half of deferred shutdown. This is called either
305 * from the deferred-shutdown timer thread, or directly through
306 * ospf_deferred_shutdown_check.
308 * Function is to cleanup G-R state, if required then call ospf_finish_final
309 * to complete shutdown of this ospf instance. Possibly exit if the
310 * whole process is being shutdown and this was the last OSPF instance.
313 ospf_deferred_shutdown_finish (struct ospf *ospf)
315 ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
316 OSPF_TIMER_OFF (ospf->t_deferred_shutdown);
318 ospf_finish_final (ospf);
320 /* *ospf is now invalid */
322 /* ospfd being shut-down? If so, was this the last ospf instance? */
323 if (CHECK_FLAG (om->options, OSPF_MASTER_SHUTDOWN)
324 && (listcount (om->ospf) == 0))
330 /* Timer thread for G-R */
332 ospf_deferred_shutdown_timer (struct thread *t)
334 struct ospf *ospf = THREAD_ARG(t);
336 ospf_deferred_shutdown_finish (ospf);
341 /* Check whether deferred-shutdown must be scheduled, otherwise call
342 * down directly into second-half of instance shutdown.
345 ospf_deferred_shutdown_check (struct ospf *ospf)
347 unsigned long timeout;
349 struct ospf_area *area;
351 /* deferred shutdown already running? */
352 if (ospf->t_deferred_shutdown)
355 /* Should we try push out max-metric LSAs? */
356 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
358 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
360 SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
362 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
363 ospf_router_lsa_update_area (area);
365 timeout = ospf->stub_router_shutdown_time;
369 /* No timer needed */
370 ospf_deferred_shutdown_finish (ospf);
374 OSPF_TIMER_ON (ospf->t_deferred_shutdown, ospf_deferred_shutdown_timer,
379 /* Shut down the entire process */
381 ospf_terminate (void)
384 struct listnode *node, *nnode;
386 /* shutdown already in progress */
387 if (CHECK_FLAG (om->options, OSPF_MASTER_SHUTDOWN))
390 SET_FLAG (om->options, OSPF_MASTER_SHUTDOWN);
392 /* exit immediately if OSPF not actually running */
393 if (listcount(om->ospf) == 0)
396 for (ALL_LIST_ELEMENTS (om->ospf, node, nnode, ospf))
399 /* Deliberately go back up, hopefully to thread scheduler, as
400 * One or more ospf_finish()'s may have deferred shutdown to a timer
406 ospf_finish (struct ospf *ospf)
408 /* let deferred shutdown decide */
409 ospf_deferred_shutdown_check (ospf);
411 /* if ospf_deferred_shutdown returns, then ospf_finish_final is
412 * deferred to expiry of G-S timer thread. Return back up, hopefully
413 * to thread scheduler.
418 /* Final cleanup of ospf instance */
420 ospf_finish_final (struct ospf *ospf)
422 struct route_node *rn;
423 struct ospf_nbr_nbma *nbr_nbma;
424 struct ospf_lsa *lsa;
425 struct ospf_interface *oi;
426 struct ospf_area *area;
427 struct ospf_vl_data *vl_data;
428 struct listnode *node, *nnode;
431 ospf_opaque_type11_lsa_term (ospf);
433 /* be nice if this worked, but it doesn't */
434 /*ospf_flush_self_originated_lsas_now (ospf);*/
436 /* Unregister redistribution */
437 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
438 ospf_redistribute_unset (ospf, i);
439 ospf_redistribute_default_unset (ospf);
441 for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
442 ospf_remove_vls_through_area (ospf, area);
444 for (ALL_LIST_ELEMENTS (ospf->vlinks, node, nnode, vl_data))
445 ospf_vl_delete (ospf, vl_data);
447 list_delete (ospf->vlinks);
449 /* Reset interface. */
450 for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi))
453 /* Clear static neighbors */
454 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
455 if ((nbr_nbma = rn->info))
457 OSPF_POLL_TIMER_OFF (nbr_nbma->t_poll);
461 nbr_nbma->nbr->nbr_nbma = NULL;
462 nbr_nbma->nbr = NULL;
467 listnode_delete (nbr_nbma->oi->nbr_nbma, nbr_nbma);
471 XFREE (MTYPE_OSPF_NEIGHBOR_STATIC, nbr_nbma);
474 route_table_finish (ospf->nbr_nbma);
476 /* Clear networks and Areas. */
477 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
479 struct ospf_network *network;
481 if ((network = rn->info) != NULL)
483 ospf_network_free (ospf, network);
485 route_unlock_node (rn);
489 for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
491 listnode_delete (ospf->areas, area);
492 ospf_area_free (area);
495 /* Cancel all timers. */
496 OSPF_TIMER_OFF (ospf->t_external_lsa);
497 OSPF_TIMER_OFF (ospf->t_spf_calc);
498 OSPF_TIMER_OFF (ospf->t_ase_calc);
499 OSPF_TIMER_OFF (ospf->t_maxage);
500 OSPF_TIMER_OFF (ospf->t_maxage_walker);
501 OSPF_TIMER_OFF (ospf->t_abr_task);
502 OSPF_TIMER_OFF (ospf->t_asbr_check);
503 OSPF_TIMER_OFF (ospf->t_distribute_update);
504 OSPF_TIMER_OFF (ospf->t_lsa_refresher);
505 OSPF_TIMER_OFF (ospf->t_read);
506 OSPF_TIMER_OFF (ospf->t_write);
507 OSPF_TIMER_OFF (ospf->t_opaque_lsa_self);
510 stream_free(ospf->ibuf);
512 LSDB_LOOP (OPAQUE_AS_LSDB (ospf), rn, lsa)
513 ospf_discard_from_db (ospf, ospf->lsdb, lsa);
514 LSDB_LOOP (EXTERNAL_LSDB (ospf), rn, lsa)
515 ospf_discard_from_db (ospf, ospf->lsdb, lsa);
517 ospf_lsdb_delete_all (ospf->lsdb);
518 ospf_lsdb_free (ospf->lsdb);
520 for (rn = route_top (ospf->maxage_lsa); rn; rn = route_next (rn))
522 struct ospf_lsa *lsa;
524 if ((lsa = rn->info) != NULL)
526 ospf_lsa_unlock (&lsa);
529 route_unlock_node (rn);
531 route_table_finish (ospf->maxage_lsa);
534 ospf_route_table_free (ospf->old_table);
537 ospf_route_delete (ospf->new_table);
538 ospf_route_table_free (ospf->new_table);
541 ospf_rtrs_free (ospf->old_rtrs);
543 ospf_rtrs_free (ospf->new_rtrs);
544 if (ospf->new_external_route)
546 ospf_route_delete (ospf->new_external_route);
547 ospf_route_table_free (ospf->new_external_route);
549 if (ospf->old_external_route)
551 ospf_route_delete (ospf->old_external_route);
552 ospf_route_table_free (ospf->old_external_route);
554 if (ospf->external_lsas)
556 ospf_ase_external_lsas_finish (ospf->external_lsas);
559 list_delete (ospf->areas);
561 for (i = ZEBRA_ROUTE_SYSTEM; i <= ZEBRA_ROUTE_MAX; i++)
562 if (EXTERNAL_INFO (i) != NULL)
563 for (rn = route_top (EXTERNAL_INFO (i)); rn; rn = route_next (rn))
565 if (rn->info == NULL)
568 XFREE (MTYPE_OSPF_EXTERNAL_INFO, rn->info);
570 route_unlock_node (rn);
573 ospf_distance_reset (ospf);
574 route_table_finish (ospf->distance_table);
578 XFREE (MTYPE_OSPF_TOP, ospf);
582 /* allocate new OSPF Area object */
583 static struct ospf_area *
584 ospf_area_new (struct ospf *ospf, struct in_addr area_id)
586 struct ospf_area *new;
588 /* Allocate new config_network. */
589 new = XCALLOC (MTYPE_OSPF_AREA, sizeof (struct ospf_area));
593 new->area_id = area_id;
595 new->external_routing = OSPF_AREA_DEFAULT;
596 new->default_cost = 1;
597 new->auth_type = OSPF_AUTH_NULL;
600 new->lsdb = ospf_lsdb_new ();
602 /* Self-originated LSAs initialize. */
603 new->router_lsa_self = NULL;
605 ospf_opaque_type10_lsa_init (new);
607 new->oiflist = list_new ();
608 new->ranges = route_table_init ();
610 if (area_id.s_addr == OSPF_AREA_BACKBONE)
611 ospf->backbone = new;
617 ospf_area_free (struct ospf_area *area)
619 struct route_node *rn;
620 struct ospf_lsa *lsa;
623 LSDB_LOOP (ROUTER_LSDB (area), rn, lsa)
624 ospf_discard_from_db (area->ospf, area->lsdb, lsa);
625 LSDB_LOOP (NETWORK_LSDB (area), rn, lsa)
626 ospf_discard_from_db (area->ospf, area->lsdb, lsa);
627 LSDB_LOOP (SUMMARY_LSDB (area), rn, lsa)
628 ospf_discard_from_db (area->ospf, area->lsdb, lsa);
629 LSDB_LOOP (ASBR_SUMMARY_LSDB (area), rn, lsa)
630 ospf_discard_from_db (area->ospf, area->lsdb, lsa);
632 LSDB_LOOP (NSSA_LSDB (area), rn, lsa)
633 ospf_discard_from_db (area->ospf, area->lsdb, lsa);
634 LSDB_LOOP (OPAQUE_AREA_LSDB (area), rn, lsa)
635 ospf_discard_from_db (area->ospf, area->lsdb, lsa);
636 LSDB_LOOP (OPAQUE_LINK_LSDB (area), rn, lsa)
637 ospf_discard_from_db (area->ospf, area->lsdb, lsa);
639 ospf_lsdb_delete_all (area->lsdb);
640 ospf_lsdb_free (area->lsdb);
642 ospf_lsa_unlock (&area->router_lsa_self);
644 route_table_finish (area->ranges);
645 list_delete (area->oiflist);
647 if (EXPORT_NAME (area))
648 free (EXPORT_NAME (area));
650 if (IMPORT_NAME (area))
651 free (IMPORT_NAME (area));
654 OSPF_TIMER_OFF (area->t_stub_router);
655 OSPF_TIMER_OFF (area->t_opaque_lsa_self);
657 if (OSPF_IS_AREA_BACKBONE (area))
658 area->ospf->backbone = NULL;
660 XFREE (MTYPE_OSPF_AREA, area);
664 ospf_area_check_free (struct ospf *ospf, struct in_addr area_id)
666 struct ospf_area *area;
668 area = ospf_area_lookup_by_area_id (ospf, area_id);
670 listcount (area->oiflist) == 0 &&
671 area->ranges->top == NULL &&
672 area->shortcut_configured == OSPF_SHORTCUT_DEFAULT &&
673 area->external_routing == OSPF_AREA_DEFAULT &&
674 area->no_summary == 0 &&
675 area->default_cost == 1 &&
676 EXPORT_NAME (area) == NULL &&
677 IMPORT_NAME (area) == NULL &&
678 area->auth_type == OSPF_AUTH_NULL)
680 listnode_delete (ospf->areas, area);
681 ospf_area_free (area);
686 ospf_area_get (struct ospf *ospf, struct in_addr area_id, int format)
688 struct ospf_area *area;
690 area = ospf_area_lookup_by_area_id (ospf, area_id);
693 area = ospf_area_new (ospf, area_id);
694 area->format = format;
695 listnode_add_sort (ospf->areas, area);
696 ospf_check_abr_status (ospf);
697 if (ospf->stub_router_admin_set == OSPF_STUB_ROUTER_ADMINISTRATIVE_SET)
699 SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
707 ospf_area_lookup_by_area_id (struct ospf *ospf, struct in_addr area_id)
709 struct ospf_area *area;
710 struct listnode *node;
712 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
713 if (IPV4_ADDR_SAME (&area->area_id, &area_id))
720 ospf_area_add_if (struct ospf_area *area, struct ospf_interface *oi)
722 listnode_add (area->oiflist, oi);
726 ospf_area_del_if (struct ospf_area *area, struct ospf_interface *oi)
728 listnode_delete (area->oiflist, oi);
732 /* Config network statement related functions. */
733 static struct ospf_network *
734 ospf_network_new (struct in_addr area_id, int format)
736 struct ospf_network *new;
737 new = XCALLOC (MTYPE_OSPF_NETWORK, sizeof (struct ospf_network));
739 new->area_id = area_id;
740 new->format = format;
746 add_ospf_interface (struct connected *co, struct ospf_area *area)
748 struct ospf_interface *oi;
750 oi = ospf_if_new (area->ospf, co->ifp, co->address);
755 oi->params = ospf_lookup_if_params (co->ifp, oi->address->u.prefix4);
756 oi->output_cost = ospf_if_get_output_cost (oi);
758 /* Relate ospf interface to ospf instance. */
759 oi->ospf = area->ospf;
761 /* update network type as interface flag */
762 /* If network type is specified previously,
763 skip network type setting. */
764 oi->type = IF_DEF_PARAMS (co->ifp)->type;
766 /* Add pseudo neighbor. */
767 ospf_nbr_self_reset (oi);
769 ospf_area_add_if (oi->area, oi);
771 /* if router_id is not configured, dont bring up
773 * ospf_router_id_update() will call ospf_if_update
774 * whenever r-id is configured instead.
776 if ((area->ospf->router_id.s_addr != 0)
777 && if_is_operative (co->ifp))
782 update_redistributed (struct ospf *ospf, int add_to_ospf)
784 struct route_node *rn;
785 struct external_info *ei;
787 if (ospf_is_type_redistributed (ZEBRA_ROUTE_CONNECT))
788 if (EXTERNAL_INFO (ZEBRA_ROUTE_CONNECT))
789 for (rn = route_top (EXTERNAL_INFO (ZEBRA_ROUTE_CONNECT));
790 rn; rn = route_next (rn))
791 if ((ei = rn->info) != NULL)
795 if (ospf_external_info_find_lsa (ospf, &ei->p))
796 if (!ospf_distribute_check_connected (ospf, ei))
797 ospf_external_lsa_flush (ospf, ei->type, &ei->p,
798 ei->ifindex /*, ei->nexthop */);
802 if (!ospf_external_info_find_lsa (ospf, &ei->p))
803 if (ospf_distribute_check_connected (ospf, ei))
804 ospf_external_lsa_originate (ospf, ei);
810 ospf_network_free (struct ospf *ospf, struct ospf_network *network)
812 ospf_area_check_free (ospf, network->area_id);
813 ospf_schedule_abr_task (ospf);
814 XFREE (MTYPE_OSPF_NETWORK, network);
818 ospf_network_set (struct ospf *ospf, struct prefix_ipv4 *p,
819 struct in_addr area_id)
821 struct ospf_network *network;
822 struct ospf_area *area;
823 struct route_node *rn;
824 int ret = OSPF_AREA_ID_FORMAT_ADDRESS;
826 rn = route_node_get (ospf->networks, (struct prefix *)p);
829 /* There is already same network statement. */
830 route_unlock_node (rn);
834 rn->info = network = ospf_network_new (area_id, ret);
835 area = ospf_area_get (ospf, area_id, ret);
837 /* Run network config now. */
838 ospf_network_run ((struct prefix *)p, area);
840 /* Update connected redistribute. */
841 update_redistributed(ospf, 1);
843 ospf_area_check_free (ospf, area_id);
849 ospf_network_unset (struct ospf *ospf, struct prefix_ipv4 *p,
850 struct in_addr area_id)
852 struct route_node *rn;
853 struct ospf_network *network;
854 struct listnode *node, *nnode;
855 struct ospf_interface *oi;
857 rn = route_node_lookup (ospf->networks, (struct prefix *)p);
862 route_unlock_node (rn);
863 if (!IPV4_ADDR_SAME (&area_id, &network->area_id))
866 ospf_network_free (ospf, rn->info);
868 route_unlock_node (rn); /* initial reference */
870 /* Find interfaces that not configured already. */
871 for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi))
873 if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
876 ospf_network_run_subnet (ospf, oi->connected, NULL, NULL);
879 /* Update connected redistribute. */
880 update_redistributed(ospf, 0);
882 ospf_area_check_free (ospf, area_id);
887 /* Ensure there's an OSPF instance, as "ip ospf area" enabled OSPF means
888 * there might not be any 'router ospf' config.
890 * Otherwise, doesn't do anything different to ospf_if_update for now
893 ospf_interface_area_set (struct interface *ifp)
895 struct ospf *ospf = ospf_get();
897 ospf_if_update (ospf, ifp);
898 /* if_update does a update_redistributed */
904 ospf_interface_area_unset (struct interface *ifp)
906 struct route_node *rn_oi;
909 if ((ospf = ospf_lookup ()) == NULL)
910 return; /* Ospf not ready yet */
912 /* Find interfaces that may need to be removed. */
913 for (rn_oi = route_top (IF_OIFS (ifp)); rn_oi; rn_oi = route_next (rn_oi))
915 struct ospf_interface *oi;
917 if ( (oi = rn_oi->info) == NULL)
920 if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
923 ospf_network_run_subnet (ospf, oi->connected, NULL, NULL);
926 /* Update connected redistribute. */
927 update_redistributed (ospf, 0); /* interfaces possibly removed */
933 /* Check whether interface matches given network
934 * returns: 1, true. 0, false
937 ospf_network_match_iface(const struct connected *co, const struct prefix *net)
939 /* new approach: more elegant and conceptually clean */
940 return prefix_match(net, CONNECTED_PREFIX(co));
944 ospf_update_interface_area (struct connected *co, struct ospf_area *area)
946 struct ospf_interface *oi = ospf_if_table_lookup (co->ifp, co->address);
948 /* nothing to be done case */
949 if (oi && oi->area == area)
955 add_ospf_interface (co, area);
958 /* Run OSPF for the given subnet, taking into account the following
959 * possible sources of area configuration, in the given order of preference:
961 * - Whether there is interface+address specific area configuration
962 * - Whether there is a default area for the interface
963 * - Whether there is an area given as a parameter.
964 * - If no specific network prefix/area is supplied, whether there's
965 * a matching network configured.
968 ospf_network_run_subnet (struct ospf *ospf, struct connected *co,
969 struct prefix *p, struct ospf_area *given_area)
971 struct ospf_interface *oi;
972 struct ospf_if_params *params;
973 struct ospf_area *area = NULL;
974 struct route_node *rn;
977 if (CHECK_FLAG(co->flags, ZEBRA_IFA_SECONDARY))
980 if (co->address->family != AF_INET)
983 /* Try determine the appropriate area for this interface + address
984 * Start by checking interface config
986 if (!(params = ospf_lookup_if_params (co->ifp, co->address->u.prefix4)))
987 params = IF_DEF_PARAMS (co->ifp);
989 if (OSPF_IF_PARAM_CONFIGURED(params, if_area))
990 area = (ospf_area_get (ospf, params->if_area,
991 OSPF_AREA_ID_FORMAT_ADDRESS));
993 /* If we've found an interface and/or addr specific area, then we're
998 ospf_update_interface_area (co, area);
1002 /* Otherwise, only remaining possibility is a matching network statement */
1005 assert (given_area != NULL);
1007 /* Which either was supplied as a parameter.. (e.g. cause a new
1008 * network/area was just added)..
1010 if (p->family == co->address->family
1011 && ospf_network_match_iface (co, p))
1012 ospf_update_interface_area (co, given_area);
1017 /* Else we have to search the existing network/area config to see
1020 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
1021 if (rn->info != NULL
1022 && ospf_network_match_iface (co, &rn->p))
1024 struct ospf_network *network = (struct ospf_network *) rn->info;
1025 area = ospf_area_get (ospf, network->area_id, network->format);
1026 ospf_update_interface_area (co, area);
1030 /* If the subnet isn't in any area, deconfigure */
1031 if (!configed && (oi = ospf_if_table_lookup (co->ifp, co->address)))
1036 ospf_network_run_interface (struct ospf *ospf, struct interface *ifp,
1038 struct ospf_area *given_area)
1040 struct listnode *cnode;
1041 struct connected *co;
1043 if (memcmp (ifp->name, "VLINK", 5) == 0)
1046 /* Network prefix without area is nonsensical */
1048 assert (given_area != NULL);
1050 /* if interface prefix is match specified prefix,
1051 then create socket and join multicast group. */
1052 for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, co))
1053 ospf_network_run_subnet (ospf, co, p, given_area);
1057 ospf_network_run (struct prefix *p, struct ospf_area *area)
1059 struct interface *ifp;
1060 struct listnode *node;
1062 /* Schedule Router ID Update. */
1063 if (area->ospf->router_id.s_addr == 0)
1064 ospf_router_id_update (area->ospf);
1066 /* Get target interface. */
1067 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
1068 ospf_network_run_interface (area->ospf, ifp, p, area);
1072 ospf_ls_upd_queue_empty (struct ospf_interface *oi)
1074 struct route_node *rn;
1075 struct listnode *node, *nnode;
1077 struct ospf_lsa *lsa;
1079 /* empty ls update queue */
1080 for (rn = route_top (oi->ls_upd_queue); rn;
1081 rn = route_next (rn))
1082 if ((lst = (struct list *) rn->info))
1084 for (ALL_LIST_ELEMENTS (lst, node, nnode, lsa))
1085 ospf_lsa_unlock (&lsa); /* oi->ls_upd_queue */
1090 /* remove update event */
1091 if (oi->t_ls_upd_event)
1093 thread_cancel (oi->t_ls_upd_event);
1094 oi->t_ls_upd_event = NULL;
1099 ospf_if_update (struct ospf *ospf, struct interface *ifp)
1102 ospf = ospf_lookup ();
1104 /* OSPF must be ready. */
1105 if (!ospf_is_ready (ospf))
1108 ospf_network_run_interface (ospf, ifp, NULL, NULL);
1110 /* Update connected redistribute. */
1111 update_redistributed(ospf, 1);
1115 ospf_remove_vls_through_area (struct ospf *ospf, struct ospf_area *area)
1117 struct listnode *node, *nnode;
1118 struct ospf_vl_data *vl_data;
1120 for (ALL_LIST_ELEMENTS (ospf->vlinks, node, nnode, vl_data))
1121 if (IPV4_ADDR_SAME (&vl_data->vl_area_id, &area->area_id))
1122 ospf_vl_delete (ospf, vl_data);
1126 static const struct message ospf_area_type_msg[] =
1128 { OSPF_AREA_DEFAULT, "Default" },
1129 { OSPF_AREA_STUB, "Stub" },
1130 { OSPF_AREA_NSSA, "NSSA" },
1132 static const int ospf_area_type_msg_max = OSPF_AREA_TYPE_MAX;
1135 ospf_area_type_set (struct ospf_area *area, int type)
1137 struct listnode *node;
1138 struct ospf_interface *oi;
1140 if (area->external_routing == type)
1142 if (IS_DEBUG_OSPF_EVENT)
1143 zlog_debug ("Area[%s]: Types are the same, ignored.",
1144 inet_ntoa (area->area_id));
1148 area->external_routing = type;
1150 if (IS_DEBUG_OSPF_EVENT)
1151 zlog_debug ("Area[%s]: Configured as %s", inet_ntoa (area->area_id),
1152 LOOKUP (ospf_area_type_msg, type));
1154 switch (area->external_routing)
1156 case OSPF_AREA_DEFAULT:
1157 for (ALL_LIST_ELEMENTS_RO (area->oiflist, node, oi))
1158 if (oi->nbr_self != NULL)
1160 UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_NP);
1161 SET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
1164 case OSPF_AREA_STUB:
1165 for (ALL_LIST_ELEMENTS_RO (area->oiflist, node, oi))
1166 if (oi->nbr_self != NULL)
1168 if (IS_DEBUG_OSPF_EVENT)
1169 zlog_debug ("setting options on %s accordingly", IF_NAME (oi));
1170 UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_NP);
1171 UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
1172 if (IS_DEBUG_OSPF_EVENT)
1173 zlog_debug ("options set on %s: %x",
1174 IF_NAME (oi), OPTIONS (oi));
1177 case OSPF_AREA_NSSA:
1178 for (ALL_LIST_ELEMENTS_RO (area->oiflist, node, oi))
1179 if (oi->nbr_self != NULL)
1181 zlog_debug ("setting nssa options on %s accordingly", IF_NAME (oi));
1182 UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
1183 SET_FLAG (oi->nbr_self->options, OSPF_OPTION_NP);
1184 zlog_debug ("options set on %s: %x", IF_NAME (oi), OPTIONS (oi));
1191 ospf_router_lsa_update_area (area);
1192 ospf_schedule_abr_task (area->ospf);
1196 ospf_area_shortcut_set (struct ospf *ospf, struct ospf_area *area, int mode)
1198 if (area->shortcut_configured == mode)
1201 area->shortcut_configured = mode;
1202 ospf_router_lsa_update_area (area);
1203 ospf_schedule_abr_task (ospf);
1205 ospf_area_check_free (ospf, area->area_id);
1211 ospf_area_shortcut_unset (struct ospf *ospf, struct ospf_area *area)
1213 area->shortcut_configured = OSPF_SHORTCUT_DEFAULT;
1214 ospf_router_lsa_update_area (area);
1215 ospf_area_check_free (ospf, area->area_id);
1216 ospf_schedule_abr_task (ospf);
1222 ospf_area_vlink_count (struct ospf *ospf, struct ospf_area *area)
1224 struct ospf_vl_data *vl;
1225 struct listnode *node;
1228 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl))
1229 if (IPV4_ADDR_SAME (&vl->vl_area_id, &area->area_id))
1236 ospf_area_stub_set (struct ospf *ospf, struct in_addr area_id)
1238 struct ospf_area *area;
1239 int format = OSPF_AREA_ID_FORMAT_ADDRESS;
1241 area = ospf_area_get (ospf, area_id, format);
1242 if (ospf_area_vlink_count (ospf, area))
1245 if (area->external_routing != OSPF_AREA_STUB)
1246 ospf_area_type_set (area, OSPF_AREA_STUB);
1252 ospf_area_stub_unset (struct ospf *ospf, struct in_addr area_id)
1254 struct ospf_area *area;
1256 area = ospf_area_lookup_by_area_id (ospf, area_id);
1260 if (area->external_routing == OSPF_AREA_STUB)
1261 ospf_area_type_set (area, OSPF_AREA_DEFAULT);
1263 ospf_area_check_free (ospf, area_id);
1269 ospf_area_no_summary_set (struct ospf *ospf, struct in_addr area_id)
1271 struct ospf_area *area;
1272 int format = OSPF_AREA_ID_FORMAT_ADDRESS;
1274 area = ospf_area_get (ospf, area_id, format);
1275 area->no_summary = 1;
1281 ospf_area_no_summary_unset (struct ospf *ospf, struct in_addr area_id)
1283 struct ospf_area *area;
1285 area = ospf_area_lookup_by_area_id (ospf, area_id);
1289 area->no_summary = 0;
1290 ospf_area_check_free (ospf, area_id);
1296 ospf_area_nssa_set (struct ospf *ospf, struct in_addr area_id)
1298 struct ospf_area *area;
1299 int format = OSPF_AREA_ID_FORMAT_ADDRESS;
1301 area = ospf_area_get (ospf, area_id, format);
1302 if (ospf_area_vlink_count (ospf, area))
1305 if (area->external_routing != OSPF_AREA_NSSA)
1307 ospf_area_type_set (area, OSPF_AREA_NSSA);
1311 /* set NSSA area defaults */
1312 area->no_summary = 0;
1313 area->NSSATranslatorRole = OSPF_NSSA_ROLE_CANDIDATE;
1314 area->NSSATranslatorState = OSPF_NSSA_TRANSLATE_DISABLED;
1315 area->NSSATranslatorStabilityInterval = OSPF_NSSA_TRANS_STABLE_DEFAULT;
1321 ospf_area_nssa_unset (struct ospf *ospf, struct in_addr area_id)
1323 struct ospf_area *area;
1325 area = ospf_area_lookup_by_area_id (ospf, area_id);
1329 if (area->external_routing == OSPF_AREA_NSSA)
1332 ospf_area_type_set (area, OSPF_AREA_DEFAULT);
1335 ospf_area_check_free (ospf, area_id);
1341 ospf_area_nssa_translator_role_set (struct ospf *ospf, struct in_addr area_id,
1344 struct ospf_area *area;
1346 area = ospf_area_lookup_by_area_id (ospf, area_id);
1350 area->NSSATranslatorRole = role;
1356 /* XXX: unused? Leave for symmetry? */
1358 ospf_area_nssa_translator_role_unset (struct ospf *ospf,
1359 struct in_addr area_id)
1361 struct ospf_area *area;
1363 area = ospf_area_lookup_by_area_id (ospf, area_id);
1367 area->NSSATranslatorRole = OSPF_NSSA_ROLE_CANDIDATE;
1369 ospf_area_check_free (ospf, area_id);
1376 ospf_area_export_list_set (struct ospf *ospf,
1377 struct ospf_area *area, const char *list_name)
1379 struct access_list *list;
1380 list = access_list_lookup (AFI_IP, list_name);
1382 EXPORT_LIST (area) = list;
1384 if (EXPORT_NAME (area))
1385 free (EXPORT_NAME (area));
1387 EXPORT_NAME (area) = strdup (list_name);
1388 ospf_schedule_abr_task (ospf);
1394 ospf_area_export_list_unset (struct ospf *ospf, struct ospf_area * area)
1397 EXPORT_LIST (area) = 0;
1399 if (EXPORT_NAME (area))
1400 free (EXPORT_NAME (area));
1402 EXPORT_NAME (area) = NULL;
1404 ospf_area_check_free (ospf, area->area_id);
1406 ospf_schedule_abr_task (ospf);
1412 ospf_area_import_list_set (struct ospf *ospf, struct ospf_area *area,
1415 struct access_list *list;
1416 list = access_list_lookup (AFI_IP, name);
1418 IMPORT_LIST (area) = list;
1420 if (IMPORT_NAME (area))
1421 free (IMPORT_NAME (area));
1423 IMPORT_NAME (area) = strdup (name);
1424 ospf_schedule_abr_task (ospf);
1430 ospf_area_import_list_unset (struct ospf *ospf, struct ospf_area * area)
1432 IMPORT_LIST (area) = 0;
1434 if (IMPORT_NAME (area))
1435 free (IMPORT_NAME (area));
1437 IMPORT_NAME (area) = NULL;
1438 ospf_area_check_free (ospf, area->area_id);
1440 ospf_schedule_abr_task (ospf);
1446 ospf_timers_refresh_set (struct ospf *ospf, int interval)
1450 if (ospf->lsa_refresh_interval == interval)
1453 time_left = ospf->lsa_refresh_interval -
1454 (quagga_time (NULL) - ospf->lsa_refresher_started);
1456 if (time_left > interval)
1458 OSPF_TIMER_OFF (ospf->t_lsa_refresher);
1459 ospf->t_lsa_refresher =
1460 thread_add_timer (master, ospf_lsa_refresh_walker, ospf, interval);
1462 ospf->lsa_refresh_interval = interval;
1468 ospf_timers_refresh_unset (struct ospf *ospf)
1472 time_left = ospf->lsa_refresh_interval -
1473 (quagga_time (NULL) - ospf->lsa_refresher_started);
1475 if (time_left > OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
1477 OSPF_TIMER_OFF (ospf->t_lsa_refresher);
1478 ospf->t_lsa_refresher =
1479 thread_add_timer (master, ospf_lsa_refresh_walker, ospf,
1480 OSPF_LSA_REFRESH_INTERVAL_DEFAULT);
1483 ospf->lsa_refresh_interval = OSPF_LSA_REFRESH_INTERVAL_DEFAULT;
1489 static struct ospf_nbr_nbma *
1490 ospf_nbr_nbma_new (void)
1492 struct ospf_nbr_nbma *nbr_nbma;
1494 nbr_nbma = XCALLOC (MTYPE_OSPF_NEIGHBOR_STATIC,
1495 sizeof (struct ospf_nbr_nbma));
1497 nbr_nbma->priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
1498 nbr_nbma->v_poll = OSPF_POLL_INTERVAL_DEFAULT;
1504 ospf_nbr_nbma_free (struct ospf_nbr_nbma *nbr_nbma)
1506 XFREE (MTYPE_OSPF_NEIGHBOR_STATIC, nbr_nbma);
1510 ospf_nbr_nbma_delete (struct ospf *ospf, struct ospf_nbr_nbma *nbr_nbma)
1512 struct route_node *rn;
1513 struct prefix_ipv4 p;
1516 p.prefix = nbr_nbma->addr;
1517 p.prefixlen = IPV4_MAX_BITLEN;
1519 rn = route_node_lookup (ospf->nbr_nbma, (struct prefix *)&p);
1522 ospf_nbr_nbma_free (rn->info);
1524 route_unlock_node (rn);
1525 route_unlock_node (rn);
1530 ospf_nbr_nbma_down (struct ospf_nbr_nbma *nbr_nbma)
1532 OSPF_TIMER_OFF (nbr_nbma->t_poll);
1536 nbr_nbma->nbr->nbr_nbma = NULL;
1537 OSPF_NSM_EVENT_EXECUTE (nbr_nbma->nbr, NSM_KillNbr);
1541 listnode_delete (nbr_nbma->oi->nbr_nbma, nbr_nbma);
1545 ospf_nbr_nbma_add (struct ospf_nbr_nbma *nbr_nbma,
1546 struct ospf_interface *oi)
1548 struct ospf_neighbor *nbr;
1549 struct route_node *rn;
1552 if (oi->type != OSPF_IFTYPE_NBMA)
1555 if (nbr_nbma->nbr != NULL)
1558 if (IPV4_ADDR_SAME (&oi->nbr_self->address.u.prefix4, &nbr_nbma->addr))
1562 listnode_add (oi->nbr_nbma, nbr_nbma);
1564 /* Get neighbor information from table. */
1566 p.prefixlen = IPV4_MAX_BITLEN;
1567 p.u.prefix4 = nbr_nbma->addr;
1569 rn = route_node_get (oi->nbrs, (struct prefix *)&p);
1573 nbr->nbr_nbma = nbr_nbma;
1574 nbr_nbma->nbr = nbr;
1576 route_unlock_node (rn);
1580 nbr = rn->info = ospf_nbr_new (oi);
1581 nbr->state = NSM_Down;
1582 nbr->src = nbr_nbma->addr;
1583 nbr->nbr_nbma = nbr_nbma;
1584 nbr->priority = nbr_nbma->priority;
1587 nbr_nbma->nbr = nbr;
1589 OSPF_NSM_EVENT_EXECUTE (nbr, NSM_Start);
1594 ospf_nbr_nbma_if_update (struct ospf *ospf, struct ospf_interface *oi)
1596 struct ospf_nbr_nbma *nbr_nbma;
1597 struct route_node *rn;
1598 struct prefix_ipv4 p;
1600 if (oi->type != OSPF_IFTYPE_NBMA)
1603 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
1604 if ((nbr_nbma = rn->info))
1605 if (nbr_nbma->oi == NULL && nbr_nbma->nbr == NULL)
1608 p.prefix = nbr_nbma->addr;
1609 p.prefixlen = IPV4_MAX_BITLEN;
1611 if (prefix_match (oi->address, (struct prefix *)&p))
1612 ospf_nbr_nbma_add (nbr_nbma, oi);
1616 struct ospf_nbr_nbma *
1617 ospf_nbr_nbma_lookup (struct ospf *ospf, struct in_addr nbr_addr)
1619 struct route_node *rn;
1620 struct prefix_ipv4 p;
1623 p.prefix = nbr_addr;
1624 p.prefixlen = IPV4_MAX_BITLEN;
1626 rn = route_node_lookup (ospf->nbr_nbma, (struct prefix *)&p);
1629 route_unlock_node (rn);
1635 struct ospf_nbr_nbma *
1636 ospf_nbr_nbma_lookup_next (struct ospf *ospf, struct in_addr *addr, int first)
1639 struct ospf_nbr_nbma *nbr_nbma;
1640 struct listnode *node;
1647 for (ALL_LIST_ELEMENTS_RO (ospf->nbr_nbma, node, nbr_nbma))
1651 *addr = nbr_nbma->addr;
1654 else if (ntohl (nbr_nbma->addr.s_addr) > ntohl (addr->s_addr))
1656 *addr = nbr_nbma->addr;
1665 ospf_nbr_nbma_set (struct ospf *ospf, struct in_addr nbr_addr)
1667 struct ospf_nbr_nbma *nbr_nbma;
1668 struct ospf_interface *oi;
1669 struct prefix_ipv4 p;
1670 struct route_node *rn;
1671 struct listnode *node;
1673 nbr_nbma = ospf_nbr_nbma_lookup (ospf, nbr_addr);
1677 nbr_nbma = ospf_nbr_nbma_new ();
1678 nbr_nbma->addr = nbr_addr;
1681 p.prefix = nbr_addr;
1682 p.prefixlen = IPV4_MAX_BITLEN;
1684 rn = route_node_get (ospf->nbr_nbma, (struct prefix *)&p);
1686 route_unlock_node (rn);
1687 rn->info = nbr_nbma;
1689 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
1691 if (oi->type == OSPF_IFTYPE_NBMA)
1692 if (prefix_match (oi->address, (struct prefix *)&p))
1694 ospf_nbr_nbma_add (nbr_nbma, oi);
1703 ospf_nbr_nbma_unset (struct ospf *ospf, struct in_addr nbr_addr)
1705 struct ospf_nbr_nbma *nbr_nbma;
1707 nbr_nbma = ospf_nbr_nbma_lookup (ospf, nbr_addr);
1708 if (nbr_nbma == NULL)
1711 ospf_nbr_nbma_down (nbr_nbma);
1712 ospf_nbr_nbma_delete (ospf, nbr_nbma);
1718 ospf_nbr_nbma_priority_set (struct ospf *ospf, struct in_addr nbr_addr,
1721 struct ospf_nbr_nbma *nbr_nbma;
1723 nbr_nbma = ospf_nbr_nbma_lookup (ospf, nbr_addr);
1724 if (nbr_nbma == NULL)
1727 if (nbr_nbma->priority != priority)
1728 nbr_nbma->priority = priority;
1734 ospf_nbr_nbma_priority_unset (struct ospf *ospf, struct in_addr nbr_addr)
1736 struct ospf_nbr_nbma *nbr_nbma;
1738 nbr_nbma = ospf_nbr_nbma_lookup (ospf, nbr_addr);
1739 if (nbr_nbma == NULL)
1742 if (nbr_nbma != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
1743 nbr_nbma->priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
1749 ospf_nbr_nbma_poll_interval_set (struct ospf *ospf, struct in_addr nbr_addr,
1750 unsigned int interval)
1752 struct ospf_nbr_nbma *nbr_nbma;
1754 nbr_nbma = ospf_nbr_nbma_lookup (ospf, nbr_addr);
1755 if (nbr_nbma == NULL)
1758 if (nbr_nbma->v_poll != interval)
1760 nbr_nbma->v_poll = interval;
1761 if (nbr_nbma->oi && ospf_if_is_up (nbr_nbma->oi))
1763 OSPF_TIMER_OFF (nbr_nbma->t_poll);
1764 OSPF_POLL_TIMER_ON (nbr_nbma->t_poll, ospf_poll_timer,
1773 ospf_nbr_nbma_poll_interval_unset (struct ospf *ospf, struct in_addr addr)
1775 struct ospf_nbr_nbma *nbr_nbma;
1777 nbr_nbma = ospf_nbr_nbma_lookup (ospf, addr);
1778 if (nbr_nbma == NULL)
1781 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
1782 nbr_nbma->v_poll = OSPF_POLL_INTERVAL_DEFAULT;
1790 memset (&ospf_master, 0, sizeof (struct ospf_master));
1793 om->ospf = list_new ();
1794 om->master = thread_master_create ();
1795 om->start_time = quagga_time (NULL);