paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 2 | * Copyright (C) 2003 Yasuhiro Ohara |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3 | * |
| 4 | * This file is part of GNU Zebra. |
| 5 | * |
| 6 | * GNU Zebra is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License as published by the |
| 8 | * Free Software Foundation; either version 2, or (at your option) any |
| 9 | * later version. |
| 10 | * |
| 11 | * GNU Zebra is distributed in the hope that it will be useful, but |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with GNU Zebra; see the file COPYING. If not, write to the |
| 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 19 | * Boston, MA 02111-1307, USA. |
| 20 | */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 21 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 22 | /* Shortest Path First calculation for OSPFv3 */ |
| 23 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 24 | #include <zebra.h> |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 25 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 26 | #include "log.h" |
| 27 | #include "memory.h" |
| 28 | #include "command.h" |
| 29 | #include "vty.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 30 | #include "prefix.h" |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 31 | #include "pqueue.h" |
| 32 | #include "linklist.h" |
| 33 | #include "thread.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 34 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 35 | #include "ospf6_lsa.h" |
| 36 | #include "ospf6_lsdb.h" |
| 37 | #include "ospf6_route.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 38 | #include "ospf6_area.h" |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 39 | #include "ospf6_spf.h" |
| 40 | #include "ospf6_intra.h" |
| 41 | #include "ospf6_interface.h" |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 42 | #include "ospf6d.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 43 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 44 | unsigned char conf_debug_ospf6_spf = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 45 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 46 | static int |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 47 | ospf6_vertex_cmp (void *a, void *b) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 48 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 49 | struct ospf6_vertex *va = (struct ospf6_vertex *) a; |
| 50 | struct ospf6_vertex *vb = (struct ospf6_vertex *) b; |
| 51 | |
| 52 | /* ascending order */ |
Dmitrij Tejblum | 403138e | 2011-01-13 18:25:40 +0300 | [diff] [blame] | 53 | if (va->cost != vb->cost) |
| 54 | return (va->cost - vb->cost); |
| 55 | return (va->hops - vb->hops); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 56 | } |
| 57 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 58 | static int |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 59 | ospf6_vertex_id_cmp (void *a, void *b) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 60 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 61 | struct ospf6_vertex *va = (struct ospf6_vertex *) a; |
| 62 | struct ospf6_vertex *vb = (struct ospf6_vertex *) b; |
| 63 | int ret = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 64 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 65 | ret = ntohl (ospf6_linkstate_prefix_adv_router (&va->vertex_id)) - |
| 66 | ntohl (ospf6_linkstate_prefix_adv_router (&vb->vertex_id)); |
| 67 | if (ret) |
| 68 | return ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 69 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 70 | ret = ntohl (ospf6_linkstate_prefix_id (&va->vertex_id)) - |
| 71 | ntohl (ospf6_linkstate_prefix_id (&vb->vertex_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 72 | return ret; |
| 73 | } |
| 74 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 75 | static struct ospf6_vertex * |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 76 | ospf6_vertex_create (struct ospf6_lsa *lsa) |
| 77 | { |
| 78 | struct ospf6_vertex *v; |
| 79 | int i; |
| 80 | |
| 81 | v = (struct ospf6_vertex *) |
| 82 | XMALLOC (MTYPE_OSPF6_VERTEX, sizeof (struct ospf6_vertex)); |
| 83 | |
| 84 | /* type */ |
| 85 | if (ntohs (lsa->header->type) == OSPF6_LSTYPE_ROUTER) |
| 86 | v->type = OSPF6_VERTEX_TYPE_ROUTER; |
| 87 | else if (ntohs (lsa->header->type) == OSPF6_LSTYPE_NETWORK) |
| 88 | v->type = OSPF6_VERTEX_TYPE_NETWORK; |
| 89 | else |
| 90 | assert (0); |
| 91 | |
| 92 | /* vertex_id */ |
| 93 | ospf6_linkstate_prefix (lsa->header->adv_router, lsa->header->id, |
| 94 | &v->vertex_id); |
| 95 | |
| 96 | /* name */ |
| 97 | ospf6_linkstate_prefix2str (&v->vertex_id, v->name, sizeof (v->name)); |
| 98 | |
| 99 | /* Associated LSA */ |
| 100 | v->lsa = lsa; |
| 101 | |
| 102 | /* capability bits + options */ |
| 103 | v->capability = *(u_char *)(OSPF6_LSA_HEADER_END (lsa->header)); |
| 104 | v->options[0] = *(u_char *)(OSPF6_LSA_HEADER_END (lsa->header) + 1); |
| 105 | v->options[1] = *(u_char *)(OSPF6_LSA_HEADER_END (lsa->header) + 2); |
| 106 | v->options[2] = *(u_char *)(OSPF6_LSA_HEADER_END (lsa->header) + 3); |
| 107 | |
| 108 | for (i = 0; i < OSPF6_MULTI_PATH_LIMIT; i++) |
| 109 | ospf6_nexthop_clear (&v->nexthop[i]); |
| 110 | |
| 111 | v->parent = NULL; |
| 112 | v->child_list = list_new (); |
| 113 | v->child_list->cmp = ospf6_vertex_id_cmp; |
| 114 | |
| 115 | return v; |
| 116 | } |
| 117 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 118 | static void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 119 | ospf6_vertex_delete (struct ospf6_vertex *v) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 120 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 121 | list_delete (v->child_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 122 | XFREE (MTYPE_OSPF6_VERTEX, v); |
| 123 | } |
| 124 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 125 | static struct ospf6_lsa * |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 126 | ospf6_lsdesc_lsa (caddr_t lsdesc, struct ospf6_vertex *v) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 127 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 128 | struct ospf6_lsa *lsa; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 129 | u_int16_t type = 0; |
| 130 | u_int32_t id = 0, adv_router = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 131 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 132 | if (VERTEX_IS_TYPE (NETWORK, v)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 133 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 134 | type = htons (OSPF6_LSTYPE_ROUTER); |
| 135 | id = htonl (0); |
| 136 | adv_router = NETWORK_LSDESC_GET_NBR_ROUTERID (lsdesc); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 137 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 138 | else |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 139 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 140 | if (ROUTER_LSDESC_IS_TYPE (POINTTOPOINT, lsdesc)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 141 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 142 | type = htons (OSPF6_LSTYPE_ROUTER); |
| 143 | id = htonl (0); |
| 144 | adv_router = ROUTER_LSDESC_GET_NBR_ROUTERID (lsdesc); |
| 145 | } |
| 146 | else if (ROUTER_LSDESC_IS_TYPE (TRANSIT_NETWORK, lsdesc)) |
| 147 | { |
| 148 | type = htons (OSPF6_LSTYPE_NETWORK); |
| 149 | id = htonl (ROUTER_LSDESC_GET_NBR_IFID (lsdesc)); |
| 150 | adv_router = ROUTER_LSDESC_GET_NBR_ROUTERID (lsdesc); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 151 | } |
| 152 | } |
| 153 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 154 | lsa = ospf6_lsdb_lookup (type, id, adv_router, v->area->lsdb); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 155 | |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 156 | if (IS_OSPF6_DEBUG_SPF (PROCESS)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 157 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 158 | char ibuf[16], abuf[16]; |
| 159 | inet_ntop (AF_INET, &id, ibuf, sizeof (ibuf)); |
| 160 | inet_ntop (AF_INET, &adv_router, abuf, sizeof (abuf)); |
| 161 | if (lsa) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 162 | zlog_debug (" Link to: %s", lsa->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 163 | else |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 164 | zlog_debug (" Link to: [%s Id:%s Adv:%s] No LSA", |
| 165 | ospf6_lstype_name (type), ibuf, abuf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 166 | } |
| 167 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 168 | return lsa; |
| 169 | } |
| 170 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 171 | static char * |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 172 | ospf6_lsdesc_backlink (struct ospf6_lsa *lsa, |
| 173 | caddr_t lsdesc, struct ospf6_vertex *v) |
| 174 | { |
| 175 | caddr_t backlink, found = NULL; |
| 176 | int size; |
| 177 | |
| 178 | size = (OSPF6_LSA_IS_TYPE (ROUTER, lsa) ? |
| 179 | sizeof (struct ospf6_router_lsdesc) : |
| 180 | sizeof (struct ospf6_network_lsdesc)); |
| 181 | for (backlink = OSPF6_LSA_HEADER_END (lsa->header) + 4; |
| 182 | backlink + size <= OSPF6_LSA_END (lsa->header); backlink += size) |
| 183 | { |
| 184 | assert (! (OSPF6_LSA_IS_TYPE (NETWORK, lsa) && |
| 185 | VERTEX_IS_TYPE (NETWORK, v))); |
| 186 | |
| 187 | if (OSPF6_LSA_IS_TYPE (NETWORK, lsa) && |
| 188 | NETWORK_LSDESC_GET_NBR_ROUTERID (backlink) |
| 189 | == v->lsa->header->adv_router) |
| 190 | found = backlink; |
| 191 | else if (VERTEX_IS_TYPE (NETWORK, v) && |
| 192 | ROUTER_LSDESC_IS_TYPE (TRANSIT_NETWORK, backlink) && |
| 193 | ROUTER_LSDESC_GET_NBR_ROUTERID (backlink) |
| 194 | == v->lsa->header->adv_router && |
| 195 | ROUTER_LSDESC_GET_NBR_IFID (backlink) |
| 196 | == ntohl (v->lsa->header->id)) |
| 197 | found = backlink; |
| 198 | else |
| 199 | { |
| 200 | if (! ROUTER_LSDESC_IS_TYPE (POINTTOPOINT, backlink) || |
| 201 | ! ROUTER_LSDESC_IS_TYPE (POINTTOPOINT, lsdesc)) |
| 202 | continue; |
| 203 | if (ROUTER_LSDESC_GET_NBR_IFID (backlink) != |
| 204 | ROUTER_LSDESC_GET_IFID (lsdesc) || |
| 205 | ROUTER_LSDESC_GET_NBR_IFID (lsdesc) != |
| 206 | ROUTER_LSDESC_GET_IFID (backlink)) |
| 207 | continue; |
| 208 | if (ROUTER_LSDESC_GET_NBR_ROUTERID (backlink) != |
| 209 | v->lsa->header->adv_router || |
| 210 | ROUTER_LSDESC_GET_NBR_ROUTERID (lsdesc) != |
| 211 | lsa->header->adv_router) |
| 212 | continue; |
| 213 | found = backlink; |
| 214 | } |
| 215 | } |
| 216 | |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 217 | if (IS_OSPF6_DEBUG_SPF (PROCESS)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 218 | zlog_debug (" Backlink %s", (found ? "OK" : "FAIL")); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 219 | |
| 220 | return found; |
| 221 | } |
| 222 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 223 | static void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 224 | ospf6_nexthop_calc (struct ospf6_vertex *w, struct ospf6_vertex *v, |
| 225 | caddr_t lsdesc) |
| 226 | { |
| 227 | int i, ifindex; |
| 228 | struct ospf6_interface *oi; |
| 229 | u_int16_t type; |
| 230 | u_int32_t adv_router; |
| 231 | struct ospf6_lsa *lsa; |
| 232 | struct ospf6_link_lsa *link_lsa; |
| 233 | char buf[64]; |
| 234 | |
| 235 | assert (VERTEX_IS_TYPE (ROUTER, w)); |
| 236 | ifindex = (VERTEX_IS_TYPE (NETWORK, v) ? v->nexthop[0].ifindex : |
| 237 | ROUTER_LSDESC_GET_IFID (lsdesc)); |
| 238 | oi = ospf6_interface_lookup_by_ifindex (ifindex); |
| 239 | if (oi == NULL) |
| 240 | { |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 241 | if (IS_OSPF6_DEBUG_SPF (PROCESS)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 242 | zlog_debug ("Can't find interface in SPF: ifindex %d", ifindex); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 243 | return; |
| 244 | } |
| 245 | |
| 246 | type = htons (OSPF6_LSTYPE_LINK); |
| 247 | adv_router = (VERTEX_IS_TYPE (NETWORK, v) ? |
| 248 | NETWORK_LSDESC_GET_NBR_ROUTERID (lsdesc) : |
| 249 | ROUTER_LSDESC_GET_NBR_ROUTERID (lsdesc)); |
| 250 | |
| 251 | i = 0; |
| 252 | for (lsa = ospf6_lsdb_type_router_head (type, adv_router, oi->lsdb); lsa; |
| 253 | lsa = ospf6_lsdb_type_router_next (type, adv_router, lsa)) |
| 254 | { |
| 255 | if (VERTEX_IS_TYPE (ROUTER, v) && |
| 256 | htonl (ROUTER_LSDESC_GET_NBR_IFID (lsdesc)) != lsa->header->id) |
| 257 | continue; |
| 258 | |
| 259 | link_lsa = (struct ospf6_link_lsa *) OSPF6_LSA_HEADER_END (lsa->header); |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 260 | if (IS_OSPF6_DEBUG_SPF (PROCESS)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 261 | { |
| 262 | inet_ntop (AF_INET6, &link_lsa->linklocal_addr, buf, sizeof (buf)); |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 263 | zlog_debug (" nexthop %s from %s", buf, lsa->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | if (i < OSPF6_MULTI_PATH_LIMIT) |
| 267 | { |
| 268 | memcpy (&w->nexthop[i].address, &link_lsa->linklocal_addr, |
| 269 | sizeof (struct in6_addr)); |
| 270 | w->nexthop[i].ifindex = ifindex; |
| 271 | i++; |
| 272 | } |
| 273 | } |
| 274 | |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 275 | if (i == 0 && IS_OSPF6_DEBUG_SPF (PROCESS)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 276 | zlog_debug ("No nexthop for %s found", w->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 277 | } |
| 278 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 279 | static int |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 280 | ospf6_spf_install (struct ospf6_vertex *v, |
| 281 | struct ospf6_route_table *result_table) |
| 282 | { |
| 283 | struct ospf6_route *route; |
| 284 | int i, j; |
| 285 | struct ospf6_vertex *prev, *w; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 286 | struct listnode *node, *nnode; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 287 | |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 288 | if (IS_OSPF6_DEBUG_SPF (PROCESS)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 289 | zlog_debug ("SPF install %s hops %d cost %d", |
| 290 | v->name, v->hops, v->cost); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 291 | |
| 292 | route = ospf6_route_lookup (&v->vertex_id, result_table); |
| 293 | if (route && route->path.cost < v->cost) |
| 294 | { |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 295 | if (IS_OSPF6_DEBUG_SPF (PROCESS)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 296 | zlog_debug (" already installed with lower cost (%d), ignore", |
| 297 | route->path.cost); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 298 | ospf6_vertex_delete (v); |
| 299 | return -1; |
| 300 | } |
| 301 | else if (route && route->path.cost == v->cost) |
| 302 | { |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 303 | if (IS_OSPF6_DEBUG_SPF (PROCESS)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 304 | zlog_debug (" another path found, merge"); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 305 | |
| 306 | for (i = 0; ospf6_nexthop_is_set (&v->nexthop[i]) && |
| 307 | i < OSPF6_MULTI_PATH_LIMIT; i++) |
| 308 | { |
| 309 | for (j = 0; j < OSPF6_MULTI_PATH_LIMIT; j++) |
| 310 | { |
| 311 | if (ospf6_nexthop_is_set (&route->nexthop[j])) |
| 312 | { |
| 313 | if (ospf6_nexthop_is_same (&route->nexthop[j], |
| 314 | &v->nexthop[i])) |
| 315 | break; |
| 316 | else |
| 317 | continue; |
| 318 | } |
| 319 | ospf6_nexthop_copy (&route->nexthop[j], &v->nexthop[i]); |
| 320 | break; |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | prev = (struct ospf6_vertex *) route->route_option; |
Dmitrij Tejblum | 403138e | 2011-01-13 18:25:40 +0300 | [diff] [blame] | 325 | assert (prev->hops <= v->hops); |
| 326 | ospf6_vertex_delete (v); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 327 | |
| 328 | return -1; |
| 329 | } |
| 330 | |
| 331 | /* There should be no case where candidate being installed (variable |
| 332 | "v") is closer than the one in the SPF tree (variable "route"). |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 333 | In the case something has gone wrong with the behavior of |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 334 | Priority-Queue. */ |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 335 | |
| 336 | /* the case where the route exists already is handled and returned |
| 337 | up to here. */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 338 | assert (route == NULL); |
| 339 | |
| 340 | route = ospf6_route_create (); |
| 341 | memcpy (&route->prefix, &v->vertex_id, sizeof (struct prefix)); |
| 342 | route->type = OSPF6_DEST_TYPE_LINKSTATE; |
| 343 | route->path.type = OSPF6_PATH_TYPE_INTRA; |
| 344 | route->path.origin.type = v->lsa->header->type; |
| 345 | route->path.origin.id = v->lsa->header->id; |
| 346 | route->path.origin.adv_router = v->lsa->header->adv_router; |
| 347 | route->path.metric_type = 1; |
| 348 | route->path.cost = v->cost; |
| 349 | route->path.cost_e2 = v->hops; |
| 350 | route->path.router_bits = v->capability; |
| 351 | route->path.options[0] = v->options[0]; |
| 352 | route->path.options[1] = v->options[1]; |
| 353 | route->path.options[2] = v->options[2]; |
| 354 | |
| 355 | for (i = 0; ospf6_nexthop_is_set (&v->nexthop[i]) && |
| 356 | i < OSPF6_MULTI_PATH_LIMIT; i++) |
| 357 | ospf6_nexthop_copy (&route->nexthop[i], &v->nexthop[i]); |
| 358 | |
| 359 | if (v->parent) |
| 360 | listnode_add_sort (v->parent->child_list, v); |
| 361 | route->route_option = v; |
| 362 | |
| 363 | ospf6_route_add (route, result_table); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 364 | return 0; |
| 365 | } |
| 366 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 367 | void |
| 368 | ospf6_spf_table_finish (struct ospf6_route_table *result_table) |
| 369 | { |
| 370 | struct ospf6_route *route; |
| 371 | struct ospf6_vertex *v; |
| 372 | for (route = ospf6_route_head (result_table); route; |
| 373 | route = ospf6_route_next (route)) |
| 374 | { |
| 375 | v = (struct ospf6_vertex *) route->route_option; |
| 376 | ospf6_vertex_delete (v); |
| 377 | ospf6_route_remove (route, result_table); |
| 378 | } |
| 379 | } |
| 380 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 381 | /* RFC2328 16.1. Calculating the shortest-path tree for an area */ |
| 382 | /* RFC2740 3.8.1. Calculating the shortest path tree for an area */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 383 | void |
| 384 | ospf6_spf_calculation (u_int32_t router_id, |
| 385 | struct ospf6_route_table *result_table, |
| 386 | struct ospf6_area *oa) |
| 387 | { |
| 388 | struct pqueue *candidate_list; |
| 389 | struct ospf6_vertex *root, *v, *w; |
| 390 | int i; |
| 391 | int size; |
| 392 | caddr_t lsdesc; |
| 393 | struct ospf6_lsa *lsa; |
| 394 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 395 | /* Install the calculating router itself as the root of the SPF tree */ |
| 396 | /* construct root vertex */ |
| 397 | lsa = ospf6_lsdb_lookup (htons (OSPF6_LSTYPE_ROUTER), htonl (0), |
| 398 | router_id, oa->lsdb); |
| 399 | if (lsa == NULL) |
| 400 | return; |
Tom Goff | 1d19234 | 2010-11-10 13:02:38 -0800 | [diff] [blame] | 401 | |
| 402 | /* initialize */ |
| 403 | candidate_list = pqueue_create (); |
| 404 | candidate_list->cmp = ospf6_vertex_cmp; |
| 405 | |
| 406 | ospf6_spf_table_finish (result_table); |
| 407 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 408 | root = ospf6_vertex_create (lsa); |
| 409 | root->area = oa; |
| 410 | root->cost = 0; |
| 411 | root->hops = 0; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 412 | root->nexthop[0].ifindex = 0; /* loopbak I/F is better ... */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 413 | inet_pton (AF_INET6, "::1", &root->nexthop[0].address); |
| 414 | |
| 415 | /* Actually insert root to the candidate-list as the only candidate */ |
| 416 | pqueue_enqueue (root, candidate_list); |
| 417 | |
| 418 | /* Iterate until candidate-list becomes empty */ |
| 419 | while (candidate_list->size) |
| 420 | { |
| 421 | /* get closest candidate from priority queue */ |
| 422 | v = pqueue_dequeue (candidate_list); |
| 423 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 424 | /* installing may result in merging or rejecting of the vertex */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 425 | if (ospf6_spf_install (v, result_table) < 0) |
| 426 | continue; |
| 427 | |
| 428 | /* For each LS description in the just-added vertex V's LSA */ |
| 429 | size = (VERTEX_IS_TYPE (ROUTER, v) ? |
| 430 | sizeof (struct ospf6_router_lsdesc) : |
| 431 | sizeof (struct ospf6_network_lsdesc)); |
| 432 | for (lsdesc = OSPF6_LSA_HEADER_END (v->lsa->header) + 4; |
| 433 | lsdesc + size <= OSPF6_LSA_END (v->lsa->header); lsdesc += size) |
| 434 | { |
| 435 | lsa = ospf6_lsdesc_lsa (lsdesc, v); |
| 436 | if (lsa == NULL) |
| 437 | continue; |
| 438 | |
| 439 | if (! ospf6_lsdesc_backlink (lsa, lsdesc, v)) |
| 440 | continue; |
| 441 | |
| 442 | w = ospf6_vertex_create (lsa); |
| 443 | w->area = oa; |
| 444 | w->parent = v; |
| 445 | if (VERTEX_IS_TYPE (ROUTER, v)) |
| 446 | { |
| 447 | w->cost = v->cost + ROUTER_LSDESC_GET_METRIC (lsdesc); |
| 448 | w->hops = v->hops + (VERTEX_IS_TYPE (NETWORK, w) ? 0 : 1); |
| 449 | } |
| 450 | else /* NETWORK */ |
| 451 | { |
| 452 | w->cost = v->cost; |
| 453 | w->hops = v->hops + 1; |
| 454 | } |
| 455 | |
| 456 | /* nexthop calculation */ |
| 457 | if (w->hops == 0) |
| 458 | w->nexthop[0].ifindex = ROUTER_LSDESC_GET_IFID (lsdesc); |
| 459 | else if (w->hops == 1 && v->hops == 0) |
| 460 | ospf6_nexthop_calc (w, v, lsdesc); |
| 461 | else |
| 462 | { |
| 463 | for (i = 0; ospf6_nexthop_is_set (&v->nexthop[i]) && |
| 464 | i < OSPF6_MULTI_PATH_LIMIT; i++) |
| 465 | ospf6_nexthop_copy (&w->nexthop[i], &v->nexthop[i]); |
| 466 | } |
| 467 | |
| 468 | /* add new candidate to the candidate_list */ |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 469 | if (IS_OSPF6_DEBUG_SPF (PROCESS)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 470 | zlog_debug (" New candidate: %s hops %d cost %d", |
| 471 | w->name, w->hops, w->cost); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 472 | pqueue_enqueue (w, candidate_list); |
| 473 | } |
| 474 | } |
| 475 | |
| 476 | pqueue_delete (candidate_list); |
| 477 | } |
| 478 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 479 | static void |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 480 | ospf6_spf_log_database (struct ospf6_area *oa) |
| 481 | { |
| 482 | char *p, *end, buffer[256]; |
| 483 | struct listnode *node; |
| 484 | struct ospf6_interface *oi; |
| 485 | |
| 486 | p = buffer; |
| 487 | end = buffer + sizeof (buffer); |
| 488 | |
| 489 | snprintf (p, end - p, "SPF on DB (#LSAs):"); |
| 490 | p = (buffer + strlen (buffer) < end ? buffer + strlen (buffer) : end); |
| 491 | snprintf (p, end - p, " Area %s: %d", oa->name, oa->lsdb->count); |
| 492 | p = (buffer + strlen (buffer) < end ? buffer + strlen (buffer) : end); |
| 493 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 494 | for (ALL_LIST_ELEMENTS_RO (oa->if_list, node, oi)) |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 495 | { |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 496 | snprintf (p, end - p, " I/F %s: %d", |
| 497 | oi->interface->name, oi->lsdb->count); |
| 498 | p = (buffer + strlen (buffer) < end ? buffer + strlen (buffer) : end); |
| 499 | } |
| 500 | |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 501 | zlog_debug ("%s", buffer); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 502 | } |
| 503 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 504 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 505 | ospf6_spf_calculation_thread (struct thread *t) |
| 506 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 507 | struct ospf6_area *oa; |
| 508 | struct timeval start, end, runtime; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 509 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 510 | oa = (struct ospf6_area *) THREAD_ARG (t); |
| 511 | oa->thread_spf_calculation = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 512 | |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 513 | if (IS_OSPF6_DEBUG_SPF (PROCESS)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 514 | zlog_debug ("SPF calculation for Area %s", oa->name); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 515 | if (IS_OSPF6_DEBUG_SPF (DATABASE)) |
| 516 | ospf6_spf_log_database (oa); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 517 | |
| 518 | /* execute SPF calculation */ |
Takashi Sogabe | 86f72dc | 2009-06-22 13:07:02 +0900 | [diff] [blame] | 519 | quagga_gettime (QUAGGA_CLK_MONOTONIC, &start); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 520 | ospf6_spf_calculation (oa->ospf6->router_id, oa->spf_table, oa); |
Takashi Sogabe | 86f72dc | 2009-06-22 13:07:02 +0900 | [diff] [blame] | 521 | quagga_gettime (QUAGGA_CLK_MONOTONIC, &end); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 522 | timersub (&end, &start, &runtime); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 523 | |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 524 | if (IS_OSPF6_DEBUG_SPF (PROCESS) || IS_OSPF6_DEBUG_SPF (TIME)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 525 | zlog_debug ("SPF runtime: %ld sec %ld usec", |
| 526 | runtime.tv_sec, runtime.tv_usec); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 527 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 528 | ospf6_intra_route_calculation (oa); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 529 | ospf6_intra_brouter_calculation (oa); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 530 | |
| 531 | return 0; |
| 532 | } |
| 533 | |
| 534 | void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 535 | ospf6_spf_schedule (struct ospf6_area *oa) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 536 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 537 | if (oa->thread_spf_calculation) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 538 | return; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 539 | oa->thread_spf_calculation = |
| 540 | thread_add_event (master, ospf6_spf_calculation_thread, oa, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 541 | } |
| 542 | |
| 543 | void |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 544 | ospf6_spf_display_subtree (struct vty *vty, const char *prefix, int rest, |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 545 | struct ospf6_vertex *v) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 546 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 547 | struct listnode *node, *nnode; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 548 | struct ospf6_vertex *c; |
| 549 | char *next_prefix; |
| 550 | int len; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 551 | int restnum; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 552 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 553 | /* "prefix" is the space prefix of the display line */ |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 554 | vty_out (vty, "%s+-%s [%d]%s", prefix, v->name, v->cost, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 555 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 556 | len = strlen (prefix) + 4; |
| 557 | next_prefix = (char *) malloc (len); |
| 558 | if (next_prefix == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 559 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 560 | vty_out (vty, "malloc failed%s", VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 561 | return; |
| 562 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 563 | snprintf (next_prefix, len, "%s%s", prefix, (rest ? "| " : " ")); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 564 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 565 | restnum = listcount (v->child_list); |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 566 | for (ALL_LIST_ELEMENTS (v->child_list, node, nnode, c)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 567 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 568 | restnum--; |
| 569 | ospf6_spf_display_subtree (vty, next_prefix, restnum, c); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 570 | } |
| 571 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 572 | free (next_prefix); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 573 | } |
| 574 | |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 575 | DEFUN (debug_ospf6_spf_process, |
| 576 | debug_ospf6_spf_process_cmd, |
| 577 | "debug ospf6 spf process", |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 578 | DEBUG_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 579 | OSPF6_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 580 | "Debug SPF Calculation\n" |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 581 | "Debug Detailed SPF Process\n" |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 582 | ) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 583 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 584 | unsigned char level = 0; |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 585 | level = OSPF6_DEBUG_SPF_PROCESS; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 586 | OSPF6_DEBUG_SPF_ON (level); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 587 | return CMD_SUCCESS; |
| 588 | } |
| 589 | |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 590 | DEFUN (debug_ospf6_spf_time, |
| 591 | debug_ospf6_spf_time_cmd, |
| 592 | "debug ospf6 spf time", |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 593 | DEBUG_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 594 | OSPF6_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 595 | "Debug SPF Calculation\n" |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 596 | "Measure time taken by SPF Calculation\n" |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 597 | ) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 598 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 599 | unsigned char level = 0; |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 600 | level = OSPF6_DEBUG_SPF_TIME; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 601 | OSPF6_DEBUG_SPF_ON (level); |
| 602 | return CMD_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 603 | } |
| 604 | |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 605 | DEFUN (debug_ospf6_spf_database, |
| 606 | debug_ospf6_spf_database_cmd, |
| 607 | "debug ospf6 spf database", |
| 608 | DEBUG_STR |
| 609 | OSPF6_STR |
| 610 | "Debug SPF Calculation\n" |
| 611 | "Log number of LSAs at SPF Calculation time\n" |
| 612 | ) |
| 613 | { |
| 614 | unsigned char level = 0; |
| 615 | level = OSPF6_DEBUG_SPF_DATABASE; |
| 616 | OSPF6_DEBUG_SPF_ON (level); |
| 617 | return CMD_SUCCESS; |
| 618 | } |
| 619 | |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 620 | DEFUN (no_debug_ospf6_spf_process, |
| 621 | no_debug_ospf6_spf_process_cmd, |
| 622 | "no debug ospf6 spf process", |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 623 | NO_STR |
| 624 | DEBUG_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 625 | OSPF6_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 626 | "Quit Debugging SPF Calculation\n" |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 627 | "Quit Debugging Detailed SPF Process\n" |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 628 | ) |
| 629 | { |
| 630 | unsigned char level = 0; |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 631 | level = OSPF6_DEBUG_SPF_PROCESS; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 632 | OSPF6_DEBUG_SPF_OFF (level); |
| 633 | return CMD_SUCCESS; |
| 634 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 635 | |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 636 | DEFUN (no_debug_ospf6_spf_time, |
| 637 | no_debug_ospf6_spf_time_cmd, |
| 638 | "no debug ospf6 spf time", |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 639 | NO_STR |
| 640 | DEBUG_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 641 | OSPF6_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 642 | "Quit Debugging SPF Calculation\n" |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 643 | "Quit Measuring time taken by SPF Calculation\n" |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 644 | ) |
| 645 | { |
| 646 | unsigned char level = 0; |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 647 | level = OSPF6_DEBUG_SPF_TIME; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 648 | OSPF6_DEBUG_SPF_OFF (level); |
| 649 | return CMD_SUCCESS; |
| 650 | } |
| 651 | |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 652 | DEFUN (no_debug_ospf6_spf_database, |
| 653 | no_debug_ospf6_spf_database_cmd, |
| 654 | "no debug ospf6 spf database", |
| 655 | NO_STR |
| 656 | DEBUG_STR |
| 657 | OSPF6_STR |
| 658 | "Debug SPF Calculation\n" |
| 659 | "Quit Logging number of LSAs at SPF Calculation time\n" |
| 660 | ) |
| 661 | { |
| 662 | unsigned char level = 0; |
| 663 | level = OSPF6_DEBUG_SPF_DATABASE; |
| 664 | OSPF6_DEBUG_SPF_OFF (level); |
| 665 | return CMD_SUCCESS; |
| 666 | } |
| 667 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 668 | int |
| 669 | config_write_ospf6_debug_spf (struct vty *vty) |
| 670 | { |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 671 | if (IS_OSPF6_DEBUG_SPF (PROCESS)) |
| 672 | vty_out (vty, "debug ospf6 spf process%s", VNL); |
| 673 | if (IS_OSPF6_DEBUG_SPF (TIME)) |
| 674 | vty_out (vty, "debug ospf6 spf time%s", VNL); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 675 | if (IS_OSPF6_DEBUG_SPF (DATABASE)) |
| 676 | vty_out (vty, "debug ospf6 spf database%s", VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 677 | return 0; |
| 678 | } |
| 679 | |
| 680 | void |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 681 | install_element_ospf6_debug_spf (void) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 682 | { |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 683 | install_element (ENABLE_NODE, &debug_ospf6_spf_process_cmd); |
| 684 | install_element (ENABLE_NODE, &debug_ospf6_spf_time_cmd); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 685 | install_element (ENABLE_NODE, &debug_ospf6_spf_database_cmd); |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 686 | install_element (ENABLE_NODE, &no_debug_ospf6_spf_process_cmd); |
| 687 | install_element (ENABLE_NODE, &no_debug_ospf6_spf_time_cmd); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 688 | install_element (ENABLE_NODE, &no_debug_ospf6_spf_database_cmd); |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 689 | install_element (CONFIG_NODE, &debug_ospf6_spf_process_cmd); |
| 690 | install_element (CONFIG_NODE, &debug_ospf6_spf_time_cmd); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 691 | install_element (CONFIG_NODE, &debug_ospf6_spf_database_cmd); |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 692 | install_element (CONFIG_NODE, &no_debug_ospf6_spf_process_cmd); |
| 693 | install_element (CONFIG_NODE, &no_debug_ospf6_spf_time_cmd); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 694 | install_element (CONFIG_NODE, &no_debug_ospf6_spf_database_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 695 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 696 | |
| 697 | void |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 698 | ospf6_spf_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 699 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 700 | } |
| 701 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 702 | |