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