]> git.proxmox.com Git - mirror_frr.git/blame - isisd/isisd.h
Merge pull request #13183 from Pdoijode/pdoijode/pim-json-changes
[mirror_frr.git] / isisd / isisd.h
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
eb5d44eb 2/*
d62a17ae 3 * IS-IS Rout(e)ing protocol - isisd.h
eb5d44eb 4 *
5 * Copyright (C) 2001,2002 Sampo Saaristo
d62a17ae 6 * Tampere University of Technology
eb5d44eb 7 * Institute of Communications Engineering
eb5d44eb 8 */
9
10#ifndef ISISD_H
11#define ISISD_H
12
91283e76 13#include "vty.h"
66b9a381 14#include "memory.h"
91283e76 15
65f9a9a8
DL
16#include "isisd/isis_constants.h"
17#include "isisd/isis_common.h"
f3ccedaa 18#include "isisd/isis_redist.h"
39bb53d6 19#include "isisd/isis_pdu_counter.h"
aaf2fd21 20#include "isisd/isis_circuit.h"
26f6acaf 21#include "isisd/isis_sr.h"
65f9a9a8 22#include "isis_flags.h"
4bef0ec4 23#include "isis_lsp.h"
e886416f 24#include "isis_lfa.h"
676a4ea3 25#include "qobj.h"
1cbf96a8 26#include "ldp_sync.h"
5d39a819 27#include "iso.h"
f3ccedaa 28
66b9a381
DL
29DECLARE_MGROUP(ISISD);
30
7c0cbd0e
CF
31#ifdef FABRICD
32static 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
1bfee936
IR
37#define PROTO_IP_REDIST_STR FRR_IP_REDIST_STR_FABRICD
38#define PROTO_IP6_REDIST_STR FRR_IP6_REDIST_STR_FABRICD
7c0cbd0e 39#define PROTO_REDIST_HELP FRR_REDIST_HELP_STR_FABRICD
1bfee936
IR
40#define PROTO_IP_REDIST_HELP FRR_IP_REDIST_HELP_STR_FABRICD
41#define PROTO_IP6_REDIST_HELP FRR_IP6_REDIST_HELP_STR_FABRICD
7c0cbd0e
CF
42#define ROUTER_NODE OPENFABRIC_NODE
43#else
44static 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
1bfee936
IR
49#define PROTO_IP_REDIST_STR FRR_IP_REDIST_STR_ISISD
50#define PROTO_IP6_REDIST_STR FRR_IP6_REDIST_STR_ISISD
7c0cbd0e 51#define PROTO_REDIST_HELP FRR_REDIST_HELP_STR_ISISD
1bfee936
IR
52#define PROTO_IP_REDIST_HELP FRR_IP_REDIST_HELP_STR_ISISD
53#define PROTO_IP6_REDIST_HELP FRR_IP6_REDIST_HELP_STR_ISISD
7c0cbd0e 54#define ROUTER_NODE ISIS_NODE
20bd27e2 55extern void isis_cli_init(void);
7c0cbd0e
CF
56#endif
57
eab88f36
K
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
76e292f9
DS
64extern struct zebra_privs_t isisd_privs;
65
eb5d44eb 66/* uncomment if you are a developer in bug hunt */
67/* #define EXTREME_DEBUG */
eb5d44eb 68
8e6fb83b
CF
69struct fabricd;
70
eab88f36
K
71struct isis_master {
72 /* ISIS instance. */
73 struct list *isis;
74 /* ISIS thread master. */
cd9d0537 75 struct event_loop *master;
eab88f36
K
76 uint8_t options;
77};
52a7c25e 78#define F_ISIS_UNIT_TEST 0x01
eab88f36 79
a2cac12a
JG
80#define ISIS_DEFAULT_MAX_AREA_ADDRESSES 3
81
d62a17ae 82struct isis {
260fcb95 83 vrf_id_t vrf_id;
eab88f36 84 char *name;
d7c0a89a 85 unsigned long process_id;
d62a17ae 86 int sysid_set;
d7c0a89a
QY
87 uint8_t sysid[ISIS_SYS_ID_LEN]; /* SystemID for this IS */
88 uint32_t router_id; /* Router ID from zebra */
d62a17ae 89 struct list *area_list; /* list of IS-IS areas */
d7c0a89a 90 uint8_t max_area_addrs; /* maximumAreaAdresses */
5d39a819 91 struct iso_address *man_area_addrs; /* manualAreaAddresses */
d62a17ae 92 time_t uptime; /* when did we start */
e6685141 93 struct event *t_dync_clean; /* dynamic hostname cache cleanup thread */
c59f88c8 94 uint32_t circuit_ids_used[8]; /* 256 bits to track circuit ids 1 through 255 */
1ee746d9 95 int snmp_notifications;
240f48b3 96 struct list *dyn_cache;
d62a17ae 97
98 struct route_table *ext_info[REDIST_PROTOCOL_COUNT];
eb5d44eb 99};
100
eab88f36 101extern struct isis_master *im;
3f045a08 102
e6685141 103extern struct event *t_isis_cfg;
3b0e97e1 104
be985ba0
CF
105enum spf_tree_id {
106 SPFTREE_IPV4 = 0,
107 SPFTREE_IPV6,
321c1bbb 108 SPFTREE_DSTSRC,
be985ba0
CF
109 SPFTREE_COUNT
110};
111
9196731f
CF
112struct lsp_refresh_arg {
113 struct isis_area *area;
114 int level;
115};
116
e0df3206
EDP
117/* for yang configuration */
118enum isis_metric_style {
119 ISIS_NARROW_METRIC = 0,
120 ISIS_WIDE_METRIC,
121 ISIS_TRANSITION_METRIC,
122};
123
d62a17ae 124struct isis_area {
125 struct isis *isis; /* back pointer */
4bef0ec4 126 struct lspdb_head lspdb[ISIS_LEVELS]; /* link-state dbs */
be985ba0 127 struct isis_spftree *spftree[SPFTREE_COUNT][ISIS_LEVELS];
b20ccb3a 128#define DEFAULT_LSP_MTU 1497
d62a17ae 129 unsigned int lsp_mtu; /* Size of LSPs to generate */
130 struct list *circuit_list; /* IS-IS circuits */
75eddbc3 131 struct list *adjacency_list; /* IS-IS adjacencies */
d62a17ae 132 struct flags flags;
e6685141
DS
133 struct event *t_tick; /* LSP walker */
134 struct event *t_lsp_refresh[ISIS_LEVELS];
135 struct event *t_overload_on_startup_timer;
f93025e1 136 struct timeval last_lsp_refresh_event[ISIS_LEVELS];
e6685141 137 struct event *t_rlfa_rib_update;
d62a17ae 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
690497fb
G
151 bool bfd_signalled_down;
152 bool bfd_force_spf_refresh;
153
8e6fb83b
CF
154 struct fabricd *fabricd;
155
d62a17ae 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 /* identifies the routing instance */
167 char *area_tag;
168 /* area addresses for this area */
169 struct list *area_addrs;
d7c0a89a 170 uint16_t max_lsp_lifetime[ISIS_LEVELS];
d62a17ae 171 char is_type; /* level-1 level-1-2 or level-2-only */
172 /* are we overloaded? */
173 char overload_bit;
4afc7836 174 bool overload_configured;
1ee746d9 175 uint32_t overload_counter;
01ea9b03 176 uint32_t overload_on_startup_time;
3f3608d8
DO
177 /* advertise prefixes of passive interfaces only? */
178 bool advertise_passive_only;
d74f913c
IL
179 /* Are we advertising high metrics? */
180 bool advertise_high_metrics;
d62a17ae 181 /* L1/L2 router identifier for inter-area traffic */
f3abc412 182 char attached_bit_send;
183 char attached_bit_rcv_ignore;
d7c0a89a 184 uint16_t lsp_refresh[ISIS_LEVELS];
d62a17ae 185 /* minimum time allowed before lsp retransmission */
d7c0a89a 186 uint16_t lsp_gen_interval[ISIS_LEVELS];
d62a17ae 187 /* min interval between between consequtive SPFs */
d7c0a89a 188 uint16_t min_spf_interval[ISIS_LEVELS];
d62a17ae 189 /* the percentage of LSP mtu size used, before generating a new frag */
190 int lsp_frag_threshold;
062f4d36 191 uint64_t lsp_gen_count[ISIS_LEVELS];
6f004b60 192 uint64_t lsp_purge_count[ISIS_LEVELS];
1ee746d9 193 uint32_t lsp_exceeded_max_counter;
194 uint32_t lsp_seqno_skipped_counter;
195 uint64_t spf_run_count[ISIS_LEVELS];
d62a17ae 196 int ip_circuits;
197 /* logging adjacency changes? */
d7c0a89a 198 uint8_t log_adj_changes;
9ace83b9
IL
199 /* logging pdu drops? */
200 uint8_t log_pdu_drops;
d62a17ae 201 /* multi topology settings */
202 struct list *mt_settings;
2e2a8b91
OD
203 /* MPLS-TE settings */
204 struct mpls_te_area *mta;
26f6acaf
RW
205 /* Segment Routing information */
206 struct isis_sr_db srdb;
d62a17ae 207 int ipv6_circuits;
2c92bee4 208 bool purge_originator;
e886416f
RW
209 /* SPF prefix priorities. */
210 struct spf_prefix_priority_acl
211 spf_prefix_priorities[SPF_PREFIX_PRIO_MAX];
c951ee6e
RW
212 /* Fast Re-Route information. */
213 size_t lfa_protected_links[ISIS_LEVELS];
e886416f
RW
214 size_t lfa_load_sharing[ISIS_LEVELS];
215 enum spf_prefix_priority lfa_priority_limit[ISIS_LEVELS];
216 struct lfa_tiebreaker_tree_head lfa_tiebreakers[ISIS_LEVELS];
16fe8cff
RW
217 char *rlfa_plist_name[ISIS_LEVELS];
218 struct prefix_list *rlfa_plist[ISIS_LEVELS];
219 size_t rlfa_protected_links[ISIS_LEVELS];
e886416f 220 size_t tilfa_protected_links[ISIS_LEVELS];
ec62fbaa
IR
221 /* MPLS LDP-IGP Sync */
222 struct ldp_sync_info_cmd ldp_sync_cmd;
d62a17ae 223 /* Counters */
d7c0a89a 224 uint32_t circuit_state_changes;
d62a17ae 225 struct isis_redist redist_settings[REDIST_PROTOCOL_COUNT]
226 [ZEBRA_ROUTE_MAX + 1][ISIS_LEVELS];
227 struct route_table *ext_reach[REDIST_PROTOCOL_COUNT][ISIS_LEVELS];
228
229 struct spf_backoff *spf_delay_ietf[ISIS_LEVELS]; /*Structure with IETF
230 SPF algo
231 parameters*/
e6685141 232 struct event *spf_timer[ISIS_LEVELS];
9196731f
CF
233
234 struct lsp_refresh_arg lsp_refresh_arg[ISIS_LEVELS];
d62a17ae 235
39bb53d6
CF
236 pdu_counter_t pdu_tx_counters;
237 pdu_counter_t pdu_rx_counters;
f64adebd 238 pdu_counter_t pdu_drop_counters;
86d6f80d 239 uint64_t lsp_rxmt_count;
39bb53d6 240
1ee746d9 241 /* Area counters */
242 uint64_t rej_adjacencies[2];
243 uint64_t auth_type_failures[2];
244 uint64_t auth_failures[2];
245 uint64_t id_len_mismatches[2];
246 uint64_t lsp_error_counter[2];
247
96244aca 248 QOBJ_FIELDS;
eb5d44eb 249};
96244aca 250DECLARE_QOBJ_TYPE(isis_area);
eb5d44eb 251
66b9a381
DL
252DECLARE_MTYPE(ISIS_ACL_NAME); /* isis_area->spf_prefix_prioritites */
253DECLARE_MTYPE(ISIS_AREA_ADDR); /* isis_area->area_addrs */
dcfe3c16 254DECLARE_MTYPE(ISIS_PLIST_NAME);
66b9a381 255
8451921b 256DECLARE_HOOK(isis_area_overload_bit_update, (struct isis_area * area), (area));
1ee746d9 257
eab88f36 258void isis_terminate(void);
cd9d0537 259void isis_master_init(struct event_loop *master);
eab88f36
K
260void isis_vrf_link(struct isis *isis, struct vrf *vrf);
261void isis_vrf_unlink(struct isis *isis, struct vrf *vrf);
eab88f36
K
262struct isis *isis_lookup_by_vrfid(vrf_id_t vrf_id);
263struct isis *isis_lookup_by_vrfname(const char *vrfname);
36944791 264struct isis *isis_lookup_by_sysid(const uint8_t *sysid);
eab88f36 265
d62a17ae 266void isis_init(void);
65251ce8 267void isis_vrf_init(void);
268
269struct isis *isis_new(const char *vrf_name);
bcf22081
IR
270void isis_finish(struct isis *isis);
271
272void isis_area_add_circuit(struct isis_area *area,
273 struct isis_circuit *circuit);
274void isis_area_del_circuit(struct isis_area *area,
275 struct isis_circuit *circuit);
276
eab88f36
K
277struct isis_area *isis_area_create(const char *, const char *);
278struct isis_area *isis_area_lookup(const char *, vrf_id_t vrf_id);
65251ce8 279struct isis_area *isis_area_lookup_by_vrf(const char *area_tag,
280 const char *vrf_name);
d62a17ae 281int isis_area_get(struct vty *vty, const char *area_tag);
14c6e772 282void isis_area_destroy(struct isis_area *area);
e886416f 283void isis_filter_update(struct access_list *access);
16fe8cff 284void isis_prefix_list_update(struct prefix_list *plist);
3f045a08 285void print_debug(struct vty *, int, int);
1d88e63a
DS
286struct isis_lsp *lsp_for_sysid(struct lspdb_head *head, const char *sysid_str,
287 struct isis *isis);
3f045a08 288
3dace42d
CF
289void isis_area_invalidate_routes(struct isis_area *area, int levels);
290void isis_area_verify_routes(struct isis_area *area);
694fa867
LS
291void isis_area_switchover_routes(struct isis_area *area, int family,
292 union g_addr *nexthop_ip, ifindex_t ifindex,
293 int level);
3dace42d 294
a38a72db 295void isis_area_overload_bit_set(struct isis_area *area, bool overload_bit);
01ea9b03
IL
296void isis_area_overload_on_startup_set(struct isis_area *area,
297 uint32_t startup_time);
d74f913c
IL
298void isis_area_advertise_high_metrics_set(struct isis_area *area,
299 bool advertise_high_metrics);
f3abc412 300void isis_area_attached_bit_send_set(struct isis_area *area, bool attached_bit);
301void isis_area_attached_bit_receive_set(struct isis_area *area,
302 bool attached_bit);
a38a72db
CF
303void isis_area_dynhostname_set(struct isis_area *area, bool dynhostname);
304void isis_area_metricstyle_set(struct isis_area *area, bool old_metric,
305 bool new_metric);
6754fc66
CF
306void isis_area_lsp_mtu_set(struct isis_area *area, unsigned int lsp_mtu);
307void isis_area_is_type_set(struct isis_area *area, int is_type);
466ed406 308void isis_area_max_lsp_lifetime_set(struct isis_area *area, int level,
d62a17ae 309 uint16_t max_lsp_lifetime);
466ed406
CF
310void isis_area_lsp_refresh_set(struct isis_area *area, int level,
311 uint16_t lsp_refresh);
9093b230 312/* IS_LEVEL_1 sets area_passwd, IS_LEVEL_2 domain_passwd */
d62a17ae 313int isis_area_passwd_unset(struct isis_area *area, int level);
314int isis_area_passwd_cleartext_set(struct isis_area *area, int level,
d7c0a89a 315 const char *passwd, uint8_t snp_auth);
d62a17ae 316int isis_area_passwd_hmac_md5_set(struct isis_area *area, int level,
d7c0a89a 317 const char *passwd, uint8_t snp_auth);
a2cac12a
JG
318void show_isis_database_lspdb_json(struct json_object *json,
319 struct isis_area *area, int level,
320 struct lspdb_head *lspdb, const char *argv,
321 int ui_level);
322void show_isis_database_lspdb_vty(struct vty *vty, struct isis_area *area,
323 int level, struct lspdb_head *lspdb,
324 const char *argv, int ui_level);
450841fe
IL
325char *isis_restart_filepath(void);
326void isis_restart_write_overload_time(struct isis_area *isis_area,
327 uint32_t overload_time);
328uint32_t isis_restart_read_overload_time(struct isis_area *isis_area);
3b0e97e1
IL
329void config_end_lsp_generate(struct isis_area *area);
330
26f6acaf
RW
331/* YANG paths */
332#define ISIS_INSTANCE "/frr-isisd:isis/instance"
333#define ISIS_SR "/frr-isisd:isis/instance/segment-routing"
334
3f045a08 335/* Master of threads. */
cd9d0537 336extern struct event_loop *master;
eb5d44eb 337
e740f9c1 338extern unsigned long debug_adj_pkt;
339extern unsigned long debug_snp_pkt;
340extern unsigned long debug_update_pkt;
341extern unsigned long debug_spf_events;
342extern unsigned long debug_rte_events;
343extern unsigned long debug_events;
344extern unsigned long debug_pkt_dump;
345extern unsigned long debug_lsp_gen;
346extern unsigned long debug_lsp_sched;
347extern unsigned long debug_flooding;
348extern unsigned long debug_bfd;
349extern unsigned long debug_tx_queue;
350extern unsigned long debug_sr;
1cbf96a8 351extern unsigned long debug_ldp_sync;
2866b119 352extern unsigned long debug_lfa;
d9884a75 353extern unsigned long debug_te;
e740f9c1 354
eb5d44eb 355#define DEBUG_ADJ_PACKETS (1<<0)
26687d25
CF
356#define DEBUG_SNP_PACKETS (1<<1)
357#define DEBUG_UPDATE_PACKETS (1<<2)
358#define DEBUG_SPF_EVENTS (1<<3)
359#define DEBUG_RTE_EVENTS (1<<4)
360#define DEBUG_EVENTS (1<<5)
361#define DEBUG_PACKET_DUMP (1<<6)
362#define DEBUG_LSP_GEN (1<<7)
363#define DEBUG_LSP_SCHED (1<<8)
ddb33326 364#define DEBUG_FLOODING (1<<9)
26687d25 365#define DEBUG_BFD (1<<10)
161fa356 366#define DEBUG_TX_QUEUE (1<<11)
26f6acaf 367#define DEBUG_SR (1<<12)
c951ee6e 368#define DEBUG_LDP_SYNC (1<<13)
2866b119 369#define DEBUG_LFA (1<<14)
d9884a75 370#define DEBUG_TE (1<<15)
14872644 371
e740f9c1 372/* Debug related macro. */
373#define IS_DEBUG_ADJ_PACKETS (debug_adj_pkt & DEBUG_ADJ_PACKETS)
374#define IS_DEBUG_SNP_PACKETS (debug_snp_pkt & DEBUG_SNP_PACKETS)
375#define IS_DEBUG_UPDATE_PACKETS (debug_update_pkt & DEBUG_UPDATE_PACKETS)
376#define IS_DEBUG_SPF_EVENTS (debug_spf_events & DEBUG_SPF_EVENTS)
377#define IS_DEBUG_RTE_EVENTS (debug_rte_events & DEBUG_RTE_EVENTS)
378#define IS_DEBUG_EVENTS (debug_events & DEBUG_EVENTS)
379#define IS_DEBUG_PACKET_DUMP (debug_pkt_dump & DEBUG_PACKET_DUMP)
380#define IS_DEBUG_LSP_GEN (debug_lsp_gen & DEBUG_LSP_GEN)
381#define IS_DEBUG_LSP_SCHED (debug_lsp_sched & DEBUG_LSP_SCHED)
382#define IS_DEBUG_FLOODING (debug_flooding & DEBUG_FLOODING)
383#define IS_DEBUG_BFD (debug_bfd & DEBUG_BFD)
384#define IS_DEBUG_TX_QUEUE (debug_tx_queue & DEBUG_TX_QUEUE)
385#define IS_DEBUG_SR (debug_sr & DEBUG_SR)
1cbf96a8 386#define IS_DEBUG_LDP_SYNC (debug_ldp_sync & DEBUG_LDP_SYNC)
2866b119 387#define IS_DEBUG_LFA (debug_lfa & DEBUG_LFA)
d9884a75 388#define IS_DEBUG_TE (debug_te & DEBUG_TE)
e740f9c1 389
d62a17ae 390#define lsp_debug(...) \
391 do { \
e740f9c1 392 if (IS_DEBUG_LSP_GEN) \
d62a17ae 393 zlog_debug(__VA_ARGS__); \
394 } while (0)
395
396#define sched_debug(...) \
397 do { \
e740f9c1 398 if (IS_DEBUG_LSP_SCHED) \
d62a17ae 399 zlog_debug(__VA_ARGS__); \
400 } while (0)
414766a1 401
b407c77a
OD
402#define sr_debug(...) \
403 do { \
e740f9c1 404 if (IS_DEBUG_SR) \
b407c77a
OD
405 zlog_debug(__VA_ARGS__); \
406 } while (0)
407
d9884a75
OD
408#define te_debug(...) \
409 do { \
410 if (IS_DEBUG_TE) \
411 zlog_debug(__VA_ARGS__); \
412 } while (0)
f8c06e2c 413
eb5d44eb 414#endif /* ISISD_H */