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