hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Area Border Router function. |
| 3 | * Copyright (C) 2004 Yasuhiro Ohara |
| 4 | * |
| 5 | * This file is part of GNU Zebra. |
| 6 | * |
| 7 | * GNU Zebra is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License as published by the |
| 9 | * Free Software Foundation; either version 2, or (at your option) any |
| 10 | * later version. |
| 11 | * |
| 12 | * GNU Zebra is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with GNU Zebra; see the file COPYING. If not, write to the |
| 19 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 20 | * Boston, MA 02111-1307, USA. |
| 21 | */ |
| 22 | |
| 23 | #include <zebra.h> |
| 24 | |
| 25 | #include "log.h" |
| 26 | #include "prefix.h" |
| 27 | #include "table.h" |
| 28 | #include "vty.h" |
| 29 | #include "linklist.h" |
| 30 | #include "command.h" |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 31 | #include "thread.h" |
hasso | 34956b3 | 2005-06-24 08:44:02 +0000 | [diff] [blame] | 32 | #include "plist.h" |
| 33 | #include "filter.h" |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 34 | |
| 35 | #include "ospf6_proto.h" |
| 36 | #include "ospf6_route.h" |
| 37 | #include "ospf6_lsa.h" |
| 38 | #include "ospf6_route.h" |
| 39 | #include "ospf6_lsdb.h" |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 40 | #include "ospf6_message.h" |
| 41 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 42 | #include "ospf6_top.h" |
| 43 | #include "ospf6_area.h" |
| 44 | #include "ospf6_interface.h" |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 45 | #include "ospf6_neighbor.h" |
| 46 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 47 | #include "ospf6_flood.h" |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 48 | #include "ospf6_intra.h" |
| 49 | #include "ospf6_abr.h" |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 50 | #include "ospf6d.h" |
| 51 | |
| 52 | unsigned char conf_debug_ospf6_abr; |
| 53 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 54 | int |
| 55 | ospf6_is_router_abr (struct ospf6 *o) |
| 56 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 57 | struct listnode *node; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 58 | struct ospf6_area *oa; |
| 59 | int area_count = 0; |
| 60 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 61 | for (ALL_LIST_ELEMENTS_RO (o->area_list, node, oa)) |
| 62 | if (IS_AREA_ENABLED (oa)) |
| 63 | area_count++; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 64 | |
| 65 | if (area_count > 1) |
| 66 | return 1; |
| 67 | return 0; |
| 68 | } |
| 69 | |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 70 | void |
| 71 | ospf6_abr_enable_area (struct ospf6_area *area) |
| 72 | { |
| 73 | struct ospf6_area *oa; |
| 74 | struct ospf6_route *ro; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 75 | struct listnode *node, *nnode; |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 76 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 77 | for (ALL_LIST_ELEMENTS (area->ospf6->area_list, node, nnode, oa)) |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 78 | { |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 79 | /* update B bit for each area */ |
| 80 | OSPF6_ROUTER_LSA_SCHEDULE (oa); |
| 81 | |
| 82 | /* install other area's configured address range */ |
| 83 | if (oa != area) |
| 84 | { |
| 85 | for (ro = ospf6_route_head (oa->range_table); ro; |
| 86 | ro = ospf6_route_next (ro)) |
hasso | 4846ef6 | 2004-09-03 06:04:00 +0000 | [diff] [blame] | 87 | { |
| 88 | if (CHECK_FLAG (ro->flag, OSPF6_ROUTE_ACTIVE_SUMMARY)) |
| 89 | ospf6_abr_originate_summary_to_area (ro, area); |
| 90 | } |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 91 | } |
| 92 | } |
| 93 | |
| 94 | /* install calculated routes to border routers */ |
| 95 | for (ro = ospf6_route_head (area->ospf6->brouter_table); ro; |
| 96 | ro = ospf6_route_next (ro)) |
| 97 | ospf6_abr_originate_summary_to_area (ro, area); |
| 98 | |
| 99 | /* install calculated routes to network (may be rejected by ranges) */ |
| 100 | for (ro = ospf6_route_head (area->ospf6->route_table); ro; |
| 101 | ro = ospf6_route_next (ro)) |
| 102 | ospf6_abr_originate_summary_to_area (ro, area); |
| 103 | } |
| 104 | |
| 105 | void |
| 106 | ospf6_abr_disable_area (struct ospf6_area *area) |
| 107 | { |
| 108 | struct ospf6_area *oa; |
Vipin Kumar | 8c075ef | 2015-05-19 18:03:53 -0700 | [diff] [blame] | 109 | struct ospf6_route *ro, *nro; |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 110 | struct ospf6_lsa *old; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 111 | struct listnode *node, *nnode; |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 112 | |
| 113 | /* Withdraw all summary prefixes previously originated */ |
Vipin Kumar | 8c075ef | 2015-05-19 18:03:53 -0700 | [diff] [blame] | 114 | for (ro = ospf6_route_head (area->summary_prefix); ro; ro = nro) |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 115 | { |
Vipin Kumar | 8c075ef | 2015-05-19 18:03:53 -0700 | [diff] [blame] | 116 | nro = ospf6_route_next (ro); |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 117 | old = ospf6_lsdb_lookup (ro->path.origin.type, ro->path.origin.id, |
| 118 | area->ospf6->router_id, area->lsdb); |
| 119 | if (old) |
| 120 | ospf6_lsa_purge (old); |
| 121 | ospf6_route_remove (ro, area->summary_prefix); |
| 122 | } |
| 123 | |
| 124 | /* Withdraw all summary router-routes previously originated */ |
Vipin Kumar | 8c075ef | 2015-05-19 18:03:53 -0700 | [diff] [blame] | 125 | for (ro = ospf6_route_head (area->summary_router); ro; ro = nro) |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 126 | { |
Vipin Kumar | 8c075ef | 2015-05-19 18:03:53 -0700 | [diff] [blame] | 127 | nro = ospf6_route_next (ro); |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 128 | old = ospf6_lsdb_lookup (ro->path.origin.type, ro->path.origin.id, |
| 129 | area->ospf6->router_id, area->lsdb); |
| 130 | if (old) |
| 131 | ospf6_lsa_purge (old); |
| 132 | ospf6_route_remove (ro, area->summary_router); |
| 133 | } |
| 134 | |
| 135 | /* Schedule Router-LSA for each area (ABR status may change) */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 136 | for (ALL_LIST_ELEMENTS (area->ospf6->area_list, node, nnode, oa)) |
| 137 | /* update B bit for each area */ |
| 138 | OSPF6_ROUTER_LSA_SCHEDULE (oa); |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 139 | } |
| 140 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 141 | /* RFC 2328 12.4.3. Summary-LSAs */ |
| 142 | void |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 143 | ospf6_abr_originate_summary_to_area (struct ospf6_route *route, |
| 144 | struct ospf6_area *area) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 145 | { |
| 146 | struct ospf6_lsa *lsa, *old = NULL; |
| 147 | struct ospf6_interface *oi; |
| 148 | struct ospf6_route *summary, *range = NULL; |
| 149 | struct ospf6_area *route_area; |
| 150 | char buffer[OSPF6_MAX_LSASIZE]; |
| 151 | struct ospf6_lsa_header *lsa_header; |
| 152 | caddr_t p; |
| 153 | struct ospf6_inter_prefix_lsa *prefix_lsa; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 154 | struct ospf6_inter_router_lsa *router_lsa; |
| 155 | struct ospf6_route_table *summary_table = NULL; |
| 156 | u_int16_t type; |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 157 | char buf[64]; |
| 158 | int is_debug = 0; |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 159 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 160 | if (route->type == OSPF6_DEST_TYPE_ROUTER) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 161 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 162 | if (IS_OSPF6_DEBUG_ABR || IS_OSPF6_DEBUG_ORIGINATE (INTER_ROUTER)) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 163 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 164 | is_debug++; |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 165 | inet_ntop (AF_INET, &(ADV_ROUTER_IN_PREFIX (&route->prefix)), |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 166 | buf, sizeof (buf)); |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 167 | zlog_debug ("Originating summary in area %s for ASBR %s", |
| 168 | area->name, buf); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 169 | } |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 170 | summary_table = area->summary_router; |
| 171 | } |
| 172 | else |
| 173 | { |
| 174 | if (IS_OSPF6_DEBUG_ABR || IS_OSPF6_DEBUG_ORIGINATE (INTER_PREFIX)) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 175 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 176 | is_debug++; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 177 | prefix2str (&route->prefix, buf, sizeof (buf)); |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 178 | zlog_debug ("Originating summary in area %s for %s", |
| 179 | area->name, buf); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 180 | } |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 181 | summary_table = area->summary_prefix; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 182 | } |
| 183 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 184 | summary = ospf6_route_lookup (&route->prefix, summary_table); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 185 | if (summary) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 186 | old = ospf6_lsdb_lookup (summary->path.origin.type, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 187 | summary->path.origin.id, |
| 188 | area->ospf6->router_id, area->lsdb); |
| 189 | |
| 190 | /* if this route has just removed, remove corresponding LSA */ |
| 191 | if (CHECK_FLAG (route->flag, OSPF6_ROUTE_REMOVE)) |
| 192 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 193 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 194 | zlog_debug ("The route has just removed, purge previous LSA"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 195 | if (summary) |
| 196 | ospf6_route_remove (summary, summary_table); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 197 | if (old) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 198 | ospf6_lsa_purge (old); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 199 | return; |
| 200 | } |
| 201 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 202 | /* Only destination type network, range or ASBR are considered */ |
| 203 | if (route->type != OSPF6_DEST_TYPE_NETWORK && |
| 204 | route->type != OSPF6_DEST_TYPE_RANGE && |
| 205 | (route->type != OSPF6_DEST_TYPE_ROUTER || |
| 206 | ! CHECK_FLAG (route->path.router_bits, OSPF6_ROUTER_BIT_E))) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 207 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 208 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 209 | zlog_debug ("Route type is none of network, range nor ASBR, withdraw"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 210 | if (summary) |
| 211 | ospf6_route_remove (summary, summary_table); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 212 | if (old) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 213 | ospf6_lsa_purge (old); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 214 | return; |
| 215 | } |
| 216 | |
| 217 | /* AS External routes are never considered */ |
| 218 | if (route->path.type == OSPF6_PATH_TYPE_EXTERNAL1 || |
| 219 | route->path.type == OSPF6_PATH_TYPE_EXTERNAL2) |
| 220 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 221 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 222 | zlog_debug ("Path type is external, withdraw"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 223 | if (summary) |
| 224 | ospf6_route_remove (summary, summary_table); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 225 | if (old) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 226 | ospf6_lsa_purge (old); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 227 | return; |
| 228 | } |
| 229 | |
| 230 | /* do not generate if the path's area is the same as target area */ |
| 231 | if (route->path.area_id == area->area_id) |
| 232 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 233 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 234 | zlog_debug ("The route is in the area itself, ignore"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 235 | if (summary) |
| 236 | ospf6_route_remove (summary, summary_table); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 237 | if (old) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 238 | ospf6_lsa_purge (old); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 239 | return; |
| 240 | } |
| 241 | |
| 242 | /* do not generate if the nexthops belongs to the target area */ |
| 243 | oi = ospf6_interface_lookup_by_ifindex (route->nexthop[0].ifindex); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 244 | if (oi && oi->area && oi->area == area) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 245 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 246 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 247 | zlog_debug ("The route's nexthop is in the same area, ignore"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 248 | if (summary) |
| 249 | ospf6_route_remove (summary, summary_table); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 250 | if (old) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 251 | ospf6_lsa_purge (old); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 252 | return; |
| 253 | } |
| 254 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 255 | /* do not generate if the route cost is greater or equal to LSInfinity */ |
Dinesh Dutt | 8551e6d | 2013-10-22 17:42:18 -0700 | [diff] [blame] | 256 | if (route->path.cost >= OSPF_LS_INFINITY) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 257 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 258 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 259 | zlog_debug ("The cost exceeds LSInfinity, withdraw"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 260 | if (summary) |
| 261 | ospf6_route_remove (summary, summary_table); |
| 262 | if (old) |
| 263 | ospf6_lsa_purge (old); |
| 264 | return; |
| 265 | } |
| 266 | |
| 267 | /* if this is a route to ASBR */ |
| 268 | if (route->type == OSPF6_DEST_TYPE_ROUTER) |
| 269 | { |
| 270 | /* Only the prefered best path is considered */ |
| 271 | if (! CHECK_FLAG (route->flag, OSPF6_ROUTE_BEST)) |
| 272 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 273 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 274 | zlog_debug ("This is the secondary path to the ASBR, ignore"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 275 | if (summary) |
| 276 | ospf6_route_remove (summary, summary_table); |
| 277 | if (old) |
| 278 | ospf6_lsa_purge (old); |
| 279 | return; |
| 280 | } |
| 281 | |
| 282 | /* Do not generate if the area is stub */ |
| 283 | /* XXX */ |
| 284 | } |
| 285 | |
| 286 | /* if this is an intra-area route, this may be suppressed by aggregation */ |
| 287 | if (route->type == OSPF6_DEST_TYPE_NETWORK && |
| 288 | route->path.type == OSPF6_PATH_TYPE_INTRA) |
| 289 | { |
| 290 | /* search for configured address range for the route's area */ |
| 291 | route_area = ospf6_area_lookup (route->path.area_id, area->ospf6); |
| 292 | assert (route_area); |
| 293 | range = ospf6_route_lookup_bestmatch (&route->prefix, |
| 294 | route_area->range_table); |
| 295 | |
| 296 | /* ranges are ignored when originate backbone routes to transit area. |
| 297 | Otherwise, if ranges are configured, the route is suppressed. */ |
| 298 | if (range && ! CHECK_FLAG (range->flag, OSPF6_ROUTE_REMOVE) && |
Dinesh Dutt | 8551e6d | 2013-10-22 17:42:18 -0700 | [diff] [blame] | 299 | (route->path.area_id != OSPF_AREA_BACKBONE || |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 300 | ! IS_AREA_TRANSIT (area))) |
| 301 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 302 | if (is_debug) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 303 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 304 | prefix2str (&range->prefix, buf, sizeof (buf)); |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 305 | zlog_debug ("Suppressed by range %s of area %s", |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 306 | buf, route_area->name); |
| 307 | } |
| 308 | |
| 309 | if (summary) |
| 310 | ospf6_route_remove (summary, summary_table); |
| 311 | if (old) |
| 312 | ospf6_lsa_purge (old); |
| 313 | return; |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | /* If this is a configured address range */ |
| 318 | if (route->type == OSPF6_DEST_TYPE_RANGE) |
| 319 | { |
| 320 | /* If DoNotAdvertise is set */ |
| 321 | if (CHECK_FLAG (route->flag, OSPF6_ROUTE_DO_NOT_ADVERTISE)) |
| 322 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 323 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 324 | zlog_debug ("This is the range with DoNotAdvertise set. ignore"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 325 | if (summary) |
| 326 | ospf6_route_remove (summary, summary_table); |
| 327 | if (old) |
| 328 | ospf6_lsa_purge (old); |
| 329 | return; |
| 330 | } |
| 331 | |
| 332 | /* Whether the route have active longer prefix */ |
| 333 | if (! CHECK_FLAG (route->flag, OSPF6_ROUTE_ACTIVE_SUMMARY)) |
| 334 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 335 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 336 | zlog_debug ("The range is not active. withdraw"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 337 | if (summary) |
| 338 | ospf6_route_remove (summary, summary_table); |
| 339 | if (old) |
| 340 | ospf6_lsa_purge (old); |
| 341 | return; |
| 342 | } |
| 343 | } |
| 344 | |
hasso | 34956b3 | 2005-06-24 08:44:02 +0000 | [diff] [blame] | 345 | /* Check export list */ |
| 346 | if (EXPORT_NAME (area)) |
| 347 | { |
| 348 | if (EXPORT_LIST (area) == NULL) |
| 349 | EXPORT_LIST (area) = |
| 350 | access_list_lookup (AFI_IP6, EXPORT_NAME (area)); |
| 351 | |
| 352 | if (EXPORT_LIST (area)) |
| 353 | if (access_list_apply (EXPORT_LIST (area), |
| 354 | &route->prefix) == FILTER_DENY) |
| 355 | { |
| 356 | if (is_debug) |
| 357 | { |
| 358 | inet_ntop (AF_INET, &(ADV_ROUTER_IN_PREFIX (&route->prefix)), |
| 359 | buf, sizeof(buf)); |
| 360 | zlog_debug ("prefix %s was denied by export list", buf); |
| 361 | } |
| 362 | return; |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | /* Check filter-list */ |
| 367 | if (PREFIX_NAME_OUT (area)) |
| 368 | { |
| 369 | if (PREFIX_LIST_OUT (area) == NULL) |
| 370 | PREFIX_LIST_OUT (area) = |
| 371 | prefix_list_lookup(AFI_IP6, PREFIX_NAME_OUT (area)); |
| 372 | |
| 373 | if (PREFIX_LIST_OUT (area)) |
| 374 | if (prefix_list_apply (PREFIX_LIST_OUT (area), |
| 375 | &route->prefix) != PREFIX_PERMIT) |
| 376 | { |
| 377 | if (is_debug) |
| 378 | { |
| 379 | inet_ntop (AF_INET, &(ADV_ROUTER_IN_PREFIX (&route->prefix)), |
| 380 | buf, sizeof (buf)); |
| 381 | zlog_debug ("prefix %s was denied by filter-list out", buf); |
| 382 | } |
| 383 | return; |
| 384 | } |
| 385 | } |
| 386 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 387 | /* the route is going to be originated. store it in area's summary_table */ |
| 388 | if (summary == NULL) |
| 389 | { |
| 390 | summary = ospf6_route_copy (route); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 391 | if (route->type == OSPF6_DEST_TYPE_NETWORK || |
| 392 | route->type == OSPF6_DEST_TYPE_RANGE) |
| 393 | summary->path.origin.type = htons (OSPF6_LSTYPE_INTER_PREFIX); |
| 394 | else |
| 395 | summary->path.origin.type = htons (OSPF6_LSTYPE_INTER_ROUTER); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 396 | summary->path.origin.adv_router = area->ospf6->router_id; |
| 397 | summary->path.origin.id = |
| 398 | ospf6_new_ls_id (summary->path.origin.type, |
| 399 | summary->path.origin.adv_router, area->lsdb); |
hasso | 9428f2d | 2004-09-13 14:01:12 +0000 | [diff] [blame] | 400 | summary = ospf6_route_add (summary, summary_table); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 401 | } |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 402 | else |
| 403 | { |
| 404 | summary->type = route->type; |
Takashi Sogabe | 86f72dc | 2009-06-22 13:07:02 +0900 | [diff] [blame] | 405 | quagga_gettime (QUAGGA_CLK_MONOTONIC, &summary->changed); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 406 | } |
| 407 | |
| 408 | summary->path.router_bits = route->path.router_bits; |
| 409 | summary->path.options[0] = route->path.options[0]; |
| 410 | summary->path.options[1] = route->path.options[1]; |
| 411 | summary->path.options[2] = route->path.options[2]; |
| 412 | summary->path.prefix_options = route->path.prefix_options; |
| 413 | summary->path.area_id = area->area_id; |
| 414 | summary->path.type = OSPF6_PATH_TYPE_INTER; |
| 415 | summary->path.cost = route->path.cost; |
| 416 | summary->nexthop[0] = route->nexthop[0]; |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 417 | |
| 418 | /* prepare buffer */ |
| 419 | memset (buffer, 0, sizeof (buffer)); |
| 420 | lsa_header = (struct ospf6_lsa_header *) buffer; |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 421 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 422 | if (route->type == OSPF6_DEST_TYPE_ROUTER) |
| 423 | { |
| 424 | router_lsa = (struct ospf6_inter_router_lsa *) |
| 425 | ((caddr_t) lsa_header + sizeof (struct ospf6_lsa_header)); |
| 426 | p = (caddr_t) router_lsa + sizeof (struct ospf6_inter_router_lsa); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 427 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 428 | /* Fill Inter-Area-Router-LSA */ |
| 429 | router_lsa->options[0] = route->path.options[0]; |
| 430 | router_lsa->options[1] = route->path.options[1]; |
| 431 | router_lsa->options[2] = route->path.options[2]; |
| 432 | OSPF6_ABR_SUMMARY_METRIC_SET (router_lsa, route->path.cost); |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 433 | router_lsa->router_id = ADV_ROUTER_IN_PREFIX (&route->prefix); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 434 | type = htons (OSPF6_LSTYPE_INTER_ROUTER); |
| 435 | } |
| 436 | else |
| 437 | { |
| 438 | prefix_lsa = (struct ospf6_inter_prefix_lsa *) |
| 439 | ((caddr_t) lsa_header + sizeof (struct ospf6_lsa_header)); |
| 440 | p = (caddr_t) prefix_lsa + sizeof (struct ospf6_inter_prefix_lsa); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 441 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 442 | /* Fill Inter-Area-Prefix-LSA */ |
| 443 | OSPF6_ABR_SUMMARY_METRIC_SET (prefix_lsa, route->path.cost); |
| 444 | prefix_lsa->prefix.prefix_length = route->prefix.prefixlen; |
| 445 | prefix_lsa->prefix.prefix_options = route->path.prefix_options; |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 446 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 447 | /* set Prefix */ |
| 448 | memcpy (p, &route->prefix.u.prefix6, |
| 449 | OSPF6_PREFIX_SPACE (route->prefix.prefixlen)); |
| 450 | ospf6_prefix_apply_mask (&prefix_lsa->prefix); |
| 451 | p += OSPF6_PREFIX_SPACE (route->prefix.prefixlen); |
| 452 | type = htons (OSPF6_LSTYPE_INTER_PREFIX); |
| 453 | } |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 454 | |
| 455 | /* Fill LSA Header */ |
| 456 | lsa_header->age = 0; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 457 | lsa_header->type = type; |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 458 | lsa_header->id = summary->path.origin.id; |
| 459 | lsa_header->adv_router = area->ospf6->router_id; |
| 460 | lsa_header->seqnum = |
| 461 | ospf6_new_ls_seqnum (lsa_header->type, lsa_header->id, |
| 462 | lsa_header->adv_router, area->lsdb); |
| 463 | lsa_header->length = htons ((caddr_t) p - (caddr_t) lsa_header); |
| 464 | |
| 465 | /* LSA checksum */ |
| 466 | ospf6_lsa_checksum (lsa_header); |
| 467 | |
| 468 | /* create LSA */ |
| 469 | lsa = ospf6_lsa_create (lsa_header); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 470 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 471 | /* Originate */ |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 472 | ospf6_lsa_originate_area (lsa, area); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 473 | } |
| 474 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 475 | static void |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 476 | ospf6_abr_range_update (struct ospf6_route *range) |
| 477 | { |
| 478 | u_int32_t cost = 0; |
| 479 | struct ospf6_route *ro; |
| 480 | |
| 481 | assert (range->type == OSPF6_DEST_TYPE_RANGE); |
| 482 | |
| 483 | /* update range's cost and active flag */ |
| 484 | for (ro = ospf6_route_match_head (&range->prefix, ospf6->route_table); |
| 485 | ro; ro = ospf6_route_match_next (&range->prefix, ro)) |
| 486 | { |
| 487 | if (ro->path.area_id == range->path.area_id && |
| 488 | ! CHECK_FLAG (ro->flag, OSPF6_ROUTE_REMOVE)) |
| 489 | cost = MAX (cost, ro->path.cost); |
| 490 | } |
| 491 | |
| 492 | if (range->path.cost != cost) |
| 493 | { |
| 494 | range->path.cost = cost; |
| 495 | |
| 496 | if (range->path.cost) |
| 497 | SET_FLAG (range->flag, OSPF6_ROUTE_ACTIVE_SUMMARY); |
| 498 | else |
| 499 | UNSET_FLAG (range->flag, OSPF6_ROUTE_ACTIVE_SUMMARY); |
| 500 | |
| 501 | ospf6_abr_originate_summary (range); |
| 502 | } |
| 503 | } |
| 504 | |
| 505 | void |
| 506 | ospf6_abr_originate_summary (struct ospf6_route *route) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 507 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 508 | struct listnode *node, *nnode; |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 509 | struct ospf6_area *oa; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 510 | struct ospf6_route *range = NULL; |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 511 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 512 | if (route->type == OSPF6_DEST_TYPE_NETWORK) |
| 513 | { |
| 514 | oa = ospf6_area_lookup (route->path.area_id, ospf6); |
| 515 | range = ospf6_route_lookup_bestmatch (&route->prefix, oa->range_table); |
| 516 | if (range) |
| 517 | ospf6_abr_range_update (range); |
| 518 | } |
| 519 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 520 | for (ALL_LIST_ELEMENTS (ospf6->area_list, node, nnode, oa)) |
| 521 | ospf6_abr_originate_summary_to_area (route, oa); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 522 | } |
| 523 | |
| 524 | /* RFC 2328 16.2. Calculating the inter-area routes */ |
| 525 | void |
| 526 | ospf6_abr_examin_summary (struct ospf6_lsa *lsa, struct ospf6_area *oa) |
| 527 | { |
| 528 | struct prefix prefix, abr_prefix; |
| 529 | struct ospf6_route_table *table = NULL; |
| 530 | struct ospf6_route *range, *route, *old = NULL; |
| 531 | struct ospf6_route *abr_entry; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 532 | u_char type = 0; |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 533 | char options[3] = {0, 0, 0}; |
| 534 | u_int8_t prefix_options = 0; |
| 535 | u_int32_t cost = 0; |
hasso | 63069ad | 2004-09-02 13:01:01 +0000 | [diff] [blame] | 536 | u_char router_bits = 0; |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 537 | int i; |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 538 | char buf[64]; |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 539 | int is_debug = 0; |
Dinesh Dutt | 0187911 | 2013-08-25 03:03:31 +0000 | [diff] [blame] | 540 | struct ospf6_inter_prefix_lsa *prefix_lsa = NULL; |
| 541 | struct ospf6_inter_router_lsa *router_lsa = NULL; |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 542 | |
Paul Jakma | cf1ce25 | 2006-05-15 10:46:07 +0000 | [diff] [blame] | 543 | memset (&prefix, 0, sizeof (prefix)); |
| 544 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 545 | if (lsa->header->type == htons (OSPF6_LSTYPE_INTER_PREFIX)) |
| 546 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 547 | if (IS_OSPF6_DEBUG_EXAMIN (INTER_PREFIX)) |
| 548 | { |
| 549 | is_debug++; |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 550 | zlog_debug ("Examin %s in area %s", lsa->name, oa->name); |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 551 | } |
| 552 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 553 | prefix_lsa = (struct ospf6_inter_prefix_lsa *) |
| 554 | OSPF6_LSA_HEADER_END (lsa->header); |
| 555 | prefix.family = AF_INET6; |
| 556 | prefix.prefixlen = prefix_lsa->prefix.prefix_length; |
| 557 | ospf6_prefix_in6_addr (&prefix.u.prefix6, &prefix_lsa->prefix); |
Denis Ovsienko | d91f35b | 2011-08-19 22:24:27 +0400 | [diff] [blame] | 558 | if (is_debug) |
| 559 | prefix2str (&prefix, buf, sizeof (buf)); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 560 | table = oa->ospf6->route_table; |
| 561 | type = OSPF6_DEST_TYPE_NETWORK; |
| 562 | prefix_options = prefix_lsa->prefix.prefix_options; |
| 563 | cost = OSPF6_ABR_SUMMARY_METRIC (prefix_lsa); |
| 564 | } |
| 565 | else if (lsa->header->type == htons (OSPF6_LSTYPE_INTER_ROUTER)) |
| 566 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 567 | if (IS_OSPF6_DEBUG_EXAMIN (INTER_ROUTER)) |
| 568 | { |
| 569 | is_debug++; |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 570 | zlog_debug ("Examin %s in area %s", lsa->name, oa->name); |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 571 | } |
| 572 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 573 | router_lsa = (struct ospf6_inter_router_lsa *) |
| 574 | OSPF6_LSA_HEADER_END (lsa->header); |
| 575 | ospf6_linkstate_prefix (router_lsa->router_id, htonl (0), &prefix); |
Denis Ovsienko | d91f35b | 2011-08-19 22:24:27 +0400 | [diff] [blame] | 576 | if (is_debug) |
| 577 | inet_ntop (AF_INET, &router_lsa->router_id, buf, sizeof (buf)); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 578 | table = oa->ospf6->brouter_table; |
| 579 | type = OSPF6_DEST_TYPE_ROUTER; |
| 580 | options[0] = router_lsa->options[0]; |
| 581 | options[1] = router_lsa->options[1]; |
| 582 | options[2] = router_lsa->options[2]; |
| 583 | cost = OSPF6_ABR_SUMMARY_METRIC (router_lsa); |
hasso | 63069ad | 2004-09-02 13:01:01 +0000 | [diff] [blame] | 584 | SET_FLAG (router_bits, OSPF6_ROUTER_BIT_E); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 585 | } |
| 586 | else |
| 587 | assert (0); |
| 588 | |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 589 | /* Find existing route */ |
| 590 | route = ospf6_route_lookup (&prefix, table); |
| 591 | if (route) |
| 592 | ospf6_route_lock (route); |
| 593 | while (route && ospf6_route_is_prefix (&prefix, route)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 594 | { |
| 595 | if (route->path.area_id == oa->area_id && |
| 596 | route->path.origin.type == lsa->header->type && |
| 597 | route->path.origin.id == lsa->header->id && |
Paul Jakma | cf1ce25 | 2006-05-15 10:46:07 +0000 | [diff] [blame] | 598 | route->path.origin.adv_router == lsa->header->adv_router && |
| 599 | ! CHECK_FLAG (route->flag, OSPF6_ROUTE_WAS_REMOVED)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 600 | old = route; |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 601 | route = ospf6_route_next (route); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | /* (1) if cost == LSInfinity or if the LSA is MaxAge */ |
Dinesh Dutt | 8551e6d | 2013-10-22 17:42:18 -0700 | [diff] [blame] | 605 | if (cost == OSPF_LS_INFINITY) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 606 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 607 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 608 | zlog_debug ("cost is LS_INFINITY, ignore"); |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 609 | if (old) |
hasso | 63069ad | 2004-09-02 13:01:01 +0000 | [diff] [blame] | 610 | ospf6_route_remove (old, table); |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 611 | return; |
| 612 | } |
| 613 | if (OSPF6_LSA_IS_MAXAGE (lsa)) |
| 614 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 615 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 616 | zlog_debug ("LSA is MaxAge, ignore"); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 617 | if (old) |
hasso | 63069ad | 2004-09-02 13:01:01 +0000 | [diff] [blame] | 618 | ospf6_route_remove (old, table); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 619 | return; |
| 620 | } |
| 621 | |
| 622 | /* (2) if the LSA is self-originated, ignore */ |
| 623 | if (lsa->header->adv_router == oa->ospf6->router_id) |
| 624 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 625 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 626 | zlog_debug ("LSA is self-originated, ignore"); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 627 | if (old) |
hasso | 63069ad | 2004-09-02 13:01:01 +0000 | [diff] [blame] | 628 | ospf6_route_remove (old, table); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 629 | return; |
| 630 | } |
| 631 | |
| 632 | /* (3) if the prefix is equal to an active configured address range */ |
Dinesh Dutt | 0187911 | 2013-08-25 03:03:31 +0000 | [diff] [blame] | 633 | /* or if the NU bit is set in the prefix */ |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 634 | if (lsa->header->type == htons (OSPF6_LSTYPE_INTER_PREFIX)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 635 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 636 | range = ospf6_route_lookup (&prefix, oa->range_table); |
| 637 | if (range) |
| 638 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 639 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 640 | zlog_debug ("Prefix is equal to address range, ignore"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 641 | if (old) |
hasso | 63069ad | 2004-09-02 13:01:01 +0000 | [diff] [blame] | 642 | ospf6_route_remove (old, table); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 643 | return; |
| 644 | } |
Dinesh Dutt | 0187911 | 2013-08-25 03:03:31 +0000 | [diff] [blame] | 645 | |
| 646 | if (CHECK_FLAG (prefix_lsa->prefix.prefix_options, |
| 647 | OSPF6_PREFIX_OPTION_NU) || |
| 648 | CHECK_FLAG (prefix_lsa->prefix.prefix_options, |
| 649 | OSPF6_PREFIX_OPTION_LA)) |
| 650 | { |
| 651 | if (is_debug) |
| 652 | zlog_debug ("Prefix has NU/LA bit set, ignore"); |
| 653 | if (old) |
| 654 | ospf6_route_remove (old, table); |
| 655 | return; |
| 656 | } |
| 657 | } |
| 658 | |
| 659 | if (lsa->header->type == htons (OSPF6_LSTYPE_INTER_ROUTER)) |
| 660 | { |
| 661 | /* To pass test suites */ |
| 662 | if (! OSPF6_OPT_ISSET (router_lsa->options, OSPF6_OPT_R) || |
| 663 | ! OSPF6_OPT_ISSET (router_lsa->options, OSPF6_OPT_V6)) |
| 664 | { |
| 665 | if (is_debug) |
| 666 | zlog_debug ("Prefix has NU/LA bit set, ignore"); |
| 667 | if (old) |
| 668 | ospf6_route_remove (old, table); |
| 669 | return; |
| 670 | } |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 671 | } |
| 672 | |
| 673 | /* (4) if the routing table entry for the ABR does not exist */ |
| 674 | ospf6_linkstate_prefix (lsa->header->adv_router, htonl (0), &abr_prefix); |
| 675 | abr_entry = ospf6_route_lookup (&abr_prefix, oa->ospf6->brouter_table); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 676 | if (abr_entry == NULL || abr_entry->path.area_id != oa->area_id || |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 677 | CHECK_FLAG (abr_entry->flag, OSPF6_ROUTE_REMOVE) || |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 678 | ! CHECK_FLAG (abr_entry->path.router_bits, OSPF6_ROUTER_BIT_B)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 679 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 680 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 681 | zlog_debug ("ABR router entry does not exist, ignore"); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 682 | if (old) |
hasso | 63069ad | 2004-09-02 13:01:01 +0000 | [diff] [blame] | 683 | ospf6_route_remove (old, table); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 684 | return; |
| 685 | } |
| 686 | |
hasso | 34956b3 | 2005-06-24 08:44:02 +0000 | [diff] [blame] | 687 | /* Check import list */ |
| 688 | if (IMPORT_NAME (oa)) |
| 689 | { |
| 690 | if (IMPORT_LIST (oa) == NULL) |
| 691 | IMPORT_LIST (oa) = access_list_lookup (AFI_IP6, IMPORT_NAME (oa)); |
| 692 | |
| 693 | if (IMPORT_LIST (oa)) |
| 694 | if (access_list_apply (IMPORT_LIST (oa), &prefix) == FILTER_DENY) |
| 695 | { |
| 696 | if (is_debug) |
| 697 | zlog_debug ("Prefix was denied by import-list"); |
| 698 | if (old) |
| 699 | ospf6_route_remove (old, table); |
| 700 | return; |
| 701 | } |
| 702 | } |
| 703 | |
| 704 | /* Check input prefix-list */ |
| 705 | if (PREFIX_NAME_IN (oa)) |
| 706 | { |
| 707 | if (PREFIX_LIST_IN (oa) == NULL) |
| 708 | PREFIX_LIST_IN (oa) = prefix_list_lookup (AFI_IP6, PREFIX_NAME_IN (oa)); |
| 709 | |
| 710 | if (PREFIX_LIST_IN (oa)) |
| 711 | if (prefix_list_apply (PREFIX_LIST_IN (oa), &prefix) != PREFIX_PERMIT) |
| 712 | { |
| 713 | if (is_debug) |
| 714 | zlog_debug ("Prefix was denied by prefix-list"); |
| 715 | if (old) |
| 716 | ospf6_route_remove (old, table); |
| 717 | return; |
| 718 | } |
| 719 | } |
| 720 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 721 | /* (5),(6),(7) the path preference is handled by the sorting |
| 722 | in the routing table. Always install the path by substituting |
| 723 | old route (if any). */ |
| 724 | if (old) |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 725 | route = ospf6_route_copy (old); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 726 | else |
| 727 | route = ospf6_route_create (); |
| 728 | |
| 729 | route->type = type; |
| 730 | route->prefix = prefix; |
| 731 | route->path.origin.type = lsa->header->type; |
| 732 | route->path.origin.id = lsa->header->id; |
| 733 | route->path.origin.adv_router = lsa->header->adv_router; |
hasso | 63069ad | 2004-09-02 13:01:01 +0000 | [diff] [blame] | 734 | route->path.router_bits = router_bits; |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 735 | route->path.options[0] = options[0]; |
| 736 | route->path.options[1] = options[1]; |
| 737 | route->path.options[2] = options[2]; |
| 738 | route->path.prefix_options = prefix_options; |
| 739 | route->path.area_id = oa->area_id; |
| 740 | route->path.type = OSPF6_PATH_TYPE_INTER; |
| 741 | route->path.cost = abr_entry->path.cost + cost; |
| 742 | for (i = 0; i < OSPF6_MULTI_PATH_LIMIT; i++) |
| 743 | route->nexthop[i] = abr_entry->nexthop[i]; |
| 744 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 745 | if (is_debug) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 746 | zlog_debug ("Install route: %s", buf); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 747 | ospf6_route_add (route, table); |
| 748 | } |
| 749 | |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 750 | void |
| 751 | ospf6_abr_examin_brouter (u_int32_t router_id) |
| 752 | { |
| 753 | struct ospf6_lsa *lsa; |
| 754 | struct ospf6_area *oa; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 755 | struct listnode *node, *nnode; |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 756 | u_int16_t type; |
| 757 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 758 | for (ALL_LIST_ELEMENTS (ospf6->area_list, node, nnode, oa)) |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 759 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 760 | type = htons (OSPF6_LSTYPE_INTER_ROUTER); |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 761 | for (lsa = ospf6_lsdb_type_router_head (type, router_id, oa->lsdb); lsa; |
| 762 | lsa = ospf6_lsdb_type_router_next (type, router_id, lsa)) |
| 763 | ospf6_abr_examin_summary (lsa, oa); |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 764 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 765 | type = htons (OSPF6_LSTYPE_INTER_PREFIX); |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 766 | for (lsa = ospf6_lsdb_type_router_head (type, router_id, oa->lsdb); lsa; |
| 767 | lsa = ospf6_lsdb_type_router_next (type, router_id, lsa)) |
| 768 | ospf6_abr_examin_summary (lsa, oa); |
| 769 | } |
| 770 | } |
| 771 | |
hasso | 34956b3 | 2005-06-24 08:44:02 +0000 | [diff] [blame] | 772 | void |
| 773 | ospf6_abr_reimport (struct ospf6_area *oa) |
| 774 | { |
| 775 | struct ospf6_lsa *lsa; |
| 776 | u_int16_t type; |
| 777 | |
| 778 | type = htons (OSPF6_LSTYPE_INTER_ROUTER); |
| 779 | for (lsa = ospf6_lsdb_type_head (type, oa->lsdb); lsa; |
| 780 | lsa = ospf6_lsdb_type_next (type, lsa)) |
| 781 | ospf6_abr_examin_summary (lsa, oa); |
| 782 | |
| 783 | type = htons (OSPF6_LSTYPE_INTER_PREFIX); |
| 784 | for (lsa = ospf6_lsdb_type_head (type, oa->lsdb); lsa; |
| 785 | lsa = ospf6_lsdb_type_next (type, lsa)) |
| 786 | ospf6_abr_examin_summary (lsa, oa); |
| 787 | } |
| 788 | |
| 789 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 790 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 791 | /* Display functions */ |
Dinesh Dutt | e68a676 | 2013-08-25 03:03:23 +0000 | [diff] [blame] | 792 | static char * |
| 793 | ospf6_inter_area_prefix_lsa_get_prefix_str (struct ospf6_lsa *lsa, char *buf, |
| 794 | int buflen, int pos) |
| 795 | { |
| 796 | struct ospf6_inter_prefix_lsa *prefix_lsa; |
| 797 | struct in6_addr in6; |
| 798 | |
| 799 | if (lsa != NULL) |
| 800 | { |
| 801 | prefix_lsa = (struct ospf6_inter_prefix_lsa *) |
| 802 | OSPF6_LSA_HEADER_END (lsa->header); |
| 803 | |
| 804 | ospf6_prefix_in6_addr (&in6, &prefix_lsa->prefix); |
| 805 | if (buf) |
| 806 | { |
| 807 | inet_ntop (AF_INET6, &in6, buf, buflen); |
| 808 | sprintf (&buf[strlen(buf)], "/%d", prefix_lsa->prefix.prefix_length); |
| 809 | } |
| 810 | } |
| 811 | |
| 812 | return (buf); |
| 813 | } |
| 814 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 815 | static int |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 816 | ospf6_inter_area_prefix_lsa_show (struct vty *vty, struct ospf6_lsa *lsa) |
| 817 | { |
| 818 | struct ospf6_inter_prefix_lsa *prefix_lsa; |
Dinesh Dutt | e68a676 | 2013-08-25 03:03:23 +0000 | [diff] [blame] | 819 | char buf[INET6_ADDRSTRLEN]; |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 820 | |
| 821 | prefix_lsa = (struct ospf6_inter_prefix_lsa *) |
| 822 | OSPF6_LSA_HEADER_END (lsa->header); |
| 823 | |
| 824 | vty_out (vty, " Metric: %lu%s", |
| 825 | (u_long) OSPF6_ABR_SUMMARY_METRIC (prefix_lsa), VNL); |
| 826 | |
| 827 | ospf6_prefix_options_printbuf (prefix_lsa->prefix.prefix_options, |
| 828 | buf, sizeof (buf)); |
| 829 | vty_out (vty, " Prefix Options: %s%s", buf, VNL); |
| 830 | |
Dinesh Dutt | e68a676 | 2013-08-25 03:03:23 +0000 | [diff] [blame] | 831 | vty_out (vty, " Prefix: %s%s", |
| 832 | ospf6_inter_area_prefix_lsa_get_prefix_str (lsa, buf, sizeof(buf), |
| 833 | 0), VNL); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 834 | |
| 835 | return 0; |
| 836 | } |
| 837 | |
Dinesh Dutt | e68a676 | 2013-08-25 03:03:23 +0000 | [diff] [blame] | 838 | static char * |
| 839 | ospf6_inter_area_router_lsa_get_prefix_str (struct ospf6_lsa *lsa, char *buf, |
| 840 | int buflen, int pos) |
| 841 | { |
| 842 | struct ospf6_inter_router_lsa *router_lsa; |
| 843 | |
| 844 | if (lsa != NULL) |
| 845 | { |
| 846 | router_lsa = (struct ospf6_inter_router_lsa *) |
| 847 | OSPF6_LSA_HEADER_END (lsa->header); |
| 848 | |
| 849 | |
| 850 | if (buf) |
| 851 | inet_ntop (AF_INET, &router_lsa->router_id, buf, buflen); |
| 852 | } |
| 853 | |
| 854 | return (buf); |
| 855 | } |
| 856 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 857 | static int |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 858 | ospf6_inter_area_router_lsa_show (struct vty *vty, struct ospf6_lsa *lsa) |
| 859 | { |
| 860 | struct ospf6_inter_router_lsa *router_lsa; |
| 861 | char buf[64]; |
| 862 | |
| 863 | router_lsa = (struct ospf6_inter_router_lsa *) |
| 864 | OSPF6_LSA_HEADER_END (lsa->header); |
| 865 | |
| 866 | ospf6_options_printbuf (router_lsa->options, buf, sizeof (buf)); |
| 867 | vty_out (vty, " Options: %s%s", buf, VNL); |
| 868 | vty_out (vty, " Metric: %lu%s", |
| 869 | (u_long) OSPF6_ABR_SUMMARY_METRIC (router_lsa), VNL); |
Dinesh Dutt | e68a676 | 2013-08-25 03:03:23 +0000 | [diff] [blame] | 870 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 871 | inet_ntop (AF_INET, &router_lsa->router_id, buf, sizeof (buf)); |
| 872 | vty_out (vty, " Destination Router ID: %s%s", buf, VNL); |
| 873 | |
| 874 | return 0; |
| 875 | } |
| 876 | |
| 877 | /* Debug commands */ |
| 878 | DEFUN (debug_ospf6_abr, |
| 879 | debug_ospf6_abr_cmd, |
| 880 | "debug ospf6 abr", |
| 881 | DEBUG_STR |
| 882 | OSPF6_STR |
| 883 | "Debug OSPFv3 ABR function\n" |
| 884 | ) |
| 885 | { |
| 886 | OSPF6_DEBUG_ABR_ON (); |
| 887 | return CMD_SUCCESS; |
| 888 | } |
| 889 | |
| 890 | DEFUN (no_debug_ospf6_abr, |
| 891 | no_debug_ospf6_abr_cmd, |
| 892 | "no debug ospf6 abr", |
| 893 | NO_STR |
| 894 | DEBUG_STR |
| 895 | OSPF6_STR |
| 896 | "Debug OSPFv3 ABR function\n" |
| 897 | ) |
| 898 | { |
| 899 | OSPF6_DEBUG_ABR_OFF (); |
| 900 | return CMD_SUCCESS; |
| 901 | } |
| 902 | |
| 903 | int |
| 904 | config_write_ospf6_debug_abr (struct vty *vty) |
| 905 | { |
| 906 | if (IS_OSPF6_DEBUG_ABR) |
| 907 | vty_out (vty, "debug ospf6 abr%s", VNL); |
| 908 | return 0; |
| 909 | } |
| 910 | |
| 911 | void |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 912 | install_element_ospf6_debug_abr (void) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 913 | { |
| 914 | install_element (ENABLE_NODE, &debug_ospf6_abr_cmd); |
| 915 | install_element (ENABLE_NODE, &no_debug_ospf6_abr_cmd); |
| 916 | install_element (CONFIG_NODE, &debug_ospf6_abr_cmd); |
| 917 | install_element (CONFIG_NODE, &no_debug_ospf6_abr_cmd); |
| 918 | } |
| 919 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 920 | struct ospf6_lsa_handler inter_prefix_handler = |
| 921 | { |
| 922 | OSPF6_LSTYPE_INTER_PREFIX, |
| 923 | "Inter-Prefix", |
Dinesh Dutt | e68a676 | 2013-08-25 03:03:23 +0000 | [diff] [blame] | 924 | "IAP", |
| 925 | ospf6_inter_area_prefix_lsa_show, |
| 926 | ospf6_inter_area_prefix_lsa_get_prefix_str, |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 927 | }; |
| 928 | |
| 929 | struct ospf6_lsa_handler inter_router_handler = |
| 930 | { |
| 931 | OSPF6_LSTYPE_INTER_ROUTER, |
| 932 | "Inter-Router", |
Dinesh Dutt | e68a676 | 2013-08-25 03:03:23 +0000 | [diff] [blame] | 933 | "IAR", |
| 934 | ospf6_inter_area_router_lsa_show, |
| 935 | ospf6_inter_area_router_lsa_get_prefix_str, |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 936 | }; |
| 937 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 938 | void |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 939 | ospf6_abr_init (void) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 940 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 941 | ospf6_install_lsa_handler (&inter_prefix_handler); |
| 942 | ospf6_install_lsa_handler (&inter_router_handler); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 943 | } |
| 944 | |
| 945 | |