2 * IS-IS Rout(e)ing protocol - isisd.h
4 * Copyright (C) 2001,2002 Sampo Saaristo
5 * Tampere University of Technology
6 * Institute of Communications Engineering
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)
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
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
29 #include "isisd/isis_constants.h"
30 #include "isisd/isis_common.h"
31 #include "isisd/isis_redist.h"
32 #include "isisd/isis_pdu_counter.h"
33 #include "isisd/isis_circuit.h"
34 #include "isisd/isis_sr.h"
35 #include "isis_flags.h"
41 DECLARE_MGROUP(ISISD
);
44 static const bool fabricd
= true;
45 #define PROTO_TYPE ZEBRA_ROUTE_OPENFABRIC
46 #define PROTO_NAME "openfabric"
47 #define PROTO_HELP "OpenFabric routing protocol\n"
48 #define PROTO_REDIST_STR FRR_REDIST_STR_FABRICD
49 #define PROTO_IP_REDIST_STR FRR_IP_REDIST_STR_FABRICD
50 #define PROTO_IP6_REDIST_STR FRR_IP6_REDIST_STR_FABRICD
51 #define PROTO_REDIST_HELP FRR_REDIST_HELP_STR_FABRICD
52 #define PROTO_IP_REDIST_HELP FRR_IP_REDIST_HELP_STR_FABRICD
53 #define PROTO_IP6_REDIST_HELP FRR_IP6_REDIST_HELP_STR_FABRICD
54 #define ROUTER_NODE OPENFABRIC_NODE
56 static const bool fabricd
= false;
57 #define PROTO_TYPE ZEBRA_ROUTE_ISIS
58 #define PROTO_NAME "isis"
59 #define PROTO_HELP "IS-IS routing protocol\n"
60 #define PROTO_REDIST_STR FRR_REDIST_STR_ISISD
61 #define PROTO_IP_REDIST_STR FRR_IP_REDIST_STR_ISISD
62 #define PROTO_IP6_REDIST_STR FRR_IP6_REDIST_STR_ISISD
63 #define PROTO_REDIST_HELP FRR_REDIST_HELP_STR_ISISD
64 #define PROTO_IP_REDIST_HELP FRR_IP_REDIST_HELP_STR_ISISD
65 #define PROTO_IP6_REDIST_HELP FRR_IP6_REDIST_HELP_STR_ISISD
66 #define ROUTER_NODE ISIS_NODE
67 extern void isis_cli_init(void);
70 #define ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf) \
71 if (argv_find(argv, argc, "vrf", &idx_vrf)) { \
72 vrf_name = argv[idx_vrf + 1]->arg; \
73 all_vrf = strmatch(vrf_name, "all"); \
76 extern struct zebra_privs_t isisd_privs
;
78 /* uncomment if you are a developer in bug hunt */
79 /* #define EXTREME_DEBUG */
86 /* ISIS thread master. */
87 struct thread_master
*master
;
90 #define F_ISIS_UNIT_TEST 0x01
92 #define ISIS_DEFAULT_MAX_AREA_ADDRESSES 3
97 unsigned long process_id
;
99 uint8_t sysid
[ISIS_SYS_ID_LEN
]; /* SystemID for this IS */
100 uint32_t router_id
; /* Router ID from zebra */
101 struct list
*area_list
; /* list of IS-IS areas */
102 uint8_t max_area_addrs
; /* maximumAreaAdresses */
103 struct area_addr
*man_area_addrs
; /* manualAreaAddresses */
104 time_t uptime
; /* when did we start */
105 struct thread
*t_dync_clean
; /* dynamic hostname cache cleanup thread */
106 uint32_t circuit_ids_used
[8]; /* 256 bits to track circuit ids 1 through 255 */
107 int snmp_notifications
;
108 struct list
*dyn_cache
;
110 struct route_table
*ext_info
[REDIST_PROTOCOL_COUNT
];
113 extern struct isis_master
*im
;
122 struct lsp_refresh_arg
{
123 struct isis_area
*area
;
127 /* for yang configuration */
128 enum isis_metric_style
{
129 ISIS_NARROW_METRIC
= 0,
131 ISIS_TRANSITION_METRIC
,
135 struct isis
*isis
; /* back pointer */
136 struct lspdb_head lspdb
[ISIS_LEVELS
]; /* link-state dbs */
137 struct isis_spftree
*spftree
[SPFTREE_COUNT
][ISIS_LEVELS
];
138 #define DEFAULT_LSP_MTU 1497
139 unsigned int lsp_mtu
; /* Size of LSPs to generate */
140 struct list
*circuit_list
; /* IS-IS circuits */
141 struct list
*adjacency_list
; /* IS-IS adjacencies */
143 struct thread
*t_tick
; /* LSP walker */
144 struct thread
*t_lsp_refresh
[ISIS_LEVELS
];
145 struct timeval last_lsp_refresh_event
[ISIS_LEVELS
];
146 struct thread
*t_rlfa_rib_update
;
147 /* t_lsp_refresh is used in two ways:
148 * a) regular refresh of LSPs
149 * b) (possibly throttled) updates to LSPs
151 * The lsp_regenerate_pending flag tracks whether the timer is active
152 * for the a) or the b) case.
154 * It is of utmost importance to clear this flag when the timer is
155 * rescheduled for normal refresh, because otherwise, updates will
156 * be delayed until the next regular refresh.
158 int lsp_regenerate_pending
[ISIS_LEVELS
];
160 bool bfd_signalled_down
;
161 bool bfd_force_spf_refresh
;
163 struct fabricd
*fabricd
;
168 struct isis_passwd area_passwd
;
169 struct isis_passwd domain_passwd
;
170 /* do we support dynamic hostnames? */
172 /* do we support new style metrics? */
175 /* identifies the routing instance */
177 /* area addresses for this area */
178 struct list
*area_addrs
;
179 uint16_t max_lsp_lifetime
[ISIS_LEVELS
];
180 char is_type
; /* level-1 level-1-2 or level-2-only */
181 /* are we overloaded? */
183 uint32_t overload_counter
;
184 /* L1/L2 router identifier for inter-area traffic */
185 char attached_bit_send
;
186 char attached_bit_rcv_ignore
;
187 uint16_t lsp_refresh
[ISIS_LEVELS
];
188 /* minimum time allowed before lsp retransmission */
189 uint16_t lsp_gen_interval
[ISIS_LEVELS
];
190 /* min interval between between consequtive SPFs */
191 uint16_t min_spf_interval
[ISIS_LEVELS
];
192 /* the percentage of LSP mtu size used, before generating a new frag */
193 int lsp_frag_threshold
;
194 uint64_t lsp_gen_count
[ISIS_LEVELS
];
195 uint64_t lsp_purge_count
[ISIS_LEVELS
];
196 uint32_t lsp_exceeded_max_counter
;
197 uint32_t lsp_seqno_skipped_counter
;
198 uint64_t spf_run_count
[ISIS_LEVELS
];
200 /* logging adjacency changes? */
201 uint8_t log_adj_changes
;
202 /* multi topology settings */
203 struct list
*mt_settings
;
204 /* MPLS-TE settings */
205 struct mpls_te_area
*mta
;
206 /* Segment Routing information */
207 struct isis_sr_db srdb
;
209 bool purge_originator
;
210 /* SPF prefix priorities. */
211 struct spf_prefix_priority_acl
212 spf_prefix_priorities
[SPF_PREFIX_PRIO_MAX
];
213 /* Fast Re-Route information. */
214 size_t lfa_protected_links
[ISIS_LEVELS
];
215 size_t lfa_load_sharing
[ISIS_LEVELS
];
216 enum spf_prefix_priority lfa_priority_limit
[ISIS_LEVELS
];
217 struct lfa_tiebreaker_tree_head lfa_tiebreakers
[ISIS_LEVELS
];
218 char *rlfa_plist_name
[ISIS_LEVELS
];
219 struct prefix_list
*rlfa_plist
[ISIS_LEVELS
];
220 size_t rlfa_protected_links
[ISIS_LEVELS
];
221 size_t tilfa_protected_links
[ISIS_LEVELS
];
222 /* MPLS LDP-IGP Sync */
223 struct ldp_sync_info_cmd ldp_sync_cmd
;
225 uint32_t circuit_state_changes
;
226 struct isis_redist redist_settings
[REDIST_PROTOCOL_COUNT
]
227 [ZEBRA_ROUTE_MAX
+ 1][ISIS_LEVELS
];
228 struct route_table
*ext_reach
[REDIST_PROTOCOL_COUNT
][ISIS_LEVELS
];
230 struct spf_backoff
*spf_delay_ietf
[ISIS_LEVELS
]; /*Structure with IETF
233 struct thread
*spf_timer
[ISIS_LEVELS
];
235 struct lsp_refresh_arg lsp_refresh_arg
[ISIS_LEVELS
];
237 pdu_counter_t pdu_tx_counters
;
238 pdu_counter_t pdu_rx_counters
;
239 uint64_t lsp_rxmt_count
;
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];
250 DECLARE_QOBJ_TYPE(isis_area
);
252 DECLARE_MTYPE(ISIS_ACL_NAME
); /* isis_area->spf_prefix_prioritites */
253 DECLARE_MTYPE(ISIS_AREA_ADDR
); /* isis_area->area_addrs */
255 DECLARE_HOOK(isis_area_overload_bit_update
, (struct isis_area
* area
), (area
));
257 void isis_terminate(void);
258 void isis_master_init(struct thread_master
*master
);
259 void isis_vrf_link(struct isis
*isis
, struct vrf
*vrf
);
260 void isis_vrf_unlink(struct isis
*isis
, struct vrf
*vrf
);
261 struct isis
*isis_lookup_by_vrfid(vrf_id_t vrf_id
);
262 struct isis
*isis_lookup_by_vrfname(const char *vrfname
);
263 struct isis
*isis_lookup_by_sysid(const uint8_t *sysid
);
265 void isis_init(void);
266 void isis_vrf_init(void);
268 struct isis
*isis_new(const char *vrf_name
);
269 void isis_finish(struct isis
*isis
);
271 void isis_area_add_circuit(struct isis_area
*area
,
272 struct isis_circuit
*circuit
);
273 void isis_area_del_circuit(struct isis_area
*area
,
274 struct isis_circuit
*circuit
);
276 struct isis_area
*isis_area_create(const char *, const char *);
277 struct isis_area
*isis_area_lookup(const char *, vrf_id_t vrf_id
);
278 struct isis_area
*isis_area_lookup_by_vrf(const char *area_tag
,
279 const char *vrf_name
);
280 int isis_area_get(struct vty
*vty
, const char *area_tag
);
281 void isis_area_destroy(struct isis_area
*area
);
282 void isis_filter_update(struct access_list
*access
);
283 void isis_prefix_list_update(struct prefix_list
*plist
);
284 void print_debug(struct vty
*, int, int);
285 struct isis_lsp
*lsp_for_sysid(struct lspdb_head
*head
, const char *sysid_str
,
288 void isis_area_invalidate_routes(struct isis_area
*area
, int levels
);
289 void isis_area_verify_routes(struct isis_area
*area
);
291 void isis_area_overload_bit_set(struct isis_area
*area
, bool overload_bit
);
292 void isis_area_attached_bit_send_set(struct isis_area
*area
, bool attached_bit
);
293 void isis_area_attached_bit_receive_set(struct isis_area
*area
,
295 void isis_area_dynhostname_set(struct isis_area
*area
, bool dynhostname
);
296 void isis_area_metricstyle_set(struct isis_area
*area
, bool old_metric
,
298 void isis_area_lsp_mtu_set(struct isis_area
*area
, unsigned int lsp_mtu
);
299 void isis_area_is_type_set(struct isis_area
*area
, int is_type
);
300 void isis_area_max_lsp_lifetime_set(struct isis_area
*area
, int level
,
301 uint16_t max_lsp_lifetime
);
302 void isis_area_lsp_refresh_set(struct isis_area
*area
, int level
,
303 uint16_t lsp_refresh
);
304 /* IS_LEVEL_1 sets area_passwd, IS_LEVEL_2 domain_passwd */
305 int isis_area_passwd_unset(struct isis_area
*area
, int level
);
306 int isis_area_passwd_cleartext_set(struct isis_area
*area
, int level
,
307 const char *passwd
, uint8_t snp_auth
);
308 int isis_area_passwd_hmac_md5_set(struct isis_area
*area
, int level
,
309 const char *passwd
, uint8_t snp_auth
);
310 void show_isis_database_lspdb_json(struct json_object
*json
,
311 struct isis_area
*area
, int level
,
312 struct lspdb_head
*lspdb
, const char *argv
,
314 void show_isis_database_lspdb_vty(struct vty
*vty
, struct isis_area
*area
,
315 int level
, struct lspdb_head
*lspdb
,
316 const char *argv
, int ui_level
);
319 #define ISIS_INSTANCE "/frr-isisd:isis/instance"
320 #define ISIS_SR "/frr-isisd:isis/instance/segment-routing"
322 /* Master of threads. */
323 extern struct thread_master
*master
;
325 extern unsigned long debug_adj_pkt
;
326 extern unsigned long debug_snp_pkt
;
327 extern unsigned long debug_update_pkt
;
328 extern unsigned long debug_spf_events
;
329 extern unsigned long debug_rte_events
;
330 extern unsigned long debug_events
;
331 extern unsigned long debug_pkt_dump
;
332 extern unsigned long debug_lsp_gen
;
333 extern unsigned long debug_lsp_sched
;
334 extern unsigned long debug_flooding
;
335 extern unsigned long debug_bfd
;
336 extern unsigned long debug_tx_queue
;
337 extern unsigned long debug_sr
;
338 extern unsigned long debug_ldp_sync
;
339 extern unsigned long debug_lfa
;
340 extern unsigned long debug_te
;
342 #define DEBUG_ADJ_PACKETS (1<<0)
343 #define DEBUG_SNP_PACKETS (1<<1)
344 #define DEBUG_UPDATE_PACKETS (1<<2)
345 #define DEBUG_SPF_EVENTS (1<<3)
346 #define DEBUG_RTE_EVENTS (1<<4)
347 #define DEBUG_EVENTS (1<<5)
348 #define DEBUG_PACKET_DUMP (1<<6)
349 #define DEBUG_LSP_GEN (1<<7)
350 #define DEBUG_LSP_SCHED (1<<8)
351 #define DEBUG_FLOODING (1<<9)
352 #define DEBUG_BFD (1<<10)
353 #define DEBUG_TX_QUEUE (1<<11)
354 #define DEBUG_SR (1<<12)
355 #define DEBUG_LDP_SYNC (1<<13)
356 #define DEBUG_LFA (1<<14)
357 #define DEBUG_TE (1<<15)
359 /* Debug related macro. */
360 #define IS_DEBUG_ADJ_PACKETS (debug_adj_pkt & DEBUG_ADJ_PACKETS)
361 #define IS_DEBUG_SNP_PACKETS (debug_snp_pkt & DEBUG_SNP_PACKETS)
362 #define IS_DEBUG_UPDATE_PACKETS (debug_update_pkt & DEBUG_UPDATE_PACKETS)
363 #define IS_DEBUG_SPF_EVENTS (debug_spf_events & DEBUG_SPF_EVENTS)
364 #define IS_DEBUG_RTE_EVENTS (debug_rte_events & DEBUG_RTE_EVENTS)
365 #define IS_DEBUG_EVENTS (debug_events & DEBUG_EVENTS)
366 #define IS_DEBUG_PACKET_DUMP (debug_pkt_dump & DEBUG_PACKET_DUMP)
367 #define IS_DEBUG_LSP_GEN (debug_lsp_gen & DEBUG_LSP_GEN)
368 #define IS_DEBUG_LSP_SCHED (debug_lsp_sched & DEBUG_LSP_SCHED)
369 #define IS_DEBUG_FLOODING (debug_flooding & DEBUG_FLOODING)
370 #define IS_DEBUG_BFD (debug_bfd & DEBUG_BFD)
371 #define IS_DEBUG_TX_QUEUE (debug_tx_queue & DEBUG_TX_QUEUE)
372 #define IS_DEBUG_SR (debug_sr & DEBUG_SR)
373 #define IS_DEBUG_LDP_SYNC (debug_ldp_sync & DEBUG_LDP_SYNC)
374 #define IS_DEBUG_LFA (debug_lfa & DEBUG_LFA)
375 #define IS_DEBUG_TE (debug_te & DEBUG_TE)
377 #define lsp_debug(...) \
379 if (IS_DEBUG_LSP_GEN) \
380 zlog_debug(__VA_ARGS__); \
383 #define sched_debug(...) \
385 if (IS_DEBUG_LSP_SCHED) \
386 zlog_debug(__VA_ARGS__); \
389 #define sr_debug(...) \
392 zlog_debug(__VA_ARGS__); \
395 #define te_debug(...) \
398 zlog_debug(__VA_ARGS__); \