version 1.1.1.3, 2013/07/21 23:54:37
|
version 1.1.1.4, 2016/11/02 10:09:10
|
Line 36 Software Foundation, Inc., 59 Temple Place - Suite 330
|
Line 36 Software Foundation, Inc., 59 Temple Place - Suite 330
|
#include "filter.h" |
#include "filter.h" |
#include "plist.h" |
#include "plist.h" |
#include "stream.h" |
#include "stream.h" |
|
#include "vrf.h" |
|
#include "workqueue.h" |
|
|
#include "bgpd/bgpd.h" |
#include "bgpd/bgpd.h" |
#include "bgpd/bgp_attr.h" |
#include "bgpd/bgp_attr.h" |
Line 104 char config_default[] = SYSCONFDIR BGP_DEFAULT_CONFIG;
|
Line 106 char config_default[] = SYSCONFDIR BGP_DEFAULT_CONFIG;
|
/* Route retain mode flag. */ |
/* Route retain mode flag. */ |
static int retain_mode = 0; |
static int retain_mode = 0; |
|
|
/* Master of threads. */ |
|
struct thread_master *master; |
|
|
|
/* Manually specified configuration file name. */ |
/* Manually specified configuration file name. */ |
char *config_file = NULL; |
char *config_file = NULL; |
|
|
Line 171 Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS);
|
Line 170 Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS);
|
|
|
exit (status); |
exit (status); |
} |
} |
| |
/* SIGHUP handler. */ |
/* SIGHUP handler. */ |
void |
void |
sighup (void) |
sighup (void) |
Line 198 sigint (void)
|
Line 197 sigint (void)
|
{ |
{ |
zlog_notice ("Terminating on signal"); |
zlog_notice ("Terminating on signal"); |
|
|
if (! retain_mode) | if (! retain_mode) |
bgp_terminate (); | { |
| bgp_terminate (); |
| zprivs_terminate (&bgpd_privs); |
| } |
|
|
zprivs_terminate (&bgpd_privs); |
|
bgp_exit (0); |
bgp_exit (0); |
} |
} |
|
|
Line 226 bgp_exit (int status)
|
Line 227 bgp_exit (int status)
|
struct listnode *node, *nnode; |
struct listnode *node, *nnode; |
int *socket; |
int *socket; |
struct interface *ifp; |
struct interface *ifp; |
extern struct zclient *zclient; |
|
extern struct zclient *zlookup; |
extern struct zclient *zlookup; |
|
|
/* it only makes sense for this to be called on a clean exit */ |
/* it only makes sense for this to be called on a clean exit */ |
Line 236 bgp_exit (int status)
|
Line 236 bgp_exit (int status)
|
for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
bgp_delete (bgp); |
bgp_delete (bgp); |
list_free (bm->bgp); |
list_free (bm->bgp); |
| bm->bgp = NULL; |
| |
| /* |
| * bgp_delete can re-allocate the process queues after they were |
| * deleted in bgp_terminate. delete them again. |
| * |
| * It might be better to ensure the RIBs (including static routes) |
| * are cleared by bgp_terminate() during its call to bgp_cleanup_routes(), |
| * which currently only deletes the kernel routes. |
| */ |
| if (bm->process_main_queue) |
| { |
| work_queue_free (bm->process_main_queue); |
| bm->process_main_queue = NULL; |
| } |
| if (bm->process_rsclient_queue) |
| { |
| work_queue_free (bm->process_rsclient_queue); |
| bm->process_rsclient_queue = NULL; |
| } |
| |
/* reverse bgp_master_init */ |
/* reverse bgp_master_init */ |
for (ALL_LIST_ELEMENTS_RO(bm->listen_sockets, node, socket)) |
for (ALL_LIST_ELEMENTS_RO(bm->listen_sockets, node, socket)) |
{ |
{ |
Line 248 bgp_exit (int status)
|
Line 268 bgp_exit (int status)
|
/* reverse bgp_zebra_init/if_init */ |
/* reverse bgp_zebra_init/if_init */ |
if (retain_mode) |
if (retain_mode) |
if_add_hook (IF_DELETE_HOOK, NULL); |
if_add_hook (IF_DELETE_HOOK, NULL); |
for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp)) | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) |
{ |
{ |
struct listnode *c_node, *c_nnode; |
struct listnode *c_node, *c_nnode; |
struct connected *c; |
struct connected *c; |
|
|
for (ALL_LIST_ELEMENTS (ifp->connected, c_node, c_nnode, c)) |
for (ALL_LIST_ELEMENTS (ifp->connected, c_node, c_nnode, c)) |
bgp_connected_delete (c); |
bgp_connected_delete (c); |
|
|
if_delete (ifp); |
|
} |
} |
list_free (iflist); |
|
|
|
/* reverse bgp_attr_init */ |
/* reverse bgp_attr_init */ |
bgp_attr_finish (); |
bgp_attr_finish (); |
Line 293 bgp_exit (int status)
|
Line 310 bgp_exit (int status)
|
/* reverse community_list_init */ |
/* reverse community_list_init */ |
community_list_terminate (bgp_clist); |
community_list_terminate (bgp_clist); |
|
|
|
vrf_terminate (); |
cmd_terminate (); |
cmd_terminate (); |
vty_terminate (); |
vty_terminate (); |
if (zclient) | bgp_address_destroy(); |
zclient_free (zclient); | bgp_scan_destroy(); |
| bgp_zebra_destroy(); |
if (zlookup) |
if (zlookup) |
zclient_free (zlookup); |
zclient_free (zlookup); |
if (bgp_nexthop_buf) |
if (bgp_nexthop_buf) |
stream_free (bgp_nexthop_buf); |
stream_free (bgp_nexthop_buf); |
|
|
/* reverse bgp_master_init */ |
/* reverse bgp_master_init */ |
if (master) | if (bm->master) |
thread_master_free (master); | thread_master_free (bm->master); |
|
|
if (zlog_default) |
if (zlog_default) |
closezlog (zlog_default); |
closezlog (zlog_default); |
Line 314 bgp_exit (int status)
|
Line 333 bgp_exit (int status)
|
|
|
exit (status); |
exit (status); |
} |
} |
| |
/* Main routine of bgpd. Treatment of argument and start bgp finite |
/* Main routine of bgpd. Treatment of argument and start bgp finite |
state machine is handled at here. */ |
state machine is handled at here. */ |
int |
int |
Line 417 main (int argc, char **argv)
|
Line 436 main (int argc, char **argv)
|
} |
} |
} |
} |
|
|
/* Make thread master. */ |
|
master = bm->master; |
|
|
|
/* Initializations. */ |
/* Initializations. */ |
srand (time (NULL)); | srandom (time (NULL)); |
signal_init (master, array_size(bgp_signals), bgp_signals); | signal_init (bm->master, array_size(bgp_signals), bgp_signals); |
zprivs_init (&bgpd_privs); |
zprivs_init (&bgpd_privs); |
cmd_init (1); |
cmd_init (1); |
vty_init (master); | vty_init (bm->master); |
memory_init (); |
memory_init (); |
|
vrf_init (); |
|
|
/* BGP related initialization. */ |
/* BGP related initialization. */ |
bgp_init (); |
bgp_init (); |
|
|
/* Sort CLI commands. */ |
|
sort_node (); |
|
|
|
/* Parse config file. */ |
/* Parse config file. */ |
vty_read_config (config_file, config_default); |
vty_read_config (config_file, config_default); |
|
|
Line 456 main (int argc, char **argv)
|
Line 470 main (int argc, char **argv)
|
vty_serv_sock (vty_addr, vty_port, BGP_VTYSH_PATH); |
vty_serv_sock (vty_addr, vty_port, BGP_VTYSH_PATH); |
|
|
/* Print banner. */ |
/* Print banner. */ |
zlog_notice ("BGPd %s starting: vty@%d, bgp@%s:%d", QUAGGA_VERSION, | zlog_notice ("BGPd %s starting: vty@%d, bgp@%s:%d pid %d", QUAGGA_VERSION, |
vty_port, |
vty_port, |
(bm->address ? bm->address : "<all>"), |
(bm->address ? bm->address : "<all>"), |
bm->port); | bm->port, |
| getpid ()); |
|
|
/* Start finite state machine, here we go! */ |
/* Start finite state machine, here we go! */ |
while (thread_fetch (master, &thread)) | while (thread_fetch (bm->master, &thread)) |
thread_call (&thread); |
thread_call (&thread); |
|
|
/* Not reached. */ |
/* Not reached. */ |