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