]>
Commit | Line | Data |
---|---|---|
acddc0ed | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
718e3744 | 2 | /* |
3 | * OSPFd main header. | |
4 | * Copyright (C) 1998, 99, 2000 Kunihiro Ishiguro, Toshiaki Takada | |
718e3744 | 5 | */ |
6 | ||
7 | #ifndef _ZEBRA_OSPFD_H | |
8 | #define _ZEBRA_OSPFD_H | |
9 | ||
c514adc6 | 10 | #include <zebra.h> |
7fd0729f | 11 | #include "typesafe.h" |
ae19c240 | 12 | #include "qobj.h" |
8551e6da | 13 | #include "libospf.h" |
132a782e | 14 | #include "ldp_sync.h" |
c514adc6 | 15 | |
718e3744 | 16 | #include "filter.h" |
343f5cc7 | 17 | #include "log.h" |
b5a8894d | 18 | #include "vrf.h" |
718e3744 | 19 | |
4a1ab8e4 | 20 | #include "ospf_memory.h" |
0a3fc2a5 | 21 | #include "ospf_dump_api.h" |
4a1ab8e4 | 22 | |
718e3744 | 23 | #define OSPF_VERSION 2 |
24 | ||
718e3744 | 25 | /* VTY port number. */ |
26 | #define OSPF_VTY_PORT 2604 | |
718e3744 | 27 | |
28 | /* IP TTL for OSPF protocol. */ | |
29 | #define OSPF_IP_TTL 1 | |
30 | #define OSPF_VL_IP_TTL 100 | |
31 | ||
32 | /* Default configuration file name for ospfd. */ | |
33 | #define OSPF_DEFAULT_CONFIG "ospfd.conf" | |
34 | ||
464c8204 | 35 | #define OSPF_NSSA_TRANS_STABLE_DEFAULT 40 |
718e3744 | 36 | |
37 | #define OSPF_ALLSPFROUTERS 0xe0000005 /* 224.0.0.5 */ | |
38 | #define OSPF_ALLDROUTERS 0xe0000006 /* 224.0.0.6 */ | |
39 | ||
718e3744 | 40 | /* OSPF Authentication Type. */ |
41 | #define OSPF_AUTH_NULL 0 | |
42 | #define OSPF_AUTH_SIMPLE 1 | |
43 | #define OSPF_AUTH_CRYPTOGRAPHIC 2 | |
44 | /* For Interface authentication setting default */ | |
45 | #define OSPF_AUTH_NOTSET -1 | |
d62a17ae | 46 | /* For the consumption and sanity of the command handler */ |
718e3744 | 47 | /* DO NIOT REMOVE!!! Need to detect whether a value has |
48 | been given or not in VLink command handlers */ | |
49 | #define OSPF_AUTH_CMD_NOTSEEN -2 | |
50 | ||
718e3744 | 51 | /* OSPF options. */ |
16f1b9ee | 52 | #define OSPF_OPTION_MT 0x01 /* M/T */ |
718e3744 | 53 | #define OSPF_OPTION_E 0x02 |
54 | #define OSPF_OPTION_MC 0x04 | |
55 | #define OSPF_OPTION_NP 0x08 | |
56 | #define OSPF_OPTION_EA 0x10 | |
57 | #define OSPF_OPTION_DC 0x20 | |
58 | #define OSPF_OPTION_O 0x40 | |
16f1b9ee | 59 | #define OSPF_OPTION_DN 0x80 |
718e3744 | 60 | |
61 | /* OSPF Database Description flags. */ | |
62 | #define OSPF_DD_FLAG_MS 0x01 | |
63 | #define OSPF_DD_FLAG_M 0x02 | |
64 | #define OSPF_DD_FLAG_I 0x04 | |
65 | #define OSPF_DD_FLAG_ALL 0x07 | |
66 | ||
718e3744 | 67 | #define OSPF_LS_REFRESH_SHIFT (60 * 15) |
68 | #define OSPF_LS_REFRESH_JITTER 60 | |
69 | ||
6e6e1020 MS |
70 | /* Default socket buffer size */ |
71 | #define OSPF_DEFAULT_SOCK_BUFSIZE (8 * 1024 * 1024) | |
72 | ||
d62a17ae | 73 | struct ospf_external { |
d7c0a89a | 74 | unsigned short instance; |
d62a17ae | 75 | struct route_table *external_info; |
7c8ff89e DS |
76 | }; |
77 | ||
020709f9 | 78 | /* OSPF master for system wide configuration and variables. */ |
d62a17ae | 79 | struct ospf_master { |
80 | /* OSPF instance. */ | |
81 | struct list *ospf; | |
020709f9 | 82 | |
d62a17ae | 83 | /* OSPF thread master. */ |
cd9d0537 | 84 | struct event_loop *master; |
020709f9 | 85 | |
d62a17ae | 86 | /* Various OSPF global configuration. */ |
d7c0a89a | 87 | uint8_t options; |
32ab5cf4 | 88 | #define OSPF_MASTER_SHUTDOWN (1 << 0) /* deferred-shutdown */ |
020709f9 | 89 | }; |
90 | ||
d62a17ae | 91 | struct ospf_redist { |
d7c0a89a | 92 | unsigned short instance; |
d62a17ae | 93 | |
94 | /* Redistribute metric info. */ | |
95 | struct { | |
96 | int type; /* External metric type (E1 or E2). */ | |
97 | int value; /* Value for static metric (24-bit). | |
98 | -1 means metric value is not set. */ | |
99 | } dmetric; | |
100 | ||
101 | /* For redistribute route map. */ | |
102 | struct { | |
103 | char *name; | |
104 | struct route_map *map; | |
105 | } route_map; /* +1 is for default-information */ | |
7c8ff89e | 106 | #define ROUTEMAP_NAME(R) (R->route_map.name) |
6f7bbc0c MN |
107 | #define ROUTEMAP(R) (R->route_map.map) |
108 | }; | |
109 | ||
110 | /* OSPF area flood reduction info */ | |
111 | struct ospf_area_fr_info { | |
112 | bool enabled; /* Area support for Flood Reduction */ | |
113 | bool configured; /* Flood Reduction configured per area knob */ | |
114 | bool state_changed; /* flood reduction state change info */ | |
115 | int router_lsas_recv_dc_bit; /* Number of unique router lsas | |
116 | * received with DC bit set. | |
117 | * (excluding self) | |
118 | */ | |
119 | bool area_ind_lsa_recvd; /* Indication lsa received in this area */ | |
120 | bool area_dc_clear; /* Area has atleast one lsa with dc bit 0( | |
121 | * excluding indication lsa) | |
122 | */ | |
123 | struct ospf_lsa *indication_lsa_self; /* Indication LSA generated | |
124 | * in the area. | |
125 | */ | |
7c8ff89e DS |
126 | }; |
127 | ||
c572fbfe DL |
128 | /* ospf->config */ |
129 | enum { | |
130 | OSPF_RFC1583_COMPATIBLE = (1 << 0), | |
131 | OSPF_OPAQUE_CAPABLE = (1 << 2), | |
132 | OSPF_LOG_ADJACENCY_CHANGES = (1 << 3), | |
133 | OSPF_LOG_ADJACENCY_DETAIL = (1 << 4), | |
5b5d66c4 | 134 | OSPF_SEND_EXTRA_DATA_TO_ZEBRA = (1 << 5), |
c572fbfe DL |
135 | }; |
136 | ||
385a1e07 G |
137 | /* TI-LFA */ |
138 | enum protection_type { | |
139 | OSPF_TI_LFA_UNDEFINED_PROTECTION, | |
140 | OSPF_TI_LFA_LINK_PROTECTION, | |
141 | OSPF_TI_LFA_NODE_PROTECTION, | |
142 | }; | |
143 | ||
10514170 RW |
144 | /* OSPF nonstop forwarding aka Graceful Restart */ |
145 | struct ospf_gr_info { | |
146 | bool restart_support; | |
147 | bool restart_in_progress; | |
148 | bool prepare_in_progress; | |
149 | bool finishing_restart; | |
150 | uint32_t grace_period; | |
ab749e7e RW |
151 | int reason; |
152 | char *exit_reason; | |
e6685141 | 153 | struct event *t_grace_period; |
10514170 RW |
154 | }; |
155 | ||
718e3744 | 156 | /* OSPF instance structure. */ |
d62a17ae | 157 | struct ospf { |
158 | /* OSPF's running state based on the '[no] router ospf [<instance>]' | |
159 | * config. */ | |
d7c0a89a | 160 | uint8_t oi_running; |
0bad4851 | 161 | |
d62a17ae | 162 | /* OSPF instance ID */ |
d7c0a89a | 163 | unsigned short instance; |
7c8ff89e | 164 | |
d62a17ae | 165 | /* OSPF Router ID. */ |
166 | struct in_addr router_id; /* Configured automatically. */ | |
167 | struct in_addr router_id_static; /* Configured manually. */ | |
6021c6c0 | 168 | struct in_addr router_id_zebra; |
718e3744 | 169 | |
996c9314 LB |
170 | vrf_id_t vrf_id; /* VRF Id */ |
171 | char *name; /* VRF name */ | |
b5a8894d | 172 | |
d62a17ae | 173 | /* ABR/ASBR internal flags. */ |
d7c0a89a | 174 | uint8_t flags; |
718e3744 | 175 | #define OSPF_FLAG_ABR 0x0001 |
176 | #define OSPF_FLAG_ASBR 0x0002 | |
177 | ||
d62a17ae | 178 | /* ABR type. */ |
d7c0a89a | 179 | uint8_t abr_type; |
718e3744 | 180 | #define OSPF_ABR_UNKNOWN 0 |
181 | #define OSPF_ABR_STAND 1 | |
182 | #define OSPF_ABR_IBM 2 | |
183 | #define OSPF_ABR_CISCO 3 | |
184 | #define OSPF_ABR_SHORTCUT 4 | |
d57834f6 | 185 | #define OSPF_ABR_DEFAULT OSPF_ABR_CISCO |
718e3744 | 186 | |
d62a17ae | 187 | /* NSSA ABR */ |
d7c0a89a | 188 | uint8_t anyNSSA; /* Bump for every NSSA attached. */ |
718e3744 | 189 | |
c572fbfe | 190 | /* Configuration bitmask, refer to enum above */ |
d7c0a89a | 191 | uint8_t config; |
718e3744 | 192 | |
d62a17ae | 193 | /* Opaque-LSA administrative flags. */ |
d7c0a89a | 194 | uint8_t opaque; |
718e3744 | 195 | #define OPAQUE_OPERATION_READY_BIT (1 << 0) |
718e3744 | 196 | |
d62a17ae | 197 | /* RFC3137 stub router. Configured time to stay stub / max-metric */ |
198 | unsigned int stub_router_startup_time; /* seconds */ | |
199 | unsigned int stub_router_shutdown_time; /* seconds */ | |
88d6cf37 | 200 | #define OSPF_STUB_ROUTER_UNCONFIGURED 0 |
d7c0a89a | 201 | uint8_t stub_router_admin_set; |
4ba4fc85 AB |
202 | #define OSPF_STUB_ROUTER_ADMINISTRATIVE_SET 1 |
203 | #define OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET 0 | |
88d6cf37 | 204 | |
b4154c14 JR |
205 | #define OSPF_STUB_MAX_METRIC_SUMMARY_COST 0x00ff0000 |
206 | ||
d62a17ae | 207 | /* LSA timers */ |
208 | unsigned int min_ls_interval; /* minimum delay between LSAs (in msec) */ | |
209 | unsigned int min_ls_arrival; /* minimum interarrival time between LSAs | |
210 | (in msec) */ | |
211 | ||
212 | /* SPF parameters */ | |
213 | unsigned int spf_delay; /* SPF delay time. */ | |
214 | unsigned int spf_holdtime; /* SPF hold time. */ | |
215 | unsigned int spf_max_holdtime; /* SPF maximum-holdtime */ | |
216 | unsigned int | |
217 | spf_hold_multiplier; /* Adaptive multiplier for hold time */ | |
218 | ||
219 | int default_originate; /* Default information originate. */ | |
718e3744 | 220 | #define DEFAULT_ORIGINATE_NONE 0 |
221 | #define DEFAULT_ORIGINATE_ZEBRA 1 | |
222 | #define DEFAULT_ORIGINATE_ALWAYS 2 | |
d7c0a89a | 223 | uint32_t ref_bandwidth; /* Reference Bandwidth (Kbps). */ |
d62a17ae | 224 | struct route_table *networks; /* OSPF config networks. */ |
225 | struct list *vlinks; /* Configured Virtual-Links. */ | |
226 | struct list *areas; /* OSPF areas. */ | |
227 | struct route_table *nbr_nbma; | |
228 | struct ospf_area *backbone; /* Pointer to the Backbone Area. */ | |
229 | ||
230 | struct list *oiflist; /* ospf interfaces */ | |
d7c0a89a | 231 | uint8_t passive_interface_default; /* passive-interface default */ |
d62a17ae | 232 | |
233 | /* LSDB of AS-external-LSAs. */ | |
234 | struct ospf_lsdb *lsdb; | |
235 | ||
236 | /* Flags. */ | |
d62a17ae | 237 | int ase_calc; /* ASE calculation flag. */ |
238 | ||
239 | struct list *opaque_lsa_self; /* Type-11 Opaque-LSAs */ | |
240 | ||
241 | /* Routing tables. */ | |
242 | struct route_table *old_table; /* Old routing table. */ | |
243 | struct route_table *new_table; /* Current routing table. */ | |
244 | ||
b538baf3 CH |
245 | struct route_table *oall_rtrs; /* Old router RT. */ |
246 | struct route_table *all_rtrs; /* New routers RT. */ | |
247 | ||
d62a17ae | 248 | struct route_table *old_rtrs; /* Old ABR/ASBR RT. */ |
249 | struct route_table *new_rtrs; /* New ABR/ASBR RT. */ | |
250 | ||
251 | struct route_table *new_external_route; /* New External Route. */ | |
252 | struct route_table *old_external_route; /* Old External Route. */ | |
253 | ||
254 | struct route_table *external_lsas; /* Database of external LSAs, | |
255 | prefix is LSA's adv. network*/ | |
256 | ||
257 | /* Time stamps */ | |
258 | struct timeval ts_spf; /* SPF calculation time stamp. */ | |
259 | struct timeval ts_spf_duration; /* Execution time of last SPF */ | |
260 | ||
261 | struct route_table *maxage_lsa; /* List of MaxAge LSA for deletion. */ | |
262 | int redistribute; /* Num of redistributed protocols. */ | |
263 | ||
264 | /* Threads. */ | |
e6685141 DS |
265 | struct event *t_abr_task; /* ABR task timer. */ |
266 | struct event *t_abr_fr; /* ABR FR timer. */ | |
267 | struct event *t_asbr_check; /* ASBR check timer. */ | |
268 | struct event *t_asbr_nssa_redist_update; /* ASBR NSSA redistribution | |
1c1c342d | 269 | update timer. */ |
e6685141 DS |
270 | struct event *t_distribute_update; /* Distirbute list update timer. */ |
271 | struct event *t_spf_calc; /* SPF calculation timer. */ | |
272 | struct event *t_ase_calc; /* ASE calculation timer. */ | |
273 | struct event *t_opaque_lsa_self; /* Type-11 Opaque-LSAs origin event. */ | |
274 | struct event *t_sr_update; /* Segment Routing update timer */ | |
d62a17ae | 275 | |
276 | unsigned int maxage_delay; /* Delay on Maxage remover timer, sec */ | |
e6685141 DS |
277 | struct event *t_maxage; /* MaxAge LSA remover timer. */ |
278 | struct event *t_maxage_walker; /* MaxAge LSA checking timer. */ | |
d62a17ae | 279 | |
e6685141 | 280 | struct event |
d62a17ae | 281 | *t_deferred_shutdown; /* deferred/stub-router shutdown timer*/ |
282 | ||
e6685141 | 283 | struct event *t_write; |
e8f45e82 | 284 | #define OSPF_WRITE_INTERFACE_COUNT_DEFAULT 20 |
e6685141 | 285 | struct event *t_default_routemap_timer; |
1febb13d | 286 | |
d62a17ae | 287 | int write_oi_count; /* Num of packets sent per thread invocation */ |
e6685141 | 288 | struct event *t_read; |
d62a17ae | 289 | int fd; |
290 | struct stream *ibuf; | |
291 | struct list *oi_write_q; | |
292 | ||
293 | /* Distribute lists out of other route sources. */ | |
294 | struct { | |
295 | char *name; | |
296 | struct access_list *list; | |
297 | } dlist[ZEBRA_ROUTE_MAX]; | |
020709f9 | 298 | #define DISTRIBUTE_NAME(O,T) (O)->dlist[T].name |
299 | #define DISTRIBUTE_LIST(O,T) (O)->dlist[T].list | |
718e3744 | 300 | |
d62a17ae | 301 | /* OSPF redistribute configuration */ |
302 | struct list *redist[ZEBRA_ROUTE_MAX + 1]; | |
718e3744 | 303 | |
d62a17ae | 304 | /* Redistribute tag info. */ |
305 | route_tag_t | |
306 | dtag[ZEBRA_ROUTE_MAX + 1]; // Pending: cant configure as of now | |
0d9551dc | 307 | |
d62a17ae | 308 | int default_metric; /* Default metric for redistribute. */ |
718e3744 | 309 | |
017714e3 RW |
310 | /* NSSA default-information-originate */ |
311 | struct { | |
312 | /* # of NSSA areas requesting default information */ | |
313 | uint16_t refcnt; | |
314 | ||
315 | /* | |
316 | * Whether a default route known through non-OSPF protocol is | |
317 | * present in the RIB. | |
318 | */ | |
319 | bool status; | |
320 | } nssa_default_import_check; | |
321 | ||
718e3744 | 322 | #define OSPF_LSA_REFRESHER_GRANULARITY 10 |
d62a17ae | 323 | #define OSPF_LSA_REFRESHER_SLOTS \ |
324 | ((OSPF_LS_REFRESH_TIME + OSPF_LS_REFRESH_SHIFT) \ | |
325 | / OSPF_LSA_REFRESHER_GRANULARITY \ | |
326 | + 1) | |
327 | struct { | |
d7c0a89a | 328 | uint16_t index; |
d62a17ae | 329 | struct list *qs[OSPF_LSA_REFRESHER_SLOTS]; |
330 | } lsa_refresh_queue; | |
331 | ||
e6685141 | 332 | struct event *t_lsa_refresher; |
d62a17ae | 333 | time_t lsa_refresher_started; |
718e3744 | 334 | #define OSPF_LSA_REFRESH_INTERVAL_DEFAULT 10 |
d7c0a89a | 335 | uint16_t lsa_refresh_interval; |
b345a3d9 | 336 | uint16_t lsa_refresh_timer; |
d62a17ae | 337 | |
338 | /* Distance parameter. */ | |
d7c0a89a QY |
339 | uint8_t distance_all; |
340 | uint8_t distance_intra; | |
341 | uint8_t distance_inter; | |
342 | uint8_t distance_external; | |
d62a17ae | 343 | |
344 | /* Statistics for LSA origination. */ | |
d7c0a89a | 345 | uint32_t lsa_originate_count; |
d62a17ae | 346 | |
347 | /* Statistics for LSA used for new instantiation. */ | |
d7c0a89a | 348 | uint32_t rx_lsa_count; |
d62a17ae | 349 | |
d62a17ae | 350 | struct route_table *distance_table; |
351 | ||
046460a1 CS |
352 | /* Used during ospf instance going down send LSDB |
353 | * update to neighbors immediatly */ | |
354 | uint8_t inst_shutdown; | |
355 | ||
a92706bb JU |
356 | /* Enable or disable sending proactive ARP requests. */ |
357 | bool proactive_arp; | |
358 | #define OSPF_PROACTIVE_ARP_DEFAULT true | |
359 | ||
de1ac5fd CS |
360 | /* Redistributed external information. */ |
361 | struct list *external[ZEBRA_ROUTE_MAX + 1]; | |
f96f2713 | 362 | #define EXTERNAL_INFO(E) (E->external_info) |
363 | ||
17be83bf | 364 | /* Graceful restart Helper supported configs*/ |
f96f2713 | 365 | /* Supported grace interval*/ |
366 | uint32_t supported_grace_time; | |
367 | ||
368 | /* Helper support | |
369 | * Supported : True | |
370 | * Not Supported : False. | |
371 | */ | |
372 | bool is_helper_supported; | |
373 | ||
374 | /* Support for strict LSA check. | |
375 | * if it is set,Helper aborted | |
376 | * upon a TOPO change. | |
377 | */ | |
378 | bool strict_lsa_check; | |
379 | ||
380 | /* Support as HELPER only for | |
381 | * planned restarts. | |
382 | */ | |
383 | bool only_planned_restart; | |
384 | ||
385 | /* This list contains the advertisement | |
386 | * routerids which are not support for HELPERs. | |
387 | */ | |
388 | struct hash *enable_rtr_list; | |
389 | ||
390 | /* HELPER for number of active | |
391 | * RESTARTERs. | |
392 | */ | |
393 | uint16_t active_restarter_cnt; | |
394 | ||
395 | /* last HELPER exit reason */ | |
396 | uint32_t last_exit_reason; | |
de1ac5fd | 397 | |
cb2bc4cb | 398 | /* delay timer to process external routes |
399 | * with summary address. | |
400 | */ | |
e6685141 | 401 | struct event *t_external_aggr; |
cb2bc4cb | 402 | |
403 | /* delay interval in seconds */ | |
4b939ad2 | 404 | uint16_t aggr_delay_interval; |
cb2bc4cb | 405 | |
406 | /* Table of configured Aggregate addresses */ | |
407 | struct route_table *rt_aggr_tbl; | |
408 | ||
409 | /* used as argument for aggr delay | |
410 | * timer thread. | |
411 | */ | |
412 | int aggr_action; | |
413 | ||
3d5b9855 | 414 | /* Max number of multiple paths |
415 | * to support ECMP. | |
416 | */ | |
417 | uint16_t max_multipath; | |
418 | ||
132a782e | 419 | /* MPLS LDP-IGP Sync */ |
420 | struct ldp_sync_info_cmd ldp_sync_cmd; | |
421 | ||
10514170 RW |
422 | /* OSPF Graceful Restart info */ |
423 | struct ospf_gr_info gr_info; | |
424 | ||
7fd0729f G |
425 | /* TI-LFA support for all interfaces. */ |
426 | bool ti_lfa_enabled; | |
385a1e07 | 427 | enum protection_type ti_lfa_protection_type; |
7fd0729f | 428 | |
6f7bbc0c MN |
429 | /* Flood Reduction configuration state */ |
430 | bool fr_configured; | |
431 | ||
6e6e1020 MS |
432 | /* Socket buffer sizes */ |
433 | uint32_t recv_sock_bufsize; | |
434 | uint32_t send_sock_bufsize; | |
435 | ||
04a0401f MS |
436 | /* Per-interface write socket */ |
437 | bool intf_socket_enabled; | |
438 | ||
96244aca | 439 | QOBJ_FIELDS; |
718e3744 | 440 | }; |
96244aca | 441 | DECLARE_QOBJ_TYPE(ospf); |
718e3744 | 442 | |
bdcfd34a G |
443 | enum ospf_ti_lfa_p_q_space_adjacency { |
444 | OSPF_TI_LFA_P_Q_SPACE_ADJACENT, | |
445 | OSPF_TI_LFA_P_Q_SPACE_NON_ADJACENT, | |
446 | }; | |
447 | ||
7fd0729f G |
448 | enum ospf_ti_lfa_node_type { |
449 | OSPF_TI_LFA_UNDEFINED_NODE, | |
450 | OSPF_TI_LFA_PQ_NODE, | |
451 | OSPF_TI_LFA_P_NODE, | |
452 | OSPF_TI_LFA_Q_NODE, | |
453 | }; | |
454 | ||
455 | struct ospf_ti_lfa_node_info { | |
456 | struct vertex *node; | |
457 | enum ospf_ti_lfa_node_type type; | |
458 | struct in_addr nexthop; | |
459 | }; | |
460 | ||
bdcfd34a G |
461 | struct ospf_ti_lfa_inner_backup_path_info { |
462 | struct ospf_ti_lfa_node_info p_node_info; | |
463 | struct ospf_ti_lfa_node_info q_node_info; | |
464 | struct mpls_label_stack *label_stack; | |
465 | }; | |
466 | ||
385a1e07 G |
467 | struct protected_resource { |
468 | enum protection_type type; | |
469 | ||
470 | /* Link Protection */ | |
471 | struct router_lsa_link *link; | |
472 | ||
473 | /* Node Protection */ | |
474 | struct in_addr router_id; | |
475 | }; | |
476 | ||
960b9a53 | 477 | PREDECL_RBTREE_UNIQ(q_spaces); |
7fd0729f G |
478 | struct q_space { |
479 | struct vertex *root; | |
480 | struct list *vertex_list; | |
481 | struct mpls_label_stack *label_stack; | |
482 | struct in_addr nexthop; | |
9d3444f8 | 483 | struct list *pc_path; |
bdcfd34a G |
484 | struct ospf_ti_lfa_node_info *p_node_info; |
485 | struct ospf_ti_lfa_node_info *q_node_info; | |
7fd0729f G |
486 | struct q_spaces_item q_spaces_item; |
487 | }; | |
488 | ||
960b9a53 | 489 | PREDECL_RBTREE_UNIQ(p_spaces); |
7fd0729f G |
490 | struct p_space { |
491 | struct vertex *root; | |
385a1e07 | 492 | struct protected_resource *protected_resource; |
7fd0729f G |
493 | struct q_spaces_head *q_spaces; |
494 | struct list *vertex_list; | |
495 | struct vertex *pc_spf; | |
496 | struct list *pc_vertex_list; | |
497 | struct p_spaces_item p_spaces_item; | |
498 | }; | |
499 | ||
718e3744 | 500 | /* OSPF area structure. */ |
d62a17ae | 501 | struct ospf_area { |
502 | /* OSPF instance. */ | |
503 | struct ospf *ospf; | |
718e3744 | 504 | |
d62a17ae | 505 | /* Zebra interface list belonging to the area. */ |
506 | struct list *oiflist; | |
718e3744 | 507 | |
d62a17ae | 508 | /* Area ID. */ |
509 | struct in_addr area_id; | |
718e3744 | 510 | |
d62a17ae | 511 | /* Area ID format. */ |
512 | int area_id_fmt; | |
86573dcb QY |
513 | #define OSPF_AREA_ID_FMT_DOTTEDQUAD 1 |
514 | #define OSPF_AREA_ID_FMT_DECIMAL 2 | |
718e3744 | 515 | |
d62a17ae | 516 | /* Address range. */ |
517 | struct list *address_range; | |
718e3744 | 518 | |
d62a17ae | 519 | /* Configured variables. */ |
520 | int external_routing; /* ExternalRoutingCapability. */ | |
521 | int no_summary; /* Don't inject summaries into stub.*/ | |
522 | int shortcut_configured; /* Area configured as shortcut. */ | |
718e3744 | 523 | #define OSPF_SHORTCUT_DEFAULT 0 |
524 | #define OSPF_SHORTCUT_ENABLE 1 | |
525 | #define OSPF_SHORTCUT_DISABLE 2 | |
d62a17ae | 526 | int shortcut_capability; /* Other ABRs agree on S-bit */ |
d7c0a89a | 527 | uint32_t default_cost; /* StubDefaultCost. */ |
d62a17ae | 528 | int auth_type; /* Authentication type. */ |
c317eddb | 529 | int suppress_fa; /* Suppress forwarding address in NSSA ABR */ |
d62a17ae | 530 | |
d7c0a89a | 531 | uint8_t NSSATranslatorRole; /* NSSA configured role */ |
718e3744 | 532 | #define OSPF_NSSA_ROLE_NEVER 0 |
d4a53d58 | 533 | #define OSPF_NSSA_ROLE_CANDIDATE 1 |
534 | #define OSPF_NSSA_ROLE_ALWAYS 2 | |
d7c0a89a | 535 | uint8_t NSSATranslatorState; /* NSSA operational role */ |
d4a53d58 | 536 | #define OSPF_NSSA_TRANSLATE_DISABLED 0 |
537 | #define OSPF_NSSA_TRANSLATE_ENABLED 1 | |
d62a17ae | 538 | int NSSATranslatorStabilityInterval; |
539 | ||
d7c0a89a | 540 | uint8_t transit; /* TransitCapability. */ |
718e3744 | 541 | #define OSPF_TRANSIT_FALSE 0 |
542 | #define OSPF_TRANSIT_TRUE 1 | |
d62a17ae | 543 | struct route_table *ranges; /* Configured Area Ranges. */ |
f07ff222 | 544 | struct route_table *nssa_ranges; /* Configured NSSA Area Ranges. */ |
d62a17ae | 545 | |
546 | /* RFC3137 stub router state flags for area */ | |
d7c0a89a | 547 | uint8_t stub_router_state; |
88d6cf37 | 548 | #define OSPF_AREA_ADMIN_STUB_ROUTED (1 << 0) /* admin stub-router set */ |
549 | #define OSPF_AREA_IS_STUB_ROUTED (1 << 1) /* stub-router active */ | |
550 | #define OSPF_AREA_WAS_START_STUB_ROUTED (1 << 2) /* startup SR was done */ | |
d62a17ae | 551 | /* Area related LSDBs[Type1-4]. */ |
552 | struct ospf_lsdb *lsdb; | |
553 | ||
554 | /* Self-originated LSAs. */ | |
555 | struct ospf_lsa *router_lsa_self; | |
556 | struct list *opaque_lsa_self; /* Type-10 Opaque-LSAs */ | |
557 | ||
558 | /* Area announce list. */ | |
559 | struct { | |
560 | char *name; | |
561 | struct access_list *list; | |
562 | } _export; | |
dea04441 PJ |
563 | #define EXPORT_NAME(A) (A)->_export.name |
564 | #define EXPORT_LIST(A) (A)->_export.list | |
718e3744 | 565 | |
d62a17ae | 566 | /* Area acceptance list. */ |
567 | struct { | |
568 | char *name; | |
569 | struct access_list *list; | |
570 | } import; | |
718e3744 | 571 | #define IMPORT_NAME(A) (A)->import.name |
572 | #define IMPORT_LIST(A) (A)->import.list | |
573 | ||
d62a17ae | 574 | /* Type 3 LSA Area prefix-list. */ |
575 | struct { | |
576 | char *name; | |
577 | struct prefix_list *list; | |
578 | } plist_in; | |
718e3744 | 579 | #define PREFIX_LIST_IN(A) (A)->plist_in.list |
580 | #define PREFIX_NAME_IN(A) (A)->plist_in.name | |
581 | ||
d62a17ae | 582 | struct { |
583 | char *name; | |
584 | struct prefix_list *list; | |
585 | } plist_out; | |
718e3744 | 586 | #define PREFIX_LIST_OUT(A) (A)->plist_out.list |
587 | #define PREFIX_NAME_OUT(A) (A)->plist_out.name | |
588 | ||
017714e3 RW |
589 | /* NSSA default-information-originate */ |
590 | struct { | |
591 | bool enabled; | |
592 | int metric_type; | |
593 | int metric_value; | |
594 | } nssa_default_originate; | |
595 | ||
d62a17ae | 596 | /* Shortest Path Tree. */ |
597 | struct vertex *spf; | |
81443a28 G |
598 | struct list *spf_vertex_list; |
599 | ||
6fc9528e G |
600 | bool spf_dry_run; /* flag for checking if the SPF calculation is |
601 | intended for the local RIB */ | |
602 | bool spf_root_node; /* flag for checking if the calculating node is the | |
603 | root node of the SPF tree */ | |
718e3744 | 604 | |
7fd0729f | 605 | /* TI-LFA protected link for SPF calculations */ |
385a1e07 | 606 | struct protected_resource *spf_protected_resource; |
7fd0729f G |
607 | |
608 | /* P/Q spaces for TI-LFA */ | |
609 | struct p_spaces_head *p_spaces; | |
610 | ||
d62a17ae | 611 | /* Threads. */ |
e6685141 DS |
612 | struct event *t_stub_router; /* Stub-router timer */ |
613 | struct event *t_opaque_lsa_self; /* Type-10 Opaque-LSAs origin. */ | |
718e3744 | 614 | |
d62a17ae | 615 | /* Statistics field. */ |
d7c0a89a | 616 | uint32_t spf_calculation; /* SPF Calculation Count. */ |
718e3744 | 617 | |
133e59cf G |
618 | /* reverse SPF (used for TI-LFA Q spaces) */ |
619 | bool spf_reversed; | |
620 | ||
d62a17ae | 621 | /* Time stamps. */ |
622 | struct timeval ts_spf; /* SPF calculation time stamp. */ | |
cf744958 | 623 | |
d62a17ae | 624 | /* Router count. */ |
d7c0a89a QY |
625 | uint32_t abr_count; /* ABR router in this area. */ |
626 | uint32_t asbr_count; /* ASBR router in this area. */ | |
718e3744 | 627 | |
d62a17ae | 628 | /* Counters. */ |
d7c0a89a QY |
629 | uint32_t act_ints; /* Active interfaces. */ |
630 | uint32_t full_nbrs; /* Fully adjacent neighbors. */ | |
631 | uint32_t full_vls; /* Fully adjacent virtual neighbors. */ | |
6f7bbc0c MN |
632 | |
633 | struct ospf_area_fr_info fr_info; /* Flood reduction info. */ | |
718e3744 | 634 | }; |
635 | ||
636 | /* OSPF config network structure. */ | |
d62a17ae | 637 | struct ospf_network { |
638 | /* Area ID. */ | |
639 | struct in_addr area_id; | |
640 | int area_id_fmt; | |
718e3744 | 641 | }; |
642 | ||
643 | /* OSPF NBMA neighbor structure. */ | |
d62a17ae | 644 | struct ospf_nbr_nbma { |
645 | /* Neighbor IP address. */ | |
646 | struct in_addr addr; | |
718e3744 | 647 | |
d62a17ae | 648 | /* OSPF interface. */ |
649 | struct ospf_interface *oi; | |
718e3744 | 650 | |
d62a17ae | 651 | /* OSPF neighbor structure. */ |
652 | struct ospf_neighbor *nbr; | |
718e3744 | 653 | |
d62a17ae | 654 | /* Neighbor priority. */ |
d7c0a89a | 655 | uint8_t priority; |
718e3744 | 656 | |
d62a17ae | 657 | /* Poll timer value. */ |
d7c0a89a | 658 | uint32_t v_poll; |
718e3744 | 659 | |
d62a17ae | 660 | /* Poll timer thread. */ |
e6685141 | 661 | struct event *t_poll; |
718e3744 | 662 | |
d62a17ae | 663 | /* State change. */ |
d7c0a89a | 664 | uint32_t state_change; |
718e3744 | 665 | }; |
666 | ||
667 | /* Macro. */ | |
d62a17ae | 668 | #define OSPF_AREA_SAME(X, Y) \ |
669 | (memcmp((X->area_id), (Y->area_id), IPV4_MAX_BYTELEN) == 0) | |
718e3744 | 670 | |
020709f9 | 671 | #define IS_OSPF_ABR(O) ((O)->flags & OSPF_FLAG_ABR) |
672 | #define IS_OSPF_ASBR(O) ((O)->flags & OSPF_FLAG_ASBR) | |
718e3744 | 673 | |
674 | #define OSPF_IS_AREA_ID_BACKBONE(I) ((I).s_addr == OSPF_AREA_BACKBONE) | |
675 | #define OSPF_IS_AREA_BACKBONE(A) OSPF_IS_AREA_ID_BACKBONE ((A)->area_id) | |
676 | ||
677 | #ifdef roundup | |
678 | # define ROUNDUP(val, gran) roundup(val, gran) | |
d62a17ae | 679 | #else /* roundup */ |
718e3744 | 680 | # define ROUNDUP(val, gran) (((val) - 1 | (gran) - 1) + 1) |
681 | #endif /* roundup */ | |
682 | ||
d62a17ae | 683 | #define LSA_OPTIONS_GET(area) \ |
684 | (((area)->external_routing == OSPF_AREA_DEFAULT) ? OSPF_OPTION_E : 0) | |
685 | #define LSA_OPTIONS_NSSA_GET(area) \ | |
686 | (((area)->external_routing == OSPF_AREA_NSSA) ? OSPF_OPTION_NP : 0) | |
718e3744 | 687 | |
907a2395 DS |
688 | #define OSPF_TIMER_ON(T, F, V) event_add_timer(master, (F), ospf, (V), &(T)) |
689 | #define OSPF_AREA_TIMER_ON(T, F, V) \ | |
690 | event_add_timer(master, (F), area, (V), &(T)) | |
691 | #define OSPF_POLL_TIMER_ON(T, F, V) \ | |
692 | event_add_timer(master, (F), nbr_nbma, (V), &(T)) | |
718e3744 | 693 | |
020709f9 | 694 | /* Extern variables. */ |
695 | extern struct ospf_master *om; | |
409f98ab | 696 | extern unsigned short ospf_instance; |
7ba82f70 | 697 | extern const int ospf_redistributed_proto_max; |
718e3744 | 698 | extern struct zclient *zclient; |
cd9d0537 | 699 | extern struct event_loop *master; |
718e3744 | 700 | extern int ospf_zlog; |
e5c25022 | 701 | extern struct zebra_privs_t ospfd_privs; |
718e3744 | 702 | |
703 | /* Prototypes. */ | |
d7c0a89a | 704 | extern const char *ospf_redist_string(unsigned int route_type); |
2d4093ee | 705 | extern struct ospf *ospf_lookup_instance(unsigned short instance); |
409f98ab | 706 | extern struct ospf *ospf_lookup(unsigned short instance, const char *name); |
c572fbfe DL |
707 | extern struct ospf *ospf_get(unsigned short instance, const char *name, |
708 | bool *created); | |
7fd0729f | 709 | extern struct ospf *ospf_new_alloc(unsigned short instance, const char *name); |
d7c0a89a | 710 | extern struct ospf *ospf_lookup_by_inst_name(unsigned short instance, |
b5a8894d CS |
711 | const char *name); |
712 | extern struct ospf *ospf_lookup_by_vrf_id(vrf_id_t vrf_id); | |
cbf32f74 | 713 | extern uint32_t ospf_count_area_params(struct ospf *ospf); |
2d4093ee | 714 | extern void ospf_finish(struct ospf *ospf); |
f91ce319 | 715 | extern void ospf_process_refresh_data(struct ospf *ospf, bool reset); |
d62a17ae | 716 | extern void ospf_router_id_update(struct ospf *ospf); |
f91ce319 MR |
717 | extern void ospf_process_reset(struct ospf *ospf); |
718 | extern void ospf_neighbor_reset(struct ospf *ospf, struct in_addr nbr_id, | |
719 | const char *nbr_str); | |
2d4093ee DS |
720 | extern int ospf_network_set(struct ospf *ospf, struct prefix_ipv4 *p, |
721 | struct in_addr area_id, int df); | |
722 | extern int ospf_network_unset(struct ospf *ospf, struct prefix_ipv4 *p, | |
723 | struct in_addr aread_id); | |
724 | extern int ospf_area_display_format_set(struct ospf *ospf, | |
725 | struct ospf_area *area, int df); | |
726 | extern int ospf_area_stub_set(struct ospf *ospf, struct in_addr area_id); | |
727 | extern int ospf_area_stub_unset(struct ospf *ospf, struct in_addr area_id); | |
728 | extern int ospf_area_no_summary_set(struct ospf *ospf, struct in_addr area_id); | |
729 | extern int ospf_area_no_summary_unset(struct ospf *ospf, | |
730 | struct in_addr area_id); | |
731 | extern int ospf_area_nssa_set(struct ospf *ospf, struct in_addr area_id); | |
e85194f5 | 732 | extern int ospf_area_nssa_unset(struct ospf *ospf, struct in_addr area_id); |
c317eddb | 733 | extern int ospf_area_nssa_suppress_fa_set(struct ospf *ospf, |
734 | struct in_addr area_id); | |
735 | extern int ospf_area_nssa_suppress_fa_unset(struct ospf *ospf, | |
736 | struct in_addr area_id); | |
2d4093ee DS |
737 | extern int ospf_area_nssa_translator_role_set(struct ospf *ospf, |
738 | struct in_addr area_id, int role); | |
017714e3 RW |
739 | extern void ospf_area_nssa_default_originate_set(struct ospf *ospf, |
740 | struct in_addr area_id, | |
741 | int metric, int metric_type); | |
742 | extern void ospf_area_nssa_default_originate_unset(struct ospf *ospf, | |
743 | struct in_addr area_id); | |
2d4093ee DS |
744 | extern int ospf_area_export_list_set(struct ospf *ospf, |
745 | struct ospf_area *area_id, | |
746 | const char *list_name); | |
747 | extern int ospf_area_export_list_unset(struct ospf *ospf, | |
748 | struct ospf_area *area_id); | |
749 | extern int ospf_area_import_list_set(struct ospf *ospf, | |
750 | struct ospf_area *area_id, | |
751 | const char *name); | |
752 | extern int ospf_area_import_list_unset(struct ospf *ospf, | |
753 | struct ospf_area *area_id); | |
754 | extern int ospf_area_shortcut_set(struct ospf *ospf, struct ospf_area *area_id, | |
755 | int mode); | |
756 | extern int ospf_area_shortcut_unset(struct ospf *ospf, | |
757 | struct ospf_area *area_id); | |
758 | extern int ospf_timers_refresh_set(struct ospf *ospf, int interval); | |
759 | extern int ospf_timers_refresh_unset(struct ospf *ospf); | |
f91ce319 | 760 | void ospf_area_lsdb_discard_delete(struct ospf_area *area); |
2d4093ee DS |
761 | extern int ospf_nbr_nbma_set(struct ospf *ospf, struct in_addr nbr_addr); |
762 | extern int ospf_nbr_nbma_unset(struct ospf *ospf, struct in_addr nbr_addr); | |
763 | extern int ospf_nbr_nbma_priority_set(struct ospf *ospf, | |
764 | struct in_addr nbr_addr, | |
765 | uint8_t priority); | |
766 | extern int ospf_nbr_nbma_priority_unset(struct ospf *ospf, | |
767 | struct in_addr nbr_addr); | |
768 | extern int ospf_nbr_nbma_poll_interval_set(struct ospf *ospf, | |
769 | struct in_addr nbr_addr, | |
770 | unsigned int interval); | |
771 | extern int ospf_nbr_nbma_poll_interval_unset(struct ospf *ospf, | |
772 | struct in_addr addr); | |
773 | extern void ospf_if_update(struct ospf *ospf, struct interface *ifp); | |
774 | extern void ospf_ls_upd_queue_empty(struct ospf_interface *oi); | |
d62a17ae | 775 | extern void ospf_terminate(void); |
2d4093ee DS |
776 | extern void ospf_nbr_nbma_if_update(struct ospf *ospf, |
777 | struct ospf_interface *oi); | |
778 | extern struct ospf_nbr_nbma *ospf_nbr_nbma_lookup(struct ospf *ospf, | |
779 | struct in_addr nbr_addr); | |
780 | extern int ospf_oi_count(struct interface *ifp); | |
d62a17ae | 781 | |
7fd0729f G |
782 | extern struct ospf_area *ospf_area_new(struct ospf *ospf, |
783 | struct in_addr area_id); | |
2d4093ee DS |
784 | extern struct ospf_area *ospf_area_get(struct ospf *ospf, |
785 | struct in_addr area_id); | |
786 | extern void ospf_area_check_free(struct ospf *ospf, struct in_addr area_id); | |
787 | extern struct ospf_area *ospf_area_lookup_by_area_id(struct ospf *ospf, | |
788 | struct in_addr area_id); | |
789 | extern void ospf_area_add_if(struct ospf_area *oa, struct ospf_interface *oi); | |
790 | extern void ospf_area_del_if(struct ospf_area *oa, struct ospf_interface *oi); | |
d62a17ae | 791 | |
2d4093ee DS |
792 | extern void ospf_interface_area_set(struct ospf *ospf, struct interface *ifp); |
793 | extern void ospf_interface_area_unset(struct ospf *ospf, struct interface *ifp); | |
d62a17ae | 794 | |
795 | extern void ospf_route_map_init(void); | |
796 | ||
cd9d0537 | 797 | extern void ospf_master_init(struct event_loop *master); |
b5a8894d CS |
798 | extern void ospf_vrf_init(void); |
799 | extern void ospf_vrf_terminate(void); | |
800 | extern void ospf_vrf_link(struct ospf *ospf, struct vrf *vrf); | |
801 | extern void ospf_vrf_unlink(struct ospf *ospf, struct vrf *vrf); | |
802 | const char *ospf_vrf_id_to_name(vrf_id_t vrf_id); | |
2d4093ee | 803 | int ospf_area_nssa_no_summary_set(struct ospf *ospf, struct in_addr area_id); |
7ef56a73 | 804 | |
88b6b28e | 805 | const char *ospf_get_name(const struct ospf *ospf); |
7fd0729f G |
806 | extern struct ospf_interface *add_ospf_interface(struct connected *co, |
807 | struct ospf_area *area); | |
6e6e1020 MS |
808 | /* Update socket bufsize(s), after config change */ |
809 | void ospf_update_bufsize(struct ospf *ospf, uint32_t recvsize, | |
810 | uint32_t sendsize); | |
7fd0729f G |
811 | |
812 | extern int p_spaces_compare_func(const struct p_space *a, | |
813 | const struct p_space *b); | |
814 | extern int q_spaces_compare_func(const struct q_space *a, | |
815 | const struct q_space *b); | |
a623b526 | 816 | |
718e3744 | 817 | #endif /* _ZEBRA_OSPFD_H */ |