]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isisd.h
Merge pull request #12819 from isabelladeleon12/isis_load_config_before_lsp_gen
[mirror_frr.git] / isisd / isisd.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * IS-IS Rout(e)ing protocol - isisd.h
4 *
5 * Copyright (C) 2001,2002 Sampo Saaristo
6 * Tampere University of Technology
7 * Institute of Communications Engineering
8 */
9
10 #ifndef ISISD_H
11 #define ISISD_H
12
13 #include "vty.h"
14 #include "memory.h"
15
16 #include "isisd/isis_constants.h"
17 #include "isisd/isis_common.h"
18 #include "isisd/isis_redist.h"
19 #include "isisd/isis_pdu_counter.h"
20 #include "isisd/isis_circuit.h"
21 #include "isisd/isis_sr.h"
22 #include "isis_flags.h"
23 #include "isis_lsp.h"
24 #include "isis_lfa.h"
25 #include "qobj.h"
26 #include "ldp_sync.h"
27
28 DECLARE_MGROUP(ISISD);
29
30 #ifdef FABRICD
31 static const bool fabricd = true;
32 #define PROTO_TYPE ZEBRA_ROUTE_OPENFABRIC
33 #define PROTO_NAME "openfabric"
34 #define PROTO_HELP "OpenFabric routing protocol\n"
35 #define PROTO_REDIST_STR FRR_REDIST_STR_FABRICD
36 #define PROTO_IP_REDIST_STR FRR_IP_REDIST_STR_FABRICD
37 #define PROTO_IP6_REDIST_STR FRR_IP6_REDIST_STR_FABRICD
38 #define PROTO_REDIST_HELP FRR_REDIST_HELP_STR_FABRICD
39 #define PROTO_IP_REDIST_HELP FRR_IP_REDIST_HELP_STR_FABRICD
40 #define PROTO_IP6_REDIST_HELP FRR_IP6_REDIST_HELP_STR_FABRICD
41 #define ROUTER_NODE OPENFABRIC_NODE
42 #else
43 static const bool fabricd = false;
44 #define PROTO_TYPE ZEBRA_ROUTE_ISIS
45 #define PROTO_NAME "isis"
46 #define PROTO_HELP "IS-IS routing protocol\n"
47 #define PROTO_REDIST_STR FRR_REDIST_STR_ISISD
48 #define PROTO_IP_REDIST_STR FRR_IP_REDIST_STR_ISISD
49 #define PROTO_IP6_REDIST_STR FRR_IP6_REDIST_STR_ISISD
50 #define PROTO_REDIST_HELP FRR_REDIST_HELP_STR_ISISD
51 #define PROTO_IP_REDIST_HELP FRR_IP_REDIST_HELP_STR_ISISD
52 #define PROTO_IP6_REDIST_HELP FRR_IP6_REDIST_HELP_STR_ISISD
53 #define ROUTER_NODE ISIS_NODE
54 extern void isis_cli_init(void);
55 #endif
56
57 #define ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf) \
58 if (argv_find(argv, argc, "vrf", &idx_vrf)) { \
59 vrf_name = argv[idx_vrf + 1]->arg; \
60 all_vrf = strmatch(vrf_name, "all"); \
61 }
62
63 extern struct zebra_privs_t isisd_privs;
64
65 /* uncomment if you are a developer in bug hunt */
66 /* #define EXTREME_DEBUG */
67
68 struct fabricd;
69
70 struct isis_master {
71 /* ISIS instance. */
72 struct list *isis;
73 /* ISIS thread master. */
74 struct thread_master *master;
75 uint8_t options;
76 };
77 #define F_ISIS_UNIT_TEST 0x01
78
79 #define ISIS_DEFAULT_MAX_AREA_ADDRESSES 3
80
81 struct isis {
82 vrf_id_t vrf_id;
83 char *name;
84 unsigned long process_id;
85 int sysid_set;
86 uint8_t sysid[ISIS_SYS_ID_LEN]; /* SystemID for this IS */
87 uint32_t router_id; /* Router ID from zebra */
88 struct list *area_list; /* list of IS-IS areas */
89 uint8_t max_area_addrs; /* maximumAreaAdresses */
90 struct area_addr *man_area_addrs; /* manualAreaAddresses */
91 time_t uptime; /* when did we start */
92 struct thread *t_dync_clean; /* dynamic hostname cache cleanup thread */
93 uint32_t circuit_ids_used[8]; /* 256 bits to track circuit ids 1 through 255 */
94 int snmp_notifications;
95 struct list *dyn_cache;
96
97 struct route_table *ext_info[REDIST_PROTOCOL_COUNT];
98 };
99
100 extern struct isis_master *im;
101
102 extern struct thread *t_isis_cfg;
103
104 enum spf_tree_id {
105 SPFTREE_IPV4 = 0,
106 SPFTREE_IPV6,
107 SPFTREE_DSTSRC,
108 SPFTREE_COUNT
109 };
110
111 struct lsp_refresh_arg {
112 struct isis_area *area;
113 int level;
114 };
115
116 /* for yang configuration */
117 enum isis_metric_style {
118 ISIS_NARROW_METRIC = 0,
119 ISIS_WIDE_METRIC,
120 ISIS_TRANSITION_METRIC,
121 };
122
123 struct isis_area {
124 struct isis *isis; /* back pointer */
125 struct lspdb_head lspdb[ISIS_LEVELS]; /* link-state dbs */
126 struct isis_spftree *spftree[SPFTREE_COUNT][ISIS_LEVELS];
127 #define DEFAULT_LSP_MTU 1497
128 unsigned int lsp_mtu; /* Size of LSPs to generate */
129 struct list *circuit_list; /* IS-IS circuits */
130 struct list *adjacency_list; /* IS-IS adjacencies */
131 struct flags flags;
132 struct thread *t_tick; /* LSP walker */
133 struct thread *t_lsp_refresh[ISIS_LEVELS];
134 struct thread *t_overload_on_startup_timer;
135 struct timeval last_lsp_refresh_event[ISIS_LEVELS];
136 struct thread *t_rlfa_rib_update;
137 /* t_lsp_refresh is used in two ways:
138 * a) regular refresh of LSPs
139 * b) (possibly throttled) updates to LSPs
140 *
141 * The lsp_regenerate_pending flag tracks whether the timer is active
142 * for the a) or the b) case.
143 *
144 * It is of utmost importance to clear this flag when the timer is
145 * rescheduled for normal refresh, because otherwise, updates will
146 * be delayed until the next regular refresh.
147 */
148 int lsp_regenerate_pending[ISIS_LEVELS];
149
150 bool bfd_signalled_down;
151 bool bfd_force_spf_refresh;
152
153 struct fabricd *fabricd;
154
155 /*
156 * Configurables
157 */
158 struct isis_passwd area_passwd;
159 struct isis_passwd domain_passwd;
160 /* do we support dynamic hostnames? */
161 char dynhostname;
162 /* do we support new style metrics? */
163 char newmetric;
164 char oldmetric;
165 /* identifies the routing instance */
166 char *area_tag;
167 /* area addresses for this area */
168 struct list *area_addrs;
169 uint16_t max_lsp_lifetime[ISIS_LEVELS];
170 char is_type; /* level-1 level-1-2 or level-2-only */
171 /* are we overloaded? */
172 char overload_bit;
173 bool overload_configured;
174 uint32_t overload_counter;
175 uint32_t overload_on_startup_time;
176 /* L1/L2 router identifier for inter-area traffic */
177 char attached_bit_send;
178 char attached_bit_rcv_ignore;
179 uint16_t lsp_refresh[ISIS_LEVELS];
180 /* minimum time allowed before lsp retransmission */
181 uint16_t lsp_gen_interval[ISIS_LEVELS];
182 /* min interval between between consequtive SPFs */
183 uint16_t min_spf_interval[ISIS_LEVELS];
184 /* the percentage of LSP mtu size used, before generating a new frag */
185 int lsp_frag_threshold;
186 uint64_t lsp_gen_count[ISIS_LEVELS];
187 uint64_t lsp_purge_count[ISIS_LEVELS];
188 uint32_t lsp_exceeded_max_counter;
189 uint32_t lsp_seqno_skipped_counter;
190 uint64_t spf_run_count[ISIS_LEVELS];
191 int ip_circuits;
192 /* logging adjacency changes? */
193 uint8_t log_adj_changes;
194 /* multi topology settings */
195 struct list *mt_settings;
196 /* MPLS-TE settings */
197 struct mpls_te_area *mta;
198 /* Segment Routing information */
199 struct isis_sr_db srdb;
200 int ipv6_circuits;
201 bool purge_originator;
202 /* SPF prefix priorities. */
203 struct spf_prefix_priority_acl
204 spf_prefix_priorities[SPF_PREFIX_PRIO_MAX];
205 /* Fast Re-Route information. */
206 size_t lfa_protected_links[ISIS_LEVELS];
207 size_t lfa_load_sharing[ISIS_LEVELS];
208 enum spf_prefix_priority lfa_priority_limit[ISIS_LEVELS];
209 struct lfa_tiebreaker_tree_head lfa_tiebreakers[ISIS_LEVELS];
210 char *rlfa_plist_name[ISIS_LEVELS];
211 struct prefix_list *rlfa_plist[ISIS_LEVELS];
212 size_t rlfa_protected_links[ISIS_LEVELS];
213 size_t tilfa_protected_links[ISIS_LEVELS];
214 /* MPLS LDP-IGP Sync */
215 struct ldp_sync_info_cmd ldp_sync_cmd;
216 /* Counters */
217 uint32_t circuit_state_changes;
218 struct isis_redist redist_settings[REDIST_PROTOCOL_COUNT]
219 [ZEBRA_ROUTE_MAX + 1][ISIS_LEVELS];
220 struct route_table *ext_reach[REDIST_PROTOCOL_COUNT][ISIS_LEVELS];
221
222 struct spf_backoff *spf_delay_ietf[ISIS_LEVELS]; /*Structure with IETF
223 SPF algo
224 parameters*/
225 struct thread *spf_timer[ISIS_LEVELS];
226
227 struct lsp_refresh_arg lsp_refresh_arg[ISIS_LEVELS];
228
229 pdu_counter_t pdu_tx_counters;
230 pdu_counter_t pdu_rx_counters;
231 uint64_t lsp_rxmt_count;
232
233 /* Area counters */
234 uint64_t rej_adjacencies[2];
235 uint64_t auth_type_failures[2];
236 uint64_t auth_failures[2];
237 uint64_t id_len_mismatches[2];
238 uint64_t lsp_error_counter[2];
239
240 QOBJ_FIELDS;
241 };
242 DECLARE_QOBJ_TYPE(isis_area);
243
244 DECLARE_MTYPE(ISIS_ACL_NAME); /* isis_area->spf_prefix_prioritites */
245 DECLARE_MTYPE(ISIS_AREA_ADDR); /* isis_area->area_addrs */
246 DECLARE_MTYPE(ISIS_PLIST_NAME);
247
248 DECLARE_HOOK(isis_area_overload_bit_update, (struct isis_area * area), (area));
249
250 void isis_terminate(void);
251 void isis_master_init(struct thread_master *master);
252 void isis_vrf_link(struct isis *isis, struct vrf *vrf);
253 void isis_vrf_unlink(struct isis *isis, struct vrf *vrf);
254 struct isis *isis_lookup_by_vrfid(vrf_id_t vrf_id);
255 struct isis *isis_lookup_by_vrfname(const char *vrfname);
256 struct isis *isis_lookup_by_sysid(const uint8_t *sysid);
257
258 void isis_init(void);
259 void isis_vrf_init(void);
260
261 struct isis *isis_new(const char *vrf_name);
262 void isis_finish(struct isis *isis);
263
264 void isis_area_add_circuit(struct isis_area *area,
265 struct isis_circuit *circuit);
266 void isis_area_del_circuit(struct isis_area *area,
267 struct isis_circuit *circuit);
268
269 struct isis_area *isis_area_create(const char *, const char *);
270 struct isis_area *isis_area_lookup(const char *, vrf_id_t vrf_id);
271 struct isis_area *isis_area_lookup_by_vrf(const char *area_tag,
272 const char *vrf_name);
273 int isis_area_get(struct vty *vty, const char *area_tag);
274 void isis_area_destroy(struct isis_area *area);
275 void isis_filter_update(struct access_list *access);
276 void isis_prefix_list_update(struct prefix_list *plist);
277 void print_debug(struct vty *, int, int);
278 struct isis_lsp *lsp_for_sysid(struct lspdb_head *head, const char *sysid_str,
279 struct isis *isis);
280
281 void isis_area_invalidate_routes(struct isis_area *area, int levels);
282 void isis_area_verify_routes(struct isis_area *area);
283 void isis_area_switchover_routes(struct isis_area *area, int family,
284 union g_addr *nexthop_ip, ifindex_t ifindex,
285 int level);
286
287 void isis_area_overload_bit_set(struct isis_area *area, bool overload_bit);
288 void isis_area_overload_on_startup_set(struct isis_area *area,
289 uint32_t startup_time);
290 void isis_area_attached_bit_send_set(struct isis_area *area, bool attached_bit);
291 void isis_area_attached_bit_receive_set(struct isis_area *area,
292 bool attached_bit);
293 void isis_area_dynhostname_set(struct isis_area *area, bool dynhostname);
294 void isis_area_metricstyle_set(struct isis_area *area, bool old_metric,
295 bool new_metric);
296 void isis_area_lsp_mtu_set(struct isis_area *area, unsigned int lsp_mtu);
297 void isis_area_is_type_set(struct isis_area *area, int is_type);
298 void isis_area_max_lsp_lifetime_set(struct isis_area *area, int level,
299 uint16_t max_lsp_lifetime);
300 void isis_area_lsp_refresh_set(struct isis_area *area, int level,
301 uint16_t lsp_refresh);
302 /* IS_LEVEL_1 sets area_passwd, IS_LEVEL_2 domain_passwd */
303 int isis_area_passwd_unset(struct isis_area *area, int level);
304 int isis_area_passwd_cleartext_set(struct isis_area *area, int level,
305 const char *passwd, uint8_t snp_auth);
306 int isis_area_passwd_hmac_md5_set(struct isis_area *area, int level,
307 const char *passwd, uint8_t snp_auth);
308 void show_isis_database_lspdb_json(struct json_object *json,
309 struct isis_area *area, int level,
310 struct lspdb_head *lspdb, const char *argv,
311 int ui_level);
312 void show_isis_database_lspdb_vty(struct vty *vty, struct isis_area *area,
313 int level, struct lspdb_head *lspdb,
314 const char *argv, int ui_level);
315 char *isis_restart_filepath(void);
316 void isis_restart_write_overload_time(struct isis_area *isis_area,
317 uint32_t overload_time);
318 uint32_t isis_restart_read_overload_time(struct isis_area *isis_area);
319 void config_end_lsp_generate(struct isis_area *area);
320
321 /* YANG paths */
322 #define ISIS_INSTANCE "/frr-isisd:isis/instance"
323 #define ISIS_SR "/frr-isisd:isis/instance/segment-routing"
324
325 /* Master of threads. */
326 extern struct thread_master *master;
327
328 extern unsigned long debug_adj_pkt;
329 extern unsigned long debug_snp_pkt;
330 extern unsigned long debug_update_pkt;
331 extern unsigned long debug_spf_events;
332 extern unsigned long debug_rte_events;
333 extern unsigned long debug_events;
334 extern unsigned long debug_pkt_dump;
335 extern unsigned long debug_lsp_gen;
336 extern unsigned long debug_lsp_sched;
337 extern unsigned long debug_flooding;
338 extern unsigned long debug_bfd;
339 extern unsigned long debug_tx_queue;
340 extern unsigned long debug_sr;
341 extern unsigned long debug_ldp_sync;
342 extern unsigned long debug_lfa;
343 extern unsigned long debug_te;
344
345 #define DEBUG_ADJ_PACKETS (1<<0)
346 #define DEBUG_SNP_PACKETS (1<<1)
347 #define DEBUG_UPDATE_PACKETS (1<<2)
348 #define DEBUG_SPF_EVENTS (1<<3)
349 #define DEBUG_RTE_EVENTS (1<<4)
350 #define DEBUG_EVENTS (1<<5)
351 #define DEBUG_PACKET_DUMP (1<<6)
352 #define DEBUG_LSP_GEN (1<<7)
353 #define DEBUG_LSP_SCHED (1<<8)
354 #define DEBUG_FLOODING (1<<9)
355 #define DEBUG_BFD (1<<10)
356 #define DEBUG_TX_QUEUE (1<<11)
357 #define DEBUG_SR (1<<12)
358 #define DEBUG_LDP_SYNC (1<<13)
359 #define DEBUG_LFA (1<<14)
360 #define DEBUG_TE (1<<15)
361
362 /* Debug related macro. */
363 #define IS_DEBUG_ADJ_PACKETS (debug_adj_pkt & DEBUG_ADJ_PACKETS)
364 #define IS_DEBUG_SNP_PACKETS (debug_snp_pkt & DEBUG_SNP_PACKETS)
365 #define IS_DEBUG_UPDATE_PACKETS (debug_update_pkt & DEBUG_UPDATE_PACKETS)
366 #define IS_DEBUG_SPF_EVENTS (debug_spf_events & DEBUG_SPF_EVENTS)
367 #define IS_DEBUG_RTE_EVENTS (debug_rte_events & DEBUG_RTE_EVENTS)
368 #define IS_DEBUG_EVENTS (debug_events & DEBUG_EVENTS)
369 #define IS_DEBUG_PACKET_DUMP (debug_pkt_dump & DEBUG_PACKET_DUMP)
370 #define IS_DEBUG_LSP_GEN (debug_lsp_gen & DEBUG_LSP_GEN)
371 #define IS_DEBUG_LSP_SCHED (debug_lsp_sched & DEBUG_LSP_SCHED)
372 #define IS_DEBUG_FLOODING (debug_flooding & DEBUG_FLOODING)
373 #define IS_DEBUG_BFD (debug_bfd & DEBUG_BFD)
374 #define IS_DEBUG_TX_QUEUE (debug_tx_queue & DEBUG_TX_QUEUE)
375 #define IS_DEBUG_SR (debug_sr & DEBUG_SR)
376 #define IS_DEBUG_LDP_SYNC (debug_ldp_sync & DEBUG_LDP_SYNC)
377 #define IS_DEBUG_LFA (debug_lfa & DEBUG_LFA)
378 #define IS_DEBUG_TE (debug_te & DEBUG_TE)
379
380 #define lsp_debug(...) \
381 do { \
382 if (IS_DEBUG_LSP_GEN) \
383 zlog_debug(__VA_ARGS__); \
384 } while (0)
385
386 #define sched_debug(...) \
387 do { \
388 if (IS_DEBUG_LSP_SCHED) \
389 zlog_debug(__VA_ARGS__); \
390 } while (0)
391
392 #define sr_debug(...) \
393 do { \
394 if (IS_DEBUG_SR) \
395 zlog_debug(__VA_ARGS__); \
396 } while (0)
397
398 #define te_debug(...) \
399 do { \
400 if (IS_DEBUG_TE) \
401 zlog_debug(__VA_ARGS__); \
402 } while (0)
403
404 #endif /* ISISD_H */