hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2003 Yasuhiro Ohara |
| 3 | * |
| 4 | * This file is part of GNU Zebra. |
| 5 | * |
| 6 | * GNU Zebra is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License as published by the |
| 8 | * Free Software Foundation; either version 2, or (at your option) any |
| 9 | * later version. |
| 10 | * |
| 11 | * GNU Zebra is distributed in the hope that it will be useful, but |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with GNU Zebra; see the file COPYING. If not, write to the |
| 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 19 | * Boston, MA 02111-1307, USA. |
| 20 | */ |
| 21 | |
| 22 | #include <zebra.h> |
| 23 | |
| 24 | #include "log.h" |
| 25 | #include "thread.h" |
| 26 | #include "linklist.h" |
| 27 | #include "vty.h" |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 28 | #include "command.h" |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 29 | |
| 30 | #include "ospf6d.h" |
| 31 | #include "ospf6_proto.h" |
| 32 | #include "ospf6_lsa.h" |
| 33 | #include "ospf6_lsdb.h" |
| 34 | #include "ospf6_message.h" |
| 35 | #include "ospf6_route.h" |
| 36 | #include "ospf6_spf.h" |
| 37 | |
| 38 | #include "ospf6_top.h" |
| 39 | #include "ospf6_area.h" |
| 40 | #include "ospf6_interface.h" |
| 41 | #include "ospf6_neighbor.h" |
| 42 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 43 | #include "ospf6_flood.h" |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 44 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 45 | unsigned char conf_debug_ospf6_flooding; |
| 46 | |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 47 | struct ospf6_lsdb * |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 48 | ospf6_get_scoped_lsdb (struct ospf6_lsa *lsa) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 49 | { |
| 50 | struct ospf6_lsdb *lsdb = NULL; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 51 | switch (OSPF6_LSA_SCOPE (lsa->header->type)) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 52 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 53 | case OSPF6_SCOPE_LINKLOCAL: |
| 54 | lsdb = OSPF6_INTERFACE (lsa->lsdb->data)->lsdb; |
| 55 | break; |
| 56 | case OSPF6_SCOPE_AREA: |
| 57 | lsdb = OSPF6_AREA (lsa->lsdb->data)->lsdb; |
| 58 | break; |
| 59 | case OSPF6_SCOPE_AS: |
| 60 | lsdb = OSPF6_PROCESS (lsa->lsdb->data)->lsdb; |
| 61 | break; |
| 62 | default: |
| 63 | assert (0); |
| 64 | break; |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 65 | } |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 66 | return lsdb; |
| 67 | } |
| 68 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 69 | struct ospf6_lsdb * |
| 70 | ospf6_get_scoped_lsdb_self (struct ospf6_lsa *lsa) |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 71 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 72 | struct ospf6_lsdb *lsdb_self = NULL; |
| 73 | switch (OSPF6_LSA_SCOPE (lsa->header->type)) |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 74 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 75 | case OSPF6_SCOPE_LINKLOCAL: |
| 76 | lsdb_self = OSPF6_INTERFACE (lsa->lsdb->data)->lsdb_self; |
| 77 | break; |
| 78 | case OSPF6_SCOPE_AREA: |
| 79 | lsdb_self = OSPF6_AREA (lsa->lsdb->data)->lsdb_self; |
| 80 | break; |
| 81 | case OSPF6_SCOPE_AS: |
| 82 | lsdb_self = OSPF6_PROCESS (lsa->lsdb->data)->lsdb_self; |
| 83 | break; |
| 84 | default: |
| 85 | assert (0); |
| 86 | break; |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 87 | } |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 88 | return lsdb_self; |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | void |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 92 | ospf6_lsa_originate (struct ospf6_lsa *lsa) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 93 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 94 | struct ospf6_lsa *old; |
| 95 | struct ospf6_lsdb *lsdb_self; |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 96 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 97 | /* find previous LSA */ |
| 98 | old = ospf6_lsdb_lookup (lsa->header->type, lsa->header->id, |
| 99 | lsa->header->adv_router, lsa->lsdb); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 100 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 101 | /* if the new LSA does not differ from previous, |
| 102 | suppress this update of the LSA */ |
| 103 | if (old && ! OSPF6_LSA_IS_DIFFER (lsa, old)) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 104 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 105 | if (IS_OSPF6_DEBUG_ORIGINATE_TYPE (lsa->header->type)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 106 | zlog_debug ("Suppress updating LSA: %s", lsa->name); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 107 | ospf6_lsa_delete (lsa); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 108 | return; |
| 109 | } |
| 110 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 111 | /* store it in the LSDB for self-originated LSAs */ |
| 112 | lsdb_self = ospf6_get_scoped_lsdb_self (lsa); |
| 113 | ospf6_lsdb_add (ospf6_lsa_copy (lsa), lsdb_self); |
| 114 | |
| 115 | lsa->refresh = thread_add_timer (master, ospf6_lsa_refresh, lsa, |
Dinesh Dutt | 8551e6d | 2013-10-22 17:42:18 -0700 | [diff] [blame] | 116 | OSPF_LS_REFRESH_TIME); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 117 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 118 | if (IS_OSPF6_DEBUG_LSA_TYPE (lsa->header->type) || |
| 119 | IS_OSPF6_DEBUG_ORIGINATE_TYPE (lsa->header->type)) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 120 | { |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 121 | zlog_debug ("LSA Originate:"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 122 | ospf6_lsa_header_print (lsa); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 123 | } |
| 124 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 125 | ospf6_install_lsa (lsa); |
Dinesh Dutt | bf986da | 2013-08-24 07:54:50 +0000 | [diff] [blame] | 126 | ospf6_flood (NULL, lsa); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | void |
| 130 | ospf6_lsa_originate_process (struct ospf6_lsa *lsa, |
| 131 | struct ospf6 *process) |
| 132 | { |
| 133 | lsa->lsdb = process->lsdb; |
| 134 | ospf6_lsa_originate (lsa); |
| 135 | } |
| 136 | |
| 137 | void |
| 138 | ospf6_lsa_originate_area (struct ospf6_lsa *lsa, |
| 139 | struct ospf6_area *oa) |
| 140 | { |
| 141 | lsa->lsdb = oa->lsdb; |
| 142 | ospf6_lsa_originate (lsa); |
| 143 | } |
| 144 | |
| 145 | void |
| 146 | ospf6_lsa_originate_interface (struct ospf6_lsa *lsa, |
| 147 | struct ospf6_interface *oi) |
| 148 | { |
| 149 | lsa->lsdb = oi->lsdb; |
| 150 | ospf6_lsa_originate (lsa); |
| 151 | } |
| 152 | |
| 153 | void |
| 154 | ospf6_lsa_purge (struct ospf6_lsa *lsa) |
| 155 | { |
| 156 | struct ospf6_lsa *self; |
| 157 | struct ospf6_lsdb *lsdb_self; |
| 158 | |
| 159 | /* remove it from the LSDB for self-originated LSAs */ |
| 160 | lsdb_self = ospf6_get_scoped_lsdb_self (lsa); |
| 161 | self = ospf6_lsdb_lookup (lsa->header->type, lsa->header->id, |
| 162 | lsa->header->adv_router, lsdb_self); |
| 163 | if (self) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 164 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 165 | THREAD_OFF (self->expire); |
| 166 | THREAD_OFF (self->refresh); |
| 167 | ospf6_lsdb_remove (self, lsdb_self); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 168 | } |
| 169 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 170 | ospf6_lsa_premature_aging (lsa); |
| 171 | } |
| 172 | |
| 173 | |
| 174 | void |
| 175 | ospf6_increment_retrans_count (struct ospf6_lsa *lsa) |
| 176 | { |
| 177 | /* The LSA must be the original one (see the description |
| 178 | in ospf6_decrement_retrans_count () below) */ |
| 179 | lsa->retrans_count++; |
| 180 | } |
| 181 | |
| 182 | void |
| 183 | ospf6_decrement_retrans_count (struct ospf6_lsa *lsa) |
| 184 | { |
| 185 | struct ospf6_lsdb *lsdb; |
| 186 | struct ospf6_lsa *orig; |
| 187 | |
| 188 | /* The LSA must be on the retrans-list of a neighbor. It means |
| 189 | the "lsa" is a copied one, and we have to decrement the |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 190 | retransmission count of the original one (instead of this "lsa"'s). |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 191 | In order to find the original LSA, first we have to find |
| 192 | appropriate LSDB that have the original LSA. */ |
| 193 | lsdb = ospf6_get_scoped_lsdb (lsa); |
| 194 | |
| 195 | /* Find the original LSA of which the retrans_count should be decremented */ |
| 196 | orig = ospf6_lsdb_lookup (lsa->header->type, lsa->header->id, |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 197 | lsa->header->adv_router, lsdb); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 198 | if (orig) |
hasso | 6861b30 | 2004-08-26 18:19:59 +0000 | [diff] [blame] | 199 | { |
| 200 | orig->retrans_count--; |
| 201 | assert (orig->retrans_count >= 0); |
| 202 | } |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | /* RFC2328 section 13.2 Installing LSAs in the database */ |
| 206 | void |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 207 | ospf6_install_lsa (struct ospf6_lsa *lsa) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 208 | { |
| 209 | struct ospf6_lsa *old; |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 210 | struct timeval now; |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 211 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 212 | if (IS_OSPF6_DEBUG_LSA_TYPE (lsa->header->type) || |
| 213 | IS_OSPF6_DEBUG_EXAMIN_TYPE (lsa->header->type)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 214 | zlog_debug ("Install LSA: %s", lsa->name); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 215 | |
| 216 | /* Remove the old instance from all neighbors' Link state |
| 217 | retransmission list (RFC2328 13.2 last paragraph) */ |
| 218 | old = ospf6_lsdb_lookup (lsa->header->type, lsa->header->id, |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 219 | lsa->header->adv_router, lsa->lsdb); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 220 | if (old) |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 221 | { |
| 222 | THREAD_OFF (old->expire); |
| 223 | ospf6_flood_clear (old); |
| 224 | } |
| 225 | |
Takashi Sogabe | 86f72dc | 2009-06-22 13:07:02 +0900 | [diff] [blame] | 226 | quagga_gettime (QUAGGA_CLK_MONOTONIC, &now); |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 227 | if (! OSPF6_LSA_IS_MAXAGE (lsa)) |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 228 | lsa->expire = thread_add_timer (master, ospf6_lsa_expire, lsa, |
Dinesh Dutt | 8551e6d | 2013-10-22 17:42:18 -0700 | [diff] [blame] | 229 | OSPF_LSA_MAXAGE + lsa->birth.tv_sec - now.tv_sec); |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 230 | else |
| 231 | lsa->expire = NULL; |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 232 | |
| 233 | /* actually install */ |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 234 | lsa->installed = now; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 235 | ospf6_lsdb_add (lsa, lsa->lsdb); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 236 | |
| 237 | return; |
| 238 | } |
| 239 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 240 | /* RFC2740 section 3.5.2. Sending Link State Update packets */ |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 241 | /* RFC2328 section 13.3 Next step in the flooding procedure */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 242 | static void |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 243 | ospf6_flood_interface (struct ospf6_neighbor *from, |
| 244 | struct ospf6_lsa *lsa, struct ospf6_interface *oi) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 245 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 246 | struct listnode *node, *nnode; |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 247 | struct ospf6_neighbor *on; |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 248 | struct ospf6_lsa *req; |
| 249 | int retrans_added = 0; |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 250 | int is_debug = 0; |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 251 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 252 | if (IS_OSPF6_DEBUG_FLOODING || |
| 253 | IS_OSPF6_DEBUG_FLOOD_TYPE (lsa->header->type)) |
| 254 | { |
| 255 | is_debug++; |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 256 | zlog_debug ("Flooding on %s: %s", oi->interface->name, lsa->name); |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 257 | } |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 258 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 259 | /* (1) For each neighbor */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 260 | for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on)) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 261 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 262 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 263 | zlog_debug ("To neighbor %s", on->name); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 264 | |
| 265 | /* (a) if neighbor state < Exchange, examin next */ |
| 266 | if (on->state < OSPF6_NEIGHBOR_EXCHANGE) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 267 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 268 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 269 | zlog_debug ("Neighbor state less than ExChange, next neighbor"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 270 | continue; |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 271 | } |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 272 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 273 | /* (b) if neighbor not yet Full, check request-list */ |
| 274 | if (on->state != OSPF6_NEIGHBOR_FULL) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 275 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 276 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 277 | zlog_debug ("Neighbor not yet Full"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 278 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 279 | req = ospf6_lsdb_lookup (lsa->header->type, lsa->header->id, |
| 280 | lsa->header->adv_router, on->request_list); |
| 281 | if (req == NULL) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 282 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 283 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 284 | zlog_debug ("Not on request-list for this neighbor"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 285 | /* fall through */ |
| 286 | } |
| 287 | else |
| 288 | { |
| 289 | /* If new LSA less recent, examin next neighbor */ |
| 290 | if (ospf6_lsa_compare (lsa, req) > 0) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 291 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 292 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 293 | zlog_debug ("Requesting is newer, next neighbor"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 294 | continue; |
| 295 | } |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 296 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 297 | /* If the same instance, delete from request-list and |
| 298 | examin next neighbor */ |
| 299 | if (ospf6_lsa_compare (lsa, req) == 0) |
| 300 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 301 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 302 | zlog_debug ("Requesting the same, remove it, next neighbor"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 303 | ospf6_lsdb_remove (req, on->request_list); |
| 304 | continue; |
| 305 | } |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 306 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 307 | /* If the new LSA is more recent, delete from request-list */ |
| 308 | if (ospf6_lsa_compare (lsa, req) < 0) |
| 309 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 310 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 311 | zlog_debug ("Received is newer, remove requesting"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 312 | ospf6_lsdb_remove (req, on->request_list); |
| 313 | /* fall through */ |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 314 | } |
| 315 | } |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 316 | } |
| 317 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 318 | /* (c) If the new LSA was received from this neighbor, |
| 319 | examin next neighbor */ |
| 320 | if (from == on) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 321 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 322 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 323 | zlog_debug ("Received is from the neighbor, next neighbor"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 324 | continue; |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 325 | } |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 326 | |
| 327 | /* (d) add retrans-list, schedule retransmission */ |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 328 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 329 | zlog_debug ("Add retrans-list of this neighbor"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 330 | ospf6_increment_retrans_count (lsa); |
| 331 | ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->retrans_list); |
| 332 | if (on->thread_send_lsupdate == NULL) |
| 333 | on->thread_send_lsupdate = |
gdt | 6639a04 | 2004-11-05 18:42:27 +0000 | [diff] [blame] | 334 | thread_add_timer (master, ospf6_lsupdate_send_neighbor, |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 335 | on, on->ospf6_if->rxmt_interval); |
| 336 | retrans_added++; |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 337 | } |
| 338 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 339 | /* (2) examin next interface if not added to retrans-list */ |
| 340 | if (retrans_added == 0) |
| 341 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 342 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 343 | zlog_debug ("No retransmission scheduled, next interface"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 344 | return; |
| 345 | } |
| 346 | |
| 347 | /* (3) If the new LSA was received on this interface, |
| 348 | and it was from DR or BDR, examin next interface */ |
| 349 | if (from && from->ospf6_if == oi && |
| 350 | (from->router_id == oi->drouter || from->router_id == oi->bdrouter)) |
| 351 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 352 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 353 | zlog_debug ("Received is from the I/F's DR or BDR, next interface"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 354 | return; |
| 355 | } |
| 356 | |
| 357 | /* (4) If the new LSA was received on this interface, |
| 358 | and the interface state is BDR, examin next interface */ |
| 359 | if (from && from->ospf6_if == oi && oi->state == OSPF6_INTERFACE_BDR) |
| 360 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 361 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 362 | zlog_debug ("Received is from the I/F, itself BDR, next interface"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 363 | return; |
| 364 | } |
| 365 | |
| 366 | /* (5) flood the LSA out the interface. */ |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 367 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 368 | zlog_debug ("Schedule flooding for the interface"); |
Dinesh Dutt | c5926a9 | 2013-08-24 07:55:00 +0000 | [diff] [blame^] | 369 | if ((oi->type == OSPF_IFTYPE_BROADCAST) || |
| 370 | (oi->type == OSPF_IFTYPE_POINTOPOINT)) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 371 | { |
| 372 | ospf6_lsdb_add (ospf6_lsa_copy (lsa), oi->lsupdate_list); |
| 373 | if (oi->thread_send_lsupdate == NULL) |
| 374 | oi->thread_send_lsupdate = |
| 375 | thread_add_event (master, ospf6_lsupdate_send_interface, oi, 0); |
| 376 | } |
| 377 | else |
| 378 | { |
| 379 | /* reschedule retransmissions to all neighbors */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 380 | for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on)) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 381 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 382 | THREAD_OFF (on->thread_send_lsupdate); |
| 383 | on->thread_send_lsupdate = |
| 384 | thread_add_event (master, ospf6_lsupdate_send_neighbor, on, 0); |
| 385 | } |
| 386 | } |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 387 | } |
| 388 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 389 | static void |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 390 | ospf6_flood_area (struct ospf6_neighbor *from, |
| 391 | struct ospf6_lsa *lsa, struct ospf6_area *oa) |
| 392 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 393 | struct listnode *node, *nnode; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 394 | struct ospf6_interface *oi; |
| 395 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 396 | for (ALL_LIST_ELEMENTS (oa->if_list, node, nnode, oi)) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 397 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 398 | if (OSPF6_LSA_SCOPE (lsa->header->type) == OSPF6_SCOPE_LINKLOCAL && |
| 399 | oi != OSPF6_INTERFACE (lsa->lsdb->data)) |
| 400 | continue; |
| 401 | |
| 402 | #if 0 |
| 403 | if (OSPF6_LSA_SCOPE (lsa->header->type) == OSPF6_SCOPE_AS && |
| 404 | ospf6_is_interface_virtual_link (oi)) |
| 405 | continue; |
| 406 | #endif/*0*/ |
| 407 | |
| 408 | ospf6_flood_interface (from, lsa, oi); |
| 409 | } |
| 410 | } |
| 411 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 412 | static void |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 413 | ospf6_flood_process (struct ospf6_neighbor *from, |
| 414 | struct ospf6_lsa *lsa, struct ospf6 *process) |
| 415 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 416 | struct listnode *node, *nnode; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 417 | struct ospf6_area *oa; |
| 418 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 419 | for (ALL_LIST_ELEMENTS (process->area_list, node, nnode, oa)) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 420 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 421 | if (OSPF6_LSA_SCOPE (lsa->header->type) == OSPF6_SCOPE_AREA && |
| 422 | oa != OSPF6_AREA (lsa->lsdb->data)) |
| 423 | continue; |
| 424 | if (OSPF6_LSA_SCOPE (lsa->header->type) == OSPF6_SCOPE_LINKLOCAL && |
| 425 | oa != OSPF6_INTERFACE (lsa->lsdb->data)->area) |
| 426 | continue; |
| 427 | |
| 428 | if (ntohs (lsa->header->type) == OSPF6_LSTYPE_AS_EXTERNAL && |
| 429 | IS_AREA_STUB (oa)) |
| 430 | continue; |
| 431 | |
| 432 | ospf6_flood_area (from, lsa, oa); |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | void |
| 437 | ospf6_flood (struct ospf6_neighbor *from, struct ospf6_lsa *lsa) |
| 438 | { |
| 439 | ospf6_flood_process (from, lsa, ospf6); |
| 440 | } |
| 441 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 442 | static void |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 443 | ospf6_flood_clear_interface (struct ospf6_lsa *lsa, struct ospf6_interface *oi) |
| 444 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 445 | struct listnode *node, *nnode; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 446 | struct ospf6_neighbor *on; |
| 447 | struct ospf6_lsa *rem; |
| 448 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 449 | for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on)) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 450 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 451 | rem = ospf6_lsdb_lookup (lsa->header->type, lsa->header->id, |
| 452 | lsa->header->adv_router, on->retrans_list); |
| 453 | if (rem && ! ospf6_lsa_compare (rem, lsa)) |
| 454 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 455 | if (IS_OSPF6_DEBUG_FLOODING || |
| 456 | IS_OSPF6_DEBUG_FLOOD_TYPE (lsa->header->type)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 457 | zlog_debug ("Remove %s from retrans_list of %s", |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 458 | rem->name, on->name); |
| 459 | ospf6_decrement_retrans_count (rem); |
| 460 | ospf6_lsdb_remove (rem, on->retrans_list); |
| 461 | } |
| 462 | } |
| 463 | } |
| 464 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 465 | static void |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 466 | ospf6_flood_clear_area (struct ospf6_lsa *lsa, struct ospf6_area *oa) |
| 467 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 468 | struct listnode *node, *nnode; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 469 | struct ospf6_interface *oi; |
| 470 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 471 | for (ALL_LIST_ELEMENTS (oa->if_list, node, nnode, oi)) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 472 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 473 | if (OSPF6_LSA_SCOPE (lsa->header->type) == OSPF6_SCOPE_LINKLOCAL && |
| 474 | oi != OSPF6_INTERFACE (lsa->lsdb->data)) |
| 475 | continue; |
| 476 | |
| 477 | #if 0 |
| 478 | if (OSPF6_LSA_SCOPE (lsa->header->type) == OSPF6_SCOPE_AS && |
| 479 | ospf6_is_interface_virtual_link (oi)) |
| 480 | continue; |
| 481 | #endif/*0*/ |
| 482 | |
| 483 | ospf6_flood_clear_interface (lsa, oi); |
| 484 | } |
| 485 | } |
| 486 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 487 | static void |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 488 | ospf6_flood_clear_process (struct ospf6_lsa *lsa, struct ospf6 *process) |
| 489 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 490 | struct listnode *node, *nnode; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 491 | struct ospf6_area *oa; |
| 492 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 493 | for (ALL_LIST_ELEMENTS (process->area_list, node, nnode, oa)) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 494 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 495 | if (OSPF6_LSA_SCOPE (lsa->header->type) == OSPF6_SCOPE_AREA && |
| 496 | oa != OSPF6_AREA (lsa->lsdb->data)) |
| 497 | continue; |
| 498 | if (OSPF6_LSA_SCOPE (lsa->header->type) == OSPF6_SCOPE_LINKLOCAL && |
| 499 | oa != OSPF6_INTERFACE (lsa->lsdb->data)->area) |
| 500 | continue; |
| 501 | |
| 502 | if (ntohs (lsa->header->type) == OSPF6_LSTYPE_AS_EXTERNAL && |
| 503 | IS_AREA_STUB (oa)) |
| 504 | continue; |
| 505 | |
| 506 | ospf6_flood_clear_area (lsa, oa); |
| 507 | } |
| 508 | } |
| 509 | |
| 510 | void |
| 511 | ospf6_flood_clear (struct ospf6_lsa *lsa) |
| 512 | { |
| 513 | ospf6_flood_clear_process (lsa, ospf6); |
| 514 | } |
| 515 | |
| 516 | |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 517 | /* RFC2328 13.5 (Table 19): Sending link state acknowledgements. */ |
| 518 | static void |
| 519 | ospf6_acknowledge_lsa_bdrouter (struct ospf6_lsa *lsa, int ismore_recent, |
| 520 | struct ospf6_neighbor *from) |
| 521 | { |
| 522 | struct ospf6_interface *oi; |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 523 | int is_debug = 0; |
| 524 | |
| 525 | if (IS_OSPF6_DEBUG_FLOODING || |
| 526 | IS_OSPF6_DEBUG_FLOOD_TYPE (lsa->header->type)) |
| 527 | is_debug++; |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 528 | |
| 529 | assert (from && from->ospf6_if); |
| 530 | oi = from->ospf6_if; |
| 531 | |
| 532 | /* LSA has been flood back out receiving interface. |
| 533 | No acknowledgement sent. */ |
| 534 | if (CHECK_FLAG (lsa->flag, OSPF6_LSA_FLOODBACK)) |
| 535 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 536 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 537 | zlog_debug ("No acknowledgement (BDR & FloodBack)"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 538 | return; |
| 539 | } |
| 540 | |
| 541 | /* LSA is more recent than database copy, but was not flooded |
| 542 | back out receiving interface. Delayed acknowledgement sent |
| 543 | if advertisement received from Designated Router, |
| 544 | otherwide do nothing. */ |
| 545 | if (ismore_recent < 0) |
| 546 | { |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 547 | if (oi->drouter == from->router_id) |
| 548 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 549 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 550 | zlog_debug ("Delayed acknowledgement (BDR & MoreRecent & from DR)"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 551 | /* Delayed acknowledgement */ |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 552 | ospf6_lsdb_add (ospf6_lsa_copy (lsa), oi->lsack_list); |
| 553 | if (oi->thread_send_lsack == NULL) |
| 554 | oi->thread_send_lsack = |
| 555 | thread_add_timer (master, ospf6_lsack_send_interface, oi, 3); |
| 556 | } |
| 557 | else |
| 558 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 559 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 560 | zlog_debug ("No acknowledgement (BDR & MoreRecent & ! from DR)"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 561 | } |
| 562 | return; |
| 563 | } |
| 564 | |
| 565 | /* LSA is a duplicate, and was treated as an implied acknowledgement. |
| 566 | Delayed acknowledgement sent if advertisement received from |
| 567 | Designated Router, otherwise do nothing */ |
| 568 | if (CHECK_FLAG (lsa->flag, OSPF6_LSA_DUPLICATE) && |
| 569 | CHECK_FLAG (lsa->flag, OSPF6_LSA_IMPLIEDACK)) |
| 570 | { |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 571 | if (oi->drouter == from->router_id) |
| 572 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 573 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 574 | zlog_debug ("Delayed acknowledgement (BDR & Duplicate & ImpliedAck & from DR)"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 575 | /* Delayed acknowledgement */ |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 576 | ospf6_lsdb_add (ospf6_lsa_copy (lsa), oi->lsack_list); |
| 577 | if (oi->thread_send_lsack == NULL) |
| 578 | oi->thread_send_lsack = |
| 579 | thread_add_timer (master, ospf6_lsack_send_interface, oi, 3); |
| 580 | } |
| 581 | else |
| 582 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 583 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 584 | zlog_debug ("No acknowledgement (BDR & Duplicate & ImpliedAck & ! from DR)"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 585 | } |
| 586 | return; |
| 587 | } |
| 588 | |
| 589 | /* LSA is a duplicate, and was not treated as an implied acknowledgement. |
| 590 | Direct acknowledgement sent */ |
| 591 | if (CHECK_FLAG (lsa->flag, OSPF6_LSA_DUPLICATE) && |
| 592 | ! CHECK_FLAG (lsa->flag, OSPF6_LSA_IMPLIEDACK)) |
| 593 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 594 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 595 | zlog_debug ("Direct acknowledgement (BDR & Duplicate)"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 596 | ospf6_lsdb_add (ospf6_lsa_copy (lsa), from->lsack_list); |
| 597 | if (from->thread_send_lsack == NULL) |
| 598 | from->thread_send_lsack = |
| 599 | thread_add_event (master, ospf6_lsack_send_neighbor, from, 0); |
| 600 | return; |
| 601 | } |
| 602 | |
| 603 | /* LSA's LS age is equal to Maxage, and there is no current instance |
| 604 | of the LSA in the link state database, and none of router's |
| 605 | neighbors are in states Exchange or Loading */ |
| 606 | /* Direct acknowledgement sent, but this case is handled in |
| 607 | early of ospf6_receive_lsa () */ |
| 608 | } |
| 609 | |
| 610 | static void |
| 611 | ospf6_acknowledge_lsa_allother (struct ospf6_lsa *lsa, int ismore_recent, |
| 612 | struct ospf6_neighbor *from) |
| 613 | { |
| 614 | struct ospf6_interface *oi; |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 615 | int is_debug = 0; |
| 616 | |
| 617 | if (IS_OSPF6_DEBUG_FLOODING || |
| 618 | IS_OSPF6_DEBUG_FLOOD_TYPE (lsa->header->type)) |
| 619 | is_debug++; |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 620 | |
| 621 | assert (from && from->ospf6_if); |
| 622 | oi = from->ospf6_if; |
| 623 | |
| 624 | /* LSA has been flood back out receiving interface. |
| 625 | No acknowledgement sent. */ |
| 626 | if (CHECK_FLAG (lsa->flag, OSPF6_LSA_FLOODBACK)) |
| 627 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 628 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 629 | zlog_debug ("No acknowledgement (AllOther & FloodBack)"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 630 | return; |
| 631 | } |
| 632 | |
| 633 | /* LSA is more recent than database copy, but was not flooded |
| 634 | back out receiving interface. Delayed acknowledgement sent. */ |
| 635 | if (ismore_recent < 0) |
| 636 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 637 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 638 | zlog_debug ("Delayed acknowledgement (AllOther & MoreRecent)"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 639 | /* Delayed acknowledgement */ |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 640 | ospf6_lsdb_add (ospf6_lsa_copy (lsa), oi->lsack_list); |
| 641 | if (oi->thread_send_lsack == NULL) |
| 642 | oi->thread_send_lsack = |
| 643 | thread_add_timer (master, ospf6_lsack_send_interface, oi, 3); |
| 644 | return; |
| 645 | } |
| 646 | |
| 647 | /* LSA is a duplicate, and was treated as an implied acknowledgement. |
| 648 | No acknowledgement sent. */ |
| 649 | if (CHECK_FLAG (lsa->flag, OSPF6_LSA_DUPLICATE) && |
| 650 | CHECK_FLAG (lsa->flag, OSPF6_LSA_IMPLIEDACK)) |
| 651 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 652 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 653 | zlog_debug ("No acknowledgement (AllOther & Duplicate & ImpliedAck)"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 654 | return; |
| 655 | } |
| 656 | |
| 657 | /* LSA is a duplicate, and was not treated as an implied acknowledgement. |
| 658 | Direct acknowledgement sent */ |
| 659 | if (CHECK_FLAG (lsa->flag, OSPF6_LSA_DUPLICATE) && |
| 660 | ! CHECK_FLAG (lsa->flag, OSPF6_LSA_IMPLIEDACK)) |
| 661 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 662 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 663 | zlog_debug ("Direct acknowledgement (AllOther & Duplicate)"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 664 | ospf6_lsdb_add (ospf6_lsa_copy (lsa), from->lsack_list); |
| 665 | if (from->thread_send_lsack == NULL) |
| 666 | from->thread_send_lsack = |
| 667 | thread_add_event (master, ospf6_lsack_send_neighbor, from, 0); |
| 668 | return; |
| 669 | } |
| 670 | |
| 671 | /* LSA's LS age is equal to Maxage, and there is no current instance |
| 672 | of the LSA in the link state database, and none of router's |
| 673 | neighbors are in states Exchange or Loading */ |
| 674 | /* Direct acknowledgement sent, but this case is handled in |
| 675 | early of ospf6_receive_lsa () */ |
| 676 | } |
| 677 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 678 | static void |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 679 | ospf6_acknowledge_lsa (struct ospf6_lsa *lsa, int ismore_recent, |
| 680 | struct ospf6_neighbor *from) |
| 681 | { |
| 682 | struct ospf6_interface *oi; |
| 683 | |
| 684 | assert (from && from->ospf6_if); |
| 685 | oi = from->ospf6_if; |
| 686 | |
| 687 | if (oi->state == OSPF6_INTERFACE_BDR) |
| 688 | ospf6_acknowledge_lsa_bdrouter (lsa, ismore_recent, from); |
| 689 | else |
| 690 | ospf6_acknowledge_lsa_allother (lsa, ismore_recent, from); |
| 691 | } |
| 692 | |
| 693 | /* RFC2328 section 13 (4): |
| 694 | if MaxAge LSA and if we have no instance, and no neighbor |
| 695 | is in states Exchange or Loading |
| 696 | returns 1 if match this case, else returns 0 */ |
| 697 | static int |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 698 | ospf6_is_maxage_lsa_drop (struct ospf6_lsa *lsa, struct ospf6_neighbor *from) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 699 | { |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 700 | struct ospf6_neighbor *on; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 701 | struct ospf6_interface *oi; |
| 702 | struct ospf6_area *oa; |
| 703 | struct ospf6 *process = NULL; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 704 | struct listnode *i, *j, *k; |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 705 | int count = 0; |
| 706 | |
| 707 | if (! OSPF6_LSA_IS_MAXAGE (lsa)) |
| 708 | return 0; |
| 709 | |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 710 | if (ospf6_lsdb_lookup (lsa->header->type, lsa->header->id, |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 711 | lsa->header->adv_router, lsa->lsdb)) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 712 | return 0; |
| 713 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 714 | process = from->ospf6_if->area->ospf6; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 715 | |
| 716 | for (ALL_LIST_ELEMENTS_RO (process->area_list, i, oa)) |
| 717 | for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi)) |
| 718 | for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on)) |
| 719 | if (on->state == OSPF6_NEIGHBOR_EXCHANGE || |
| 720 | on->state == OSPF6_NEIGHBOR_LOADING) |
| 721 | count++; |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 722 | |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 723 | if (count == 0) |
| 724 | return 1; |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 725 | return 0; |
| 726 | } |
| 727 | |
| 728 | /* RFC2328 section 13 The Flooding Procedure */ |
| 729 | void |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 730 | ospf6_receive_lsa (struct ospf6_neighbor *from, |
| 731 | struct ospf6_lsa_header *lsa_header) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 732 | { |
| 733 | struct ospf6_lsa *new = NULL, *old = NULL, *rem = NULL; |
| 734 | int ismore_recent; |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 735 | int is_debug = 0; |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 736 | |
| 737 | ismore_recent = 1; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 738 | assert (from); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 739 | |
| 740 | /* make lsa structure for received lsa */ |
| 741 | new = ospf6_lsa_create (lsa_header); |
| 742 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 743 | if (IS_OSPF6_DEBUG_FLOODING || |
| 744 | IS_OSPF6_DEBUG_FLOOD_TYPE (new->header->type)) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 745 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 746 | is_debug++; |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 747 | zlog_debug ("LSA Receive from %s", from->name); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 748 | ospf6_lsa_header_print (new); |
| 749 | } |
| 750 | |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 751 | /* (1) LSA Checksum */ |
JR Rivers | d8a4e42 | 2012-09-13 17:17:36 +0000 | [diff] [blame] | 752 | if (! ospf6_lsa_checksum_valid (new->header)) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 753 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 754 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 755 | zlog_debug ("Wrong LSA Checksum, discard"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 756 | ospf6_lsa_delete (new); |
| 757 | return; |
| 758 | } |
| 759 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 760 | /* (2) Examine the LSA's LS type. |
| 761 | RFC2470 3.5.1. Receiving Link State Update packets */ |
| 762 | if (IS_AREA_STUB (from->ospf6_if->area) && |
| 763 | OSPF6_LSA_SCOPE (new->header->type) == OSPF6_SCOPE_AS) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 764 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 765 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 766 | zlog_debug ("AS-External-LSA (or AS-scope LSA) in stub area, discard"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 767 | ospf6_lsa_delete (new); |
| 768 | return; |
| 769 | } |
| 770 | |
| 771 | /* (3) LSA which have reserved scope is discarded |
| 772 | RFC2470 3.5.1. Receiving Link State Update packets */ |
| 773 | /* Flooding scope check. LSAs with unknown scope are discarded here. |
| 774 | Set appropriate LSDB for the LSA */ |
| 775 | switch (OSPF6_LSA_SCOPE (new->header->type)) |
| 776 | { |
| 777 | case OSPF6_SCOPE_LINKLOCAL: |
| 778 | new->lsdb = from->ospf6_if->lsdb; |
| 779 | break; |
| 780 | case OSPF6_SCOPE_AREA: |
| 781 | new->lsdb = from->ospf6_if->area->lsdb; |
| 782 | break; |
| 783 | case OSPF6_SCOPE_AS: |
| 784 | new->lsdb = from->ospf6_if->area->ospf6->lsdb; |
| 785 | break; |
| 786 | default: |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 787 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 788 | zlog_debug ("LSA has reserved scope, discard"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 789 | ospf6_lsa_delete (new); |
| 790 | return; |
| 791 | } |
| 792 | |
| 793 | /* (4) if MaxAge LSA and if we have no instance, and no neighbor |
| 794 | is in states Exchange or Loading */ |
| 795 | if (ospf6_is_maxage_lsa_drop (new, from)) |
| 796 | { |
| 797 | /* log */ |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 798 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 799 | zlog_debug ("Drop MaxAge LSA with direct acknowledgement."); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 800 | |
| 801 | /* a) Acknowledge back to neighbor (Direct acknowledgement, 13.5) */ |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 802 | ospf6_lsdb_add (ospf6_lsa_copy (new), from->lsack_list); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 803 | if (from->thread_send_lsack == NULL) |
| 804 | from->thread_send_lsack = |
| 805 | thread_add_event (master, ospf6_lsack_send_neighbor, from, 0); |
| 806 | |
| 807 | /* b) Discard */ |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 808 | ospf6_lsa_delete (new); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 809 | return; |
| 810 | } |
| 811 | |
| 812 | /* (5) */ |
| 813 | /* lookup the same database copy in lsdb */ |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 814 | old = ospf6_lsdb_lookup (new->header->type, new->header->id, |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 815 | new->header->adv_router, new->lsdb); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 816 | if (old) |
| 817 | { |
| 818 | ismore_recent = ospf6_lsa_compare (new, old); |
| 819 | if (ntohl (new->header->seqnum) == ntohl (old->header->seqnum)) |
| 820 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 821 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 822 | zlog_debug ("Received is duplicated LSA"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 823 | SET_FLAG (new->flag, OSPF6_LSA_DUPLICATE); |
| 824 | } |
| 825 | } |
| 826 | |
| 827 | /* if no database copy or received is more recent */ |
| 828 | if (old == NULL || ismore_recent < 0) |
| 829 | { |
| 830 | /* in case we have no database copy */ |
| 831 | ismore_recent = -1; |
| 832 | |
| 833 | /* (a) MinLSArrival check */ |
| 834 | if (old) |
| 835 | { |
| 836 | struct timeval now, res; |
Takashi Sogabe | 86f72dc | 2009-06-22 13:07:02 +0900 | [diff] [blame] | 837 | quagga_gettime (QUAGGA_CLK_MONOTONIC, &now); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 838 | timersub (&now, &old->installed, &res); |
Dinesh Dutt | 8551e6d | 2013-10-22 17:42:18 -0700 | [diff] [blame] | 839 | if (res.tv_sec < OSPF_MIN_LS_ARRIVAL) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 840 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 841 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 842 | zlog_debug ("LSA can't be updated within MinLSArrival, discard"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 843 | ospf6_lsa_delete (new); |
| 844 | return; /* examin next lsa */ |
| 845 | } |
| 846 | } |
| 847 | |
Takashi Sogabe | 86f72dc | 2009-06-22 13:07:02 +0900 | [diff] [blame] | 848 | quagga_gettime (QUAGGA_CLK_MONOTONIC, &new->received); |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 849 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 850 | if (is_debug) |
Dinesh Dutt | bf986da | 2013-08-24 07:54:50 +0000 | [diff] [blame] | 851 | zlog_debug ("Install, Flood, Possibly acknowledge the received LSA"); |
| 852 | |
| 853 | /* Remove older copies of this LSA from retx lists */ |
| 854 | if (old) |
| 855 | ospf6_flood_clear (old); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 856 | |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 857 | /* (b) immediately flood and (c) remove from all retrans-list */ |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 858 | /* Prevent self-originated LSA to be flooded. this is to make |
| 859 | reoriginated instance of the LSA not to be rejected by other routers |
| 860 | due to MinLSArrival. */ |
| 861 | if (new->header->adv_router != from->ospf6_if->area->ospf6->router_id) |
| 862 | ospf6_flood (from, new); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 863 | |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 864 | /* (d), installing lsdb, which may cause routing |
| 865 | table calculation (replacing database copy) */ |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 866 | ospf6_install_lsa (new); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 867 | |
| 868 | /* (e) possibly acknowledge */ |
| 869 | ospf6_acknowledge_lsa (new, ismore_recent, from); |
| 870 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 871 | /* (f) Self Originated LSA, section 13.4 */ |
| 872 | if (new->header->adv_router == from->ospf6_if->area->ospf6->router_id) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 873 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 874 | /* Self-originated LSA (newer than ours) is received from |
| 875 | another router. We have to make a new instance of the LSA |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 876 | or have to flush this LSA. */ |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 877 | if (is_debug) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 878 | { |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 879 | zlog_debug ("Newer instance of the self-originated LSA"); |
| 880 | zlog_debug ("Schedule reorigination"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 881 | } |
| 882 | new->refresh = thread_add_event (master, ospf6_lsa_refresh, new, 0); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 883 | } |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 884 | |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 885 | return; |
| 886 | } |
| 887 | |
| 888 | /* (6) if there is instance on sending neighbor's request list */ |
| 889 | if (ospf6_lsdb_lookup (new->header->type, new->header->id, |
| 890 | new->header->adv_router, from->request_list)) |
| 891 | { |
| 892 | /* if no database copy, should go above state (5) */ |
| 893 | assert (old); |
| 894 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 895 | if (is_debug) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 896 | { |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 897 | zlog_debug ("Received is not newer, on the neighbor's request-list"); |
| 898 | zlog_debug ("BadLSReq, discard the received LSA"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 899 | } |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 900 | |
| 901 | /* BadLSReq */ |
| 902 | thread_add_event (master, bad_lsreq, from, 0); |
| 903 | |
| 904 | ospf6_lsa_delete (new); |
| 905 | return; |
| 906 | } |
| 907 | |
| 908 | /* (7) if neither one is more recent */ |
| 909 | if (ismore_recent == 0) |
| 910 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 911 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 912 | zlog_debug ("The same instance as database copy (neither recent)"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 913 | |
| 914 | /* (a) if on retrans-list, Treat this LSA as an Ack: Implied Ack */ |
| 915 | rem = ospf6_lsdb_lookup (new->header->type, new->header->id, |
| 916 | new->header->adv_router, from->retrans_list); |
| 917 | if (rem) |
| 918 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 919 | if (is_debug) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 920 | { |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 921 | zlog_debug ("It is on the neighbor's retrans-list."); |
| 922 | zlog_debug ("Treat as an Implied acknowledgement"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 923 | } |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 924 | SET_FLAG (new->flag, OSPF6_LSA_IMPLIEDACK); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 925 | ospf6_decrement_retrans_count (rem); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 926 | ospf6_lsdb_remove (rem, from->retrans_list); |
| 927 | } |
| 928 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 929 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 930 | zlog_debug ("Possibly acknowledge and then discard"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 931 | |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 932 | /* (b) possibly acknowledge */ |
| 933 | ospf6_acknowledge_lsa (new, ismore_recent, from); |
| 934 | |
| 935 | ospf6_lsa_delete (new); |
| 936 | return; |
| 937 | } |
| 938 | |
| 939 | /* (8) previous database copy is more recent */ |
| 940 | { |
| 941 | assert (old); |
| 942 | |
| 943 | /* If database copy is in 'Seqnumber Wrapping', |
| 944 | simply discard the received LSA */ |
| 945 | if (OSPF6_LSA_IS_MAXAGE (old) && |
Dinesh Dutt | 8551e6d | 2013-10-22 17:42:18 -0700 | [diff] [blame] | 946 | old->header->seqnum == htonl (OSPF_MAX_SEQUENCE_NUMBER)) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 947 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 948 | if (is_debug) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 949 | { |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 950 | zlog_debug ("The LSA is in Seqnumber Wrapping"); |
| 951 | zlog_debug ("MaxAge & MaxSeqNum, discard"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 952 | } |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 953 | ospf6_lsa_delete (new); |
| 954 | return; |
| 955 | } |
| 956 | |
| 957 | /* Otherwise, Send database copy of this LSA to this neighbor */ |
| 958 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 959 | if (is_debug) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 960 | { |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 961 | zlog_debug ("Database copy is more recent."); |
| 962 | zlog_debug ("Send back directly and then discard"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 963 | } |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 964 | |
| 965 | /* XXX, MinLSArrival check !? RFC 2328 13 (8) */ |
| 966 | |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 967 | ospf6_lsdb_add (ospf6_lsa_copy (old), from->lsupdate_list); |
| 968 | if (from->thread_send_lsupdate == NULL) |
| 969 | from->thread_send_lsupdate = |
| 970 | thread_add_event (master, ospf6_lsupdate_send_neighbor, from, 0); |
| 971 | ospf6_lsa_delete (new); |
| 972 | return; |
| 973 | } |
| 974 | return; |
| 975 | } |
| 976 | } |
| 977 | |
| 978 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 979 | DEFUN (debug_ospf6_flooding, |
| 980 | debug_ospf6_flooding_cmd, |
| 981 | "debug ospf6 flooding", |
| 982 | DEBUG_STR |
| 983 | OSPF6_STR |
| 984 | "Debug OSPFv3 flooding function\n" |
| 985 | ) |
| 986 | { |
| 987 | OSPF6_DEBUG_FLOODING_ON (); |
| 988 | return CMD_SUCCESS; |
| 989 | } |
| 990 | |
| 991 | DEFUN (no_debug_ospf6_flooding, |
| 992 | no_debug_ospf6_flooding_cmd, |
| 993 | "no debug ospf6 flooding", |
| 994 | NO_STR |
| 995 | DEBUG_STR |
| 996 | OSPF6_STR |
| 997 | "Debug OSPFv3 flooding function\n" |
| 998 | ) |
| 999 | { |
| 1000 | OSPF6_DEBUG_FLOODING_OFF (); |
| 1001 | return CMD_SUCCESS; |
| 1002 | } |
| 1003 | |
| 1004 | int |
| 1005 | config_write_ospf6_debug_flood (struct vty *vty) |
| 1006 | { |
| 1007 | if (IS_OSPF6_DEBUG_FLOODING) |
| 1008 | vty_out (vty, "debug ospf6 flooding%s", VNL); |
| 1009 | return 0; |
| 1010 | } |
| 1011 | |
| 1012 | void |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 1013 | install_element_ospf6_debug_flood (void) |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 1014 | { |
| 1015 | install_element (ENABLE_NODE, &debug_ospf6_flooding_cmd); |
| 1016 | install_element (ENABLE_NODE, &no_debug_ospf6_flooding_cmd); |
| 1017 | install_element (CONFIG_NODE, &debug_ospf6_flooding_cmd); |
| 1018 | install_element (CONFIG_NODE, &no_debug_ospf6_flooding_cmd); |
| 1019 | } |
| 1020 | |
| 1021 | |
| 1022 | |
| 1023 | |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 1024 | |