jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * IS-IS Rout(e)ing protocol - isis_spf.c |
| 3 | * The SPT algorithm |
| 4 | * |
| 5 | * Copyright (C) 2001,2002 Sampo Saaristo |
| 6 | * Tampere University of Technology |
| 7 | * Institute of Communications Engineering |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify it |
| 10 | * under the terms of the GNU General Public Licenseas published by the Free |
| 11 | * Software Foundation; either version 2 of the License, or (at your option) |
| 12 | * any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful,but WITHOUT |
| 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 16 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 17 | * more details. |
| 18 | |
| 19 | * You should have received a copy of the GNU General Public License along |
| 20 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 21 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 22 | */ |
| 23 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 24 | #include <zebra.h> |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 25 | |
| 26 | #include "thread.h" |
| 27 | #include "linklist.h" |
| 28 | #include "vty.h" |
| 29 | #include "log.h" |
| 30 | #include "command.h" |
| 31 | #include "memory.h" |
| 32 | #include "prefix.h" |
| 33 | #include "hash.h" |
| 34 | #include "if.h" |
| 35 | #include "table.h" |
| 36 | |
| 37 | #include "isis_constants.h" |
| 38 | #include "isis_common.h" |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 39 | #include "isis_flags.h" |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 40 | #include "dict.h" |
| 41 | #include "isisd.h" |
| 42 | #include "isis_misc.h" |
| 43 | #include "isis_adjacency.h" |
| 44 | #include "isis_circuit.h" |
| 45 | #include "isis_tlv.h" |
| 46 | #include "isis_pdu.h" |
| 47 | #include "isis_lsp.h" |
| 48 | #include "isis_dynhn.h" |
| 49 | #include "isis_spf.h" |
| 50 | #include "isis_route.h" |
| 51 | #include "isis_csm.h" |
| 52 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 53 | int isis_run_spf_l1 (struct thread *thread); |
| 54 | int isis_run_spf_l2 (struct thread *thread); |
| 55 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 56 | /* 7.2.7 */ |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 57 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 58 | remove_excess_adjs (struct list *adjs) |
| 59 | { |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 60 | struct listnode *node, *excess = NULL; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 61 | struct isis_adjacency *adj, *candidate = NULL; |
| 62 | int comp; |
| 63 | |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 64 | for (ALL_LIST_ELEMENTS_RO (adjs, node, adj)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 65 | { |
| 66 | if (excess == NULL) |
| 67 | excess = node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 68 | candidate = listgetdata (excess); |
| 69 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 70 | if (candidate->sys_type < adj->sys_type) |
| 71 | { |
| 72 | excess = node; |
| 73 | candidate = adj; |
| 74 | continue; |
| 75 | } |
| 76 | if (candidate->sys_type > adj->sys_type) |
| 77 | continue; |
| 78 | |
| 79 | comp = memcmp (candidate->sysid, adj->sysid, ISIS_SYS_ID_LEN); |
| 80 | if (comp > 0) |
| 81 | { |
| 82 | excess = node; |
| 83 | candidate = adj; |
| 84 | continue; |
| 85 | } |
| 86 | if (comp < 0) |
| 87 | continue; |
| 88 | |
| 89 | if (candidate->circuit->circuit_id > adj->circuit->circuit_id) |
| 90 | { |
| 91 | excess = node; |
| 92 | candidate = adj; |
| 93 | continue; |
| 94 | } |
| 95 | |
| 96 | if (candidate->circuit->circuit_id < adj->circuit->circuit_id) |
| 97 | continue; |
| 98 | |
| 99 | comp = memcmp (candidate->snpa, adj->snpa, ETH_ALEN); |
| 100 | if (comp > 0) |
| 101 | { |
| 102 | excess = node; |
| 103 | candidate = adj; |
| 104 | continue; |
| 105 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 106 | } |
| 107 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 108 | list_delete_node (adjs, excess); |
| 109 | |
| 110 | return; |
| 111 | } |
| 112 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 113 | static const char * |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 114 | vtype2string (enum vertextype vtype) |
| 115 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 116 | switch (vtype) |
| 117 | { |
| 118 | case VTYPE_PSEUDO_IS: |
| 119 | return "pseudo_IS"; |
| 120 | break; |
hasso | 82a8428 | 2005-09-26 18:15:36 +0000 | [diff] [blame] | 121 | case VTYPE_PSEUDO_TE_IS: |
| 122 | return "pseudo_TE-IS"; |
| 123 | break; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 124 | case VTYPE_NONPSEUDO_IS: |
| 125 | return "IS"; |
| 126 | break; |
hasso | 82a8428 | 2005-09-26 18:15:36 +0000 | [diff] [blame] | 127 | case VTYPE_NONPSEUDO_TE_IS: |
| 128 | return "TE-IS"; |
| 129 | break; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 130 | case VTYPE_ES: |
| 131 | return "ES"; |
| 132 | break; |
| 133 | case VTYPE_IPREACH_INTERNAL: |
| 134 | return "IP internal"; |
| 135 | break; |
| 136 | case VTYPE_IPREACH_EXTERNAL: |
| 137 | return "IP external"; |
| 138 | break; |
hasso | 82a8428 | 2005-09-26 18:15:36 +0000 | [diff] [blame] | 139 | case VTYPE_IPREACH_TE: |
| 140 | return "IP TE"; |
| 141 | break; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 142 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 143 | case VTYPE_IP6REACH_INTERNAL: |
| 144 | return "IP6 internal"; |
| 145 | break; |
| 146 | case VTYPE_IP6REACH_EXTERNAL: |
| 147 | return "IP6 external"; |
| 148 | break; |
| 149 | #endif /* HAVE_IPV6 */ |
| 150 | default: |
| 151 | return "UNKNOWN"; |
| 152 | } |
| 153 | return NULL; /* Not reached */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 154 | } |
| 155 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 156 | static const char * |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 157 | vid2string (struct isis_vertex *vertex, u_char * buff) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 158 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 159 | switch (vertex->type) |
| 160 | { |
| 161 | case VTYPE_PSEUDO_IS: |
hasso | 82a8428 | 2005-09-26 18:15:36 +0000 | [diff] [blame] | 162 | case VTYPE_PSEUDO_TE_IS: |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 163 | return print_sys_hostname (vertex->N.id); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 164 | break; |
| 165 | case VTYPE_NONPSEUDO_IS: |
hasso | 82a8428 | 2005-09-26 18:15:36 +0000 | [diff] [blame] | 166 | case VTYPE_NONPSEUDO_TE_IS: |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 167 | case VTYPE_ES: |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 168 | return print_sys_hostname (vertex->N.id); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 169 | break; |
| 170 | case VTYPE_IPREACH_INTERNAL: |
| 171 | case VTYPE_IPREACH_EXTERNAL: |
hasso | 82a8428 | 2005-09-26 18:15:36 +0000 | [diff] [blame] | 172 | case VTYPE_IPREACH_TE: |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 173 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 174 | case VTYPE_IP6REACH_INTERNAL: |
| 175 | case VTYPE_IP6REACH_EXTERNAL: |
| 176 | #endif /* HAVE_IPV6 */ |
hasso | f7c43dc | 2004-09-26 16:24:14 +0000 | [diff] [blame] | 177 | prefix2str ((struct prefix *) &vertex->N.prefix, (char *) buff, BUFSIZ); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 178 | break; |
| 179 | default: |
| 180 | return "UNKNOWN"; |
| 181 | } |
| 182 | |
hasso | f7c43dc | 2004-09-26 16:24:14 +0000 | [diff] [blame] | 183 | return (char *) buff; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 184 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 185 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 186 | static struct isis_vertex * |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 187 | isis_vertex_new (void *id, enum vertextype vtype) |
| 188 | { |
| 189 | struct isis_vertex *vertex; |
| 190 | |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 191 | vertex = XCALLOC (MTYPE_ISIS_VERTEX, sizeof (struct isis_vertex)); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 192 | if (vertex == NULL) |
| 193 | { |
| 194 | zlog_err ("isis_vertex_new Out of memory!"); |
| 195 | return NULL; |
| 196 | } |
| 197 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 198 | vertex->type = vtype; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 199 | switch (vtype) |
| 200 | { |
| 201 | case VTYPE_ES: |
| 202 | case VTYPE_NONPSEUDO_IS: |
hasso | 82a8428 | 2005-09-26 18:15:36 +0000 | [diff] [blame] | 203 | case VTYPE_NONPSEUDO_TE_IS: |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 204 | memcpy (vertex->N.id, (u_char *) id, ISIS_SYS_ID_LEN); |
| 205 | break; |
| 206 | case VTYPE_PSEUDO_IS: |
hasso | 82a8428 | 2005-09-26 18:15:36 +0000 | [diff] [blame] | 207 | case VTYPE_PSEUDO_TE_IS: |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 208 | memcpy (vertex->N.id, (u_char *) id, ISIS_SYS_ID_LEN + 1); |
| 209 | break; |
| 210 | case VTYPE_IPREACH_INTERNAL: |
| 211 | case VTYPE_IPREACH_EXTERNAL: |
hasso | 82a8428 | 2005-09-26 18:15:36 +0000 | [diff] [blame] | 212 | case VTYPE_IPREACH_TE: |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 213 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 214 | case VTYPE_IP6REACH_INTERNAL: |
| 215 | case VTYPE_IP6REACH_EXTERNAL: |
| 216 | #endif /* HAVE_IPV6 */ |
| 217 | memcpy (&vertex->N.prefix, (struct prefix *) id, |
| 218 | sizeof (struct prefix)); |
| 219 | break; |
| 220 | default: |
| 221 | zlog_err ("WTF!"); |
| 222 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 223 | |
| 224 | vertex->Adj_N = list_new (); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 225 | vertex->parents = list_new (); |
| 226 | vertex->children = list_new (); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 227 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 228 | return vertex; |
| 229 | } |
| 230 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 231 | static void |
| 232 | isis_vertex_del (struct isis_vertex *vertex) |
| 233 | { |
| 234 | list_delete (vertex->Adj_N); |
| 235 | vertex->Adj_N = NULL; |
| 236 | list_delete (vertex->parents); |
| 237 | vertex->parents = NULL; |
| 238 | list_delete (vertex->children); |
| 239 | vertex->children = NULL; |
| 240 | |
| 241 | memset(vertex, 0, sizeof(struct isis_vertex)); |
| 242 | XFREE (MTYPE_ISIS_VERTEX, vertex); |
| 243 | |
| 244 | return; |
| 245 | } |
| 246 | |
| 247 | static void |
| 248 | isis_vertex_adj_del (struct isis_vertex *vertex, struct isis_adjacency *adj) |
| 249 | { |
| 250 | struct listnode *node, *nextnode; |
| 251 | if (!vertex) |
| 252 | return; |
| 253 | for (node = listhead (vertex->Adj_N); node; node = nextnode) |
| 254 | { |
| 255 | nextnode = listnextnode(node); |
| 256 | if (listgetdata(node) == adj) |
| 257 | list_delete_node(vertex->Adj_N, node); |
| 258 | } |
| 259 | return; |
| 260 | } |
| 261 | |
| 262 | struct isis_spftree * |
| 263 | isis_spftree_new (struct isis_area *area) |
| 264 | { |
| 265 | struct isis_spftree *tree; |
| 266 | |
| 267 | tree = XCALLOC (MTYPE_ISIS_SPFTREE, sizeof (struct isis_spftree)); |
| 268 | if (tree == NULL) |
| 269 | { |
| 270 | zlog_err ("ISIS-Spf: isis_spftree_new Out of memory!"); |
| 271 | return NULL; |
| 272 | } |
| 273 | |
| 274 | tree->tents = list_new (); |
| 275 | tree->paths = list_new (); |
| 276 | tree->area = area; |
| 277 | tree->lastrun = 0; |
| 278 | tree->runcount = 0; |
| 279 | tree->pending = 0; |
| 280 | return tree; |
| 281 | } |
| 282 | |
| 283 | void |
| 284 | isis_spftree_del (struct isis_spftree *spftree) |
| 285 | { |
| 286 | THREAD_TIMER_OFF (spftree->t_spf); |
| 287 | |
| 288 | spftree->tents->del = (void (*)(void *)) isis_vertex_del; |
| 289 | list_delete (spftree->tents); |
| 290 | spftree->tents = NULL; |
| 291 | |
| 292 | spftree->paths->del = (void (*)(void *)) isis_vertex_del; |
| 293 | list_delete (spftree->paths); |
| 294 | spftree->paths = NULL; |
| 295 | |
| 296 | XFREE (MTYPE_ISIS_SPFTREE, spftree); |
| 297 | |
| 298 | return; |
| 299 | } |
| 300 | |
| 301 | void |
| 302 | isis_spftree_adj_del (struct isis_spftree *spftree, struct isis_adjacency *adj) |
| 303 | { |
| 304 | struct listnode *node; |
| 305 | if (!adj) |
| 306 | return; |
| 307 | for (node = listhead (spftree->tents); node; node = listnextnode (node)) |
| 308 | isis_vertex_adj_del (listgetdata (node), adj); |
| 309 | for (node = listhead (spftree->paths); node; node = listnextnode (node)) |
| 310 | isis_vertex_adj_del (listgetdata (node), adj); |
| 311 | return; |
| 312 | } |
| 313 | |
| 314 | void |
| 315 | spftree_area_init (struct isis_area *area) |
| 316 | { |
| 317 | if (area->is_type & IS_LEVEL_1) |
| 318 | { |
| 319 | if (area->spftree[0] == NULL) |
| 320 | area->spftree[0] = isis_spftree_new (area); |
| 321 | #ifdef HAVE_IPV6 |
| 322 | if (area->spftree6[0] == NULL) |
| 323 | area->spftree6[0] = isis_spftree_new (area); |
| 324 | #endif |
| 325 | } |
| 326 | |
| 327 | if (area->is_type & IS_LEVEL_2) |
| 328 | { |
| 329 | if (area->spftree[1] == NULL) |
| 330 | area->spftree[1] = isis_spftree_new (area); |
| 331 | #ifdef HAVE_IPV6 |
| 332 | if (area->spftree6[1] == NULL) |
| 333 | area->spftree6[1] = isis_spftree_new (area); |
| 334 | #endif |
| 335 | } |
| 336 | |
| 337 | return; |
| 338 | } |
| 339 | |
| 340 | void |
| 341 | spftree_area_del (struct isis_area *area) |
| 342 | { |
| 343 | if (area->is_type & IS_LEVEL_1) |
| 344 | { |
| 345 | if (area->spftree[0] != NULL) |
| 346 | { |
| 347 | isis_spftree_del (area->spftree[0]); |
| 348 | area->spftree[0] = NULL; |
| 349 | } |
| 350 | #ifdef HAVE_IPV6 |
| 351 | if (area->spftree6[0]) |
| 352 | { |
| 353 | isis_spftree_del (area->spftree6[0]); |
| 354 | area->spftree6[0] = NULL; |
| 355 | } |
| 356 | #endif |
| 357 | } |
| 358 | |
| 359 | if (area->is_type & IS_LEVEL_2) |
| 360 | { |
| 361 | if (area->spftree[1] != NULL) |
| 362 | { |
| 363 | isis_spftree_del (area->spftree[1]); |
| 364 | area->spftree[1] = NULL; |
| 365 | } |
| 366 | #ifdef HAVE_IPV6 |
| 367 | if (area->spftree[1] != NULL) |
| 368 | { |
| 369 | isis_spftree_del (area->spftree6[1]); |
| 370 | area->spftree6[1] = NULL; |
| 371 | } |
| 372 | #endif |
| 373 | } |
| 374 | |
| 375 | return; |
| 376 | } |
| 377 | |
| 378 | void |
| 379 | spftree_area_adj_del (struct isis_area *area, struct isis_adjacency *adj) |
| 380 | { |
| 381 | if (area->is_type & IS_LEVEL_1) |
| 382 | { |
| 383 | if (area->spftree[0] != NULL) |
| 384 | isis_spftree_adj_del (area->spftree[0], adj); |
| 385 | #ifdef HAVE_IPV6 |
| 386 | if (area->spftree6[0] != NULL) |
| 387 | isis_spftree_adj_del (area->spftree6[0], adj); |
| 388 | #endif |
| 389 | } |
| 390 | |
| 391 | if (area->is_type & IS_LEVEL_2) |
| 392 | { |
| 393 | if (area->spftree[1] != NULL) |
| 394 | isis_spftree_adj_del (area->spftree[1], adj); |
| 395 | #ifdef HAVE_IPV6 |
| 396 | if (area->spftree6[1] != NULL) |
| 397 | isis_spftree_adj_del (area->spftree6[1], adj); |
| 398 | #endif |
| 399 | } |
| 400 | |
| 401 | return; |
| 402 | } |
| 403 | |
| 404 | /* |
| 405 | * Find the system LSP: returns the LSP in our LSP database |
| 406 | * associated with the given system ID. |
| 407 | */ |
| 408 | static struct isis_lsp * |
| 409 | isis_root_system_lsp (struct isis_area *area, int level, u_char *sysid) |
| 410 | { |
| 411 | u_char lspid[ISIS_SYS_ID_LEN + 2]; |
| 412 | |
| 413 | memcpy (lspid, sysid, ISIS_SYS_ID_LEN); |
| 414 | LSP_PSEUDO_ID (lspid) = 0; |
| 415 | LSP_FRAGMENT (lspid) = 0; |
| 416 | return (lsp_search (lspid, area->lspdb[level - 1])); |
| 417 | } |
| 418 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 419 | /* |
| 420 | * Add this IS to the root of SPT |
| 421 | */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 422 | static struct isis_vertex * |
| 423 | isis_spf_add_root (struct isis_spftree *spftree, int level, u_char *sysid) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 424 | { |
| 425 | struct isis_vertex *vertex; |
| 426 | struct isis_lsp *lsp; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 427 | #ifdef EXTREME_DEBUG |
| 428 | u_char buff[BUFSIZ]; |
| 429 | #endif /* EXTREME_DEBUG */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 430 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 431 | lsp = isis_root_system_lsp (spftree->area, level, sysid); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 432 | if (lsp == NULL) |
| 433 | zlog_warn ("ISIS-Spf: could not find own l%d LSP!", level); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 434 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 435 | if (!spftree->area->oldmetric) |
| 436 | vertex = isis_vertex_new (sysid, VTYPE_NONPSEUDO_TE_IS); |
hasso | 82a8428 | 2005-09-26 18:15:36 +0000 | [diff] [blame] | 437 | else |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 438 | vertex = isis_vertex_new (sysid, VTYPE_NONPSEUDO_IS); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 439 | |
| 440 | listnode_add (spftree->paths, vertex); |
| 441 | |
| 442 | #ifdef EXTREME_DEBUG |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 443 | zlog_debug ("ISIS-Spf: added this IS %s %s depth %d dist %d to PATHS", |
| 444 | vtype2string (vertex->type), vid2string (vertex, buff), |
| 445 | vertex->depth, vertex->d_N); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 446 | #endif /* EXTREME_DEBUG */ |
| 447 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 448 | return vertex; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 449 | } |
| 450 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 451 | static struct isis_vertex * |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 452 | isis_find_vertex (struct list *list, void *id, enum vertextype vtype) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 453 | { |
| 454 | struct listnode *node; |
| 455 | struct isis_vertex *vertex; |
| 456 | struct prefix *p1, *p2; |
| 457 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 458 | for (ALL_LIST_ELEMENTS_RO (list, node, vertex)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 459 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 460 | if (vertex->type != vtype) |
| 461 | continue; |
| 462 | switch (vtype) |
| 463 | { |
| 464 | case VTYPE_ES: |
| 465 | case VTYPE_NONPSEUDO_IS: |
hasso | 82a8428 | 2005-09-26 18:15:36 +0000 | [diff] [blame] | 466 | case VTYPE_NONPSEUDO_TE_IS: |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 467 | if (memcmp ((u_char *) id, vertex->N.id, ISIS_SYS_ID_LEN) == 0) |
| 468 | return vertex; |
| 469 | break; |
| 470 | case VTYPE_PSEUDO_IS: |
hasso | 82a8428 | 2005-09-26 18:15:36 +0000 | [diff] [blame] | 471 | case VTYPE_PSEUDO_TE_IS: |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 472 | if (memcmp ((u_char *) id, vertex->N.id, ISIS_SYS_ID_LEN + 1) == 0) |
| 473 | return vertex; |
| 474 | break; |
| 475 | case VTYPE_IPREACH_INTERNAL: |
| 476 | case VTYPE_IPREACH_EXTERNAL: |
hasso | 82a8428 | 2005-09-26 18:15:36 +0000 | [diff] [blame] | 477 | case VTYPE_IPREACH_TE: |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 478 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 479 | case VTYPE_IP6REACH_INTERNAL: |
| 480 | case VTYPE_IP6REACH_EXTERNAL: |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 481 | #endif /* HAVE_IPV6 */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 482 | p1 = (struct prefix *) id; |
| 483 | p2 = (struct prefix *) &vertex->N.id; |
| 484 | if (p1->family == p2->family && p1->prefixlen == p2->prefixlen && |
| 485 | memcmp (&p1->u.prefix, &p2->u.prefix, |
| 486 | PSIZE (p1->prefixlen)) == 0) |
| 487 | return vertex; |
| 488 | break; |
| 489 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 490 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 491 | |
| 492 | return NULL; |
| 493 | } |
| 494 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 495 | /* |
| 496 | * Add a vertex to TENT sorted by cost and by vertextype on tie break situation |
| 497 | */ |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 498 | static struct isis_vertex * |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 499 | isis_spf_add2tent (struct isis_spftree *spftree, enum vertextype vtype, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 500 | void *id, uint32_t cost, int depth, int family, |
| 501 | struct isis_adjacency *adj, struct isis_vertex *parent) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 502 | { |
| 503 | struct isis_vertex *vertex, *v; |
| 504 | struct listnode *node; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 505 | struct isis_adjacency *parent_adj; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 506 | #ifdef EXTREME_DEBUG |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 507 | u_char buff[BUFSIZ]; |
| 508 | #endif |
| 509 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 510 | assert (isis_find_vertex (spftree->paths, id, vtype) == NULL); |
| 511 | assert (isis_find_vertex (spftree->tents, id, vtype) == NULL); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 512 | vertex = isis_vertex_new (id, vtype); |
| 513 | vertex->d_N = cost; |
| 514 | vertex->depth = depth; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 515 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 516 | if (parent) { |
| 517 | listnode_add (vertex->parents, parent); |
| 518 | if (listnode_lookup (parent->children, vertex) == NULL) |
| 519 | listnode_add (parent->children, vertex); |
| 520 | } |
| 521 | |
| 522 | if (parent && parent->Adj_N && listcount(parent->Adj_N) > 0) { |
| 523 | for (ALL_LIST_ELEMENTS_RO (parent->Adj_N, node, parent_adj)) |
| 524 | listnode_add (vertex->Adj_N, parent_adj); |
| 525 | } else if (adj) { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 526 | listnode_add (vertex->Adj_N, adj); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 527 | } |
| 528 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 529 | #ifdef EXTREME_DEBUG |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 530 | zlog_debug ("ISIS-Spf: add to TENT %s %s %s depth %d dist %d adjcount %d", |
| 531 | print_sys_hostname (vertex->N.id), |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 532 | vtype2string (vertex->type), vid2string (vertex, buff), |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 533 | vertex->depth, vertex->d_N, listcount(vertex->Adj_N)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 534 | #endif /* EXTREME_DEBUG */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 535 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 536 | if (list_isempty (spftree->tents)) |
| 537 | { |
| 538 | listnode_add (spftree->tents, vertex); |
| 539 | return vertex; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 540 | } |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 541 | |
| 542 | /* XXX: This cant use the standard ALL_LIST_ELEMENTS macro */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 543 | for (node = listhead (spftree->tents); node; node = listnextnode (node)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 544 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 545 | v = listgetdata (node); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 546 | if (v->d_N > vertex->d_N) |
| 547 | { |
| 548 | list_add_node_prev (spftree->tents, node, vertex); |
| 549 | break; |
| 550 | } |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 551 | else if (v->d_N == vertex->d_N && v->type > vertex->type) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 552 | { |
| 553 | /* Tie break, add according to type */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 554 | list_add_node_prev (spftree->tents, node, vertex); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 555 | break; |
| 556 | } |
| 557 | } |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 558 | |
| 559 | if (node == NULL) |
| 560 | listnode_add (spftree->tents, vertex); |
| 561 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 562 | return vertex; |
| 563 | } |
| 564 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 565 | static void |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 566 | isis_spf_add_local (struct isis_spftree *spftree, enum vertextype vtype, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 567 | void *id, struct isis_adjacency *adj, uint32_t cost, |
| 568 | int family, struct isis_vertex *parent) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 569 | { |
| 570 | struct isis_vertex *vertex; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 571 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 572 | vertex = isis_find_vertex (spftree->tents, id, vtype); |
| 573 | |
| 574 | if (vertex) |
| 575 | { |
| 576 | /* C.2.5 c) */ |
| 577 | if (vertex->d_N == cost) |
| 578 | { |
| 579 | if (adj) |
| 580 | listnode_add (vertex->Adj_N, adj); |
| 581 | /* d) */ |
| 582 | if (listcount (vertex->Adj_N) > ISIS_MAX_PATH_SPLITS) |
| 583 | remove_excess_adjs (vertex->Adj_N); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 584 | if (parent && (listnode_lookup (vertex->parents, parent) == NULL)) |
| 585 | listnode_add (vertex->parents, parent); |
| 586 | if (parent && (listnode_lookup (parent->children, vertex) == NULL)) |
| 587 | listnode_add (parent->children, vertex); |
| 588 | return; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 589 | } |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 590 | else if (vertex->d_N < cost) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 591 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 592 | /* e) do nothing */ |
| 593 | return; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 594 | } |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 595 | else { /* vertex->d_N > cost */ |
| 596 | /* f) */ |
| 597 | struct listnode *pnode, *pnextnode; |
| 598 | struct isis_vertex *pvertex; |
| 599 | listnode_delete (spftree->tents, vertex); |
| 600 | assert (listcount (vertex->children) == 0); |
| 601 | for (ALL_LIST_ELEMENTS (vertex->parents, pnode, pnextnode, pvertex)) |
| 602 | listnode_delete(pvertex->children, vertex); |
| 603 | isis_vertex_del (vertex); |
| 604 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 605 | } |
| 606 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 607 | isis_spf_add2tent (spftree, vtype, id, cost, 1, family, adj, parent); |
| 608 | return; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 609 | } |
| 610 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 611 | static void |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 612 | process_N (struct isis_spftree *spftree, enum vertextype vtype, void *id, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 613 | uint32_t dist, uint16_t depth, int family, |
| 614 | struct isis_vertex *parent) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 615 | { |
| 616 | struct isis_vertex *vertex; |
| 617 | #ifdef EXTREME_DEBUG |
| 618 | u_char buff[255]; |
| 619 | #endif |
| 620 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 621 | assert (spftree && parent); |
| 622 | |
| 623 | /* RFC3787 section 5.1 */ |
| 624 | if (spftree->area->newmetric == 1) |
| 625 | { |
| 626 | if (dist > MAX_WIDE_PATH_METRIC) |
| 627 | return; |
| 628 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 629 | /* C.2.6 b) */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 630 | else if (spftree->area->oldmetric == 1) |
| 631 | { |
| 632 | if (dist > MAX_NARROW_PATH_METRIC) |
| 633 | return; |
| 634 | } |
| 635 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 636 | /* c) */ |
| 637 | vertex = isis_find_vertex (spftree->paths, id, vtype); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 638 | if (vertex) |
| 639 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 640 | #ifdef EXTREME_DEBUG |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 641 | zlog_debug ("ISIS-Spf: process_N %s %s %s dist %d already found from PATH", |
| 642 | print_sys_hostname (vertex->N.id), |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 643 | vtype2string (vtype), vid2string (vertex, buff), dist); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 644 | #endif /* EXTREME_DEBUG */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 645 | assert (dist >= vertex->d_N); |
| 646 | return; |
| 647 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 648 | |
| 649 | vertex = isis_find_vertex (spftree->tents, id, vtype); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 650 | /* d) */ |
| 651 | if (vertex) |
| 652 | { |
| 653 | /* 1) */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 654 | #ifdef EXTREME_DEBUG |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 655 | zlog_debug ("ISIS-Spf: process_N %s %s %s dist %d parent %s adjcount %d", |
| 656 | print_sys_hostname (vertex->N.id), |
| 657 | vtype2string (vtype), vid2string (vertex, buff), dist, |
| 658 | (parent ? print_sys_hostname (parent->N.id) : "null"), |
| 659 | (parent ? listcount (parent->Adj_N) : 0)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 660 | #endif /* EXTREME_DEBUG */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 661 | if (vertex->d_N == dist) |
| 662 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 663 | struct listnode *node; |
| 664 | struct isis_adjacency *parent_adj; |
| 665 | for (ALL_LIST_ELEMENTS_RO (parent->Adj_N, node, parent_adj)) |
| 666 | if (listnode_lookup(vertex->Adj_N, parent_adj) == NULL) |
| 667 | listnode_add (vertex->Adj_N, parent_adj); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 668 | /* 2) */ |
| 669 | if (listcount (vertex->Adj_N) > ISIS_MAX_PATH_SPLITS) |
| 670 | remove_excess_adjs (vertex->Adj_N); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 671 | if (listnode_lookup (vertex->parents, parent) == NULL) |
| 672 | listnode_add (vertex->parents, parent); |
| 673 | if (listnode_lookup (parent->children, vertex) == NULL) |
| 674 | listnode_add (parent->children, vertex); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 675 | /* 3) */ |
| 676 | return; |
| 677 | } |
| 678 | else if (vertex->d_N < dist) |
| 679 | { |
| 680 | return; |
| 681 | /* 4) */ |
| 682 | } |
| 683 | else |
| 684 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 685 | struct listnode *pnode, *pnextnode; |
| 686 | struct isis_vertex *pvertex; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 687 | listnode_delete (spftree->tents, vertex); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 688 | assert (listcount (vertex->children) == 0); |
| 689 | for (ALL_LIST_ELEMENTS (vertex->parents, pnode, pnextnode, pvertex)) |
| 690 | listnode_delete(pvertex->children, vertex); |
| 691 | isis_vertex_del (vertex); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 692 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 693 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 694 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 695 | #ifdef EXTREME_DEBUG |
| 696 | zlog_debug ("ISIS-Spf: process_N add2tent %s %s dist %d parent %s", |
| 697 | print_sys_hostname(id), vtype2string (vtype), dist, |
| 698 | (parent ? print_sys_hostname (parent->N.id) : "null")); |
| 699 | #endif /* EXTREME_DEBUG */ |
| 700 | |
| 701 | isis_spf_add2tent (spftree, vtype, id, dist, depth, family, NULL, parent); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 702 | return; |
| 703 | } |
| 704 | |
| 705 | /* |
| 706 | * C.2.6 Step 1 |
| 707 | */ |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 708 | static int |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 709 | isis_spf_process_lsp (struct isis_spftree *spftree, struct isis_lsp *lsp, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 710 | uint32_t cost, uint16_t depth, int family, |
| 711 | u_char *root_sysid, struct isis_vertex *parent) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 712 | { |
| 713 | struct listnode *node, *fragnode = NULL; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 714 | uint32_t dist; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 715 | struct is_neigh *is_neigh; |
hasso | 82a8428 | 2005-09-26 18:15:36 +0000 | [diff] [blame] | 716 | struct te_is_neigh *te_is_neigh; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 717 | struct ipv4_reachability *ipreach; |
hasso | 82a8428 | 2005-09-26 18:15:36 +0000 | [diff] [blame] | 718 | struct te_ipv4_reachability *te_ipv4_reach; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 719 | enum vertextype vtype; |
| 720 | struct prefix prefix; |
| 721 | #ifdef HAVE_IPV6 |
| 722 | struct ipv6_reachability *ip6reach; |
| 723 | #endif /* HAVE_IPV6 */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 724 | static const u_char null_sysid[ISIS_SYS_ID_LEN]; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 725 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 726 | if (!speaks (lsp->tlv_data.nlpids, family)) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 727 | return ISIS_OK; |
| 728 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 729 | lspfragloop: |
| 730 | if (lsp->lsp_header->seq_num == 0) |
| 731 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 732 | zlog_warn ("isis_spf_process_lsp(): lsp with 0 seq_num - ignore"); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 733 | return ISIS_WARNING; |
| 734 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 735 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 736 | #ifdef EXTREME_DEBUG |
| 737 | zlog_debug ("ISIS-Spf: process_lsp %s", print_sys_hostname(lsp->lsp_header->lsp_id)); |
| 738 | #endif /* EXTREME_DEBUG */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 739 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 740 | if (!ISIS_MASK_LSP_OL_BIT (lsp->lsp_header->lsp_bits)) |
| 741 | { |
| 742 | if (lsp->tlv_data.is_neighs) |
| 743 | { |
| 744 | for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.is_neighs, node, is_neigh)) |
| 745 | { |
| 746 | /* C.2.6 a) */ |
| 747 | /* Two way connectivity */ |
| 748 | if (!memcmp (is_neigh->neigh_id, root_sysid, ISIS_SYS_ID_LEN)) |
| 749 | continue; |
| 750 | if (!memcmp (is_neigh->neigh_id, null_sysid, ISIS_SYS_ID_LEN)) |
| 751 | continue; |
| 752 | dist = cost + is_neigh->metrics.metric_default; |
| 753 | vtype = LSP_PSEUDO_ID (is_neigh->neigh_id) ? VTYPE_PSEUDO_IS |
| 754 | : VTYPE_NONPSEUDO_IS; |
| 755 | process_N (spftree, vtype, (void *) is_neigh->neigh_id, dist, |
| 756 | depth + 1, family, parent); |
| 757 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 758 | } |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 759 | if (lsp->tlv_data.te_is_neighs) |
| 760 | { |
| 761 | for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.te_is_neighs, node, |
| 762 | te_is_neigh)) |
| 763 | { |
| 764 | if (!memcmp (te_is_neigh->neigh_id, root_sysid, ISIS_SYS_ID_LEN)) |
| 765 | continue; |
| 766 | if (!memcmp (te_is_neigh->neigh_id, null_sysid, ISIS_SYS_ID_LEN)) |
| 767 | continue; |
| 768 | dist = cost + GET_TE_METRIC(te_is_neigh); |
| 769 | vtype = LSP_PSEUDO_ID (te_is_neigh->neigh_id) ? VTYPE_PSEUDO_TE_IS |
| 770 | : VTYPE_NONPSEUDO_TE_IS; |
| 771 | process_N (spftree, vtype, (void *) te_is_neigh->neigh_id, dist, |
| 772 | depth + 1, family, parent); |
| 773 | } |
| 774 | } |
| 775 | } |
| 776 | |
| 777 | if (family == AF_INET && lsp->tlv_data.ipv4_int_reachs) |
| 778 | { |
| 779 | prefix.family = AF_INET; |
| 780 | for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.ipv4_int_reachs, node, ipreach)) |
| 781 | { |
| 782 | dist = cost + ipreach->metrics.metric_default; |
| 783 | vtype = VTYPE_IPREACH_INTERNAL; |
| 784 | prefix.u.prefix4 = ipreach->prefix; |
| 785 | prefix.prefixlen = ip_masklen (ipreach->mask); |
| 786 | apply_mask (&prefix); |
| 787 | process_N (spftree, vtype, (void *) &prefix, dist, depth + 1, |
| 788 | family, parent); |
| 789 | } |
| 790 | } |
| 791 | if (family == AF_INET && lsp->tlv_data.ipv4_ext_reachs) |
| 792 | { |
| 793 | prefix.family = AF_INET; |
| 794 | for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.ipv4_ext_reachs, node, ipreach)) |
| 795 | { |
| 796 | dist = cost + ipreach->metrics.metric_default; |
| 797 | vtype = VTYPE_IPREACH_EXTERNAL; |
| 798 | prefix.u.prefix4 = ipreach->prefix; |
| 799 | prefix.prefixlen = ip_masklen (ipreach->mask); |
| 800 | apply_mask (&prefix); |
| 801 | process_N (spftree, vtype, (void *) &prefix, dist, depth + 1, |
| 802 | family, parent); |
| 803 | } |
| 804 | } |
| 805 | if (family == AF_INET && lsp->tlv_data.te_ipv4_reachs) |
| 806 | { |
| 807 | prefix.family = AF_INET; |
| 808 | for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.te_ipv4_reachs, |
| 809 | node, te_ipv4_reach)) |
| 810 | { |
| 811 | dist = cost + ntohl (te_ipv4_reach->te_metric); |
| 812 | vtype = VTYPE_IPREACH_TE; |
| 813 | prefix.u.prefix4 = newprefix2inaddr (&te_ipv4_reach->prefix_start, |
| 814 | te_ipv4_reach->control); |
| 815 | prefix.prefixlen = (te_ipv4_reach->control & 0x3F); |
| 816 | apply_mask (&prefix); |
| 817 | process_N (spftree, vtype, (void *) &prefix, dist, depth + 1, |
| 818 | family, parent); |
| 819 | } |
| 820 | } |
| 821 | #ifdef HAVE_IPV6 |
| 822 | if (family == AF_INET6 && lsp->tlv_data.ipv6_reachs) |
| 823 | { |
| 824 | prefix.family = AF_INET6; |
| 825 | for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.ipv6_reachs, node, ip6reach)) |
| 826 | { |
| 827 | dist = cost + ip6reach->metric; |
| 828 | vtype = (ip6reach->control_info & CTRL_INFO_DISTRIBUTION) ? |
| 829 | VTYPE_IP6REACH_EXTERNAL : VTYPE_IP6REACH_INTERNAL; |
| 830 | prefix.prefixlen = ip6reach->prefix_len; |
| 831 | memcpy (&prefix.u.prefix6.s6_addr, ip6reach->prefix, |
| 832 | PSIZE (ip6reach->prefix_len)); |
| 833 | apply_mask (&prefix); |
| 834 | process_N (spftree, vtype, (void *) &prefix, dist, depth + 1, |
| 835 | family, parent); |
| 836 | } |
| 837 | } |
| 838 | #endif /* HAVE_IPV6 */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 839 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 840 | if (fragnode == NULL) |
| 841 | fragnode = listhead (lsp->lspu.frags); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 842 | else |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 843 | fragnode = listnextnode (fragnode); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 844 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 845 | if (fragnode) |
| 846 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 847 | lsp = listgetdata (fragnode); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 848 | goto lspfragloop; |
| 849 | } |
| 850 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 851 | return ISIS_OK; |
| 852 | } |
| 853 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 854 | static int |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 855 | isis_spf_process_pseudo_lsp (struct isis_spftree *spftree, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 856 | struct isis_lsp *lsp, uint32_t cost, |
| 857 | uint16_t depth, int family, |
| 858 | u_char *root_sysid, |
| 859 | struct isis_vertex *parent) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 860 | { |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 861 | struct listnode *node, *fragnode = NULL; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 862 | struct is_neigh *is_neigh; |
hasso | 82a8428 | 2005-09-26 18:15:36 +0000 | [diff] [blame] | 863 | struct te_is_neigh *te_is_neigh; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 864 | enum vertextype vtype; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 865 | uint32_t dist; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 866 | |
| 867 | pseudofragloop: |
| 868 | |
| 869 | if (lsp->lsp_header->seq_num == 0) |
| 870 | { |
| 871 | zlog_warn ("isis_spf_process_pseudo_lsp(): lsp with 0 seq_num" |
| 872 | " - do not process"); |
| 873 | return ISIS_WARNING; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 874 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 875 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 876 | #ifdef EXTREME_DEBUG |
| 877 | zlog_debug ("ISIS-Spf: process_pseudo_lsp %s", |
| 878 | print_sys_hostname(lsp->lsp_header->lsp_id)); |
| 879 | #endif /* EXTREME_DEBUG */ |
| 880 | |
| 881 | /* RFC3787 section 4 SHOULD ignore overload bit in pseudo LSPs */ |
| 882 | |
hasso | 82a8428 | 2005-09-26 18:15:36 +0000 | [diff] [blame] | 883 | if (lsp->tlv_data.is_neighs) |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 884 | for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.is_neighs, node, is_neigh)) |
hasso | 82a8428 | 2005-09-26 18:15:36 +0000 | [diff] [blame] | 885 | { |
hasso | 82a8428 | 2005-09-26 18:15:36 +0000 | [diff] [blame] | 886 | /* Two way connectivity */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 887 | if (!memcmp (is_neigh->neigh_id, root_sysid, ISIS_SYS_ID_LEN)) |
hasso | 82a8428 | 2005-09-26 18:15:36 +0000 | [diff] [blame] | 888 | continue; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 889 | dist = cost + is_neigh->metrics.metric_default; |
| 890 | vtype = LSP_PSEUDO_ID (is_neigh->neigh_id) ? VTYPE_PSEUDO_IS |
| 891 | : VTYPE_NONPSEUDO_IS; |
| 892 | process_N (spftree, vtype, (void *) is_neigh->neigh_id, dist, |
| 893 | depth + 1, family, parent); |
hasso | 82a8428 | 2005-09-26 18:15:36 +0000 | [diff] [blame] | 894 | } |
| 895 | if (lsp->tlv_data.te_is_neighs) |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 896 | for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.te_is_neighs, node, te_is_neigh)) |
hasso | 82a8428 | 2005-09-26 18:15:36 +0000 | [diff] [blame] | 897 | { |
hasso | 82a8428 | 2005-09-26 18:15:36 +0000 | [diff] [blame] | 898 | /* Two way connectivity */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 899 | if (!memcmp (te_is_neigh->neigh_id, root_sysid, ISIS_SYS_ID_LEN)) |
hasso | 82a8428 | 2005-09-26 18:15:36 +0000 | [diff] [blame] | 900 | continue; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 901 | dist = cost + GET_TE_METRIC(te_is_neigh); |
| 902 | vtype = LSP_PSEUDO_ID (te_is_neigh->neigh_id) ? VTYPE_PSEUDO_TE_IS |
| 903 | : VTYPE_NONPSEUDO_TE_IS; |
| 904 | process_N (spftree, vtype, (void *) te_is_neigh->neigh_id, dist, |
| 905 | depth + 1, family, parent); |
hasso | 82a8428 | 2005-09-26 18:15:36 +0000 | [diff] [blame] | 906 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 907 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 908 | if (fragnode == NULL) |
| 909 | fragnode = listhead (lsp->lspu.frags); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 910 | else |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 911 | fragnode = listnextnode (fragnode); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 912 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 913 | if (fragnode) |
| 914 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 915 | lsp = listgetdata (fragnode); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 916 | goto pseudofragloop; |
| 917 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 918 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 919 | return ISIS_OK; |
| 920 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 921 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 922 | static int |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 923 | isis_spf_preload_tent (struct isis_spftree *spftree, int level, |
| 924 | int family, u_char *root_sysid, |
| 925 | struct isis_vertex *parent) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 926 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 927 | struct isis_circuit *circuit; |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 928 | struct listnode *cnode, *anode, *ipnode; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 929 | struct isis_adjacency *adj; |
| 930 | struct isis_lsp *lsp; |
| 931 | struct list *adj_list; |
| 932 | struct list *adjdb; |
| 933 | struct prefix_ipv4 *ipv4; |
| 934 | struct prefix prefix; |
| 935 | int retval = ISIS_OK; |
| 936 | u_char lsp_id[ISIS_SYS_ID_LEN + 2]; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 937 | static u_char null_lsp_id[ISIS_SYS_ID_LEN + 2]; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 938 | #ifdef HAVE_IPV6 |
| 939 | struct prefix_ipv6 *ipv6; |
| 940 | #endif /* HAVE_IPV6 */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 941 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 942 | for (ALL_LIST_ELEMENTS_RO (spftree->area->circuit_list, cnode, circuit)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 943 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 944 | if (circuit->state != C_STATE_UP) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 945 | continue; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 946 | if (!(circuit->is_type & level)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 947 | continue; |
| 948 | if (family == AF_INET && !circuit->ip_router) |
| 949 | continue; |
| 950 | #ifdef HAVE_IPV6 |
| 951 | if (family == AF_INET6 && !circuit->ipv6_router) |
| 952 | continue; |
| 953 | #endif /* HAVE_IPV6 */ |
| 954 | /* |
| 955 | * Add IP(v6) addresses of this circuit |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 956 | */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 957 | if (family == AF_INET) |
| 958 | { |
| 959 | prefix.family = AF_INET; |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 960 | for (ALL_LIST_ELEMENTS_RO (circuit->ip_addrs, ipnode, ipv4)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 961 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 962 | prefix.u.prefix4 = ipv4->prefix; |
| 963 | prefix.prefixlen = ipv4->prefixlen; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 964 | apply_mask (&prefix); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 965 | isis_spf_add_local (spftree, VTYPE_IPREACH_INTERNAL, &prefix, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 966 | NULL, 0, family, parent); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 967 | } |
| 968 | } |
| 969 | #ifdef HAVE_IPV6 |
| 970 | if (family == AF_INET6) |
| 971 | { |
| 972 | prefix.family = AF_INET6; |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 973 | for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_non_link, ipnode, ipv6)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 974 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 975 | prefix.prefixlen = ipv6->prefixlen; |
| 976 | prefix.u.prefix6 = ipv6->prefix; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 977 | apply_mask (&prefix); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 978 | isis_spf_add_local (spftree, VTYPE_IP6REACH_INTERNAL, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 979 | &prefix, NULL, 0, family, parent); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 980 | } |
| 981 | } |
| 982 | #endif /* HAVE_IPV6 */ |
| 983 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) |
| 984 | { |
| 985 | /* |
| 986 | * Add the adjacencies |
| 987 | */ |
| 988 | adj_list = list_new (); |
| 989 | adjdb = circuit->u.bc.adjdb[level - 1]; |
| 990 | isis_adj_build_up_list (adjdb, adj_list); |
| 991 | if (listcount (adj_list) == 0) |
| 992 | { |
| 993 | list_delete (adj_list); |
hasso | c89c05d | 2005-09-04 21:36:36 +0000 | [diff] [blame] | 994 | if (isis->debugs & DEBUG_SPF_EVENTS) |
| 995 | zlog_debug ("ISIS-Spf: no L%d adjacencies on circuit %s", |
| 996 | level, circuit->interface->name); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 997 | continue; |
| 998 | } |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 999 | for (ALL_LIST_ELEMENTS_RO (adj_list, anode, adj)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1000 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1001 | if (!speaks (&adj->nlpids, family)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1002 | continue; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1003 | switch (adj->sys_type) |
| 1004 | { |
| 1005 | case ISIS_SYSTYPE_ES: |
| 1006 | isis_spf_add_local (spftree, VTYPE_ES, adj->sysid, adj, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1007 | circuit->te_metric[level - 1], |
| 1008 | family, parent); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1009 | break; |
| 1010 | case ISIS_SYSTYPE_IS: |
| 1011 | case ISIS_SYSTYPE_L1_IS: |
| 1012 | case ISIS_SYSTYPE_L2_IS: |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1013 | isis_spf_add_local (spftree, |
| 1014 | spftree->area->oldmetric ? |
| 1015 | VTYPE_NONPSEUDO_IS : |
| 1016 | VTYPE_NONPSEUDO_TE_IS, |
| 1017 | adj->sysid, adj, |
| 1018 | circuit->te_metric[level - 1], |
| 1019 | family, parent); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1020 | memcpy (lsp_id, adj->sysid, ISIS_SYS_ID_LEN); |
| 1021 | LSP_PSEUDO_ID (lsp_id) = 0; |
| 1022 | LSP_FRAGMENT (lsp_id) = 0; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1023 | lsp = lsp_search (lsp_id, spftree->area->lspdb[level - 1]); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1024 | if (!lsp) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1025 | zlog_warn ("ISIS-Spf: No LSP %s found for IS adjacency " |
| 1026 | "L%d on %s (ID %u)", |
| 1027 | rawlspid_print (lsp_id), level, |
| 1028 | circuit->interface->name, circuit->circuit_id); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1029 | break; |
| 1030 | case ISIS_SYSTYPE_UNKNOWN: |
| 1031 | default: |
| 1032 | zlog_warn ("isis_spf_preload_tent unknow adj type"); |
| 1033 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1034 | } |
| 1035 | list_delete (adj_list); |
| 1036 | /* |
| 1037 | * Add the pseudonode |
| 1038 | */ |
| 1039 | if (level == 1) |
| 1040 | memcpy (lsp_id, circuit->u.bc.l1_desig_is, ISIS_SYS_ID_LEN + 1); |
| 1041 | else |
| 1042 | memcpy (lsp_id, circuit->u.bc.l2_desig_is, ISIS_SYS_ID_LEN + 1); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1043 | /* can happen during DR reboot */ |
| 1044 | if (memcmp (lsp_id, null_lsp_id, ISIS_SYS_ID_LEN + 1) == 0) |
| 1045 | { |
| 1046 | if (isis->debugs & DEBUG_SPF_EVENTS) |
| 1047 | zlog_debug ("ISIS-Spf: No L%d DR on %s (ID %d)", |
| 1048 | level, circuit->interface->name, circuit->circuit_id); |
| 1049 | continue; |
| 1050 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1051 | adj = isis_adj_lookup (lsp_id, adjdb); |
| 1052 | /* if no adj, we are the dis or error */ |
| 1053 | if (!adj && !circuit->u.bc.is_dr[level - 1]) |
| 1054 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1055 | zlog_warn ("ISIS-Spf: No adjacency found from root " |
| 1056 | "to L%d DR %s on %s (ID %d)", |
| 1057 | level, rawlspid_print (lsp_id), |
| 1058 | circuit->interface->name, circuit->circuit_id); |
| 1059 | continue; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1060 | } |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1061 | lsp = lsp_search (lsp_id, spftree->area->lspdb[level - 1]); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1062 | if (lsp == NULL || lsp->lsp_header->rem_lifetime == 0) |
| 1063 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1064 | zlog_warn ("ISIS-Spf: No lsp (%p) found from root " |
| 1065 | "to L%d DR %s on %s (ID %d)", |
| 1066 | lsp, level, rawlspid_print (lsp_id), |
| 1067 | circuit->interface->name, circuit->circuit_id); |
| 1068 | continue; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1069 | } |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1070 | isis_spf_process_pseudo_lsp (spftree, lsp, |
| 1071 | circuit->te_metric[level - 1], 0, |
| 1072 | family, root_sysid, parent); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1073 | } |
| 1074 | else if (circuit->circ_type == CIRCUIT_T_P2P) |
| 1075 | { |
| 1076 | adj = circuit->u.p2p.neighbor; |
| 1077 | if (!adj) |
| 1078 | continue; |
| 1079 | switch (adj->sys_type) |
| 1080 | { |
| 1081 | case ISIS_SYSTYPE_ES: |
| 1082 | isis_spf_add_local (spftree, VTYPE_ES, adj->sysid, adj, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1083 | circuit->te_metric[level - 1], family, |
| 1084 | parent); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1085 | break; |
| 1086 | case ISIS_SYSTYPE_IS: |
| 1087 | case ISIS_SYSTYPE_L1_IS: |
| 1088 | case ISIS_SYSTYPE_L2_IS: |
| 1089 | if (speaks (&adj->nlpids, family)) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1090 | isis_spf_add_local (spftree, |
| 1091 | spftree->area->oldmetric ? |
| 1092 | VTYPE_NONPSEUDO_IS : |
| 1093 | VTYPE_NONPSEUDO_TE_IS, |
| 1094 | adj->sysid, |
hasso | 82a8428 | 2005-09-26 18:15:36 +0000 | [diff] [blame] | 1095 | adj, circuit->te_metric[level - 1], |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1096 | family, parent); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1097 | break; |
| 1098 | case ISIS_SYSTYPE_UNKNOWN: |
| 1099 | default: |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1100 | zlog_warn ("isis_spf_preload_tent unknown adj type"); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1101 | break; |
| 1102 | } |
| 1103 | } |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1104 | else if (circuit->circ_type == CIRCUIT_T_LOOPBACK) |
| 1105 | { |
| 1106 | continue; |
| 1107 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1108 | else |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1109 | { |
| 1110 | zlog_warn ("isis_spf_preload_tent unsupported media"); |
| 1111 | retval = ISIS_WARNING; |
| 1112 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1113 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1114 | |
| 1115 | return retval; |
| 1116 | } |
| 1117 | |
| 1118 | /* |
| 1119 | * The parent(s) for vertex is set when added to TENT list |
| 1120 | * now we just put the child pointer(s) in place |
| 1121 | */ |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 1122 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1123 | add_to_paths (struct isis_spftree *spftree, struct isis_vertex *vertex, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1124 | int level) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1125 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1126 | u_char buff[BUFSIZ]; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1127 | |
| 1128 | if (isis_find_vertex (spftree->paths, vertex->N.id, vertex->type)) |
| 1129 | return; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1130 | listnode_add (spftree->paths, vertex); |
| 1131 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1132 | #ifdef EXTREME_DEBUG |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1133 | zlog_debug ("ISIS-Spf: added %s %s %s depth %d dist %d to PATHS", |
| 1134 | print_sys_hostname (vertex->N.id), |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 1135 | vtype2string (vertex->type), vid2string (vertex, buff), |
| 1136 | vertex->depth, vertex->d_N); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1137 | #endif /* EXTREME_DEBUG */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1138 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1139 | if (vertex->type > VTYPE_ES) |
| 1140 | { |
| 1141 | if (listcount (vertex->Adj_N) > 0) |
hasso | fac1f7c | 2005-09-26 18:26:26 +0000 | [diff] [blame] | 1142 | isis_route_create ((struct prefix *) &vertex->N.prefix, vertex->d_N, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1143 | vertex->depth, vertex->Adj_N, spftree->area, level); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1144 | else if (isis->debugs & DEBUG_SPF_EVENTS) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1145 | zlog_debug ("ISIS-Spf: no adjacencies do not install route for " |
| 1146 | "%s depth %d dist %d", vid2string (vertex, buff), |
| 1147 | vertex->depth, vertex->d_N); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1148 | } |
| 1149 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1150 | return; |
| 1151 | } |
| 1152 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 1153 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1154 | init_spt (struct isis_spftree *spftree) |
| 1155 | { |
hasso | f7c43dc | 2004-09-26 16:24:14 +0000 | [diff] [blame] | 1156 | spftree->tents->del = spftree->paths->del = (void (*)(void *)) isis_vertex_del; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1157 | list_delete_all_node (spftree->tents); |
| 1158 | list_delete_all_node (spftree->paths); |
| 1159 | spftree->tents->del = spftree->paths->del = NULL; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1160 | return; |
| 1161 | } |
| 1162 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 1163 | static int |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1164 | isis_run_spf (struct isis_area *area, int level, int family, u_char *sysid) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1165 | { |
| 1166 | int retval = ISIS_OK; |
| 1167 | struct listnode *node; |
| 1168 | struct isis_vertex *vertex; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1169 | struct isis_vertex *root_vertex; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1170 | struct isis_spftree *spftree = NULL; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1171 | u_char lsp_id[ISIS_SYS_ID_LEN + 2]; |
| 1172 | struct isis_lsp *lsp; |
hasso | fac1f7c | 2005-09-26 18:26:26 +0000 | [diff] [blame] | 1173 | struct route_table *table = NULL; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1174 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1175 | if (family == AF_INET) |
| 1176 | spftree = area->spftree[level - 1]; |
| 1177 | #ifdef HAVE_IPV6 |
| 1178 | else if (family == AF_INET6) |
| 1179 | spftree = area->spftree6[level - 1]; |
| 1180 | #endif |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1181 | assert (spftree); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1182 | assert (sysid); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1183 | |
hasso | fac1f7c | 2005-09-26 18:26:26 +0000 | [diff] [blame] | 1184 | /* Make all routes in current route table inactive. */ |
| 1185 | if (family == AF_INET) |
| 1186 | table = area->route_table[level - 1]; |
Paul Jakma | 41b36e9 | 2006-12-08 01:09:50 +0000 | [diff] [blame] | 1187 | #ifdef HAVE_IPV6 |
hasso | fac1f7c | 2005-09-26 18:26:26 +0000 | [diff] [blame] | 1188 | else if (family == AF_INET6) |
| 1189 | table = area->route_table6[level - 1]; |
Paul Jakma | 41b36e9 | 2006-12-08 01:09:50 +0000 | [diff] [blame] | 1190 | #endif |
hasso | fac1f7c | 2005-09-26 18:26:26 +0000 | [diff] [blame] | 1191 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1192 | isis_route_invalidate_table (area, table); |
hasso | fac1f7c | 2005-09-26 18:26:26 +0000 | [diff] [blame] | 1193 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1194 | /* |
| 1195 | * C.2.5 Step 0 |
| 1196 | */ |
| 1197 | init_spt (spftree); |
| 1198 | /* a) */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1199 | root_vertex = isis_spf_add_root (spftree, level, sysid); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1200 | /* b) */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1201 | retval = isis_spf_preload_tent (spftree, level, family, sysid, root_vertex); |
| 1202 | if (retval != ISIS_OK) |
| 1203 | { |
| 1204 | zlog_warn ("ISIS-Spf: failed to load TENT SPF-root:%s", print_sys_hostname(sysid)); |
| 1205 | goto out; |
| 1206 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1207 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1208 | /* |
| 1209 | * C.2.7 Step 2 |
| 1210 | */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1211 | if (listcount (spftree->tents) == 0) |
| 1212 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1213 | zlog_warn ("ISIS-Spf: TENT is empty SPF-root:%s", print_sys_hostname(sysid)); |
hasso | 13fb40a | 2005-10-01 06:03:04 +0000 | [diff] [blame] | 1214 | goto out; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1215 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1216 | |
| 1217 | while (listcount (spftree->tents) > 0) |
| 1218 | { |
| 1219 | node = listhead (spftree->tents); |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1220 | vertex = listgetdata (node); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1221 | |
| 1222 | #ifdef EXTREME_DEBUG |
| 1223 | zlog_debug ("ISIS-Spf: get TENT node %s %s depth %d dist %d to PATHS", |
| 1224 | print_sys_hostname (vertex->N.id), |
| 1225 | vtype2string (vertex->type), vertex->depth, vertex->d_N); |
| 1226 | #endif /* EXTREME_DEBUG */ |
| 1227 | |
| 1228 | /* Remove from tent list and add to paths list */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1229 | list_delete_node (spftree->tents, node); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1230 | add_to_paths (spftree, vertex, level); |
| 1231 | switch (vertex->type) |
| 1232 | { |
| 1233 | case VTYPE_PSEUDO_IS: |
| 1234 | case VTYPE_NONPSEUDO_IS: |
| 1235 | case VTYPE_PSEUDO_TE_IS: |
| 1236 | case VTYPE_NONPSEUDO_TE_IS: |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1237 | memcpy (lsp_id, vertex->N.id, ISIS_SYS_ID_LEN + 1); |
| 1238 | LSP_FRAGMENT (lsp_id) = 0; |
| 1239 | lsp = lsp_search (lsp_id, area->lspdb[level - 1]); |
| 1240 | if (lsp) |
| 1241 | { |
| 1242 | if (LSP_PSEUDO_ID (lsp_id)) |
| 1243 | { |
| 1244 | isis_spf_process_pseudo_lsp (spftree, lsp, vertex->d_N, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1245 | vertex->depth, family, sysid, |
| 1246 | vertex); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1247 | } |
| 1248 | else |
| 1249 | { |
| 1250 | isis_spf_process_lsp (spftree, lsp, vertex->d_N, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1251 | vertex->depth, family, sysid, vertex); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1252 | } |
| 1253 | } |
| 1254 | else |
| 1255 | { |
| 1256 | zlog_warn ("ISIS-Spf: No LSP found for %s", |
| 1257 | rawlspid_print (lsp_id)); |
| 1258 | } |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1259 | break; |
| 1260 | default:; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1261 | } |
| 1262 | } |
| 1263 | |
hasso | 13fb40a | 2005-10-01 06:03:04 +0000 | [diff] [blame] | 1264 | out: |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1265 | isis_route_validate (area); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1266 | spftree->lastrun = time (NULL); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1267 | spftree->runcount++; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1268 | spftree->pending = 0; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1269 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1270 | return retval; |
| 1271 | } |
| 1272 | |
| 1273 | int |
| 1274 | isis_run_spf_l1 (struct thread *thread) |
| 1275 | { |
| 1276 | struct isis_area *area; |
| 1277 | int retval = ISIS_OK; |
| 1278 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1279 | area = THREAD_ARG (thread); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1280 | assert (area); |
| 1281 | |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1282 | area->spftree[0]->t_spf = NULL; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1283 | area->spftree[0]->pending = 0; |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1284 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1285 | if (!(area->is_type & IS_LEVEL_1)) |
| 1286 | { |
| 1287 | if (isis->debugs & DEBUG_SPF_EVENTS) |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1288 | zlog_warn ("ISIS-SPF (%s) area does not share level", |
| 1289 | area->area_tag); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1290 | return ISIS_WARNING; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1291 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1292 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1293 | if (isis->debugs & DEBUG_SPF_EVENTS) |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 1294 | zlog_debug ("ISIS-Spf (%s) L1 SPF needed, periodic SPF", area->area_tag); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1295 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1296 | if (area->ip_circuits) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1297 | retval = isis_run_spf (area, 1, AF_INET, isis->sysid); |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1298 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1299 | return retval; |
| 1300 | } |
| 1301 | |
| 1302 | int |
| 1303 | isis_run_spf_l2 (struct thread *thread) |
| 1304 | { |
| 1305 | struct isis_area *area; |
| 1306 | int retval = ISIS_OK; |
| 1307 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1308 | area = THREAD_ARG (thread); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1309 | assert (area); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1310 | |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1311 | area->spftree[1]->t_spf = NULL; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1312 | area->spftree[1]->pending = 0; |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1313 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1314 | if (!(area->is_type & IS_LEVEL_2)) |
| 1315 | { |
| 1316 | if (isis->debugs & DEBUG_SPF_EVENTS) |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1317 | zlog_warn ("ISIS-SPF (%s) area does not share level", area->area_tag); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1318 | return ISIS_WARNING; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1319 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1320 | |
| 1321 | if (isis->debugs & DEBUG_SPF_EVENTS) |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 1322 | zlog_debug ("ISIS-Spf (%s) L2 SPF needed, periodic SPF", area->area_tag); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1323 | |
| 1324 | if (area->ip_circuits) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1325 | retval = isis_run_spf (area, 2, AF_INET, isis->sysid); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1326 | |
| 1327 | return retval; |
| 1328 | } |
| 1329 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1330 | int |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1331 | isis_spf_schedule (struct isis_area *area, int level) |
| 1332 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1333 | struct isis_spftree *spftree = area->spftree[level - 1]; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1334 | time_t now = time (NULL); |
| 1335 | int diff = now - spftree->lastrun; |
| 1336 | |
| 1337 | assert (diff >= 0); |
| 1338 | assert (area->is_type & level); |
| 1339 | |
| 1340 | if (isis->debugs & DEBUG_SPF_EVENTS) |
| 1341 | zlog_debug ("ISIS-Spf (%s) L%d SPF schedule called, lastrun %d sec ago", |
| 1342 | area->area_tag, level, diff); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1343 | |
| 1344 | if (spftree->pending) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1345 | return ISIS_OK; |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1346 | |
| 1347 | THREAD_TIMER_OFF (spftree->t_spf); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1348 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1349 | /* wait MINIMUM_SPF_INTERVAL before doing the SPF */ |
| 1350 | if (diff >= MINIMUM_SPF_INTERVAL) |
| 1351 | return isis_run_spf (area, level, AF_INET, isis->sysid); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1352 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1353 | if (level == 1) |
| 1354 | THREAD_TIMER_ON (master, spftree->t_spf, isis_run_spf_l1, area, |
| 1355 | MINIMUM_SPF_INTERVAL - diff); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1356 | else |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1357 | THREAD_TIMER_ON (master, spftree->t_spf, isis_run_spf_l2, area, |
| 1358 | MINIMUM_SPF_INTERVAL - diff); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1359 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1360 | if (isis->debugs & DEBUG_SPF_EVENTS) |
| 1361 | zlog_debug ("ISIS-Spf (%s) L%d SPF scheduled %d sec from now", |
| 1362 | area->area_tag, level, MINIMUM_SPF_INTERVAL - diff); |
| 1363 | |
| 1364 | spftree->pending = 1; |
| 1365 | |
| 1366 | return ISIS_OK; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1367 | } |
| 1368 | |
| 1369 | #ifdef HAVE_IPV6 |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 1370 | static int |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1371 | isis_run_spf6_l1 (struct thread *thread) |
| 1372 | { |
| 1373 | struct isis_area *area; |
| 1374 | int retval = ISIS_OK; |
| 1375 | |
| 1376 | area = THREAD_ARG (thread); |
| 1377 | assert (area); |
| 1378 | |
| 1379 | area->spftree6[0]->t_spf = NULL; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1380 | area->spftree6[0]->pending = 0; |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1381 | |
| 1382 | if (!(area->is_type & IS_LEVEL_1)) |
| 1383 | { |
| 1384 | if (isis->debugs & DEBUG_SPF_EVENTS) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1385 | zlog_warn ("ISIS-SPF (%s) area does not share level", area->area_tag); |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1386 | return ISIS_WARNING; |
| 1387 | } |
| 1388 | |
| 1389 | if (isis->debugs & DEBUG_SPF_EVENTS) |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 1390 | zlog_debug ("ISIS-Spf (%s) L1 SPF needed, periodic SPF", area->area_tag); |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1391 | |
| 1392 | if (area->ipv6_circuits) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1393 | retval = isis_run_spf (area, 1, AF_INET6, isis->sysid); |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1394 | |
| 1395 | return retval; |
| 1396 | } |
| 1397 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 1398 | static int |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1399 | isis_run_spf6_l2 (struct thread *thread) |
| 1400 | { |
| 1401 | struct isis_area *area; |
| 1402 | int retval = ISIS_OK; |
| 1403 | |
| 1404 | area = THREAD_ARG (thread); |
| 1405 | assert (area); |
| 1406 | |
| 1407 | area->spftree6[1]->t_spf = NULL; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1408 | area->spftree6[1]->pending = 0; |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1409 | |
| 1410 | if (!(area->is_type & IS_LEVEL_2)) |
| 1411 | { |
| 1412 | if (isis->debugs & DEBUG_SPF_EVENTS) |
| 1413 | zlog_warn ("ISIS-SPF (%s) area does not share level", area->area_tag); |
| 1414 | return ISIS_WARNING; |
| 1415 | } |
| 1416 | |
| 1417 | if (isis->debugs & DEBUG_SPF_EVENTS) |
hasso | fac1f7c | 2005-09-26 18:26:26 +0000 | [diff] [blame] | 1418 | zlog_debug ("ISIS-Spf (%s) L2 SPF needed, periodic SPF.", area->area_tag); |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1419 | |
| 1420 | if (area->ipv6_circuits) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1421 | retval = isis_run_spf (area, 2, AF_INET6, isis->sysid); |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1422 | |
| 1423 | return retval; |
| 1424 | } |
| 1425 | |
| 1426 | int |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1427 | isis_spf_schedule6 (struct isis_area *area, int level) |
| 1428 | { |
| 1429 | int retval = ISIS_OK; |
| 1430 | struct isis_spftree *spftree = area->spftree6[level - 1]; |
| 1431 | time_t diff, now = time (NULL); |
| 1432 | |
| 1433 | if (spftree->pending) |
| 1434 | return retval; |
| 1435 | |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1436 | THREAD_TIMER_OFF (spftree->t_spf); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1437 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1438 | /* FIXME: let's wait MINIMUM_SPF_INTERVAL before doing the SPF */ |
| 1439 | if (now - isis->uptime < MINIMUM_SPF_INTERVAL || isis->uptime == 0) |
| 1440 | diff = 0; |
| 1441 | else |
| 1442 | diff = now - spftree->lastrun; |
| 1443 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1444 | if (diff < MINIMUM_SPF_INTERVAL) |
| 1445 | { |
| 1446 | if (level == 1) |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1447 | THREAD_TIMER_ON (master, spftree->t_spf, isis_run_spf6_l1, area, |
| 1448 | MINIMUM_SPF_INTERVAL - diff); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1449 | else |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1450 | THREAD_TIMER_ON (master, spftree->t_spf, isis_run_spf6_l2, area, |
| 1451 | MINIMUM_SPF_INTERVAL - diff); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1452 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1453 | spftree->pending = 1; |
| 1454 | } |
| 1455 | else |
| 1456 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1457 | retval = isis_run_spf (area, level, AF_INET6, isis->sysid); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1458 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1459 | |
| 1460 | return retval; |
| 1461 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1462 | #endif |
| 1463 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 1464 | static void |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1465 | isis_print_paths (struct vty *vty, struct list *paths, u_char *root_sysid) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1466 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1467 | struct listnode *node; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1468 | struct listnode *anode; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1469 | struct isis_vertex *vertex; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1470 | struct isis_adjacency *adj; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1471 | u_char buff[255]; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1472 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1473 | vty_out (vty, "Vertex Type Metric " |
| 1474 | "Next-Hop Interface Parent%s", VTY_NEWLINE); |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1475 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1476 | for (ALL_LIST_ELEMENTS_RO (paths, node, vertex)) { |
| 1477 | if (memcmp (vertex->N.id, root_sysid, ISIS_SYS_ID_LEN) == 0) { |
| 1478 | vty_out (vty, "%-20s %-12s %-6s", print_sys_hostname (root_sysid), |
| 1479 | "", ""); |
| 1480 | vty_out (vty, "%-30s", ""); |
| 1481 | } else { |
| 1482 | int rows = 0; |
| 1483 | vty_out (vty, "%-20s %-12s %-6u ", vid2string (vertex, buff), |
| 1484 | vtype2string (vertex->type), vertex->d_N); |
| 1485 | for (ALL_LIST_ELEMENTS_RO (vertex->Adj_N, anode, adj)) { |
| 1486 | if (adj) { |
| 1487 | if (rows) { |
| 1488 | vty_out (vty, "%s", VTY_NEWLINE); |
| 1489 | vty_out (vty, "%-20s %-12s %-6s ", "", "", ""); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1490 | } |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1491 | vty_out (vty, "%-20s %-9s ", |
| 1492 | print_sys_hostname (adj->sysid), |
| 1493 | adj->circuit->interface->name); |
| 1494 | ++rows; |
| 1495 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1496 | } |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1497 | if (rows == 0) |
| 1498 | vty_out (vty, "%-30s ", ""); |
| 1499 | } |
| 1500 | |
| 1501 | /* Print list of parents for the ECMP DAG */ |
| 1502 | if (listcount (vertex->parents) > 0) { |
| 1503 | struct listnode *pnode; |
| 1504 | struct isis_vertex *pvertex; |
| 1505 | int rows = 0; |
| 1506 | for (ALL_LIST_ELEMENTS_RO (vertex->parents, pnode, pvertex)) { |
| 1507 | if (rows) { |
| 1508 | vty_out (vty, "%s", VTY_NEWLINE); |
| 1509 | vty_out (vty, "%-72s", ""); |
| 1510 | } |
| 1511 | vty_out (vty, "%s(%d)", |
| 1512 | vid2string (pvertex, buff), pvertex->type); |
| 1513 | ++rows; |
| 1514 | } |
| 1515 | } else { |
| 1516 | vty_out (vty, " NULL "); |
| 1517 | } |
| 1518 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1519 | #if 0 |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1520 | if (listcount (vertex->children) > 0) { |
| 1521 | struct listnode *cnode; |
| 1522 | struct isis_vertex *cvertex; |
| 1523 | for (ALL_LIST_ELEMENTS_RO (vertex->children, cnode, cvertex)) { |
| 1524 | vty_out (vty, "%s", VTY_NEWLINE); |
| 1525 | vty_out (vty, "%-72s", ""); |
| 1526 | vty_out (vty, "%s(%d) ", |
| 1527 | vid2string (cvertex, buff), cvertex->type); |
| 1528 | } |
| 1529 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1530 | #endif |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1531 | vty_out (vty, "%s", VTY_NEWLINE); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1532 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1533 | } |
| 1534 | |
| 1535 | DEFUN (show_isis_topology, |
| 1536 | show_isis_topology_cmd, |
| 1537 | "show isis topology", |
| 1538 | SHOW_STR |
| 1539 | "IS-IS information\n" |
| 1540 | "IS-IS paths to Intermediate Systems\n") |
| 1541 | { |
| 1542 | struct listnode *node; |
| 1543 | struct isis_area *area; |
| 1544 | int level; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1545 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1546 | if (!isis->area_list || isis->area_list->count == 0) |
| 1547 | return CMD_SUCCESS; |
| 1548 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1549 | for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1550 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1551 | vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null", |
| 1552 | VTY_NEWLINE); |
| 1553 | |
| 1554 | for (level = 0; level < ISIS_LEVELS; level++) |
| 1555 | { |
| 1556 | if (area->ip_circuits > 0 && area->spftree[level] |
| 1557 | && area->spftree[level]->paths->count > 0) |
| 1558 | { |
| 1559 | vty_out (vty, "IS-IS paths to level-%d routers that speak IP%s", |
| 1560 | level + 1, VTY_NEWLINE); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1561 | isis_print_paths (vty, area->spftree[level]->paths, isis->sysid); |
| 1562 | vty_out (vty, "%s", VTY_NEWLINE); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1563 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1564 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1565 | if (area->ipv6_circuits > 0 && area->spftree6[level] |
| 1566 | && area->spftree6[level]->paths->count > 0) |
| 1567 | { |
| 1568 | vty_out (vty, |
| 1569 | "IS-IS paths to level-%d routers that speak IPv6%s", |
| 1570 | level + 1, VTY_NEWLINE); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1571 | isis_print_paths (vty, area->spftree6[level]->paths, isis->sysid); |
| 1572 | vty_out (vty, "%s", VTY_NEWLINE); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1573 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1574 | #endif /* HAVE_IPV6 */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1575 | } |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1576 | |
| 1577 | vty_out (vty, "%s", VTY_NEWLINE); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1578 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1579 | |
| 1580 | return CMD_SUCCESS; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1581 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1582 | |
| 1583 | DEFUN (show_isis_topology_l1, |
| 1584 | show_isis_topology_l1_cmd, |
| 1585 | "show isis topology level-1", |
| 1586 | SHOW_STR |
| 1587 | "IS-IS information\n" |
| 1588 | "IS-IS paths to Intermediate Systems\n" |
| 1589 | "Paths to all level-1 routers in the area\n") |
| 1590 | { |
| 1591 | struct listnode *node; |
| 1592 | struct isis_area *area; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1593 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1594 | if (!isis->area_list || isis->area_list->count == 0) |
| 1595 | return CMD_SUCCESS; |
| 1596 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1597 | for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1598 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1599 | vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null", |
| 1600 | VTY_NEWLINE); |
| 1601 | |
| 1602 | if (area->ip_circuits > 0 && area->spftree[0] |
| 1603 | && area->spftree[0]->paths->count > 0) |
| 1604 | { |
| 1605 | vty_out (vty, "IS-IS paths to level-1 routers that speak IP%s", |
| 1606 | VTY_NEWLINE); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1607 | isis_print_paths (vty, area->spftree[0]->paths, isis->sysid); |
| 1608 | vty_out (vty, "%s", VTY_NEWLINE); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1609 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1610 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1611 | if (area->ipv6_circuits > 0 && area->spftree6[0] |
| 1612 | && area->spftree6[0]->paths->count > 0) |
| 1613 | { |
| 1614 | vty_out (vty, "IS-IS paths to level-1 routers that speak IPv6%s", |
| 1615 | VTY_NEWLINE); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1616 | isis_print_paths (vty, area->spftree6[0]->paths, isis->sysid); |
| 1617 | vty_out (vty, "%s", VTY_NEWLINE); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1618 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1619 | #endif /* HAVE_IPV6 */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1620 | vty_out (vty, "%s", VTY_NEWLINE); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1621 | } |
| 1622 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1623 | return CMD_SUCCESS; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1624 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1625 | |
| 1626 | DEFUN (show_isis_topology_l2, |
| 1627 | show_isis_topology_l2_cmd, |
| 1628 | "show isis topology level-2", |
| 1629 | SHOW_STR |
| 1630 | "IS-IS information\n" |
| 1631 | "IS-IS paths to Intermediate Systems\n" |
| 1632 | "Paths to all level-2 routers in the domain\n") |
| 1633 | { |
| 1634 | struct listnode *node; |
| 1635 | struct isis_area *area; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1636 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1637 | if (!isis->area_list || isis->area_list->count == 0) |
| 1638 | return CMD_SUCCESS; |
| 1639 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1640 | for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1641 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1642 | vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null", |
| 1643 | VTY_NEWLINE); |
| 1644 | |
| 1645 | if (area->ip_circuits > 0 && area->spftree[1] |
| 1646 | && area->spftree[1]->paths->count > 0) |
| 1647 | { |
| 1648 | vty_out (vty, "IS-IS paths to level-2 routers that speak IP%s", |
| 1649 | VTY_NEWLINE); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1650 | isis_print_paths (vty, area->spftree[1]->paths, isis->sysid); |
| 1651 | vty_out (vty, "%s", VTY_NEWLINE); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1652 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1653 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1654 | if (area->ipv6_circuits > 0 && area->spftree6[1] |
| 1655 | && area->spftree6[1]->paths->count > 0) |
| 1656 | { |
| 1657 | vty_out (vty, "IS-IS paths to level-2 routers that speak IPv6%s", |
| 1658 | VTY_NEWLINE); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1659 | isis_print_paths (vty, area->spftree6[1]->paths, isis->sysid); |
| 1660 | vty_out (vty, "%s", VTY_NEWLINE); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1661 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1662 | #endif /* HAVE_IPV6 */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 1663 | vty_out (vty, "%s", VTY_NEWLINE); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1664 | } |
| 1665 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1666 | return CMD_SUCCESS; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1667 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1668 | |
| 1669 | void |
| 1670 | isis_spf_cmds_init () |
| 1671 | { |
| 1672 | install_element (VIEW_NODE, &show_isis_topology_cmd); |
| 1673 | install_element (VIEW_NODE, &show_isis_topology_l1_cmd); |
| 1674 | install_element (VIEW_NODE, &show_isis_topology_l2_cmd); |
| 1675 | |
| 1676 | install_element (ENABLE_NODE, &show_isis_topology_cmd); |
| 1677 | install_element (ENABLE_NODE, &show_isis_topology_l1_cmd); |
| 1678 | install_element (ENABLE_NODE, &show_isis_topology_l2_cmd); |
| 1679 | } |