blob: c0b362285fef351dfdee7f0d0ad8a305b1a3b009 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/*
2 * OSPF Flooding -- RFC2328 Section 13.
3 * Copyright (C) 1999, 2000 Toshiaki Takada
4 *
5 * This file is part of GNU Zebra.
6 *
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 *
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
21 */
22
23#include <zebra.h>
24
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
51extern struct zclient *zclient;
David Lamparter6b0655a2014-06-04 06:53:35 +020052
paul718e3742002-12-13 20:15:29 +000053/* Do the LSA acking specified in table 19, Section 13.5, row 2
54 * This get called from ospf_flood_out_interface. Declared inline
55 * for speed. */
56static void
57ospf_flood_delayed_lsa_ack (struct ospf_neighbor *inbr, struct ospf_lsa *lsa)
58{
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 */
Paul Jakma1fe6ed32006-07-26 09:37:26 +000075 listnode_add (inbr->oi->ls_ack, ospf_lsa_lock (lsa)); /* delayed LSA Ack */
paul718e3742002-12-13 20:15:29 +000076}
77
78/* Check LSA is related to external info. */
79struct external_info *
80ospf_external_info_check (struct ospf_lsa *lsa)
81{
82 struct as_external_lsa *al;
83 struct prefix_ipv4 p;
84 struct route_node *rn;
85 int type;
86
87 al = (struct as_external_lsa *) lsa->data;
88
89 p.family = AF_INET;
90 p.prefix = lsa->data->id;
91 p.prefixlen = ip_masklen (al->mask);
92
93 for (type = 0; type <= ZEBRA_ROUTE_MAX; type++)
94 {
95 int redist_type = is_prefix_default (&p) ? DEFAULT_ROUTE : type;
96 if (ospf_is_type_redistributed (redist_type))
97 if (EXTERNAL_INFO (type))
98 {
99 rn = route_node_lookup (EXTERNAL_INFO (type),
100 (struct prefix *) &p);
101 if (rn)
102 {
103 route_unlock_node (rn);
104 if (rn->info != NULL)
105 return (struct external_info *) rn->info;
106 }
107 }
108 }
109
110 return NULL;
111}
112
paul4dadc292005-05-06 21:37:42 +0000113static void
paul68980082003-03-25 05:07:42 +0000114ospf_process_self_originated_lsa (struct ospf *ospf,
115 struct ospf_lsa *new, struct ospf_area *area)
paul718e3742002-12-13 20:15:29 +0000116{
117 struct ospf_interface *oi;
118 struct external_info *ei;
hasso52dc7ee2004-09-23 19:18:23 +0000119 struct listnode *node;
paul718e3742002-12-13 20:15:29 +0000120
121 if (IS_DEBUG_OSPF_EVENT)
ajs60925302004-12-08 17:45:02 +0000122 zlog_debug ("LSA[Type%d:%s]: Process self-originated LSA seq 0x%x",
paul7ddf1d62003-10-13 09:06:46 +0000123 new->data->type, inet_ntoa (new->data->id),
paul0c2be262004-05-31 14:16:54 +0000124 ntohl(new->data->ls_seqnum));
paul718e3742002-12-13 20:15:29 +0000125
126 /* If we're here, we installed a self-originated LSA that we received
127 from a neighbor, i.e. it's more recent. We must see whether we want
128 to originate it.
129 If yes, we should use this LSA's sequence number and reoriginate
130 a new instance.
131 if not --- we must flush this LSA from the domain. */
132 switch (new->data->type)
133 {
134 case OSPF_ROUTER_LSA:
135 /* Originate a new instance and schedule flooding */
Joakim Tjernlundbd246242009-01-05 17:44:46 +0100136 if (area->router_lsa_self)
137 area->router_lsa_self->data->ls_seqnum = new->data->ls_seqnum;
Paul Jakmac363d382010-01-24 22:42:13 +0000138 ospf_router_lsa_update_area (area);
paul718e3742002-12-13 20:15:29 +0000139 return;
140 case OSPF_NETWORK_LSA:
141#ifdef HAVE_OPAQUE_LSA
142 case OSPF_OPAQUE_LINK_LSA:
143#endif /* HAVE_OPAQUE_LSA */
144 /* We must find the interface the LSA could belong to.
145 If the interface is no more a broadcast type or we are no more
146 the DR, we flush the LSA otherwise -- create the new instance and
147 schedule flooding. */
148
149 /* Look through all interfaces, not just area, since interface
150 could be moved from one area to another. */
paul1eb8ef22005-04-07 07:30:20 +0000151 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +0000152 /* These are sanity check. */
paul1eb8ef22005-04-07 07:30:20 +0000153 if (IPV4_ADDR_SAME (&oi->address->u.prefix4, &new->data->id))
154 {
155 if (oi->area != area ||
156 oi->type != OSPF_IFTYPE_BROADCAST ||
157 !IPV4_ADDR_SAME (&oi->address->u.prefix4, &DR (oi)))
158 {
159 ospf_schedule_lsa_flush_area (area, new);
160 return;
161 }
162
paul718e3742002-12-13 20:15:29 +0000163#ifdef HAVE_OPAQUE_LSA
paul1eb8ef22005-04-07 07:30:20 +0000164 if (new->data->type == OSPF_OPAQUE_LINK_LSA)
165 {
166 ospf_opaque_lsa_refresh (new);
167 return;
168 }
paul718e3742002-12-13 20:15:29 +0000169#endif /* HAVE_OPAQUE_LSA */
170
Joakim Tjernlundbd246242009-01-05 17:44:46 +0100171 if (oi->network_lsa_self)
172 oi->network_lsa_self->data->ls_seqnum = new->data->ls_seqnum;
paul1eb8ef22005-04-07 07:30:20 +0000173 /* Schedule network-LSA origination. */
Paul Jakmac363d382010-01-24 22:42:13 +0000174 ospf_network_lsa_update (oi);
paul1eb8ef22005-04-07 07:30:20 +0000175 return;
176 }
paul718e3742002-12-13 20:15:29 +0000177 break;
178 case OSPF_SUMMARY_LSA:
179 case OSPF_ASBR_SUMMARY_LSA:
paul68980082003-03-25 05:07:42 +0000180 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +0000181 break;
182 case OSPF_AS_EXTERNAL_LSA :
paul718e3742002-12-13 20:15:29 +0000183 case OSPF_AS_NSSA_LSA:
pauld4a53d52003-07-12 21:30:57 +0000184 if ( (new->data->type == OSPF_AS_EXTERNAL_LSA)
185 && CHECK_FLAG (new->flags, OSPF_LSA_LOCAL_XLT))
186 {
187 ospf_translated_nssa_refresh (ospf, NULL, new);
188 return;
189 }
paul718e3742002-12-13 20:15:29 +0000190 ei = ospf_external_info_check (new);
191 if (ei)
pauld4a53d52003-07-12 21:30:57 +0000192 ospf_external_lsa_refresh (ospf, new, ei, LSA_REFRESH_FORCE);
paul718e3742002-12-13 20:15:29 +0000193 else
pauld4a53d52003-07-12 21:30:57 +0000194 ospf_lsa_flush_as (ospf, new);
paul718e3742002-12-13 20:15:29 +0000195 break;
196#ifdef HAVE_OPAQUE_LSA
197 case OSPF_OPAQUE_AREA_LSA:
198 ospf_opaque_lsa_refresh (new);
199 break;
200 case OSPF_OPAQUE_AS_LSA:
201 ospf_opaque_lsa_refresh (new); /* Reconsideration may needed. *//* XXX */
202 break;
203#endif /* HAVE_OPAQUE_LSA */
204 default:
205 break;
206 }
207}
208
209/* OSPF LSA flooding -- RFC2328 Section 13.(5). */
210
211/* Now Updated for NSSA operation, as follows:
212
213
214 Type-5's have no change. Blocked to STUB or NSSA.
215
216 Type-7's can be received, and if a DR
217 they will also flood the local NSSA Area as Type-7's
218
219 If a Self-Originated LSA (now an ASBR),
220 The LSDB will be updated as Type-5's, (for continual re-fresh)
221
222 If an NSSA-IR it is installed/flooded as Type-7, P-bit on.
223 if an NSSA-ABR it is installed/flooded as Type-7, P-bit off.
224
225 Later, during the ABR TASK, if the ABR is the Elected NSSA
226 translator, then All Type-7s (with P-bit ON) are Translated to
227 Type-5's and flooded to all non-NSSA/STUB areas.
228
229 During ASE Calculations,
230 non-ABRs calculate external routes from Type-7's
231 ABRs calculate external routes from Type-5's and non-self Type-7s
232*/
233int
paul68980082003-03-25 05:07:42 +0000234ospf_flood (struct ospf *ospf, struct ospf_neighbor *nbr,
235 struct ospf_lsa *current, struct ospf_lsa *new)
paul718e3742002-12-13 20:15:29 +0000236{
237 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +0000238 int lsa_ack_flag;
239
240 /* Type-7 LSA's will be flooded throughout their native NSSA area,
241 but will also be flooded as Type-5's into ABR capable links. */
242
243 if (IS_DEBUG_OSPF_EVENT)
ajs60925302004-12-08 17:45:02 +0000244 zlog_debug ("LSA[Flooding]: start, NBR %s (%s), cur(%p), New-LSA[%s]",
paul718e3742002-12-13 20:15:29 +0000245 inet_ntoa (nbr->router_id),
246 LOOKUP (ospf_nsm_state_msg, nbr->state),
David Lampartereed3c482015-03-03 08:51:53 +0100247 (void *)current,
paul718e3742002-12-13 20:15:29 +0000248 dump_lsa_key (new));
249
250 lsa_ack_flag = 0;
251 oi = nbr->oi;
252
paul718e3742002-12-13 20:15:29 +0000253 /* If there is already a database copy, and if the
254 database copy was received via flooding and installed less
255 than MinLSArrival seconds ago, discard the new LSA
256 (without acknowledging it). */
257 if (current != NULL) /* -- endo. */
258 {
259 if (IS_LSA_SELF (current)
260 && (ntohs (current->data->ls_age) == 0
261 && ntohl (current->data->ls_seqnum) == OSPF_INITIAL_SEQUENCE_NUMBER))
262 {
263 if (IS_DEBUG_OSPF_EVENT)
ajs60925302004-12-08 17:45:02 +0000264 zlog_debug ("LSA[Flooding]: Got a self-originated LSA, "
paul718e3742002-12-13 20:15:29 +0000265 "while local one is initial instance.");
266 ; /* Accept this LSA for quick LSDB resynchronization. */
267 }
Paul Jakma2518efd2006-08-27 06:49:29 +0000268 else if (tv_cmp (tv_sub (recent_relative_time (), current->tv_recv),
paul718e3742002-12-13 20:15:29 +0000269 int2tv (OSPF_MIN_LS_ARRIVAL)) < 0)
270 {
271 if (IS_DEBUG_OSPF_EVENT)
ajs60925302004-12-08 17:45:02 +0000272 zlog_debug ("LSA[Flooding]: LSA is received recently.");
paul718e3742002-12-13 20:15:29 +0000273 return -1;
274 }
275 }
276
277 /* Flood the new LSA out some subset of the router's interfaces.
278 In some cases (e.g., the state of the receiving interface is
279 DR and the LSA was received from a router other than the
280 Backup DR) the LSA will be flooded back out the receiving
281 interface. */
paul68980082003-03-25 05:07:42 +0000282 lsa_ack_flag = ospf_flood_through (ospf, nbr, new);
paul718e3742002-12-13 20:15:29 +0000283
284#ifdef HAVE_OPAQUE_LSA
285 /* Remove the current database copy from all neighbors' Link state
286 retransmission lists. AS_EXTERNAL and AS_EXTERNAL_OPAQUE does
287 ^^^^^^^^^^^^^^^^^^^^^^^
288 not have area ID.
289 All other (even NSSA's) do have area ID. */
290#else /* HAVE_OPAQUE_LSA */
291 /* Remove the current database copy from all neighbors' Link state
292 retransmission lists. Only AS_EXTERNAL does not have area ID.
293 All other (even NSSA's) do have area ID. */
294#endif /* HAVE_OPAQUE_LSA */
295 if (current)
296 {
297 switch (current->data->type)
298 {
299 case OSPF_AS_EXTERNAL_LSA:
300#ifdef HAVE_OPAQUE_LSA
301 case OSPF_OPAQUE_AS_LSA:
302#endif /* HAVE_OPAQUE_LSA */
paul68980082003-03-25 05:07:42 +0000303 ospf_ls_retransmit_delete_nbr_as (ospf, current);
paul718e3742002-12-13 20:15:29 +0000304 break;
305 default:
paul68980082003-03-25 05:07:42 +0000306 ospf_ls_retransmit_delete_nbr_area (nbr->oi->area, current);
paul718e3742002-12-13 20:15:29 +0000307 break;
308 }
309 }
310
311 /* Do some internal house keeping that is needed here */
312 SET_FLAG (new->flags, OSPF_LSA_RECEIVED);
paul68980082003-03-25 05:07:42 +0000313 ospf_lsa_is_self_originated (ospf, new); /* Let it set the flag */
paul718e3742002-12-13 20:15:29 +0000314
315 /* Install the new LSA in the link state database
316 (replacing the current database copy). This may cause the
317 routing table calculation to be scheduled. In addition,
318 timestamp the new LSA with the current time. The flooding
319 procedure cannot overwrite the newly installed LSA until
320 MinLSArrival seconds have elapsed. */
321
CROSS6b161fc2011-09-26 13:17:21 +0400322 if (! (new = ospf_lsa_install (ospf, nbr->oi, new)))
Thomas Ries4de148e2011-10-27 17:43:38 +0400323 return -1; /* unknown LSA type or any other error condition */
paul718e3742002-12-13 20:15:29 +0000324
325 /* Acknowledge the receipt of the LSA by sending a Link State
326 Acknowledgment packet back out the receiving interface. */
327 if (lsa_ack_flag)
328 ospf_flood_delayed_lsa_ack (nbr, new);
329
330 /* If this new LSA indicates that it was originated by the
331 receiving router itself, the router must take special action,
332 either updating the LSA or in some cases flushing it from
333 the routing domain. */
paul68980082003-03-25 05:07:42 +0000334 if (ospf_lsa_is_self_originated (ospf, new))
335 ospf_process_self_originated_lsa (ospf, new, oi->area);
paul718e3742002-12-13 20:15:29 +0000336 else
337 /* Update statistics value for OSPF-MIB. */
paul68980082003-03-25 05:07:42 +0000338 ospf->rx_lsa_count++;
paul718e3742002-12-13 20:15:29 +0000339
340 return 0;
341}
342
343/* OSPF LSA flooding -- RFC2328 Section 13.3. */
paul4dadc292005-05-06 21:37:42 +0000344static int
paul718e3742002-12-13 20:15:29 +0000345ospf_flood_through_interface (struct ospf_interface *oi,
346 struct ospf_neighbor *inbr,
347 struct ospf_lsa *lsa)
348{
349 struct ospf_neighbor *onbr;
350 struct route_node *rn;
351 int retx_flag;
352
353 if (IS_DEBUG_OSPF_EVENT)
ajs60925302004-12-08 17:45:02 +0000354 zlog_debug ("ospf_flood_through_interface(): "
paul718e3742002-12-13 20:15:29 +0000355 "considering int %s, INBR(%s), LSA[%s]",
356 IF_NAME (oi), inbr ? inet_ntoa (inbr->router_id) : "NULL",
357 dump_lsa_key (lsa));
358
359 if (!ospf_if_is_enable (oi))
360 return 0;
361
362 /* Remember if new LSA is aded to a retransmit list. */
363 retx_flag = 0;
364
365 /* Each of the neighbors attached to this interface are examined,
366 to determine whether they must receive the new LSA. The following
367 steps are executed for each neighbor: */
368 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
369 {
370 struct ospf_lsa *ls_req;
371
372 if (rn->info == NULL)
373 continue;
374
375 onbr = rn->info;
376 if (IS_DEBUG_OSPF_EVENT)
ajs60925302004-12-08 17:45:02 +0000377 zlog_debug ("ospf_flood_through_interface(): considering nbr %s (%s)",
paul718e3742002-12-13 20:15:29 +0000378 inet_ntoa (onbr->router_id),
379 LOOKUP (ospf_nsm_state_msg, onbr->state));
380
381 /* If the neighbor is in a lesser state than Exchange, it
382 does not participate in flooding, and the next neighbor
383 should be examined. */
384 if (onbr->state < NSM_Exchange)
385 continue;
386
387 /* If the adjacency is not yet full (neighbor state is
388 Exchange or Loading), examine the Link state request
389 list associated with this adjacency. If there is an
390 instance of the new LSA on the list, it indicates that
391 the neighboring router has an instance of the LSA
392 already. Compare the new LSA to the neighbor's copy: */
393 if (onbr->state < NSM_Full)
394 {
395 if (IS_DEBUG_OSPF_EVENT)
ajs60925302004-12-08 17:45:02 +0000396 zlog_debug ("ospf_flood_through_interface(): nbr adj is not Full");
paul718e3742002-12-13 20:15:29 +0000397 ls_req = ospf_ls_request_lookup (onbr, lsa);
398 if (ls_req != NULL)
399 {
400 int ret;
401
402 ret = ospf_lsa_more_recent (ls_req, lsa);
403 /* The new LSA is less recent. */
404 if (ret > 0)
405 continue;
406 /* The two copies are the same instance, then delete
407 the LSA from the Link state request list. */
408 else if (ret == 0)
409 {
410 ospf_ls_request_delete (onbr, ls_req);
411 ospf_check_nbr_loading (onbr);
412 continue;
413 }
414 /* The new LSA is more recent. Delete the LSA
415 from the Link state request list. */
416 else
417 {
418 ospf_ls_request_delete (onbr, ls_req);
419 ospf_check_nbr_loading (onbr);
420 }
421 }
422 }
423
424#ifdef HAVE_OPAQUE_LSA
425 if (IS_OPAQUE_LSA (lsa->data->type))
426 {
427 if (! CHECK_FLAG (onbr->options, OSPF_OPTION_O))
428 {
429 if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
ajs60925302004-12-08 17:45:02 +0000430 zlog_debug ("Skip this neighbor: Not Opaque-capable.");
paul718e3742002-12-13 20:15:29 +0000431 continue;
432 }
433
paul29226d42003-12-06 17:10:11 +0000434 if (IS_OPAQUE_LSA_ORIGINATION_BLOCKED (oi->ospf->opaque)
paul718e3742002-12-13 20:15:29 +0000435 && IS_LSA_SELF (lsa)
436 && onbr->state == NSM_Full)
437 {
438 /* Small attempt to reduce unnecessary retransmission. */
439 if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
ajs60925302004-12-08 17:45:02 +0000440 zlog_debug ("Skip this neighbor: Initial flushing done.");
paul718e3742002-12-13 20:15:29 +0000441 continue;
442 }
443 }
444#endif /* HAVE_OPAQUE_LSA */
445
446 /* If the new LSA was received from this neighbor,
447 examine the next neighbor. */
448#ifdef ORIGINAL_CODING
449 if (inbr)
450 if (IPV4_ADDR_SAME (&inbr->router_id, &onbr->router_id))
451 continue;
452#else /* ORIGINAL_CODING */
453 if (inbr)
454 {
455 /*
456 * Triggered by LSUpd message parser "ospf_ls_upd ()".
457 * E.g., all LSAs handling here is received via network.
458 */
459 if (IPV4_ADDR_SAME (&inbr->router_id, &onbr->router_id))
460 {
461 if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
ajs60925302004-12-08 17:45:02 +0000462 zlog_debug ("Skip this neighbor: inbr == onbr");
paul718e3742002-12-13 20:15:29 +0000463 continue;
464 }
465 }
466 else
467 {
468 /*
469 * Triggered by MaxAge remover, so far.
470 * NULL "inbr" means flooding starts from this node.
471 */
472 if (IPV4_ADDR_SAME (&lsa->data->adv_router, &onbr->router_id))
473 {
474 if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
ajs60925302004-12-08 17:45:02 +0000475 zlog_debug ("Skip this neighbor: lsah->adv_router == onbr");
paul718e3742002-12-13 20:15:29 +0000476 continue;
477 }
478 }
479#endif /* ORIGINAL_CODING */
480
481 /* Add the new LSA to the Link state retransmission list
482 for the adjacency. The LSA will be retransmitted
483 at intervals until an acknowledgment is seen from
484 the neighbor. */
485 ospf_ls_retransmit_add (onbr, lsa);
486 retx_flag = 1;
487 }
488
489 /* If in the previous step, the LSA was NOT added to any of
490 the Link state retransmission lists, there is no need to
491 flood the LSA out the interface. */
492 if (retx_flag == 0)
493 {
494 return (inbr && inbr->oi == oi);
495 }
496
497 /* if we've received the lsa on this interface we need to perform
498 additional checking */
499 if (inbr && (inbr->oi == oi))
500 {
501 /* If the new LSA was received on this interface, and it was
502 received from either the Designated Router or the Backup
503 Designated Router, chances are that all the neighbors have
504 received the LSA already. */
505 if (NBR_IS_DR (inbr) || NBR_IS_BDR (inbr))
506 {
paul718e3742002-12-13 20:15:29 +0000507 if (IS_DEBUG_OSPF_NSSA)
ajs60925302004-12-08 17:45:02 +0000508 zlog_debug ("ospf_flood_through_interface(): "
paul718e3742002-12-13 20:15:29 +0000509 "DR/BDR NOT SEND to int %s", IF_NAME (oi));
paul718e3742002-12-13 20:15:29 +0000510 return 1;
511 }
512
513 /* If the new LSA was received on this interface, and the
514 interface state is Backup, examine the next interface. The
515 Designated Router will do the flooding on this interface.
516 However, if the Designated Router fails the router will
517 end up retransmitting the updates. */
518
519 if (oi->state == ISM_Backup)
520 {
paul718e3742002-12-13 20:15:29 +0000521 if (IS_DEBUG_OSPF_NSSA)
ajs60925302004-12-08 17:45:02 +0000522 zlog_debug ("ospf_flood_through_interface(): "
paul718e3742002-12-13 20:15:29 +0000523 "ISM_Backup NOT SEND to int %s", IF_NAME (oi));
paul718e3742002-12-13 20:15:29 +0000524 return 1;
525 }
526 }
527
528 /* The LSA must be flooded out the interface. Send a Link State
529 Update packet (including the new LSA as contents) out the
530 interface. The LSA's LS age must be incremented by InfTransDelay
531 (which must be > 0) when it is copied into the outgoing Link
532 State Update packet (until the LS age field reaches the maximum
533 value of MaxAge). */
hassobeebba72004-06-20 21:00:27 +0000534 /* XXX HASSO: Is this IS_DEBUG_OSPF_NSSA really correct? */
paul718e3742002-12-13 20:15:29 +0000535 if (IS_DEBUG_OSPF_NSSA)
ajs60925302004-12-08 17:45:02 +0000536 zlog_debug ("ospf_flood_through_interface(): "
paul718e3742002-12-13 20:15:29 +0000537 "DR/BDR sending upd to int %s", IF_NAME (oi));
paul718e3742002-12-13 20:15:29 +0000538
539 /* RFC2328 Section 13.3
540 On non-broadcast networks, separate Link State Update
541 packets must be sent, as unicasts, to each adjacent neighbor
542 (i.e., those in state Exchange or greater). The destination
543 IP addresses for these packets are the neighbors' IP
544 addresses. */
545 if (oi->type == OSPF_IFTYPE_NBMA)
546 {
547 struct route_node *rn;
548 struct ospf_neighbor *nbr;
549
550 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
551 if ((nbr = rn->info) != NULL)
552 if (nbr != oi->nbr_self && nbr->state >= NSM_Exchange)
553 ospf_ls_upd_send_lsa (nbr, lsa, OSPF_SEND_PACKET_DIRECT);
554 }
555 else
556 ospf_ls_upd_send_lsa (oi->nbr_self, lsa, OSPF_SEND_PACKET_INDIRECT);
557
558 return 0;
559}
560
561int
paul68980082003-03-25 05:07:42 +0000562ospf_flood_through_area (struct ospf_area *area,
563 struct ospf_neighbor *inbr, struct ospf_lsa *lsa)
paul718e3742002-12-13 20:15:29 +0000564{
paul1eb8ef22005-04-07 07:30:20 +0000565 struct listnode *node, *nnode;
566 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +0000567 int lsa_ack_flag = 0;
568
569 /* All other types are specific to a single area (Area A). The
570 eligible interfaces are all those interfaces attaching to the
571 Area A. If Area A is the backbone, this includes all the virtual
572 links. */
paul1eb8ef22005-04-07 07:30:20 +0000573 for (ALL_LIST_ELEMENTS (area->oiflist, node, nnode, oi))
paul718e3742002-12-13 20:15:29 +0000574 {
paul718e3742002-12-13 20:15:29 +0000575 if (area->area_id.s_addr != OSPF_AREA_BACKBONE &&
576 oi->type == OSPF_IFTYPE_VIRTUALLINK)
577 continue;
578
579#ifdef HAVE_OPAQUE_LSA
580 if ((lsa->data->type == OSPF_OPAQUE_LINK_LSA) && (lsa->oi != oi))
581 {
582 /*
583 * Link local scoped Opaque-LSA should only be flooded
584 * for the link on which the LSA has received.
585 */
586 if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
David Lampartereed3c482015-03-03 08:51:53 +0100587 zlog_debug ("Type-9 Opaque-LSA: lsa->oi(%p) != oi(%p)",
588 (void *)lsa->oi, (void *)oi);
paul718e3742002-12-13 20:15:29 +0000589 continue;
590 }
591#endif /* HAVE_OPAQUE_LSA */
592
593 if (ospf_flood_through_interface (oi, inbr, lsa))
594 lsa_ack_flag = 1;
595 }
596
597 return (lsa_ack_flag);
598}
599
600int
paul68980082003-03-25 05:07:42 +0000601ospf_flood_through_as (struct ospf *ospf, struct ospf_neighbor *inbr,
602 struct ospf_lsa *lsa)
paul718e3742002-12-13 20:15:29 +0000603{
hasso52dc7ee2004-09-23 19:18:23 +0000604 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +0000605 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +0000606 int lsa_ack_flag;
607
608 lsa_ack_flag = 0;
609
610 /* The incoming LSA is type 5 or type 7 (AS-EXTERNAL or AS-NSSA )
611
612 Divert the Type-5 LSA's to all non-NSSA/STUB areas
613
614 Divert the Type-7 LSA's to all NSSA areas
615
616 AS-external-LSAs are flooded throughout the entire AS, with the
617 exception of stub areas (see Section 3.6). The eligible
618 interfaces are all the router's interfaces, excluding virtual
619 links and those interfaces attaching to stub areas. */
620
paul718e3742002-12-13 20:15:29 +0000621 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)) /* Translated from 7 */
622 if (IS_DEBUG_OSPF_NSSA)
ajs60925302004-12-08 17:45:02 +0000623 zlog_debug ("Flood/AS: NSSA TRANSLATED LSA");
paul718e3742002-12-13 20:15:29 +0000624
paul1eb8ef22005-04-07 07:30:20 +0000625 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +0000626 {
627 int continue_flag = 0;
hasso52dc7ee2004-09-23 19:18:23 +0000628 struct listnode *if_node;
paul1eb8ef22005-04-07 07:30:20 +0000629 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +0000630
631 switch (area->external_routing)
632 {
633 /* Don't send AS externals into stub areas. Various types
634 of support for partial stub areas can be implemented
635 here. NSSA's will receive Type-7's that have areas
636 matching the originl LSA. */
637 case OSPF_AREA_NSSA: /* Sending Type 5 or 7 into NSSA area */
paul718e3742002-12-13 20:15:29 +0000638 /* Type-7, flood NSSA area */
paul68980082003-03-25 05:07:42 +0000639 if (lsa->data->type == OSPF_AS_NSSA_LSA
640 && area == lsa->area)
paul718e3742002-12-13 20:15:29 +0000641 /* We will send it. */
642 continue_flag = 0;
paul68980082003-03-25 05:07:42 +0000643 else
paul718e3742002-12-13 20:15:29 +0000644 continue_flag = 1; /* Skip this NSSA area for Type-5's et al */
paul718e3742002-12-13 20:15:29 +0000645 break;
paul718e3742002-12-13 20:15:29 +0000646
647 case OSPF_AREA_TYPE_MAX:
648 case OSPF_AREA_STUB:
649 continue_flag = 1; /* Skip this area. */
650 break;
651
652 case OSPF_AREA_DEFAULT:
653 default:
paul718e3742002-12-13 20:15:29 +0000654 /* No Type-7 into normal area */
655 if (lsa->data->type == OSPF_AS_NSSA_LSA)
656 continue_flag = 1; /* skip Type-7 */
657 else
paul718e3742002-12-13 20:15:29 +0000658 continue_flag = 0; /* Do this area. */
659 break;
660 }
661
662 /* Do continue for above switch. Saves a big if then mess */
663 if (continue_flag)
664 continue; /* main for-loop */
665
666 /* send to every interface in this area */
667
paul1eb8ef22005-04-07 07:30:20 +0000668 for (ALL_LIST_ELEMENTS_RO (area->oiflist, if_node, oi))
paul718e3742002-12-13 20:15:29 +0000669 {
paul718e3742002-12-13 20:15:29 +0000670 /* Skip virtual links */
671 if (oi->type != OSPF_IFTYPE_VIRTUALLINK)
672 if (ospf_flood_through_interface (oi, inbr, lsa)) /* lsa */
673 lsa_ack_flag = 1;
674 }
675 } /* main area for-loop */
676
677 return (lsa_ack_flag);
678}
679
680int
paul68980082003-03-25 05:07:42 +0000681ospf_flood_through (struct ospf *ospf,
682 struct ospf_neighbor *inbr, struct ospf_lsa *lsa)
paul718e3742002-12-13 20:15:29 +0000683{
684 int lsa_ack_flag = 0;
685
686 /* Type-7 LSA's for NSSA are flooded throughout the AS here, and
687 upon return are updated in the LSDB for Type-7's. Later,
688 re-fresh will re-send them (and also, if ABR, packet code will
689 translate to Type-5's)
690
691 As usual, Type-5 LSA's (if not DISCARDED because we are STUB or
692 NSSA) are flooded throughout the AS, and are updated in the
693 global table. */
694#ifdef ORIGINAL_CODING
695 switch (lsa->data->type)
696 {
697 case OSPF_ROUTER_LSA:
698 case OSPF_NETWORK_LSA:
699 case OSPF_SUMMARY_LSA:
700 case OSPF_ASBR_SUMMARY_LSA:
701#ifdef HAVE_OPAQUE_LSA
702 case OSPF_OPAQUE_LINK_LSA: /* ospf_flood_through_interface ? */
703 case OSPF_OPAQUE_AREA_LSA:
704#endif /* HAVE_OPAQUE_LSA */
705 lsa_ack_flag = ospf_flood_through_area (inbr->oi->area, inbr, lsa);
706 break;
707 case OSPF_AS_EXTERNAL_LSA: /* Type-5 */
708#ifdef HAVE_OPAQUE_LSA
709 case OSPF_OPAQUE_AS_LSA:
710#endif /* HAVE_OPAQUE_LSA */
paul68980082003-03-25 05:07:42 +0000711 lsa_ack_flag = ospf_flood_through_as (ospf, inbr, lsa);
paul718e3742002-12-13 20:15:29 +0000712 break;
paul718e3742002-12-13 20:15:29 +0000713 /* Type-7 Only received within NSSA, then flooded */
714 case OSPF_AS_NSSA_LSA:
715 /* Any P-bit was installed with the Type-7. */
716 lsa_ack_flag = ospf_flood_through_area (inbr->oi->area, inbr, lsa);
717
718 if (IS_DEBUG_OSPF_NSSA)
ajs60925302004-12-08 17:45:02 +0000719 zlog_debug ("ospf_flood_through: LOCAL NSSA FLOOD of Type-7.");
paul718e3742002-12-13 20:15:29 +0000720 break;
paul718e3742002-12-13 20:15:29 +0000721 default:
722 break;
723 }
724#else /* ORIGINAL_CODING */
725 /*
726 * At the common sub-sub-function "ospf_flood_through_interface()",
727 * a parameter "inbr" will be used to distinguish the called context
728 * whether the given LSA was received from the neighbor, or the
729 * flooding for the LSA starts from this node (e.g. the LSA was self-
730 * originated, or the LSA is going to be flushed from routing domain).
731 *
732 * So, for consistency reasons, this function "ospf_flood_through()"
733 * should also allow the usage that the given "inbr" parameter to be
734 * NULL. If we do so, corresponding AREA parameter should be referred
735 * by "lsa->area", instead of "inbr->oi->area".
736 */
737 switch (lsa->data->type)
738 {
739 case OSPF_AS_EXTERNAL_LSA: /* Type-5 */
740#ifdef HAVE_OPAQUE_LSA
741 case OSPF_OPAQUE_AS_LSA:
742#endif /* HAVE_OPAQUE_LSA */
paul68980082003-03-25 05:07:42 +0000743 lsa_ack_flag = ospf_flood_through_as (ospf, inbr, lsa);
paul718e3742002-12-13 20:15:29 +0000744 break;
paul718e3742002-12-13 20:15:29 +0000745 /* Type-7 Only received within NSSA, then flooded */
746 case OSPF_AS_NSSA_LSA:
747 /* Any P-bit was installed with the Type-7. */
748
749 if (IS_DEBUG_OSPF_NSSA)
ajs60925302004-12-08 17:45:02 +0000750 zlog_debug ("ospf_flood_through: LOCAL NSSA FLOOD of Type-7.");
paul718e3742002-12-13 20:15:29 +0000751 /* Fallthrough */
paul718e3742002-12-13 20:15:29 +0000752 default:
753 lsa_ack_flag = ospf_flood_through_area (lsa->area, inbr, lsa);
754 break;
755 }
756#endif /* ORIGINAL_CODING */
757
758 return (lsa_ack_flag);
759}
760
David Lamparter6b0655a2014-06-04 06:53:35 +0200761
paul718e3742002-12-13 20:15:29 +0000762
763/* Management functions for neighbor's Link State Request list. */
764void
765ospf_ls_request_add (struct ospf_neighbor *nbr, struct ospf_lsa *lsa)
766{
767 /*
768 * We cannot make use of the newly introduced callback function
769 * "lsdb->new_lsa_hook" to replace debug output below, just because
770 * it seems no simple and smart way to pass neighbor information to
771 * the common function "ospf_lsdb_add()" -- endo.
772 */
773 if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
ajs60925302004-12-08 17:45:02 +0000774 zlog_debug ("RqstL(%lu)++, NBR(%s), LSA[%s]",
paul718e3742002-12-13 20:15:29 +0000775 ospf_ls_request_count (nbr),
776 inet_ntoa (nbr->router_id), dump_lsa_key (lsa));
777
778 ospf_lsdb_add (&nbr->ls_req, lsa);
779}
780
781unsigned long
782ospf_ls_request_count (struct ospf_neighbor *nbr)
783{
784 return ospf_lsdb_count_all (&nbr->ls_req);
785}
786
787int
788ospf_ls_request_isempty (struct ospf_neighbor *nbr)
789{
790 return ospf_lsdb_isempty (&nbr->ls_req);
791}
792
793/* Remove LSA from neighbor's ls-request list. */
794void
795ospf_ls_request_delete (struct ospf_neighbor *nbr, struct ospf_lsa *lsa)
796{
797 if (nbr->ls_req_last == lsa)
798 {
Paul Jakma1fe6ed32006-07-26 09:37:26 +0000799 ospf_lsa_unlock (&nbr->ls_req_last);
paul718e3742002-12-13 20:15:29 +0000800 nbr->ls_req_last = NULL;
801 }
802
803 if (IS_DEBUG_OSPF (lsa, LSA_FLOODING)) /* -- endo. */
ajs60925302004-12-08 17:45:02 +0000804 zlog_debug ("RqstL(%lu)--, NBR(%s), LSA[%s]",
paul718e3742002-12-13 20:15:29 +0000805 ospf_ls_request_count (nbr),
806 inet_ntoa (nbr->router_id), dump_lsa_key (lsa));
807
808 ospf_lsdb_delete (&nbr->ls_req, lsa);
809}
810
811/* Remove all LSA from neighbor's ls-requenst list. */
812void
813ospf_ls_request_delete_all (struct ospf_neighbor *nbr)
814{
Paul Jakma1fe6ed32006-07-26 09:37:26 +0000815 ospf_lsa_unlock (&nbr->ls_req_last);
paul718e3742002-12-13 20:15:29 +0000816 nbr->ls_req_last = NULL;
817 ospf_lsdb_delete_all (&nbr->ls_req);
818}
819
820/* Lookup LSA from neighbor's ls-request list. */
821struct ospf_lsa *
822ospf_ls_request_lookup (struct ospf_neighbor *nbr, struct ospf_lsa *lsa)
823{
824 return ospf_lsdb_lookup (&nbr->ls_req, lsa);
825}
826
827struct ospf_lsa *
828ospf_ls_request_new (struct lsa_header *lsah)
829{
830 struct ospf_lsa *new;
831
832 new = ospf_lsa_new ();
833 new->data = ospf_lsa_data_new (OSPF_LSA_HEADER_SIZE);
834 memcpy (new->data, lsah, OSPF_LSA_HEADER_SIZE);
835
836 return new;
837}
838
David Lamparter6b0655a2014-06-04 06:53:35 +0200839
paul718e3742002-12-13 20:15:29 +0000840/* Management functions for neighbor's ls-retransmit list. */
841unsigned long
842ospf_ls_retransmit_count (struct ospf_neighbor *nbr)
843{
844 return ospf_lsdb_count_all (&nbr->ls_rxmt);
845}
846
847unsigned long
848ospf_ls_retransmit_count_self (struct ospf_neighbor *nbr, int lsa_type)
849{
850 return ospf_lsdb_count_self (&nbr->ls_rxmt, lsa_type);
851}
852
853int
854ospf_ls_retransmit_isempty (struct ospf_neighbor *nbr)
855{
856 return ospf_lsdb_isempty (&nbr->ls_rxmt);
857}
858
859/* Add LSA to be retransmitted to neighbor's ls-retransmit list. */
860void
861ospf_ls_retransmit_add (struct ospf_neighbor *nbr, struct ospf_lsa *lsa)
862{
863 struct ospf_lsa *old;
864
865 old = ospf_ls_retransmit_lookup (nbr, lsa);
866
867 if (ospf_lsa_more_recent (old, lsa) < 0)
868 {
869 if (old)
870 {
871 old->retransmit_counter--;
872 ospf_lsdb_delete (&nbr->ls_rxmt, old);
873 }
874 lsa->retransmit_counter++;
875 /*
876 * We cannot make use of the newly introduced callback function
877 * "lsdb->new_lsa_hook" to replace debug output below, just because
878 * it seems no simple and smart way to pass neighbor information to
879 * the common function "ospf_lsdb_add()" -- endo.
880 */
881 if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
ajs60925302004-12-08 17:45:02 +0000882 zlog_debug ("RXmtL(%lu)++, NBR(%s), LSA[%s]",
paul718e3742002-12-13 20:15:29 +0000883 ospf_ls_retransmit_count (nbr),
884 inet_ntoa (nbr->router_id), dump_lsa_key (lsa));
885 ospf_lsdb_add (&nbr->ls_rxmt, lsa);
886 }
887}
888
889/* Remove LSA from neibghbor's ls-retransmit list. */
890void
891ospf_ls_retransmit_delete (struct ospf_neighbor *nbr, struct ospf_lsa *lsa)
892{
893 if (ospf_ls_retransmit_lookup (nbr, lsa))
894 {
895 lsa->retransmit_counter--;
896 if (IS_DEBUG_OSPF (lsa, LSA_FLOODING)) /* -- endo. */
ajs60925302004-12-08 17:45:02 +0000897 zlog_debug ("RXmtL(%lu)--, NBR(%s), LSA[%s]",
paul718e3742002-12-13 20:15:29 +0000898 ospf_ls_retransmit_count (nbr),
899 inet_ntoa (nbr->router_id), dump_lsa_key (lsa));
900 ospf_lsdb_delete (&nbr->ls_rxmt, lsa);
901 }
902}
903
904/* Clear neighbor's ls-retransmit list. */
905void
906ospf_ls_retransmit_clear (struct ospf_neighbor *nbr)
907{
908 struct ospf_lsdb *lsdb;
909 int i;
910
911 lsdb = &nbr->ls_rxmt;
912
913 for (i = OSPF_MIN_LSA; i < OSPF_MAX_LSA; i++)
914 {
915 struct route_table *table = lsdb->type[i].db;
916 struct route_node *rn;
917 struct ospf_lsa *lsa;
918
919 for (rn = route_top (table); rn; rn = route_next (rn))
920 if ((lsa = rn->info) != NULL)
921 ospf_ls_retransmit_delete (nbr, lsa);
922 }
923
Paul Jakma1fe6ed32006-07-26 09:37:26 +0000924 ospf_lsa_unlock (&nbr->ls_req_last);
paul718e3742002-12-13 20:15:29 +0000925 nbr->ls_req_last = NULL;
926}
927
928/* Lookup LSA from neighbor's ls-retransmit list. */
929struct ospf_lsa *
930ospf_ls_retransmit_lookup (struct ospf_neighbor *nbr, struct ospf_lsa *lsa)
931{
932 return ospf_lsdb_lookup (&nbr->ls_rxmt, lsa);
933}
934
paul4dadc292005-05-06 21:37:42 +0000935static void
paul68980082003-03-25 05:07:42 +0000936ospf_ls_retransmit_delete_nbr_if (struct ospf_interface *oi,
937 struct ospf_lsa *lsa)
paul718e3742002-12-13 20:15:29 +0000938{
paul68980082003-03-25 05:07:42 +0000939 struct route_node *rn;
940 struct ospf_neighbor *nbr;
941 struct ospf_lsa *lsr;
942
943 if (ospf_if_is_enable (oi))
944 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
945 /* If LSA find in LS-retransmit list, then remove it. */
946 if ((nbr = rn->info) != NULL)
947 {
948 lsr = ospf_ls_retransmit_lookup (nbr, lsa);
paul718e3742002-12-13 20:15:29 +0000949
paul68980082003-03-25 05:07:42 +0000950 /* If LSA find in ls-retransmit list, remove it. */
951 if (lsr != NULL && lsr->data->ls_seqnum == lsa->data->ls_seqnum)
952 ospf_ls_retransmit_delete (nbr, lsr);
953 }
paul718e3742002-12-13 20:15:29 +0000954}
955
paul718e3742002-12-13 20:15:29 +0000956void
paul68980082003-03-25 05:07:42 +0000957ospf_ls_retransmit_delete_nbr_area (struct ospf_area *area,
958 struct ospf_lsa *lsa)
paul718e3742002-12-13 20:15:29 +0000959{
paul1eb8ef22005-04-07 07:30:20 +0000960 struct listnode *node, *nnode;
961 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +0000962
paul1eb8ef22005-04-07 07:30:20 +0000963 for (ALL_LIST_ELEMENTS (area->oiflist, node, nnode, oi))
964 ospf_ls_retransmit_delete_nbr_if (oi, lsa);
paul68980082003-03-25 05:07:42 +0000965}
paul718e3742002-12-13 20:15:29 +0000966
paul68980082003-03-25 05:07:42 +0000967void
968ospf_ls_retransmit_delete_nbr_as (struct ospf *ospf, struct ospf_lsa *lsa)
969{
paul1eb8ef22005-04-07 07:30:20 +0000970 struct listnode *node, *nnode;
971 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +0000972
paul1eb8ef22005-04-07 07:30:20 +0000973 for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi))
974 ospf_ls_retransmit_delete_nbr_if (oi, lsa);
paul718e3742002-12-13 20:15:29 +0000975}
976
David Lamparter6b0655a2014-06-04 06:53:35 +0200977
paul718e3742002-12-13 20:15:29 +0000978/* Sets ls_age to MaxAge and floods throu the area.
979 When we implement ASE routing, there will be anothe function
980 flushing an LSA from the whole domain. */
981void
982ospf_lsa_flush_area (struct ospf_lsa *lsa, struct ospf_area *area)
983{
Dinesh G Dutt8306be22014-09-30 14:11:17 -0700984 /* Reset the lsa origination time such that it gives
985 more time for the ACK to be received and avoid
986 retransmissions */
paul718e3742002-12-13 20:15:29 +0000987 lsa->data->ls_age = htons (OSPF_LSA_MAXAGE);
Dinesh G Dutt8306be22014-09-30 14:11:17 -0700988 lsa->tv_recv = recent_relative_time ();
989 lsa->tv_orig = lsa->tv_recv;
paul718e3742002-12-13 20:15:29 +0000990 ospf_flood_through_area (area, NULL, lsa);
paul68980082003-03-25 05:07:42 +0000991 ospf_lsa_maxage (area->ospf, lsa);
paul718e3742002-12-13 20:15:29 +0000992}
993
994void
paul68980082003-03-25 05:07:42 +0000995ospf_lsa_flush_as (struct ospf *ospf, struct ospf_lsa *lsa)
paul718e3742002-12-13 20:15:29 +0000996{
Dinesh G Dutt8306be22014-09-30 14:11:17 -0700997 /* Reset the lsa origination time such that it gives
998 more time for the ACK to be received and avoid
999 retransmissions */
paul718e3742002-12-13 20:15:29 +00001000 lsa->data->ls_age = htons (OSPF_LSA_MAXAGE);
Dinesh G Dutt8306be22014-09-30 14:11:17 -07001001 lsa->tv_recv = recent_relative_time ();
1002 lsa->tv_orig = lsa->tv_recv;
paul68980082003-03-25 05:07:42 +00001003 ospf_flood_through_as (ospf, NULL, lsa);
1004 ospf_lsa_maxage (ospf, lsa);
paul718e3742002-12-13 20:15:29 +00001005}
Paul Jakma02d942c2010-01-24 23:36:20 +00001006
1007void
1008ospf_lsa_flush (struct ospf *ospf, struct ospf_lsa *lsa)
1009{
1010 lsa->data->ls_age = htons (OSPF_LSA_MAXAGE);
1011
1012 switch (lsa->data->type)
1013 {
1014 case OSPF_ROUTER_LSA:
1015 case OSPF_NETWORK_LSA:
1016 case OSPF_SUMMARY_LSA:
1017 case OSPF_ASBR_SUMMARY_LSA:
1018 case OSPF_AS_NSSA_LSA:
1019#ifdef HAVE_OPAQUE_LSA
1020 case OSPF_OPAQUE_LINK_LSA:
1021 case OSPF_OPAQUE_AREA_LSA:
1022#endif /* HAVE_OPAQUE_LSA */
1023 ospf_lsa_flush_area (lsa, lsa->area);
1024 break;
1025 case OSPF_AS_EXTERNAL_LSA:
1026#ifdef HAVE_OPAQUE_LSA
1027 case OSPF_OPAQUE_AS_LSA:
1028#endif /* HAVE_OPAQUE_LSA */
1029 ospf_lsa_flush_as (ospf, lsa);
1030 break;
1031 default:
1032 zlog_info ("%s: Unknown LSA type %u", __func__, lsa->data->type);
1033 break;
1034 }
1035}