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