jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * IS-IS Rout(e)ing protocol - isis_route.c |
| 3 | * Copyright (C) 2001,2002 Sampo Saaristo |
| 4 | * Tampere University of Technology |
| 5 | * Institute of Communications Engineering |
| 6 | * |
| 7 | * based on ../ospf6d/ospf6_route.[ch] |
| 8 | * by Yasuhiro Ohara |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify it |
| 11 | * under the terms of the GNU General Public Licenseas published by the Free |
| 12 | * Software Foundation; either version 2 of the License, or (at your option) |
| 13 | * any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful,but WITHOUT |
| 16 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 18 | * more details. |
| 19 | |
| 20 | * You should have received a copy of the GNU General Public License along |
| 21 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 22 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 23 | */ |
| 24 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 25 | #include <zebra.h> |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 26 | |
| 27 | #include "thread.h" |
| 28 | #include "linklist.h" |
| 29 | #include "vty.h" |
| 30 | #include "log.h" |
| 31 | #include "memory.h" |
| 32 | #include "prefix.h" |
| 33 | #include "hash.h" |
| 34 | #include "if.h" |
| 35 | #include "table.h" |
| 36 | |
| 37 | #include "isis_constants.h" |
| 38 | #include "isis_common.h" |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 39 | #include "isis_flags.h" |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 40 | #include "dict.h" |
| 41 | #include "isisd.h" |
| 42 | #include "isis_misc.h" |
| 43 | #include "isis_adjacency.h" |
| 44 | #include "isis_circuit.h" |
| 45 | #include "isis_tlv.h" |
| 46 | #include "isis_pdu.h" |
| 47 | #include "isis_lsp.h" |
| 48 | #include "isis_spf.h" |
| 49 | #include "isis_route.h" |
| 50 | #include "isis_zebra.h" |
| 51 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 52 | static struct isis_nexthop * |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 53 | isis_nexthop_create (struct in_addr *ip, unsigned int ifindex) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 54 | { |
| 55 | struct listnode *node; |
| 56 | struct isis_nexthop *nexthop; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 57 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 58 | for (ALL_LIST_ELEMENTS_RO (isis->nexthops, node, nexthop)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 59 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 60 | if (nexthop->ifindex != ifindex) |
| 61 | continue; |
| 62 | if (ip && memcmp (&nexthop->ip, ip, sizeof (struct in_addr)) != 0) |
| 63 | continue; |
| 64 | |
| 65 | nexthop->lock++; |
| 66 | return nexthop; |
| 67 | } |
| 68 | |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 69 | nexthop = XCALLOC (MTYPE_ISIS_NEXTHOP, sizeof (struct isis_nexthop)); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 70 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 71 | nexthop->ifindex = ifindex; |
| 72 | memcpy (&nexthop->ip, ip, sizeof (struct in_addr)); |
| 73 | listnode_add (isis->nexthops, nexthop); |
| 74 | nexthop->lock++; |
| 75 | |
| 76 | return nexthop; |
| 77 | } |
| 78 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 79 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 80 | isis_nexthop_delete (struct isis_nexthop *nexthop) |
| 81 | { |
| 82 | nexthop->lock--; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 83 | if (nexthop->lock == 0) |
| 84 | { |
| 85 | listnode_delete (isis->nexthops, nexthop); |
| 86 | XFREE (MTYPE_ISIS_NEXTHOP, nexthop); |
| 87 | } |
| 88 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 89 | return; |
| 90 | } |
| 91 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 92 | static int |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 93 | nexthoplookup (struct list *nexthops, struct in_addr *ip, |
| 94 | unsigned int ifindex) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 95 | { |
| 96 | struct listnode *node; |
| 97 | struct isis_nexthop *nh; |
| 98 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 99 | for (ALL_LIST_ELEMENTS_RO (nexthops, node, nh)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 100 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 101 | if (!(memcmp (ip, &nh->ip, sizeof (struct in_addr))) && |
| 102 | ifindex == nh->ifindex) |
| 103 | return 1; |
| 104 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 105 | |
| 106 | return 0; |
| 107 | } |
| 108 | |
hasso | 3d54927 | 2005-09-21 18:52:14 +0000 | [diff] [blame] | 109 | #ifdef EXTREME_DEBUG |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 110 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 111 | nexthop_print (struct isis_nexthop *nh) |
| 112 | { |
| 113 | u_char buf[BUFSIZ]; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 114 | |
hasso | f7c43dc | 2004-09-26 16:24:14 +0000 | [diff] [blame] | 115 | inet_ntop (AF_INET, &nh->ip, (char *) buf, BUFSIZ); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 116 | |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 117 | zlog_debug (" %s %u", buf, nh->ifindex); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 118 | } |
| 119 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 120 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 121 | nexthops_print (struct list *nhs) |
| 122 | { |
| 123 | struct listnode *node; |
hasso | 13fb40a | 2005-10-01 06:03:04 +0000 | [diff] [blame] | 124 | struct isis_nexthop *nh; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 125 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 126 | for (ALL_LIST_ELEMENTS_RO (nhs, node, nh)) |
| 127 | nexthop_print (nh); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 128 | } |
hasso | 3d54927 | 2005-09-21 18:52:14 +0000 | [diff] [blame] | 129 | #endif /* EXTREME_DEBUG */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 130 | |
| 131 | #ifdef HAVE_IPV6 |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 132 | static struct isis_nexthop6 * |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 133 | isis_nexthop6_new (struct in6_addr *ip6, unsigned int ifindex) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 134 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 135 | struct isis_nexthop6 *nexthop6; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 136 | |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 137 | nexthop6 = XCALLOC (MTYPE_ISIS_NEXTHOP6, sizeof (struct isis_nexthop6)); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 138 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 139 | nexthop6->ifindex = ifindex; |
| 140 | memcpy (&nexthop6->ip6, ip6, sizeof (struct in6_addr)); |
| 141 | nexthop6->lock++; |
| 142 | |
| 143 | return nexthop6; |
| 144 | } |
| 145 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 146 | static struct isis_nexthop6 * |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 147 | isis_nexthop6_create (struct in6_addr *ip6, unsigned int ifindex) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 148 | { |
| 149 | struct listnode *node; |
| 150 | struct isis_nexthop6 *nexthop6; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 151 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 152 | for (ALL_LIST_ELEMENTS_RO (isis->nexthops6, node, nexthop6)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 153 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 154 | if (nexthop6->ifindex != ifindex) |
| 155 | continue; |
| 156 | if (ip6 && memcmp (&nexthop6->ip6, ip6, sizeof (struct in6_addr)) != 0) |
| 157 | continue; |
| 158 | |
| 159 | nexthop6->lock++; |
| 160 | return nexthop6; |
| 161 | } |
| 162 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 163 | nexthop6 = isis_nexthop6_new (ip6, ifindex); |
| 164 | |
| 165 | return nexthop6; |
| 166 | } |
| 167 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 168 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 169 | isis_nexthop6_delete (struct isis_nexthop6 *nexthop6) |
| 170 | { |
| 171 | |
| 172 | nexthop6->lock--; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 173 | if (nexthop6->lock == 0) |
| 174 | { |
| 175 | listnode_delete (isis->nexthops6, nexthop6); |
| 176 | XFREE (MTYPE_ISIS_NEXTHOP6, nexthop6); |
| 177 | } |
| 178 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 179 | return; |
| 180 | } |
| 181 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 182 | static int |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 183 | nexthop6lookup (struct list *nexthops6, struct in6_addr *ip6, |
| 184 | unsigned int ifindex) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 185 | { |
| 186 | struct listnode *node; |
| 187 | struct isis_nexthop6 *nh6; |
| 188 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 189 | for (ALL_LIST_ELEMENTS_RO (nexthops6, node, nh6)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 190 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 191 | if (!(memcmp (ip6, &nh6->ip6, sizeof (struct in6_addr))) && |
| 192 | ifindex == nh6->ifindex) |
| 193 | return 1; |
| 194 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 195 | |
| 196 | return 0; |
| 197 | } |
| 198 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 199 | #ifdef EXTREME_DEBUG |
| 200 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 201 | nexthop6_print (struct isis_nexthop6 *nh6) |
| 202 | { |
| 203 | u_char buf[BUFSIZ]; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 204 | |
hasso | f7c43dc | 2004-09-26 16:24:14 +0000 | [diff] [blame] | 205 | inet_ntop (AF_INET6, &nh6->ip6, (char *) buf, BUFSIZ); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 206 | |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 207 | zlog_debug (" %s %u", buf, nh6->ifindex); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 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 | nexthops6_print (struct list *nhs6) |
| 212 | { |
| 213 | struct listnode *node; |
jardin | 10fc918 | 2005-10-01 00:09:39 +0000 | [diff] [blame] | 214 | struct isis_nexthop6 *nh6; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 215 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 216 | for (ALL_LIST_ELEMENTS_RO (nhs6, node, nh6)) |
| 217 | nexthop6_print (nh6); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 218 | } |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 219 | #endif /* EXTREME_DEBUG */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 220 | #endif /* HAVE_IPV6 */ |
| 221 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 222 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 223 | adjinfo2nexthop (struct list *nexthops, struct isis_adjacency *adj) |
| 224 | { |
| 225 | struct isis_nexthop *nh; |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 226 | struct listnode *node; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 227 | struct in_addr *ipv4_addr; |
| 228 | |
| 229 | if (adj->ipv4_addrs == NULL) |
| 230 | return; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 231 | |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 232 | for (ALL_LIST_ELEMENTS_RO (adj->ipv4_addrs, node, ipv4_addr)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 233 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 234 | if (!nexthoplookup (nexthops, ipv4_addr, |
| 235 | adj->circuit->interface->ifindex)) |
| 236 | { |
| 237 | nh = isis_nexthop_create (ipv4_addr, |
| 238 | adj->circuit->interface->ifindex); |
Subbaiah Venkata | e38e0df | 2012-03-27 23:48:05 -0700 | [diff] [blame] | 239 | nh->router_address = adj->router_address; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 240 | listnode_add (nexthops, nh); |
| 241 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 242 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | #ifdef HAVE_IPV6 |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 246 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 247 | adjinfo2nexthop6 (struct list *nexthops6, struct isis_adjacency *adj) |
| 248 | { |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 249 | struct listnode *node; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 250 | struct in6_addr *ipv6_addr; |
| 251 | struct isis_nexthop6 *nh6; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 252 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 253 | if (!adj->ipv6_addrs) |
| 254 | return; |
| 255 | |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 256 | for (ALL_LIST_ELEMENTS_RO (adj->ipv6_addrs, node, ipv6_addr)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 257 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 258 | if (!nexthop6lookup (nexthops6, ipv6_addr, |
| 259 | adj->circuit->interface->ifindex)) |
| 260 | { |
| 261 | nh6 = isis_nexthop6_create (ipv6_addr, |
| 262 | adj->circuit->interface->ifindex); |
Subbaiah Venkata | e38e0df | 2012-03-27 23:48:05 -0700 | [diff] [blame] | 263 | nh6->router_address6 = adj->router_address6; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 264 | listnode_add (nexthops6, nh6); |
| 265 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 266 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 267 | } |
| 268 | #endif /* HAVE_IPV6 */ |
| 269 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 270 | static struct isis_route_info * |
Subbaiah Venkata | e38e0df | 2012-03-27 23:48:05 -0700 | [diff] [blame] | 271 | isis_route_info_new (struct prefix *prefix, uint32_t cost, uint32_t depth, |
| 272 | struct list *adjacencies) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 273 | { |
| 274 | struct isis_route_info *rinfo; |
| 275 | struct isis_adjacency *adj; |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 276 | struct listnode *node; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 277 | |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 278 | rinfo = XCALLOC (MTYPE_ISIS_ROUTE_INFO, sizeof (struct isis_route_info)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 279 | |
Subbaiah Venkata | e38e0df | 2012-03-27 23:48:05 -0700 | [diff] [blame] | 280 | if (prefix->family == AF_INET) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 281 | { |
| 282 | rinfo->nexthops = list_new (); |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 283 | for (ALL_LIST_ELEMENTS_RO (adjacencies, node, adj)) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 284 | { |
| 285 | /* check for force resync this route */ |
| 286 | if (CHECK_FLAG (adj->circuit->flags, ISIS_CIRCUIT_FLAPPED_AFTER_SPF)) |
| 287 | SET_FLAG (rinfo->flag, ISIS_ROUTE_FLAG_ZEBRA_RESYNC); |
Subbaiah Venkata | e38e0df | 2012-03-27 23:48:05 -0700 | [diff] [blame] | 288 | /* update neighbor router address */ |
| 289 | if (depth == 2 && prefix->prefixlen == 32) |
| 290 | adj->router_address = prefix->u.prefix4; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 291 | adjinfo2nexthop (rinfo->nexthops, adj); |
| 292 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 293 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 294 | #ifdef HAVE_IPV6 |
Subbaiah Venkata | e38e0df | 2012-03-27 23:48:05 -0700 | [diff] [blame] | 295 | if (prefix->family == AF_INET6) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 296 | { |
| 297 | rinfo->nexthops6 = list_new (); |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 298 | for (ALL_LIST_ELEMENTS_RO (adjacencies, node, adj)) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 299 | { |
| 300 | /* check for force resync this route */ |
| 301 | if (CHECK_FLAG (adj->circuit->flags, ISIS_CIRCUIT_FLAPPED_AFTER_SPF)) |
| 302 | SET_FLAG (rinfo->flag, ISIS_ROUTE_FLAG_ZEBRA_RESYNC); |
Subbaiah Venkata | e38e0df | 2012-03-27 23:48:05 -0700 | [diff] [blame] | 303 | /* update neighbor router address */ |
| 304 | if (depth == 2 && prefix->prefixlen == 128) |
| 305 | adj->router_address6 = prefix->u.prefix6; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 306 | adjinfo2nexthop6 (rinfo->nexthops6, adj); |
| 307 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 308 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 309 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 310 | #endif /* HAVE_IPV6 */ |
| 311 | |
| 312 | rinfo->cost = cost; |
| 313 | rinfo->depth = depth; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 314 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 315 | return rinfo; |
| 316 | } |
| 317 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 318 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 319 | isis_route_info_delete (struct isis_route_info *route_info) |
| 320 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 321 | if (route_info->nexthops) |
| 322 | { |
hasso | f7c43dc | 2004-09-26 16:24:14 +0000 | [diff] [blame] | 323 | route_info->nexthops->del = (void (*)(void *)) isis_nexthop_delete; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 324 | list_delete (route_info->nexthops); |
| 325 | } |
| 326 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 327 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 328 | if (route_info->nexthops6) |
| 329 | { |
hasso | f7c43dc | 2004-09-26 16:24:14 +0000 | [diff] [blame] | 330 | route_info->nexthops6->del = (void (*)(void *)) isis_nexthop6_delete; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 331 | list_delete (route_info->nexthops6); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 332 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 333 | #endif /* HAVE_IPV6 */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 334 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 335 | XFREE (MTYPE_ISIS_ROUTE_INFO, route_info); |
| 336 | } |
| 337 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 338 | static int |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 339 | isis_route_info_same_attrib (struct isis_route_info *new, |
| 340 | struct isis_route_info *old) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 341 | { |
| 342 | if (new->cost != old->cost) |
| 343 | return 0; |
| 344 | if (new->depth != old->depth) |
| 345 | return 0; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 346 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 347 | return 1; |
| 348 | } |
| 349 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 350 | static int |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 351 | isis_route_info_same (struct isis_route_info *new, |
| 352 | struct isis_route_info *old, u_char family) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 353 | { |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 354 | struct listnode *node; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 355 | struct isis_nexthop *nexthop; |
| 356 | #ifdef HAVE_IPV6 |
| 357 | struct isis_nexthop6 *nexthop6; |
| 358 | #endif /* HAVE_IPV6 */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 359 | |
| 360 | if (!CHECK_FLAG (old->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED)) |
| 361 | return 0; |
| 362 | |
| 363 | if (CHECK_FLAG (new->flag, ISIS_ROUTE_FLAG_ZEBRA_RESYNC)) |
| 364 | return 0; |
| 365 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 366 | if (!isis_route_info_same_attrib (new, old)) |
| 367 | return 0; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 368 | |
| 369 | if (family == AF_INET) |
| 370 | { |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 371 | for (ALL_LIST_ELEMENTS_RO (new->nexthops, node, nexthop)) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 372 | if (nexthoplookup (old->nexthops, &nexthop->ip, nexthop->ifindex) |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 373 | == 0) |
| 374 | return 0; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 375 | |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 376 | for (ALL_LIST_ELEMENTS_RO (old->nexthops, node, nexthop)) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 377 | if (nexthoplookup (new->nexthops, &nexthop->ip, nexthop->ifindex) |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 378 | == 0) |
| 379 | return 0; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 380 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 381 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 382 | else if (family == AF_INET6) |
| 383 | { |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 384 | for (ALL_LIST_ELEMENTS_RO (new->nexthops6, node, nexthop6)) |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 385 | if (nexthop6lookup (old->nexthops6, &nexthop6->ip6, |
| 386 | nexthop6->ifindex) == 0) |
| 387 | return 0; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 388 | |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 389 | for (ALL_LIST_ELEMENTS_RO (old->nexthops6, node, nexthop6)) |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 390 | if (nexthop6lookup (new->nexthops6, &nexthop6->ip6, |
| 391 | nexthop6->ifindex) == 0) |
| 392 | return 0; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 393 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 394 | #endif /* HAVE_IPV6 */ |
| 395 | |
| 396 | return 1; |
| 397 | } |
| 398 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 399 | struct isis_route_info * |
| 400 | isis_route_create (struct prefix *prefix, u_int32_t cost, u_int32_t depth, |
hasso | fac1f7c | 2005-09-26 18:26:26 +0000 | [diff] [blame] | 401 | struct list *adjacencies, struct isis_area *area, |
| 402 | int level) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 403 | { |
| 404 | struct route_node *route_node; |
| 405 | struct isis_route_info *rinfo_new, *rinfo_old, *route_info = NULL; |
| 406 | u_char buff[BUFSIZ]; |
| 407 | u_char family; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 408 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 409 | family = prefix->family; |
| 410 | /* for debugs */ |
hasso | f7c43dc | 2004-09-26 16:24:14 +0000 | [diff] [blame] | 411 | prefix2str (prefix, (char *) buff, BUFSIZ); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 412 | |
Subbaiah Venkata | e38e0df | 2012-03-27 23:48:05 -0700 | [diff] [blame] | 413 | rinfo_new = isis_route_info_new (prefix, cost, depth, adjacencies); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 414 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 415 | if (family == AF_INET) |
hasso | fac1f7c | 2005-09-26 18:26:26 +0000 | [diff] [blame] | 416 | route_node = route_node_get (area->route_table[level - 1], prefix); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 417 | #ifdef HAVE_IPV6 |
| 418 | else if (family == AF_INET6) |
hasso | fac1f7c | 2005-09-26 18:26:26 +0000 | [diff] [blame] | 419 | route_node = route_node_get (area->route_table6[level - 1], prefix); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 420 | #endif /* HAVE_IPV6 */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 421 | else |
David Lamparter | e8aca32 | 2012-11-27 01:10:30 +0000 | [diff] [blame] | 422 | { |
| 423 | isis_route_info_delete (rinfo_new); |
| 424 | return NULL; |
| 425 | } |
| 426 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 427 | rinfo_old = route_node->info; |
| 428 | if (!rinfo_old) |
| 429 | { |
| 430 | if (isis->debugs & DEBUG_RTE_EVENTS) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 431 | zlog_debug ("ISIS-Rte (%s) route created: %s", area->area_tag, buff); |
| 432 | route_info = rinfo_new; |
| 433 | UNSET_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 434 | } |
| 435 | else |
| 436 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 437 | if (isis->debugs & DEBUG_RTE_EVENTS) |
| 438 | zlog_debug ("ISIS-Rte (%s) route already exists: %s", area->area_tag, |
| 439 | buff); |
| 440 | if (isis_route_info_same (rinfo_new, rinfo_old, family)) |
| 441 | { |
| 442 | if (isis->debugs & DEBUG_RTE_EVENTS) |
| 443 | zlog_debug ("ISIS-Rte (%s) route unchanged: %s", area->area_tag, |
| 444 | buff); |
| 445 | isis_route_info_delete (rinfo_new); |
| 446 | route_info = rinfo_old; |
| 447 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 448 | else |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 449 | { |
| 450 | if (isis->debugs & DEBUG_RTE_EVENTS) |
| 451 | zlog_debug ("ISIS-Rte (%s) route changed: %s", area->area_tag, |
| 452 | buff); |
| 453 | isis_route_info_delete (rinfo_old); |
| 454 | route_info = rinfo_new; |
| 455 | UNSET_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED); |
| 456 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 457 | } |
| 458 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 459 | SET_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ACTIVE); |
| 460 | route_node->info = route_info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 461 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 462 | return route_info; |
| 463 | } |
| 464 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 465 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 466 | isis_route_delete (struct prefix *prefix, struct route_table *table) |
| 467 | { |
| 468 | struct route_node *rode; |
| 469 | struct isis_route_info *rinfo; |
| 470 | char buff[BUFSIZ]; |
| 471 | |
| 472 | /* for log */ |
| 473 | prefix2str (prefix, buff, BUFSIZ); |
| 474 | |
| 475 | |
| 476 | rode = route_node_get (table, prefix); |
| 477 | rinfo = rode->info; |
| 478 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 479 | if (rinfo == NULL) |
| 480 | { |
| 481 | if (isis->debugs & DEBUG_RTE_EVENTS) |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 482 | zlog_debug ("ISIS-Rte: tried to delete non-existant route %s", buff); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 483 | return; |
| 484 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 485 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 486 | if (CHECK_FLAG (rinfo->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 487 | { |
| 488 | UNSET_FLAG (rinfo->flag, ISIS_ROUTE_FLAG_ACTIVE); |
| 489 | if (isis->debugs & DEBUG_RTE_EVENTS) |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 490 | zlog_debug ("ISIS-Rte: route delete %s", buff); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 491 | isis_zebra_route_update (prefix, rinfo); |
| 492 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 493 | isis_route_info_delete (rinfo); |
| 494 | rode->info = NULL; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 495 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 496 | return; |
| 497 | } |
| 498 | |
hasso | fac1f7c | 2005-09-26 18:26:26 +0000 | [diff] [blame] | 499 | /* Validating routes in particular table. */ |
| 500 | static void |
| 501 | isis_route_validate_table (struct isis_area *area, struct route_table *table) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 502 | { |
hasso | fac1f7c | 2005-09-26 18:26:26 +0000 | [diff] [blame] | 503 | struct route_node *rnode, *drnode; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 504 | struct isis_route_info *rinfo; |
| 505 | u_char buff[BUFSIZ]; |
hasso | fac1f7c | 2005-09-26 18:26:26 +0000 | [diff] [blame] | 506 | |
| 507 | for (rnode = route_top (table); rnode; rnode = route_next (rnode)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 508 | { |
hasso | fac1f7c | 2005-09-26 18:26:26 +0000 | [diff] [blame] | 509 | if (rnode->info == NULL) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 510 | continue; |
hasso | fac1f7c | 2005-09-26 18:26:26 +0000 | [diff] [blame] | 511 | rinfo = rnode->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 512 | |
| 513 | if (isis->debugs & DEBUG_RTE_EVENTS) |
| 514 | { |
hasso | fac1f7c | 2005-09-26 18:26:26 +0000 | [diff] [blame] | 515 | prefix2str (&rnode->p, (char *) buff, BUFSIZ); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 516 | zlog_debug ("ISIS-Rte (%s): route validate: %s %s %s %s", |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 517 | area->area_tag, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 518 | (CHECK_FLAG (rinfo->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED) ? |
| 519 | "synced" : "not-synced"), |
| 520 | (CHECK_FLAG (rinfo->flag, ISIS_ROUTE_FLAG_ZEBRA_RESYNC) ? |
| 521 | "resync" : "not-resync"), |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 522 | (CHECK_FLAG (rinfo->flag, ISIS_ROUTE_FLAG_ACTIVE) ? |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 523 | "active" : "inactive"), buff); |
| 524 | } |
| 525 | |
hasso | fac1f7c | 2005-09-26 18:26:26 +0000 | [diff] [blame] | 526 | isis_zebra_route_update (&rnode->p, rinfo); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 527 | if (!CHECK_FLAG (rinfo->flag, ISIS_ROUTE_FLAG_ACTIVE)) |
hasso | fac1f7c | 2005-09-26 18:26:26 +0000 | [diff] [blame] | 528 | { |
| 529 | /* Area is either L1 or L2 => we use level route tables directly for |
| 530 | * validating => no problems with deleting routes. */ |
| 531 | if (area->is_type != IS_LEVEL_1_AND_2) |
| 532 | { |
| 533 | isis_route_delete (&rnode->p, table); |
| 534 | continue; |
| 535 | } |
| 536 | /* If area is L1L2, we work with merge table and therefore must |
| 537 | * delete node from level tables as well before deleting route info. |
| 538 | * FIXME: Is it performance problem? There has to be the better way. |
| 539 | * Like not to deal with it here at all (see the next comment)? */ |
| 540 | if (rnode->p.family == AF_INET) |
| 541 | { |
| 542 | drnode = route_node_get (area->route_table[0], &rnode->p); |
| 543 | if (drnode->info == rnode->info) |
| 544 | drnode->info = NULL; |
| 545 | drnode = route_node_get (area->route_table[1], &rnode->p); |
| 546 | if (drnode->info == rnode->info) |
| 547 | drnode->info = NULL; |
| 548 | } |
Paul Jakma | 41b36e9 | 2006-12-08 01:09:50 +0000 | [diff] [blame] | 549 | |
| 550 | #ifdef HAVE_IPV6 |
hasso | fac1f7c | 2005-09-26 18:26:26 +0000 | [diff] [blame] | 551 | if (rnode->p.family == AF_INET6) |
| 552 | { |
| 553 | drnode = route_node_get (area->route_table6[0], &rnode->p); |
| 554 | if (drnode->info == rnode->info) |
| 555 | drnode->info = NULL; |
| 556 | drnode = route_node_get (area->route_table6[1], &rnode->p); |
| 557 | if (drnode->info == rnode->info) |
| 558 | drnode->info = NULL; |
| 559 | } |
Paul Jakma | 41b36e9 | 2006-12-08 01:09:50 +0000 | [diff] [blame] | 560 | #endif |
hasso | fac1f7c | 2005-09-26 18:26:26 +0000 | [diff] [blame] | 561 | |
| 562 | isis_route_delete (&rnode->p, table); |
| 563 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 564 | } |
hasso | fac1f7c | 2005-09-26 18:26:26 +0000 | [diff] [blame] | 565 | } |
| 566 | |
| 567 | /* Function to validate route tables for L1L2 areas. In this case we can't use |
| 568 | * level route tables directly, we have to merge them at first. L1 routes are |
| 569 | * preferred over the L2 ones. |
| 570 | * |
| 571 | * Merge algorithm is trivial (at least for now). All L1 paths are copied into |
| 572 | * merge table at first, then L2 paths are added if L1 path for same prefix |
| 573 | * doesn't already exists there. |
| 574 | * |
| 575 | * FIXME: Is it right place to do it at all? Maybe we should push both levels |
| 576 | * to the RIB with different zebra route types and let RIB handle this? */ |
| 577 | static void |
| 578 | isis_route_validate_merge (struct isis_area *area, int family) |
| 579 | { |
| 580 | struct route_table *table = NULL; |
| 581 | struct route_table *merge; |
| 582 | struct route_node *rnode, *mrnode; |
| 583 | |
| 584 | merge = route_table_init (); |
| 585 | |
| 586 | if (family == AF_INET) |
| 587 | table = area->route_table[0]; |
Paul Jakma | 41b36e9 | 2006-12-08 01:09:50 +0000 | [diff] [blame] | 588 | #ifdef HAVE_IPV6 |
hasso | fac1f7c | 2005-09-26 18:26:26 +0000 | [diff] [blame] | 589 | else if (family == AF_INET6) |
| 590 | table = area->route_table6[0]; |
Paul Jakma | 41b36e9 | 2006-12-08 01:09:50 +0000 | [diff] [blame] | 591 | #endif |
hasso | fac1f7c | 2005-09-26 18:26:26 +0000 | [diff] [blame] | 592 | |
| 593 | for (rnode = route_top (table); rnode; rnode = route_next (rnode)) |
| 594 | { |
| 595 | if (rnode->info == NULL) |
| 596 | continue; |
| 597 | mrnode = route_node_get (merge, &rnode->p); |
| 598 | mrnode->info = rnode->info; |
| 599 | } |
| 600 | |
| 601 | if (family == AF_INET) |
| 602 | table = area->route_table[1]; |
Paul Jakma | 41b36e9 | 2006-12-08 01:09:50 +0000 | [diff] [blame] | 603 | #ifdef HAVE_IPV6 |
hasso | fac1f7c | 2005-09-26 18:26:26 +0000 | [diff] [blame] | 604 | else if (family == AF_INET6) |
| 605 | table = area->route_table6[1]; |
Paul Jakma | 41b36e9 | 2006-12-08 01:09:50 +0000 | [diff] [blame] | 606 | #endif |
hasso | fac1f7c | 2005-09-26 18:26:26 +0000 | [diff] [blame] | 607 | |
| 608 | for (rnode = route_top (table); rnode; rnode = route_next (rnode)) |
| 609 | { |
| 610 | if (rnode->info == NULL) |
| 611 | continue; |
| 612 | mrnode = route_node_get (merge, &rnode->p); |
| 613 | if (mrnode->info != NULL) |
| 614 | continue; |
| 615 | mrnode->info = rnode->info; |
| 616 | } |
| 617 | |
| 618 | isis_route_validate_table (area, merge); |
| 619 | route_table_finish (merge); |
| 620 | } |
| 621 | |
| 622 | /* Walk through route tables and propagate necessary changes into RIB. In case |
| 623 | * of L1L2 area, level tables have to be merged at first. */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 624 | void |
| 625 | isis_route_validate (struct isis_area *area) |
hasso | fac1f7c | 2005-09-26 18:26:26 +0000 | [diff] [blame] | 626 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 627 | struct listnode *node; |
| 628 | struct isis_circuit *circuit; |
hasso | fac1f7c | 2005-09-26 18:26:26 +0000 | [diff] [blame] | 629 | |
| 630 | if (area->is_type == IS_LEVEL_1) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 631 | isis_route_validate_table (area, area->route_table[0]); |
| 632 | else if (area->is_type == IS_LEVEL_2) |
| 633 | isis_route_validate_table (area, area->route_table[1]); |
| 634 | else |
| 635 | isis_route_validate_merge (area, AF_INET); |
hasso | fac1f7c | 2005-09-26 18:26:26 +0000 | [diff] [blame] | 636 | |
Paul Jakma | 41b36e9 | 2006-12-08 01:09:50 +0000 | [diff] [blame] | 637 | #ifdef HAVE_IPV6 |
hasso | fac1f7c | 2005-09-26 18:26:26 +0000 | [diff] [blame] | 638 | if (area->is_type == IS_LEVEL_1) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 639 | isis_route_validate_table (area, area->route_table6[0]); |
| 640 | else if (area->is_type == IS_LEVEL_2) |
| 641 | isis_route_validate_table (area, area->route_table6[1]); |
| 642 | else |
| 643 | isis_route_validate_merge (area, AF_INET6); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 644 | #endif |
| 645 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 646 | /* walk all circuits and reset any spf specific flags */ |
| 647 | for (ALL_LIST_ELEMENTS_RO (area->circuit_list, node, circuit)) |
| 648 | UNSET_FLAG(circuit->flags, ISIS_CIRCUIT_FLAPPED_AFTER_SPF); |
| 649 | |
| 650 | return; |
| 651 | } |
| 652 | |
| 653 | void |
| 654 | isis_route_invalidate_table (struct isis_area *area, struct route_table *table) |
| 655 | { |
| 656 | struct route_node *rode; |
| 657 | struct isis_route_info *rinfo; |
| 658 | for (rode = route_top (table); rode; rode = route_next (rode)) |
| 659 | { |
| 660 | if (rode->info == NULL) |
| 661 | continue; |
| 662 | rinfo = rode->info; |
| 663 | |
| 664 | UNSET_FLAG (rinfo->flag, ISIS_ROUTE_FLAG_ACTIVE); |
| 665 | } |
| 666 | } |
| 667 | |
| 668 | void |
| 669 | isis_route_invalidate (struct isis_area *area) |
| 670 | { |
| 671 | if (area->is_type & IS_LEVEL_1) |
| 672 | isis_route_invalidate_table (area, area->route_table[0]); |
| 673 | if (area->is_type & IS_LEVEL_2) |
| 674 | isis_route_invalidate_table (area, area->route_table[1]); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 675 | } |