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