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