]>
Commit | Line | Data |
---|---|---|
acddc0ed | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
eb5d44eb | 2 | /* |
3 | * IS-IS Rout(e)ing protocol - isis_main.c | |
4 | * | |
5 | * Copyright (C) 2001,2002 Sampo Saaristo | |
d62a17ae | 6 | * Tampere University of Technology |
eb5d44eb | 7 | * Institute of Communications Engineering |
eb5d44eb | 8 | */ |
9 | ||
eb5d44eb | 10 | #include <zebra.h> |
eb5d44eb | 11 | |
12 | #include "getopt.h" | |
13 | #include "thread.h" | |
14 | #include "log.h" | |
5e4fa164 | 15 | #include <lib/version.h> |
eb5d44eb | 16 | #include "command.h" |
17 | #include "vty.h" | |
18 | #include "memory.h" | |
19 | #include "stream.h" | |
20 | #include "if.h" | |
9e867fe6 | 21 | #include "privs.h" |
2d75d052 | 22 | #include "sigevent.h" |
c729c650 | 23 | #include "filter.h" |
f3ccedaa | 24 | #include "plist.h" |
48d8bea8 | 25 | #include "zclient.h" |
6a69b354 | 26 | #include "vrf.h" |
676a4ea3 | 27 | #include "qobj.h" |
4f04a76b | 28 | #include "libfrr.h" |
91835f1f | 29 | #include "routemap.h" |
8300f2f5 | 30 | #include "affinitymap.h" |
eb5d44eb | 31 | |
eb5d44eb | 32 | #include "isisd/isis_constants.h" |
33 | #include "isisd/isis_common.h" | |
34 | #include "isisd/isis_flags.h" | |
35 | #include "isisd/isis_circuit.h" | |
36 | #include "isisd/isisd.h" | |
37 | #include "isisd/isis_dynhn.h" | |
3f045a08 JB |
38 | #include "isisd/isis_spf.h" |
39 | #include "isisd/isis_route.h" | |
f3ccedaa | 40 | #include "isisd/isis_routemap.h" |
3f045a08 | 41 | #include "isisd/isis_zebra.h" |
f8c06e2c | 42 | #include "isisd/isis_te.h" |
54ece698 | 43 | #include "isisd/isis_errors.h" |
52df8228 | 44 | #include "isisd/isis_bfd.h" |
a5b5e946 | 45 | #include "isisd/isis_lsp.h" |
d56afe53 | 46 | #include "isisd/isis_mt.h" |
2cd971af | 47 | #include "isisd/fabricd.h" |
2a1c520e | 48 | #include "isisd/isis_nb.h" |
1cbf96a8 | 49 | #include "isisd/isis_ldp_sync.h" |
eb5d44eb | 50 | |
51 | /* Default configuration file name */ | |
52 | #define ISISD_DEFAULT_CONFIG "isisd.conf" | |
53 | /* Default vty port */ | |
fc58e874 | 54 | #define ISISD_VTY_PORT 2608 |
7c0cbd0e | 55 | #define FABRICD_VTY_PORT 2618 |
eb5d44eb | 56 | |
9e867fe6 | 57 | /* isisd privileges */ |
caa18d49 | 58 | zebra_capabilities_t _caps_p[] = {ZCAP_NET_RAW, ZCAP_BIND, ZCAP_SYS_ADMIN}; |
9e867fe6 | 59 | |
f390d2c7 | 60 | struct zebra_privs_t isisd_privs = { |
b2f36157 | 61 | #if defined(FRR_USER) |
d62a17ae | 62 | .user = FRR_USER, |
9e867fe6 | 63 | #endif |
b2f36157 | 64 | #if defined FRR_GROUP |
d62a17ae | 65 | .group = FRR_GROUP, |
9e867fe6 | 66 | #endif |
67 | #ifdef VTY_GROUP | |
d62a17ae | 68 | .vty_group = VTY_GROUP, |
9e867fe6 | 69 | #endif |
d62a17ae | 70 | .caps_p = _caps_p, |
97b5d752 | 71 | .cap_num_p = array_size(_caps_p), |
d62a17ae | 72 | .cap_num_i = 0}; |
9e867fe6 | 73 | |
eb5d44eb | 74 | /* isisd options */ |
26f6acaf RW |
75 | static const struct option longopts[] = { |
76 | {"int_num", required_argument, NULL, 'I'}, | |
77 | {0}}; | |
eb5d44eb | 78 | |
eb5d44eb | 79 | /* Master of threads. */ |
80 | struct thread_master *master; | |
81 | ||
41b36e90 PJ |
82 | /* |
83 | * Prototypes. | |
84 | */ | |
41b36e90 PJ |
85 | void sighup(void); |
86 | void sigint(void); | |
87 | void sigterm(void); | |
88 | void sigusr1(void); | |
89 | ||
90 | ||
d62a17ae | 91 | static __attribute__((__noreturn__)) void terminate(int i) |
eb5d44eb | 92 | { |
eab88f36 | 93 | isis_terminate(); |
26f6acaf | 94 | isis_sr_term(); |
d62a17ae | 95 | isis_zebra_stop(); |
96 | exit(i); | |
eb5d44eb | 97 | } |
98 | ||
99 | /* | |
100 | * Signal handlers | |
101 | */ | |
98cbd0f2 | 102 | #ifdef FABRICD |
d62a17ae | 103 | void sighup(void) |
eb5d44eb | 104 | { |
98cbd0f2 | 105 | zlog_notice("SIGHUP/reload is not implemented for fabricd"); |
d62a17ae | 106 | return; |
eb5d44eb | 107 | } |
98cbd0f2 EDP |
108 | #else |
109 | static struct frr_daemon_info isisd_di; | |
110 | void sighup(void) | |
111 | { | |
112 | zlog_info("SIGHUP received"); | |
113 | ||
114 | /* Reload config file. */ | |
115 | vty_read_config(NULL, isisd_di.config_file, config_default); | |
116 | } | |
117 | ||
118 | #endif | |
eb5d44eb | 119 | |
d62a17ae | 120 | __attribute__((__noreturn__)) void sigint(void) |
eb5d44eb | 121 | { |
d62a17ae | 122 | zlog_notice("Terminating on signal SIGINT"); |
123 | terminate(0); | |
eb5d44eb | 124 | } |
125 | ||
d62a17ae | 126 | __attribute__((__noreturn__)) void sigterm(void) |
eb5d44eb | 127 | { |
d62a17ae | 128 | zlog_notice("Terminating on signal SIGTERM"); |
129 | terminate(0); | |
eb5d44eb | 130 | } |
131 | ||
d62a17ae | 132 | void sigusr1(void) |
eb5d44eb | 133 | { |
d62a17ae | 134 | zlog_debug("SIGUSR1 received"); |
135 | zlog_rotate(); | |
eb5d44eb | 136 | } |
137 | ||
7cc91e67 | 138 | struct frr_signal_t isisd_signals[] = { |
d62a17ae | 139 | { |
140 | .signal = SIGHUP, | |
141 | .handler = &sighup, | |
142 | }, | |
143 | { | |
144 | .signal = SIGUSR1, | |
145 | .handler = &sigusr1, | |
146 | }, | |
147 | { | |
148 | .signal = SIGINT, | |
149 | .handler = &sigint, | |
150 | }, | |
151 | { | |
152 | .signal = SIGTERM, | |
153 | .handler = &sigterm, | |
154 | }, | |
2d75d052 | 155 | }; |
eb5d44eb | 156 | |
20bd27e2 | 157 | |
8300f2f5 | 158 | /* clang-format off */ |
0d8c7a26 | 159 | static const struct frr_yang_module_info *const isisd_yang_modules[] = { |
c2aab693 | 160 | &frr_filter_info, |
a4bed468 | 161 | &frr_interface_info, |
20bd27e2 EDP |
162 | #ifndef FABRICD |
163 | &frr_isisd_info, | |
164 | #endif /* ifndef FABRICD */ | |
91835f1f | 165 | &frr_route_map_info, |
8300f2f5 | 166 | &frr_affinity_map_info, |
6fd8972a | 167 | &frr_vrf_info, |
8fcdd0d6 | 168 | }; |
8300f2f5 | 169 | /* clang-format on */ |
8fcdd0d6 | 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 = |
3efd0893 | 181 | "Copyright (c) 2001-2002 Sampo Saaristo, Ofer Wald and Hannes Gredler", |
4f04a76b | 182 | |
d62a17ae | 183 | .signals = isisd_signals, |
184 | .n_signals = array_size(isisd_signals), | |
4f04a76b | 185 | |
8fcdd0d6 | 186 | .privs = &isisd_privs, .yang_modules = isisd_yang_modules, |
80413c20 DL |
187 | .n_yang_modules = array_size(isisd_yang_modules), |
188 | ); | |
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; |
26f6acaf | 196 | int instance = 1; |
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 |
26f6acaf RW |
203 | frr_opt_add( |
204 | "I:", longopts, | |
205 | " -I, --int_num Set instance number (label-manager)\n"); | |
4f04a76b | 206 | |
d62a17ae | 207 | /* Command line argument treatment. */ |
208 | while (1) { | |
209 | opt = frr_getopt(argc, argv, NULL); | |
f390d2c7 | 210 | |
d62a17ae | 211 | if (opt == EOF) |
212 | break; | |
f390d2c7 | 213 | |
d62a17ae | 214 | switch (opt) { |
215 | case 0: | |
216 | break; | |
26f6acaf RW |
217 | case 'I': |
218 | instance = atoi(optarg); | |
219 | if (instance < 1 || instance > (unsigned short)-1) | |
220 | zlog_err("Instance %i out of range (1..%u)", | |
221 | instance, (unsigned short)-1); | |
222 | break; | |
d62a17ae | 223 | default: |
224 | frr_help_exit(1); | |
d62a17ae | 225 | } |
f390d2c7 | 226 | } |
d62a17ae | 227 | |
d62a17ae | 228 | /* thread master */ |
eab88f36 K |
229 | isis_master_init(frr_init()); |
230 | master = im->master; | |
d62a17ae | 231 | /* |
232 | * initializations | |
233 | */ | |
54ece698 | 234 | isis_error_init(); |
d62a17ae | 235 | access_list_init(); |
e886416f RW |
236 | access_list_add_hook(isis_filter_update); |
237 | access_list_delete_hook(isis_filter_update); | |
65251ce8 | 238 | isis_vrf_init(); |
d62a17ae | 239 | prefix_list_init(); |
16fe8cff RW |
240 | prefix_list_add_hook(isis_prefix_list_update); |
241 | prefix_list_delete_hook(isis_prefix_list_update); | |
d62a17ae | 242 | isis_init(); |
243 | isis_circuit_init(); | |
f2971ce3 RZ |
244 | #ifdef FABRICD |
245 | isis_vty_daemon_init(); | |
246 | #endif /* FABRICD */ | |
20bd27e2 EDP |
247 | #ifndef FABRICD |
248 | isis_cli_init(); | |
249 | #endif /* ifdef FABRICD */ | |
56ea2b21 | 250 | isis_spf_init(); |
d62a17ae | 251 | isis_redist_init(); |
252 | isis_route_map_init(); | |
253 | isis_mpls_te_init(); | |
26f6acaf | 254 | isis_sr_init(); |
a5b5e946 | 255 | lsp_init(); |
d56afe53 | 256 | mt_init(); |
d62a17ae | 257 | |
8300f2f5 LS |
258 | affinity_map_init(); |
259 | ||
26f6acaf | 260 | isis_zebra_init(master, instance); |
13bf3830 | 261 | isis_bfd_init(master); |
1cbf96a8 | 262 | isis_ldp_sync_init(); |
2cd971af | 263 | fabricd_init(); |
d62a17ae | 264 | |
265 | frr_config_fork(); | |
266 | frr_run(master); | |
267 | ||
268 | /* Not reached. */ | |
269 | exit(0); | |
eb5d44eb | 270 | } |