paul | edd7c24 | 2003-06-04 13:59:38 +0000 | [diff] [blame] | 1 | /* zebra daemon main routine. |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2 | * Copyright (C) 1997, 98 Kunihiro Ishiguro |
| 3 | * |
| 4 | * This file is part of GNU Zebra. |
| 5 | * |
| 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 |
| 9 | * later version. |
| 10 | * |
| 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. |
| 15 | * |
| 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 |
| 19 | * 02111-1307, USA. |
| 20 | */ |
| 21 | |
| 22 | #include <zebra.h> |
| 23 | |
gdt | 5e4fa16 | 2004-03-16 14:38:36 +0000 | [diff] [blame] | 24 | #include <lib/version.h> |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 25 | #include "getopt.h" |
| 26 | #include "command.h" |
| 27 | #include "thread.h" |
| 28 | #include "filter.h" |
| 29 | #include "memory.h" |
| 30 | #include "prefix.h" |
| 31 | #include "log.h" |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 32 | #include "plist.h" |
paul | edd7c24 | 2003-06-04 13:59:38 +0000 | [diff] [blame] | 33 | #include "privs.h" |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 34 | #include "sigevent.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 35 | |
| 36 | #include "zebra/rib.h" |
| 37 | #include "zebra/zserv.h" |
| 38 | #include "zebra/debug.h" |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 39 | #include "zebra/router-id.h" |
hasso | ca77698 | 2004-06-12 14:33:05 +0000 | [diff] [blame] | 40 | #include "zebra/irdp.h" |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 41 | #include "zebra/rtadv.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 42 | |
paul | b21b19c | 2003-06-15 01:28:29 +0000 | [diff] [blame] | 43 | /* Zebra instance */ |
| 44 | struct zebra_t zebrad = |
| 45 | { |
| 46 | .rtm_table_default = 0, |
| 47 | }; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 48 | |
| 49 | /* process id. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 50 | pid_t pid; |
| 51 | |
gdt | 87efd64 | 2004-06-30 17:36:11 +0000 | [diff] [blame] | 52 | /* Pacify zclient.o in libzebra, which expects this variable. */ |
| 53 | struct thread_master *master; |
| 54 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 55 | /* Route retain mode flag. */ |
| 56 | int retain_mode = 0; |
| 57 | |
| 58 | /* Don't delete kernel route. */ |
| 59 | int keep_kernel_mode = 0; |
| 60 | |
hasso | c34b6b5 | 2004-08-31 13:41:49 +0000 | [diff] [blame] | 61 | #ifdef HAVE_NETLINK |
| 62 | /* Receive buffer size for netlink socket */ |
| 63 | u_int32_t nl_rcvbufsize = 0; |
| 64 | #endif /* HAVE_NETLINK */ |
| 65 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 66 | /* Command line options. */ |
| 67 | struct option longopts[] = |
| 68 | { |
| 69 | { "batch", no_argument, NULL, 'b'}, |
| 70 | { "daemon", no_argument, NULL, 'd'}, |
| 71 | { "keep_kernel", no_argument, NULL, 'k'}, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 72 | { "config_file", required_argument, NULL, 'f'}, |
| 73 | { "pid_file", required_argument, NULL, 'i'}, |
| 74 | { "help", no_argument, NULL, 'h'}, |
| 75 | { "vty_addr", required_argument, NULL, 'A'}, |
| 76 | { "vty_port", required_argument, NULL, 'P'}, |
| 77 | { "retain", no_argument, NULL, 'r'}, |
Paul Jakma | 876b8be | 2006-10-15 23:35:57 +0000 | [diff] [blame] | 78 | { "dryrun", no_argument, NULL, 'C'}, |
hasso | c34b6b5 | 2004-08-31 13:41:49 +0000 | [diff] [blame] | 79 | #ifdef HAVE_NETLINK |
hasso | 583d800 | 2005-01-16 23:34:02 +0000 | [diff] [blame] | 80 | { "nl-bufsize", required_argument, NULL, 's'}, |
hasso | c34b6b5 | 2004-08-31 13:41:49 +0000 | [diff] [blame] | 81 | #endif /* HAVE_NETLINK */ |
paul | edd7c24 | 2003-06-04 13:59:38 +0000 | [diff] [blame] | 82 | { "user", required_argument, NULL, 'u'}, |
hasso | c065230 | 2004-11-25 19:33:48 +0000 | [diff] [blame] | 83 | { "group", required_argument, NULL, 'g'}, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 84 | { "version", no_argument, NULL, 'v'}, |
| 85 | { 0 } |
| 86 | }; |
| 87 | |
paul | edd7c24 | 2003-06-04 13:59:38 +0000 | [diff] [blame] | 88 | zebra_capabilities_t _caps_p [] = |
| 89 | { |
paul | ceacedb | 2005-09-29 14:39:32 +0000 | [diff] [blame] | 90 | ZCAP_NET_ADMIN, |
paul | edd7c24 | 2003-06-04 13:59:38 +0000 | [diff] [blame] | 91 | ZCAP_SYS_ADMIN, |
paul | ceacedb | 2005-09-29 14:39:32 +0000 | [diff] [blame] | 92 | ZCAP_NET_RAW, |
paul | edd7c24 | 2003-06-04 13:59:38 +0000 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | /* zebra privileges to run with */ |
| 96 | struct zebra_privs_t zserv_privs = |
| 97 | { |
paul | d81fadf | 2003-08-14 05:32:12 +0000 | [diff] [blame] | 98 | #if defined(QUAGGA_USER) && defined(QUAGGA_GROUP) |
| 99 | .user = QUAGGA_USER, |
| 100 | .group = QUAGGA_GROUP, |
paul | edd7c24 | 2003-06-04 13:59:38 +0000 | [diff] [blame] | 101 | #endif |
| 102 | #ifdef VTY_GROUP |
| 103 | .vty_group = VTY_GROUP, |
| 104 | #endif |
| 105 | .caps_p = _caps_p, |
| 106 | .cap_num_p = sizeof(_caps_p)/sizeof(_caps_p[0]), |
| 107 | .cap_num_i = 0 |
| 108 | }; |
| 109 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 110 | /* Default configuration file path. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 111 | char config_default[] = SYSCONFDIR DEFAULT_CONFIG_FILE; |
| 112 | |
| 113 | /* Process ID saved for use by init system */ |
hasso | fce954f | 2004-10-07 20:29:24 +0000 | [diff] [blame] | 114 | const char *pid_file = PATH_ZEBRA_PID; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 115 | |
| 116 | /* Help information display. */ |
| 117 | static void |
| 118 | usage (char *progname, int status) |
| 119 | { |
| 120 | if (status != 0) |
| 121 | fprintf (stderr, "Try `%s --help' for more information.\n", progname); |
| 122 | else |
| 123 | { |
hasso | c34b6b5 | 2004-08-31 13:41:49 +0000 | [diff] [blame] | 124 | printf ("Usage : %s [OPTION...]\n\n"\ |
| 125 | "Daemon which manages kernel routing table management and "\ |
| 126 | "redistribution between different routing protocols.\n\n"\ |
| 127 | "-b, --batch Runs in batch mode\n"\ |
| 128 | "-d, --daemon Runs in daemon mode\n"\ |
| 129 | "-f, --config_file Set configuration file name\n"\ |
| 130 | "-i, --pid_file Set process identifier file name\n"\ |
| 131 | "-k, --keep_kernel Don't delete old routes which installed by "\ |
| 132 | "zebra.\n"\ |
Paul Jakma | 876b8be | 2006-10-15 23:35:57 +0000 | [diff] [blame] | 133 | "-C, --dryrun Check configuration for validity and exit\n"\ |
hasso | c34b6b5 | 2004-08-31 13:41:49 +0000 | [diff] [blame] | 134 | "-A, --vty_addr Set vty's bind address\n"\ |
| 135 | "-P, --vty_port Set vty's port number\n"\ |
| 136 | "-r, --retain When program terminates, retain added route "\ |
| 137 | "by zebra.\n"\ |
hasso | c065230 | 2004-11-25 19:33:48 +0000 | [diff] [blame] | 138 | "-u, --user User to run as\n"\ |
| 139 | "-g, --group Group to run as\n", progname); |
hasso | c34b6b5 | 2004-08-31 13:41:49 +0000 | [diff] [blame] | 140 | #ifdef HAVE_NETLINK |
| 141 | printf ("-s, --nl-bufsize Set netlink receive buffer size\n"); |
| 142 | #endif /* HAVE_NETLINK */ |
| 143 | printf ("-v, --version Print program version\n"\ |
| 144 | "-h, --help Display this help and exit\n"\ |
| 145 | "\n"\ |
| 146 | "Report bugs to %s\n", ZEBRA_BUG_ADDRESS); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | exit (status); |
| 150 | } |
| 151 | |
| 152 | /* SIGHUP handler. */ |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 153 | static void |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 154 | sighup (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 155 | { |
| 156 | zlog_info ("SIGHUP received"); |
| 157 | |
| 158 | /* Reload of config file. */ |
| 159 | ; |
| 160 | } |
| 161 | |
| 162 | /* SIGINT handler. */ |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 163 | static void |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 164 | sigint (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 165 | { |
ajs | 887c44a | 2004-12-03 16:36:46 +0000 | [diff] [blame] | 166 | zlog_notice ("Terminating on signal"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 167 | |
| 168 | if (!retain_mode) |
| 169 | rib_close (); |
hasso | ca77698 | 2004-06-12 14:33:05 +0000 | [diff] [blame] | 170 | #ifdef HAVE_IRDP |
| 171 | irdp_finish(); |
| 172 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 173 | |
| 174 | exit (0); |
| 175 | } |
| 176 | |
| 177 | /* SIGUSR1 handler. */ |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 178 | static void |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 179 | sigusr1 (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 180 | { |
| 181 | zlog_rotate (NULL); |
| 182 | } |
| 183 | |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 184 | struct quagga_signal_t zebra_signals[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 185 | { |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 186 | { |
| 187 | .signal = SIGHUP, |
| 188 | .handler = &sighup, |
| 189 | }, |
| 190 | { |
| 191 | .signal = SIGUSR1, |
| 192 | .handler = &sigusr1, |
| 193 | }, |
| 194 | { |
| 195 | .signal = SIGINT, |
hasso | 8c903fb | 2004-03-17 20:39:18 +0000 | [diff] [blame] | 196 | .handler = &sigint, |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 197 | }, |
hasso | f571dab | 2004-03-22 08:55:25 +0000 | [diff] [blame] | 198 | { |
| 199 | .signal = SIGTERM, |
| 200 | .handler = &sigint, |
| 201 | }, |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 202 | }; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 203 | |
| 204 | /* Main startup routine. */ |
| 205 | int |
| 206 | main (int argc, char **argv) |
| 207 | { |
| 208 | char *p; |
| 209 | char *vty_addr = NULL; |
paul | 4fc4e7a | 2003-01-22 19:47:09 +0000 | [diff] [blame] | 210 | int vty_port = ZEBRA_VTY_PORT; |
Paul Jakma | 876b8be | 2006-10-15 23:35:57 +0000 | [diff] [blame] | 211 | int dryrun = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 212 | int batch_mode = 0; |
| 213 | int daemon_mode = 0; |
| 214 | char *config_file = NULL; |
| 215 | char *progname; |
| 216 | struct thread thread; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 217 | |
| 218 | /* Set umask before anything for security */ |
| 219 | umask (0027); |
| 220 | |
| 221 | /* preserve my name */ |
| 222 | progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]); |
| 223 | |
ajs | 274a4a4 | 2004-12-07 15:39:31 +0000 | [diff] [blame] | 224 | zlog_default = openzlog (progname, ZLOG_ZEBRA, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 225 | LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON); |
| 226 | |
| 227 | while (1) |
| 228 | { |
| 229 | int opt; |
| 230 | |
hasso | c34b6b5 | 2004-08-31 13:41:49 +0000 | [diff] [blame] | 231 | #ifdef HAVE_NETLINK |
Jeremy Jackson | c77cffd | 2008-12-28 12:57:42 -0500 | [diff] [blame^] | 232 | opt = getopt_long (argc, argv, "bdkf:i:hA:P:ru:g:vs:C", longopts, 0); |
hasso | c34b6b5 | 2004-08-31 13:41:49 +0000 | [diff] [blame] | 233 | #else |
Jeremy Jackson | c77cffd | 2008-12-28 12:57:42 -0500 | [diff] [blame^] | 234 | opt = getopt_long (argc, argv, "bdkf:i:hA:P:ru:g:vC", longopts, 0); |
hasso | c34b6b5 | 2004-08-31 13:41:49 +0000 | [diff] [blame] | 235 | #endif /* HAVE_NETLINK */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 236 | |
| 237 | if (opt == EOF) |
| 238 | break; |
| 239 | |
| 240 | switch (opt) |
| 241 | { |
| 242 | case 0: |
| 243 | break; |
| 244 | case 'b': |
| 245 | batch_mode = 1; |
| 246 | case 'd': |
| 247 | daemon_mode = 1; |
| 248 | break; |
| 249 | case 'k': |
| 250 | keep_kernel_mode = 1; |
| 251 | break; |
Paul Jakma | 876b8be | 2006-10-15 23:35:57 +0000 | [diff] [blame] | 252 | case 'C': |
| 253 | dryrun = 1; |
| 254 | break; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 255 | case 'f': |
| 256 | config_file = optarg; |
| 257 | break; |
| 258 | case 'A': |
| 259 | vty_addr = optarg; |
| 260 | break; |
| 261 | case 'i': |
| 262 | pid_file = optarg; |
| 263 | break; |
| 264 | case 'P': |
paul | 4fc4e7a | 2003-01-22 19:47:09 +0000 | [diff] [blame] | 265 | /* Deal with atoi() returning 0 on failure, and zebra not |
| 266 | listening on zebra port... */ |
| 267 | if (strcmp(optarg, "0") == 0) |
| 268 | { |
| 269 | vty_port = 0; |
| 270 | break; |
| 271 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 272 | vty_port = atoi (optarg); |
Paul Jakma | 0d6b2ee | 2008-05-29 18:29:16 +0000 | [diff] [blame] | 273 | if (vty_port <= 0 || vty_port > 0xffff) |
| 274 | vty_port = ZEBRA_VTY_PORT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 275 | break; |
| 276 | case 'r': |
| 277 | retain_mode = 1; |
| 278 | break; |
hasso | c34b6b5 | 2004-08-31 13:41:49 +0000 | [diff] [blame] | 279 | #ifdef HAVE_NETLINK |
| 280 | case 's': |
| 281 | nl_rcvbufsize = atoi (optarg); |
| 282 | break; |
| 283 | #endif /* HAVE_NETLINK */ |
hasso | c065230 | 2004-11-25 19:33:48 +0000 | [diff] [blame] | 284 | case 'u': |
| 285 | zserv_privs.user = optarg; |
| 286 | break; |
| 287 | case 'g': |
| 288 | zserv_privs.group = optarg; |
| 289 | break; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 290 | case 'v': |
| 291 | print_version (progname); |
| 292 | exit (0); |
| 293 | break; |
| 294 | case 'h': |
| 295 | usage (progname, 0); |
| 296 | break; |
| 297 | default: |
| 298 | usage (progname, 1); |
| 299 | break; |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | /* Make master thread emulator. */ |
paul | b21b19c | 2003-06-15 01:28:29 +0000 | [diff] [blame] | 304 | zebrad.master = thread_master_create (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 305 | |
paul | edd7c24 | 2003-06-04 13:59:38 +0000 | [diff] [blame] | 306 | /* privs initialise */ |
| 307 | zprivs_init (&zserv_privs); |
| 308 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 309 | /* Vty related initialize. */ |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 310 | signal_init (zebrad.master, Q_SIGC(zebra_signals), zebra_signals); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 311 | cmd_init (1); |
paul | b21b19c | 2003-06-15 01:28:29 +0000 | [diff] [blame] | 312 | vty_init (zebrad.master); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 313 | memory_init (); |
| 314 | |
| 315 | /* Zebra related initialize. */ |
| 316 | zebra_init (); |
| 317 | rib_init (); |
| 318 | zebra_if_init (); |
| 319 | zebra_debug_init (); |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 320 | router_id_init(); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 321 | zebra_vty_init (); |
| 322 | access_list_init (); |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 323 | prefix_list_init (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 324 | rtadv_init (); |
hasso | ca77698 | 2004-06-12 14:33:05 +0000 | [diff] [blame] | 325 | #ifdef HAVE_IRDP |
| 326 | irdp_init(); |
| 327 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 328 | |
| 329 | /* For debug purpose. */ |
| 330 | /* SET_FLAG (zebra_debug_event, ZEBRA_DEBUG_EVENT); */ |
| 331 | |
| 332 | /* Make kernel routing socket. */ |
| 333 | kernel_init (); |
| 334 | interface_list (); |
| 335 | route_read (); |
| 336 | |
| 337 | /* Sort VTY commands. */ |
| 338 | sort_node (); |
| 339 | |
| 340 | #ifdef HAVE_SNMP |
| 341 | zebra_snmp_init (); |
| 342 | #endif /* HAVE_SNMP */ |
| 343 | |
Denis Ovsienko | 91b7351 | 2007-09-14 13:31:52 +0000 | [diff] [blame] | 344 | /* Process the configuration file. Among other configuration |
| 345 | * directives we can meet those installing static routes. Such |
| 346 | * requests will not be executed immediately, but queued in |
| 347 | * zebra->ribq structure until we enter the main execution loop. |
| 348 | * The notifications from kernel will show originating PID equal |
| 349 | * to that after daemon() completes (if ever called). |
| 350 | */ |
hasso | 320ec10 | 2004-06-20 19:54:37 +0000 | [diff] [blame] | 351 | vty_read_config (config_file, config_default); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 352 | |
Paul Jakma | 876b8be | 2006-10-15 23:35:57 +0000 | [diff] [blame] | 353 | /* Don't start execution if we are in dry-run mode */ |
| 354 | if (dryrun) |
| 355 | return(0); |
| 356 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 357 | /* Clean up rib. */ |
| 358 | rib_weed_tables (); |
| 359 | |
| 360 | /* Exit when zebra is working in batch mode. */ |
| 361 | if (batch_mode) |
| 362 | exit (0); |
| 363 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 364 | /* Daemonize. */ |
| 365 | if (daemon_mode) |
| 366 | daemon (0, 0); |
| 367 | |
| 368 | /* Output pid of zebra. */ |
| 369 | pid_output (pid_file); |
| 370 | |
Denis Ovsienko | 91b7351 | 2007-09-14 13:31:52 +0000 | [diff] [blame] | 371 | /* After we have successfully acquired the pidfile, we can be sure |
| 372 | * about being the only copy of zebra process, which is submitting |
| 373 | * changes to the FIB. |
| 374 | * Clean up zebra-originated routes. The requests will be sent to OS |
| 375 | * immediately, so originating PID in notifications from kernel |
| 376 | * will be equal to the current getpid(). To know about such routes, |
| 377 | * we have to have route_read() called before. |
| 378 | */ |
| 379 | if (! keep_kernel_mode) |
| 380 | rib_sweep_route (); |
| 381 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 382 | /* Needed for BSD routing socket. */ |
| 383 | pid = getpid (); |
| 384 | |
| 385 | /* Make vty server socket. */ |
paul | 4fc4e7a | 2003-01-22 19:47:09 +0000 | [diff] [blame] | 386 | vty_serv_sock (vty_addr, vty_port, ZEBRA_VTYSH_PATH); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 387 | |
ajs | 887c44a | 2004-12-03 16:36:46 +0000 | [diff] [blame] | 388 | /* Print banner. */ |
| 389 | zlog_notice ("Zebra %s starting: vty@%d", QUAGGA_VERSION, vty_port); |
| 390 | |
paul | b21b19c | 2003-06-15 01:28:29 +0000 | [diff] [blame] | 391 | while (thread_fetch (zebrad.master, &thread)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 392 | thread_call (&thread); |
| 393 | |
| 394 | /* Not reached... */ |
paul | e8e1946 | 2006-01-19 20:16:55 +0000 | [diff] [blame] | 395 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 396 | } |