]>
Commit | Line | Data |
---|---|---|
eb5d44eb | 1 | /* |
2 | * IS-IS Rout(e)ing protocol - isis_main.c | |
3 | * | |
4 | * Copyright (C) 2001,2002 Sampo Saaristo | |
d62a17ae | 5 | * Tampere University of Technology |
eb5d44eb | 6 | * Institute of Communications Engineering |
7 | * | |
d62a17ae | 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) | |
eb5d44eb | 11 | * any later version. |
12 | * | |
d62a17ae | 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 | |
eb5d44eb | 16 | * more details. |
896014f4 DL |
17 | * |
18 | * You should have received a copy of the GNU General Public License along | |
19 | * with this program; see the file COPYING; if not, write to the Free Software | |
20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
eb5d44eb | 21 | */ |
22 | ||
eb5d44eb | 23 | #include <zebra.h> |
eb5d44eb | 24 | |
25 | #include "getopt.h" | |
26 | #include "thread.h" | |
27 | #include "log.h" | |
5e4fa164 | 28 | #include <lib/version.h> |
eb5d44eb | 29 | #include "command.h" |
30 | #include "vty.h" | |
31 | #include "memory.h" | |
32 | #include "stream.h" | |
33 | #include "if.h" | |
9e867fe6 | 34 | #include "privs.h" |
2d75d052 | 35 | #include "sigevent.h" |
c729c650 | 36 | #include "filter.h" |
f3ccedaa | 37 | #include "plist.h" |
48d8bea8 | 38 | #include "zclient.h" |
6a69b354 | 39 | #include "vrf.h" |
676a4ea3 | 40 | #include "qobj.h" |
4f04a76b | 41 | #include "libfrr.h" |
eb5d44eb | 42 | |
eb5d44eb | 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" | |
3f045a08 JB |
49 | #include "isisd/isis_spf.h" |
50 | #include "isisd/isis_route.h" | |
f3ccedaa | 51 | #include "isisd/isis_routemap.h" |
3f045a08 | 52 | #include "isisd/isis_zebra.h" |
f8c06e2c | 53 | #include "isisd/isis_te.h" |
54ece698 | 54 | #include "isisd/isis_errors.h" |
52df8228 | 55 | #include "isisd/isis_bfd.h" |
a5b5e946 | 56 | #include "isisd/isis_lsp.h" |
d56afe53 | 57 | #include "isisd/isis_mt.h" |
2cd971af | 58 | #include "isisd/fabricd.h" |
2a1c520e | 59 | #include "isisd/isis_nb.h" |
eb5d44eb | 60 | |
61 | /* Default configuration file name */ | |
62 | #define ISISD_DEFAULT_CONFIG "isisd.conf" | |
63 | /* Default vty port */ | |
fc58e874 | 64 | #define ISISD_VTY_PORT 2608 |
7c0cbd0e | 65 | #define FABRICD_VTY_PORT 2618 |
eb5d44eb | 66 | |
9e867fe6 | 67 | /* isisd privileges */ |
d62a17ae | 68 | zebra_capabilities_t _caps_p[] = {ZCAP_NET_RAW, ZCAP_BIND}; |
9e867fe6 | 69 | |
f390d2c7 | 70 | struct zebra_privs_t isisd_privs = { |
b2f36157 | 71 | #if defined(FRR_USER) |
d62a17ae | 72 | .user = FRR_USER, |
9e867fe6 | 73 | #endif |
b2f36157 | 74 | #if defined FRR_GROUP |
d62a17ae | 75 | .group = FRR_GROUP, |
9e867fe6 | 76 | #endif |
77 | #ifdef VTY_GROUP | |
d62a17ae | 78 | .vty_group = VTY_GROUP, |
9e867fe6 | 79 | #endif |
d62a17ae | 80 | .caps_p = _caps_p, |
97b5d752 | 81 | .cap_num_p = array_size(_caps_p), |
d62a17ae | 82 | .cap_num_i = 0}; |
9e867fe6 | 83 | |
eb5d44eb | 84 | /* isisd options */ |
d62a17ae | 85 | struct option longopts[] = {{0}}; |
eb5d44eb | 86 | |
eb5d44eb | 87 | /* Master of threads. */ |
88 | struct thread_master *master; | |
89 | ||
41b36e90 PJ |
90 | /* |
91 | * Prototypes. | |
92 | */ | |
41b36e90 PJ |
93 | void sighup(void); |
94 | void sigint(void); | |
95 | void sigterm(void); | |
96 | void sigusr1(void); | |
97 | ||
98 | ||
d62a17ae | 99 | static __attribute__((__noreturn__)) void terminate(int i) |
eb5d44eb | 100 | { |
d62a17ae | 101 | isis_zebra_stop(); |
102 | exit(i); | |
eb5d44eb | 103 | } |
104 | ||
105 | /* | |
106 | * Signal handlers | |
107 | */ | |
98cbd0f2 | 108 | #ifdef FABRICD |
d62a17ae | 109 | void sighup(void) |
eb5d44eb | 110 | { |
98cbd0f2 | 111 | zlog_notice("SIGHUP/reload is not implemented for fabricd"); |
d62a17ae | 112 | return; |
eb5d44eb | 113 | } |
98cbd0f2 EDP |
114 | #else |
115 | static struct frr_daemon_info isisd_di; | |
116 | void sighup(void) | |
117 | { | |
118 | zlog_info("SIGHUP received"); | |
119 | ||
120 | /* Reload config file. */ | |
121 | vty_read_config(NULL, isisd_di.config_file, config_default); | |
122 | } | |
123 | ||
124 | #endif | |
eb5d44eb | 125 | |
d62a17ae | 126 | __attribute__((__noreturn__)) void sigint(void) |
eb5d44eb | 127 | { |
d62a17ae | 128 | zlog_notice("Terminating on signal SIGINT"); |
129 | terminate(0); | |
eb5d44eb | 130 | } |
131 | ||
d62a17ae | 132 | __attribute__((__noreturn__)) void sigterm(void) |
eb5d44eb | 133 | { |
d62a17ae | 134 | zlog_notice("Terminating on signal SIGTERM"); |
135 | terminate(0); | |
eb5d44eb | 136 | } |
137 | ||
d62a17ae | 138 | void sigusr1(void) |
eb5d44eb | 139 | { |
d62a17ae | 140 | zlog_debug("SIGUSR1 received"); |
141 | zlog_rotate(); | |
eb5d44eb | 142 | } |
143 | ||
d62a17ae | 144 | struct quagga_signal_t isisd_signals[] = { |
145 | { | |
146 | .signal = SIGHUP, | |
147 | .handler = &sighup, | |
148 | }, | |
149 | { | |
150 | .signal = SIGUSR1, | |
151 | .handler = &sigusr1, | |
152 | }, | |
153 | { | |
154 | .signal = SIGINT, | |
155 | .handler = &sigint, | |
156 | }, | |
157 | { | |
158 | .signal = SIGTERM, | |
159 | .handler = &sigterm, | |
160 | }, | |
2d75d052 | 161 | }; |
eb5d44eb | 162 | |
20bd27e2 | 163 | |
0d8c7a26 | 164 | static const struct frr_yang_module_info *const isisd_yang_modules[] = { |
a4bed468 | 165 | &frr_interface_info, |
20bd27e2 EDP |
166 | #ifndef FABRICD |
167 | &frr_isisd_info, | |
168 | #endif /* ifndef FABRICD */ | |
8fcdd0d6 RW |
169 | }; |
170 | ||
7c0cbd0e CF |
171 | #ifdef FABRICD |
172 | FRR_DAEMON_INFO(fabricd, OPEN_FABRIC, .vty_port = FABRICD_VTY_PORT, | |
173 | ||
174 | .proghelp = "Implementation of the OpenFabric routing protocol.", | |
175 | #else | |
d62a17ae | 176 | FRR_DAEMON_INFO(isisd, ISIS, .vty_port = ISISD_VTY_PORT, |
4f04a76b | 177 | |
d62a17ae | 178 | .proghelp = "Implementation of the IS-IS routing protocol.", |
7c0cbd0e | 179 | #endif |
d62a17ae | 180 | .copyright = |
181 | "Copyright (c) 2001-2002 Sampo Saaristo," | |
182 | " Ofer Wald and Hannes Gredler", | |
4f04a76b | 183 | |
d62a17ae | 184 | .signals = isisd_signals, |
185 | .n_signals = array_size(isisd_signals), | |
4f04a76b | 186 | |
8fcdd0d6 RW |
187 | .privs = &isisd_privs, .yang_modules = isisd_yang_modules, |
188 | .n_yang_modules = array_size(isisd_yang_modules), ) | |
4f04a76b | 189 | |
eb5d44eb | 190 | /* |
191 | * Main routine of isisd. Parse arguments and handle IS-IS state machine. | |
192 | */ | |
d62a17ae | 193 | int main(int argc, char **argv, char **envp) |
eb5d44eb | 194 | { |
d62a17ae | 195 | int opt; |
eb5d44eb | 196 | |
7c0cbd0e CF |
197 | #ifdef FABRICD |
198 | frr_preinit(&fabricd_di, argc, argv); | |
199 | #else | |
d62a17ae | 200 | frr_preinit(&isisd_di, argc, argv); |
7c0cbd0e | 201 | #endif |
d62a17ae | 202 | frr_opt_add("", longopts, ""); |
4f04a76b | 203 | |
d62a17ae | 204 | /* Command line argument treatment. */ |
205 | while (1) { | |
206 | opt = frr_getopt(argc, argv, NULL); | |
f390d2c7 | 207 | |
d62a17ae | 208 | if (opt == EOF) |
209 | break; | |
f390d2c7 | 210 | |
d62a17ae | 211 | switch (opt) { |
212 | case 0: | |
213 | break; | |
214 | default: | |
215 | frr_help_exit(1); | |
216 | break; | |
217 | } | |
f390d2c7 | 218 | } |
d62a17ae | 219 | |
d62a17ae | 220 | /* thread master */ |
221 | master = frr_init(); | |
222 | ||
223 | /* | |
224 | * initializations | |
225 | */ | |
54ece698 | 226 | isis_error_init(); |
d62a17ae | 227 | access_list_init(); |
ecbc5a37 | 228 | vrf_init(NULL, NULL, NULL, NULL, NULL); |
d62a17ae | 229 | prefix_list_init(); |
230 | isis_init(); | |
231 | isis_circuit_init(); | |
f2971ce3 RZ |
232 | #ifdef FABRICD |
233 | isis_vty_daemon_init(); | |
234 | #endif /* FABRICD */ | |
20bd27e2 EDP |
235 | #ifndef FABRICD |
236 | isis_cli_init(); | |
237 | #endif /* ifdef FABRICD */ | |
d62a17ae | 238 | isis_spf_cmds_init(); |
239 | isis_redist_init(); | |
240 | isis_route_map_init(); | |
241 | isis_mpls_te_init(); | |
a5b5e946 | 242 | lsp_init(); |
d56afe53 | 243 | mt_init(); |
d62a17ae | 244 | |
245 | /* create the global 'isis' instance */ | |
260fcb95 | 246 | isis_new(1, VRF_DEFAULT); |
d62a17ae | 247 | |
248 | isis_zebra_init(master); | |
52df8228 | 249 | isis_bfd_init(); |
2cd971af | 250 | fabricd_init(); |
d62a17ae | 251 | |
252 | frr_config_fork(); | |
253 | frr_run(master); | |
254 | ||
255 | /* Not reached. */ | |
256 | exit(0); | |
eb5d44eb | 257 | } |