diff options
Diffstat (limited to 'ospf6d')
-rw-r--r-- | ospf6d/ospf6_area.c | 6 | ||||
-rw-r--r-- | ospf6d/ospf6_asbr.c | 5 | ||||
-rw-r--r-- | ospf6d/ospf6_asbr.h | 12 | ||||
-rw-r--r-- | ospf6d/ospf6_interface.c | 28 | ||||
-rw-r--r-- | ospf6d/ospf6_intra.c | 2 | ||||
-rw-r--r-- | ospf6d/ospf6_lsa.c | 5 | ||||
-rw-r--r-- | ospf6d/ospf6_lsa.h | 1 | ||||
-rw-r--r-- | ospf6d/ospf6_main.c | 58 | ||||
-rw-r--r-- | ospf6d/ospf6_message.c | 18 | ||||
-rw-r--r-- | ospf6d/ospf6_message.h | 1 | ||||
-rw-r--r-- | ospf6d/ospf6_route.c | 15 | ||||
-rw-r--r-- | ospf6d/ospf6_spf.c | 45 | ||||
-rw-r--r-- | ospf6d/ospf6_top.c | 9 | ||||
-rw-r--r-- | ospf6d/ospf6_top.h | 1 |
14 files changed, 140 insertions, 66 deletions
diff --git a/ospf6d/ospf6_area.c b/ospf6d/ospf6_area.c index 3c999bbc..f4b327e4 100644 --- a/ospf6d/ospf6_area.c +++ b/ospf6d/ospf6_area.c @@ -199,14 +199,10 @@ ospf6_area_delete (struct ospf6_area *oa) ospf6_lsdb_delete (oa->lsdb); ospf6_lsdb_delete (oa->lsdb_self); + ospf6_spf_table_finish (oa->spf_table); ospf6_route_table_delete (oa->spf_table); ospf6_route_table_delete (oa->route_table); -#if 0 - ospf6_spftree_delete (oa->spf_tree); - ospf6_route_table_delete (oa->topology_table); -#endif /*0*/ - THREAD_OFF (oa->thread_spf_calculation); THREAD_OFF (oa->thread_route_calculation); diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c index 1bf98559..b1351bff 100644 --- a/ospf6d/ospf6_asbr.c +++ b/ospf6d/ospf6_asbr.c @@ -1219,6 +1219,11 @@ ospf6_asbr_init (void) install_element (OSPF6_NODE, &no_ospf6_redistribute_cmd); } +void +ospf6_asbr_terminate (void) +{ + route_map_finish (); +} DEFUN (debug_ospf6_asbr, debug_ospf6_asbr_cmd, diff --git a/ospf6d/ospf6_asbr.h b/ospf6d/ospf6_asbr.h index 7166aa3e..d7bad420 100644 --- a/ospf6d/ospf6_asbr.h +++ b/ospf6d/ospf6_asbr.h @@ -14,14 +14,19 @@ * General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with GNU Zebra; see the file COPYING. If not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * along with GNU Zebra; see the file COPYING. If not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ #ifndef OSPF6_ASBR_H #define OSPF6_ASBR_H +#include "ospf6_proto.h" +#include "ospf6_lsa.h" +#include "ospf6_route.h" +#include "ospf6_top.h" + /* Debug option */ extern unsigned char conf_debug_ospf6_asbr; #define OSPF6_DEBUG_ASBR_ON() \ @@ -79,6 +84,7 @@ extern void ospf6_asbr_redistribute_remove (int type, int ifindex, extern int ospf6_redistribute_config_write (struct vty *vty); extern void ospf6_asbr_init (void); +extern void ospf6_asbr_terminate (void); extern int config_write_ospf6_debug_asbr (struct vty *vty); extern void install_element_ospf6_debug_asbr (void); diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c index 777bc7c9..cb347451 100644 --- a/ospf6d/ospf6_interface.c +++ b/ospf6d/ospf6_interface.c @@ -1394,13 +1394,17 @@ DEFUN (ipv6_ospf6_advertise_prefix_list, oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]); ospf6_interface_connected_route_update (oi->interface); - OSPF6_LINK_LSA_SCHEDULE (oi); - if (oi->state == OSPF6_INTERFACE_DR) + + if (oi->area) { - OSPF6_NETWORK_LSA_SCHEDULE (oi); - OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi); + OSPF6_LINK_LSA_SCHEDULE (oi); + if (oi->state == OSPF6_INTERFACE_DR) + { + OSPF6_NETWORK_LSA_SCHEDULE (oi); + OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi); + } + OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area); } - OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area); return CMD_SUCCESS; } @@ -1433,13 +1437,17 @@ DEFUN (no_ipv6_ospf6_advertise_prefix_list, } ospf6_interface_connected_route_update (oi->interface); - OSPF6_LINK_LSA_SCHEDULE (oi); - if (oi->state == OSPF6_INTERFACE_DR) + + if (oi->area) { - OSPF6_NETWORK_LSA_SCHEDULE (oi); - OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi); + OSPF6_LINK_LSA_SCHEDULE (oi); + if (oi->state == OSPF6_INTERFACE_DR) + { + OSPF6_NETWORK_LSA_SCHEDULE (oi); + OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi); + } + OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area); } - OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area); return CMD_SUCCESS; } diff --git a/ospf6d/ospf6_intra.c b/ospf6d/ospf6_intra.c index b30398f0..9d94f408 100644 --- a/ospf6d/ospf6_intra.c +++ b/ospf6d/ospf6_intra.c @@ -1177,6 +1177,8 @@ ospf6_intra_prefix_lsa_remove (struct ospf6_lsa *lsa) } ospf6_route_remove (route, oa->route_table); } + if (route) + ospf6_route_unlock (route); } if (current != end && IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX)) diff --git a/ospf6d/ospf6_lsa.c b/ospf6d/ospf6_lsa.c index c1db3741..588b9462 100644 --- a/ospf6d/ospf6_lsa.c +++ b/ospf6d/ospf6_lsa.c @@ -712,6 +712,11 @@ ospf6_lsa_init (void) ospf6_install_lsa_handler (&unknown_handler); } +void +ospf6_lsa_terminate (void) +{ + vector_free (ospf6_lsa_handler_vector); +} static char * ospf6_lsa_handler_name (struct ospf6_lsa_handler *h) diff --git a/ospf6d/ospf6_lsa.h b/ospf6d/ospf6_lsa.h index fb0f27cd..c1093cab 100644 --- a/ospf6d/ospf6_lsa.h +++ b/ospf6d/ospf6_lsa.h @@ -243,6 +243,7 @@ extern void ospf6_install_lsa_handler (struct ospf6_lsa_handler *handler); extern struct ospf6_lsa_handler *ospf6_get_lsa_handler (u_int16_t type); extern void ospf6_lsa_init (void); +extern void ospf6_lsa_terminate (void); extern void ospf6_lsa_cmd_init (void); extern int config_write_ospf6_debug_lsa (struct vty *vty); diff --git a/ospf6d/ospf6_main.c b/ospf6d/ospf6_main.c index a7a96a1f..cd00fa86 100644 --- a/ospf6d/ospf6_main.c +++ b/ospf6d/ospf6_main.c @@ -14,13 +14,14 @@ * General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with GNU Zebra; see the file COPYING. If not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * along with GNU Zebra; see the file COPYING. If not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ #include <zebra.h> #include <lib/version.h> +#include <lib/zclient.h> #include "getopt.h" #include "thread.h" @@ -36,6 +37,8 @@ #include "sigevent.h" #include "ospf6d.h" +#include "ospf6_asbr.h" +#include "ospf6_message.h" /* Default configuration file name for ospf6d. */ #define OSPF6_DEFAULT_CONFIG "ospf6d.conf" @@ -67,7 +70,7 @@ struct zebra_privs_t ospf6d_privs = }; /* ospf6d options, we use GNU getopt library. */ -struct option longopts[] = +struct option longopts[] = { { "daemon", no_argument, NULL, 'd'}, { "config_file", required_argument, NULL, 'f'}, @@ -104,7 +107,7 @@ usage (char *progname, int status) if (status != 0) fprintf (stderr, "Try `%s --help' for more information.\n", progname); else - { + { printf ("Usage : %s [OPTION...]\n\n\ Daemon which manages OSPF version 3.\n\n\ -d, --daemon Runs in daemon mode\n\ @@ -124,8 +127,37 @@ Report bugs to zebra@zebra.org\n", progname); exit (status); } +static void +ospf6_exit (int status) +{ + extern struct ospf6 *ospf6; + extern struct zclient *zclient; + + if (ospf6) + ospf6_delete (ospf6); + + ospf6_message_terminate (); + ospf6_asbr_terminate (); + ospf6_lsa_terminate (); + + if_terminate (); + vty_terminate (); + cmd_terminate (); + + if (zclient) + zclient_free (zclient); + + if (master) + thread_master_free (master); + + if (zlog_default) + closezlog (zlog_default); + + exit (status); +} + /* SIGHUP handler. */ -static void +static void sighup (void) { zlog_info ("SIGHUP received"); @@ -136,7 +168,7 @@ static void sigint (void) { zlog_notice ("Terminating on signal SIGINT"); - exit (0); + ospf6_exit (0); } /* SIGTERM handler. */ @@ -144,7 +176,7 @@ static void sigterm (void) { zlog_notice ("Terminating on signal SIGTERM"); - exit (0); + ospf6_exit (0); } /* SIGUSR1 handler. */ @@ -195,14 +227,14 @@ main (int argc, char *argv[], char *envp[]) progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]); /* Command line argument treatment. */ - while (1) + while (1) { opt = getopt_long (argc, argv, "df:i:hp:A:P:u:g:vC", longopts, 0); - + if (opt == EOF) break; - switch (opt) + switch (opt) { case 0: break; @@ -281,7 +313,7 @@ main (int argc, char *argv[], char *envp[]) /* Start execution only if not in dry-run mode */ if (dryrun) return(0); - + if (daemon_mode && daemon (0, 0) < 0) { zlog_err("OSPF6d daemon failed: %s", strerror(errno)); @@ -308,7 +340,7 @@ main (int argc, char *argv[], char *envp[]) zlog_warn ("Thread failed"); /* Not reached. */ - exit (0); + ospf6_exit (0); } diff --git a/ospf6d/ospf6_message.c b/ospf6d/ospf6_message.c index 790fc0ae..d06eba26 100644 --- a/ospf6d/ospf6_message.c +++ b/ospf6d/ospf6_message.c @@ -1168,6 +1168,24 @@ ospf6_iobuf_size (unsigned int size) return iobuflen; } +void +ospf6_message_terminate (void) +{ + if (recvbuf) + { + XFREE (MTYPE_OSPF6_MESSAGE, recvbuf); + recvbuf = NULL; + } + + if (sendbuf) + { + XFREE (MTYPE_OSPF6_MESSAGE, sendbuf); + sendbuf = NULL; + } + + iobuflen = 0; +} + int ospf6_receive (struct thread *thread) { diff --git a/ospf6d/ospf6_message.h b/ospf6d/ospf6_message.h index ebb6308e..c72f0af4 100644 --- a/ospf6d/ospf6_message.h +++ b/ospf6d/ospf6_message.h @@ -123,6 +123,7 @@ extern void ospf6_lsupdate_print (struct ospf6_header *); extern void ospf6_lsack_print (struct ospf6_header *); extern int ospf6_iobuf_size (unsigned int size); +extern void ospf6_message_terminate (void); extern int ospf6_receive (struct thread *thread); extern int ospf6_hello_send (struct thread *thread); diff --git a/ospf6d/ospf6_route.c b/ospf6d/ospf6_route.c index 8c1746c7..b0ecea6c 100644 --- a/ospf6d/ospf6_route.c +++ b/ospf6d/ospf6_route.c @@ -690,6 +690,8 @@ ospf6_route_best_next (struct ospf6_route *route) struct route_node *rnode; struct ospf6_route *next; + ospf6_route_unlock (route); + rnode = route->rnode; route_lock_node (rnode); rnode = route_next (rnode); @@ -701,7 +703,6 @@ ospf6_route_best_next (struct ospf6_route *route) assert (rnode->info); next = (struct ospf6_route *) rnode->info; - ospf6_route_unlock (route); ospf6_route_lock (next); return next; } @@ -1335,13 +1336,14 @@ ospf6_brouter_show (struct vty *vty, struct ospf6_route *route) DEFUN (debug_ospf6_route, debug_ospf6_route_cmd, - "debug ospf6 route (table|intra-area|inter-area)", + "debug ospf6 route (table|intra-area|inter-area|memory)", DEBUG_STR OSPF6_STR "Debug route table calculation\n" "Debug detail\n" "Debug intra-area route calculation\n" "Debug inter-area route calculation\n" + "Debug route memory use\n" ) { unsigned char level = 0; @@ -1352,18 +1354,21 @@ DEFUN (debug_ospf6_route, level = OSPF6_DEBUG_ROUTE_INTRA; else if (! strncmp (argv[0], "inter", 5)) level = OSPF6_DEBUG_ROUTE_INTER; + else if (! strncmp (argv[0], "memor", 5)) + level = OSPF6_DEBUG_ROUTE_MEMORY; OSPF6_DEBUG_ROUTE_ON (level); return CMD_SUCCESS; } DEFUN (no_debug_ospf6_route, no_debug_ospf6_route_cmd, - "no debug ospf6 route (table|intra-area|inter-area)", + "no debug ospf6 route (table|intra-area|inter-area|memory)", NO_STR DEBUG_STR OSPF6_STR "Debug route table calculation\n" - "Debug intra-area route calculation\n") + "Debug intra-area route calculation\n" + "Debug route memory use\n") { unsigned char level = 0; @@ -1373,6 +1378,8 @@ DEFUN (no_debug_ospf6_route, level = OSPF6_DEBUG_ROUTE_INTRA; else if (! strncmp (argv[0], "inter", 5)) level = OSPF6_DEBUG_ROUTE_INTER; + else if (! strncmp (argv[0], "memor", 5)) + level = OSPF6_DEBUG_ROUTE_MEMORY; OSPF6_DEBUG_ROUTE_OFF (level); return CMD_SUCCESS; } diff --git a/ospf6d/ospf6_spf.c b/ospf6d/ospf6_spf.c index 767f5255..25b86007 100644 --- a/ospf6d/ospf6_spf.c +++ b/ospf6d/ospf6_spf.c @@ -14,9 +14,9 @@ * General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with GNU Zebra; see the file COPYING. If not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * along with GNU Zebra; see the file COPYING. If not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ /* Shortest Path First calculation for OSPFv3 */ @@ -50,7 +50,9 @@ ospf6_vertex_cmp (void *a, void *b) struct ospf6_vertex *vb = (struct ospf6_vertex *) b; /* ascending order */ - return (va->cost - vb->cost); + if (va->cost != vb->cost) + return (va->cost - vb->cost); + return (va->hops - vb->hops); } static int @@ -280,8 +282,8 @@ ospf6_spf_install (struct ospf6_vertex *v, { struct ospf6_route *route; int i, j; - struct ospf6_vertex *prev, *w; - struct listnode *node, *nnode; + struct ospf6_vertex *prev; //, *w; +//struct listnode *node, *nnode; if (IS_OSPF6_DEBUG_SPF (PROCESS)) zlog_debug ("SPF install %s hops %d cost %d", @@ -320,22 +322,8 @@ ospf6_spf_install (struct ospf6_vertex *v, } prev = (struct ospf6_vertex *) route->route_option; - if (prev->hops > v->hops) - { - for (ALL_LIST_ELEMENTS (prev->child_list, node, nnode, w)) - { - assert (w->parent == prev); - w->parent = v; - listnode_add_sort (v->child_list, w); - } - listnode_delete (prev->parent->child_list, prev); - listnode_add_sort (v->parent->child_list, v); - - ospf6_vertex_delete (prev); - route->route_option = v; - } - else - ospf6_vertex_delete (v); + assert (prev->hops <= v->hops); + ospf6_vertex_delete (v); return -1; } @@ -404,18 +392,19 @@ ospf6_spf_calculation (u_int32_t router_id, caddr_t lsdesc; struct ospf6_lsa *lsa; - /* initialize */ - candidate_list = pqueue_create (); - candidate_list->cmp = ospf6_vertex_cmp; - - ospf6_spf_table_finish (result_table); - /* Install the calculating router itself as the root of the SPF tree */ /* construct root vertex */ lsa = ospf6_lsdb_lookup (htons (OSPF6_LSTYPE_ROUTER), htonl (0), router_id, oa->lsdb); if (lsa == NULL) return; + + /* initialize */ + candidate_list = pqueue_create (); + candidate_list->cmp = ospf6_vertex_cmp; + + ospf6_spf_table_finish (result_table); + root = ospf6_vertex_create (lsa); root->area = oa; root->cost = 0; diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c index 9305b23f..bc0b477e 100644 --- a/ospf6d/ospf6_top.c +++ b/ospf6d/ospf6_top.c @@ -51,6 +51,8 @@ /* global ospf6d variable */ struct ospf6 *ospf6; +static void ospf6_disable (struct ospf6 *o); + static void ospf6_top_lsdb_hook_add (struct ospf6_lsa *lsa) { @@ -143,15 +145,17 @@ ospf6_create (void) return o; } -#if 0 -static void +void ospf6_delete (struct ospf6 *o) { struct listnode *node, *nnode; struct ospf6_area *oa; + ospf6_disable (ospf6); + for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa)) ospf6_area_delete (oa); + list_delete (o->area_list); ospf6_lsdb_delete (o->lsdb); ospf6_lsdb_delete (o->lsdb_self); @@ -164,7 +168,6 @@ ospf6_delete (struct ospf6 *o) XFREE (MTYPE_OSPF6_TOP, o); } -#endif static void ospf6_enable (struct ospf6 *o) diff --git a/ospf6d/ospf6_top.h b/ospf6d/ospf6_top.h index ba485f9e..4b2d2c3e 100644 --- a/ospf6d/ospf6_top.h +++ b/ospf6d/ospf6_top.h @@ -69,6 +69,7 @@ extern struct ospf6 *ospf6; /* prototypes */ extern void ospf6_top_init (void); +extern void ospf6_delete (struct ospf6 *o); extern void ospf6_maxage_remove (struct ospf6 *o); |