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 | { |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 209 | struct timeval now; |
Dinesh Dutt | eb82e9e | 2013-08-24 07:55:07 +0000 | [diff] [blame] | 210 | struct ospf6_lsa *old; |
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) |
Dinesh Dutt | eb82e9e | 2013-08-24 07:55:07 +0000 | [diff] [blame] | 293 | zlog_debug ("Requesting is older, 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 | { |
Dinesh Dutt | eb82e9e | 2013-08-24 07:55:07 +0000 | [diff] [blame] | 301 | if (is_debug) |
| 302 | zlog_debug ("Requesting the same, remove it, next neighbor"); |
| 303 | if (req == on->last_ls_req) |
| 304 | { |
| 305 | ospf6_lsa_unlock (req); |
| 306 | on->last_ls_req = NULL; |
| 307 | } |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 308 | ospf6_lsdb_remove (req, on->request_list); |
Dinesh Dutt | eb82e9e | 2013-08-24 07:55:07 +0000 | [diff] [blame] | 309 | ospf6_check_nbr_loading (on); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 310 | continue; |
| 311 | } |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 312 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 313 | /* If the new LSA is more recent, delete from request-list */ |
| 314 | if (ospf6_lsa_compare (lsa, req) < 0) |
| 315 | { |
Dinesh Dutt | eb82e9e | 2013-08-24 07:55:07 +0000 | [diff] [blame] | 316 | if (is_debug) |
| 317 | zlog_debug ("Received is newer, remove requesting"); |
| 318 | if (req == on->last_ls_req) |
| 319 | { |
| 320 | ospf6_lsa_unlock (req); |
| 321 | on->last_ls_req = NULL; |
| 322 | } |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 323 | ospf6_lsdb_remove (req, on->request_list); |
Dinesh Dutt | eb82e9e | 2013-08-24 07:55:07 +0000 | [diff] [blame] | 324 | ospf6_check_nbr_loading (on); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 325 | /* fall through */ |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 326 | } |
| 327 | } |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 328 | } |
| 329 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 330 | /* (c) If the new LSA was received from this neighbor, |
| 331 | examin next neighbor */ |
| 332 | if (from == on) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 333 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 334 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 335 | zlog_debug ("Received is from the neighbor, next neighbor"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 336 | continue; |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 337 | } |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 338 | |
| 339 | /* (d) add retrans-list, schedule retransmission */ |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 340 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 341 | zlog_debug ("Add retrans-list of this neighbor"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 342 | ospf6_increment_retrans_count (lsa); |
| 343 | ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->retrans_list); |
| 344 | if (on->thread_send_lsupdate == NULL) |
| 345 | on->thread_send_lsupdate = |
gdt | 6639a04 | 2004-11-05 18:42:27 +0000 | [diff] [blame] | 346 | thread_add_timer (master, ospf6_lsupdate_send_neighbor, |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 347 | on, on->ospf6_if->rxmt_interval); |
| 348 | retrans_added++; |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 349 | } |
| 350 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 351 | /* (2) examin next interface if not added to retrans-list */ |
| 352 | if (retrans_added == 0) |
| 353 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 354 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 355 | zlog_debug ("No retransmission scheduled, next interface"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 356 | return; |
| 357 | } |
| 358 | |
| 359 | /* (3) If the new LSA was received on this interface, |
| 360 | and it was from DR or BDR, examin next interface */ |
| 361 | if (from && from->ospf6_if == oi && |
| 362 | (from->router_id == oi->drouter || from->router_id == oi->bdrouter)) |
| 363 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 364 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 365 | 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] | 366 | return; |
| 367 | } |
| 368 | |
| 369 | /* (4) If the new LSA was received on this interface, |
| 370 | and the interface state is BDR, examin next interface */ |
| 371 | if (from && from->ospf6_if == oi && oi->state == OSPF6_INTERFACE_BDR) |
| 372 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 373 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 374 | zlog_debug ("Received is from the I/F, itself BDR, next interface"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 375 | return; |
| 376 | } |
| 377 | |
| 378 | /* (5) flood the LSA out the interface. */ |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 379 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 380 | zlog_debug ("Schedule flooding for the interface"); |
Dinesh Dutt | c5926a9 | 2013-08-24 07:55:00 +0000 | [diff] [blame] | 381 | if ((oi->type == OSPF_IFTYPE_BROADCAST) || |
| 382 | (oi->type == OSPF_IFTYPE_POINTOPOINT)) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 383 | { |
| 384 | ospf6_lsdb_add (ospf6_lsa_copy (lsa), oi->lsupdate_list); |
| 385 | if (oi->thread_send_lsupdate == NULL) |
| 386 | oi->thread_send_lsupdate = |
| 387 | thread_add_event (master, ospf6_lsupdate_send_interface, oi, 0); |
| 388 | } |
| 389 | else |
| 390 | { |
| 391 | /* reschedule retransmissions to all neighbors */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 392 | for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on)) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 393 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 394 | THREAD_OFF (on->thread_send_lsupdate); |
| 395 | on->thread_send_lsupdate = |
| 396 | thread_add_event (master, ospf6_lsupdate_send_neighbor, on, 0); |
| 397 | } |
| 398 | } |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 399 | } |
| 400 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 401 | static void |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 402 | ospf6_flood_area (struct ospf6_neighbor *from, |
| 403 | struct ospf6_lsa *lsa, struct ospf6_area *oa) |
| 404 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 405 | struct listnode *node, *nnode; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 406 | struct ospf6_interface *oi; |
| 407 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 408 | for (ALL_LIST_ELEMENTS (oa->if_list, node, nnode, oi)) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 409 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 410 | if (OSPF6_LSA_SCOPE (lsa->header->type) == OSPF6_SCOPE_LINKLOCAL && |
| 411 | oi != OSPF6_INTERFACE (lsa->lsdb->data)) |
| 412 | continue; |
| 413 | |
| 414 | #if 0 |
| 415 | if (OSPF6_LSA_SCOPE (lsa->header->type) == OSPF6_SCOPE_AS && |
| 416 | ospf6_is_interface_virtual_link (oi)) |
| 417 | continue; |
| 418 | #endif/*0*/ |
| 419 | |
| 420 | ospf6_flood_interface (from, lsa, oi); |
| 421 | } |
| 422 | } |
| 423 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 424 | static void |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 425 | ospf6_flood_process (struct ospf6_neighbor *from, |
| 426 | struct ospf6_lsa *lsa, struct ospf6 *process) |
| 427 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 428 | struct listnode *node, *nnode; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 429 | struct ospf6_area *oa; |
| 430 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 431 | for (ALL_LIST_ELEMENTS (process->area_list, node, nnode, oa)) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 432 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 433 | if (OSPF6_LSA_SCOPE (lsa->header->type) == OSPF6_SCOPE_AREA && |
| 434 | oa != OSPF6_AREA (lsa->lsdb->data)) |
| 435 | continue; |
| 436 | if (OSPF6_LSA_SCOPE (lsa->header->type) == OSPF6_SCOPE_LINKLOCAL && |
| 437 | oa != OSPF6_INTERFACE (lsa->lsdb->data)->area) |
| 438 | continue; |
| 439 | |
| 440 | if (ntohs (lsa->header->type) == OSPF6_LSTYPE_AS_EXTERNAL && |
| 441 | IS_AREA_STUB (oa)) |
| 442 | continue; |
| 443 | |
| 444 | ospf6_flood_area (from, lsa, oa); |
| 445 | } |
| 446 | } |
| 447 | |
| 448 | void |
| 449 | ospf6_flood (struct ospf6_neighbor *from, struct ospf6_lsa *lsa) |
| 450 | { |
| 451 | ospf6_flood_process (from, lsa, ospf6); |
| 452 | } |
| 453 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 454 | static void |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 455 | ospf6_flood_clear_interface (struct ospf6_lsa *lsa, struct ospf6_interface *oi) |
| 456 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 457 | struct listnode *node, *nnode; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 458 | struct ospf6_neighbor *on; |
| 459 | struct ospf6_lsa *rem; |
| 460 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 461 | for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on)) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 462 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 463 | rem = ospf6_lsdb_lookup (lsa->header->type, lsa->header->id, |
| 464 | lsa->header->adv_router, on->retrans_list); |
| 465 | if (rem && ! ospf6_lsa_compare (rem, lsa)) |
| 466 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 467 | if (IS_OSPF6_DEBUG_FLOODING || |
| 468 | IS_OSPF6_DEBUG_FLOOD_TYPE (lsa->header->type)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 469 | zlog_debug ("Remove %s from retrans_list of %s", |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 470 | rem->name, on->name); |
| 471 | ospf6_decrement_retrans_count (rem); |
| 472 | ospf6_lsdb_remove (rem, on->retrans_list); |
| 473 | } |
| 474 | } |
| 475 | } |
| 476 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 477 | static void |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 478 | ospf6_flood_clear_area (struct ospf6_lsa *lsa, struct ospf6_area *oa) |
| 479 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 480 | struct listnode *node, *nnode; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 481 | struct ospf6_interface *oi; |
| 482 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 483 | for (ALL_LIST_ELEMENTS (oa->if_list, node, nnode, oi)) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 484 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 485 | if (OSPF6_LSA_SCOPE (lsa->header->type) == OSPF6_SCOPE_LINKLOCAL && |
| 486 | oi != OSPF6_INTERFACE (lsa->lsdb->data)) |
| 487 | continue; |
| 488 | |
| 489 | #if 0 |
| 490 | if (OSPF6_LSA_SCOPE (lsa->header->type) == OSPF6_SCOPE_AS && |
| 491 | ospf6_is_interface_virtual_link (oi)) |
| 492 | continue; |
| 493 | #endif/*0*/ |
| 494 | |
| 495 | ospf6_flood_clear_interface (lsa, oi); |
| 496 | } |
| 497 | } |
| 498 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 499 | static void |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 500 | ospf6_flood_clear_process (struct ospf6_lsa *lsa, struct ospf6 *process) |
| 501 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 502 | struct listnode *node, *nnode; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 503 | struct ospf6_area *oa; |
| 504 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 505 | for (ALL_LIST_ELEMENTS (process->area_list, node, nnode, oa)) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 506 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 507 | if (OSPF6_LSA_SCOPE (lsa->header->type) == OSPF6_SCOPE_AREA && |
| 508 | oa != OSPF6_AREA (lsa->lsdb->data)) |
| 509 | continue; |
| 510 | if (OSPF6_LSA_SCOPE (lsa->header->type) == OSPF6_SCOPE_LINKLOCAL && |
| 511 | oa != OSPF6_INTERFACE (lsa->lsdb->data)->area) |
| 512 | continue; |
| 513 | |
| 514 | if (ntohs (lsa->header->type) == OSPF6_LSTYPE_AS_EXTERNAL && |
| 515 | IS_AREA_STUB (oa)) |
| 516 | continue; |
| 517 | |
| 518 | ospf6_flood_clear_area (lsa, oa); |
| 519 | } |
| 520 | } |
| 521 | |
| 522 | void |
| 523 | ospf6_flood_clear (struct ospf6_lsa *lsa) |
| 524 | { |
| 525 | ospf6_flood_clear_process (lsa, ospf6); |
| 526 | } |
| 527 | |
| 528 | |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 529 | /* RFC2328 13.5 (Table 19): Sending link state acknowledgements. */ |
| 530 | static void |
| 531 | ospf6_acknowledge_lsa_bdrouter (struct ospf6_lsa *lsa, int ismore_recent, |
| 532 | struct ospf6_neighbor *from) |
| 533 | { |
| 534 | struct ospf6_interface *oi; |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 535 | int is_debug = 0; |
| 536 | |
| 537 | if (IS_OSPF6_DEBUG_FLOODING || |
| 538 | IS_OSPF6_DEBUG_FLOOD_TYPE (lsa->header->type)) |
| 539 | is_debug++; |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 540 | |
| 541 | assert (from && from->ospf6_if); |
| 542 | oi = from->ospf6_if; |
| 543 | |
| 544 | /* LSA has been flood back out receiving interface. |
| 545 | No acknowledgement sent. */ |
| 546 | if (CHECK_FLAG (lsa->flag, OSPF6_LSA_FLOODBACK)) |
| 547 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 548 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 549 | zlog_debug ("No acknowledgement (BDR & FloodBack)"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 550 | return; |
| 551 | } |
| 552 | |
| 553 | /* LSA is more recent than database copy, but was not flooded |
| 554 | back out receiving interface. Delayed acknowledgement sent |
| 555 | if advertisement received from Designated Router, |
| 556 | otherwide do nothing. */ |
| 557 | if (ismore_recent < 0) |
| 558 | { |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 559 | if (oi->drouter == from->router_id) |
| 560 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 561 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 562 | zlog_debug ("Delayed acknowledgement (BDR & MoreRecent & from DR)"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 563 | /* Delayed acknowledgement */ |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 564 | ospf6_lsdb_add (ospf6_lsa_copy (lsa), oi->lsack_list); |
| 565 | if (oi->thread_send_lsack == NULL) |
| 566 | oi->thread_send_lsack = |
| 567 | thread_add_timer (master, ospf6_lsack_send_interface, oi, 3); |
| 568 | } |
| 569 | else |
| 570 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 571 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 572 | zlog_debug ("No acknowledgement (BDR & MoreRecent & ! from DR)"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 573 | } |
| 574 | return; |
| 575 | } |
| 576 | |
| 577 | /* LSA is a duplicate, and was treated as an implied acknowledgement. |
| 578 | Delayed acknowledgement sent if advertisement received from |
| 579 | Designated Router, otherwise do nothing */ |
| 580 | if (CHECK_FLAG (lsa->flag, OSPF6_LSA_DUPLICATE) && |
| 581 | CHECK_FLAG (lsa->flag, OSPF6_LSA_IMPLIEDACK)) |
| 582 | { |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 583 | if (oi->drouter == from->router_id) |
| 584 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 585 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 586 | zlog_debug ("Delayed acknowledgement (BDR & Duplicate & ImpliedAck & from DR)"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 587 | /* Delayed acknowledgement */ |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 588 | ospf6_lsdb_add (ospf6_lsa_copy (lsa), oi->lsack_list); |
| 589 | if (oi->thread_send_lsack == NULL) |
| 590 | oi->thread_send_lsack = |
| 591 | thread_add_timer (master, ospf6_lsack_send_interface, oi, 3); |
| 592 | } |
| 593 | else |
| 594 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 595 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 596 | zlog_debug ("No acknowledgement (BDR & Duplicate & ImpliedAck & ! from DR)"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 597 | } |
| 598 | return; |
| 599 | } |
| 600 | |
| 601 | /* LSA is a duplicate, and was not treated as an implied acknowledgement. |
| 602 | Direct acknowledgement sent */ |
| 603 | if (CHECK_FLAG (lsa->flag, OSPF6_LSA_DUPLICATE) && |
| 604 | ! CHECK_FLAG (lsa->flag, OSPF6_LSA_IMPLIEDACK)) |
| 605 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 606 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 607 | zlog_debug ("Direct acknowledgement (BDR & Duplicate)"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 608 | ospf6_lsdb_add (ospf6_lsa_copy (lsa), from->lsack_list); |
| 609 | if (from->thread_send_lsack == NULL) |
| 610 | from->thread_send_lsack = |
| 611 | thread_add_event (master, ospf6_lsack_send_neighbor, from, 0); |
| 612 | return; |
| 613 | } |
| 614 | |
| 615 | /* LSA's LS age is equal to Maxage, and there is no current instance |
| 616 | of the LSA in the link state database, and none of router's |
| 617 | neighbors are in states Exchange or Loading */ |
| 618 | /* Direct acknowledgement sent, but this case is handled in |
| 619 | early of ospf6_receive_lsa () */ |
| 620 | } |
| 621 | |
| 622 | static void |
| 623 | ospf6_acknowledge_lsa_allother (struct ospf6_lsa *lsa, int ismore_recent, |
| 624 | struct ospf6_neighbor *from) |
| 625 | { |
| 626 | struct ospf6_interface *oi; |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 627 | int is_debug = 0; |
| 628 | |
| 629 | if (IS_OSPF6_DEBUG_FLOODING || |
| 630 | IS_OSPF6_DEBUG_FLOOD_TYPE (lsa->header->type)) |
| 631 | is_debug++; |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 632 | |
| 633 | assert (from && from->ospf6_if); |
| 634 | oi = from->ospf6_if; |
| 635 | |
| 636 | /* LSA has been flood back out receiving interface. |
| 637 | No acknowledgement sent. */ |
| 638 | if (CHECK_FLAG (lsa->flag, OSPF6_LSA_FLOODBACK)) |
| 639 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 640 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 641 | zlog_debug ("No acknowledgement (AllOther & FloodBack)"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 642 | return; |
| 643 | } |
| 644 | |
| 645 | /* LSA is more recent than database copy, but was not flooded |
| 646 | back out receiving interface. Delayed acknowledgement sent. */ |
| 647 | if (ismore_recent < 0) |
| 648 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 649 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 650 | zlog_debug ("Delayed acknowledgement (AllOther & MoreRecent)"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 651 | /* Delayed acknowledgement */ |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 652 | ospf6_lsdb_add (ospf6_lsa_copy (lsa), oi->lsack_list); |
| 653 | if (oi->thread_send_lsack == NULL) |
| 654 | oi->thread_send_lsack = |
| 655 | thread_add_timer (master, ospf6_lsack_send_interface, oi, 3); |
| 656 | return; |
| 657 | } |
| 658 | |
| 659 | /* LSA is a duplicate, and was treated as an implied acknowledgement. |
| 660 | No acknowledgement sent. */ |
| 661 | if (CHECK_FLAG (lsa->flag, OSPF6_LSA_DUPLICATE) && |
| 662 | CHECK_FLAG (lsa->flag, OSPF6_LSA_IMPLIEDACK)) |
| 663 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 664 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 665 | zlog_debug ("No acknowledgement (AllOther & Duplicate & ImpliedAck)"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 666 | return; |
| 667 | } |
| 668 | |
| 669 | /* LSA is a duplicate, and was not treated as an implied acknowledgement. |
| 670 | Direct acknowledgement sent */ |
| 671 | if (CHECK_FLAG (lsa->flag, OSPF6_LSA_DUPLICATE) && |
| 672 | ! CHECK_FLAG (lsa->flag, OSPF6_LSA_IMPLIEDACK)) |
| 673 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 674 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 675 | zlog_debug ("Direct acknowledgement (AllOther & Duplicate)"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 676 | ospf6_lsdb_add (ospf6_lsa_copy (lsa), from->lsack_list); |
| 677 | if (from->thread_send_lsack == NULL) |
| 678 | from->thread_send_lsack = |
| 679 | thread_add_event (master, ospf6_lsack_send_neighbor, from, 0); |
| 680 | return; |
| 681 | } |
| 682 | |
| 683 | /* LSA's LS age is equal to Maxage, and there is no current instance |
| 684 | of the LSA in the link state database, and none of router's |
| 685 | neighbors are in states Exchange or Loading */ |
| 686 | /* Direct acknowledgement sent, but this case is handled in |
| 687 | early of ospf6_receive_lsa () */ |
| 688 | } |
| 689 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 690 | static void |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 691 | ospf6_acknowledge_lsa (struct ospf6_lsa *lsa, int ismore_recent, |
| 692 | struct ospf6_neighbor *from) |
| 693 | { |
| 694 | struct ospf6_interface *oi; |
| 695 | |
| 696 | assert (from && from->ospf6_if); |
| 697 | oi = from->ospf6_if; |
| 698 | |
| 699 | if (oi->state == OSPF6_INTERFACE_BDR) |
| 700 | ospf6_acknowledge_lsa_bdrouter (lsa, ismore_recent, from); |
| 701 | else |
| 702 | ospf6_acknowledge_lsa_allother (lsa, ismore_recent, from); |
| 703 | } |
| 704 | |
| 705 | /* RFC2328 section 13 (4): |
| 706 | if MaxAge LSA and if we have no instance, and no neighbor |
| 707 | is in states Exchange or Loading |
| 708 | returns 1 if match this case, else returns 0 */ |
| 709 | static int |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 710 | ospf6_is_maxage_lsa_drop (struct ospf6_lsa *lsa, struct ospf6_neighbor *from) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 711 | { |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 712 | struct ospf6_neighbor *on; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 713 | struct ospf6_interface *oi; |
| 714 | struct ospf6_area *oa; |
| 715 | struct ospf6 *process = NULL; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 716 | struct listnode *i, *j, *k; |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 717 | int count = 0; |
| 718 | |
| 719 | if (! OSPF6_LSA_IS_MAXAGE (lsa)) |
| 720 | return 0; |
| 721 | |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 722 | if (ospf6_lsdb_lookup (lsa->header->type, lsa->header->id, |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 723 | lsa->header->adv_router, lsa->lsdb)) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 724 | return 0; |
| 725 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 726 | process = from->ospf6_if->area->ospf6; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 727 | |
| 728 | for (ALL_LIST_ELEMENTS_RO (process->area_list, i, oa)) |
| 729 | for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi)) |
| 730 | for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on)) |
| 731 | if (on->state == OSPF6_NEIGHBOR_EXCHANGE || |
| 732 | on->state == OSPF6_NEIGHBOR_LOADING) |
| 733 | count++; |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 734 | |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 735 | if (count == 0) |
| 736 | return 1; |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 737 | return 0; |
| 738 | } |
| 739 | |
| 740 | /* RFC2328 section 13 The Flooding Procedure */ |
| 741 | void |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 742 | ospf6_receive_lsa (struct ospf6_neighbor *from, |
| 743 | struct ospf6_lsa_header *lsa_header) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 744 | { |
| 745 | struct ospf6_lsa *new = NULL, *old = NULL, *rem = NULL; |
| 746 | int ismore_recent; |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 747 | int is_debug = 0; |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 748 | |
| 749 | ismore_recent = 1; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 750 | assert (from); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 751 | |
| 752 | /* make lsa structure for received lsa */ |
| 753 | new = ospf6_lsa_create (lsa_header); |
| 754 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 755 | if (IS_OSPF6_DEBUG_FLOODING || |
| 756 | IS_OSPF6_DEBUG_FLOOD_TYPE (new->header->type)) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 757 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 758 | is_debug++; |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 759 | zlog_debug ("LSA Receive from %s", from->name); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 760 | ospf6_lsa_header_print (new); |
| 761 | } |
| 762 | |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 763 | /* (1) LSA Checksum */ |
JR Rivers | d8a4e42 | 2012-09-13 17:17:36 +0000 | [diff] [blame] | 764 | if (! ospf6_lsa_checksum_valid (new->header)) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 765 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 766 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 767 | zlog_debug ("Wrong LSA Checksum, discard"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 768 | ospf6_lsa_delete (new); |
| 769 | return; |
| 770 | } |
| 771 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 772 | /* (2) Examine the LSA's LS type. |
| 773 | RFC2470 3.5.1. Receiving Link State Update packets */ |
| 774 | if (IS_AREA_STUB (from->ospf6_if->area) && |
| 775 | OSPF6_LSA_SCOPE (new->header->type) == OSPF6_SCOPE_AS) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 776 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 777 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 778 | zlog_debug ("AS-External-LSA (or AS-scope LSA) in stub area, discard"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 779 | ospf6_lsa_delete (new); |
| 780 | return; |
| 781 | } |
| 782 | |
| 783 | /* (3) LSA which have reserved scope is discarded |
| 784 | RFC2470 3.5.1. Receiving Link State Update packets */ |
| 785 | /* Flooding scope check. LSAs with unknown scope are discarded here. |
| 786 | Set appropriate LSDB for the LSA */ |
| 787 | switch (OSPF6_LSA_SCOPE (new->header->type)) |
| 788 | { |
| 789 | case OSPF6_SCOPE_LINKLOCAL: |
| 790 | new->lsdb = from->ospf6_if->lsdb; |
| 791 | break; |
| 792 | case OSPF6_SCOPE_AREA: |
| 793 | new->lsdb = from->ospf6_if->area->lsdb; |
| 794 | break; |
| 795 | case OSPF6_SCOPE_AS: |
| 796 | new->lsdb = from->ospf6_if->area->ospf6->lsdb; |
| 797 | break; |
| 798 | default: |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 799 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 800 | zlog_debug ("LSA has reserved scope, discard"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 801 | ospf6_lsa_delete (new); |
| 802 | return; |
| 803 | } |
| 804 | |
| 805 | /* (4) if MaxAge LSA and if we have no instance, and no neighbor |
| 806 | is in states Exchange or Loading */ |
| 807 | if (ospf6_is_maxage_lsa_drop (new, from)) |
| 808 | { |
| 809 | /* log */ |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 810 | if (is_debug) |
Dinesh Dutt | eb82e9e | 2013-08-24 07:55:07 +0000 | [diff] [blame] | 811 | zlog_debug ("Drop MaxAge LSA with direct acknowledgement."); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 812 | |
| 813 | /* a) Acknowledge back to neighbor (Direct acknowledgement, 13.5) */ |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 814 | ospf6_lsdb_add (ospf6_lsa_copy (new), from->lsack_list); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 815 | if (from->thread_send_lsack == NULL) |
| 816 | from->thread_send_lsack = |
| 817 | thread_add_event (master, ospf6_lsack_send_neighbor, from, 0); |
| 818 | |
| 819 | /* b) Discard */ |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 820 | ospf6_lsa_delete (new); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 821 | return; |
| 822 | } |
| 823 | |
| 824 | /* (5) */ |
| 825 | /* lookup the same database copy in lsdb */ |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 826 | old = ospf6_lsdb_lookup (new->header->type, new->header->id, |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 827 | new->header->adv_router, new->lsdb); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 828 | if (old) |
| 829 | { |
| 830 | ismore_recent = ospf6_lsa_compare (new, old); |
| 831 | if (ntohl (new->header->seqnum) == ntohl (old->header->seqnum)) |
| 832 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 833 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 834 | zlog_debug ("Received is duplicated LSA"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 835 | SET_FLAG (new->flag, OSPF6_LSA_DUPLICATE); |
| 836 | } |
| 837 | } |
| 838 | |
| 839 | /* if no database copy or received is more recent */ |
| 840 | if (old == NULL || ismore_recent < 0) |
| 841 | { |
| 842 | /* in case we have no database copy */ |
| 843 | ismore_recent = -1; |
| 844 | |
| 845 | /* (a) MinLSArrival check */ |
| 846 | if (old) |
| 847 | { |
| 848 | struct timeval now, res; |
Takashi Sogabe | 86f72dc | 2009-06-22 13:07:02 +0900 | [diff] [blame] | 849 | quagga_gettime (QUAGGA_CLK_MONOTONIC, &now); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 850 | timersub (&now, &old->installed, &res); |
Dinesh Dutt | 8551e6d | 2013-10-22 17:42:18 -0700 | [diff] [blame] | 851 | if (res.tv_sec < OSPF_MIN_LS_ARRIVAL) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 852 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 853 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 854 | zlog_debug ("LSA can't be updated within MinLSArrival, discard"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 855 | ospf6_lsa_delete (new); |
| 856 | return; /* examin next lsa */ |
| 857 | } |
| 858 | } |
| 859 | |
Takashi Sogabe | 86f72dc | 2009-06-22 13:07:02 +0900 | [diff] [blame] | 860 | quagga_gettime (QUAGGA_CLK_MONOTONIC, &new->received); |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 861 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 862 | if (is_debug) |
Dinesh Dutt | bf986da | 2013-08-24 07:54:50 +0000 | [diff] [blame] | 863 | zlog_debug ("Install, Flood, Possibly acknowledge the received LSA"); |
| 864 | |
| 865 | /* Remove older copies of this LSA from retx lists */ |
| 866 | if (old) |
| 867 | ospf6_flood_clear (old); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 868 | |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 869 | /* (b) immediately flood and (c) remove from all retrans-list */ |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 870 | /* Prevent self-originated LSA to be flooded. this is to make |
| 871 | reoriginated instance of the LSA not to be rejected by other routers |
| 872 | due to MinLSArrival. */ |
| 873 | if (new->header->adv_router != from->ospf6_if->area->ospf6->router_id) |
| 874 | ospf6_flood (from, new); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 875 | |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 876 | /* (d), installing lsdb, which may cause routing |
| 877 | table calculation (replacing database copy) */ |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 878 | ospf6_install_lsa (new); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 879 | |
| 880 | /* (e) possibly acknowledge */ |
| 881 | ospf6_acknowledge_lsa (new, ismore_recent, from); |
| 882 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 883 | /* (f) Self Originated LSA, section 13.4 */ |
| 884 | if (new->header->adv_router == from->ospf6_if->area->ospf6->router_id) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 885 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 886 | /* Self-originated LSA (newer than ours) is received from |
| 887 | another router. We have to make a new instance of the LSA |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 888 | or have to flush this LSA. */ |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 889 | if (is_debug) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 890 | { |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 891 | zlog_debug ("Newer instance of the self-originated LSA"); |
| 892 | zlog_debug ("Schedule reorigination"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 893 | } |
| 894 | new->refresh = thread_add_event (master, ospf6_lsa_refresh, new, 0); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 895 | } |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 896 | |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 897 | return; |
| 898 | } |
| 899 | |
| 900 | /* (6) if there is instance on sending neighbor's request list */ |
| 901 | if (ospf6_lsdb_lookup (new->header->type, new->header->id, |
| 902 | new->header->adv_router, from->request_list)) |
| 903 | { |
| 904 | /* if no database copy, should go above state (5) */ |
| 905 | assert (old); |
| 906 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 907 | if (is_debug) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 908 | { |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 909 | zlog_debug ("Received is not newer, on the neighbor's request-list"); |
| 910 | zlog_debug ("BadLSReq, discard the received LSA"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 911 | } |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 912 | |
| 913 | /* BadLSReq */ |
| 914 | thread_add_event (master, bad_lsreq, from, 0); |
| 915 | |
| 916 | ospf6_lsa_delete (new); |
| 917 | return; |
| 918 | } |
| 919 | |
| 920 | /* (7) if neither one is more recent */ |
| 921 | if (ismore_recent == 0) |
| 922 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 923 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 924 | zlog_debug ("The same instance as database copy (neither recent)"); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 925 | |
| 926 | /* (a) if on retrans-list, Treat this LSA as an Ack: Implied Ack */ |
| 927 | rem = ospf6_lsdb_lookup (new->header->type, new->header->id, |
| 928 | new->header->adv_router, from->retrans_list); |
| 929 | if (rem) |
| 930 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 931 | if (is_debug) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 932 | { |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 933 | zlog_debug ("It is on the neighbor's retrans-list."); |
| 934 | zlog_debug ("Treat as an Implied acknowledgement"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 935 | } |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 936 | SET_FLAG (new->flag, OSPF6_LSA_IMPLIEDACK); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 937 | ospf6_decrement_retrans_count (rem); |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 938 | ospf6_lsdb_remove (rem, from->retrans_list); |
| 939 | } |
| 940 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 941 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 942 | zlog_debug ("Possibly acknowledge and then discard"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 943 | |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 944 | /* (b) possibly acknowledge */ |
| 945 | ospf6_acknowledge_lsa (new, ismore_recent, from); |
| 946 | |
| 947 | ospf6_lsa_delete (new); |
| 948 | return; |
| 949 | } |
| 950 | |
| 951 | /* (8) previous database copy is more recent */ |
| 952 | { |
| 953 | assert (old); |
| 954 | |
| 955 | /* If database copy is in 'Seqnumber Wrapping', |
| 956 | simply discard the received LSA */ |
| 957 | if (OSPF6_LSA_IS_MAXAGE (old) && |
Dinesh Dutt | 8551e6d | 2013-10-22 17:42:18 -0700 | [diff] [blame] | 958 | old->header->seqnum == htonl (OSPF_MAX_SEQUENCE_NUMBER)) |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 959 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 960 | if (is_debug) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 961 | { |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 962 | zlog_debug ("The LSA is in Seqnumber Wrapping"); |
| 963 | zlog_debug ("MaxAge & MaxSeqNum, discard"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 964 | } |
Dinesh Dutt | eb82e9e | 2013-08-24 07:55:07 +0000 | [diff] [blame] | 965 | ospf6_lsa_delete (new); |
| 966 | return; |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 967 | } |
| 968 | |
| 969 | /* Otherwise, Send database copy of this LSA to this neighbor */ |
| 970 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 971 | if (is_debug) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 972 | { |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 973 | zlog_debug ("Database copy is more recent."); |
| 974 | zlog_debug ("Send back directly and then discard"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 975 | } |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 976 | |
| 977 | /* XXX, MinLSArrival check !? RFC 2328 13 (8) */ |
| 978 | |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 979 | ospf6_lsdb_add (ospf6_lsa_copy (old), from->lsupdate_list); |
| 980 | if (from->thread_send_lsupdate == NULL) |
| 981 | from->thread_send_lsupdate = |
| 982 | thread_add_event (master, ospf6_lsupdate_send_neighbor, from, 0); |
Dinesh Dutt | eb82e9e | 2013-08-24 07:55:07 +0000 | [diff] [blame] | 983 | ospf6_lsa_delete (new); |
| 984 | return; |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 985 | } |
| 986 | return; |
| 987 | } |
| 988 | } |
| 989 | |
| 990 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 991 | DEFUN (debug_ospf6_flooding, |
| 992 | debug_ospf6_flooding_cmd, |
| 993 | "debug ospf6 flooding", |
| 994 | DEBUG_STR |
| 995 | OSPF6_STR |
| 996 | "Debug OSPFv3 flooding function\n" |
| 997 | ) |
| 998 | { |
| 999 | OSPF6_DEBUG_FLOODING_ON (); |
| 1000 | return CMD_SUCCESS; |
| 1001 | } |
| 1002 | |
| 1003 | DEFUN (no_debug_ospf6_flooding, |
| 1004 | no_debug_ospf6_flooding_cmd, |
| 1005 | "no debug ospf6 flooding", |
| 1006 | NO_STR |
| 1007 | DEBUG_STR |
| 1008 | OSPF6_STR |
| 1009 | "Debug OSPFv3 flooding function\n" |
| 1010 | ) |
| 1011 | { |
| 1012 | OSPF6_DEBUG_FLOODING_OFF (); |
| 1013 | return CMD_SUCCESS; |
| 1014 | } |
| 1015 | |
| 1016 | int |
| 1017 | config_write_ospf6_debug_flood (struct vty *vty) |
| 1018 | { |
| 1019 | if (IS_OSPF6_DEBUG_FLOODING) |
| 1020 | vty_out (vty, "debug ospf6 flooding%s", VNL); |
| 1021 | return 0; |
| 1022 | } |
| 1023 | |
| 1024 | void |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 1025 | install_element_ospf6_debug_flood (void) |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 1026 | { |
| 1027 | install_element (ENABLE_NODE, &debug_ospf6_flooding_cmd); |
| 1028 | install_element (ENABLE_NODE, &no_debug_ospf6_flooding_cmd); |
| 1029 | install_element (CONFIG_NODE, &debug_ospf6_flooding_cmd); |
| 1030 | install_element (CONFIG_NODE, &no_debug_ospf6_flooding_cmd); |
| 1031 | } |
| 1032 | |
| 1033 | |
| 1034 | |
| 1035 | |
hasso | 4845437 | 2004-05-18 19:14:52 +0000 | [diff] [blame] | 1036 | |