]>
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" |
91835f1f | 42 | #include "routemap.h" |
eb5d44eb | 43 | |
eb5d44eb | 44 | #include "isisd/isis_constants.h" |
45 | #include "isisd/isis_common.h" | |
46 | #include "isisd/isis_flags.h" | |
47 | #include "isisd/isis_circuit.h" | |
48 | #include "isisd/isisd.h" | |
49 | #include "isisd/isis_dynhn.h" | |
3f045a08 JB |
50 | #include "isisd/isis_spf.h" |
51 | #include "isisd/isis_route.h" | |
f3ccedaa | 52 | #include "isisd/isis_routemap.h" |
3f045a08 | 53 | #include "isisd/isis_zebra.h" |
f8c06e2c | 54 | #include "isisd/isis_te.h" |
54ece698 | 55 | #include "isisd/isis_errors.h" |
52df8228 | 56 | #include "isisd/isis_bfd.h" |
a5b5e946 | 57 | #include "isisd/isis_lsp.h" |
d56afe53 | 58 | #include "isisd/isis_mt.h" |
2cd971af | 59 | #include "isisd/fabricd.h" |
2a1c520e | 60 | #include "isisd/isis_nb.h" |
eb5d44eb | 61 | |
62 | /* Default configuration file name */ | |
63 | #define ISISD_DEFAULT_CONFIG "isisd.conf" | |
64 | /* Default vty port */ | |
fc58e874 | 65 | #define ISISD_VTY_PORT 2608 |
7c0cbd0e | 66 | #define FABRICD_VTY_PORT 2618 |
eb5d44eb | 67 | |
9e867fe6 | 68 | /* isisd privileges */ |
caa18d49 | 69 | zebra_capabilities_t _caps_p[] = {ZCAP_NET_RAW, ZCAP_BIND, ZCAP_SYS_ADMIN}; |
9e867fe6 | 70 | |
f390d2c7 | 71 | struct zebra_privs_t isisd_privs = { |
b2f36157 | 72 | #if defined(FRR_USER) |
d62a17ae | 73 | .user = FRR_USER, |
9e867fe6 | 74 | #endif |
b2f36157 | 75 | #if defined FRR_GROUP |
d62a17ae | 76 | .group = FRR_GROUP, |
9e867fe6 | 77 | #endif |
78 | #ifdef VTY_GROUP | |
d62a17ae | 79 | .vty_group = VTY_GROUP, |
9e867fe6 | 80 | #endif |
d62a17ae | 81 | .caps_p = _caps_p, |
97b5d752 | 82 | .cap_num_p = array_size(_caps_p), |
d62a17ae | 83 | .cap_num_i = 0}; |
9e867fe6 | 84 | |
eb5d44eb | 85 | /* isisd options */ |
26f6acaf RW |
86 | static const struct option longopts[] = { |
87 | {"int_num", required_argument, NULL, 'I'}, | |
88 | {0}}; | |
eb5d44eb | 89 | |
eb5d44eb | 90 | /* Master of threads. */ |
91 | struct thread_master *master; | |
92 | ||
41b36e90 PJ |
93 | /* |
94 | * Prototypes. | |
95 | */ | |
41b36e90 PJ |
96 | void sighup(void); |
97 | void sigint(void); | |
98 | void sigterm(void); | |
99 | void sigusr1(void); | |
100 | ||
101 | ||
d62a17ae | 102 | static __attribute__((__noreturn__)) void terminate(int i) |
eb5d44eb | 103 | { |
26f6acaf | 104 | isis_sr_term(); |
d62a17ae | 105 | isis_zebra_stop(); |
106 | exit(i); | |
eb5d44eb | 107 | } |
108 | ||
109 | /* | |
110 | * Signal handlers | |
111 | */ | |
98cbd0f2 | 112 | #ifdef FABRICD |
d62a17ae | 113 | void sighup(void) |
eb5d44eb | 114 | { |
98cbd0f2 | 115 | zlog_notice("SIGHUP/reload is not implemented for fabricd"); |
d62a17ae | 116 | return; |
eb5d44eb | 117 | } |
98cbd0f2 EDP |
118 | #else |
119 | static struct frr_daemon_info isisd_di; | |
120 | void sighup(void) | |
121 | { | |
122 | zlog_info("SIGHUP received"); | |
123 | ||
124 | /* Reload config file. */ | |
125 | vty_read_config(NULL, isisd_di.config_file, config_default); | |
126 | } | |
127 | ||
128 | #endif | |
eb5d44eb | 129 | |
d62a17ae | 130 | __attribute__((__noreturn__)) void sigint(void) |
eb5d44eb | 131 | { |
d62a17ae | 132 | zlog_notice("Terminating on signal SIGINT"); |
133 | terminate(0); | |
eb5d44eb | 134 | } |
135 | ||
d62a17ae | 136 | __attribute__((__noreturn__)) void sigterm(void) |
eb5d44eb | 137 | { |
d62a17ae | 138 | zlog_notice("Terminating on signal SIGTERM"); |
139 | terminate(0); | |
eb5d44eb | 140 | } |
141 | ||
d62a17ae | 142 | void sigusr1(void) |
eb5d44eb | 143 | { |
d62a17ae | 144 | zlog_debug("SIGUSR1 received"); |
145 | zlog_rotate(); | |
eb5d44eb | 146 | } |
147 | ||
d62a17ae | 148 | struct quagga_signal_t isisd_signals[] = { |
149 | { | |
150 | .signal = SIGHUP, | |
151 | .handler = &sighup, | |
152 | }, | |
153 | { | |
154 | .signal = SIGUSR1, | |
155 | .handler = &sigusr1, | |
156 | }, | |
157 | { | |
158 | .signal = SIGINT, | |
159 | .handler = &sigint, | |
160 | }, | |
161 | { | |
162 | .signal = SIGTERM, | |
163 | .handler = &sigterm, | |
164 | }, | |
2d75d052 | 165 | }; |
eb5d44eb | 166 | |
20bd27e2 | 167 | |
0d8c7a26 | 168 | static const struct frr_yang_module_info *const isisd_yang_modules[] = { |
c2aab693 | 169 | &frr_filter_info, |
a4bed468 | 170 | &frr_interface_info, |
20bd27e2 EDP |
171 | #ifndef FABRICD |
172 | &frr_isisd_info, | |
173 | #endif /* ifndef FABRICD */ | |
91835f1f | 174 | &frr_route_map_info, |
6fd8972a | 175 | &frr_vrf_info, |
8fcdd0d6 RW |
176 | }; |
177 | ||
7c0cbd0e CF |
178 | #ifdef FABRICD |
179 | FRR_DAEMON_INFO(fabricd, OPEN_FABRIC, .vty_port = FABRICD_VTY_PORT, | |
180 | ||
181 | .proghelp = "Implementation of the OpenFabric routing protocol.", | |
182 | #else | |
d62a17ae | 183 | FRR_DAEMON_INFO(isisd, ISIS, .vty_port = ISISD_VTY_PORT, |
4f04a76b | 184 | |
d62a17ae | 185 | .proghelp = "Implementation of the IS-IS routing protocol.", |
7c0cbd0e | 186 | #endif |
d62a17ae | 187 | .copyright = |
188 | "Copyright (c) 2001-2002 Sampo Saaristo," | |
189 | " Ofer Wald and Hannes Gredler", | |
4f04a76b | 190 | |
d62a17ae | 191 | .signals = isisd_signals, |
192 | .n_signals = array_size(isisd_signals), | |
4f04a76b | 193 | |
8fcdd0d6 RW |
194 | .privs = &isisd_privs, .yang_modules = isisd_yang_modules, |
195 | .n_yang_modules = array_size(isisd_yang_modules), ) | |
4f04a76b | 196 | |
eb5d44eb | 197 | /* |
198 | * Main routine of isisd. Parse arguments and handle IS-IS state machine. | |
199 | */ | |
d62a17ae | 200 | int main(int argc, char **argv, char **envp) |
eb5d44eb | 201 | { |
d62a17ae | 202 | int opt; |
26f6acaf | 203 | int instance = 1; |
eb5d44eb | 204 | |
7c0cbd0e CF |
205 | #ifdef FABRICD |
206 | frr_preinit(&fabricd_di, argc, argv); | |
207 | #else | |
d62a17ae | 208 | frr_preinit(&isisd_di, argc, argv); |
7c0cbd0e | 209 | #endif |
26f6acaf RW |
210 | frr_opt_add( |
211 | "I:", longopts, | |
212 | " -I, --int_num Set instance number (label-manager)\n"); | |
4f04a76b | 213 | |
d62a17ae | 214 | /* Command line argument treatment. */ |
215 | while (1) { | |
216 | opt = frr_getopt(argc, argv, NULL); | |
f390d2c7 | 217 | |
d62a17ae | 218 | if (opt == EOF) |
219 | break; | |
f390d2c7 | 220 | |
d62a17ae | 221 | switch (opt) { |
222 | case 0: | |
223 | break; | |
26f6acaf RW |
224 | case 'I': |
225 | instance = atoi(optarg); | |
226 | if (instance < 1 || instance > (unsigned short)-1) | |
227 | zlog_err("Instance %i out of range (1..%u)", | |
228 | instance, (unsigned short)-1); | |
229 | break; | |
d62a17ae | 230 | default: |
231 | frr_help_exit(1); | |
232 | break; | |
233 | } | |
f390d2c7 | 234 | } |
d62a17ae | 235 | |
d62a17ae | 236 | /* thread master */ |
237 | master = frr_init(); | |
238 | ||
239 | /* | |
240 | * initializations | |
241 | */ | |
54ece698 | 242 | isis_error_init(); |
d62a17ae | 243 | access_list_init(); |
ecbc5a37 | 244 | vrf_init(NULL, NULL, NULL, NULL, NULL); |
d62a17ae | 245 | prefix_list_init(); |
246 | isis_init(); | |
247 | isis_circuit_init(); | |
f2971ce3 RZ |
248 | #ifdef FABRICD |
249 | isis_vty_daemon_init(); | |
250 | #endif /* FABRICD */ | |
20bd27e2 EDP |
251 | #ifndef FABRICD |
252 | isis_cli_init(); | |
253 | #endif /* ifdef FABRICD */ | |
d62a17ae | 254 | isis_spf_cmds_init(); |
255 | isis_redist_init(); | |
256 | isis_route_map_init(); | |
257 | isis_mpls_te_init(); | |
26f6acaf | 258 | isis_sr_init(); |
a5b5e946 | 259 | lsp_init(); |
d56afe53 | 260 | mt_init(); |
d62a17ae | 261 | |
262 | /* create the global 'isis' instance */ | |
260fcb95 | 263 | isis_new(1, VRF_DEFAULT); |
d62a17ae | 264 | |
26f6acaf | 265 | isis_zebra_init(master, instance); |
52df8228 | 266 | isis_bfd_init(); |
2cd971af | 267 | fabricd_init(); |
d62a17ae | 268 | |
269 | frr_config_fork(); | |
270 | frr_run(master); | |
271 | ||
272 | /* Not reached. */ | |
273 | exit(0); | |
eb5d44eb | 274 | } |