]>
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" | |
fc7948fa | 32 | #include "memory_vty.h" |
eb5d44eb | 33 | #include "stream.h" |
34 | #include "if.h" | |
9e867fe6 | 35 | #include "privs.h" |
2d75d052 | 36 | #include "sigevent.h" |
c729c650 | 37 | #include "filter.h" |
f3ccedaa | 38 | #include "plist.h" |
48d8bea8 | 39 | #include "zclient.h" |
6a69b354 | 40 | #include "vrf.h" |
676a4ea3 | 41 | #include "qobj.h" |
4f04a76b | 42 | #include "libfrr.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 */ |
d62a17ae | 69 | zebra_capabilities_t _caps_p[] = {ZCAP_NET_RAW, ZCAP_BIND}; |
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 */ |
d62a17ae | 86 | struct option longopts[] = {{0}}; |
eb5d44eb | 87 | |
eb5d44eb | 88 | /* Master of threads. */ |
89 | struct thread_master *master; | |
90 | ||
41b36e90 PJ |
91 | /* |
92 | * Prototypes. | |
93 | */ | |
41b36e90 PJ |
94 | void sighup(void); |
95 | void sigint(void); | |
96 | void sigterm(void); | |
97 | void sigusr1(void); | |
98 | ||
99 | ||
d62a17ae | 100 | static __attribute__((__noreturn__)) void terminate(int i) |
eb5d44eb | 101 | { |
d62a17ae | 102 | isis_zebra_stop(); |
103 | exit(i); | |
eb5d44eb | 104 | } |
105 | ||
106 | /* | |
107 | * Signal handlers | |
108 | */ | |
98cbd0f2 | 109 | #ifdef FABRICD |
d62a17ae | 110 | void sighup(void) |
eb5d44eb | 111 | { |
98cbd0f2 | 112 | zlog_notice("SIGHUP/reload is not implemented for fabricd"); |
d62a17ae | 113 | return; |
eb5d44eb | 114 | } |
98cbd0f2 EDP |
115 | #else |
116 | static struct frr_daemon_info isisd_di; | |
117 | void sighup(void) | |
118 | { | |
119 | zlog_info("SIGHUP received"); | |
120 | ||
121 | /* Reload config file. */ | |
122 | vty_read_config(NULL, isisd_di.config_file, config_default); | |
123 | } | |
124 | ||
125 | #endif | |
eb5d44eb | 126 | |
d62a17ae | 127 | __attribute__((__noreturn__)) void sigint(void) |
eb5d44eb | 128 | { |
d62a17ae | 129 | zlog_notice("Terminating on signal SIGINT"); |
130 | terminate(0); | |
eb5d44eb | 131 | } |
132 | ||
d62a17ae | 133 | __attribute__((__noreturn__)) void sigterm(void) |
eb5d44eb | 134 | { |
d62a17ae | 135 | zlog_notice("Terminating on signal SIGTERM"); |
136 | terminate(0); | |
eb5d44eb | 137 | } |
138 | ||
d62a17ae | 139 | void sigusr1(void) |
eb5d44eb | 140 | { |
d62a17ae | 141 | zlog_debug("SIGUSR1 received"); |
142 | zlog_rotate(); | |
eb5d44eb | 143 | } |
144 | ||
d62a17ae | 145 | struct quagga_signal_t isisd_signals[] = { |
146 | { | |
147 | .signal = SIGHUP, | |
148 | .handler = &sighup, | |
149 | }, | |
150 | { | |
151 | .signal = SIGUSR1, | |
152 | .handler = &sigusr1, | |
153 | }, | |
154 | { | |
155 | .signal = SIGINT, | |
156 | .handler = &sigint, | |
157 | }, | |
158 | { | |
159 | .signal = SIGTERM, | |
160 | .handler = &sigterm, | |
161 | }, | |
2d75d052 | 162 | }; |
eb5d44eb | 163 | |
20bd27e2 | 164 | |
0d8c7a26 | 165 | static const struct frr_yang_module_info *const isisd_yang_modules[] = { |
a4bed468 | 166 | &frr_interface_info, |
20bd27e2 EDP |
167 | #ifndef FABRICD |
168 | &frr_isisd_info, | |
169 | #endif /* ifndef FABRICD */ | |
8fcdd0d6 RW |
170 | }; |
171 | ||
7c0cbd0e CF |
172 | #ifdef FABRICD |
173 | FRR_DAEMON_INFO(fabricd, OPEN_FABRIC, .vty_port = FABRICD_VTY_PORT, | |
174 | ||
175 | .proghelp = "Implementation of the OpenFabric routing protocol.", | |
176 | #else | |
d62a17ae | 177 | FRR_DAEMON_INFO(isisd, ISIS, .vty_port = ISISD_VTY_PORT, |
4f04a76b | 178 | |
d62a17ae | 179 | .proghelp = "Implementation of the IS-IS routing protocol.", |
7c0cbd0e | 180 | #endif |
d62a17ae | 181 | .copyright = |
182 | "Copyright (c) 2001-2002 Sampo Saaristo," | |
183 | " Ofer Wald and Hannes Gredler", | |
4f04a76b | 184 | |
d62a17ae | 185 | .signals = isisd_signals, |
186 | .n_signals = array_size(isisd_signals), | |
4f04a76b | 187 | |
8fcdd0d6 RW |
188 | .privs = &isisd_privs, .yang_modules = isisd_yang_modules, |
189 | .n_yang_modules = array_size(isisd_yang_modules), ) | |
4f04a76b | 190 | |
eb5d44eb | 191 | /* |
192 | * Main routine of isisd. Parse arguments and handle IS-IS state machine. | |
193 | */ | |
d62a17ae | 194 | int main(int argc, char **argv, char **envp) |
eb5d44eb | 195 | { |
d62a17ae | 196 | int opt; |
eb5d44eb | 197 | |
7c0cbd0e CF |
198 | #ifdef FABRICD |
199 | frr_preinit(&fabricd_di, argc, argv); | |
200 | #else | |
d62a17ae | 201 | frr_preinit(&isisd_di, argc, argv); |
7c0cbd0e | 202 | #endif |
d62a17ae | 203 | frr_opt_add("", longopts, ""); |
4f04a76b | 204 | |
d62a17ae | 205 | /* Command line argument treatment. */ |
206 | while (1) { | |
207 | opt = frr_getopt(argc, argv, NULL); | |
f390d2c7 | 208 | |
d62a17ae | 209 | if (opt == EOF) |
210 | break; | |
f390d2c7 | 211 | |
d62a17ae | 212 | switch (opt) { |
213 | case 0: | |
214 | break; | |
215 | default: | |
216 | frr_help_exit(1); | |
217 | break; | |
218 | } | |
f390d2c7 | 219 | } |
d62a17ae | 220 | |
d62a17ae | 221 | /* thread master */ |
222 | master = frr_init(); | |
223 | ||
224 | /* | |
225 | * initializations | |
226 | */ | |
54ece698 | 227 | isis_error_init(); |
d62a17ae | 228 | access_list_init(); |
ecbc5a37 | 229 | vrf_init(NULL, NULL, NULL, NULL, NULL); |
d62a17ae | 230 | prefix_list_init(); |
231 | isis_init(); | |
232 | isis_circuit_init(); | |
f2971ce3 RZ |
233 | #ifdef FABRICD |
234 | isis_vty_daemon_init(); | |
235 | #endif /* FABRICD */ | |
20bd27e2 EDP |
236 | #ifndef FABRICD |
237 | isis_cli_init(); | |
238 | #endif /* ifdef FABRICD */ | |
d62a17ae | 239 | isis_spf_cmds_init(); |
240 | isis_redist_init(); | |
241 | isis_route_map_init(); | |
242 | isis_mpls_te_init(); | |
a5b5e946 | 243 | lsp_init(); |
d56afe53 | 244 | mt_init(); |
d62a17ae | 245 | |
246 | /* create the global 'isis' instance */ | |
260fcb95 | 247 | isis_new(1, VRF_DEFAULT); |
d62a17ae | 248 | |
249 | isis_zebra_init(master); | |
52df8228 | 250 | isis_bfd_init(); |
2cd971af | 251 | fabricd_init(); |
d62a17ae | 252 | |
253 | frr_config_fork(); | |
254 | frr_run(master); | |
255 | ||
256 | /* Not reached. */ | |
257 | exit(0); | |
eb5d44eb | 258 | } |