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 | |
| 24 | #include <stdlib.h> |
| 25 | #include <stdio.h> |
| 26 | #include <zebra.h> |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 27 | |
| 28 | #include "thread.h" |
| 29 | #include "linklist.h" |
| 30 | #include "vty.h" |
| 31 | #include "log.h" |
| 32 | #include "command.h" |
| 33 | #include "memory.h" |
| 34 | #include "prefix.h" |
| 35 | #include "hash.h" |
| 36 | #include "if.h" |
| 37 | #include "table.h" |
| 38 | |
| 39 | #include "isis_constants.h" |
| 40 | #include "isis_common.h" |
| 41 | #include "dict.h" |
| 42 | #include "isisd.h" |
| 43 | #include "isis_misc.h" |
| 44 | #include "isis_adjacency.h" |
| 45 | #include "isis_circuit.h" |
| 46 | #include "isis_tlv.h" |
| 47 | #include "isis_pdu.h" |
| 48 | #include "isis_lsp.h" |
| 49 | #include "isis_dynhn.h" |
| 50 | #include "isis_spf.h" |
| 51 | #include "isis_route.h" |
| 52 | #include "isis_csm.h" |
| 53 | |
| 54 | extern struct isis *isis; |
| 55 | extern struct thread_master *master; |
| 56 | extern struct host host; |
| 57 | |
| 58 | int isis_run_spf_l1 (struct thread *thread); |
| 59 | int isis_run_spf_l2 (struct thread *thread); |
| 60 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 61 | #if 0 |
| 62 | /* performace issue ???? HT: Old or new code? */ |
| 63 | static void |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 64 | union_adjlist (struct list *target, struct list *source) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 65 | { |
| 66 | struct isis_adjacency *adj, *adj2; |
| 67 | struct listnode *node, *node2; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 68 | |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 69 | zlog_debug ("Union adjlist!"); |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 70 | for (ALL_LIST_ELEMENTS_RO (source, node, adj)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 71 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 72 | /* lookup adjacency in the source list */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 73 | for (ALL_LIST_ELEMENTS_RO (target, node2, adj2)) |
| 74 | if (adj == adj2) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 75 | break; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 76 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 77 | if (!node2) |
| 78 | listnode_add (target, adj); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 79 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 80 | } |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 81 | #endif |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 82 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 83 | /* 7.2.7 */ |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 84 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 85 | remove_excess_adjs (struct list *adjs) |
| 86 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 87 | struct listnode *node, *nnode, *excess = NULL; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 88 | struct isis_adjacency *adj, *candidate = NULL; |
| 89 | int comp; |
| 90 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 91 | for (ALL_LIST_ELEMENTS (adjs, node, nnode, adj)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 92 | { |
| 93 | if (excess == NULL) |
| 94 | excess = node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 95 | candidate = listgetdata (excess); |
| 96 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 97 | if (candidate->sys_type < adj->sys_type) |
| 98 | { |
| 99 | excess = node; |
| 100 | candidate = adj; |
| 101 | continue; |
| 102 | } |
| 103 | if (candidate->sys_type > adj->sys_type) |
| 104 | continue; |
| 105 | |
| 106 | comp = memcmp (candidate->sysid, adj->sysid, ISIS_SYS_ID_LEN); |
| 107 | if (comp > 0) |
| 108 | { |
| 109 | excess = node; |
| 110 | candidate = adj; |
| 111 | continue; |
| 112 | } |
| 113 | if (comp < 0) |
| 114 | continue; |
| 115 | |
| 116 | if (candidate->circuit->circuit_id > adj->circuit->circuit_id) |
| 117 | { |
| 118 | excess = node; |
| 119 | candidate = adj; |
| 120 | continue; |
| 121 | } |
| 122 | |
| 123 | if (candidate->circuit->circuit_id < adj->circuit->circuit_id) |
| 124 | continue; |
| 125 | |
| 126 | comp = memcmp (candidate->snpa, adj->snpa, ETH_ALEN); |
| 127 | if (comp > 0) |
| 128 | { |
| 129 | excess = node; |
| 130 | candidate = adj; |
| 131 | continue; |
| 132 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 133 | } |
| 134 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 135 | list_delete_node (adjs, excess); |
| 136 | |
| 137 | return; |
| 138 | } |
| 139 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 140 | #ifdef EXTREME_DEBUG |
| 141 | static const char * |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 142 | vtype2string (enum vertextype vtype) |
| 143 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 144 | switch (vtype) |
| 145 | { |
| 146 | case VTYPE_PSEUDO_IS: |
| 147 | return "pseudo_IS"; |
| 148 | break; |
| 149 | case VTYPE_NONPSEUDO_IS: |
| 150 | return "IS"; |
| 151 | break; |
| 152 | case VTYPE_ES: |
| 153 | return "ES"; |
| 154 | break; |
| 155 | case VTYPE_IPREACH_INTERNAL: |
| 156 | return "IP internal"; |
| 157 | break; |
| 158 | case VTYPE_IPREACH_EXTERNAL: |
| 159 | return "IP external"; |
| 160 | break; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 161 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 162 | case VTYPE_IP6REACH_INTERNAL: |
| 163 | return "IP6 internal"; |
| 164 | break; |
| 165 | case VTYPE_IP6REACH_EXTERNAL: |
| 166 | return "IP6 external"; |
| 167 | break; |
| 168 | #endif /* HAVE_IPV6 */ |
| 169 | default: |
| 170 | return "UNKNOWN"; |
| 171 | } |
| 172 | return NULL; /* Not reached */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 173 | } |
| 174 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 175 | static const char * |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 176 | vid2string (struct isis_vertex *vertex, u_char * buff) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 177 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 178 | switch (vertex->type) |
| 179 | { |
| 180 | case VTYPE_PSEUDO_IS: |
| 181 | return rawlspid_print (vertex->N.id); |
| 182 | break; |
| 183 | case VTYPE_NONPSEUDO_IS: |
| 184 | case VTYPE_ES: |
| 185 | return sysid_print (vertex->N.id); |
| 186 | break; |
| 187 | case VTYPE_IPREACH_INTERNAL: |
| 188 | case VTYPE_IPREACH_EXTERNAL: |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 189 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 190 | case VTYPE_IP6REACH_INTERNAL: |
| 191 | case VTYPE_IP6REACH_EXTERNAL: |
| 192 | #endif /* HAVE_IPV6 */ |
hasso | f7c43dc | 2004-09-26 16:24:14 +0000 | [diff] [blame] | 193 | prefix2str ((struct prefix *) &vertex->N.prefix, (char *) buff, BUFSIZ); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 194 | break; |
| 195 | default: |
| 196 | return "UNKNOWN"; |
| 197 | } |
| 198 | |
hasso | f7c43dc | 2004-09-26 16:24:14 +0000 | [diff] [blame] | 199 | return (char *) buff; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 200 | } |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 201 | #endif /* EXTREME_DEBUG */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 202 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 203 | static struct isis_spftree * |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 204 | isis_spftree_new () |
| 205 | { |
| 206 | struct isis_spftree *tree; |
| 207 | |
| 208 | tree = XMALLOC (MTYPE_ISIS_SPFTREE, sizeof (struct isis_spftree)); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 209 | if (tree == NULL) |
| 210 | { |
| 211 | zlog_err ("ISIS-Spf: isis_spftree_new Out of memory!"); |
| 212 | return NULL; |
| 213 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 214 | memset (tree, 0, sizeof (struct isis_spftree)); |
| 215 | |
| 216 | tree->tents = list_new (); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 217 | tree->paths = list_new (); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 218 | return tree; |
| 219 | } |
| 220 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 221 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 222 | isis_vertex_del (struct isis_vertex *vertex) |
| 223 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 224 | list_delete (vertex->Adj_N); |
| 225 | |
| 226 | XFREE (MTYPE_ISIS_VERTEX, vertex); |
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; |
| 229 | } |
| 230 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 231 | #if 0 /* HT: Not used yet. */ |
| 232 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 233 | isis_spftree_del (struct isis_spftree *spftree) |
| 234 | { |
hasso | f7c43dc | 2004-09-26 16:24:14 +0000 | [diff] [blame] | 235 | spftree->tents->del = (void (*)(void *)) isis_vertex_del; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 236 | list_delete (spftree->tents); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 237 | |
hasso | f7c43dc | 2004-09-26 16:24:14 +0000 | [diff] [blame] | 238 | spftree->paths->del = (void (*)(void *)) isis_vertex_del; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 239 | list_delete (spftree->paths); |
| 240 | |
| 241 | XFREE (MTYPE_ISIS_SPFTREE, spftree); |
| 242 | |
| 243 | return; |
| 244 | } |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 245 | #endif |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 246 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 247 | void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 248 | spftree_area_init (struct isis_area *area) |
| 249 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 250 | if ((area->is_type & IS_LEVEL_1) && area->spftree[0] == NULL) |
| 251 | { |
| 252 | area->spftree[0] = isis_spftree_new (); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 253 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 254 | area->spftree6[0] = isis_spftree_new (); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 255 | #endif |
| 256 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 257 | /* thread_add_timer (master, isis_run_spf_l1, area, |
| 258 | isis_jitter (PERIODIC_SPF_INTERVAL, 10)); */ |
| 259 | } |
| 260 | |
| 261 | if ((area->is_type & IS_LEVEL_2) && area->spftree[1] == NULL) |
| 262 | { |
| 263 | area->spftree[1] = isis_spftree_new (); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 264 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 265 | area->spftree6[1] = isis_spftree_new (); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 266 | #endif |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 267 | /* thread_add_timer (master, isis_run_spf_l2, area, |
| 268 | isis_jitter (PERIODIC_SPF_INTERVAL, 10)); */ |
| 269 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 270 | |
| 271 | return; |
| 272 | } |
| 273 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 274 | static struct isis_vertex * |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 275 | isis_vertex_new (void *id, enum vertextype vtype) |
| 276 | { |
| 277 | struct isis_vertex *vertex; |
| 278 | |
| 279 | vertex = XMALLOC (MTYPE_ISIS_VERTEX, sizeof (struct isis_vertex)); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 280 | if (vertex == NULL) |
| 281 | { |
| 282 | zlog_err ("isis_vertex_new Out of memory!"); |
| 283 | return NULL; |
| 284 | } |
| 285 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 286 | memset (vertex, 0, sizeof (struct isis_vertex)); |
| 287 | vertex->type = vtype; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 288 | switch (vtype) |
| 289 | { |
| 290 | case VTYPE_ES: |
| 291 | case VTYPE_NONPSEUDO_IS: |
| 292 | memcpy (vertex->N.id, (u_char *) id, ISIS_SYS_ID_LEN); |
| 293 | break; |
| 294 | case VTYPE_PSEUDO_IS: |
| 295 | memcpy (vertex->N.id, (u_char *) id, ISIS_SYS_ID_LEN + 1); |
| 296 | break; |
| 297 | case VTYPE_IPREACH_INTERNAL: |
| 298 | case VTYPE_IPREACH_EXTERNAL: |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 299 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 300 | case VTYPE_IP6REACH_INTERNAL: |
| 301 | case VTYPE_IP6REACH_EXTERNAL: |
| 302 | #endif /* HAVE_IPV6 */ |
| 303 | memcpy (&vertex->N.prefix, (struct prefix *) id, |
| 304 | sizeof (struct prefix)); |
| 305 | break; |
| 306 | default: |
| 307 | zlog_err ("WTF!"); |
| 308 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 309 | |
| 310 | vertex->Adj_N = list_new (); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 311 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 312 | return vertex; |
| 313 | } |
| 314 | |
| 315 | /* |
| 316 | * Add this IS to the root of SPT |
| 317 | */ |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 318 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 319 | isis_spf_add_self (struct isis_spftree *spftree, struct isis_area *area, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 320 | int level) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 321 | { |
| 322 | struct isis_vertex *vertex; |
| 323 | struct isis_lsp *lsp; |
| 324 | u_char lspid[ISIS_SYS_ID_LEN + 2]; |
| 325 | #ifdef EXTREME_DEBUG |
| 326 | u_char buff[BUFSIZ]; |
| 327 | #endif /* EXTREME_DEBUG */ |
| 328 | memcpy (lspid, isis->sysid, ISIS_SYS_ID_LEN); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 329 | LSP_PSEUDO_ID (lspid) = 0; |
| 330 | LSP_FRAGMENT (lspid) = 0; |
| 331 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 332 | lsp = lsp_search (lspid, area->lspdb[level - 1]); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 333 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 334 | if (lsp == NULL) |
| 335 | zlog_warn ("ISIS-Spf: could not find own l%d LSP!", level); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 336 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 337 | vertex = isis_vertex_new (isis->sysid, VTYPE_NONPSEUDO_IS); |
| 338 | vertex->lsp = lsp; |
| 339 | |
| 340 | listnode_add (spftree->paths, vertex); |
| 341 | |
| 342 | #ifdef EXTREME_DEBUG |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 343 | zlog_debug ("ISIS-Spf: added this IS %s %s depth %d dist %d to PATHS", |
| 344 | vtype2string (vertex->type), vid2string (vertex, buff), |
| 345 | vertex->depth, vertex->d_N); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 346 | #endif /* EXTREME_DEBUG */ |
| 347 | |
| 348 | return; |
| 349 | } |
| 350 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 351 | static struct isis_vertex * |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 352 | isis_find_vertex (struct list *list, void *id, enum vertextype vtype) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 353 | { |
| 354 | struct listnode *node; |
| 355 | struct isis_vertex *vertex; |
| 356 | struct prefix *p1, *p2; |
| 357 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 358 | for (ALL_LIST_ELEMENTS_RO (list, node, vertex)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 359 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 360 | if (vertex->type != vtype) |
| 361 | continue; |
| 362 | switch (vtype) |
| 363 | { |
| 364 | case VTYPE_ES: |
| 365 | case VTYPE_NONPSEUDO_IS: |
| 366 | if (memcmp ((u_char *) id, vertex->N.id, ISIS_SYS_ID_LEN) == 0) |
| 367 | return vertex; |
| 368 | break; |
| 369 | case VTYPE_PSEUDO_IS: |
| 370 | if (memcmp ((u_char *) id, vertex->N.id, ISIS_SYS_ID_LEN + 1) == 0) |
| 371 | return vertex; |
| 372 | break; |
| 373 | case VTYPE_IPREACH_INTERNAL: |
| 374 | case VTYPE_IPREACH_EXTERNAL: |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 375 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 376 | case VTYPE_IP6REACH_INTERNAL: |
| 377 | case VTYPE_IP6REACH_EXTERNAL: |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 378 | #endif /* HAVE_IPV6 */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 379 | p1 = (struct prefix *) id; |
| 380 | p2 = (struct prefix *) &vertex->N.id; |
| 381 | if (p1->family == p2->family && p1->prefixlen == p2->prefixlen && |
| 382 | memcmp (&p1->u.prefix, &p2->u.prefix, |
| 383 | PSIZE (p1->prefixlen)) == 0) |
| 384 | return vertex; |
| 385 | break; |
| 386 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 387 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 388 | |
| 389 | return NULL; |
| 390 | } |
| 391 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 392 | /* |
| 393 | * Add a vertex to TENT sorted by cost and by vertextype on tie break situation |
| 394 | */ |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 395 | static struct isis_vertex * |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 396 | isis_spf_add2tent (struct isis_spftree *spftree, enum vertextype vtype, |
| 397 | void *id, struct isis_adjacency *adj, u_int16_t cost, |
| 398 | int depth, int family) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 399 | { |
| 400 | struct isis_vertex *vertex, *v; |
| 401 | struct listnode *node; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 402 | #ifdef EXTREME_DEBUG |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 403 | u_char buff[BUFSIZ]; |
| 404 | #endif |
| 405 | |
| 406 | vertex = isis_vertex_new (id, vtype); |
| 407 | vertex->d_N = cost; |
| 408 | vertex->depth = depth; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 409 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 410 | if (adj) |
| 411 | listnode_add (vertex->Adj_N, adj); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 412 | #ifdef EXTREME_DEBUG |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 413 | zlog_debug ("ISIS-Spf: add to TENT %s %s depth %d dist %d", |
| 414 | vtype2string (vertex->type), vid2string (vertex, buff), |
| 415 | vertex->depth, vertex->d_N); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 416 | #endif /* EXTREME_DEBUG */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 417 | listnode_add (spftree->tents, vertex); |
| 418 | if (list_isempty (spftree->tents)) |
| 419 | { |
| 420 | listnode_add (spftree->tents, vertex); |
| 421 | return vertex; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 422 | } |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 423 | |
| 424 | /* XXX: This cant use the standard ALL_LIST_ELEMENT macro */ |
| 425 | for (node = listhead (spftree->tents); node; node = listnextnode (node)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 426 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 427 | v = listgetdata (node); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 428 | if (v->d_N > vertex->d_N) |
| 429 | { |
| 430 | list_add_node_prev (spftree->tents, node, vertex); |
| 431 | break; |
| 432 | } |
| 433 | else if (v->d_N == vertex->d_N) |
| 434 | { |
| 435 | /* Tie break, add according to type */ |
| 436 | while (v && v->d_N == vertex->d_N && v->type > vertex->type) |
| 437 | { |
| 438 | if (v->type > vertex->type) |
| 439 | { |
| 440 | break; |
| 441 | } |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 442 | /* XXX: this seems dubious, node is the loop iterator */ |
| 443 | node = listnextnode (node); |
| 444 | (node) ? (v = listgetdata (node)) : (v = NULL); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 445 | } |
| 446 | list_add_node_prev (spftree->tents, node, vertex); |
| 447 | break; |
| 448 | } |
| 449 | else if (node->next == NULL) |
| 450 | { |
| 451 | list_add_node_next (spftree->tents, node, vertex); |
| 452 | break; |
| 453 | } |
| 454 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 455 | return vertex; |
| 456 | } |
| 457 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 458 | static struct isis_vertex * |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 459 | isis_spf_add_local (struct isis_spftree *spftree, enum vertextype vtype, |
| 460 | void *id, struct isis_adjacency *adj, u_int16_t cost, |
| 461 | int family) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 462 | { |
| 463 | struct isis_vertex *vertex; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 464 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 465 | vertex = isis_find_vertex (spftree->tents, id, vtype); |
| 466 | |
| 467 | if (vertex) |
| 468 | { |
| 469 | /* C.2.5 c) */ |
| 470 | if (vertex->d_N == cost) |
| 471 | { |
| 472 | if (adj) |
| 473 | listnode_add (vertex->Adj_N, adj); |
| 474 | /* d) */ |
| 475 | if (listcount (vertex->Adj_N) > ISIS_MAX_PATH_SPLITS) |
| 476 | remove_excess_adjs (vertex->Adj_N); |
| 477 | } |
| 478 | /* f) */ |
| 479 | else if (vertex->d_N > cost) |
| 480 | { |
| 481 | listnode_delete (spftree->tents, vertex); |
| 482 | goto add2tent; |
| 483 | } |
| 484 | /* e) do nothing */ |
| 485 | return vertex; |
| 486 | } |
| 487 | |
| 488 | add2tent: |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 489 | return isis_spf_add2tent (spftree, vtype, id, adj, cost, 1, family); |
| 490 | } |
| 491 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 492 | static void |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 493 | process_N (struct isis_spftree *spftree, enum vertextype vtype, void *id, |
| 494 | u_int16_t dist, u_int16_t depth, struct isis_adjacency *adj, |
| 495 | int family) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 496 | { |
| 497 | struct isis_vertex *vertex; |
| 498 | #ifdef EXTREME_DEBUG |
| 499 | u_char buff[255]; |
| 500 | #endif |
| 501 | |
| 502 | /* C.2.6 b) */ |
| 503 | if (dist > MAX_PATH_METRIC) |
| 504 | return; |
| 505 | /* c) */ |
| 506 | vertex = isis_find_vertex (spftree->paths, id, vtype); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 507 | if (vertex) |
| 508 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 509 | #ifdef EXTREME_DEBUG |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 510 | zlog_debug ("ISIS-Spf: process_N %s %s dist %d already found from PATH", |
| 511 | vtype2string (vtype), vid2string (vertex, buff), dist); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 512 | #endif /* EXTREME_DEBUG */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 513 | assert (dist >= vertex->d_N); |
| 514 | return; |
| 515 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 516 | |
| 517 | vertex = isis_find_vertex (spftree->tents, id, vtype); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 518 | /* d) */ |
| 519 | if (vertex) |
| 520 | { |
| 521 | /* 1) */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 522 | #ifdef EXTREME_DEBUG |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 523 | zlog_debug ("ISIS-Spf: process_N %s %s dist %d", |
| 524 | vtype2string (vtype), vid2string (vertex, buff), dist); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 525 | #endif /* EXTREME_DEBUG */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 526 | if (vertex->d_N == dist) |
| 527 | { |
| 528 | if (adj) |
| 529 | listnode_add (vertex->Adj_N, adj); |
| 530 | /* 2) */ |
| 531 | if (listcount (vertex->Adj_N) > ISIS_MAX_PATH_SPLITS) |
| 532 | remove_excess_adjs (vertex->Adj_N); |
| 533 | /* 3) */ |
| 534 | return; |
| 535 | } |
| 536 | else if (vertex->d_N < dist) |
| 537 | { |
| 538 | return; |
| 539 | /* 4) */ |
| 540 | } |
| 541 | else |
| 542 | { |
| 543 | listnode_delete (spftree->tents, vertex); |
| 544 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 545 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 546 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 547 | isis_spf_add2tent (spftree, vtype, id, adj, dist, depth, family); |
| 548 | return; |
| 549 | } |
| 550 | |
| 551 | /* |
| 552 | * C.2.6 Step 1 |
| 553 | */ |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 554 | static int |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 555 | isis_spf_process_lsp (struct isis_spftree *spftree, struct isis_lsp *lsp, |
| 556 | uint16_t cost, uint16_t depth, int family) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 557 | { |
| 558 | struct listnode *node, *fragnode = NULL; |
| 559 | u_int16_t dist; |
| 560 | struct is_neigh *is_neigh; |
| 561 | struct ipv4_reachability *ipreach; |
| 562 | enum vertextype vtype; |
| 563 | struct prefix prefix; |
| 564 | #ifdef HAVE_IPV6 |
| 565 | struct ipv6_reachability *ip6reach; |
| 566 | #endif /* HAVE_IPV6 */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 567 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 568 | |
| 569 | if (!lsp->adj) |
| 570 | return ISIS_WARNING; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 571 | if (lsp->tlv_data.nlpids == NULL || !speaks (lsp->tlv_data.nlpids, family)) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 572 | return ISIS_OK; |
| 573 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 574 | lspfragloop: |
| 575 | if (lsp->lsp_header->seq_num == 0) |
| 576 | { |
| 577 | zlog_warn ("isis_spf_process_lsp(): lsp with 0 seq_num" |
| 578 | " - do not process"); |
| 579 | return ISIS_WARNING; |
| 580 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 581 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 582 | if (!ISIS_MASK_LSP_OL_BIT (lsp->lsp_header->lsp_bits)) |
| 583 | { |
| 584 | if (lsp->tlv_data.is_neighs) |
| 585 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 586 | for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.is_neighs, node, is_neigh)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 587 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 588 | /* C.2.6 a) */ |
| 589 | /* Two way connectivity */ |
| 590 | if (!memcmp (is_neigh->neigh_id, isis->sysid, ISIS_SYS_ID_LEN)) |
| 591 | continue; |
| 592 | dist = cost + is_neigh->metrics.metric_default; |
| 593 | vtype = LSP_PSEUDO_ID (is_neigh->neigh_id) ? VTYPE_PSEUDO_IS |
| 594 | : VTYPE_NONPSEUDO_IS; |
| 595 | process_N (spftree, vtype, (void *) is_neigh->neigh_id, dist, |
| 596 | depth + 1, lsp->adj, family); |
| 597 | } |
| 598 | } |
| 599 | if (family == AF_INET && lsp->tlv_data.ipv4_int_reachs) |
| 600 | { |
| 601 | prefix.family = AF_INET; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 602 | for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.ipv4_int_reachs, |
| 603 | node, ipreach)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 604 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 605 | dist = cost + ipreach->metrics.metric_default; |
| 606 | vtype = VTYPE_IPREACH_INTERNAL; |
| 607 | prefix.u.prefix4 = ipreach->prefix; |
| 608 | prefix.prefixlen = ip_masklen (ipreach->mask); |
| 609 | process_N (spftree, vtype, (void *) &prefix, dist, depth + 1, |
| 610 | lsp->adj, family); |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | if (family == AF_INET && lsp->tlv_data.ipv4_ext_reachs) |
| 615 | { |
| 616 | prefix.family = AF_INET; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 617 | for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.ipv4_ext_reachs, |
| 618 | node, ipreach)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 619 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 620 | dist = cost + ipreach->metrics.metric_default; |
| 621 | vtype = VTYPE_IPREACH_EXTERNAL; |
| 622 | prefix.u.prefix4 = ipreach->prefix; |
| 623 | prefix.prefixlen = ip_masklen (ipreach->mask); |
| 624 | process_N (spftree, vtype, (void *) &prefix, dist, depth + 1, |
| 625 | lsp->adj, family); |
| 626 | } |
| 627 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 628 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 629 | if (family == AF_INET6 && lsp->tlv_data.ipv6_reachs) |
| 630 | { |
| 631 | prefix.family = AF_INET6; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 632 | for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.ipv6_reachs, |
| 633 | node, ip6reach)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 634 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 635 | dist = cost + ip6reach->metric; |
| 636 | vtype = (ip6reach->control_info & CTRL_INFO_DISTRIBUTION) ? |
| 637 | VTYPE_IP6REACH_EXTERNAL : VTYPE_IP6REACH_INTERNAL; |
| 638 | prefix.prefixlen = ip6reach->prefix_len; |
| 639 | memcpy (&prefix.u.prefix6.s6_addr, ip6reach->prefix, |
| 640 | PSIZE (ip6reach->prefix_len)); |
| 641 | process_N (spftree, vtype, (void *) &prefix, dist, depth + 1, |
| 642 | lsp->adj, family); |
| 643 | } |
| 644 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 645 | #endif /* HAVE_IPV6 */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 646 | } |
| 647 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 648 | if (fragnode == NULL) |
| 649 | fragnode = listhead (lsp->lspu.frags); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 650 | else |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 651 | fragnode = listnextnode (fragnode); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 652 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 653 | if (fragnode) |
| 654 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 655 | lsp = listgetdata (fragnode); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 656 | goto lspfragloop; |
| 657 | } |
| 658 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 659 | return ISIS_OK; |
| 660 | } |
| 661 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 662 | static int |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 663 | isis_spf_process_pseudo_lsp (struct isis_spftree *spftree, |
| 664 | struct isis_lsp *lsp, uint16_t cost, |
| 665 | uint16_t depth, int family) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 666 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 667 | struct listnode *node, *nnode, *fragnode = NULL; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 668 | struct is_neigh *is_neigh; |
| 669 | enum vertextype vtype; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 670 | |
| 671 | pseudofragloop: |
| 672 | |
| 673 | if (lsp->lsp_header->seq_num == 0) |
| 674 | { |
| 675 | zlog_warn ("isis_spf_process_pseudo_lsp(): lsp with 0 seq_num" |
| 676 | " - do not process"); |
| 677 | return ISIS_WARNING; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 678 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 679 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 680 | for (ALL_LIST_ELEMENTS (lsp->tlv_data.is_neighs, node, nnode, is_neigh)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 681 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 682 | vtype = LSP_PSEUDO_ID (is_neigh->neigh_id) ? VTYPE_PSEUDO_IS |
| 683 | : VTYPE_NONPSEUDO_IS; |
| 684 | /* Two way connectivity */ |
| 685 | if (!memcmp (is_neigh->neigh_id, isis->sysid, ISIS_SYS_ID_LEN)) |
| 686 | continue; |
| 687 | if (isis_find_vertex |
| 688 | (spftree->tents, (void *) is_neigh->neigh_id, vtype) == NULL |
| 689 | && isis_find_vertex (spftree->paths, (void *) is_neigh->neigh_id, |
| 690 | vtype) == NULL) |
| 691 | { |
| 692 | /* C.2.5 i) */ |
| 693 | isis_spf_add2tent (spftree, vtype, is_neigh->neigh_id, lsp->adj, |
| 694 | cost, depth, family); |
| 695 | } |
| 696 | } |
| 697 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 698 | if (fragnode == NULL) |
| 699 | fragnode = listhead (lsp->lspu.frags); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 700 | else |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 701 | fragnode = listnextnode (fragnode); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 702 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 703 | if (fragnode) |
| 704 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 705 | lsp = listgetdata (fragnode); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 706 | goto pseudofragloop; |
| 707 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 708 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 709 | return ISIS_OK; |
| 710 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 711 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 712 | static int |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 713 | isis_spf_preload_tent (struct isis_spftree *spftree, |
| 714 | struct isis_area *area, int level, int family) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 715 | { |
| 716 | struct isis_vertex *vertex; |
| 717 | struct isis_circuit *circuit; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 718 | struct listnode *cnode, *cnnode; |
| 719 | struct listnode *anode; |
| 720 | struct listnode *ipnode, *ipnnode; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 721 | struct isis_adjacency *adj; |
| 722 | struct isis_lsp *lsp; |
| 723 | struct list *adj_list; |
| 724 | struct list *adjdb; |
| 725 | struct prefix_ipv4 *ipv4; |
| 726 | struct prefix prefix; |
| 727 | int retval = ISIS_OK; |
| 728 | u_char lsp_id[ISIS_SYS_ID_LEN + 2]; |
| 729 | #ifdef HAVE_IPV6 |
| 730 | struct prefix_ipv6 *ipv6; |
| 731 | #endif /* HAVE_IPV6 */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 732 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 733 | for (ALL_LIST_ELEMENTS (area->circuit_list, cnode, cnnode, circuit)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 734 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 735 | if (circuit->state != C_STATE_UP) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 736 | continue; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 737 | if (!(circuit->circuit_is_type & level)) |
| 738 | continue; |
| 739 | if (family == AF_INET && !circuit->ip_router) |
| 740 | continue; |
| 741 | #ifdef HAVE_IPV6 |
| 742 | if (family == AF_INET6 && !circuit->ipv6_router) |
| 743 | continue; |
| 744 | #endif /* HAVE_IPV6 */ |
| 745 | /* |
| 746 | * Add IP(v6) addresses of this circuit |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 747 | */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 748 | if (family == AF_INET) |
| 749 | { |
| 750 | prefix.family = AF_INET; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 751 | for (ALL_LIST_ELEMENTS (circuit->ip_addrs, ipnode, ipnnode, ipv4)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 752 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 753 | prefix.u.prefix4 = ipv4->prefix; |
| 754 | prefix.prefixlen = ipv4->prefixlen; |
| 755 | isis_spf_add_local (spftree, VTYPE_IPREACH_INTERNAL, &prefix, |
| 756 | NULL, 0, family); |
| 757 | } |
| 758 | } |
| 759 | #ifdef HAVE_IPV6 |
| 760 | if (family == AF_INET6) |
| 761 | { |
| 762 | prefix.family = AF_INET6; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 763 | for (ALL_LIST_ELEMENTS (circuit->ipv6_non_link, |
| 764 | ipnode, ipnnode, ipv6)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 765 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 766 | prefix.prefixlen = ipv6->prefixlen; |
| 767 | prefix.u.prefix6 = ipv6->prefix; |
| 768 | isis_spf_add_local (spftree, VTYPE_IP6REACH_INTERNAL, |
| 769 | &prefix, NULL, 0, family); |
| 770 | } |
| 771 | } |
| 772 | #endif /* HAVE_IPV6 */ |
| 773 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) |
| 774 | { |
| 775 | /* |
| 776 | * Add the adjacencies |
| 777 | */ |
| 778 | adj_list = list_new (); |
| 779 | adjdb = circuit->u.bc.adjdb[level - 1]; |
| 780 | isis_adj_build_up_list (adjdb, adj_list); |
| 781 | if (listcount (adj_list) == 0) |
| 782 | { |
| 783 | list_delete (adj_list); |
hasso | c89c05d | 2005-09-04 21:36:36 +0000 | [diff] [blame] | 784 | if (isis->debugs & DEBUG_SPF_EVENTS) |
| 785 | zlog_debug ("ISIS-Spf: no L%d adjacencies on circuit %s", |
| 786 | level, circuit->interface->name); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 787 | continue; |
| 788 | } |
| 789 | anode = listhead (adj_list); |
| 790 | while (anode) |
| 791 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 792 | adj = listgetdata (anode); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 793 | if (!speaks (&adj->nlpids, family)) |
| 794 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 795 | anode = listnextnode (anode); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 796 | continue; |
| 797 | } |
| 798 | switch (adj->sys_type) |
| 799 | { |
| 800 | case ISIS_SYSTYPE_ES: |
| 801 | isis_spf_add_local (spftree, VTYPE_ES, adj->sysid, adj, |
| 802 | circuit->metrics[level - |
| 803 | 1].metric_default, |
| 804 | family); |
| 805 | break; |
| 806 | case ISIS_SYSTYPE_IS: |
| 807 | case ISIS_SYSTYPE_L1_IS: |
| 808 | case ISIS_SYSTYPE_L2_IS: |
| 809 | vertex = |
| 810 | isis_spf_add_local (spftree, VTYPE_NONPSEUDO_IS, |
| 811 | adj->sysid, adj, |
| 812 | circuit->metrics[level - |
| 813 | 1].metric_default, |
| 814 | family); |
| 815 | memcpy (lsp_id, adj->sysid, ISIS_SYS_ID_LEN); |
| 816 | LSP_PSEUDO_ID (lsp_id) = 0; |
| 817 | LSP_FRAGMENT (lsp_id) = 0; |
| 818 | lsp = lsp_search (lsp_id, area->lspdb[level - 1]); |
| 819 | if (!lsp) |
| 820 | zlog_warn ("No lsp found for IS adjacency"); |
| 821 | /* else { |
| 822 | isis_spf_process_lsp (spftree, lsp, vertex->d_N, 1, family); |
| 823 | } */ |
| 824 | break; |
| 825 | case ISIS_SYSTYPE_UNKNOWN: |
| 826 | default: |
| 827 | zlog_warn ("isis_spf_preload_tent unknow adj type"); |
| 828 | } |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 829 | anode = listnextnode (anode); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 830 | } |
| 831 | list_delete (adj_list); |
| 832 | /* |
| 833 | * Add the pseudonode |
| 834 | */ |
| 835 | if (level == 1) |
| 836 | memcpy (lsp_id, circuit->u.bc.l1_desig_is, ISIS_SYS_ID_LEN + 1); |
| 837 | else |
| 838 | memcpy (lsp_id, circuit->u.bc.l2_desig_is, ISIS_SYS_ID_LEN + 1); |
| 839 | lsp = lsp_search (lsp_id, area->lspdb[level - 1]); |
| 840 | adj = isis_adj_lookup (lsp_id, adjdb); |
| 841 | /* if no adj, we are the dis or error */ |
| 842 | if (!adj && !circuit->u.bc.is_dr[level - 1]) |
| 843 | { |
| 844 | zlog_warn ("ISIS-Spf: No adjacency found for DR"); |
| 845 | } |
| 846 | if (lsp == NULL || lsp->lsp_header->rem_lifetime == 0) |
| 847 | { |
| 848 | zlog_warn ("ISIS-Spf: No lsp found for DR"); |
| 849 | } |
| 850 | else |
| 851 | { |
| 852 | isis_spf_process_pseudo_lsp |
| 853 | (spftree, lsp, circuit->metrics[level - 1].metric_default, 0, |
| 854 | family); |
| 855 | |
| 856 | } |
| 857 | } |
| 858 | else if (circuit->circ_type == CIRCUIT_T_P2P) |
| 859 | { |
| 860 | adj = circuit->u.p2p.neighbor; |
| 861 | if (!adj) |
| 862 | continue; |
| 863 | switch (adj->sys_type) |
| 864 | { |
| 865 | case ISIS_SYSTYPE_ES: |
| 866 | isis_spf_add_local (spftree, VTYPE_ES, adj->sysid, adj, |
| 867 | circuit->metrics[level - 1].metric_default, |
| 868 | family); |
| 869 | break; |
| 870 | case ISIS_SYSTYPE_IS: |
| 871 | case ISIS_SYSTYPE_L1_IS: |
| 872 | case ISIS_SYSTYPE_L2_IS: |
| 873 | if (speaks (&adj->nlpids, family)) |
| 874 | isis_spf_add_local (spftree, VTYPE_NONPSEUDO_IS, adj->sysid, |
| 875 | adj, |
| 876 | circuit->metrics[level - |
| 877 | 1].metric_default, |
| 878 | family); |
| 879 | break; |
| 880 | case ISIS_SYSTYPE_UNKNOWN: |
| 881 | default: |
| 882 | zlog_warn ("isis_spf_preload_tent unknow adj type"); |
| 883 | break; |
| 884 | } |
| 885 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 886 | else |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 887 | { |
| 888 | zlog_warn ("isis_spf_preload_tent unsupported media"); |
| 889 | retval = ISIS_WARNING; |
| 890 | } |
| 891 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 892 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 893 | |
| 894 | return retval; |
| 895 | } |
| 896 | |
| 897 | /* |
| 898 | * The parent(s) for vertex is set when added to TENT list |
| 899 | * now we just put the child pointer(s) in place |
| 900 | */ |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 901 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 902 | add_to_paths (struct isis_spftree *spftree, struct isis_vertex *vertex, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 903 | struct isis_area *area) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 904 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 905 | #ifdef EXTREME_DEBUG |
| 906 | u_char buff[BUFSIZ]; |
| 907 | #endif /* EXTREME_DEBUG */ |
| 908 | listnode_add (spftree->paths, vertex); |
| 909 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 910 | #ifdef EXTREME_DEBUG |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 911 | zlog_debug ("ISIS-Spf: added %s %s depth %d dist %d to PATHS", |
| 912 | vtype2string (vertex->type), vid2string (vertex, buff), |
| 913 | vertex->depth, vertex->d_N); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 914 | #endif /* EXTREME_DEBUG */ |
| 915 | if (vertex->type > VTYPE_ES) |
| 916 | { |
| 917 | if (listcount (vertex->Adj_N) > 0) |
| 918 | isis_route_create ((struct prefix *) &vertex->N.prefix, |
| 919 | vertex->d_N, vertex->depth, vertex->Adj_N, area); |
| 920 | else if (isis->debugs & DEBUG_SPF_EVENTS) |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 921 | zlog_debug ("ISIS-Spf: no adjacencies do not install route"); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 922 | } |
| 923 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 924 | return; |
| 925 | } |
| 926 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 927 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 928 | init_spt (struct isis_spftree *spftree) |
| 929 | { |
hasso | f7c43dc | 2004-09-26 16:24:14 +0000 | [diff] [blame] | 930 | spftree->tents->del = spftree->paths->del = (void (*)(void *)) isis_vertex_del; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 931 | list_delete_all_node (spftree->tents); |
| 932 | list_delete_all_node (spftree->paths); |
| 933 | spftree->tents->del = spftree->paths->del = NULL; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 934 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 935 | return; |
| 936 | } |
| 937 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 938 | static int |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 939 | isis_run_spf (struct isis_area *area, int level, int family) |
| 940 | { |
| 941 | int retval = ISIS_OK; |
| 942 | struct listnode *node; |
| 943 | struct isis_vertex *vertex; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 944 | struct isis_spftree *spftree = NULL; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 945 | u_char lsp_id[ISIS_SYS_ID_LEN + 2]; |
| 946 | struct isis_lsp *lsp; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 947 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 948 | if (family == AF_INET) |
| 949 | spftree = area->spftree[level - 1]; |
| 950 | #ifdef HAVE_IPV6 |
| 951 | else if (family == AF_INET6) |
| 952 | spftree = area->spftree6[level - 1]; |
| 953 | #endif |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 954 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 955 | assert (spftree); |
| 956 | |
| 957 | /* |
| 958 | * C.2.5 Step 0 |
| 959 | */ |
| 960 | init_spt (spftree); |
| 961 | /* a) */ |
| 962 | isis_spf_add_self (spftree, area, level); |
| 963 | /* b) */ |
| 964 | retval = isis_spf_preload_tent (spftree, area, level, family); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 965 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 966 | /* |
| 967 | * C.2.7 Step 2 |
| 968 | */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 969 | if (listcount (spftree->tents) == 0) |
| 970 | { |
| 971 | zlog_warn ("ISIS-Spf: TENT is empty"); |
| 972 | spftree->lastrun = time (NULL); |
| 973 | return retval; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 974 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 975 | |
| 976 | while (listcount (spftree->tents) > 0) |
| 977 | { |
| 978 | node = listhead (spftree->tents); |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 979 | vertex = listgetdata (node); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 980 | /* Remove from tent list */ |
| 981 | list_delete_node (spftree->tents, node); |
| 982 | if (isis_find_vertex (spftree->paths, vertex->N.id, vertex->type)) |
| 983 | continue; |
| 984 | add_to_paths (spftree, vertex, area); |
| 985 | if (vertex->type == VTYPE_PSEUDO_IS || |
| 986 | vertex->type == VTYPE_NONPSEUDO_IS) |
| 987 | { |
| 988 | memcpy (lsp_id, vertex->N.id, ISIS_SYS_ID_LEN + 1); |
| 989 | LSP_FRAGMENT (lsp_id) = 0; |
| 990 | lsp = lsp_search (lsp_id, area->lspdb[level - 1]); |
| 991 | if (lsp) |
| 992 | { |
| 993 | if (LSP_PSEUDO_ID (lsp_id)) |
| 994 | { |
| 995 | isis_spf_process_pseudo_lsp (spftree, lsp, vertex->d_N, |
| 996 | vertex->depth, family); |
| 997 | |
| 998 | } |
| 999 | else |
| 1000 | { |
| 1001 | isis_spf_process_lsp (spftree, lsp, vertex->d_N, |
| 1002 | vertex->depth, family); |
| 1003 | } |
| 1004 | } |
| 1005 | else |
| 1006 | { |
| 1007 | zlog_warn ("ISIS-Spf: No LSP found for %s", |
| 1008 | rawlspid_print (lsp_id)); |
| 1009 | } |
| 1010 | } |
| 1011 | } |
| 1012 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1013 | thread_add_event (master, isis_route_validate, area, 0); |
| 1014 | spftree->lastrun = time (NULL); |
| 1015 | spftree->pending = 0; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1016 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1017 | return retval; |
| 1018 | } |
| 1019 | |
| 1020 | int |
| 1021 | isis_run_spf_l1 (struct thread *thread) |
| 1022 | { |
| 1023 | struct isis_area *area; |
| 1024 | int retval = ISIS_OK; |
| 1025 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1026 | area = THREAD_ARG (thread); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1027 | assert (area); |
| 1028 | |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1029 | area->spftree[0]->t_spf = NULL; |
| 1030 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1031 | if (!(area->is_type & IS_LEVEL_1)) |
| 1032 | { |
| 1033 | if (isis->debugs & DEBUG_SPF_EVENTS) |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1034 | zlog_warn ("ISIS-SPF (%s) area does not share level", |
| 1035 | area->area_tag); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1036 | return ISIS_WARNING; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1037 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1038 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1039 | if (isis->debugs & DEBUG_SPF_EVENTS) |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 1040 | zlog_debug ("ISIS-Spf (%s) L1 SPF needed, periodic SPF", area->area_tag); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1041 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1042 | if (area->ip_circuits) |
| 1043 | retval = isis_run_spf (area, 1, AF_INET); |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1044 | |
| 1045 | THREAD_TIMER_ON (master, area->spftree[0]->t_spf, isis_run_spf_l1, area, |
| 1046 | isis_jitter (PERIODIC_SPF_INTERVAL, 10)); |
| 1047 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1048 | return retval; |
| 1049 | } |
| 1050 | |
| 1051 | int |
| 1052 | isis_run_spf_l2 (struct thread *thread) |
| 1053 | { |
| 1054 | struct isis_area *area; |
| 1055 | int retval = ISIS_OK; |
| 1056 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1057 | area = THREAD_ARG (thread); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1058 | assert (area); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1059 | |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1060 | area->spftree[1]->t_spf = NULL; |
| 1061 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1062 | if (!(area->is_type & IS_LEVEL_2)) |
| 1063 | { |
| 1064 | if (isis->debugs & DEBUG_SPF_EVENTS) |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1065 | zlog_warn ("ISIS-SPF (%s) area does not share level", area->area_tag); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1066 | return ISIS_WARNING; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1067 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1068 | |
| 1069 | if (isis->debugs & DEBUG_SPF_EVENTS) |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 1070 | zlog_debug ("ISIS-Spf (%s) L2 SPF needed, periodic SPF", area->area_tag); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1071 | |
| 1072 | if (area->ip_circuits) |
| 1073 | retval = isis_run_spf (area, 2, AF_INET); |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1074 | |
| 1075 | THREAD_TIMER_ON (master, area->spftree[1]->t_spf, isis_run_spf_l2, area, |
| 1076 | isis_jitter (PERIODIC_SPF_INTERVAL, 10)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1077 | |
| 1078 | return retval; |
| 1079 | } |
| 1080 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1081 | int |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1082 | isis_spf_schedule (struct isis_area *area, int level) |
| 1083 | { |
| 1084 | int retval = ISIS_OK; |
| 1085 | struct isis_spftree *spftree = area->spftree[level - 1]; |
| 1086 | time_t diff, now = time (NULL); |
| 1087 | |
| 1088 | if (spftree->pending) |
| 1089 | return retval; |
| 1090 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1091 | diff = now - spftree->lastrun; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1092 | |
| 1093 | /* FIXME: let's wait a minute before doing the SPF */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1094 | if (now - isis->uptime < 60 || isis->uptime == 0) |
| 1095 | { |
| 1096 | if (level == 1) |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1097 | THREAD_TIMER_ON (master, spftree->t_spf, isis_run_spf_l1, area, 60); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1098 | else |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1099 | THREAD_TIMER_ON (master, spftree->t_spf, isis_run_spf_l2, area, 60); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1100 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1101 | spftree->pending = 1; |
| 1102 | return retval; |
| 1103 | } |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1104 | |
| 1105 | THREAD_TIMER_OFF (spftree->t_spf); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1106 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1107 | if (diff < MINIMUM_SPF_INTERVAL) |
| 1108 | { |
| 1109 | if (level == 1) |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1110 | THREAD_TIMER_ON (master, spftree->t_spf, isis_run_spf_l1, area, |
| 1111 | MINIMUM_SPF_INTERVAL - diff); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1112 | else |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1113 | THREAD_TIMER_ON (master, spftree->t_spf, isis_run_spf_l2, area, |
| 1114 | MINIMUM_SPF_INTERVAL - diff); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1115 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1116 | spftree->pending = 1; |
| 1117 | } |
| 1118 | else |
| 1119 | { |
| 1120 | spftree->pending = 0; |
| 1121 | retval = isis_run_spf (area, level, AF_INET); |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1122 | if (level == 1) |
| 1123 | THREAD_TIMER_ON (master, spftree->t_spf, isis_run_spf_l1, area, |
| 1124 | isis_jitter (PERIODIC_SPF_INTERVAL, 10)); |
| 1125 | else |
| 1126 | THREAD_TIMER_ON (master, spftree->t_spf, isis_run_spf_l2, area, |
| 1127 | isis_jitter (PERIODIC_SPF_INTERVAL, 10)); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1128 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1129 | |
| 1130 | return retval; |
| 1131 | } |
| 1132 | |
| 1133 | #ifdef HAVE_IPV6 |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 1134 | static int |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1135 | isis_run_spf6_l1 (struct thread *thread) |
| 1136 | { |
| 1137 | struct isis_area *area; |
| 1138 | int retval = ISIS_OK; |
| 1139 | |
| 1140 | area = THREAD_ARG (thread); |
| 1141 | assert (area); |
| 1142 | |
| 1143 | area->spftree6[0]->t_spf = NULL; |
| 1144 | |
| 1145 | if (!(area->is_type & IS_LEVEL_1)) |
| 1146 | { |
| 1147 | if (isis->debugs & DEBUG_SPF_EVENTS) |
| 1148 | zlog_warn ("ISIS-SPF (%s) area does not share level", area->area_tag); |
| 1149 | return ISIS_WARNING; |
| 1150 | } |
| 1151 | |
| 1152 | if (isis->debugs & DEBUG_SPF_EVENTS) |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 1153 | zlog_debug ("ISIS-Spf (%s) L1 SPF needed, periodic SPF", area->area_tag); |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1154 | |
| 1155 | if (area->ipv6_circuits) |
| 1156 | retval = isis_run_spf (area, 1, AF_INET6); |
| 1157 | |
| 1158 | THREAD_TIMER_ON (master, area->spftree6[0]->t_spf, isis_run_spf6_l1, area, |
| 1159 | isis_jitter (PERIODIC_SPF_INTERVAL, 10)); |
| 1160 | |
| 1161 | return retval; |
| 1162 | } |
| 1163 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 1164 | static int |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1165 | isis_run_spf6_l2 (struct thread *thread) |
| 1166 | { |
| 1167 | struct isis_area *area; |
| 1168 | int retval = ISIS_OK; |
| 1169 | |
| 1170 | area = THREAD_ARG (thread); |
| 1171 | assert (area); |
| 1172 | |
| 1173 | area->spftree6[1]->t_spf = NULL; |
| 1174 | |
| 1175 | if (!(area->is_type & IS_LEVEL_2)) |
| 1176 | { |
| 1177 | if (isis->debugs & DEBUG_SPF_EVENTS) |
| 1178 | zlog_warn ("ISIS-SPF (%s) area does not share level", area->area_tag); |
| 1179 | return ISIS_WARNING; |
| 1180 | } |
| 1181 | |
| 1182 | if (isis->debugs & DEBUG_SPF_EVENTS) |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 1183 | zlog_debug ("ISIS-Spf (%s) L2 SPF needed, periodic SPF", area->area_tag); |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1184 | |
| 1185 | if (area->ipv6_circuits) |
| 1186 | retval = isis_run_spf (area, 2, AF_INET6); |
| 1187 | |
| 1188 | THREAD_TIMER_ON (master, area->spftree6[1]->t_spf, isis_run_spf6_l2, area, |
| 1189 | isis_jitter (PERIODIC_SPF_INTERVAL, 10)); |
| 1190 | |
| 1191 | return retval; |
| 1192 | } |
| 1193 | |
| 1194 | int |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1195 | isis_spf_schedule6 (struct isis_area *area, int level) |
| 1196 | { |
| 1197 | int retval = ISIS_OK; |
| 1198 | struct isis_spftree *spftree = area->spftree6[level - 1]; |
| 1199 | time_t diff, now = time (NULL); |
| 1200 | |
| 1201 | if (spftree->pending) |
| 1202 | return retval; |
| 1203 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1204 | diff = now - spftree->lastrun; |
| 1205 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1206 | /* FIXME: let's wait a minute before doing the SPF */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1207 | if (now - isis->uptime < 60 || isis->uptime == 0) |
| 1208 | { |
| 1209 | if (level == 1) |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1210 | THREAD_TIMER_ON (master, spftree->t_spf, isis_run_spf6_l1, area, 60); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1211 | else |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1212 | THREAD_TIMER_ON (master, spftree->t_spf, isis_run_spf6_l2, area, 60); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1213 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1214 | spftree->pending = 1; |
| 1215 | return retval; |
| 1216 | } |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1217 | |
| 1218 | THREAD_TIMER_OFF (spftree->t_spf); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1219 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1220 | if (diff < MINIMUM_SPF_INTERVAL) |
| 1221 | { |
| 1222 | if (level == 1) |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1223 | THREAD_TIMER_ON (master, spftree->t_spf, isis_run_spf6_l1, area, |
| 1224 | MINIMUM_SPF_INTERVAL - diff); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1225 | else |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1226 | THREAD_TIMER_ON (master, spftree->t_spf, isis_run_spf6_l2, area, |
| 1227 | MINIMUM_SPF_INTERVAL - diff); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1228 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1229 | spftree->pending = 1; |
| 1230 | } |
| 1231 | else |
| 1232 | { |
| 1233 | spftree->pending = 0; |
| 1234 | retval = isis_run_spf (area, level, AF_INET6); |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1235 | |
| 1236 | if (level == 1) |
| 1237 | THREAD_TIMER_ON (master, spftree->t_spf, isis_run_spf6_l1, area, |
| 1238 | isis_jitter (PERIODIC_SPF_INTERVAL, 10)); |
| 1239 | else |
| 1240 | THREAD_TIMER_ON (master, spftree->t_spf, isis_run_spf6_l2, area, |
| 1241 | isis_jitter (PERIODIC_SPF_INTERVAL, 10)); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1242 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1243 | |
| 1244 | return retval; |
| 1245 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1246 | #endif |
| 1247 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 1248 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1249 | isis_print_paths (struct vty *vty, struct list *paths) |
| 1250 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1251 | struct listnode *node; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1252 | struct isis_vertex *vertex; |
| 1253 | struct isis_dynhn *dyn, *nh_dyn = NULL; |
| 1254 | struct isis_adjacency *adj; |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 1255 | #if 0 |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1256 | u_char buff[255]; |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 1257 | #endif /* 0 */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1258 | |
| 1259 | vty_out (vty, "System Id Metric Next-Hop" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1260 | " Interface SNPA%s", VTY_NEWLINE); |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1261 | |
| 1262 | for (ALL_LIST_ELEMENTS_RO (paths, node, vertex)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1263 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1264 | if (vertex->type != VTYPE_NONPSEUDO_IS) |
| 1265 | continue; |
| 1266 | if (memcmp (vertex->N.id, isis->sysid, ISIS_SYS_ID_LEN) == 0) |
| 1267 | { |
hasso | c3d26c7 | 2005-03-07 08:54:41 +0000 | [diff] [blame] | 1268 | vty_out (vty, "%s --%s", host.name?host.name:"", |
| 1269 | VTY_NEWLINE); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1270 | } |
| 1271 | else |
| 1272 | { |
| 1273 | dyn = dynhn_find_by_id ((u_char *) vertex->N.id); |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1274 | adj = listgetdata (listhead (vertex->Adj_N)); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1275 | if (adj) |
| 1276 | { |
| 1277 | nh_dyn = dynhn_find_by_id (adj->sysid); |
| 1278 | vty_out (vty, "%-20s %-10u %-20s %-11s %-5s%s", |
| 1279 | (dyn != NULL) ? dyn->name.name : |
| 1280 | (u_char *) rawlspid_print ((u_char *) vertex->N.id), |
| 1281 | vertex->d_N, (nh_dyn != NULL) ? nh_dyn->name.name : |
| 1282 | (u_char *) rawlspid_print (adj->sysid), |
| 1283 | adj->circuit->interface->name, |
| 1284 | snpa_print (adj->snpa), VTY_NEWLINE); |
| 1285 | } |
| 1286 | else |
| 1287 | { |
| 1288 | vty_out (vty, "%s %u %s", dyn ? dyn->name.name : |
| 1289 | (u_char *) rawlspid_print (vertex->N.id), |
| 1290 | vertex->d_N, VTY_NEWLINE); |
| 1291 | } |
| 1292 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1293 | #if 0 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1294 | vty_out (vty, "%s %s %u %s", vtype2string (vertex->type), |
| 1295 | vid2string (vertex, buff), vertex->d_N, VTY_NEWLINE); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1296 | #endif |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1297 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1298 | } |
| 1299 | |
| 1300 | DEFUN (show_isis_topology, |
| 1301 | show_isis_topology_cmd, |
| 1302 | "show isis topology", |
| 1303 | SHOW_STR |
| 1304 | "IS-IS information\n" |
| 1305 | "IS-IS paths to Intermediate Systems\n") |
| 1306 | { |
| 1307 | struct listnode *node; |
| 1308 | struct isis_area *area; |
| 1309 | int level; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1310 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1311 | if (!isis->area_list || isis->area_list->count == 0) |
| 1312 | return CMD_SUCCESS; |
| 1313 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1314 | for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1315 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1316 | vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null", |
| 1317 | VTY_NEWLINE); |
| 1318 | |
| 1319 | for (level = 0; level < ISIS_LEVELS; level++) |
| 1320 | { |
| 1321 | if (area->ip_circuits > 0 && area->spftree[level] |
| 1322 | && area->spftree[level]->paths->count > 0) |
| 1323 | { |
| 1324 | vty_out (vty, "IS-IS paths to level-%d routers that speak IP%s", |
| 1325 | level + 1, VTY_NEWLINE); |
| 1326 | isis_print_paths (vty, area->spftree[level]->paths); |
| 1327 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1328 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1329 | if (area->ipv6_circuits > 0 && area->spftree6[level] |
| 1330 | && area->spftree6[level]->paths->count > 0) |
| 1331 | { |
| 1332 | vty_out (vty, |
| 1333 | "IS-IS paths to level-%d routers that speak IPv6%s", |
| 1334 | level + 1, VTY_NEWLINE); |
| 1335 | isis_print_paths (vty, area->spftree6[level]->paths); |
| 1336 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1337 | #endif /* HAVE_IPV6 */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1338 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1339 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1340 | |
| 1341 | return CMD_SUCCESS; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1342 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1343 | |
| 1344 | DEFUN (show_isis_topology_l1, |
| 1345 | show_isis_topology_l1_cmd, |
| 1346 | "show isis topology level-1", |
| 1347 | SHOW_STR |
| 1348 | "IS-IS information\n" |
| 1349 | "IS-IS paths to Intermediate Systems\n" |
| 1350 | "Paths to all level-1 routers in the area\n") |
| 1351 | { |
| 1352 | struct listnode *node; |
| 1353 | struct isis_area *area; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1354 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1355 | if (!isis->area_list || isis->area_list->count == 0) |
| 1356 | return CMD_SUCCESS; |
| 1357 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1358 | for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1359 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1360 | vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null", |
| 1361 | VTY_NEWLINE); |
| 1362 | |
| 1363 | if (area->ip_circuits > 0 && area->spftree[0] |
| 1364 | && area->spftree[0]->paths->count > 0) |
| 1365 | { |
| 1366 | vty_out (vty, "IS-IS paths to level-1 routers that speak IP%s", |
| 1367 | VTY_NEWLINE); |
| 1368 | isis_print_paths (vty, area->spftree[0]->paths); |
| 1369 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1370 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1371 | if (area->ipv6_circuits > 0 && area->spftree6[0] |
| 1372 | && area->spftree6[0]->paths->count > 0) |
| 1373 | { |
| 1374 | vty_out (vty, "IS-IS paths to level-1 routers that speak IPv6%s", |
| 1375 | VTY_NEWLINE); |
| 1376 | isis_print_paths (vty, area->spftree6[0]->paths); |
| 1377 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1378 | #endif /* HAVE_IPV6 */ |
| 1379 | } |
| 1380 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1381 | return CMD_SUCCESS; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1382 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1383 | |
| 1384 | DEFUN (show_isis_topology_l2, |
| 1385 | show_isis_topology_l2_cmd, |
| 1386 | "show isis topology level-2", |
| 1387 | SHOW_STR |
| 1388 | "IS-IS information\n" |
| 1389 | "IS-IS paths to Intermediate Systems\n" |
| 1390 | "Paths to all level-2 routers in the domain\n") |
| 1391 | { |
| 1392 | struct listnode *node; |
| 1393 | struct isis_area *area; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1394 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1395 | if (!isis->area_list || isis->area_list->count == 0) |
| 1396 | return CMD_SUCCESS; |
| 1397 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1398 | for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1399 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1400 | vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null", |
| 1401 | VTY_NEWLINE); |
| 1402 | |
| 1403 | if (area->ip_circuits > 0 && area->spftree[1] |
| 1404 | && area->spftree[1]->paths->count > 0) |
| 1405 | { |
| 1406 | vty_out (vty, "IS-IS paths to level-2 routers that speak IP%s", |
| 1407 | VTY_NEWLINE); |
| 1408 | isis_print_paths (vty, area->spftree[1]->paths); |
| 1409 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1410 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1411 | if (area->ipv6_circuits > 0 && area->spftree6[1] |
| 1412 | && area->spftree6[1]->paths->count > 0) |
| 1413 | { |
| 1414 | vty_out (vty, "IS-IS paths to level-2 routers that speak IPv6%s", |
| 1415 | VTY_NEWLINE); |
| 1416 | isis_print_paths (vty, area->spftree6[1]->paths); |
| 1417 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1418 | #endif /* HAVE_IPV6 */ |
| 1419 | } |
| 1420 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1421 | return CMD_SUCCESS; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1422 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1423 | |
| 1424 | void |
| 1425 | isis_spf_cmds_init () |
| 1426 | { |
| 1427 | install_element (VIEW_NODE, &show_isis_topology_cmd); |
| 1428 | install_element (VIEW_NODE, &show_isis_topology_l1_cmd); |
| 1429 | install_element (VIEW_NODE, &show_isis_topology_l2_cmd); |
| 1430 | |
| 1431 | install_element (ENABLE_NODE, &show_isis_topology_cmd); |
| 1432 | install_element (ENABLE_NODE, &show_isis_topology_l1_cmd); |
| 1433 | install_element (ENABLE_NODE, &show_isis_topology_l2_cmd); |
| 1434 | } |