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