]> git.proxmox.com Git - mirror_frr.git/blame - isisd/isis_main.c
ospfd: ldp-igp-sync feature: adding ospf support
[mirror_frr.git] / isisd / isis_main.c
CommitLineData
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 69zebra_capabilities_t _caps_p[] = {ZCAP_NET_RAW, ZCAP_BIND, ZCAP_SYS_ADMIN};
9e867fe6 70
f390d2c7 71struct 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
86static const struct option longopts[] = {
87 {"int_num", required_argument, NULL, 'I'},
88 {0}};
eb5d44eb 89
eb5d44eb 90/* Master of threads. */
91struct thread_master *master;
92
41b36e90
PJ
93/*
94 * Prototypes.
95 */
41b36e90
PJ
96void sighup(void);
97void sigint(void);
98void sigterm(void);
99void sigusr1(void);
100
101
d62a17ae 102static __attribute__((__noreturn__)) void terminate(int i)
eb5d44eb 103{
eab88f36 104 isis_terminate();
26f6acaf 105 isis_sr_term();
d62a17ae 106 isis_zebra_stop();
107 exit(i);
eb5d44eb 108}
109
110/*
111 * Signal handlers
112 */
98cbd0f2 113#ifdef FABRICD
d62a17ae 114void sighup(void)
eb5d44eb 115{
98cbd0f2 116 zlog_notice("SIGHUP/reload is not implemented for fabricd");
d62a17ae 117 return;
eb5d44eb 118}
98cbd0f2
EDP
119#else
120static struct frr_daemon_info isisd_di;
121void sighup(void)
122{
123 zlog_info("SIGHUP received");
124
125 /* Reload config file. */
126 vty_read_config(NULL, isisd_di.config_file, config_default);
127}
128
129#endif
eb5d44eb 130
d62a17ae 131__attribute__((__noreturn__)) void sigint(void)
eb5d44eb 132{
d62a17ae 133 zlog_notice("Terminating on signal SIGINT");
134 terminate(0);
eb5d44eb 135}
136
d62a17ae 137__attribute__((__noreturn__)) void sigterm(void)
eb5d44eb 138{
d62a17ae 139 zlog_notice("Terminating on signal SIGTERM");
140 terminate(0);
eb5d44eb 141}
142
d62a17ae 143void sigusr1(void)
eb5d44eb 144{
d62a17ae 145 zlog_debug("SIGUSR1 received");
146 zlog_rotate();
eb5d44eb 147}
148
d62a17ae 149struct quagga_signal_t isisd_signals[] = {
150 {
151 .signal = SIGHUP,
152 .handler = &sighup,
153 },
154 {
155 .signal = SIGUSR1,
156 .handler = &sigusr1,
157 },
158 {
159 .signal = SIGINT,
160 .handler = &sigint,
161 },
162 {
163 .signal = SIGTERM,
164 .handler = &sigterm,
165 },
2d75d052 166};
eb5d44eb 167
20bd27e2 168
0d8c7a26 169static const struct frr_yang_module_info *const isisd_yang_modules[] = {
c2aab693 170 &frr_filter_info,
a4bed468 171 &frr_interface_info,
20bd27e2
EDP
172#ifndef FABRICD
173 &frr_isisd_info,
174#endif /* ifndef FABRICD */
91835f1f 175 &frr_route_map_info,
6fd8972a 176 &frr_vrf_info,
8fcdd0d6
RW
177};
178
7c0cbd0e
CF
179#ifdef FABRICD
180FRR_DAEMON_INFO(fabricd, OPEN_FABRIC, .vty_port = FABRICD_VTY_PORT,
181
182 .proghelp = "Implementation of the OpenFabric routing protocol.",
183#else
d62a17ae 184FRR_DAEMON_INFO(isisd, ISIS, .vty_port = ISISD_VTY_PORT,
4f04a76b 185
d62a17ae 186 .proghelp = "Implementation of the IS-IS routing protocol.",
7c0cbd0e 187#endif
d62a17ae 188 .copyright =
3efd0893 189 "Copyright (c) 2001-2002 Sampo Saaristo, 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 200int 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 */
eab88f36
K
237 isis_master_init(frr_init());
238 master = im->master;
d62a17ae 239
240 /*
241 * initializations
242 */
54ece698 243 isis_error_init();
d62a17ae 244 access_list_init();
ecbc5a37 245 vrf_init(NULL, NULL, NULL, NULL, NULL);
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 */
d62a17ae 255 isis_spf_cmds_init();
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 */
eab88f36 264 isis_global_instance_create();
d62a17ae 265
26f6acaf 266 isis_zebra_init(master, instance);
52df8228 267 isis_bfd_init();
2cd971af 268 fabricd_init();
d62a17ae 269
270 frr_config_fork();
271 frr_run(master);
272
273 /* Not reached. */
274 exit(0);
eb5d44eb 275}