]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* |
508e53e2 | 2 | * Copyright (C) 2003 Yasuhiro Ohara |
718e3744 | 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 | * | |
896014f4 DL |
16 | * You should have received a copy of the GNU General Public License along |
17 | * with this program; see the file COPYING; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
718e3744 | 19 | */ |
20 | ||
21 | #include <zebra.h> | |
22 | ||
23 | #include "log.h" | |
24 | #include "memory.h" | |
25 | #include "prefix.h" | |
26 | #include "command.h" | |
27 | #include "vty.h" | |
28 | #include "routemap.h" | |
29 | #include "table.h" | |
30 | #include "plist.h" | |
31 | #include "thread.h" | |
508e53e2 | 32 | #include "linklist.h" |
718e3744 | 33 | |
508e53e2 | 34 | #include "ospf6_proto.h" |
35 | #include "ospf6_lsa.h" | |
36 | #include "ospf6_lsdb.h" | |
37 | #include "ospf6_route.h" | |
718e3744 | 38 | #include "ospf6_zebra.h" |
6452df09 | 39 | #include "ospf6_message.h" |
40 | ||
718e3744 | 41 | #include "ospf6_top.h" |
508e53e2 | 42 | #include "ospf6_area.h" |
6452df09 | 43 | #include "ospf6_interface.h" |
44 | #include "ospf6_neighbor.h" | |
508e53e2 | 45 | #include "ospf6_asbr.h" |
46 | #include "ospf6_intra.h" | |
6452df09 | 47 | #include "ospf6_flood.h" |
049207c3 | 48 | #include "ospf6d.h" |
718e3744 | 49 | |
508e53e2 | 50 | unsigned char conf_debug_ospf6_asbr = 0; |
718e3744 | 51 | |
f52d13cb | 52 | #define ZROUTE_NAME(x) zebra_route_string(x) |
508e53e2 | 53 | |
54 | /* AS External LSA origination */ | |
d62a17ae | 55 | static void ospf6_as_external_lsa_originate(struct ospf6_route *route) |
718e3744 | 56 | { |
d62a17ae | 57 | char buffer[OSPF6_MAX_LSASIZE]; |
58 | struct ospf6_lsa_header *lsa_header; | |
59 | struct ospf6_lsa *lsa; | |
60 | struct ospf6_external_info *info = route->route_option; | |
61 | ||
62 | struct ospf6_as_external_lsa *as_external_lsa; | |
63 | char buf[PREFIX2STR_BUFFER]; | |
64 | caddr_t p; | |
65 | ||
66 | if (IS_OSPF6_DEBUG_ASBR || IS_OSPF6_DEBUG_ORIGINATE(AS_EXTERNAL)) { | |
67 | prefix2str(&route->prefix, buf, sizeof(buf)); | |
68 | zlog_debug("Originate AS-External-LSA for %s", buf); | |
69 | } | |
70 | ||
71 | /* prepare buffer */ | |
72 | memset(buffer, 0, sizeof(buffer)); | |
73 | lsa_header = (struct ospf6_lsa_header *)buffer; | |
74 | as_external_lsa = (struct ospf6_as_external_lsa | |
75 | *)((caddr_t)lsa_header | |
76 | + sizeof(struct ospf6_lsa_header)); | |
77 | p = (caddr_t)((caddr_t)as_external_lsa | |
78 | + sizeof(struct ospf6_as_external_lsa)); | |
79 | ||
80 | /* Fill AS-External-LSA */ | |
81 | /* Metric type */ | |
82 | if (route->path.metric_type == 2) | |
83 | SET_FLAG(as_external_lsa->bits_metric, OSPF6_ASBR_BIT_E); | |
84 | else | |
85 | UNSET_FLAG(as_external_lsa->bits_metric, OSPF6_ASBR_BIT_E); | |
86 | ||
87 | /* forwarding address */ | |
88 | if (!IN6_IS_ADDR_UNSPECIFIED(&info->forwarding)) | |
89 | SET_FLAG(as_external_lsa->bits_metric, OSPF6_ASBR_BIT_F); | |
90 | else | |
91 | UNSET_FLAG(as_external_lsa->bits_metric, OSPF6_ASBR_BIT_F); | |
92 | ||
93 | /* external route tag */ | |
94 | if (info->tag) | |
95 | SET_FLAG(as_external_lsa->bits_metric, OSPF6_ASBR_BIT_T); | |
96 | else | |
97 | UNSET_FLAG(as_external_lsa->bits_metric, OSPF6_ASBR_BIT_T); | |
98 | ||
99 | /* Set metric */ | |
100 | OSPF6_ASBR_METRIC_SET(as_external_lsa, route->path.cost); | |
101 | ||
102 | /* prefixlen */ | |
103 | as_external_lsa->prefix.prefix_length = route->prefix.prefixlen; | |
104 | ||
105 | /* PrefixOptions */ | |
106 | as_external_lsa->prefix.prefix_options = route->path.prefix_options; | |
107 | ||
108 | /* don't use refer LS-type */ | |
109 | as_external_lsa->prefix.prefix_refer_lstype = htons(0); | |
110 | ||
111 | /* set Prefix */ | |
112 | memcpy(p, &route->prefix.u.prefix6, | |
113 | OSPF6_PREFIX_SPACE(route->prefix.prefixlen)); | |
114 | ospf6_prefix_apply_mask(&as_external_lsa->prefix); | |
115 | p += OSPF6_PREFIX_SPACE(route->prefix.prefixlen); | |
116 | ||
117 | /* Forwarding address */ | |
118 | if (CHECK_FLAG(as_external_lsa->bits_metric, OSPF6_ASBR_BIT_F)) { | |
119 | memcpy(p, &info->forwarding, sizeof(struct in6_addr)); | |
120 | p += sizeof(struct in6_addr); | |
121 | } | |
122 | ||
123 | /* External Route Tag */ | |
124 | if (CHECK_FLAG(as_external_lsa->bits_metric, OSPF6_ASBR_BIT_T)) { | |
125 | route_tag_t network_order = htonl(info->tag); | |
126 | ||
127 | memcpy(p, &network_order, sizeof(network_order)); | |
128 | p += sizeof(network_order); | |
129 | } | |
130 | ||
131 | /* Fill LSA Header */ | |
132 | lsa_header->age = 0; | |
133 | lsa_header->type = htons(OSPF6_LSTYPE_AS_EXTERNAL); | |
134 | lsa_header->id = route->path.origin.id; | |
135 | lsa_header->adv_router = ospf6->router_id; | |
136 | lsa_header->seqnum = | |
137 | ospf6_new_ls_seqnum(lsa_header->type, lsa_header->id, | |
138 | lsa_header->adv_router, ospf6->lsdb); | |
139 | lsa_header->length = htons((caddr_t)p - (caddr_t)lsa_header); | |
140 | ||
141 | /* LSA checksum */ | |
142 | ospf6_lsa_checksum(lsa_header); | |
143 | ||
144 | /* create LSA */ | |
145 | lsa = ospf6_lsa_create(lsa_header); | |
146 | ||
147 | /* Originate */ | |
148 | ospf6_lsa_originate_process(lsa, ospf6); | |
718e3744 | 149 | } |
150 | ||
76249532 CS |
151 | int ospf6_orig_as_external_lsa(struct thread *thread) |
152 | { | |
153 | struct ospf6_interface *oi; | |
154 | struct ospf6_lsa *lsa; | |
155 | uint32_t type, adv_router; | |
156 | ||
157 | oi = (struct ospf6_interface *)THREAD_ARG(thread); | |
158 | oi->thread_as_extern_lsa = NULL; | |
159 | ||
160 | if (oi->state == OSPF6_INTERFACE_DOWN) | |
161 | return 0; | |
162 | ||
163 | type = htons(OSPF6_LSTYPE_AS_EXTERNAL); | |
164 | adv_router = oi->area->ospf6->router_id; | |
165 | for (ALL_LSDB_TYPED_ADVRTR(ospf6->lsdb, type, adv_router, lsa)) { | |
166 | if (IS_OSPF6_DEBUG_ASBR) | |
996c9314 LB |
167 | zlog_debug( |
168 | "%s: Send update of AS-External LSA %s seq 0x%x", | |
169 | __PRETTY_FUNCTION__, lsa->name, | |
170 | ntohl(lsa->header->seqnum)); | |
76249532 CS |
171 | |
172 | ospf6_flood_interface(NULL, lsa, oi); | |
173 | } | |
174 | ||
175 | return 0; | |
176 | } | |
177 | ||
d62a17ae | 178 | static route_tag_t ospf6_as_external_lsa_get_tag(struct ospf6_lsa *lsa) |
464015fa | 179 | { |
d62a17ae | 180 | struct ospf6_as_external_lsa *external; |
181 | ptrdiff_t tag_offset; | |
182 | route_tag_t network_order; | |
464015fa | 183 | |
d62a17ae | 184 | if (!lsa) |
185 | return 0; | |
464015fa | 186 | |
d62a17ae | 187 | external = (struct ospf6_as_external_lsa *)OSPF6_LSA_HEADER_END( |
188 | lsa->header); | |
464015fa | 189 | |
d62a17ae | 190 | if (!CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_T)) |
191 | return 0; | |
464015fa | 192 | |
d62a17ae | 193 | tag_offset = sizeof(*external) |
194 | + OSPF6_PREFIX_SPACE(external->prefix.prefix_length); | |
195 | if (CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_F)) | |
196 | tag_offset += sizeof(struct in6_addr); | |
464015fa | 197 | |
d62a17ae | 198 | memcpy(&network_order, (caddr_t)external + tag_offset, |
199 | sizeof(network_order)); | |
200 | return ntohl(network_order); | |
464015fa | 201 | } |
6b0655a2 | 202 | |
064d4355 CS |
203 | void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old, |
204 | struct ospf6_route *route) | |
205 | { | |
206 | struct ospf6_route *old_route; | |
207 | struct ospf6_path *ecmp_path, *o_path = NULL; | |
07b37f93 | 208 | struct listnode *anode, *anext; |
064d4355 CS |
209 | struct listnode *nnode, *rnode, *rnext; |
210 | struct ospf6_nexthop *nh, *rnh; | |
211 | char buf[PREFIX2STR_BUFFER]; | |
212 | bool route_found = false; | |
213 | ||
07b37f93 CS |
214 | /* check for old entry match with new route origin, |
215 | * delete old entry. | |
216 | */ | |
064d4355 | 217 | for (old_route = old; old_route; old_route = old_route->next) { |
07b37f93 CS |
218 | bool route_updated = false; |
219 | ||
996c9314 LB |
220 | if (!ospf6_route_is_same(old_route, route) |
221 | || (old_route->path.type != route->path.type)) | |
07b37f93 CS |
222 | continue; |
223 | ||
224 | /* Current and New route has same origin, | |
225 | * delete old entry. | |
226 | */ | |
227 | for (ALL_LIST_ELEMENTS(old_route->paths, anode, anext, | |
996c9314 | 228 | o_path)) { |
07b37f93 CS |
229 | /* Check old route path and route has same |
230 | * origin. | |
231 | */ | |
996c9314 LB |
232 | if (o_path->area_id != route->path.area_id |
233 | || (memcmp(&(o_path)->origin, &(route)->path.origin, | |
234 | sizeof(struct ospf6_ls_origin)) | |
235 | != 0)) | |
07b37f93 CS |
236 | continue; |
237 | ||
238 | /* Cost is not same then delete current path */ | |
996c9314 LB |
239 | if ((o_path->cost == route->path.cost) |
240 | && (o_path->u.cost_e2 == route->path.u.cost_e2)) | |
07b37f93 | 241 | continue; |
064d4355 CS |
242 | |
243 | if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) { | |
244 | prefix2str(&old_route->prefix, buf, | |
245 | sizeof(buf)); | |
996c9314 LB |
246 | zlog_debug( |
247 | "%s: route %s cost old %u new %u is not same, replace route", | |
248 | __PRETTY_FUNCTION__, buf, o_path->cost, | |
249 | route->path.cost); | |
07b37f93 CS |
250 | } |
251 | ||
252 | /* Remove selected current rout path's nh from | |
253 | * effective nh list. | |
254 | */ | |
255 | for (ALL_LIST_ELEMENTS_RO(o_path->nh_list, nnode, nh)) { | |
256 | for (ALL_LIST_ELEMENTS(old_route->nh_list, | |
996c9314 | 257 | rnode, rnext, rnh)) { |
07b37f93 CS |
258 | if (!ospf6_nexthop_is_same(rnh, nh)) |
259 | continue; | |
260 | listnode_delete(old_route->nh_list, | |
996c9314 | 261 | rnh); |
07b37f93 | 262 | ospf6_nexthop_delete(rnh); |
07b37f93 CS |
263 | } |
264 | } | |
265 | ||
266 | listnode_delete(old_route->paths, o_path); | |
267 | ospf6_path_free(o_path); | |
804a3294 | 268 | route_updated = true; |
07b37f93 CS |
269 | |
270 | /* Current route's path (adv_router info) is similar | |
271 | * to route being added. | |
272 | * Replace current route's path with paths list head. | |
273 | * Update FIB with effective NHs. | |
274 | */ | |
275 | if (listcount(old_route->paths)) { | |
804a3294 CS |
276 | for (ALL_LIST_ELEMENTS(old_route->paths, |
277 | anode, anext, o_path)) { | |
278 | ospf6_merge_nexthops( | |
279 | old_route->nh_list, | |
280 | o_path->nh_list); | |
281 | } | |
282 | /* Update RIB/FIB with effective | |
283 | * nh_list | |
284 | */ | |
285 | if (ospf6->route_table->hook_add) | |
286 | (*ospf6->route_table->hook_add) | |
287 | (old_route); | |
288 | ||
996c9314 LB |
289 | if (old_route->path.origin.id |
290 | == route->path.origin.id | |
291 | && old_route->path.origin.adv_router | |
292 | == route->path.origin | |
293 | .adv_router) { | |
07b37f93 CS |
294 | struct ospf6_path *h_path; |
295 | ||
296 | h_path = (struct ospf6_path *) | |
996c9314 LB |
297 | listgetdata(listhead( |
298 | old_route->paths)); | |
07b37f93 CS |
299 | old_route->path.origin.type = |
300 | h_path->origin.type; | |
301 | old_route->path.origin.id = | |
302 | h_path->origin.id; | |
303 | old_route->path.origin.adv_router = | |
304 | h_path->origin.adv_router; | |
305 | } | |
07b37f93 CS |
306 | } else { |
307 | if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) { | |
308 | prefix2str(&old_route->prefix, buf, | |
309 | sizeof(buf)); | |
996c9314 LB |
310 | zlog_debug( |
311 | "%s: route %s old cost %u new cost %u, delete old entry.", | |
312 | __PRETTY_FUNCTION__, buf, | |
313 | old_route->path.cost, | |
314 | route->path.cost); | |
07b37f93 CS |
315 | } |
316 | ospf6_route_remove(old_route, | |
317 | ospf6->route_table); | |
07b37f93 CS |
318 | } |
319 | } | |
320 | if (route_updated) | |
321 | break; | |
322 | } | |
323 | ||
324 | /* Add new route */ | |
325 | for (old_route = old; old_route; old_route = old_route->next) { | |
326 | ||
327 | /* Current and New Route prefix or route type | |
328 | * is not same skip this current node. | |
329 | */ | |
996c9314 LB |
330 | if (!ospf6_route_is_same(old_route, route) |
331 | || (old_route->path.type != route->path.type)) | |
07b37f93 CS |
332 | continue; |
333 | ||
334 | /* Old Route and New Route have Equal Cost, Merge NHs */ | |
996c9314 LB |
335 | if ((old_route->path.cost == route->path.cost) |
336 | && (old_route->path.u.cost_e2 == route->path.u.cost_e2)) { | |
07b37f93 CS |
337 | |
338 | if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) { | |
339 | prefix2str(&old_route->prefix, buf, | |
340 | sizeof(buf)); | |
996c9314 LB |
341 | zlog_debug( |
342 | "%s: old route %s path cost %u e2 %u", | |
343 | __PRETTY_FUNCTION__, buf, | |
344 | old_route->path.cost, | |
345 | old_route->path.u.cost_e2); | |
064d4355 CS |
346 | } |
347 | route_found = true; | |
348 | /* check if this path exists already in | |
349 | * route->paths list, if so, replace nh_list | |
350 | * from asbr_entry. | |
351 | */ | |
352 | for (ALL_LIST_ELEMENTS_RO(old_route->paths, anode, | |
353 | o_path)) { | |
996c9314 LB |
354 | if (o_path->area_id == route->path.area_id |
355 | && (memcmp(&(o_path)->origin, | |
356 | &(route)->path.origin, | |
357 | sizeof(struct ospf6_ls_origin)) | |
358 | == 0)) | |
064d4355 CS |
359 | break; |
360 | } | |
361 | /* If path is not found in old_route paths's list, | |
362 | * add a new path to route paths list and merge | |
363 | * nexthops in route->path->nh_list. | |
364 | * Otherwise replace existing path's nh_list. | |
365 | */ | |
366 | if (o_path == NULL) { | |
367 | ecmp_path = ospf6_path_dup(&route->path); | |
368 | ||
369 | /* Add a nh_list to new ecmp path */ | |
370 | ospf6_copy_nexthops(ecmp_path->nh_list, | |
371 | route->nh_list); | |
064d4355 CS |
372 | |
373 | /* Add the new path to route's path list */ | |
374 | listnode_add_sort(old_route->paths, ecmp_path); | |
375 | ||
376 | if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) { | |
377 | prefix2str(&route->prefix, buf, | |
378 | sizeof(buf)); | |
996c9314 LB |
379 | zlog_debug( |
380 | "%s: route %s another path added with nh %u, effective paths %u nh %u", | |
064d4355 CS |
381 | __PRETTY_FUNCTION__, buf, |
382 | listcount(ecmp_path->nh_list), | |
996c9314 LB |
383 | old_route->paths |
384 | ? listcount( | |
385 | old_route | |
386 | ->paths) | |
387 | : 0, | |
07b37f93 | 388 | listcount(old_route->nh_list)); |
064d4355 CS |
389 | } |
390 | } else { | |
064d4355 CS |
391 | list_delete_all_node(o_path->nh_list); |
392 | ospf6_copy_nexthops(o_path->nh_list, | |
996c9314 | 393 | route->nh_list); |
804a3294 | 394 | } |
064d4355 | 395 | |
804a3294 CS |
396 | /* Reset nexthop lists, rebuild from brouter table |
397 | * for each adv. router. | |
398 | */ | |
399 | list_delete_all_node(old_route->nh_list); | |
064d4355 | 400 | |
804a3294 CS |
401 | for (ALL_LIST_ELEMENTS_RO(old_route->paths, anode, |
402 | o_path)) { | |
403 | struct ospf6_route *asbr_entry; | |
404 | ||
405 | asbr_entry = ospf6_route_lookup( | |
406 | &o_path->ls_prefix, | |
407 | ospf6->brouter_table); | |
408 | if (asbr_entry == NULL) { | |
409 | if (IS_OSPF6_DEBUG_EXAMIN( | |
410 | AS_EXTERNAL)) { | |
411 | prefix2str(&old_route->prefix, | |
412 | buf, sizeof(buf)); | |
413 | zlog_debug("%s: ls_prfix %s asbr_entry not found.", | |
414 | __PRETTY_FUNCTION__, | |
415 | buf); | |
416 | } | |
417 | continue; | |
064d4355 | 418 | } |
804a3294 CS |
419 | ospf6_route_merge_nexthops(old_route, |
420 | asbr_entry); | |
421 | } | |
064d4355 | 422 | |
804a3294 CS |
423 | if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) { |
424 | prefix2str(&route->prefix, buf, sizeof(buf)); | |
425 | zlog_debug("%s: route %s with effective paths %u nh %u", | |
426 | __PRETTY_FUNCTION__, buf, | |
427 | old_route->paths ? | |
428 | listcount(old_route->paths) : 0, | |
429 | old_route->nh_list ? | |
430 | listcount(old_route->nh_list) : 0); | |
064d4355 | 431 | } |
804a3294 CS |
432 | |
433 | /* Update RIB/FIB */ | |
434 | if (ospf6->route_table->hook_add) | |
435 | (*ospf6->route_table->hook_add)(old_route); | |
436 | ||
064d4355 CS |
437 | /* Delete the new route its info added to existing |
438 | * route. | |
439 | */ | |
440 | ospf6_route_delete(route); | |
07b37f93 | 441 | |
064d4355 CS |
442 | break; |
443 | } | |
444 | } | |
445 | ||
446 | if (!route_found) { | |
447 | /* Add new route to existing node in ospf6 route table. */ | |
448 | ospf6_route_add(route, ospf6->route_table); | |
449 | } | |
450 | } | |
451 | ||
d62a17ae | 452 | void ospf6_asbr_lsa_add(struct ospf6_lsa *lsa) |
718e3744 | 453 | { |
d62a17ae | 454 | struct ospf6_as_external_lsa *external; |
455 | struct prefix asbr_id; | |
064d4355 CS |
456 | struct ospf6_route *asbr_entry, *route, *old; |
457 | struct ospf6_path *path; | |
d62a17ae | 458 | char buf[PREFIX2STR_BUFFER]; |
459 | ||
460 | external = (struct ospf6_as_external_lsa *)OSPF6_LSA_HEADER_END( | |
461 | lsa->header); | |
462 | ||
463 | if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) | |
464 | zlog_debug("Calculate AS-External route for %s", lsa->name); | |
465 | ||
466 | if (lsa->header->adv_router == ospf6->router_id) { | |
467 | if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) | |
468 | zlog_debug("Ignore self-originated AS-External-LSA"); | |
469 | return; | |
470 | } | |
471 | ||
472 | if (OSPF6_ASBR_METRIC(external) == OSPF_LS_INFINITY) { | |
473 | if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) | |
474 | zlog_debug("Ignore LSA with LSInfinity Metric"); | |
475 | return; | |
476 | } | |
477 | ||
478 | if (CHECK_FLAG(external->prefix.prefix_options, | |
479 | OSPF6_PREFIX_OPTION_NU)) { | |
480 | if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) | |
481 | zlog_debug("Ignore LSA with NU bit set Metric"); | |
482 | return; | |
483 | } | |
484 | ||
485 | ospf6_linkstate_prefix(lsa->header->adv_router, htonl(0), &asbr_id); | |
486 | asbr_entry = ospf6_route_lookup(&asbr_id, ospf6->brouter_table); | |
487 | if (asbr_entry == NULL | |
488 | || !CHECK_FLAG(asbr_entry->path.router_bits, OSPF6_ROUTER_BIT_E)) { | |
489 | if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) { | |
490 | prefix2str(&asbr_id, buf, sizeof(buf)); | |
491 | zlog_debug("ASBR entry not found: %s", buf); | |
492 | } | |
493 | return; | |
494 | } | |
495 | ||
496 | route = ospf6_route_create(); | |
497 | route->type = OSPF6_DEST_TYPE_NETWORK; | |
498 | route->prefix.family = AF_INET6; | |
499 | route->prefix.prefixlen = external->prefix.prefix_length; | |
b8ce0c36 | 500 | ospf6_prefix_in6_addr(&route->prefix.u.prefix6, external, |
501 | &external->prefix); | |
d62a17ae | 502 | |
503 | route->path.area_id = asbr_entry->path.area_id; | |
504 | route->path.origin.type = lsa->header->type; | |
505 | route->path.origin.id = lsa->header->id; | |
506 | route->path.origin.adv_router = lsa->header->adv_router; | |
d62a17ae | 507 | route->path.prefix_options = external->prefix.prefix_options; |
804a3294 CS |
508 | memcpy(&route->path.ls_prefix, &asbr_id, sizeof(struct prefix)); |
509 | ||
d62a17ae | 510 | if (CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_E)) { |
511 | route->path.type = OSPF6_PATH_TYPE_EXTERNAL2; | |
512 | route->path.metric_type = 2; | |
513 | route->path.cost = asbr_entry->path.cost; | |
514 | route->path.u.cost_e2 = OSPF6_ASBR_METRIC(external); | |
515 | } else { | |
516 | route->path.type = OSPF6_PATH_TYPE_EXTERNAL1; | |
517 | route->path.metric_type = 1; | |
518 | route->path.cost = | |
519 | asbr_entry->path.cost + OSPF6_ASBR_METRIC(external); | |
520 | route->path.u.cost_e2 = 0; | |
521 | } | |
522 | ||
523 | route->path.tag = ospf6_as_external_lsa_get_tag(lsa); | |
524 | ||
525 | ospf6_route_copy_nexthops(route, asbr_entry); | |
526 | ||
064d4355 CS |
527 | path = ospf6_path_dup(&route->path); |
528 | ospf6_copy_nexthops(path->nh_list, asbr_entry->nh_list); | |
529 | listnode_add_sort(route->paths, path); | |
530 | ||
531 | ||
d62a17ae | 532 | if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) { |
533 | prefix2str(&route->prefix, buf, sizeof(buf)); | |
064d4355 CS |
534 | zlog_debug("%s: AS-External %u route add %s cost %u(%u) nh %u", |
535 | __PRETTY_FUNCTION__, | |
996c9314 LB |
536 | (route->path.type == OSPF6_PATH_TYPE_EXTERNAL1) ? 1 |
537 | : 2, | |
538 | buf, route->path.cost, route->path.u.cost_e2, | |
064d4355 CS |
539 | listcount(route->nh_list)); |
540 | } | |
541 | ||
542 | old = ospf6_route_lookup(&route->prefix, ospf6->route_table); | |
543 | if (!old) { | |
544 | /* Add the new route to ospf6 instance route table. */ | |
545 | ospf6_route_add(route, ospf6->route_table); | |
546 | } else { | |
547 | /* RFC 2328 16.4 (6) | |
548 | * ECMP: Keep new equal preference path in current | |
549 | * route's path list, update zebra with new effective | |
550 | * list along with addition of ECMP path. | |
551 | */ | |
552 | ospf6_asbr_update_route_ecmp_path(old, route); | |
d62a17ae | 553 | } |
718e3744 | 554 | } |
555 | ||
07b37f93 CS |
556 | void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa, |
557 | struct ospf6_route *asbr_entry) | |
718e3744 | 558 | { |
d62a17ae | 559 | struct ospf6_as_external_lsa *external; |
560 | struct prefix prefix; | |
07b37f93 | 561 | struct ospf6_route *route, *nroute, *route_to_del; |
d62a17ae | 562 | char buf[PREFIX2STR_BUFFER]; |
563 | ||
564 | external = (struct ospf6_as_external_lsa *)OSPF6_LSA_HEADER_END( | |
565 | lsa->header); | |
566 | ||
567 | if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) | |
568 | zlog_debug("Withdraw AS-External route for %s", lsa->name); | |
569 | ||
570 | if (lsa->header->adv_router == ospf6->router_id) { | |
571 | if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) | |
572 | zlog_debug("Ignore self-originated AS-External-LSA"); | |
573 | return; | |
574 | } | |
575 | ||
07b37f93 CS |
576 | route_to_del = ospf6_route_create(); |
577 | route_to_del->type = OSPF6_DEST_TYPE_NETWORK; | |
578 | route_to_del->prefix.family = AF_INET6; | |
579 | route_to_del->prefix.prefixlen = external->prefix.prefix_length; | |
b8ce0c36 | 580 | ospf6_prefix_in6_addr(&route_to_del->prefix.u.prefix6, external, |
07b37f93 CS |
581 | &external->prefix); |
582 | ||
583 | route_to_del->path.origin.type = lsa->header->type; | |
584 | route_to_del->path.origin.id = lsa->header->id; | |
585 | route_to_del->path.origin.adv_router = lsa->header->adv_router; | |
586 | ||
587 | if (asbr_entry) { | |
588 | route_to_del->path.area_id = asbr_entry->path.area_id; | |
589 | if (CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_E)) { | |
590 | route_to_del->path.type = OSPF6_PATH_TYPE_EXTERNAL2; | |
591 | route_to_del->path.metric_type = 2; | |
592 | route_to_del->path.cost = asbr_entry->path.cost; | |
593 | route_to_del->path.u.cost_e2 = | |
594 | OSPF6_ASBR_METRIC(external); | |
595 | } else { | |
596 | route_to_del->path.type = OSPF6_PATH_TYPE_EXTERNAL1; | |
597 | route_to_del->path.metric_type = 1; | |
996c9314 LB |
598 | route_to_del->path.cost = asbr_entry->path.cost |
599 | + OSPF6_ASBR_METRIC(external); | |
07b37f93 CS |
600 | route_to_del->path.u.cost_e2 = 0; |
601 | } | |
602 | } | |
603 | ||
d62a17ae | 604 | memset(&prefix, 0, sizeof(struct prefix)); |
605 | prefix.family = AF_INET6; | |
606 | prefix.prefixlen = external->prefix.prefix_length; | |
b8ce0c36 | 607 | ospf6_prefix_in6_addr(&prefix.u.prefix6, external, &external->prefix); |
d62a17ae | 608 | |
609 | route = ospf6_route_lookup(&prefix, ospf6->route_table); | |
610 | if (route == NULL) { | |
611 | if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) { | |
612 | prefix2str(&prefix, buf, sizeof(buf)); | |
613 | zlog_debug("AS-External route %s not found", buf); | |
614 | } | |
267bf505 DS |
615 | |
616 | ospf6_route_delete(route_to_del); | |
d62a17ae | 617 | return; |
618 | } | |
619 | ||
07b37f93 CS |
620 | if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) { |
621 | prefix2str(&prefix, buf, sizeof(buf)); | |
996c9314 LB |
622 | zlog_debug( |
623 | "%s: Current route %s cost %u e2 %u, route to del cost %u e2 %u", | |
624 | __PRETTY_FUNCTION__, buf, route->path.cost, | |
625 | route->path.u.cost_e2, route_to_del->path.cost, | |
626 | route_to_del->path.u.cost_e2); | |
07b37f93 CS |
627 | } |
628 | ||
996c9314 LB |
629 | for (ospf6_route_lock(route); |
630 | route && ospf6_route_is_prefix(&prefix, route); route = nroute) { | |
d62a17ae | 631 | nroute = ospf6_route_next(route); |
07b37f93 | 632 | |
d62a17ae | 633 | if (route->type != OSPF6_DEST_TYPE_NETWORK) |
634 | continue; | |
064d4355 | 635 | |
07b37f93 CS |
636 | /* Route has multiple ECMP paths, remove matching |
637 | * path. Update current route's effective nh list | |
638 | * after removal of one of the path. | |
064d4355 CS |
639 | */ |
640 | if (listcount(route->paths) > 1) { | |
641 | struct listnode *anode, *anext; | |
642 | struct listnode *nnode, *rnode, *rnext; | |
643 | struct ospf6_nexthop *nh, *rnh; | |
644 | struct ospf6_path *o_path; | |
645 | bool nh_updated = false; | |
646 | ||
647 | /* Iterate all paths of route to find maching with LSA | |
648 | * remove from route path list. If route->path is same, | |
649 | * replace from paths list. | |
650 | */ | |
651 | for (ALL_LIST_ELEMENTS(route->paths, anode, anext, | |
996c9314 | 652 | o_path)) { |
07b37f93 | 653 | if ((o_path->origin.type != lsa->header->type) |
996c9314 LB |
654 | || (o_path->origin.adv_router |
655 | != lsa->header->adv_router) | |
656 | || (o_path->origin.id != lsa->header->id)) | |
064d4355 | 657 | continue; |
07b37f93 CS |
658 | |
659 | /* Compare LSA cost with current | |
660 | * route info. | |
661 | */ | |
996c9314 LB |
662 | if (!asbr_entry |
663 | && (o_path->cost != route_to_del->path.cost | |
664 | || o_path->u.cost_e2 | |
665 | != route_to_del->path.u | |
666 | .cost_e2)) { | |
07b37f93 | 667 | if (IS_OSPF6_DEBUG_EXAMIN( |
996c9314 | 668 | AS_EXTERNAL)) { |
07b37f93 CS |
669 | prefix2str(&prefix, buf, |
670 | sizeof(buf)); | |
671 | zlog_debug( | |
996c9314 LB |
672 | "%s: route %s to delete is not same, cost %u del cost %u. skip", |
673 | __PRETTY_FUNCTION__, | |
674 | buf, route->path.cost, | |
675 | route_to_del->path | |
676 | .cost); | |
07b37f93 | 677 | } |
064d4355 | 678 | continue; |
07b37f93 | 679 | } |
064d4355 | 680 | |
996c9314 | 681 | if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) { |
064d4355 CS |
682 | prefix2str(&prefix, buf, sizeof(buf)); |
683 | zlog_debug( | |
8873ebd3 | 684 | "%s: route %s path found with cost %u nh %u to remove.", |
064d4355 | 685 | __PRETTY_FUNCTION__, buf, |
8873ebd3 | 686 | route->path.cost, |
064d4355 CS |
687 | listcount(o_path->nh_list)); |
688 | } | |
689 | ||
690 | /* Remove found path's nh_list from | |
691 | * the route's nh_list. | |
692 | */ | |
693 | for (ALL_LIST_ELEMENTS_RO(o_path->nh_list, | |
694 | nnode, nh)) { | |
695 | for (ALL_LIST_ELEMENTS(route->nh_list, | |
996c9314 LB |
696 | rnode, rnext, |
697 | rnh)) { | |
064d4355 | 698 | if (!ospf6_nexthop_is_same(rnh, |
996c9314 | 699 | nh)) |
064d4355 CS |
700 | continue; |
701 | listnode_delete(route->nh_list, | |
702 | rnh); | |
703 | ospf6_nexthop_delete(rnh); | |
704 | } | |
705 | } | |
706 | /* Delete the path from route's path list */ | |
707 | listnode_delete(route->paths, o_path); | |
708 | ospf6_path_free(o_path); | |
709 | nh_updated = true; | |
710 | } | |
711 | ||
712 | if (nh_updated) { | |
713 | /* Iterate all paths and merge nexthop, | |
714 | * unlesss any of the nexthop similar to | |
715 | * ones deleted as part of path deletion. | |
716 | */ | |
717 | ||
718 | for (ALL_LIST_ELEMENTS(route->paths, anode, | |
719 | anext, o_path)) { | |
720 | ospf6_merge_nexthops(route->nh_list, | |
721 | o_path->nh_list); | |
722 | } | |
723 | ||
724 | if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) { | |
725 | prefix2str(&route->prefix, buf, | |
726 | sizeof(buf)); | |
996c9314 LB |
727 | zlog_debug( |
728 | "%s: AS-External %u route %s update paths %u nh %u", | |
729 | __PRETTY_FUNCTION__, | |
730 | (route->path.type | |
731 | == OSPF6_PATH_TYPE_EXTERNAL1) | |
732 | ? 1 | |
733 | : 2, | |
734 | buf, listcount(route->paths), | |
4f4060f6 DL |
735 | route->nh_list ? |
736 | listcount(route->nh_list) : 0); | |
064d4355 CS |
737 | } |
738 | ||
8873ebd3 CS |
739 | if (listcount(route->paths)) { |
740 | /* Update RIB/FIB with effective | |
741 | * nh_list | |
742 | */ | |
743 | if (ospf6->route_table->hook_add) | |
744 | (*ospf6->route_table->hook_add) | |
745 | (route); | |
064d4355 | 746 | |
8873ebd3 CS |
747 | /* route's primary path is similar |
748 | * to LSA, replace route's primary | |
749 | * path with route's paths list head. | |
750 | */ | |
751 | if ((route->path.origin.id == | |
752 | lsa->header->id) && | |
753 | (route->path.origin.adv_router | |
754 | == lsa->header->adv_router)) { | |
755 | struct ospf6_path *h_path; | |
064d4355 | 756 | |
8873ebd3 | 757 | h_path = (struct ospf6_path *) |
996c9314 LB |
758 | listgetdata( |
759 | listhead(route->paths)); | |
8873ebd3 CS |
760 | route->path.origin.type = |
761 | h_path->origin.type; | |
762 | route->path.origin.id = | |
763 | h_path->origin.id; | |
764 | route->path.origin.adv_router = | |
064d4355 | 765 | h_path->origin.adv_router; |
8873ebd3 CS |
766 | } |
767 | } else { | |
768 | ospf6_route_remove(route, | |
769 | ospf6->route_table); | |
064d4355 CS |
770 | } |
771 | } | |
d62a17ae | 772 | continue; |
773 | ||
064d4355 | 774 | } else { |
07b37f93 CS |
775 | /* Compare LSA origin and cost with current route info. |
776 | * if any check fails skip del this route node. | |
777 | */ | |
996c9314 LB |
778 | if (asbr_entry |
779 | && (!ospf6_route_is_same_origin(route, route_to_del) | |
780 | || (route->path.type != route_to_del->path.type) | |
781 | || (route->path.cost != route_to_del->path.cost) | |
782 | || (route->path.u.cost_e2 | |
783 | != route_to_del->path.u.cost_e2))) { | |
07b37f93 CS |
784 | if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) { |
785 | prefix2str(&prefix, buf, sizeof(buf)); | |
996c9314 LB |
786 | zlog_debug( |
787 | "%s: route %s to delete is not same, cost %u del cost %u. skip", | |
788 | __PRETTY_FUNCTION__, buf, | |
789 | route->path.cost, | |
790 | route_to_del->path.cost); | |
07b37f93 | 791 | } |
064d4355 | 792 | continue; |
07b37f93 CS |
793 | } |
794 | ||
996c9314 LB |
795 | if ((route->path.origin.type != lsa->header->type) |
796 | || (route->path.origin.adv_router | |
797 | != lsa->header->adv_router) | |
798 | || (route->path.origin.id != lsa->header->id)) | |
064d4355 CS |
799 | continue; |
800 | } | |
d62a17ae | 801 | if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) { |
802 | prefix2str(&route->prefix, buf, sizeof(buf)); | |
996c9314 LB |
803 | zlog_debug( |
804 | "%s: AS-External %u route remove %s cost %u(%u) nh %u", | |
805 | __PRETTY_FUNCTION__, | |
806 | route->path.type == OSPF6_PATH_TYPE_EXTERNAL1 | |
807 | ? 1 | |
808 | : 2, | |
809 | buf, route->path.cost, route->path.u.cost_e2, | |
810 | listcount(route->nh_list)); | |
d62a17ae | 811 | } |
812 | ospf6_route_remove(route, ospf6->route_table); | |
813 | } | |
814 | if (route != NULL) | |
815 | ospf6_route_unlock(route); | |
07b37f93 CS |
816 | |
817 | ospf6_route_delete(route_to_del); | |
718e3744 | 818 | } |
819 | ||
d62a17ae | 820 | void ospf6_asbr_lsentry_add(struct ospf6_route *asbr_entry) |
508e53e2 | 821 | { |
d62a17ae | 822 | struct ospf6_lsa *lsa; |
d7c0a89a QY |
823 | uint16_t type; |
824 | uint32_t router; | |
d62a17ae | 825 | |
826 | if (!CHECK_FLAG(asbr_entry->flag, OSPF6_ROUTE_BEST)) { | |
827 | char buf[16]; | |
828 | inet_ntop(AF_INET, &ADV_ROUTER_IN_PREFIX(&asbr_entry->prefix), | |
829 | buf, sizeof(buf)); | |
830 | zlog_info("ignore non-best path: lsentry %s add", buf); | |
831 | return; | |
832 | } | |
833 | ||
834 | type = htons(OSPF6_LSTYPE_AS_EXTERNAL); | |
835 | router = ospf6_linkstate_prefix_adv_router(&asbr_entry->prefix); | |
836 | for (ALL_LSDB_TYPED_ADVRTR(ospf6->lsdb, type, router, lsa)) { | |
837 | if (!OSPF6_LSA_IS_MAXAGE(lsa)) | |
838 | ospf6_asbr_lsa_add(lsa); | |
839 | } | |
508e53e2 | 840 | } |
841 | ||
d62a17ae | 842 | void ospf6_asbr_lsentry_remove(struct ospf6_route *asbr_entry) |
718e3744 | 843 | { |
d62a17ae | 844 | struct ospf6_lsa *lsa; |
d7c0a89a QY |
845 | uint16_t type; |
846 | uint32_t router; | |
d62a17ae | 847 | |
848 | type = htons(OSPF6_LSTYPE_AS_EXTERNAL); | |
849 | router = ospf6_linkstate_prefix_adv_router(&asbr_entry->prefix); | |
850 | for (ALL_LSDB_TYPED_ADVRTR(ospf6->lsdb, type, router, lsa)) | |
07b37f93 | 851 | ospf6_asbr_lsa_remove(lsa, asbr_entry); |
508e53e2 | 852 | } |
718e3744 | 853 | |
508e53e2 | 854 | |
508e53e2 | 855 | /* redistribute function */ |
856 | ||
d62a17ae | 857 | static void ospf6_asbr_routemap_set(int type, const char *mapname) |
508e53e2 | 858 | { |
d62a17ae | 859 | if (ospf6->rmap[type].name) |
860 | free(ospf6->rmap[type].name); | |
861 | ospf6->rmap[type].name = strdup(mapname); | |
862 | ospf6->rmap[type].map = route_map_lookup_by_name(mapname); | |
718e3744 | 863 | } |
864 | ||
d62a17ae | 865 | static void ospf6_asbr_routemap_unset(int type) |
718e3744 | 866 | { |
d62a17ae | 867 | if (ospf6->rmap[type].name) |
868 | free(ospf6->rmap[type].name); | |
869 | ospf6->rmap[type].name = NULL; | |
870 | ospf6->rmap[type].map = NULL; | |
508e53e2 | 871 | } |
872 | ||
856ae1eb CS |
873 | static int ospf6_asbr_routemap_update_timer(struct thread *thread) |
874 | { | |
875 | void **arg; | |
876 | int arg_type; | |
877 | ||
878 | arg = THREAD_ARG(thread); | |
879 | arg_type = (int)(intptr_t)arg[1]; | |
880 | ||
881 | ospf6->t_distribute_update = NULL; | |
882 | ||
883 | if (ospf6->rmap[arg_type].name) | |
996c9314 LB |
884 | ospf6->rmap[arg_type].map = |
885 | route_map_lookup_by_name(ospf6->rmap[arg_type].name); | |
856ae1eb CS |
886 | if (ospf6->rmap[arg_type].map) { |
887 | if (IS_OSPF6_DEBUG_ASBR) | |
888 | zlog_debug("%s: route-map %s update, reset redist %s", | |
889 | __PRETTY_FUNCTION__, | |
890 | ospf6->rmap[arg_type].name, | |
891 | ZROUTE_NAME(arg_type)); | |
892 | ||
893 | ospf6_zebra_no_redistribute(arg_type); | |
894 | ospf6_zebra_redistribute(arg_type); | |
895 | } | |
896 | ||
897 | XFREE(MTYPE_OSPF6_DIST_ARGS, arg); | |
898 | return 0; | |
899 | } | |
900 | ||
901 | void ospf6_asbr_distribute_list_update(int type) | |
902 | { | |
903 | void **args = NULL; | |
904 | ||
905 | if (ospf6->t_distribute_update) | |
906 | return; | |
907 | ||
996c9314 | 908 | args = XCALLOC(MTYPE_OSPF6_DIST_ARGS, sizeof(void *) * 2); |
856ae1eb CS |
909 | |
910 | args[0] = ospf6; | |
911 | args[1] = (void *)((ptrdiff_t)type); | |
912 | ||
913 | if (IS_OSPF6_DEBUG_ASBR) | |
914 | zlog_debug("%s: trigger redistribute %s reset thread", | |
915 | __PRETTY_FUNCTION__, ZROUTE_NAME(type)); | |
916 | ||
917 | ospf6->t_distribute_update = NULL; | |
918 | thread_add_timer_msec(master, ospf6_asbr_routemap_update_timer, | |
919 | (void **)args, OSPF_MIN_LS_INTERVAL, | |
920 | &ospf6->t_distribute_update); | |
921 | } | |
922 | ||
d62a17ae | 923 | static void ospf6_asbr_routemap_update(const char *mapname) |
508e53e2 | 924 | { |
d62a17ae | 925 | int type; |
926 | ||
927 | if (ospf6 == NULL) | |
928 | return; | |
929 | ||
930 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) { | |
c600ce45 | 931 | if (ospf6->rmap[type].name) { |
d62a17ae | 932 | ospf6->rmap[type].map = route_map_lookup_by_name( |
933 | ospf6->rmap[type].name); | |
c600ce45 | 934 | |
996c9314 LB |
935 | if (mapname && ospf6->rmap[type].map |
936 | && (strcmp(ospf6->rmap[type].name, mapname) == 0)) { | |
c600ce45 | 937 | if (IS_OSPF6_DEBUG_ASBR) |
996c9314 LB |
938 | zlog_debug( |
939 | "%s: route-map %s update, reset redist %s", | |
940 | __PRETTY_FUNCTION__, mapname, | |
941 | ZROUTE_NAME(type)); | |
856ae1eb | 942 | ospf6_asbr_distribute_list_update(type); |
c600ce45 CS |
943 | } |
944 | } else | |
d62a17ae | 945 | ospf6->rmap[type].map = NULL; |
946 | } | |
718e3744 | 947 | } |
948 | ||
856ae1eb CS |
949 | static void ospf6_asbr_routemap_event(route_map_event_t event, const char *name) |
950 | { | |
951 | int type; | |
952 | ||
953 | if (ospf6 == NULL) | |
954 | return; | |
955 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) { | |
996c9314 LB |
956 | if ((ospf6->rmap[type].name) |
957 | && (strcmp(ospf6->rmap[type].name, name) == 0)) { | |
856ae1eb CS |
958 | ospf6_asbr_distribute_list_update(type); |
959 | } | |
960 | } | |
961 | } | |
962 | ||
d62a17ae | 963 | int ospf6_asbr_is_asbr(struct ospf6 *o) |
508e53e2 | 964 | { |
d62a17ae | 965 | return o->external_table->count; |
508e53e2 | 966 | } |
967 | ||
d62a17ae | 968 | static void ospf6_asbr_redistribute_set(int type) |
718e3744 | 969 | { |
d62a17ae | 970 | ospf6_zebra_redistribute(type); |
508e53e2 | 971 | } |
972 | ||
d62a17ae | 973 | static void ospf6_asbr_redistribute_unset(int type) |
508e53e2 | 974 | { |
d62a17ae | 975 | struct ospf6_route *route; |
976 | struct ospf6_external_info *info; | |
718e3744 | 977 | |
d62a17ae | 978 | ospf6_zebra_no_redistribute(type); |
508e53e2 | 979 | |
d62a17ae | 980 | for (route = ospf6_route_head(ospf6->external_table); route; |
981 | route = ospf6_route_next(route)) { | |
982 | info = route->route_option; | |
983 | if (info->type != type) | |
984 | continue; | |
718e3744 | 985 | |
d62a17ae | 986 | ospf6_asbr_redistribute_remove(info->type, 0, &route->prefix); |
987 | } | |
d9628728 | 988 | |
d62a17ae | 989 | ospf6_asbr_routemap_unset(type); |
508e53e2 | 990 | } |
718e3744 | 991 | |
ca1f4309 | 992 | /* When an area is unstubified, flood all the external LSAs in the area */ |
d62a17ae | 993 | void ospf6_asbr_send_externals_to_area(struct ospf6_area *oa) |
ca1f4309 | 994 | { |
d62a17ae | 995 | struct ospf6_lsa *lsa; |
996 | ||
997 | for (ALL_LSDB(oa->ospf6->lsdb, lsa)) { | |
998 | if (ntohs(lsa->header->type) == OSPF6_LSTYPE_AS_EXTERNAL) { | |
999 | zlog_debug("%s: Flooding AS-External LSA %s\n", | |
1000 | __func__, lsa->name); | |
1001 | ospf6_flood_area(NULL, lsa, oa); | |
1002 | } | |
ca1f4309 | 1003 | } |
ca1f4309 DS |
1004 | } |
1005 | ||
d62a17ae | 1006 | void ospf6_asbr_redistribute_add(int type, ifindex_t ifindex, |
d7c0a89a QY |
1007 | struct prefix *prefix, |
1008 | unsigned int nexthop_num, | |
d62a17ae | 1009 | struct in6_addr *nexthop, route_tag_t tag) |
508e53e2 | 1010 | { |
d62a17ae | 1011 | int ret; |
1012 | struct ospf6_route troute; | |
1013 | struct ospf6_external_info tinfo; | |
1014 | struct ospf6_route *route, *match; | |
1015 | struct ospf6_external_info *info; | |
1016 | struct prefix prefix_id; | |
1017 | struct route_node *node; | |
1018 | char pbuf[PREFIX2STR_BUFFER], ibuf[16]; | |
1019 | struct listnode *lnode, *lnnode; | |
1020 | struct ospf6_area *oa; | |
1021 | ||
1022 | if (!ospf6_zebra_is_redistribute(type)) | |
1023 | return; | |
1024 | ||
6e38a9ec VJ |
1025 | memset(&troute, 0, sizeof(troute)); |
1026 | memset(&tinfo, 0, sizeof(tinfo)); | |
1027 | ||
d62a17ae | 1028 | if (IS_OSPF6_DEBUG_ASBR) { |
1029 | prefix2str(prefix, pbuf, sizeof(pbuf)); | |
1030 | zlog_debug("Redistribute %s (%s)", pbuf, ZROUTE_NAME(type)); | |
1031 | } | |
1032 | ||
1033 | /* if route-map was specified but not found, do not advertise */ | |
1034 | if (ospf6->rmap[type].name) { | |
1035 | if (ospf6->rmap[type].map == NULL) | |
1036 | ospf6_asbr_routemap_update(NULL); | |
1037 | if (ospf6->rmap[type].map == NULL) { | |
1038 | zlog_warn( | |
1039 | "route-map \"%s\" not found, suppress redistributing", | |
1040 | ospf6->rmap[type].name); | |
1041 | return; | |
1042 | } | |
1043 | } | |
1044 | ||
1045 | /* apply route-map */ | |
1046 | if (ospf6->rmap[type].map) { | |
d62a17ae | 1047 | troute.route_option = &tinfo; |
1048 | tinfo.ifindex = ifindex; | |
1049 | tinfo.tag = tag; | |
1050 | ||
1051 | ret = route_map_apply(ospf6->rmap[type].map, prefix, RMAP_OSPF6, | |
1052 | &troute); | |
1053 | if (ret == RMAP_DENYMATCH) { | |
1054 | if (IS_OSPF6_DEBUG_ASBR) | |
1055 | zlog_debug("Denied by route-map \"%s\"", | |
1056 | ospf6->rmap[type].name); | |
1057 | return; | |
1058 | } | |
1059 | } | |
1060 | ||
1061 | match = ospf6_route_lookup(prefix, ospf6->external_table); | |
1062 | if (match) { | |
1063 | info = match->route_option; | |
d62a17ae | 1064 | /* copy result of route-map */ |
1065 | if (ospf6->rmap[type].map) { | |
1066 | if (troute.path.metric_type) | |
1067 | match->path.metric_type = | |
1068 | troute.path.metric_type; | |
1069 | if (troute.path.cost) | |
1070 | match->path.cost = troute.path.cost; | |
1071 | if (!IN6_IS_ADDR_UNSPECIFIED(&tinfo.forwarding)) | |
1072 | memcpy(&info->forwarding, &tinfo.forwarding, | |
1073 | sizeof(struct in6_addr)); | |
1074 | info->tag = tinfo.tag; | |
1075 | } else { | |
1076 | /* If there is no route-map, simply update the tag */ | |
1077 | info->tag = tag; | |
1078 | } | |
1079 | ||
1080 | info->type = type; | |
1081 | ||
1082 | if (nexthop_num && nexthop) | |
1083 | ospf6_route_add_nexthop(match, ifindex, nexthop); | |
1084 | else | |
1085 | ospf6_route_add_nexthop(match, ifindex, NULL); | |
1086 | ||
1087 | /* create/update binding in external_id_table */ | |
1088 | prefix_id.family = AF_INET; | |
1089 | prefix_id.prefixlen = 32; | |
1090 | prefix_id.u.prefix4.s_addr = htonl(info->id); | |
1091 | node = route_node_get(ospf6->external_id_table, &prefix_id); | |
1092 | node->info = match; | |
1093 | ||
1094 | if (IS_OSPF6_DEBUG_ASBR) { | |
1095 | inet_ntop(AF_INET, &prefix_id.u.prefix4, ibuf, | |
1096 | sizeof(ibuf)); | |
856ae1eb | 1097 | prefix2str(prefix, pbuf, sizeof(pbuf)); |
996c9314 LB |
1098 | zlog_debug( |
1099 | "Advertise as AS-External Id:%s prefix %s metric %u", | |
1100 | ibuf, pbuf, match->path.metric_type); | |
d62a17ae | 1101 | } |
1102 | ||
1103 | match->path.origin.id = htonl(info->id); | |
1104 | ospf6_as_external_lsa_originate(match); | |
1105 | return; | |
1106 | } | |
1107 | ||
1108 | /* create new entry */ | |
1109 | route = ospf6_route_create(); | |
1110 | route->type = OSPF6_DEST_TYPE_NETWORK; | |
1111 | memcpy(&route->prefix, prefix, sizeof(struct prefix)); | |
1112 | ||
1113 | info = (struct ospf6_external_info *)XCALLOC( | |
1114 | MTYPE_OSPF6_EXTERNAL_INFO, sizeof(struct ospf6_external_info)); | |
1115 | route->route_option = info; | |
1116 | info->id = ospf6->external_id++; | |
1117 | ||
1118 | /* copy result of route-map */ | |
1119 | if (ospf6->rmap[type].map) { | |
1120 | if (troute.path.metric_type) | |
1121 | route->path.metric_type = troute.path.metric_type; | |
1122 | if (troute.path.cost) | |
1123 | route->path.cost = troute.path.cost; | |
1124 | if (!IN6_IS_ADDR_UNSPECIFIED(&tinfo.forwarding)) | |
1125 | memcpy(&info->forwarding, &tinfo.forwarding, | |
1126 | sizeof(struct in6_addr)); | |
1127 | info->tag = tinfo.tag; | |
1128 | } else { | |
1129 | /* If there is no route-map, simply set the tag */ | |
1130 | info->tag = tag; | |
1131 | } | |
1132 | ||
1133 | info->type = type; | |
1134 | if (nexthop_num && nexthop) | |
1135 | ospf6_route_add_nexthop(route, ifindex, nexthop); | |
1136 | else | |
1137 | ospf6_route_add_nexthop(route, ifindex, NULL); | |
1138 | ||
1139 | /* create/update binding in external_id_table */ | |
1140 | prefix_id.family = AF_INET; | |
1141 | prefix_id.prefixlen = 32; | |
1142 | prefix_id.u.prefix4.s_addr = htonl(info->id); | |
1143 | node = route_node_get(ospf6->external_id_table, &prefix_id); | |
1144 | node->info = route; | |
1145 | ||
1146 | route = ospf6_route_add(route, ospf6->external_table); | |
1147 | route->route_option = info; | |
1148 | ||
1149 | if (IS_OSPF6_DEBUG_ASBR) { | |
1150 | inet_ntop(AF_INET, &prefix_id.u.prefix4, ibuf, sizeof(ibuf)); | |
856ae1eb CS |
1151 | prefix2str(prefix, pbuf, sizeof(pbuf)); |
1152 | zlog_debug("Advertise as AS-External Id:%s prefix %s metric %u", | |
1153 | ibuf, pbuf, route->path.metric_type); | |
d62a17ae | 1154 | } |
1155 | ||
1156 | route->path.origin.id = htonl(info->id); | |
1157 | ospf6_as_external_lsa_originate(route); | |
1158 | ||
1159 | /* Router-Bit (ASBR Flag) may have to be updated */ | |
1160 | for (ALL_LIST_ELEMENTS(ospf6->area_list, lnode, lnnode, oa)) | |
1161 | OSPF6_ROUTER_LSA_SCHEDULE(oa); | |
718e3744 | 1162 | } |
1163 | ||
d62a17ae | 1164 | void ospf6_asbr_redistribute_remove(int type, ifindex_t ifindex, |
1165 | struct prefix *prefix) | |
718e3744 | 1166 | { |
d62a17ae | 1167 | struct ospf6_route *match; |
1168 | struct ospf6_external_info *info = NULL; | |
1169 | struct route_node *node; | |
1170 | struct ospf6_lsa *lsa; | |
1171 | struct prefix prefix_id; | |
1172 | char pbuf[PREFIX2STR_BUFFER], ibuf[16]; | |
1173 | struct listnode *lnode, *lnnode; | |
1174 | struct ospf6_area *oa; | |
1175 | ||
1176 | match = ospf6_route_lookup(prefix, ospf6->external_table); | |
1177 | if (match == NULL) { | |
1178 | if (IS_OSPF6_DEBUG_ASBR) { | |
1179 | prefix2str(prefix, pbuf, sizeof(pbuf)); | |
1180 | zlog_debug("No such route %s to withdraw", pbuf); | |
1181 | } | |
1182 | return; | |
1183 | } | |
1184 | ||
1185 | info = match->route_option; | |
1186 | assert(info); | |
1187 | ||
1188 | if (info->type != type) { | |
1189 | if (IS_OSPF6_DEBUG_ASBR) { | |
1190 | prefix2str(prefix, pbuf, sizeof(pbuf)); | |
1191 | zlog_debug("Original protocol mismatch: %s", pbuf); | |
1192 | } | |
1193 | return; | |
1194 | } | |
1195 | ||
1196 | if (IS_OSPF6_DEBUG_ASBR) { | |
1197 | prefix2str(prefix, pbuf, sizeof(pbuf)); | |
1198 | inet_ntop(AF_INET, &prefix_id.u.prefix4, ibuf, sizeof(ibuf)); | |
1199 | zlog_debug("Withdraw %s (AS-External Id:%s)", pbuf, ibuf); | |
1200 | } | |
1201 | ||
1202 | lsa = ospf6_lsdb_lookup(htons(OSPF6_LSTYPE_AS_EXTERNAL), | |
1203 | htonl(info->id), ospf6->router_id, ospf6->lsdb); | |
1204 | if (lsa) | |
1205 | ospf6_lsa_purge(lsa); | |
1206 | ||
1207 | /* remove binding in external_id_table */ | |
1208 | prefix_id.family = AF_INET; | |
1209 | prefix_id.prefixlen = 32; | |
1210 | prefix_id.u.prefix4.s_addr = htonl(info->id); | |
1211 | node = route_node_lookup(ospf6->external_id_table, &prefix_id); | |
1212 | assert(node); | |
1213 | node->info = NULL; | |
d107621d CS |
1214 | route_unlock_node(node); /* to free the lookup lock */ |
1215 | route_unlock_node(node); /* to free the original lock */ | |
d62a17ae | 1216 | |
1217 | ospf6_route_remove(match, ospf6->external_table); | |
1218 | XFREE(MTYPE_OSPF6_EXTERNAL_INFO, info); | |
1219 | ||
1220 | /* Router-Bit (ASBR Flag) may have to be updated */ | |
1221 | for (ALL_LIST_ELEMENTS(ospf6->area_list, lnode, lnnode, oa)) | |
1222 | OSPF6_ROUTER_LSA_SCHEDULE(oa); | |
718e3744 | 1223 | } |
1224 | ||
508e53e2 | 1225 | DEFUN (ospf6_redistribute, |
1226 | ospf6_redistribute_cmd, | |
40d1cbfb | 1227 | "redistribute " FRR_REDIST_STR_OSPF6D, |
508e53e2 | 1228 | "Redistribute\n" |
3b14d86e | 1229 | FRR_REDIST_HELP_STR_OSPF6D) |
718e3744 | 1230 | { |
d62a17ae | 1231 | int type; |
e0ca5fde | 1232 | |
d62a17ae | 1233 | char *proto = argv[argc - 1]->text; |
1234 | type = proto_redistnum(AFI_IP6, proto); | |
1235 | if (type < 0) | |
1236 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 1237 | |
d62a17ae | 1238 | ospf6_asbr_redistribute_unset(type); |
1239 | ospf6_asbr_redistribute_set(type); | |
1240 | return CMD_SUCCESS; | |
508e53e2 | 1241 | } |
718e3744 | 1242 | |
508e53e2 | 1243 | DEFUN (ospf6_redistribute_routemap, |
1244 | ospf6_redistribute_routemap_cmd, | |
40d1cbfb | 1245 | "redistribute " FRR_REDIST_STR_OSPF6D " route-map WORD", |
508e53e2 | 1246 | "Redistribute\n" |
ab0181ee | 1247 | FRR_REDIST_HELP_STR_OSPF6D |
508e53e2 | 1248 | "Route map reference\n" |
e52702f2 | 1249 | "Route map name\n") |
508e53e2 | 1250 | { |
d62a17ae | 1251 | int idx_protocol = 1; |
1252 | int idx_word = 3; | |
1253 | int type; | |
1254 | ||
1255 | char *proto = argv[idx_protocol]->text; | |
1256 | type = proto_redistnum(AFI_IP6, proto); | |
1257 | if (type < 0) | |
1258 | return CMD_WARNING_CONFIG_FAILED; | |
1259 | ||
1260 | ospf6_asbr_redistribute_unset(type); | |
1261 | ospf6_asbr_routemap_set(type, argv[idx_word]->arg); | |
1262 | ospf6_asbr_redistribute_set(type); | |
1263 | return CMD_SUCCESS; | |
508e53e2 | 1264 | } |
1265 | ||
1266 | DEFUN (no_ospf6_redistribute, | |
1267 | no_ospf6_redistribute_cmd, | |
40d1cbfb | 1268 | "no redistribute " FRR_REDIST_STR_OSPF6D " [route-map WORD]", |
508e53e2 | 1269 | NO_STR |
1270 | "Redistribute\n" | |
ab0181ee | 1271 | FRR_REDIST_HELP_STR_OSPF6D |
1d68dbfe DW |
1272 | "Route map reference\n" |
1273 | "Route map name\n") | |
508e53e2 | 1274 | { |
d62a17ae | 1275 | int idx_protocol = 2; |
1276 | int type; | |
e0ca5fde | 1277 | |
d62a17ae | 1278 | char *proto = argv[idx_protocol]->text; |
1279 | type = proto_redistnum(AFI_IP6, proto); | |
1280 | if (type < 0) | |
1281 | return CMD_WARNING_CONFIG_FAILED; | |
e26bbeba | 1282 | |
d62a17ae | 1283 | ospf6_asbr_redistribute_unset(type); |
e26bbeba | 1284 | |
d62a17ae | 1285 | return CMD_SUCCESS; |
508e53e2 | 1286 | } |
718e3744 | 1287 | |
d62a17ae | 1288 | int ospf6_redistribute_config_write(struct vty *vty) |
508e53e2 | 1289 | { |
d62a17ae | 1290 | int type; |
1291 | ||
1292 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) { | |
1293 | if (type == ZEBRA_ROUTE_OSPF6) | |
1294 | continue; | |
1295 | if (!ospf6_zebra_is_redistribute(type)) | |
1296 | continue; | |
1297 | ||
1298 | if (ospf6->rmap[type].name) | |
1299 | vty_out(vty, " redistribute %s route-map %s\n", | |
1300 | ZROUTE_NAME(type), ospf6->rmap[type].name); | |
1301 | else | |
1302 | vty_out(vty, " redistribute %s\n", ZROUTE_NAME(type)); | |
1303 | } | |
1304 | ||
1305 | return 0; | |
718e3744 | 1306 | } |
1307 | ||
d62a17ae | 1308 | static void ospf6_redistribute_show_config(struct vty *vty) |
718e3744 | 1309 | { |
d62a17ae | 1310 | int type; |
1311 | int nroute[ZEBRA_ROUTE_MAX]; | |
1312 | int total; | |
1313 | struct ospf6_route *route; | |
1314 | struct ospf6_external_info *info; | |
1315 | ||
1316 | total = 0; | |
1317 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) | |
1318 | nroute[type] = 0; | |
1319 | for (route = ospf6_route_head(ospf6->external_table); route; | |
1320 | route = ospf6_route_next(route)) { | |
1321 | info = route->route_option; | |
1322 | nroute[info->type]++; | |
1323 | total++; | |
1324 | } | |
718e3744 | 1325 | |
d62a17ae | 1326 | vty_out(vty, "Redistributing External Routes from:\n"); |
1327 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) { | |
1328 | if (type == ZEBRA_ROUTE_OSPF6) | |
1329 | continue; | |
1330 | if (!ospf6_zebra_is_redistribute(type)) | |
1331 | continue; | |
1332 | ||
1333 | if (ospf6->rmap[type].name) | |
1334 | vty_out(vty, " %d: %s with route-map \"%s\"%s\n", | |
1335 | nroute[type], ZROUTE_NAME(type), | |
1336 | ospf6->rmap[type].name, | |
1337 | (ospf6->rmap[type].map ? "" | |
1338 | : " (not found !)")); | |
1339 | else | |
1340 | vty_out(vty, " %d: %s\n", nroute[type], | |
1341 | ZROUTE_NAME(type)); | |
1342 | } | |
1343 | vty_out(vty, "Total %d routes\n", total); | |
1344 | } | |
718e3744 | 1345 | |
6b0655a2 | 1346 | |
508e53e2 | 1347 | /* Routemap Functions */ |
6ac29a51 | 1348 | static route_map_result_t |
123214ef MS |
1349 | ospf6_routemap_rule_match_address_prefixlist(void *rule, |
1350 | const struct prefix *prefix, | |
d62a17ae | 1351 | route_map_object_t type, |
1352 | void *object) | |
508e53e2 | 1353 | { |
d62a17ae | 1354 | struct prefix_list *plist; |
718e3744 | 1355 | |
d62a17ae | 1356 | if (type != RMAP_OSPF6) |
1357 | return RMAP_NOMATCH; | |
718e3744 | 1358 | |
d62a17ae | 1359 | plist = prefix_list_lookup(AFI_IP6, (char *)rule); |
1360 | if (plist == NULL) | |
1361 | return RMAP_NOMATCH; | |
718e3744 | 1362 | |
d62a17ae | 1363 | return (prefix_list_apply(plist, prefix) == PREFIX_DENY ? RMAP_NOMATCH |
1364 | : RMAP_MATCH); | |
508e53e2 | 1365 | } |
718e3744 | 1366 | |
6ac29a51 | 1367 | static void * |
d62a17ae | 1368 | ospf6_routemap_rule_match_address_prefixlist_compile(const char *arg) |
508e53e2 | 1369 | { |
d62a17ae | 1370 | return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED, arg); |
718e3744 | 1371 | } |
1372 | ||
d62a17ae | 1373 | static void ospf6_routemap_rule_match_address_prefixlist_free(void *rule) |
718e3744 | 1374 | { |
d62a17ae | 1375 | XFREE(MTYPE_ROUTE_MAP_COMPILED, rule); |
508e53e2 | 1376 | } |
718e3744 | 1377 | |
d62a17ae | 1378 | struct route_map_rule_cmd ospf6_routemap_rule_match_address_prefixlist_cmd = { |
1379 | "ipv6 address prefix-list", | |
1380 | ospf6_routemap_rule_match_address_prefixlist, | |
1381 | ospf6_routemap_rule_match_address_prefixlist_compile, | |
1382 | ospf6_routemap_rule_match_address_prefixlist_free, | |
508e53e2 | 1383 | }; |
718e3744 | 1384 | |
42a7debf VT |
1385 | /* `match interface IFNAME' */ |
1386 | /* Match function should return 1 if match is success else return | |
1387 | zero. */ | |
1388 | static route_map_result_t | |
123214ef | 1389 | ospf6_routemap_rule_match_interface(void *rule, const struct prefix *prefix, |
d62a17ae | 1390 | route_map_object_t type, void *object) |
42a7debf | 1391 | { |
d62a17ae | 1392 | struct interface *ifp; |
1393 | struct ospf6_external_info *ei; | |
42a7debf | 1394 | |
d62a17ae | 1395 | if (type == RMAP_OSPF6) { |
1396 | ei = ((struct ospf6_route *)object)->route_option; | |
1397 | ifp = if_lookup_by_name((char *)rule, VRF_DEFAULT); | |
42a7debf | 1398 | |
d62a17ae | 1399 | if (ifp != NULL && ei->ifindex == ifp->ifindex) |
1400 | return RMAP_MATCH; | |
1401 | } | |
42a7debf | 1402 | |
d62a17ae | 1403 | return RMAP_NOMATCH; |
42a7debf VT |
1404 | } |
1405 | ||
1406 | /* Route map `interface' match statement. `arg' should be | |
1407 | interface name. */ | |
d62a17ae | 1408 | static void *ospf6_routemap_rule_match_interface_compile(const char *arg) |
42a7debf | 1409 | { |
d62a17ae | 1410 | return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED, arg); |
42a7debf VT |
1411 | } |
1412 | ||
1413 | /* Free route map's compiled `interface' value. */ | |
d62a17ae | 1414 | static void ospf6_routemap_rule_match_interface_free(void *rule) |
42a7debf | 1415 | { |
d62a17ae | 1416 | XFREE(MTYPE_ROUTE_MAP_COMPILED, rule); |
42a7debf VT |
1417 | } |
1418 | ||
1419 | /* Route map commands for interface matching. */ | |
d62a17ae | 1420 | struct route_map_rule_cmd ospf6_routemap_rule_match_interface_cmd = { |
1421 | "interface", ospf6_routemap_rule_match_interface, | |
1422 | ospf6_routemap_rule_match_interface_compile, | |
1423 | ospf6_routemap_rule_match_interface_free}; | |
42a7debf | 1424 | |
464015fa | 1425 | /* Match function for matching route tags */ |
d62a17ae | 1426 | static route_map_result_t ospf6_routemap_rule_match_tag(void *rule, |
123214ef | 1427 | const struct prefix *p, |
d62a17ae | 1428 | route_map_object_t type, |
1429 | void *object) | |
464015fa | 1430 | { |
d62a17ae | 1431 | route_tag_t *tag = rule; |
1432 | struct ospf6_route *route = object; | |
1433 | struct ospf6_external_info *info = route->route_option; | |
464015fa | 1434 | |
d62a17ae | 1435 | if (type == RMAP_OSPF6 && info->tag == *tag) |
1436 | return RMAP_MATCH; | |
464015fa | 1437 | |
d62a17ae | 1438 | return RMAP_NOMATCH; |
464015fa CF |
1439 | } |
1440 | ||
d62a17ae | 1441 | static struct route_map_rule_cmd ospf6_routemap_rule_match_tag_cmd = { |
9d303b37 | 1442 | "tag", ospf6_routemap_rule_match_tag, route_map_rule_tag_compile, |
d62a17ae | 1443 | route_map_rule_tag_free, |
464015fa CF |
1444 | }; |
1445 | ||
6ac29a51 | 1446 | static route_map_result_t |
123214ef | 1447 | ospf6_routemap_rule_set_metric_type(void *rule, const struct prefix *prefix, |
d62a17ae | 1448 | route_map_object_t type, void *object) |
508e53e2 | 1449 | { |
d62a17ae | 1450 | char *metric_type = rule; |
1451 | struct ospf6_route *route = object; | |
718e3744 | 1452 | |
d62a17ae | 1453 | if (type != RMAP_OSPF6) |
1454 | return RMAP_OKAY; | |
718e3744 | 1455 | |
d62a17ae | 1456 | if (strcmp(metric_type, "type-2") == 0) |
1457 | route->path.metric_type = 2; | |
1458 | else | |
1459 | route->path.metric_type = 1; | |
718e3744 | 1460 | |
d62a17ae | 1461 | return RMAP_OKAY; |
508e53e2 | 1462 | } |
718e3744 | 1463 | |
d62a17ae | 1464 | static void *ospf6_routemap_rule_set_metric_type_compile(const char *arg) |
508e53e2 | 1465 | { |
d62a17ae | 1466 | if (strcmp(arg, "type-2") && strcmp(arg, "type-1")) |
1467 | return NULL; | |
1468 | return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED, arg); | |
718e3744 | 1469 | } |
1470 | ||
d62a17ae | 1471 | static void ospf6_routemap_rule_set_metric_type_free(void *rule) |
718e3744 | 1472 | { |
d62a17ae | 1473 | XFREE(MTYPE_ROUTE_MAP_COMPILED, rule); |
508e53e2 | 1474 | } |
718e3744 | 1475 | |
d62a17ae | 1476 | struct route_map_rule_cmd ospf6_routemap_rule_set_metric_type_cmd = { |
9d303b37 | 1477 | "metric-type", ospf6_routemap_rule_set_metric_type, |
d62a17ae | 1478 | ospf6_routemap_rule_set_metric_type_compile, |
1479 | ospf6_routemap_rule_set_metric_type_free, | |
508e53e2 | 1480 | }; |
718e3744 | 1481 | |
6ac29a51 | 1482 | static route_map_result_t |
123214ef | 1483 | ospf6_routemap_rule_set_metric(void *rule, const struct prefix *prefix, |
d62a17ae | 1484 | route_map_object_t type, void *object) |
508e53e2 | 1485 | { |
d62a17ae | 1486 | char *metric = rule; |
1487 | struct ospf6_route *route = object; | |
718e3744 | 1488 | |
d62a17ae | 1489 | if (type != RMAP_OSPF6) |
1490 | return RMAP_OKAY; | |
718e3744 | 1491 | |
d62a17ae | 1492 | route->path.cost = atoi(metric); |
1493 | return RMAP_OKAY; | |
508e53e2 | 1494 | } |
718e3744 | 1495 | |
d62a17ae | 1496 | static void *ospf6_routemap_rule_set_metric_compile(const char *arg) |
508e53e2 | 1497 | { |
d7c0a89a | 1498 | uint32_t metric; |
d62a17ae | 1499 | char *endp; |
1500 | metric = strtoul(arg, &endp, 0); | |
1501 | if (metric > OSPF_LS_INFINITY || *endp != '\0') | |
1502 | return NULL; | |
1503 | return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED, arg); | |
718e3744 | 1504 | } |
1505 | ||
d62a17ae | 1506 | static void ospf6_routemap_rule_set_metric_free(void *rule) |
718e3744 | 1507 | { |
d62a17ae | 1508 | XFREE(MTYPE_ROUTE_MAP_COMPILED, rule); |
508e53e2 | 1509 | } |
718e3744 | 1510 | |
d62a17ae | 1511 | struct route_map_rule_cmd ospf6_routemap_rule_set_metric_cmd = { |
9d303b37 | 1512 | "metric", ospf6_routemap_rule_set_metric, |
d62a17ae | 1513 | ospf6_routemap_rule_set_metric_compile, |
1514 | ospf6_routemap_rule_set_metric_free, | |
508e53e2 | 1515 | }; |
718e3744 | 1516 | |
6ac29a51 | 1517 | static route_map_result_t |
123214ef | 1518 | ospf6_routemap_rule_set_forwarding(void *rule, const struct prefix *prefix, |
d62a17ae | 1519 | route_map_object_t type, void *object) |
508e53e2 | 1520 | { |
d62a17ae | 1521 | char *forwarding = rule; |
1522 | struct ospf6_route *route = object; | |
1523 | struct ospf6_external_info *info = route->route_option; | |
718e3744 | 1524 | |
d62a17ae | 1525 | if (type != RMAP_OSPF6) |
1526 | return RMAP_OKAY; | |
718e3744 | 1527 | |
d62a17ae | 1528 | if (inet_pton(AF_INET6, forwarding, &info->forwarding) != 1) { |
1529 | memset(&info->forwarding, 0, sizeof(struct in6_addr)); | |
1530 | return RMAP_ERROR; | |
1531 | } | |
718e3744 | 1532 | |
d62a17ae | 1533 | return RMAP_OKAY; |
718e3744 | 1534 | } |
1535 | ||
d62a17ae | 1536 | static void *ospf6_routemap_rule_set_forwarding_compile(const char *arg) |
718e3744 | 1537 | { |
d62a17ae | 1538 | struct in6_addr a; |
1539 | if (inet_pton(AF_INET6, arg, &a) != 1) | |
1540 | return NULL; | |
1541 | return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED, arg); | |
718e3744 | 1542 | } |
1543 | ||
d62a17ae | 1544 | static void ospf6_routemap_rule_set_forwarding_free(void *rule) |
718e3744 | 1545 | { |
d62a17ae | 1546 | XFREE(MTYPE_ROUTE_MAP_COMPILED, rule); |
508e53e2 | 1547 | } |
718e3744 | 1548 | |
d62a17ae | 1549 | struct route_map_rule_cmd ospf6_routemap_rule_set_forwarding_cmd = { |
9d303b37 | 1550 | "forwarding-address", ospf6_routemap_rule_set_forwarding, |
d62a17ae | 1551 | ospf6_routemap_rule_set_forwarding_compile, |
1552 | ospf6_routemap_rule_set_forwarding_free, | |
508e53e2 | 1553 | }; |
718e3744 | 1554 | |
d62a17ae | 1555 | static route_map_result_t ospf6_routemap_rule_set_tag(void *rule, |
123214ef | 1556 | const struct prefix *p, |
d62a17ae | 1557 | route_map_object_t type, |
1558 | void *object) | |
464015fa | 1559 | { |
d62a17ae | 1560 | route_tag_t *tag = rule; |
1561 | struct ospf6_route *route = object; | |
1562 | struct ospf6_external_info *info = route->route_option; | |
464015fa | 1563 | |
d62a17ae | 1564 | if (type != RMAP_OSPF6) |
1565 | return RMAP_OKAY; | |
464015fa | 1566 | |
d62a17ae | 1567 | info->tag = *tag; |
1568 | return RMAP_OKAY; | |
464015fa CF |
1569 | } |
1570 | ||
d62a17ae | 1571 | static struct route_map_rule_cmd ospf6_routemap_rule_set_tag_cmd = { |
9d303b37 | 1572 | "tag", ospf6_routemap_rule_set_tag, route_map_rule_tag_compile, |
d62a17ae | 1573 | route_map_rule_tag_free, |
464015fa CF |
1574 | }; |
1575 | ||
d62a17ae | 1576 | static int route_map_command_status(struct vty *vty, int ret) |
508e53e2 | 1577 | { |
d62a17ae | 1578 | switch (ret) { |
1579 | case RMAP_RULE_MISSING: | |
1580 | vty_out(vty, "OSPF6 Can't find rule.\n"); | |
9ca25fed | 1581 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 1582 | break; |
1583 | case RMAP_COMPILE_ERROR: | |
1584 | vty_out(vty, "OSPF6 Argument is malformed.\n"); | |
9ca25fed | 1585 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 1586 | break; |
9ca25fed | 1587 | case RMAP_COMPILE_SUCCESS: |
d62a17ae | 1588 | break; |
1589 | } | |
9ca25fed DS |
1590 | |
1591 | return CMD_SUCCESS; | |
508e53e2 | 1592 | } |
718e3744 | 1593 | |
508e53e2 | 1594 | /* add "set metric-type" */ |
1595 | DEFUN (ospf6_routemap_set_metric_type, | |
1596 | ospf6_routemap_set_metric_type_cmd, | |
6147e2c6 | 1597 | "set metric-type <type-1|type-2>", |
508e53e2 | 1598 | "Set value\n" |
1599 | "Type of metric\n" | |
1600 | "OSPF6 external type 1 metric\n" | |
1601 | "OSPF6 external type 2 metric\n") | |
1602 | { | |
d62a17ae | 1603 | VTY_DECLVAR_CONTEXT(route_map_index, route_map_index); |
1604 | int idx_external = 2; | |
1605 | int ret = route_map_add_set(route_map_index, "metric-type", | |
1606 | argv[idx_external]->arg); | |
1607 | return route_map_command_status(vty, ret); | |
718e3744 | 1608 | } |
1609 | ||
508e53e2 | 1610 | /* delete "set metric-type" */ |
1611 | DEFUN (ospf6_routemap_no_set_metric_type, | |
1612 | ospf6_routemap_no_set_metric_type_cmd, | |
dab8cd00 | 1613 | "no set metric-type [<type-1|type-2>]", |
508e53e2 | 1614 | NO_STR |
1615 | "Set value\n" | |
1616 | "Type of metric\n" | |
1617 | "OSPF6 external type 1 metric\n" | |
1618 | "OSPF6 external type 2 metric\n") | |
718e3744 | 1619 | { |
d62a17ae | 1620 | VTY_DECLVAR_CONTEXT(route_map_index, route_map_index); |
1621 | char *ext = (argc == 4) ? argv[3]->text : NULL; | |
1622 | int ret = route_map_delete_set(route_map_index, "metric-type", ext); | |
1623 | return route_map_command_status(vty, ret); | |
508e53e2 | 1624 | } |
718e3744 | 1625 | |
508e53e2 | 1626 | /* add "set forwarding-address" */ |
1627 | DEFUN (ospf6_routemap_set_forwarding, | |
1628 | ospf6_routemap_set_forwarding_cmd, | |
1629 | "set forwarding-address X:X::X:X", | |
1630 | "Set value\n" | |
1631 | "Forwarding Address\n" | |
1632 | "IPv6 Address\n") | |
1633 | { | |
d62a17ae | 1634 | VTY_DECLVAR_CONTEXT(route_map_index, route_map_index); |
1635 | int idx_ipv6 = 2; | |
1636 | int ret = route_map_add_set(route_map_index, "forwarding-address", | |
1637 | argv[idx_ipv6]->arg); | |
1638 | return route_map_command_status(vty, ret); | |
508e53e2 | 1639 | } |
718e3744 | 1640 | |
508e53e2 | 1641 | /* delete "set forwarding-address" */ |
1642 | DEFUN (ospf6_routemap_no_set_forwarding, | |
1643 | ospf6_routemap_no_set_forwarding_cmd, | |
1644 | "no set forwarding-address X:X::X:X", | |
1645 | NO_STR | |
1646 | "Set value\n" | |
1647 | "Forwarding Address\n" | |
1648 | "IPv6 Address\n") | |
1649 | { | |
d62a17ae | 1650 | VTY_DECLVAR_CONTEXT(route_map_index, route_map_index); |
1651 | int idx_ipv6 = 3; | |
1652 | int ret = route_map_delete_set(route_map_index, "forwarding-address", | |
1653 | argv[idx_ipv6]->arg); | |
1654 | return route_map_command_status(vty, ret); | |
508e53e2 | 1655 | } |
718e3744 | 1656 | |
d62a17ae | 1657 | static void ospf6_routemap_init(void) |
508e53e2 | 1658 | { |
d62a17ae | 1659 | route_map_init(); |
b2575bc0 | 1660 | |
d62a17ae | 1661 | route_map_add_hook(ospf6_asbr_routemap_update); |
1662 | route_map_delete_hook(ospf6_asbr_routemap_update); | |
856ae1eb | 1663 | route_map_event_hook(ospf6_asbr_routemap_event); |
508e53e2 | 1664 | |
d62a17ae | 1665 | route_map_set_metric_hook(generic_set_add); |
1666 | route_map_no_set_metric_hook(generic_set_delete); | |
82f97584 | 1667 | |
d62a17ae | 1668 | route_map_match_tag_hook(generic_match_add); |
1669 | route_map_no_match_tag_hook(generic_match_delete); | |
e1a1b2ed | 1670 | |
d62a17ae | 1671 | route_map_match_ipv6_address_prefix_list_hook(generic_match_add); |
1672 | route_map_no_match_ipv6_address_prefix_list_hook(generic_match_delete); | |
e1a1b2ed | 1673 | |
d62a17ae | 1674 | route_map_match_interface_hook(generic_match_add); |
1675 | route_map_no_match_interface_hook(generic_match_delete); | |
e1a1b2ed | 1676 | |
d62a17ae | 1677 | route_map_install_match( |
1678 | &ospf6_routemap_rule_match_address_prefixlist_cmd); | |
1679 | route_map_install_match(&ospf6_routemap_rule_match_interface_cmd); | |
1680 | route_map_install_match(&ospf6_routemap_rule_match_tag_cmd); | |
42a7debf | 1681 | |
d62a17ae | 1682 | route_map_install_set(&ospf6_routemap_rule_set_metric_type_cmd); |
1683 | route_map_install_set(&ospf6_routemap_rule_set_metric_cmd); | |
1684 | route_map_install_set(&ospf6_routemap_rule_set_forwarding_cmd); | |
1685 | route_map_install_set(&ospf6_routemap_rule_set_tag_cmd); | |
508e53e2 | 1686 | |
d62a17ae | 1687 | /* ASE Metric Type (e.g. Type-1/Type-2) */ |
1688 | install_element(RMAP_NODE, &ospf6_routemap_set_metric_type_cmd); | |
1689 | install_element(RMAP_NODE, &ospf6_routemap_no_set_metric_type_cmd); | |
508e53e2 | 1690 | |
d62a17ae | 1691 | /* ASE Metric */ |
1692 | install_element(RMAP_NODE, &ospf6_routemap_set_forwarding_cmd); | |
1693 | install_element(RMAP_NODE, &ospf6_routemap_no_set_forwarding_cmd); | |
718e3744 | 1694 | } |
1695 | ||
6b0655a2 | 1696 | |
508e53e2 | 1697 | /* Display functions */ |
d62a17ae | 1698 | static char *ospf6_as_external_lsa_get_prefix_str(struct ospf6_lsa *lsa, |
1699 | char *buf, int buflen, | |
1700 | int pos) | |
e68a6767 | 1701 | { |
d62a17ae | 1702 | struct ospf6_as_external_lsa *external; |
1703 | struct in6_addr in6; | |
1704 | int prefix_length = 0; | |
1705 | ||
1706 | if (lsa) { | |
1707 | external = (struct ospf6_as_external_lsa *)OSPF6_LSA_HEADER_END( | |
1708 | lsa->header); | |
1709 | ||
1710 | if (pos == 0) { | |
b8ce0c36 | 1711 | ospf6_prefix_in6_addr(&in6, external, |
1712 | &external->prefix); | |
d62a17ae | 1713 | prefix_length = external->prefix.prefix_length; |
1714 | } else { | |
1715 | in6 = *((struct in6_addr | |
1716 | *)((caddr_t)external | |
1717 | + sizeof(struct | |
1718 | ospf6_as_external_lsa) | |
1719 | + OSPF6_PREFIX_SPACE( | |
1720 | external->prefix | |
1721 | .prefix_length))); | |
1722 | } | |
1723 | if (buf) { | |
1724 | inet_ntop(AF_INET6, &in6, buf, buflen); | |
1725 | if (prefix_length) | |
1726 | sprintf(&buf[strlen(buf)], "/%d", | |
1727 | prefix_length); | |
1728 | } | |
e68a6767 | 1729 | } |
d62a17ae | 1730 | return (buf); |
e68a6767 DD |
1731 | } |
1732 | ||
d62a17ae | 1733 | static int ospf6_as_external_lsa_show(struct vty *vty, struct ospf6_lsa *lsa) |
718e3744 | 1734 | { |
d62a17ae | 1735 | struct ospf6_as_external_lsa *external; |
1736 | char buf[64]; | |
1737 | ||
1738 | assert(lsa->header); | |
1739 | external = (struct ospf6_as_external_lsa *)OSPF6_LSA_HEADER_END( | |
1740 | lsa->header); | |
1741 | ||
1742 | /* bits */ | |
1743 | snprintf(buf, sizeof(buf), "%c%c%c", | |
1744 | (CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_E) ? 'E' | |
1745 | : '-'), | |
1746 | (CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_F) ? 'F' | |
1747 | : '-'), | |
1748 | (CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_T) ? 'T' | |
1749 | : '-')); | |
1750 | ||
1751 | vty_out(vty, " Bits: %s\n", buf); | |
1752 | vty_out(vty, " Metric: %5lu\n", | |
d7c0a89a | 1753 | (unsigned long)OSPF6_ASBR_METRIC(external)); |
d62a17ae | 1754 | |
1755 | ospf6_prefix_options_printbuf(external->prefix.prefix_options, buf, | |
1756 | sizeof(buf)); | |
1757 | vty_out(vty, " Prefix Options: %s\n", buf); | |
1758 | ||
1759 | vty_out(vty, " Referenced LSType: %d\n", | |
1760 | ntohs(external->prefix.prefix_refer_lstype)); | |
1761 | ||
1762 | vty_out(vty, " Prefix: %s\n", | |
1763 | ospf6_as_external_lsa_get_prefix_str(lsa, buf, sizeof(buf), 0)); | |
1764 | ||
1765 | /* Forwarding-Address */ | |
1766 | if (CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_F)) { | |
1767 | vty_out(vty, " Forwarding-Address: %s\n", | |
1768 | ospf6_as_external_lsa_get_prefix_str(lsa, buf, | |
1769 | sizeof(buf), 1)); | |
1770 | } | |
1771 | ||
1772 | /* Tag */ | |
1773 | if (CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_T)) { | |
1774 | vty_out(vty, " Tag: %" ROUTE_TAG_PRI "\n", | |
1775 | ospf6_as_external_lsa_get_tag(lsa)); | |
1776 | } | |
1777 | ||
1778 | return 0; | |
718e3744 | 1779 | } |
1780 | ||
d62a17ae | 1781 | static void ospf6_asbr_external_route_show(struct vty *vty, |
1782 | struct ospf6_route *route) | |
718e3744 | 1783 | { |
d62a17ae | 1784 | struct ospf6_external_info *info = route->route_option; |
1785 | char prefix[PREFIX2STR_BUFFER], id[16], forwarding[64]; | |
d7c0a89a | 1786 | uint32_t tmp_id; |
d62a17ae | 1787 | |
1788 | prefix2str(&route->prefix, prefix, sizeof(prefix)); | |
1789 | tmp_id = ntohl(info->id); | |
1790 | inet_ntop(AF_INET, &tmp_id, id, sizeof(id)); | |
1791 | if (!IN6_IS_ADDR_UNSPECIFIED(&info->forwarding)) | |
1792 | inet_ntop(AF_INET6, &info->forwarding, forwarding, | |
1793 | sizeof(forwarding)); | |
1794 | else | |
1795 | snprintf(forwarding, sizeof(forwarding), ":: (ifindex %d)", | |
1796 | ospf6_route_get_first_nh_index(route)); | |
1797 | ||
1798 | vty_out(vty, "%c %-32s %-15s type-%d %5lu %s\n", | |
1799 | zebra_route_char(info->type), prefix, id, | |
1800 | route->path.metric_type, | |
d7c0a89a QY |
1801 | (unsigned long)(route->path.metric_type == 2 |
1802 | ? route->path.u.cost_e2 | |
1803 | : route->path.cost), | |
d62a17ae | 1804 | forwarding); |
718e3744 | 1805 | } |
1806 | ||
508e53e2 | 1807 | DEFUN (show_ipv6_ospf6_redistribute, |
1808 | show_ipv6_ospf6_redistribute_cmd, | |
1809 | "show ipv6 ospf6 redistribute", | |
1810 | SHOW_STR | |
1811 | IP6_STR | |
1812 | OSPF6_STR | |
1813 | "redistributing External information\n" | |
1814 | ) | |
718e3744 | 1815 | { |
d62a17ae | 1816 | struct ospf6_route *route; |
718e3744 | 1817 | |
d62a17ae | 1818 | OSPF6_CMD_CHECK_RUNNING(); |
b52a8a52 | 1819 | |
d62a17ae | 1820 | ospf6_redistribute_show_config(vty); |
718e3744 | 1821 | |
d62a17ae | 1822 | for (route = ospf6_route_head(ospf6->external_table); route; |
1823 | route = ospf6_route_next(route)) | |
1824 | ospf6_asbr_external_route_show(vty, route); | |
508e53e2 | 1825 | |
d62a17ae | 1826 | return CMD_SUCCESS; |
718e3744 | 1827 | } |
1828 | ||
d62a17ae | 1829 | struct ospf6_lsa_handler as_external_handler = { |
3981b5c7 VJ |
1830 | .lh_type = OSPF6_LSTYPE_AS_EXTERNAL, |
1831 | .lh_name = "AS-External", | |
1832 | .lh_short_name = "ASE", | |
1833 | .lh_show = ospf6_as_external_lsa_show, | |
1834 | .lh_get_prefix_str = ospf6_as_external_lsa_get_prefix_str, | |
996c9314 | 1835 | .lh_debug = 0}; |
508e53e2 | 1836 | |
d62a17ae | 1837 | void ospf6_asbr_init(void) |
718e3744 | 1838 | { |
d62a17ae | 1839 | ospf6_routemap_init(); |
508e53e2 | 1840 | |
d62a17ae | 1841 | ospf6_install_lsa_handler(&as_external_handler); |
718e3744 | 1842 | |
d62a17ae | 1843 | install_element(VIEW_NODE, &show_ipv6_ospf6_redistribute_cmd); |
508e53e2 | 1844 | |
d62a17ae | 1845 | install_element(OSPF6_NODE, &ospf6_redistribute_cmd); |
1846 | install_element(OSPF6_NODE, &ospf6_redistribute_routemap_cmd); | |
1847 | install_element(OSPF6_NODE, &no_ospf6_redistribute_cmd); | |
718e3744 | 1848 | } |
1849 | ||
d62a17ae | 1850 | void ospf6_asbr_redistribute_reset(void) |
d9628728 | 1851 | { |
d62a17ae | 1852 | int type; |
1853 | ||
1854 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) { | |
1855 | if (type == ZEBRA_ROUTE_OSPF6) | |
1856 | continue; | |
1857 | if (ospf6_zebra_is_redistribute(type)) | |
1858 | ospf6_asbr_redistribute_unset(type); | |
1859 | } | |
d9628728 CF |
1860 | } |
1861 | ||
d62a17ae | 1862 | void ospf6_asbr_terminate(void) |
ae2254aa | 1863 | { |
856ae1eb | 1864 | /* Cleanup route maps */ |
d62a17ae | 1865 | route_map_finish(); |
ae2254aa | 1866 | } |
718e3744 | 1867 | |
508e53e2 | 1868 | DEFUN (debug_ospf6_asbr, |
1869 | debug_ospf6_asbr_cmd, | |
1870 | "debug ospf6 asbr", | |
1871 | DEBUG_STR | |
1872 | OSPF6_STR | |
1873 | "Debug OSPFv3 ASBR function\n" | |
1874 | ) | |
1875 | { | |
d62a17ae | 1876 | OSPF6_DEBUG_ASBR_ON(); |
1877 | return CMD_SUCCESS; | |
508e53e2 | 1878 | } |
1879 | ||
1880 | DEFUN (no_debug_ospf6_asbr, | |
1881 | no_debug_ospf6_asbr_cmd, | |
1882 | "no debug ospf6 asbr", | |
1883 | NO_STR | |
1884 | DEBUG_STR | |
1885 | OSPF6_STR | |
1886 | "Debug OSPFv3 ASBR function\n" | |
1887 | ) | |
1888 | { | |
d62a17ae | 1889 | OSPF6_DEBUG_ASBR_OFF(); |
1890 | return CMD_SUCCESS; | |
508e53e2 | 1891 | } |
1892 | ||
d62a17ae | 1893 | int config_write_ospf6_debug_asbr(struct vty *vty) |
508e53e2 | 1894 | { |
d62a17ae | 1895 | if (IS_OSPF6_DEBUG_ASBR) |
1896 | vty_out(vty, "debug ospf6 asbr\n"); | |
1897 | return 0; | |
508e53e2 | 1898 | } |
1899 | ||
d62a17ae | 1900 | void install_element_ospf6_debug_asbr() |
92300491 | 1901 | { |
d62a17ae | 1902 | install_element(ENABLE_NODE, &debug_ospf6_asbr_cmd); |
1903 | install_element(ENABLE_NODE, &no_debug_ospf6_asbr_cmd); | |
1904 | install_element(CONFIG_NODE, &debug_ospf6_asbr_cmd); | |
1905 | install_element(CONFIG_NODE, &no_debug_ospf6_asbr_cmd); | |
92300491 | 1906 | } |