]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* |
2 | * OSPF Flooding -- RFC2328 Section 13. | |
3 | * Copyright (C) 1999, 2000 Toshiaki Takada | |
4 | * | |
5 | * This file is part of GNU Zebra. | |
896014f4 | 6 | * |
718e3744 | 7 | * GNU Zebra is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published | |
9 | * by the Free Software Foundation; either version 2, or (at your | |
10 | * option) any later version. | |
11 | * | |
12 | * GNU Zebra is distributed in the hope that it will be useful, but | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
896014f4 DL |
17 | * You should have received a copy of the GNU General Public License along |
18 | * with this program; see the file COPYING; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
718e3744 | 20 | */ |
21 | ||
22 | #include <zebra.h> | |
23 | ||
cbf3e3eb | 24 | #include "monotime.h" |
718e3744 | 25 | #include "linklist.h" |
26 | #include "prefix.h" | |
27 | #include "if.h" | |
28 | #include "command.h" | |
29 | #include "table.h" | |
30 | #include "thread.h" | |
31 | #include "memory.h" | |
32 | #include "log.h" | |
33 | #include "zclient.h" | |
34 | ||
35 | #include "ospfd/ospfd.h" | |
36 | #include "ospfd/ospf_interface.h" | |
37 | #include "ospfd/ospf_ism.h" | |
38 | #include "ospfd/ospf_asbr.h" | |
39 | #include "ospfd/ospf_lsa.h" | |
40 | #include "ospfd/ospf_lsdb.h" | |
41 | #include "ospfd/ospf_neighbor.h" | |
42 | #include "ospfd/ospf_nsm.h" | |
43 | #include "ospfd/ospf_spf.h" | |
44 | #include "ospfd/ospf_flood.h" | |
45 | #include "ospfd/ospf_packet.h" | |
46 | #include "ospfd/ospf_abr.h" | |
47 | #include "ospfd/ospf_route.h" | |
48 | #include "ospfd/ospf_zebra.h" | |
49 | #include "ospfd/ospf_dump.h" | |
50 | ||
51 | extern struct zclient *zclient; | |
6b0655a2 | 52 | |
718e3744 | 53 | /* Do the LSA acking specified in table 19, Section 13.5, row 2 |
d62a17ae | 54 | * This get called from ospf_flood_out_interface. Declared inline |
718e3744 | 55 | * for speed. */ |
d62a17ae | 56 | static void ospf_flood_delayed_lsa_ack(struct ospf_neighbor *inbr, |
57 | struct ospf_lsa *lsa) | |
718e3744 | 58 | { |
d62a17ae | 59 | /* LSA is more recent than database copy, but was not |
60 | flooded back out receiving interface. Delayed | |
61 | acknowledgment sent. If interface is in Backup state | |
62 | delayed acknowledgment sent only if advertisement | |
63 | received from Designated Router, otherwise do nothing See | |
64 | RFC 2328 Section 13.5 */ | |
65 | ||
66 | /* Whether LSA is more recent or not, and whether this is in | |
67 | response to the LSA being sent out recieving interface has been | |
68 | worked out previously */ | |
69 | ||
70 | /* Deal with router as BDR */ | |
71 | if (inbr->oi->state == ISM_Backup && !NBR_IS_DR(inbr)) | |
72 | return; | |
73 | ||
74 | /* Schedule a delayed LSA Ack to be sent */ | |
75 | listnode_add(inbr->oi->ls_ack, | |
76 | ospf_lsa_lock(lsa)); /* delayed LSA Ack */ | |
718e3744 | 77 | } |
78 | ||
79 | /* Check LSA is related to external info. */ | |
b5a8894d CS |
80 | struct external_info *ospf_external_info_check(struct ospf *ospf, |
81 | struct ospf_lsa *lsa) | |
718e3744 | 82 | { |
d62a17ae | 83 | struct as_external_lsa *al; |
84 | struct prefix_ipv4 p; | |
85 | struct route_node *rn; | |
86 | int type; | |
87 | ||
88 | al = (struct as_external_lsa *)lsa->data; | |
89 | ||
90 | p.family = AF_INET; | |
91 | p.prefix = lsa->data->id; | |
92 | p.prefixlen = ip_masklen(al->mask); | |
93 | ||
a6b4e1fd | 94 | for (type = 0; type <= ZEBRA_ROUTE_MAX; type++) { |
d62a17ae | 95 | int redist_on = 0; |
96 | ||
97 | redist_on = | |
98 | is_prefix_default(&p) | |
99 | ? vrf_bitmap_check(zclient->default_information, | |
b5a8894d | 100 | ospf->vrf_id) |
d62a17ae | 101 | : (zclient->mi_redist[AFI_IP][type].enabled |
102 | || vrf_bitmap_check( | |
103 | zclient->redist[AFI_IP][type], | |
b5a8894d | 104 | ospf->vrf_id)); |
d62a17ae | 105 | // Pending: check for MI above. |
106 | if (redist_on) { | |
107 | struct list *ext_list; | |
108 | struct listnode *node; | |
109 | struct ospf_external *ext; | |
110 | ||
de1ac5fd | 111 | ext_list = ospf->external[type]; |
d62a17ae | 112 | if (!ext_list) |
113 | continue; | |
114 | ||
115 | for (ALL_LIST_ELEMENTS_RO(ext_list, node, ext)) { | |
116 | rn = NULL; | |
117 | if (ext->external_info) | |
118 | rn = route_node_lookup( | |
119 | ext->external_info, | |
120 | (struct prefix *)&p); | |
121 | if (rn) { | |
122 | route_unlock_node(rn); | |
123 | if (rn->info != NULL) | |
124 | return (struct external_info *) | |
125 | rn->info; | |
126 | } | |
127 | } | |
128 | } | |
129 | } | |
130 | ||
131 | return NULL; | |
718e3744 | 132 | } |
133 | ||
d62a17ae | 134 | static void ospf_process_self_originated_lsa(struct ospf *ospf, |
135 | struct ospf_lsa *new, | |
136 | struct ospf_area *area) | |
718e3744 | 137 | { |
d62a17ae | 138 | struct ospf_interface *oi; |
139 | struct external_info *ei; | |
140 | struct listnode *node; | |
141 | ||
142 | if (IS_DEBUG_OSPF_EVENT) | |
143 | zlog_debug( | |
144 | "LSA[Type%d:%s]: Process self-originated LSA seq 0x%x", | |
145 | new->data->type, inet_ntoa(new->data->id), | |
146 | ntohl(new->data->ls_seqnum)); | |
147 | ||
148 | /* If we're here, we installed a self-originated LSA that we received | |
149 | from a neighbor, i.e. it's more recent. We must see whether we want | |
150 | to originate it. | |
151 | If yes, we should use this LSA's sequence number and reoriginate | |
152 | a new instance. | |
153 | if not --- we must flush this LSA from the domain. */ | |
154 | switch (new->data->type) { | |
155 | case OSPF_ROUTER_LSA: | |
156 | /* Originate a new instance and schedule flooding */ | |
157 | if (area->router_lsa_self) | |
158 | area->router_lsa_self->data->ls_seqnum = | |
159 | new->data->ls_seqnum; | |
160 | ospf_router_lsa_update_area(area); | |
161 | return; | |
162 | case OSPF_NETWORK_LSA: | |
163 | case OSPF_OPAQUE_LINK_LSA: | |
164 | /* We must find the interface the LSA could belong to. | |
165 | If the interface is no more a broadcast type or we are no | |
166 | more | |
167 | the DR, we flush the LSA otherwise -- create the new instance | |
168 | and | |
169 | schedule flooding. */ | |
170 | ||
171 | /* Look through all interfaces, not just area, since interface | |
172 | could be moved from one area to another. */ | |
173 | for (ALL_LIST_ELEMENTS_RO(ospf->oiflist, node, oi)) | |
174 | /* These are sanity check. */ | |
175 | if (IPV4_ADDR_SAME(&oi->address->u.prefix4, | |
176 | &new->data->id)) { | |
177 | if (oi->area != area | |
178 | || oi->type != OSPF_IFTYPE_BROADCAST | |
179 | || !IPV4_ADDR_SAME(&oi->address->u.prefix4, | |
180 | &DR(oi))) { | |
181 | ospf_schedule_lsa_flush_area(area, new); | |
182 | return; | |
183 | } | |
184 | ||
185 | if (new->data->type == OSPF_OPAQUE_LINK_LSA) { | |
186 | ospf_opaque_lsa_refresh(new); | |
187 | return; | |
188 | } | |
189 | ||
190 | if (oi->network_lsa_self) | |
191 | oi->network_lsa_self->data->ls_seqnum = | |
192 | new->data->ls_seqnum; | |
193 | /* Schedule network-LSA origination. */ | |
194 | ospf_network_lsa_update(oi); | |
195 | return; | |
196 | } | |
197 | break; | |
198 | case OSPF_SUMMARY_LSA: | |
199 | case OSPF_ASBR_SUMMARY_LSA: | |
200 | ospf_schedule_abr_task(ospf); | |
201 | break; | |
202 | case OSPF_AS_EXTERNAL_LSA: | |
203 | case OSPF_AS_NSSA_LSA: | |
204 | if ((new->data->type == OSPF_AS_EXTERNAL_LSA) | |
205 | && CHECK_FLAG(new->flags, OSPF_LSA_LOCAL_XLT)) { | |
206 | ospf_translated_nssa_refresh(ospf, NULL, new); | |
207 | return; | |
208 | } | |
b5a8894d | 209 | ei = ospf_external_info_check(ospf, new); |
d62a17ae | 210 | if (ei) |
211 | ospf_external_lsa_refresh(ospf, new, ei, | |
212 | LSA_REFRESH_FORCE); | |
213 | else | |
214 | ospf_lsa_flush_as(ospf, new); | |
215 | break; | |
216 | case OSPF_OPAQUE_AREA_LSA: | |
217 | ospf_opaque_lsa_refresh(new); | |
218 | break; | |
219 | case OSPF_OPAQUE_AS_LSA: | |
220 | ospf_opaque_lsa_refresh(new); | |
996c9314 | 221 | /* Reconsideration may needed. */ /* XXX */ |
d62a17ae | 222 | break; |
223 | default: | |
224 | break; | |
225 | } | |
718e3744 | 226 | } |
227 | ||
228 | /* OSPF LSA flooding -- RFC2328 Section 13.(5). */ | |
229 | ||
230 | /* Now Updated for NSSA operation, as follows: | |
231 | ||
232 | ||
233 | Type-5's have no change. Blocked to STUB or NSSA. | |
234 | ||
235 | Type-7's can be received, and if a DR | |
236 | they will also flood the local NSSA Area as Type-7's | |
237 | ||
d62a17ae | 238 | If a Self-Originated LSA (now an ASBR), |
718e3744 | 239 | The LSDB will be updated as Type-5's, (for continual re-fresh) |
240 | ||
241 | If an NSSA-IR it is installed/flooded as Type-7, P-bit on. | |
242 | if an NSSA-ABR it is installed/flooded as Type-7, P-bit off. | |
243 | ||
244 | Later, during the ABR TASK, if the ABR is the Elected NSSA | |
245 | translator, then All Type-7s (with P-bit ON) are Translated to | |
246 | Type-5's and flooded to all non-NSSA/STUB areas. | |
247 | ||
d62a17ae | 248 | During ASE Calculations, |
718e3744 | 249 | non-ABRs calculate external routes from Type-7's |
250 | ABRs calculate external routes from Type-5's and non-self Type-7s | |
251 | */ | |
d62a17ae | 252 | int ospf_flood(struct ospf *ospf, struct ospf_neighbor *nbr, |
253 | struct ospf_lsa *current, struct ospf_lsa *new) | |
718e3744 | 254 | { |
d62a17ae | 255 | struct ospf_interface *oi; |
256 | int lsa_ack_flag; | |
257 | ||
258 | /* Type-7 LSA's will be flooded throughout their native NSSA area, | |
259 | but will also be flooded as Type-5's into ABR capable links. */ | |
260 | ||
261 | if (IS_DEBUG_OSPF_EVENT) | |
262 | zlog_debug( | |
263 | "LSA[Flooding]: start, NBR %s (%s), cur(%p), New-LSA[%s]", | |
264 | inet_ntoa(nbr->router_id), | |
265 | lookup_msg(ospf_nsm_state_msg, nbr->state, NULL), | |
266 | (void *)current, dump_lsa_key(new)); | |
267 | ||
268 | oi = nbr->oi; | |
269 | ||
270 | /* If there is already a database copy, and if the | |
271 | database copy was received via flooding and installed less | |
272 | than MinLSArrival seconds ago, discard the new LSA | |
273 | (without acknowledging it). */ | |
274 | if (current != NULL) /* -- endo. */ | |
275 | { | |
276 | if (IS_LSA_SELF(current) | |
277 | && (ntohs(current->data->ls_age) == 0 | |
278 | && ntohl(current->data->ls_seqnum) | |
279 | == OSPF_INITIAL_SEQUENCE_NUMBER)) { | |
280 | if (IS_DEBUG_OSPF_EVENT) | |
281 | zlog_debug( | |
282 | "LSA[Flooding]: Got a self-originated LSA, " | |
283 | "while local one is initial instance."); | |
284 | ; /* Accept this LSA for quick LSDB resynchronization. | |
9d303b37 | 285 | */ |
d62a17ae | 286 | } else if (monotime_since(¤t->tv_recv, NULL) |
287 | < ospf->min_ls_arrival * 1000LL) { | |
288 | if (IS_DEBUG_OSPF_EVENT) | |
289 | zlog_debug( | |
290 | "LSA[Flooding]: LSA is received recently."); | |
291 | return -1; | |
292 | } | |
293 | } | |
294 | ||
295 | /* Flood the new LSA out some subset of the router's interfaces. | |
296 | In some cases (e.g., the state of the receiving interface is | |
297 | DR and the LSA was received from a router other than the | |
298 | Backup DR) the LSA will be flooded back out the receiving | |
299 | interface. */ | |
300 | lsa_ack_flag = ospf_flood_through(ospf, nbr, new); | |
301 | ||
302 | /* Remove the current database copy from all neighbors' Link state | |
303 | retransmission lists. AS_EXTERNAL and AS_EXTERNAL_OPAQUE does | |
304 | ^^^^^^^^^^^^^^^^^^^^^^^ | |
305 | not have area ID. | |
306 | All other (even NSSA's) do have area ID. */ | |
307 | if (current) { | |
308 | switch (current->data->type) { | |
309 | case OSPF_AS_EXTERNAL_LSA: | |
310 | case OSPF_OPAQUE_AS_LSA: | |
311 | ospf_ls_retransmit_delete_nbr_as(ospf, current); | |
312 | break; | |
313 | default: | |
314 | ospf_ls_retransmit_delete_nbr_area(nbr->oi->area, | |
315 | current); | |
316 | break; | |
317 | } | |
318 | } | |
319 | ||
320 | /* Do some internal house keeping that is needed here */ | |
321 | SET_FLAG(new->flags, OSPF_LSA_RECEIVED); | |
752ee70b | 322 | (void)ospf_lsa_is_self_originated(ospf, new); /* Let it set the flag */ |
d62a17ae | 323 | |
324 | /* Install the new LSA in the link state database | |
325 | (replacing the current database copy). This may cause the | |
326 | routing table calculation to be scheduled. In addition, | |
327 | timestamp the new LSA with the current time. The flooding | |
328 | procedure cannot overwrite the newly installed LSA until | |
329 | MinLSArrival seconds have elapsed. */ | |
330 | ||
331 | if (!(new = ospf_lsa_install(ospf, nbr->oi, new))) | |
332 | return -1; /* unknown LSA type or any other error condition */ | |
333 | ||
334 | /* Acknowledge the receipt of the LSA by sending a Link State | |
335 | Acknowledgment packet back out the receiving interface. */ | |
336 | if (lsa_ack_flag) | |
337 | ospf_flood_delayed_lsa_ack(nbr, new); | |
338 | ||
339 | /* If this new LSA indicates that it was originated by the | |
340 | receiving router itself, the router must take special action, | |
341 | either updating the LSA or in some cases flushing it from | |
342 | the routing domain. */ | |
343 | if (ospf_lsa_is_self_originated(ospf, new)) | |
344 | ospf_process_self_originated_lsa(ospf, new, oi->area); | |
345 | else | |
346 | /* Update statistics value for OSPF-MIB. */ | |
347 | ospf->rx_lsa_count++; | |
348 | ||
349 | return 0; | |
718e3744 | 350 | } |
351 | ||
352 | /* OSPF LSA flooding -- RFC2328 Section 13.3. */ | |
d62a17ae | 353 | static int ospf_flood_through_interface(struct ospf_interface *oi, |
354 | struct ospf_neighbor *inbr, | |
355 | struct ospf_lsa *lsa) | |
718e3744 | 356 | { |
d62a17ae | 357 | struct ospf_neighbor *onbr; |
358 | struct route_node *rn; | |
359 | int retx_flag; | |
360 | ||
361 | if (IS_DEBUG_OSPF_EVENT) | |
362 | zlog_debug( | |
363 | "ospf_flood_through_interface(): " | |
046460a1 | 364 | "considering int %s, INBR(%s), LSA[%s] AGE %u", |
d62a17ae | 365 | IF_NAME(oi), inbr ? inet_ntoa(inbr->router_id) : "NULL", |
046460a1 | 366 | dump_lsa_key(lsa), ntohs(lsa->data->ls_age)); |
d62a17ae | 367 | |
368 | if (!ospf_if_is_enable(oi)) | |
369 | return 0; | |
370 | ||
371 | /* Remember if new LSA is aded to a retransmit list. */ | |
372 | retx_flag = 0; | |
373 | ||
374 | /* Each of the neighbors attached to this interface are examined, | |
375 | to determine whether they must receive the new LSA. The following | |
376 | steps are executed for each neighbor: */ | |
377 | for (rn = route_top(oi->nbrs); rn; rn = route_next(rn)) { | |
378 | struct ospf_lsa *ls_req; | |
379 | ||
380 | if (rn->info == NULL) | |
381 | continue; | |
382 | ||
383 | onbr = rn->info; | |
384 | if (IS_DEBUG_OSPF_EVENT) | |
385 | zlog_debug( | |
386 | "ospf_flood_through_interface(): considering nbr %s (%s)", | |
387 | inet_ntoa(onbr->router_id), | |
388 | lookup_msg(ospf_nsm_state_msg, onbr->state, | |
389 | NULL)); | |
390 | ||
391 | /* If the neighbor is in a lesser state than Exchange, it | |
392 | does not participate in flooding, and the next neighbor | |
393 | should be examined. */ | |
394 | if (onbr->state < NSM_Exchange) | |
395 | continue; | |
396 | ||
397 | /* If the adjacency is not yet full (neighbor state is | |
398 | Exchange or Loading), examine the Link state request | |
399 | list associated with this adjacency. If there is an | |
400 | instance of the new LSA on the list, it indicates that | |
401 | the neighboring router has an instance of the LSA | |
402 | already. Compare the new LSA to the neighbor's copy: */ | |
403 | if (onbr->state < NSM_Full) { | |
404 | if (IS_DEBUG_OSPF_EVENT) | |
405 | zlog_debug( | |
406 | "ospf_flood_through_interface(): nbr adj is not Full"); | |
407 | ls_req = ospf_ls_request_lookup(onbr, lsa); | |
408 | if (ls_req != NULL) { | |
409 | int ret; | |
410 | ||
411 | ret = ospf_lsa_more_recent(ls_req, lsa); | |
412 | /* The new LSA is less recent. */ | |
413 | if (ret > 0) | |
414 | continue; | |
415 | /* The two copies are the same instance, then | |
416 | delete | |
417 | the LSA from the Link state request list. */ | |
418 | else if (ret == 0) { | |
419 | ospf_ls_request_delete(onbr, ls_req); | |
420 | ospf_check_nbr_loading(onbr); | |
421 | continue; | |
422 | } | |
423 | /* The new LSA is more recent. Delete the LSA | |
424 | from the Link state request list. */ | |
425 | else { | |
426 | ospf_ls_request_delete(onbr, ls_req); | |
427 | ospf_check_nbr_loading(onbr); | |
428 | } | |
429 | } | |
718e3744 | 430 | } |
d62a17ae | 431 | |
432 | if (IS_OPAQUE_LSA(lsa->data->type)) { | |
433 | if (!CHECK_FLAG(onbr->options, OSPF_OPTION_O)) { | |
434 | if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) | |
435 | zlog_debug( | |
436 | "Skip this neighbor: Not Opaque-capable."); | |
437 | continue; | |
438 | } | |
718e3744 | 439 | } |
718e3744 | 440 | |
d62a17ae | 441 | /* If the new LSA was received from this neighbor, |
442 | examine the next neighbor. */ | |
718e3744 | 443 | #ifdef ORIGINAL_CODING |
d62a17ae | 444 | if (inbr) |
445 | if (IPV4_ADDR_SAME(&inbr->router_id, &onbr->router_id)) | |
446 | continue; | |
447 | #else /* ORIGINAL_CODING */ | |
448 | if (inbr) { | |
449 | /* | |
450 | * Triggered by LSUpd message parser "ospf_ls_upd ()". | |
451 | * E.g., all LSAs handling here is received via network. | |
452 | */ | |
453 | if (IPV4_ADDR_SAME(&inbr->router_id, | |
454 | &onbr->router_id)) { | |
455 | if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) | |
456 | zlog_debug( | |
457 | "Skip this neighbor: inbr == onbr"); | |
458 | continue; | |
459 | } | |
460 | } else { | |
461 | /* | |
462 | * Triggered by MaxAge remover, so far. | |
463 | * NULL "inbr" means flooding starts from this node. | |
464 | */ | |
465 | if (IPV4_ADDR_SAME(&lsa->data->adv_router, | |
466 | &onbr->router_id)) { | |
467 | if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) | |
468 | zlog_debug( | |
469 | "Skip this neighbor: lsah->adv_router == onbr"); | |
470 | continue; | |
471 | } | |
472 | } | |
718e3744 | 473 | #endif /* ORIGINAL_CODING */ |
474 | ||
d62a17ae | 475 | /* Add the new LSA to the Link state retransmission list |
476 | for the adjacency. The LSA will be retransmitted | |
477 | at intervals until an acknowledgment is seen from | |
478 | the neighbor. */ | |
479 | ospf_ls_retransmit_add(onbr, lsa); | |
480 | retx_flag = 1; | |
718e3744 | 481 | } |
d62a17ae | 482 | |
483 | /* If in the previous step, the LSA was NOT added to any of | |
484 | the Link state retransmission lists, there is no need to | |
485 | flood the LSA out the interface. */ | |
486 | if (retx_flag == 0) { | |
487 | return (inbr && inbr->oi == oi); | |
488 | } | |
489 | ||
490 | /* if we've received the lsa on this interface we need to perform | |
491 | additional checking */ | |
492 | if (inbr && (inbr->oi == oi)) { | |
493 | /* If the new LSA was received on this interface, and it was | |
494 | received from either the Designated Router or the Backup | |
495 | Designated Router, chances are that all the neighbors have | |
496 | received the LSA already. */ | |
497 | if (NBR_IS_DR(inbr) || NBR_IS_BDR(inbr)) { | |
498 | if (IS_DEBUG_OSPF_NSSA) | |
499 | zlog_debug( | |
500 | "ospf_flood_through_interface(): " | |
501 | "DR/BDR NOT SEND to int %s", | |
502 | IF_NAME(oi)); | |
503 | return 1; | |
504 | } | |
505 | ||
506 | /* If the new LSA was received on this interface, and the | |
507 | interface state is Backup, examine the next interface. The | |
508 | Designated Router will do the flooding on this interface. | |
509 | However, if the Designated Router fails the router will | |
510 | end up retransmitting the updates. */ | |
511 | ||
512 | if (oi->state == ISM_Backup) { | |
513 | if (IS_DEBUG_OSPF_NSSA) | |
514 | zlog_debug( | |
515 | "ospf_flood_through_interface(): " | |
516 | "ISM_Backup NOT SEND to int %s", | |
517 | IF_NAME(oi)); | |
518 | return 1; | |
519 | } | |
718e3744 | 520 | } |
d62a17ae | 521 | |
522 | /* The LSA must be flooded out the interface. Send a Link State | |
523 | Update packet (including the new LSA as contents) out the | |
524 | interface. The LSA's LS age must be incremented by InfTransDelay | |
525 | (which must be > 0) when it is copied into the outgoing Link | |
526 | State Update packet (until the LS age field reaches the maximum | |
527 | value of MaxAge). */ | |
528 | /* XXX HASSO: Is this IS_DEBUG_OSPF_NSSA really correct? */ | |
529 | if (IS_DEBUG_OSPF_NSSA) | |
530 | zlog_debug( | |
531 | "ospf_flood_through_interface(): " | |
532 | "DR/BDR sending upd to int %s", | |
533 | IF_NAME(oi)); | |
534 | ||
535 | /* RFC2328 Section 13.3 | |
536 | On non-broadcast networks, separate Link State Update | |
537 | packets must be sent, as unicasts, to each adjacent neighbor | |
538 | (i.e., those in state Exchange or greater). The destination | |
539 | IP addresses for these packets are the neighbors' IP | |
540 | addresses. */ | |
541 | if (oi->type == OSPF_IFTYPE_NBMA) { | |
d62a17ae | 542 | struct ospf_neighbor *nbr; |
543 | ||
544 | for (rn = route_top(oi->nbrs); rn; rn = route_next(rn)) | |
545 | if ((nbr = rn->info) != NULL) | |
546 | if (nbr != oi->nbr_self | |
547 | && nbr->state >= NSM_Exchange) | |
548 | ospf_ls_upd_send_lsa( | |
549 | nbr, lsa, | |
550 | OSPF_SEND_PACKET_DIRECT); | |
551 | } else | |
552 | ospf_ls_upd_send_lsa(oi->nbr_self, lsa, | |
553 | OSPF_SEND_PACKET_INDIRECT); | |
554 | ||
555 | return 0; | |
718e3744 | 556 | } |
557 | ||
d62a17ae | 558 | int ospf_flood_through_area(struct ospf_area *area, struct ospf_neighbor *inbr, |
559 | struct ospf_lsa *lsa) | |
718e3744 | 560 | { |
d62a17ae | 561 | struct listnode *node, *nnode; |
562 | struct ospf_interface *oi; | |
563 | int lsa_ack_flag = 0; | |
564 | ||
9b50aa1f | 565 | assert(area); |
d62a17ae | 566 | /* All other types are specific to a single area (Area A). The |
567 | eligible interfaces are all those interfaces attaching to the | |
568 | Area A. If Area A is the backbone, this includes all the virtual | |
569 | links. */ | |
570 | for (ALL_LIST_ELEMENTS(area->oiflist, node, nnode, oi)) { | |
571 | if (area->area_id.s_addr != OSPF_AREA_BACKBONE | |
572 | && oi->type == OSPF_IFTYPE_VIRTUALLINK) | |
573 | continue; | |
574 | ||
575 | if ((lsa->data->type == OSPF_OPAQUE_LINK_LSA) | |
576 | && (lsa->oi != oi)) { | |
577 | /* | |
578 | * Link local scoped Opaque-LSA should only be flooded | |
579 | * for the link on which the LSA has received. | |
580 | */ | |
581 | if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) | |
582 | zlog_debug( | |
583 | "Type-9 Opaque-LSA: lsa->oi(%p) != oi(%p)", | |
584 | (void *)lsa->oi, (void *)oi); | |
585 | continue; | |
586 | } | |
587 | ||
588 | if (ospf_flood_through_interface(oi, inbr, lsa)) | |
589 | lsa_ack_flag = 1; | |
590 | } | |
591 | ||
592 | return (lsa_ack_flag); | |
718e3744 | 593 | } |
594 | ||
d62a17ae | 595 | int ospf_flood_through_as(struct ospf *ospf, struct ospf_neighbor *inbr, |
596 | struct ospf_lsa *lsa) | |
718e3744 | 597 | { |
d62a17ae | 598 | struct listnode *node; |
599 | struct ospf_area *area; | |
600 | int lsa_ack_flag; | |
601 | ||
602 | lsa_ack_flag = 0; | |
603 | ||
604 | /* The incoming LSA is type 5 or type 7 (AS-EXTERNAL or AS-NSSA ) | |
605 | ||
606 | Divert the Type-5 LSA's to all non-NSSA/STUB areas | |
607 | ||
608 | Divert the Type-7 LSA's to all NSSA areas | |
609 | ||
610 | AS-external-LSAs are flooded throughout the entire AS, with the | |
611 | exception of stub areas (see Section 3.6). The eligible | |
612 | interfaces are all the router's interfaces, excluding virtual | |
613 | links and those interfaces attaching to stub areas. */ | |
614 | ||
615 | if (CHECK_FLAG(lsa->flags, OSPF_LSA_LOCAL_XLT)) /* Translated from 7 */ | |
616 | if (IS_DEBUG_OSPF_NSSA) | |
617 | zlog_debug("Flood/AS: NSSA TRANSLATED LSA"); | |
618 | ||
619 | for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) { | |
620 | int continue_flag = 0; | |
621 | struct listnode *if_node; | |
622 | struct ospf_interface *oi; | |
623 | ||
624 | switch (area->external_routing) { | |
625 | /* Don't send AS externals into stub areas. Various types | |
626 | of support for partial stub areas can be implemented | |
627 | here. NSSA's will receive Type-7's that have areas | |
628 | matching the originl LSA. */ | |
629 | case OSPF_AREA_NSSA: /* Sending Type 5 or 7 into NSSA area */ | |
630 | /* Type-7, flood NSSA area */ | |
631 | if (lsa->data->type == OSPF_AS_NSSA_LSA | |
632 | && area == lsa->area) | |
633 | /* We will send it. */ | |
634 | continue_flag = 0; | |
635 | else | |
636 | continue_flag = 1; /* Skip this NSSA area for | |
637 | Type-5's et al */ | |
638 | break; | |
639 | ||
640 | case OSPF_AREA_TYPE_MAX: | |
641 | case OSPF_AREA_STUB: | |
642 | continue_flag = 1; /* Skip this area. */ | |
643 | break; | |
644 | ||
645 | case OSPF_AREA_DEFAULT: | |
646 | default: | |
647 | /* No Type-7 into normal area */ | |
648 | if (lsa->data->type == OSPF_AS_NSSA_LSA) | |
649 | continue_flag = 1; /* skip Type-7 */ | |
650 | else | |
651 | continue_flag = 0; /* Do this area. */ | |
652 | break; | |
653 | } | |
718e3744 | 654 | |
d62a17ae | 655 | /* Do continue for above switch. Saves a big if then mess */ |
656 | if (continue_flag) | |
657 | continue; /* main for-loop */ | |
718e3744 | 658 | |
d62a17ae | 659 | /* send to every interface in this area */ |
718e3744 | 660 | |
d62a17ae | 661 | for (ALL_LIST_ELEMENTS_RO(area->oiflist, if_node, oi)) { |
662 | /* Skip virtual links */ | |
663 | if (oi->type != OSPF_IFTYPE_VIRTUALLINK) | |
664 | if (ospf_flood_through_interface(oi, inbr, | |
665 | lsa)) /* lsa */ | |
666 | lsa_ack_flag = 1; | |
667 | } | |
668 | } /* main area for-loop */ | |
718e3744 | 669 | |
d62a17ae | 670 | return (lsa_ack_flag); |
671 | } | |
718e3744 | 672 | |
d62a17ae | 673 | int ospf_flood_through(struct ospf *ospf, struct ospf_neighbor *inbr, |
674 | struct ospf_lsa *lsa) | |
675 | { | |
676 | int lsa_ack_flag = 0; | |
718e3744 | 677 | |
d62a17ae | 678 | /* Type-7 LSA's for NSSA are flooded throughout the AS here, and |
679 | upon return are updated in the LSDB for Type-7's. Later, | |
680 | re-fresh will re-send them (and also, if ABR, packet code will | |
681 | translate to Type-5's) | |
718e3744 | 682 | |
d62a17ae | 683 | As usual, Type-5 LSA's (if not DISCARDED because we are STUB or |
684 | NSSA) are flooded throughout the AS, and are updated in the | |
685 | global table. */ | |
686 | #ifdef ORIGINAL_CODING | |
687 | switch (lsa->data->type) { | |
688 | case OSPF_ROUTER_LSA: | |
689 | case OSPF_NETWORK_LSA: | |
690 | case OSPF_SUMMARY_LSA: | |
691 | case OSPF_ASBR_SUMMARY_LSA: | |
692 | case OSPF_OPAQUE_LINK_LSA: /* ospf_flood_through_interface ? */ | |
693 | case OSPF_OPAQUE_AREA_LSA: | |
694 | lsa_ack_flag = | |
695 | ospf_flood_through_area(inbr->oi->area, inbr, lsa); | |
696 | break; | |
697 | case OSPF_AS_EXTERNAL_LSA: /* Type-5 */ | |
698 | case OSPF_OPAQUE_AS_LSA: | |
699 | lsa_ack_flag = ospf_flood_through_as(ospf, inbr, lsa); | |
700 | break; | |
701 | /* Type-7 Only received within NSSA, then flooded */ | |
702 | case OSPF_AS_NSSA_LSA: | |
703 | /* Any P-bit was installed with the Type-7. */ | |
704 | lsa_ack_flag = | |
705 | ospf_flood_through_area(inbr->oi->area, inbr, lsa); | |
706 | ||
707 | if (IS_DEBUG_OSPF_NSSA) | |
708 | zlog_debug( | |
709 | "ospf_flood_through: LOCAL NSSA FLOOD of Type-7."); | |
710 | break; | |
718e3744 | 711 | default: |
d62a17ae | 712 | break; |
718e3744 | 713 | } |
d62a17ae | 714 | #else /* ORIGINAL_CODING */ |
715 | /* | |
716 | * At the common sub-sub-function "ospf_flood_through_interface()", | |
717 | * a parameter "inbr" will be used to distinguish the called context | |
718 | * whether the given LSA was received from the neighbor, or the | |
719 | * flooding for the LSA starts from this node (e.g. the LSA was self- | |
720 | * originated, or the LSA is going to be flushed from routing domain). | |
721 | * | |
722 | * So, for consistency reasons, this function "ospf_flood_through()" | |
723 | * should also allow the usage that the given "inbr" parameter to be | |
724 | * NULL. If we do so, corresponding AREA parameter should be referred | |
725 | * by "lsa->area", instead of "inbr->oi->area". | |
726 | */ | |
727 | switch (lsa->data->type) { | |
728 | case OSPF_AS_EXTERNAL_LSA: /* Type-5 */ | |
729 | case OSPF_OPAQUE_AS_LSA: | |
730 | lsa_ack_flag = ospf_flood_through_as(ospf, inbr, lsa); | |
731 | break; | |
732 | /* Type-7 Only received within NSSA, then flooded */ | |
733 | case OSPF_AS_NSSA_LSA: | |
734 | /* Any P-bit was installed with the Type-7. */ | |
735 | ||
736 | if (IS_DEBUG_OSPF_NSSA) | |
737 | zlog_debug( | |
738 | "ospf_flood_through: LOCAL NSSA FLOOD of Type-7."); | |
739 | /* Fallthrough */ | |
740 | default: | |
741 | lsa_ack_flag = ospf_flood_through_area(lsa->area, inbr, lsa); | |
742 | break; | |
718e3744 | 743 | } |
718e3744 | 744 | #endif /* ORIGINAL_CODING */ |
718e3744 | 745 | |
d62a17ae | 746 | return (lsa_ack_flag); |
747 | } | |
6b0655a2 | 748 | |
718e3744 | 749 | |
750 | /* Management functions for neighbor's Link State Request list. */ | |
d62a17ae | 751 | void ospf_ls_request_add(struct ospf_neighbor *nbr, struct ospf_lsa *lsa) |
718e3744 | 752 | { |
d62a17ae | 753 | /* |
754 | * We cannot make use of the newly introduced callback function | |
755 | * "lsdb->new_lsa_hook" to replace debug output below, just because | |
756 | * it seems no simple and smart way to pass neighbor information to | |
757 | * the common function "ospf_lsdb_add()" -- endo. | |
758 | */ | |
759 | if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) | |
760 | zlog_debug("RqstL(%lu)++, NBR(%s), LSA[%s]", | |
761 | ospf_ls_request_count(nbr), | |
762 | inet_ntoa(nbr->router_id), dump_lsa_key(lsa)); | |
763 | ||
764 | ospf_lsdb_add(&nbr->ls_req, lsa); | |
718e3744 | 765 | } |
766 | ||
d62a17ae | 767 | unsigned long ospf_ls_request_count(struct ospf_neighbor *nbr) |
718e3744 | 768 | { |
d62a17ae | 769 | return ospf_lsdb_count_all(&nbr->ls_req); |
718e3744 | 770 | } |
771 | ||
d62a17ae | 772 | int ospf_ls_request_isempty(struct ospf_neighbor *nbr) |
718e3744 | 773 | { |
d62a17ae | 774 | return ospf_lsdb_isempty(&nbr->ls_req); |
718e3744 | 775 | } |
776 | ||
777 | /* Remove LSA from neighbor's ls-request list. */ | |
d62a17ae | 778 | void ospf_ls_request_delete(struct ospf_neighbor *nbr, struct ospf_lsa *lsa) |
718e3744 | 779 | { |
d62a17ae | 780 | if (nbr->ls_req_last == lsa) { |
781 | ospf_lsa_unlock(&nbr->ls_req_last); | |
782 | nbr->ls_req_last = NULL; | |
783 | } | |
784 | ||
785 | if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) /* -- endo. */ | |
786 | zlog_debug("RqstL(%lu)--, NBR(%s), LSA[%s]", | |
787 | ospf_ls_request_count(nbr), | |
788 | inet_ntoa(nbr->router_id), dump_lsa_key(lsa)); | |
789 | ||
790 | ospf_lsdb_delete(&nbr->ls_req, lsa); | |
718e3744 | 791 | } |
792 | ||
793 | /* Remove all LSA from neighbor's ls-requenst list. */ | |
d62a17ae | 794 | void ospf_ls_request_delete_all(struct ospf_neighbor *nbr) |
718e3744 | 795 | { |
d62a17ae | 796 | ospf_lsa_unlock(&nbr->ls_req_last); |
797 | nbr->ls_req_last = NULL; | |
798 | ospf_lsdb_delete_all(&nbr->ls_req); | |
718e3744 | 799 | } |
800 | ||
801 | /* Lookup LSA from neighbor's ls-request list. */ | |
d62a17ae | 802 | struct ospf_lsa *ospf_ls_request_lookup(struct ospf_neighbor *nbr, |
803 | struct ospf_lsa *lsa) | |
718e3744 | 804 | { |
d62a17ae | 805 | return ospf_lsdb_lookup(&nbr->ls_req, lsa); |
718e3744 | 806 | } |
807 | ||
d62a17ae | 808 | struct ospf_lsa *ospf_ls_request_new(struct lsa_header *lsah) |
718e3744 | 809 | { |
d62a17ae | 810 | struct ospf_lsa *new; |
718e3744 | 811 | |
5b3d4186 | 812 | new = ospf_lsa_new_and_data(OSPF_LSA_HEADER_SIZE); |
d62a17ae | 813 | memcpy(new->data, lsah, OSPF_LSA_HEADER_SIZE); |
718e3744 | 814 | |
d62a17ae | 815 | return new; |
718e3744 | 816 | } |
817 | ||
6b0655a2 | 818 | |
718e3744 | 819 | /* Management functions for neighbor's ls-retransmit list. */ |
d62a17ae | 820 | unsigned long ospf_ls_retransmit_count(struct ospf_neighbor *nbr) |
718e3744 | 821 | { |
d62a17ae | 822 | return ospf_lsdb_count_all(&nbr->ls_rxmt); |
718e3744 | 823 | } |
824 | ||
d62a17ae | 825 | unsigned long ospf_ls_retransmit_count_self(struct ospf_neighbor *nbr, |
826 | int lsa_type) | |
718e3744 | 827 | { |
d62a17ae | 828 | return ospf_lsdb_count_self(&nbr->ls_rxmt, lsa_type); |
718e3744 | 829 | } |
830 | ||
d62a17ae | 831 | int ospf_ls_retransmit_isempty(struct ospf_neighbor *nbr) |
718e3744 | 832 | { |
d62a17ae | 833 | return ospf_lsdb_isempty(&nbr->ls_rxmt); |
718e3744 | 834 | } |
835 | ||
836 | /* Add LSA to be retransmitted to neighbor's ls-retransmit list. */ | |
d62a17ae | 837 | void ospf_ls_retransmit_add(struct ospf_neighbor *nbr, struct ospf_lsa *lsa) |
718e3744 | 838 | { |
d62a17ae | 839 | struct ospf_lsa *old; |
718e3744 | 840 | |
d62a17ae | 841 | old = ospf_ls_retransmit_lookup(nbr, lsa); |
718e3744 | 842 | |
d62a17ae | 843 | if (ospf_lsa_more_recent(old, lsa) < 0) { |
844 | if (old) { | |
845 | old->retransmit_counter--; | |
846 | ospf_lsdb_delete(&nbr->ls_rxmt, old); | |
847 | } | |
848 | lsa->retransmit_counter++; | |
849 | /* | |
850 | * We cannot make use of the newly introduced callback function | |
851 | * "lsdb->new_lsa_hook" to replace debug output below, just | |
852 | * because | |
853 | * it seems no simple and smart way to pass neighbor information | |
854 | * to | |
855 | * the common function "ospf_lsdb_add()" -- endo. | |
856 | */ | |
857 | if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) | |
858 | zlog_debug("RXmtL(%lu)++, NBR(%s), LSA[%s]", | |
859 | ospf_ls_retransmit_count(nbr), | |
860 | inet_ntoa(nbr->router_id), | |
861 | dump_lsa_key(lsa)); | |
862 | ospf_lsdb_add(&nbr->ls_rxmt, lsa); | |
718e3744 | 863 | } |
718e3744 | 864 | } |
865 | ||
866 | /* Remove LSA from neibghbor's ls-retransmit list. */ | |
d62a17ae | 867 | void ospf_ls_retransmit_delete(struct ospf_neighbor *nbr, struct ospf_lsa *lsa) |
718e3744 | 868 | { |
d62a17ae | 869 | if (ospf_ls_retransmit_lookup(nbr, lsa)) { |
870 | lsa->retransmit_counter--; | |
871 | if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) /* -- endo. */ | |
872 | zlog_debug("RXmtL(%lu)--, NBR(%s), LSA[%s]", | |
873 | ospf_ls_retransmit_count(nbr), | |
874 | inet_ntoa(nbr->router_id), | |
875 | dump_lsa_key(lsa)); | |
876 | ospf_lsdb_delete(&nbr->ls_rxmt, lsa); | |
877 | } | |
718e3744 | 878 | } |
879 | ||
880 | /* Clear neighbor's ls-retransmit list. */ | |
d62a17ae | 881 | void ospf_ls_retransmit_clear(struct ospf_neighbor *nbr) |
718e3744 | 882 | { |
d62a17ae | 883 | struct ospf_lsdb *lsdb; |
884 | int i; | |
718e3744 | 885 | |
d62a17ae | 886 | lsdb = &nbr->ls_rxmt; |
718e3744 | 887 | |
d62a17ae | 888 | for (i = OSPF_MIN_LSA; i < OSPF_MAX_LSA; i++) { |
889 | struct route_table *table = lsdb->type[i].db; | |
890 | struct route_node *rn; | |
891 | struct ospf_lsa *lsa; | |
718e3744 | 892 | |
d62a17ae | 893 | for (rn = route_top(table); rn; rn = route_next(rn)) |
894 | if ((lsa = rn->info) != NULL) | |
895 | ospf_ls_retransmit_delete(nbr, lsa); | |
896 | } | |
718e3744 | 897 | |
d62a17ae | 898 | ospf_lsa_unlock(&nbr->ls_req_last); |
899 | nbr->ls_req_last = NULL; | |
718e3744 | 900 | } |
901 | ||
902 | /* Lookup LSA from neighbor's ls-retransmit list. */ | |
d62a17ae | 903 | struct ospf_lsa *ospf_ls_retransmit_lookup(struct ospf_neighbor *nbr, |
904 | struct ospf_lsa *lsa) | |
718e3744 | 905 | { |
d62a17ae | 906 | return ospf_lsdb_lookup(&nbr->ls_rxmt, lsa); |
718e3744 | 907 | } |
908 | ||
d62a17ae | 909 | static void ospf_ls_retransmit_delete_nbr_if(struct ospf_interface *oi, |
910 | struct ospf_lsa *lsa) | |
718e3744 | 911 | { |
d62a17ae | 912 | struct route_node *rn; |
913 | struct ospf_neighbor *nbr; | |
914 | struct ospf_lsa *lsr; | |
915 | ||
916 | if (ospf_if_is_enable(oi)) | |
917 | for (rn = route_top(oi->nbrs); rn; rn = route_next(rn)) | |
918 | /* If LSA find in LS-retransmit list, then remove it. */ | |
919 | if ((nbr = rn->info) != NULL) { | |
920 | lsr = ospf_ls_retransmit_lookup(nbr, lsa); | |
921 | ||
922 | /* If LSA find in ls-retransmit list, remove it. | |
923 | */ | |
924 | if (lsr != NULL | |
925 | && lsr->data->ls_seqnum | |
926 | == lsa->data->ls_seqnum) | |
927 | ospf_ls_retransmit_delete(nbr, lsr); | |
928 | } | |
718e3744 | 929 | } |
930 | ||
d62a17ae | 931 | void ospf_ls_retransmit_delete_nbr_area(struct ospf_area *area, |
932 | struct ospf_lsa *lsa) | |
718e3744 | 933 | { |
d62a17ae | 934 | struct listnode *node, *nnode; |
935 | struct ospf_interface *oi; | |
718e3744 | 936 | |
d62a17ae | 937 | for (ALL_LIST_ELEMENTS(area->oiflist, node, nnode, oi)) |
938 | ospf_ls_retransmit_delete_nbr_if(oi, lsa); | |
68980084 | 939 | } |
718e3744 | 940 | |
d62a17ae | 941 | void ospf_ls_retransmit_delete_nbr_as(struct ospf *ospf, struct ospf_lsa *lsa) |
68980084 | 942 | { |
d62a17ae | 943 | struct listnode *node, *nnode; |
944 | struct ospf_interface *oi; | |
718e3744 | 945 | |
d62a17ae | 946 | for (ALL_LIST_ELEMENTS(ospf->oiflist, node, nnode, oi)) |
947 | ospf_ls_retransmit_delete_nbr_if(oi, lsa); | |
718e3744 | 948 | } |
949 | ||
6b0655a2 | 950 | |
d62a17ae | 951 | /* Sets ls_age to MaxAge and floods throu the area. |
718e3744 | 952 | When we implement ASE routing, there will be anothe function |
953 | flushing an LSA from the whole domain. */ | |
d62a17ae | 954 | void ospf_lsa_flush_area(struct ospf_lsa *lsa, struct ospf_area *area) |
718e3744 | 955 | { |
d62a17ae | 956 | /* Reset the lsa origination time such that it gives |
957 | more time for the ACK to be received and avoid | |
958 | retransmissions */ | |
959 | lsa->data->ls_age = htons(OSPF_LSA_MAXAGE); | |
046460a1 CS |
960 | if (IS_DEBUG_OSPF_EVENT) |
961 | zlog_debug("%s: MAXAGE set to LSA %s", __PRETTY_FUNCTION__, | |
962 | inet_ntoa(lsa->data->id)); | |
d62a17ae | 963 | monotime(&lsa->tv_recv); |
964 | lsa->tv_orig = lsa->tv_recv; | |
965 | ospf_flood_through_area(area, NULL, lsa); | |
966 | ospf_lsa_maxage(area->ospf, lsa); | |
718e3744 | 967 | } |
968 | ||
d62a17ae | 969 | void ospf_lsa_flush_as(struct ospf *ospf, struct ospf_lsa *lsa) |
718e3744 | 970 | { |
d62a17ae | 971 | /* Reset the lsa origination time such that it gives |
972 | more time for the ACK to be received and avoid | |
973 | retransmissions */ | |
974 | lsa->data->ls_age = htons(OSPF_LSA_MAXAGE); | |
975 | monotime(&lsa->tv_recv); | |
976 | lsa->tv_orig = lsa->tv_recv; | |
977 | ospf_flood_through_as(ospf, NULL, lsa); | |
978 | ospf_lsa_maxage(ospf, lsa); | |
718e3744 | 979 | } |
02d942c9 | 980 | |
d62a17ae | 981 | void ospf_lsa_flush(struct ospf *ospf, struct ospf_lsa *lsa) |
02d942c9 | 982 | { |
d62a17ae | 983 | lsa->data->ls_age = htons(OSPF_LSA_MAXAGE); |
984 | ||
985 | switch (lsa->data->type) { | |
986 | case OSPF_ROUTER_LSA: | |
987 | case OSPF_NETWORK_LSA: | |
988 | case OSPF_SUMMARY_LSA: | |
989 | case OSPF_ASBR_SUMMARY_LSA: | |
990 | case OSPF_AS_NSSA_LSA: | |
991 | case OSPF_OPAQUE_LINK_LSA: | |
992 | case OSPF_OPAQUE_AREA_LSA: | |
993 | ospf_lsa_flush_area(lsa, lsa->area); | |
994 | break; | |
995 | case OSPF_AS_EXTERNAL_LSA: | |
996 | case OSPF_OPAQUE_AS_LSA: | |
997 | ospf_lsa_flush_as(ospf, lsa); | |
998 | break; | |
999 | default: | |
1000 | zlog_info("%s: Unknown LSA type %u", __func__, lsa->data->type); | |
1001 | break; | |
1002 | } | |
02d942c9 | 1003 | } |