jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * IS-IS Rout(e)ing protocol - isis_main.c |
| 3 | * |
| 4 | * Copyright (C) 2001,2002 Sampo Saaristo |
| 5 | * Tampere University of Technology |
| 6 | * Institute of Communications Engineering |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU General Public Licenseas published by the Free |
| 10 | * Software Foundation; either version 2 of the License, or (at your option) |
| 11 | * any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful,but WITHOUT |
| 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 16 | * more details. |
| 17 | |
| 18 | * You should have received a copy of the GNU General Public License along |
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 20 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 21 | */ |
| 22 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 23 | #include <zebra.h> |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 24 | |
| 25 | #include "getopt.h" |
| 26 | #include "thread.h" |
| 27 | #include "log.h" |
gdt | 5e4fa16 | 2004-03-16 14:38:36 +0000 | [diff] [blame] | 28 | #include <lib/version.h> |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 29 | #include "command.h" |
| 30 | #include "vty.h" |
| 31 | #include "memory.h" |
| 32 | #include "stream.h" |
| 33 | #include "if.h" |
jardin | 9e867fe | 2003-12-23 08:56:18 +0000 | [diff] [blame] | 34 | #include "privs.h" |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 35 | #include "sigevent.h" |
hasso | c729c65 | 2004-10-13 08:36:47 +0000 | [diff] [blame] | 36 | #include "filter.h" |
Christian Franke | acf9865 | 2015-11-12 14:24:22 +0100 | [diff] [blame] | 37 | #include "plist.h" |
Vyacheslav Trushkin | 48d8bea | 2011-11-25 18:51:48 +0400 | [diff] [blame] | 38 | #include "zclient.h" |
Feng Lu | 126215c | 2015-05-22 11:39:58 +0200 | [diff] [blame] | 39 | #include "vrf.h" |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 40 | |
| 41 | #include "isisd/dict.h" |
| 42 | #include "include-netbsd/iso.h" |
| 43 | #include "isisd/isis_constants.h" |
| 44 | #include "isisd/isis_common.h" |
| 45 | #include "isisd/isis_flags.h" |
| 46 | #include "isisd/isis_circuit.h" |
| 47 | #include "isisd/isisd.h" |
| 48 | #include "isisd/isis_dynhn.h" |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 49 | #include "isisd/isis_spf.h" |
| 50 | #include "isisd/isis_route.h" |
Christian Franke | acf9865 | 2015-11-12 14:24:22 +0100 | [diff] [blame] | 51 | #include "isisd/isis_routemap.h" |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 52 | #include "isisd/isis_zebra.h" |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 53 | |
| 54 | /* Default configuration file name */ |
| 55 | #define ISISD_DEFAULT_CONFIG "isisd.conf" |
| 56 | /* Default vty port */ |
jardin | fc58e87 | 2003-12-23 10:42:45 +0000 | [diff] [blame] | 57 | #define ISISD_VTY_PORT 2608 |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 58 | |
jardin | 9e867fe | 2003-12-23 08:56:18 +0000 | [diff] [blame] | 59 | /* isisd privileges */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 60 | zebra_capabilities_t _caps_p[] = { |
paul | ceacedb | 2005-09-29 14:39:32 +0000 | [diff] [blame] | 61 | ZCAP_NET_RAW, |
jardin | 9e867fe | 2003-12-23 08:56:18 +0000 | [diff] [blame] | 62 | ZCAP_BIND |
| 63 | }; |
| 64 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 65 | struct zebra_privs_t isisd_privs = { |
jardin | 9e867fe | 2003-12-23 08:56:18 +0000 | [diff] [blame] | 66 | #if defined(QUAGGA_USER) |
| 67 | .user = QUAGGA_USER, |
| 68 | #endif |
| 69 | #if defined QUAGGA_GROUP |
| 70 | .group = QUAGGA_GROUP, |
| 71 | #endif |
| 72 | #ifdef VTY_GROUP |
| 73 | .vty_group = VTY_GROUP, |
| 74 | #endif |
| 75 | .caps_p = _caps_p, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 76 | .cap_num_p = sizeof (_caps_p) / sizeof (*_caps_p), |
jardin | 9e867fe | 2003-12-23 08:56:18 +0000 | [diff] [blame] | 77 | .cap_num_i = 0 |
| 78 | }; |
| 79 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 80 | /* isisd options */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 81 | struct option longopts[] = { |
Vyacheslav Trushkin | 1627b20 | 2011-11-25 17:56:21 +0400 | [diff] [blame] | 82 | {"daemon", no_argument, NULL, 'd'}, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 83 | {"config_file", required_argument, NULL, 'f'}, |
Vyacheslav Trushkin | 1627b20 | 2011-11-25 17:56:21 +0400 | [diff] [blame] | 84 | {"pid_file", required_argument, NULL, 'i'}, |
Vyacheslav Trushkin | 48d8bea | 2011-11-25 18:51:48 +0400 | [diff] [blame] | 85 | {"socket", required_argument, NULL, 'z'}, |
Vyacheslav Trushkin | 1627b20 | 2011-11-25 17:56:21 +0400 | [diff] [blame] | 86 | {"vty_addr", required_argument, NULL, 'A'}, |
| 87 | {"vty_port", required_argument, NULL, 'P'}, |
| 88 | {"user", required_argument, NULL, 'u'}, |
| 89 | {"group", required_argument, NULL, 'g'}, |
| 90 | {"version", no_argument, NULL, 'v'}, |
| 91 | {"dryrun", no_argument, NULL, 'C'}, |
| 92 | {"help", no_argument, NULL, 'h'}, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 93 | {0} |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 94 | }; |
| 95 | |
| 96 | /* Configuration file and directory. */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 97 | char config_default[] = SYSCONFDIR ISISD_DEFAULT_CONFIG; |
| 98 | char *config_file = NULL; |
| 99 | |
| 100 | /* isisd program name. */ |
| 101 | char *progname; |
| 102 | |
| 103 | int daemon_mode = 0; |
| 104 | |
| 105 | /* Master of threads. */ |
| 106 | struct thread_master *master; |
| 107 | |
hasso | c3aac6f | 2004-02-20 18:44:21 +0000 | [diff] [blame] | 108 | /* Process ID saved for use by init system */ |
hasso | 1cd8084 | 2004-10-07 20:07:40 +0000 | [diff] [blame] | 109 | const char *pid_file = PATH_ISISD_PID; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 110 | |
| 111 | /* for reload */ |
hasso | 37da8c0 | 2004-05-19 11:38:40 +0000 | [diff] [blame] | 112 | char _cwd[MAXPATHLEN]; |
| 113 | char _progpath[MAXPATHLEN]; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 114 | int _argc; |
| 115 | char **_argv; |
| 116 | char **_envp; |
| 117 | |
Paul Jakma | 41b36e9 | 2006-12-08 01:09:50 +0000 | [diff] [blame] | 118 | /* |
| 119 | * Prototypes. |
| 120 | */ |
| 121 | void reload(void); |
| 122 | void sighup(void); |
| 123 | void sigint(void); |
| 124 | void sigterm(void); |
| 125 | void sigusr1(void); |
| 126 | |
| 127 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 128 | /* Help information display. */ |
| 129 | static void |
| 130 | usage (int status) |
| 131 | { |
| 132 | if (status != 0) |
| 133 | fprintf (stderr, "Try `%s --help' for more information.\n", progname); |
| 134 | else |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 135 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 136 | printf ("Usage : %s [OPTION...]\n\n\ |
| 137 | Daemon which manages IS-IS routing\n\n\ |
| 138 | -d, --daemon Runs in daemon mode\n\ |
| 139 | -f, --config_file Set configuration file name\n\ |
hasso | c3aac6f | 2004-02-20 18:44:21 +0000 | [diff] [blame] | 140 | -i, --pid_file Set process identifier file name\n\ |
Vyacheslav Trushkin | 48d8bea | 2011-11-25 18:51:48 +0400 | [diff] [blame] | 141 | -z, --socket Set path of zebra socket\n\ |
hasso | c3aac6f | 2004-02-20 18:44:21 +0000 | [diff] [blame] | 142 | -A, --vty_addr Set vty's bind address\n\ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 143 | -P, --vty_port Set vty's port number\n\ |
hasso | c065230 | 2004-11-25 19:33:48 +0000 | [diff] [blame] | 144 | -u, --user User to run as\n\ |
| 145 | -g, --group Group to run as\n\ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 146 | -v, --version Print program version\n\ |
Paul Jakma | 876b8be | 2006-10-15 23:35:57 +0000 | [diff] [blame] | 147 | -C, --dryrun Check configuration for validity and exit\n\ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 148 | -h, --help Display this help and exit\n\ |
| 149 | \n\ |
Christian Franke | 4ff3bca | 2013-03-20 10:50:07 +0000 | [diff] [blame] | 150 | Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | exit (status); |
| 154 | } |
| 155 | |
| 156 | |
| 157 | void |
| 158 | reload () |
| 159 | { |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 160 | zlog_debug ("Reload"); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 161 | /* FIXME: Clean up func call here */ |
ajs | cdb6ee9 | 2005-02-23 15:48:32 +0000 | [diff] [blame] | 162 | vty_reset (); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 163 | (void) isisd_privs.change (ZPRIVS_RAISE); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 164 | execve (_progpath, _argv, _envp); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 165 | zlog_err ("Reload failed: cannot exec %s: %s", _progpath, |
| 166 | safe_strerror (errno)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 167 | } |
| 168 | |
ajs | 887c44a | 2004-12-03 16:36:46 +0000 | [diff] [blame] | 169 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 170 | terminate (int i) |
| 171 | { |
| 172 | exit (i); |
| 173 | } |
| 174 | |
| 175 | /* |
| 176 | * Signal handlers |
| 177 | */ |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 178 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 179 | void |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 180 | sighup (void) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 181 | { |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 182 | zlog_debug ("SIGHUP received"); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 183 | reload (); |
| 184 | |
| 185 | return; |
| 186 | } |
| 187 | |
| 188 | void |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 189 | sigint (void) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 190 | { |
ajs | 887c44a | 2004-12-03 16:36:46 +0000 | [diff] [blame] | 191 | zlog_notice ("Terminating on signal SIGINT"); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 192 | terminate (0); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | void |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 196 | sigterm (void) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 197 | { |
ajs | 887c44a | 2004-12-03 16:36:46 +0000 | [diff] [blame] | 198 | zlog_notice ("Terminating on signal SIGTERM"); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 199 | terminate (0); |
| 200 | } |
| 201 | |
| 202 | void |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 203 | sigusr1 (void) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 204 | { |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 205 | zlog_debug ("SIGUSR1 received"); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 206 | zlog_rotate (NULL); |
| 207 | } |
| 208 | |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 209 | struct quagga_signal_t isisd_signals[] = |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 210 | { |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 211 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 212 | .signal = SIGHUP, |
| 213 | .handler = &sighup, |
| 214 | }, |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 215 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 216 | .signal = SIGUSR1, |
| 217 | .handler = &sigusr1, |
| 218 | }, |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 219 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 220 | .signal = SIGINT, |
| 221 | .handler = &sigint, |
| 222 | }, |
| 223 | { |
| 224 | .signal = SIGTERM, |
| 225 | .handler = &sigterm, |
| 226 | }, |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 227 | }; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 228 | |
| 229 | /* |
| 230 | * Main routine of isisd. Parse arguments and handle IS-IS state machine. |
| 231 | */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 232 | int |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 233 | main (int argc, char **argv, char **envp) |
| 234 | { |
| 235 | char *p; |
| 236 | int opt, vty_port = ISISD_VTY_PORT; |
| 237 | struct thread thread; |
| 238 | char *config_file = NULL; |
| 239 | char *vty_addr = NULL; |
Paul Jakma | 876b8be | 2006-10-15 23:35:57 +0000 | [diff] [blame] | 240 | int dryrun = 0; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 241 | |
| 242 | /* Get the programname without the preceding path. */ |
| 243 | progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]); |
| 244 | |
ajs | 274a4a4 | 2004-12-07 15:39:31 +0000 | [diff] [blame] | 245 | zlog_default = openzlog (progname, ZLOG_ISIS, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 246 | LOG_CONS | LOG_NDELAY | LOG_PID, LOG_DAEMON); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 247 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 248 | /* for reload */ |
| 249 | _argc = argc; |
| 250 | _argv = argv; |
| 251 | _envp = envp; |
| 252 | getcwd (_cwd, sizeof (_cwd)); |
| 253 | if (*argv[0] == '.') |
| 254 | snprintf (_progpath, sizeof (_progpath), "%s/%s", _cwd, _argv[0]); |
| 255 | else |
| 256 | snprintf (_progpath, sizeof (_progpath), "%s", argv[0]); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 257 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 258 | /* Command line argument treatment. */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 259 | while (1) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 260 | { |
Vyacheslav Trushkin | 48d8bea | 2011-11-25 18:51:48 +0400 | [diff] [blame] | 261 | opt = getopt_long (argc, argv, "df:i:z:hA:p:P:u:g:vC", longopts, 0); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 262 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 263 | if (opt == EOF) |
| 264 | break; |
| 265 | |
| 266 | switch (opt) |
| 267 | { |
| 268 | case 0: |
jardin | 9e867fe | 2003-12-23 08:56:18 +0000 | [diff] [blame] | 269 | break; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 270 | case 'd': |
| 271 | daemon_mode = 1; |
| 272 | break; |
| 273 | case 'f': |
| 274 | config_file = optarg; |
| 275 | break; |
| 276 | case 'i': |
| 277 | pid_file = optarg; |
| 278 | break; |
Vyacheslav Trushkin | 48d8bea | 2011-11-25 18:51:48 +0400 | [diff] [blame] | 279 | case 'z': |
| 280 | zclient_serv_path_set (optarg); |
| 281 | break; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 282 | case 'A': |
| 283 | vty_addr = optarg; |
| 284 | break; |
| 285 | case 'P': |
| 286 | /* Deal with atoi() returning 0 on failure, and isisd not |
| 287 | listening on isisd port... */ |
| 288 | if (strcmp (optarg, "0") == 0) |
| 289 | { |
| 290 | vty_port = 0; |
| 291 | break; |
| 292 | } |
| 293 | vty_port = atoi (optarg); |
| 294 | vty_port = (vty_port ? vty_port : ISISD_VTY_PORT); |
| 295 | break; |
| 296 | case 'u': |
hasso | c065230 | 2004-11-25 19:33:48 +0000 | [diff] [blame] | 297 | isisd_privs.user = optarg; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 298 | break; |
hasso | c065230 | 2004-11-25 19:33:48 +0000 | [diff] [blame] | 299 | case 'g': |
| 300 | isisd_privs.group = optarg; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 301 | break; |
| 302 | case 'v': |
| 303 | printf ("ISISd version %s\n", ISISD_VERSION); |
| 304 | printf ("Copyright (c) 2001-2002 Sampo Saaristo," |
| 305 | " Ofer Wald and Hannes Gredler\n"); |
| 306 | print_version ("Zebra"); |
| 307 | exit (0); |
| 308 | break; |
Paul Jakma | 876b8be | 2006-10-15 23:35:57 +0000 | [diff] [blame] | 309 | case 'C': |
| 310 | dryrun = 1; |
| 311 | break; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 312 | case 'h': |
| 313 | usage (0); |
| 314 | break; |
| 315 | default: |
| 316 | usage (1); |
| 317 | break; |
| 318 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 319 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 320 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 321 | /* thread master */ |
| 322 | master = thread_master_create (); |
| 323 | |
| 324 | /* random seed from time */ |
Donald Sharp | f31bab4 | 2015-06-19 19:26:19 -0400 | [diff] [blame] | 325 | srandom (time (NULL)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 326 | |
| 327 | /* |
| 328 | * initializations |
| 329 | */ |
jardin | 9e867fe | 2003-12-23 08:56:18 +0000 | [diff] [blame] | 330 | zprivs_init (&isisd_privs); |
Balaji.G | 837d16c | 2012-09-26 14:09:10 +0530 | [diff] [blame] | 331 | signal_init (master, array_size (isisd_signals), isisd_signals); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 332 | cmd_init (1); |
jardin | 9e867fe | 2003-12-23 08:56:18 +0000 | [diff] [blame] | 333 | vty_init (master); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 334 | memory_init (); |
hasso | c729c65 | 2004-10-13 08:36:47 +0000 | [diff] [blame] | 335 | access_list_init(); |
Feng Lu | 126215c | 2015-05-22 11:39:58 +0200 | [diff] [blame] | 336 | vrf_init (); |
Christian Franke | acf9865 | 2015-11-12 14:24:22 +0100 | [diff] [blame] | 337 | prefix_list_init(); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 338 | isis_init (); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 339 | isis_circuit_init (); |
| 340 | isis_spf_cmds_init (); |
Christian Franke | acf9865 | 2015-11-12 14:24:22 +0100 | [diff] [blame] | 341 | isis_redist_init (); |
| 342 | isis_route_map_init(); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 343 | |
| 344 | /* create the global 'isis' instance */ |
| 345 | isis_new (1); |
| 346 | |
Donald Sharp | 7125293 | 2015-09-24 09:25:19 -0400 | [diff] [blame] | 347 | isis_zebra_init (master); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 348 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 349 | /* parse config file */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 350 | /* this is needed three times! because we have interfaces before the areas */ |
hasso | 320ec10 | 2004-06-20 19:54:37 +0000 | [diff] [blame] | 351 | vty_read_config (config_file, config_default); |
hasso | 00995cf | 2004-05-19 13:43:50 +0000 | [diff] [blame] | 352 | |
Paul Jakma | 876b8be | 2006-10-15 23:35:57 +0000 | [diff] [blame] | 353 | /* Start execution only if not in dry-run mode */ |
| 354 | if (dryrun) |
| 355 | return(0); |
| 356 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 357 | /* demonize */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 358 | if (daemon_mode) |
| 359 | daemon (0, 0); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 360 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 361 | /* Process ID file creation. */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 362 | if (pid_file[0] != '\0') |
| 363 | pid_output (pid_file); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 364 | |
| 365 | /* Make isis vty socket. */ |
jardin | 9e867fe | 2003-12-23 08:56:18 +0000 | [diff] [blame] | 366 | vty_serv_sock (vty_addr, vty_port, ISIS_VTYSH_PATH); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 367 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 368 | /* Print banner. */ |
ajs | 887c44a | 2004-12-03 16:36:46 +0000 | [diff] [blame] | 369 | zlog_notice ("Quagga-ISISd %s starting: vty@%d", QUAGGA_VERSION, vty_port); |
hasso | c89c05d | 2005-09-04 21:36:36 +0000 | [diff] [blame] | 370 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 371 | /* Start finite state machine. */ |
| 372 | while (thread_fetch (master, &thread)) |
| 373 | thread_call (&thread); |
| 374 | |
| 375 | /* Not reached. */ |
| 376 | exit (0); |
| 377 | } |