]>
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 | ||
508e53e2 | 21 | #include <zebra.h> |
718e3744 | 22 | |
508e53e2 | 23 | #include "log.h" |
24 | #include "linklist.h" | |
25 | #include "thread.h" | |
26 | #include "memory.h" | |
27 | #include "if.h" | |
28 | #include "prefix.h" | |
29 | #include "table.h" | |
30 | #include "vty.h" | |
31 | #include "command.h" | |
a90607a4 | 32 | #include "vrf.h" |
718e3744 | 33 | |
508e53e2 | 34 | #include "ospf6_proto.h" |
35 | #include "ospf6_message.h" | |
36 | #include "ospf6_route.h" | |
37 | #include "ospf6_lsa.h" | |
38 | #include "ospf6_lsdb.h" | |
39 | ||
40 | #include "ospf6_top.h" | |
41 | #include "ospf6_area.h" | |
42 | #include "ospf6_interface.h" | |
43 | #include "ospf6_neighbor.h" | |
44 | #include "ospf6_intra.h" | |
45 | #include "ospf6_asbr.h" | |
6452df09 | 46 | #include "ospf6_abr.h" |
47 | #include "ospf6_flood.h" | |
049207c3 | 48 | #include "ospf6d.h" |
a0edf674 | 49 | #include "ospf6_spf.h" |
cb4b8845 PJ |
50 | |
51 | unsigned char conf_debug_ospf6_brouter = 0; | |
d7c0a89a QY |
52 | uint32_t conf_debug_ospf6_brouter_specific_router_id; |
53 | uint32_t conf_debug_ospf6_brouter_specific_area_id; | |
cb4b8845 | 54 | |
9a703f8d | 55 | #define MAX_LSA_PAYLOAD (1024 + 256) |
508e53e2 | 56 | /******************************/ |
57 | /* RFC2740 3.4.3.1 Router-LSA */ | |
58 | /******************************/ | |
718e3744 | 59 | |
d62a17ae | 60 | static char *ospf6_router_lsa_get_nbr_id(struct ospf6_lsa *lsa, char *buf, |
61 | int buflen, int pos) | |
e68a6767 | 62 | { |
d62a17ae | 63 | struct ospf6_router_lsa *router_lsa; |
64 | struct ospf6_router_lsdesc *lsdesc; | |
65 | char *start, *end; | |
66 | char buf1[INET_ADDRSTRLEN], buf2[INET_ADDRSTRLEN]; | |
67 | ||
68 | if (lsa) { | |
69 | router_lsa = (struct ospf6_router_lsa | |
70 | *)((char *)lsa->header | |
71 | + sizeof(struct ospf6_lsa_header)); | |
72 | start = (char *)router_lsa + sizeof(struct ospf6_router_lsa); | |
73 | end = (char *)lsa->header + ntohs(lsa->header->length); | |
74 | ||
75 | lsdesc = (struct ospf6_router_lsdesc | |
76 | *)(start | |
9d303b37 DL |
77 | + pos * (sizeof(struct |
78 | ospf6_router_lsdesc))); | |
d62a17ae | 79 | if ((char *)lsdesc < end) { |
80 | if (buf && (buflen > INET_ADDRSTRLEN * 2)) { | |
81 | inet_ntop(AF_INET, | |
82 | &lsdesc->neighbor_interface_id, buf1, | |
83 | sizeof(buf1)); | |
84 | inet_ntop(AF_INET, &lsdesc->neighbor_router_id, | |
85 | buf2, sizeof(buf2)); | |
86 | sprintf(buf, "%s/%s", buf2, buf1); | |
87 | } | |
88 | } else | |
89 | return NULL; | |
e68a6767 | 90 | } |
e68a6767 | 91 | |
d62a17ae | 92 | return buf; |
e68a6767 DD |
93 | } |
94 | ||
d62a17ae | 95 | static int ospf6_router_lsa_show(struct vty *vty, struct ospf6_lsa *lsa) |
718e3744 | 96 | { |
d62a17ae | 97 | char *start, *end, *current; |
98 | char buf[32], name[32], bits[16], options[32]; | |
99 | struct ospf6_router_lsa *router_lsa; | |
100 | struct ospf6_router_lsdesc *lsdesc; | |
101 | ||
102 | router_lsa = | |
103 | (struct ospf6_router_lsa *)((char *)lsa->header | |
104 | + sizeof(struct ospf6_lsa_header)); | |
105 | ||
106 | ospf6_capability_printbuf(router_lsa->bits, bits, sizeof(bits)); | |
107 | ospf6_options_printbuf(router_lsa->options, options, sizeof(options)); | |
108 | vty_out(vty, " Bits: %s Options: %s\n", bits, options); | |
109 | ||
110 | start = (char *)router_lsa + sizeof(struct ospf6_router_lsa); | |
111 | end = (char *)lsa->header + ntohs(lsa->header->length); | |
112 | for (current = start; | |
113 | current + sizeof(struct ospf6_router_lsdesc) <= end; | |
114 | current += sizeof(struct ospf6_router_lsdesc)) { | |
115 | lsdesc = (struct ospf6_router_lsdesc *)current; | |
116 | ||
117 | if (lsdesc->type == OSPF6_ROUTER_LSDESC_POINTTOPOINT) | |
118 | snprintf(name, sizeof(name), "Point-To-Point"); | |
119 | else if (lsdesc->type == OSPF6_ROUTER_LSDESC_TRANSIT_NETWORK) | |
120 | snprintf(name, sizeof(name), "Transit-Network"); | |
121 | else if (lsdesc->type == OSPF6_ROUTER_LSDESC_STUB_NETWORK) | |
122 | snprintf(name, sizeof(name), "Stub-Network"); | |
123 | else if (lsdesc->type == OSPF6_ROUTER_LSDESC_VIRTUAL_LINK) | |
124 | snprintf(name, sizeof(name), "Virtual-Link"); | |
125 | else | |
126 | snprintf(name, sizeof(name), "Unknown (%#x)", | |
127 | lsdesc->type); | |
128 | ||
129 | vty_out(vty, " Type: %s Metric: %d\n", name, | |
130 | ntohs(lsdesc->metric)); | |
131 | vty_out(vty, " Interface ID: %s\n", | |
132 | inet_ntop(AF_INET, &lsdesc->interface_id, buf, | |
133 | sizeof(buf))); | |
134 | vty_out(vty, " Neighbor Interface ID: %s\n", | |
135 | inet_ntop(AF_INET, &lsdesc->neighbor_interface_id, buf, | |
136 | sizeof(buf))); | |
137 | vty_out(vty, " Neighbor Router ID: %s\n", | |
138 | inet_ntop(AF_INET, &lsdesc->neighbor_router_id, buf, | |
139 | sizeof(buf))); | |
140 | } | |
141 | return 0; | |
718e3744 | 142 | } |
143 | ||
d62a17ae | 144 | static void ospf6_router_lsa_options_set(struct ospf6_area *oa, |
145 | struct ospf6_router_lsa *router_lsa) | |
ca1f4309 | 146 | { |
d62a17ae | 147 | OSPF6_OPT_CLEAR_ALL(router_lsa->options); |
148 | memcpy(router_lsa->options, oa->options, 3); | |
149 | ||
150 | if (ospf6_is_router_abr(ospf6)) | |
151 | SET_FLAG(router_lsa->bits, OSPF6_ROUTER_BIT_B); | |
152 | else | |
153 | UNSET_FLAG(router_lsa->bits, OSPF6_ROUTER_BIT_B); | |
154 | ||
155 | if (!IS_AREA_STUB(oa) && ospf6_asbr_is_asbr(oa->ospf6)) { | |
156 | SET_FLAG(router_lsa->bits, OSPF6_ROUTER_BIT_E); | |
157 | } else { | |
158 | UNSET_FLAG(router_lsa->bits, OSPF6_ROUTER_BIT_E); | |
159 | } | |
160 | ||
161 | UNSET_FLAG(router_lsa->bits, OSPF6_ROUTER_BIT_V); | |
162 | UNSET_FLAG(router_lsa->bits, OSPF6_ROUTER_BIT_W); | |
ca1f4309 DS |
163 | } |
164 | ||
d62a17ae | 165 | int ospf6_router_is_stub_router(struct ospf6_lsa *lsa) |
f41b4a02 | 166 | { |
d62a17ae | 167 | struct ospf6_router_lsa *rtr_lsa; |
168 | ||
169 | if (lsa != NULL && OSPF6_LSA_IS_TYPE(ROUTER, lsa)) { | |
170 | rtr_lsa = (struct ospf6_router_lsa | |
171 | *)((caddr_t)lsa->header | |
172 | + sizeof(struct ospf6_lsa_header)); | |
173 | ||
174 | if (!OSPF6_OPT_ISSET(rtr_lsa->options, OSPF6_OPT_R)) { | |
175 | return (OSPF6_IS_STUB_ROUTER); | |
176 | } else if (!OSPF6_OPT_ISSET(rtr_lsa->options, OSPF6_OPT_V6)) { | |
177 | return (OSPF6_IS_STUB_ROUTER_V6); | |
178 | } | |
f41b4a02 | 179 | } |
f41b4a02 | 180 | |
d62a17ae | 181 | return (OSPF6_NOT_STUB_ROUTER); |
f41b4a02 DD |
182 | } |
183 | ||
d62a17ae | 184 | int ospf6_router_lsa_originate(struct thread *thread) |
718e3744 | 185 | { |
d62a17ae | 186 | struct ospf6_area *oa; |
187 | ||
188 | char buffer[OSPF6_MAX_LSASIZE]; | |
189 | struct ospf6_lsa_header *lsa_header; | |
190 | struct ospf6_lsa *lsa; | |
191 | ||
d7c0a89a | 192 | uint32_t link_state_id = 0; |
d62a17ae | 193 | struct listnode *node, *nnode; |
194 | struct listnode *j; | |
195 | struct ospf6_interface *oi; | |
196 | struct ospf6_neighbor *on, *drouter = NULL; | |
197 | struct ospf6_router_lsa *router_lsa; | |
198 | struct ospf6_router_lsdesc *lsdesc; | |
d7c0a89a QY |
199 | uint16_t type; |
200 | uint32_t router; | |
d62a17ae | 201 | int count; |
202 | ||
203 | oa = (struct ospf6_area *)THREAD_ARG(thread); | |
204 | oa->thread_router_lsa = NULL; | |
205 | ||
206 | if (IS_OSPF6_DEBUG_ORIGINATE(ROUTER)) | |
207 | zlog_debug("Originate Router-LSA for Area %s", oa->name); | |
208 | ||
209 | memset(buffer, 0, sizeof(buffer)); | |
210 | lsa_header = (struct ospf6_lsa_header *)buffer; | |
211 | router_lsa = | |
212 | (struct ospf6_router_lsa *)((caddr_t)lsa_header | |
213 | + sizeof(struct ospf6_lsa_header)); | |
214 | ||
215 | ospf6_router_lsa_options_set(oa, router_lsa); | |
216 | ||
217 | /* describe links for each interfaces */ | |
996c9314 LB |
218 | lsdesc = (struct ospf6_router_lsdesc |
219 | *)((caddr_t)router_lsa | |
d62a17ae | 220 | + sizeof(struct ospf6_router_lsa)); |
221 | ||
222 | for (ALL_LIST_ELEMENTS(oa->if_list, node, nnode, oi)) { | |
223 | /* Interfaces in state Down or Loopback are not described */ | |
224 | if (oi->state == OSPF6_INTERFACE_DOWN | |
225 | || oi->state == OSPF6_INTERFACE_LOOPBACK) | |
226 | continue; | |
227 | ||
228 | /* Nor are interfaces without any full adjacencies described */ | |
229 | count = 0; | |
230 | for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, j, on)) | |
231 | if (on->state == OSPF6_NEIGHBOR_FULL) | |
232 | count++; | |
233 | ||
234 | if (count == 0) | |
235 | continue; | |
236 | ||
237 | /* Multiple Router-LSA instance according to size limit setting | |
238 | */ | |
239 | if ((oa->router_lsa_size_limit != 0) | |
240 | && ((size_t)((char *)lsdesc - buffer) | |
241 | + sizeof(struct ospf6_router_lsdesc) | |
242 | > oa->router_lsa_size_limit)) { | |
243 | if ((caddr_t)lsdesc | |
244 | == (caddr_t)router_lsa | |
245 | + sizeof(struct ospf6_router_lsa)) { | |
246 | if (IS_OSPF6_DEBUG_ORIGINATE(ROUTER)) | |
247 | zlog_debug( | |
248 | "Size limit setting for Router-LSA too short"); | |
249 | return 0; | |
250 | } | |
251 | ||
9a703f8d CS |
252 | /* Fill LSA Header */ |
253 | lsa_header->age = 0; | |
254 | lsa_header->type = htons(OSPF6_LSTYPE_ROUTER); | |
255 | lsa_header->id = htonl(link_state_id); | |
256 | lsa_header->adv_router = oa->ospf6->router_id; | |
996c9314 LB |
257 | lsa_header->seqnum = ospf6_new_ls_seqnum( |
258 | lsa_header->type, lsa_header->id, | |
259 | lsa_header->adv_router, oa->lsdb); | |
9a703f8d CS |
260 | lsa_header->length = |
261 | htons((caddr_t)lsdesc - (caddr_t)buffer); | |
262 | ||
263 | /* LSA checksum */ | |
264 | ospf6_lsa_checksum(lsa_header); | |
265 | ||
266 | /* create LSA */ | |
267 | lsa = ospf6_lsa_create(lsa_header); | |
268 | ||
269 | /* Originate */ | |
270 | ospf6_lsa_originate_area(lsa, oa); | |
271 | ||
272 | /* Reset Buffer to fill next Router LSA */ | |
273 | memset(buffer, 0, sizeof(buffer)); | |
274 | lsa_header = (struct ospf6_lsa_header *)buffer; | |
275 | router_lsa = | |
996c9314 LB |
276 | (struct ospf6_router_lsa |
277 | *)((caddr_t)lsa_header | |
9a703f8d CS |
278 | + sizeof(struct ospf6_lsa_header)); |
279 | ||
280 | ospf6_router_lsa_options_set(oa, router_lsa); | |
281 | ||
282 | /* describe links for each interfaces */ | |
996c9314 LB |
283 | lsdesc = (struct ospf6_router_lsdesc |
284 | *)((caddr_t)router_lsa | |
285 | + sizeof(struct ospf6_router_lsa)); | |
9a703f8d | 286 | |
d62a17ae | 287 | link_state_id++; |
288 | } | |
289 | ||
290 | /* Point-to-Point interfaces */ | |
291 | if (oi->type == OSPF_IFTYPE_POINTOPOINT) { | |
292 | for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, j, on)) { | |
293 | if (on->state != OSPF6_NEIGHBOR_FULL) | |
294 | continue; | |
295 | ||
296 | lsdesc->type = OSPF6_ROUTER_LSDESC_POINTTOPOINT; | |
297 | lsdesc->metric = htons(oi->cost); | |
298 | lsdesc->interface_id = | |
299 | htonl(oi->interface->ifindex); | |
300 | lsdesc->neighbor_interface_id = | |
301 | htonl(on->ifindex); | |
302 | lsdesc->neighbor_router_id = on->router_id; | |
303 | ||
304 | lsdesc++; | |
305 | } | |
306 | } | |
307 | ||
308 | /* Broadcast and NBMA interfaces */ | |
309 | else if (oi->type == OSPF_IFTYPE_BROADCAST) { | |
310 | /* If this router is not DR, | |
311 | and If this router not fully adjacent with DR, | |
312 | this interface is not transit yet: ignore. */ | |
313 | if (oi->state != OSPF6_INTERFACE_DR) { | |
314 | drouter = | |
315 | ospf6_neighbor_lookup(oi->drouter, oi); | |
316 | if (drouter == NULL | |
317 | || drouter->state != OSPF6_NEIGHBOR_FULL) | |
318 | continue; | |
319 | } | |
320 | ||
321 | lsdesc->type = OSPF6_ROUTER_LSDESC_TRANSIT_NETWORK; | |
322 | lsdesc->metric = htons(oi->cost); | |
323 | lsdesc->interface_id = htonl(oi->interface->ifindex); | |
324 | if (oi->state != OSPF6_INTERFACE_DR) { | |
325 | lsdesc->neighbor_interface_id = | |
326 | htonl(drouter->ifindex); | |
327 | lsdesc->neighbor_router_id = drouter->router_id; | |
328 | } else { | |
329 | lsdesc->neighbor_interface_id = | |
330 | htonl(oi->interface->ifindex); | |
331 | lsdesc->neighbor_router_id = | |
332 | oi->area->ospf6->router_id; | |
333 | } | |
334 | ||
335 | lsdesc++; | |
336 | } else { | |
337 | assert(0); /* Unknown interface type */ | |
338 | } | |
339 | ||
340 | /* Virtual links */ | |
341 | /* xxx */ | |
342 | /* Point-to-Multipoint interfaces */ | |
343 | /* xxx */ | |
344 | } | |
345 | ||
346 | /* Fill LSA Header */ | |
347 | lsa_header->age = 0; | |
348 | lsa_header->type = htons(OSPF6_LSTYPE_ROUTER); | |
349 | lsa_header->id = htonl(link_state_id); | |
350 | lsa_header->adv_router = oa->ospf6->router_id; | |
351 | lsa_header->seqnum = | |
352 | ospf6_new_ls_seqnum(lsa_header->type, lsa_header->id, | |
353 | lsa_header->adv_router, oa->lsdb); | |
354 | lsa_header->length = htons((caddr_t)lsdesc - (caddr_t)buffer); | |
355 | ||
356 | /* LSA checksum */ | |
357 | ospf6_lsa_checksum(lsa_header); | |
358 | ||
359 | /* create LSA */ | |
360 | lsa = ospf6_lsa_create(lsa_header); | |
361 | ||
362 | /* Originate */ | |
363 | ospf6_lsa_originate_area(lsa, oa); | |
364 | ||
365 | link_state_id++; | |
366 | ||
367 | /* Do premature-aging of rest, undesired Router-LSAs */ | |
368 | type = ntohs(OSPF6_LSTYPE_ROUTER); | |
369 | router = oa->ospf6->router_id; | |
370 | count = 0; | |
371 | for (ALL_LSDB_TYPED_ADVRTR(oa->lsdb, type, router, lsa)) { | |
372 | if (ntohl(lsa->header->id) < link_state_id) | |
373 | continue; | |
374 | ospf6_lsa_purge(lsa); | |
375 | count++; | |
c5926a92 | 376 | } |
508e53e2 | 377 | |
d62a17ae | 378 | /* |
379 | * Waiting till the LSA is actually removed from the database to trigger | |
380 | * SPF delays network convergence. Unlike IPv4, for an ABR, when all | |
381 | * interfaces associated with an area are gone, triggering an SPF right | |
382 | * away | |
383 | * helps convergence with inter-area routes. | |
384 | */ | |
385 | if (count && !link_state_id) | |
386 | ospf6_spf_schedule(oa->ospf6, | |
387 | OSPF6_SPF_FLAGS_ROUTER_LSA_ORIGINATED); | |
388 | ||
389 | return 0; | |
508e53e2 | 390 | } |
718e3744 | 391 | |
508e53e2 | 392 | /*******************************/ |
393 | /* RFC2740 3.4.3.2 Network-LSA */ | |
394 | /*******************************/ | |
718e3744 | 395 | |
d62a17ae | 396 | static char *ospf6_network_lsa_get_ar_id(struct ospf6_lsa *lsa, char *buf, |
397 | int buflen, int pos) | |
e68a6767 | 398 | { |
d62a17ae | 399 | char *start, *end, *current; |
400 | struct ospf6_network_lsa *network_lsa; | |
401 | struct ospf6_network_lsdesc *lsdesc; | |
402 | ||
403 | if (lsa) { | |
404 | network_lsa = (struct ospf6_network_lsa | |
405 | *)((caddr_t)lsa->header | |
406 | + sizeof(struct ospf6_lsa_header)); | |
407 | ||
408 | start = (char *)network_lsa + sizeof(struct ospf6_network_lsa); | |
409 | end = (char *)lsa->header + ntohs(lsa->header->length); | |
410 | current = start + pos * (sizeof(struct ospf6_network_lsdesc)); | |
411 | ||
412 | if ((current + sizeof(struct ospf6_network_lsdesc)) <= end) { | |
413 | lsdesc = (struct ospf6_network_lsdesc *)current; | |
414 | if (buf) | |
415 | inet_ntop(AF_INET, &lsdesc->router_id, buf, | |
416 | buflen); | |
417 | } else | |
418 | return NULL; | |
e68a6767 | 419 | } |
e68a6767 | 420 | |
d62a17ae | 421 | return (buf); |
e68a6767 DD |
422 | } |
423 | ||
d62a17ae | 424 | static int ospf6_network_lsa_show(struct vty *vty, struct ospf6_lsa *lsa) |
508e53e2 | 425 | { |
d62a17ae | 426 | char *start, *end, *current; |
427 | struct ospf6_network_lsa *network_lsa; | |
428 | struct ospf6_network_lsdesc *lsdesc; | |
429 | char buf[128], options[32]; | |
430 | ||
431 | network_lsa = | |
432 | (struct ospf6_network_lsa *)((caddr_t)lsa->header | |
433 | + sizeof(struct ospf6_lsa_header)); | |
434 | ||
435 | ospf6_options_printbuf(network_lsa->options, options, sizeof(options)); | |
436 | vty_out(vty, " Options: %s\n", options); | |
437 | ||
438 | start = (char *)network_lsa + sizeof(struct ospf6_network_lsa); | |
439 | end = (char *)lsa->header + ntohs(lsa->header->length); | |
440 | for (current = start; | |
441 | current + sizeof(struct ospf6_network_lsdesc) <= end; | |
442 | current += sizeof(struct ospf6_network_lsdesc)) { | |
443 | lsdesc = (struct ospf6_network_lsdesc *)current; | |
444 | inet_ntop(AF_INET, &lsdesc->router_id, buf, sizeof(buf)); | |
445 | vty_out(vty, " Attached Router: %s\n", buf); | |
446 | } | |
447 | return 0; | |
718e3744 | 448 | } |
449 | ||
d62a17ae | 450 | int ospf6_network_lsa_originate(struct thread *thread) |
718e3744 | 451 | { |
d62a17ae | 452 | struct ospf6_interface *oi; |
453 | ||
454 | char buffer[OSPF6_MAX_LSASIZE]; | |
455 | struct ospf6_lsa_header *lsa_header; | |
456 | ||
457 | int count; | |
458 | struct ospf6_lsa *old, *lsa; | |
459 | struct ospf6_network_lsa *network_lsa; | |
460 | struct ospf6_network_lsdesc *lsdesc; | |
461 | struct ospf6_neighbor *on; | |
462 | struct ospf6_link_lsa *link_lsa; | |
463 | struct listnode *i; | |
d7c0a89a | 464 | uint16_t type; |
d62a17ae | 465 | |
466 | oi = (struct ospf6_interface *)THREAD_ARG(thread); | |
467 | oi->thread_network_lsa = NULL; | |
468 | ||
469 | /* The interface must be enabled until here. A Network-LSA of a | |
470 | disabled interface (but was once enabled) should be flushed | |
471 | by ospf6_lsa_refresh (), and does not come here. */ | |
472 | assert(oi->area); | |
473 | ||
474 | old = ospf6_lsdb_lookup(htons(OSPF6_LSTYPE_NETWORK), | |
475 | htonl(oi->interface->ifindex), | |
476 | oi->area->ospf6->router_id, oi->area->lsdb); | |
477 | ||
478 | /* Do not originate Network-LSA if not DR */ | |
479 | if (oi->state != OSPF6_INTERFACE_DR) { | |
480 | if (old) { | |
481 | ospf6_lsa_purge(old); | |
482 | /* | |
483 | * Waiting till the LSA is actually removed from the | |
484 | * database to | |
485 | * trigger SPF delays network convergence. | |
486 | */ | |
487 | ospf6_spf_schedule( | |
488 | oi->area->ospf6, | |
489 | OSPF6_SPF_FLAGS_NETWORK_LSA_ORIGINATED); | |
490 | } | |
491 | return 0; | |
492 | } | |
493 | ||
494 | if (IS_OSPF6_DEBUG_ORIGINATE(NETWORK)) | |
495 | zlog_debug("Originate Network-LSA for Interface %s", | |
496 | oi->interface->name); | |
497 | ||
498 | /* If none of neighbor is adjacent to us */ | |
499 | count = 0; | |
500 | ||
501 | for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, i, on)) | |
502 | if (on->state == OSPF6_NEIGHBOR_FULL) | |
503 | count++; | |
504 | ||
505 | if (count == 0) { | |
506 | if (IS_OSPF6_DEBUG_ORIGINATE(NETWORK)) | |
507 | zlog_debug("Interface stub, ignore"); | |
508 | if (old) | |
509 | ospf6_lsa_purge(old); | |
510 | return 0; | |
c3c0ac83 | 511 | } |
d62a17ae | 512 | |
513 | /* prepare buffer */ | |
514 | memset(buffer, 0, sizeof(buffer)); | |
515 | lsa_header = (struct ospf6_lsa_header *)buffer; | |
516 | network_lsa = | |
517 | (struct ospf6_network_lsa *)((caddr_t)lsa_header | |
518 | + sizeof(struct ospf6_lsa_header)); | |
519 | ||
520 | /* Collect the interface's Link-LSAs to describe | |
521 | network's optional capabilities */ | |
522 | type = htons(OSPF6_LSTYPE_LINK); | |
523 | for (ALL_LSDB_TYPED(oi->lsdb, type, lsa)) { | |
524 | link_lsa = (struct ospf6_link_lsa | |
525 | *)((caddr_t)lsa->header | |
526 | + sizeof(struct ospf6_lsa_header)); | |
527 | network_lsa->options[0] |= link_lsa->options[0]; | |
528 | network_lsa->options[1] |= link_lsa->options[1]; | |
529 | network_lsa->options[2] |= link_lsa->options[2]; | |
530 | } | |
531 | ||
532 | lsdesc = (struct ospf6_network_lsdesc | |
533 | *)((caddr_t)network_lsa | |
534 | + sizeof(struct ospf6_network_lsa)); | |
535 | ||
536 | /* set Link Description to the router itself */ | |
537 | lsdesc->router_id = oi->area->ospf6->router_id; | |
538 | lsdesc++; | |
539 | ||
540 | /* Walk through the neighbors */ | |
541 | for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, i, on)) { | |
542 | if (on->state != OSPF6_NEIGHBOR_FULL) | |
543 | continue; | |
544 | ||
545 | /* set this neighbor's Router-ID to LSA */ | |
546 | lsdesc->router_id = on->router_id; | |
547 | lsdesc++; | |
548 | } | |
549 | ||
550 | /* Fill LSA Header */ | |
551 | lsa_header->age = 0; | |
552 | lsa_header->type = htons(OSPF6_LSTYPE_NETWORK); | |
553 | lsa_header->id = htonl(oi->interface->ifindex); | |
554 | lsa_header->adv_router = oi->area->ospf6->router_id; | |
555 | lsa_header->seqnum = | |
556 | ospf6_new_ls_seqnum(lsa_header->type, lsa_header->id, | |
557 | lsa_header->adv_router, oi->area->lsdb); | |
558 | lsa_header->length = htons((caddr_t)lsdesc - (caddr_t)buffer); | |
559 | ||
560 | /* LSA checksum */ | |
561 | ospf6_lsa_checksum(lsa_header); | |
562 | ||
563 | /* create LSA */ | |
564 | lsa = ospf6_lsa_create(lsa_header); | |
565 | ||
566 | /* Originate */ | |
567 | ospf6_lsa_originate_area(lsa, oi->area); | |
568 | ||
569 | return 0; | |
508e53e2 | 570 | } |
718e3744 | 571 | |
572 | ||
508e53e2 | 573 | /****************************/ |
574 | /* RFC2740 3.4.3.6 Link-LSA */ | |
575 | /****************************/ | |
576 | ||
d62a17ae | 577 | static char *ospf6_link_lsa_get_prefix_str(struct ospf6_lsa *lsa, char *buf, |
578 | int buflen, int pos) | |
e68a6767 | 579 | { |
d62a17ae | 580 | char *start, *end, *current; |
581 | struct ospf6_link_lsa *link_lsa; | |
582 | struct in6_addr in6; | |
583 | struct ospf6_prefix *prefix; | |
584 | int cnt = 0, prefixnum; | |
585 | ||
586 | if (lsa) { | |
587 | link_lsa = (struct ospf6_link_lsa | |
588 | *)((caddr_t)lsa->header | |
589 | + sizeof(struct ospf6_lsa_header)); | |
590 | ||
591 | if (pos == 0) { | |
592 | inet_ntop(AF_INET6, &link_lsa->linklocal_addr, buf, | |
593 | buflen); | |
594 | return (buf); | |
595 | } | |
596 | ||
597 | prefixnum = ntohl(link_lsa->prefix_num); | |
598 | if (pos > prefixnum) | |
599 | return (NULL); | |
600 | ||
601 | start = (char *)link_lsa + sizeof(struct ospf6_link_lsa); | |
602 | end = (char *)lsa->header + ntohs(lsa->header->length); | |
603 | current = start; | |
604 | ||
605 | do { | |
606 | prefix = (struct ospf6_prefix *)current; | |
607 | if (prefix->prefix_length == 0 | |
608 | || current + OSPF6_PREFIX_SIZE(prefix) > end) { | |
609 | return (NULL); | |
610 | } | |
611 | ||
612 | if (cnt < pos) { | |
613 | current = | |
614 | start + pos * OSPF6_PREFIX_SIZE(prefix); | |
615 | cnt++; | |
616 | } else { | |
617 | memset(&in6, 0, sizeof(in6)); | |
618 | memcpy(&in6, OSPF6_PREFIX_BODY(prefix), | |
619 | OSPF6_PREFIX_SPACE( | |
620 | prefix->prefix_length)); | |
621 | inet_ntop(AF_INET6, &in6, buf, buflen); | |
622 | return (buf); | |
623 | } | |
624 | } while (current <= end); | |
625 | } | |
e68a6767 | 626 | return (NULL); |
e68a6767 DD |
627 | } |
628 | ||
d62a17ae | 629 | static int ospf6_link_lsa_show(struct vty *vty, struct ospf6_lsa *lsa) |
718e3744 | 630 | { |
d62a17ae | 631 | char *start, *end, *current; |
632 | struct ospf6_link_lsa *link_lsa; | |
633 | int prefixnum; | |
634 | char buf[128], options[32]; | |
635 | struct ospf6_prefix *prefix; | |
636 | const char *p, *mc, *la, *nu; | |
637 | struct in6_addr in6; | |
638 | ||
639 | link_lsa = (struct ospf6_link_lsa *)((caddr_t)lsa->header | |
640 | + sizeof(struct ospf6_lsa_header)); | |
641 | ||
642 | ospf6_options_printbuf(link_lsa->options, options, sizeof(options)); | |
643 | inet_ntop(AF_INET6, &link_lsa->linklocal_addr, buf, sizeof(buf)); | |
644 | prefixnum = ntohl(link_lsa->prefix_num); | |
645 | ||
646 | vty_out(vty, " Priority: %d Options: %s\n", link_lsa->priority, | |
647 | options); | |
648 | vty_out(vty, " LinkLocal Address: %s\n", buf); | |
649 | vty_out(vty, " Number of Prefix: %d\n", prefixnum); | |
650 | ||
651 | start = (char *)link_lsa + sizeof(struct ospf6_link_lsa); | |
652 | end = (char *)lsa->header + ntohs(lsa->header->length); | |
653 | for (current = start; current < end; | |
654 | current += OSPF6_PREFIX_SIZE(prefix)) { | |
655 | prefix = (struct ospf6_prefix *)current; | |
656 | if (prefix->prefix_length == 0 | |
657 | || current + OSPF6_PREFIX_SIZE(prefix) > end) | |
658 | break; | |
659 | ||
660 | p = (CHECK_FLAG(prefix->prefix_options, OSPF6_PREFIX_OPTION_P) | |
661 | ? "P" | |
662 | : "--"); | |
663 | mc = (CHECK_FLAG(prefix->prefix_options, OSPF6_PREFIX_OPTION_MC) | |
664 | ? "MC" | |
665 | : "--"); | |
666 | la = (CHECK_FLAG(prefix->prefix_options, OSPF6_PREFIX_OPTION_LA) | |
667 | ? "LA" | |
668 | : "--"); | |
669 | nu = (CHECK_FLAG(prefix->prefix_options, OSPF6_PREFIX_OPTION_NU) | |
670 | ? "NU" | |
671 | : "--"); | |
672 | vty_out(vty, " Prefix Options: %s|%s|%s|%s\n", p, mc, la, | |
673 | nu); | |
674 | ||
675 | memset(&in6, 0, sizeof(in6)); | |
676 | memcpy(&in6, OSPF6_PREFIX_BODY(prefix), | |
677 | OSPF6_PREFIX_SPACE(prefix->prefix_length)); | |
678 | inet_ntop(AF_INET6, &in6, buf, sizeof(buf)); | |
679 | vty_out(vty, " Prefix: %s/%d\n", buf, | |
680 | prefix->prefix_length); | |
681 | } | |
682 | ||
683 | return 0; | |
718e3744 | 684 | } |
685 | ||
d62a17ae | 686 | int ospf6_link_lsa_originate(struct thread *thread) |
718e3744 | 687 | { |
d62a17ae | 688 | struct ospf6_interface *oi; |
689 | ||
690 | char buffer[OSPF6_MAX_LSASIZE]; | |
691 | struct ospf6_lsa_header *lsa_header; | |
692 | struct ospf6_lsa *old, *lsa; | |
693 | ||
694 | struct ospf6_link_lsa *link_lsa; | |
695 | struct ospf6_route *route; | |
696 | struct ospf6_prefix *op; | |
697 | ||
698 | oi = (struct ospf6_interface *)THREAD_ARG(thread); | |
699 | oi->thread_link_lsa = NULL; | |
700 | ||
701 | assert(oi->area); | |
702 | ||
703 | /* find previous LSA */ | |
704 | old = ospf6_lsdb_lookup(htons(OSPF6_LSTYPE_LINK), | |
705 | htonl(oi->interface->ifindex), | |
706 | oi->area->ospf6->router_id, oi->lsdb); | |
707 | ||
708 | if (CHECK_FLAG(oi->flag, OSPF6_INTERFACE_DISABLE)) { | |
709 | if (old) | |
710 | ospf6_lsa_purge(old); | |
711 | return 0; | |
712 | } | |
713 | ||
714 | if (IS_OSPF6_DEBUG_ORIGINATE(LINK)) | |
715 | zlog_debug("Originate Link-LSA for Interface %s", | |
716 | oi->interface->name); | |
717 | ||
718 | /* can't make Link-LSA if linklocal address not set */ | |
719 | if (oi->linklocal_addr == NULL) { | |
720 | if (IS_OSPF6_DEBUG_ORIGINATE(LINK)) | |
721 | zlog_debug( | |
722 | "No Linklocal address on %s, defer originating", | |
723 | oi->interface->name); | |
724 | if (old) | |
725 | ospf6_lsa_purge(old); | |
726 | return 0; | |
727 | } | |
728 | ||
729 | /* prepare buffer */ | |
730 | memset(buffer, 0, sizeof(buffer)); | |
731 | lsa_header = (struct ospf6_lsa_header *)buffer; | |
732 | link_lsa = (struct ospf6_link_lsa *)((caddr_t)lsa_header | |
733 | + sizeof(struct ospf6_lsa_header)); | |
734 | ||
735 | /* Fill Link-LSA */ | |
736 | link_lsa->priority = oi->priority; | |
737 | memcpy(link_lsa->options, oi->area->options, 3); | |
738 | memcpy(&link_lsa->linklocal_addr, oi->linklocal_addr, | |
739 | sizeof(struct in6_addr)); | |
740 | link_lsa->prefix_num = htonl(oi->route_connected->count); | |
741 | ||
742 | op = (struct ospf6_prefix *)((caddr_t)link_lsa | |
743 | + sizeof(struct ospf6_link_lsa)); | |
744 | ||
745 | /* connected prefix to advertise */ | |
746 | for (route = ospf6_route_head(oi->route_connected); route; | |
747 | route = ospf6_route_next(route)) { | |
748 | op->prefix_length = route->prefix.prefixlen; | |
749 | op->prefix_options = route->path.prefix_options; | |
750 | op->prefix_metric = htons(0); | |
751 | memcpy(OSPF6_PREFIX_BODY(op), &route->prefix.u.prefix6, | |
752 | OSPF6_PREFIX_SPACE(op->prefix_length)); | |
753 | op = OSPF6_PREFIX_NEXT(op); | |
754 | } | |
755 | ||
756 | /* Fill LSA Header */ | |
757 | lsa_header->age = 0; | |
758 | lsa_header->type = htons(OSPF6_LSTYPE_LINK); | |
759 | lsa_header->id = htonl(oi->interface->ifindex); | |
760 | lsa_header->adv_router = oi->area->ospf6->router_id; | |
761 | lsa_header->seqnum = | |
762 | ospf6_new_ls_seqnum(lsa_header->type, lsa_header->id, | |
763 | lsa_header->adv_router, oi->lsdb); | |
764 | lsa_header->length = htons((caddr_t)op - (caddr_t)buffer); | |
765 | ||
766 | /* LSA checksum */ | |
767 | ospf6_lsa_checksum(lsa_header); | |
768 | ||
769 | /* create LSA */ | |
770 | lsa = ospf6_lsa_create(lsa_header); | |
771 | ||
772 | /* Originate */ | |
773 | ospf6_lsa_originate_interface(lsa, oi); | |
774 | ||
775 | return 0; | |
508e53e2 | 776 | } |
718e3744 | 777 | |
718e3744 | 778 | |
508e53e2 | 779 | /*****************************************/ |
780 | /* RFC2740 3.4.3.7 Intra-Area-Prefix-LSA */ | |
781 | /*****************************************/ | |
d62a17ae | 782 | static char *ospf6_intra_prefix_lsa_get_prefix_str(struct ospf6_lsa *lsa, |
783 | char *buf, int buflen, | |
784 | int pos) | |
e68a6767 | 785 | { |
d62a17ae | 786 | char *start, *end, *current; |
787 | struct ospf6_intra_prefix_lsa *intra_prefix_lsa; | |
788 | struct in6_addr in6; | |
789 | int prefixnum, cnt = 0; | |
790 | struct ospf6_prefix *prefix; | |
791 | ||
792 | if (lsa) { | |
793 | intra_prefix_lsa = | |
794 | (struct ospf6_intra_prefix_lsa | |
795 | *)((caddr_t)lsa->header | |
796 | + sizeof(struct ospf6_lsa_header)); | |
797 | ||
798 | prefixnum = ntohs(intra_prefix_lsa->prefix_num); | |
799 | if (pos > prefixnum) | |
800 | return (NULL); | |
801 | ||
802 | start = (char *)intra_prefix_lsa | |
803 | + sizeof(struct ospf6_intra_prefix_lsa); | |
804 | end = (char *)lsa->header + ntohs(lsa->header->length); | |
805 | current = start; | |
806 | ||
807 | do { | |
808 | prefix = (struct ospf6_prefix *)current; | |
809 | if (prefix->prefix_length == 0 | |
810 | || current + OSPF6_PREFIX_SIZE(prefix) > end) { | |
811 | return NULL; | |
812 | } | |
813 | ||
814 | if (cnt < pos) { | |
815 | current = | |
816 | start + pos * OSPF6_PREFIX_SIZE(prefix); | |
817 | cnt++; | |
818 | } else { | |
819 | memset(&in6, 0, sizeof(in6)); | |
820 | memcpy(&in6, OSPF6_PREFIX_BODY(prefix), | |
821 | OSPF6_PREFIX_SPACE( | |
822 | prefix->prefix_length)); | |
823 | inet_ntop(AF_INET6, &in6, buf, buflen); | |
824 | sprintf(&buf[strlen(buf)], "/%d", | |
825 | prefix->prefix_length); | |
826 | return (buf); | |
827 | } | |
828 | } while (current <= end); | |
829 | } | |
830 | return (buf); | |
e68a6767 | 831 | } |
718e3744 | 832 | |
d62a17ae | 833 | static int ospf6_intra_prefix_lsa_show(struct vty *vty, struct ospf6_lsa *lsa) |
508e53e2 | 834 | { |
d62a17ae | 835 | char *start, *end, *current; |
836 | struct ospf6_intra_prefix_lsa *intra_prefix_lsa; | |
837 | int prefixnum; | |
838 | char buf[128]; | |
839 | struct ospf6_prefix *prefix; | |
840 | char id[16], adv_router[16]; | |
841 | const char *p, *mc, *la, *nu; | |
842 | struct in6_addr in6; | |
843 | ||
844 | intra_prefix_lsa = (struct ospf6_intra_prefix_lsa | |
845 | *)((caddr_t)lsa->header | |
846 | + sizeof(struct ospf6_lsa_header)); | |
847 | ||
848 | prefixnum = ntohs(intra_prefix_lsa->prefix_num); | |
849 | ||
850 | vty_out(vty, " Number of Prefix: %d\n", prefixnum); | |
851 | ||
852 | inet_ntop(AF_INET, &intra_prefix_lsa->ref_id, id, sizeof(id)); | |
853 | inet_ntop(AF_INET, &intra_prefix_lsa->ref_adv_router, adv_router, | |
854 | sizeof(adv_router)); | |
855 | vty_out(vty, " Reference: %s Id: %s Adv: %s\n", | |
856 | ospf6_lstype_name(intra_prefix_lsa->ref_type), id, adv_router); | |
857 | ||
858 | start = (char *)intra_prefix_lsa | |
859 | + sizeof(struct ospf6_intra_prefix_lsa); | |
860 | end = (char *)lsa->header + ntohs(lsa->header->length); | |
861 | for (current = start; current < end; | |
862 | current += OSPF6_PREFIX_SIZE(prefix)) { | |
863 | prefix = (struct ospf6_prefix *)current; | |
864 | if (prefix->prefix_length == 0 | |
865 | || current + OSPF6_PREFIX_SIZE(prefix) > end) | |
866 | break; | |
867 | ||
868 | p = (CHECK_FLAG(prefix->prefix_options, OSPF6_PREFIX_OPTION_P) | |
869 | ? "P" | |
870 | : "--"); | |
871 | mc = (CHECK_FLAG(prefix->prefix_options, OSPF6_PREFIX_OPTION_MC) | |
872 | ? "MC" | |
873 | : "--"); | |
874 | la = (CHECK_FLAG(prefix->prefix_options, OSPF6_PREFIX_OPTION_LA) | |
875 | ? "LA" | |
876 | : "--"); | |
877 | nu = (CHECK_FLAG(prefix->prefix_options, OSPF6_PREFIX_OPTION_NU) | |
878 | ? "NU" | |
879 | : "--"); | |
880 | vty_out(vty, " Prefix Options: %s|%s|%s|%s\n", p, mc, la, | |
881 | nu); | |
882 | ||
883 | memset(&in6, 0, sizeof(in6)); | |
884 | memcpy(&in6, OSPF6_PREFIX_BODY(prefix), | |
885 | OSPF6_PREFIX_SPACE(prefix->prefix_length)); | |
886 | inet_ntop(AF_INET6, &in6, buf, sizeof(buf)); | |
887 | vty_out(vty, " Prefix: %s/%d\n", buf, | |
888 | prefix->prefix_length); | |
889 | } | |
890 | ||
891 | return 0; | |
718e3744 | 892 | } |
893 | ||
d62a17ae | 894 | int ospf6_intra_prefix_lsa_originate_stub(struct thread *thread) |
718e3744 | 895 | { |
d62a17ae | 896 | struct ospf6_area *oa; |
897 | ||
898 | char buffer[OSPF6_MAX_LSASIZE]; | |
899 | struct ospf6_lsa_header *lsa_header; | |
9a703f8d | 900 | struct ospf6_lsa *old, *lsa, *old_next = NULL; |
d62a17ae | 901 | |
902 | struct ospf6_intra_prefix_lsa *intra_prefix_lsa; | |
903 | struct ospf6_interface *oi; | |
904 | struct ospf6_neighbor *on; | |
905 | struct ospf6_route *route; | |
906 | struct ospf6_prefix *op; | |
907 | struct listnode *i, *j; | |
908 | int full_count = 0; | |
909 | unsigned short prefix_num = 0; | |
910 | char buf[PREFIX2STR_BUFFER]; | |
911 | struct ospf6_route_table *route_advertise; | |
9a703f8d | 912 | int ls_id = 0; |
d62a17ae | 913 | |
914 | oa = (struct ospf6_area *)THREAD_ARG(thread); | |
915 | oa->thread_intra_prefix_lsa = NULL; | |
916 | ||
917 | /* find previous LSA */ | |
918 | old = ospf6_lsdb_lookup(htons(OSPF6_LSTYPE_INTRA_PREFIX), htonl(0), | |
919 | oa->ospf6->router_id, oa->lsdb); | |
920 | ||
921 | if (!IS_AREA_ENABLED(oa)) { | |
9a703f8d | 922 | if (old) { |
d62a17ae | 923 | ospf6_lsa_purge(old); |
9a703f8d CS |
924 | /* find previous LSA */ |
925 | old_next = ospf6_lsdb_lookup( | |
996c9314 LB |
926 | htons(OSPF6_LSTYPE_INTRA_PREFIX), |
927 | htonl(++ls_id), oa->ospf6->router_id, oa->lsdb); | |
9a703f8d CS |
928 | |
929 | while (old_next) { | |
930 | ospf6_lsa_purge(old_next); | |
931 | old_next = ospf6_lsdb_lookup( | |
932 | htons(OSPF6_LSTYPE_INTRA_PREFIX), | |
996c9314 LB |
933 | htonl(++ls_id), oa->ospf6->router_id, |
934 | oa->lsdb); | |
9a703f8d CS |
935 | } |
936 | } | |
d62a17ae | 937 | return 0; |
938 | } | |
939 | ||
940 | if (IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX)) | |
941 | zlog_debug( | |
942 | "Originate Intra-Area-Prefix-LSA for area %s's stub prefix", | |
943 | oa->name); | |
944 | ||
945 | /* prepare buffer */ | |
946 | memset(buffer, 0, sizeof(buffer)); | |
947 | lsa_header = (struct ospf6_lsa_header *)buffer; | |
996c9314 LB |
948 | intra_prefix_lsa = (struct ospf6_intra_prefix_lsa |
949 | *)((caddr_t)lsa_header | |
d62a17ae | 950 | + sizeof(struct ospf6_lsa_header)); |
951 | ||
952 | /* Fill Intra-Area-Prefix-LSA */ | |
953 | intra_prefix_lsa->ref_type = htons(OSPF6_LSTYPE_ROUTER); | |
954 | intra_prefix_lsa->ref_id = htonl(0); | |
955 | intra_prefix_lsa->ref_adv_router = oa->ospf6->router_id; | |
956 | ||
957 | route_advertise = ospf6_route_table_create(0, 0); | |
958 | ||
959 | for (ALL_LIST_ELEMENTS_RO(oa->if_list, i, oi)) { | |
960 | if (oi->state == OSPF6_INTERFACE_DOWN) { | |
961 | if (IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX)) | |
962 | zlog_debug(" Interface %s is down, ignore", | |
963 | oi->interface->name); | |
964 | continue; | |
965 | } | |
966 | ||
967 | full_count = 0; | |
968 | ||
969 | for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, j, on)) | |
970 | if (on->state == OSPF6_NEIGHBOR_FULL) | |
971 | full_count++; | |
972 | ||
973 | if (oi->state != OSPF6_INTERFACE_LOOPBACK | |
974 | && oi->state != OSPF6_INTERFACE_POINTTOPOINT | |
975 | && full_count != 0) { | |
976 | if (IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX)) | |
977 | zlog_debug(" Interface %s is not stub, ignore", | |
978 | oi->interface->name); | |
979 | continue; | |
980 | } | |
981 | ||
982 | if (IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX)) | |
983 | zlog_debug(" Interface %s:", oi->interface->name); | |
984 | ||
985 | /* connected prefix to advertise */ | |
986 | for (route = ospf6_route_head(oi->route_connected); route; | |
987 | route = ospf6_route_best_next(route)) { | |
988 | if (IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX)) { | |
989 | prefix2str(&route->prefix, buf, sizeof(buf)); | |
990 | zlog_debug(" include %s", buf); | |
991 | } | |
992 | ospf6_route_add(ospf6_route_copy(route), | |
993 | route_advertise); | |
994 | } | |
995 | } | |
996 | ||
997 | if (route_advertise->count == 0) { | |
9a703f8d CS |
998 | if (old) { |
999 | ls_id = 0; | |
d62a17ae | 1000 | ospf6_lsa_purge(old); |
9a703f8d CS |
1001 | /* find previous LSA */ |
1002 | old_next = ospf6_lsdb_lookup( | |
996c9314 LB |
1003 | htons(OSPF6_LSTYPE_INTRA_PREFIX), |
1004 | htonl(++ls_id), oa->ospf6->router_id, oa->lsdb); | |
9a703f8d CS |
1005 | |
1006 | while (old_next) { | |
1007 | ospf6_lsa_purge(old_next); | |
1008 | old_next = ospf6_lsdb_lookup( | |
1009 | htons(OSPF6_LSTYPE_INTRA_PREFIX), | |
996c9314 LB |
1010 | htonl(++ls_id), oa->ospf6->router_id, |
1011 | oa->lsdb); | |
9a703f8d CS |
1012 | } |
1013 | } | |
d62a17ae | 1014 | ospf6_route_table_delete(route_advertise); |
1015 | return 0; | |
1016 | } | |
1017 | ||
690df177 CS |
1018 | /* Neighbor change to FULL, if INTRA-AREA-PREFIX LSA |
1019 | * has not change, Flush old LSA and Re-Originate INP, | |
1020 | * as ospf6_flood() checks if LSA is same as DB, | |
1021 | * it won't be updated to neighbor's DB. | |
1022 | */ | |
1023 | if (oa->intra_prefix_originate) { | |
1024 | if (IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX)) | |
1025 | zlog_debug("%s: Re-originate intra prefix LSA, Current full nbrs %u", | |
1026 | __PRETTY_FUNCTION__, oa->full_nbrs); | |
1027 | if (old) | |
1028 | ospf6_lsa_purge_multi_ls_id(oa, old); | |
1029 | oa->intra_prefix_originate = 0; | |
1030 | } | |
1031 | ||
d62a17ae | 1032 | /* put prefixes to advertise */ |
1033 | prefix_num = 0; | |
1034 | op = (struct ospf6_prefix *)((caddr_t)intra_prefix_lsa | |
1035 | + sizeof(struct ospf6_intra_prefix_lsa)); | |
1036 | for (route = ospf6_route_head(route_advertise); route; | |
1037 | route = ospf6_route_best_next(route)) { | |
9a703f8d CS |
1038 | if (((caddr_t)op - (caddr_t)lsa_header) > MAX_LSA_PAYLOAD) { |
1039 | ||
1040 | intra_prefix_lsa->prefix_num = htons(prefix_num); | |
1041 | ||
1042 | /* Fill LSA Header */ | |
1043 | lsa_header->age = 0; | |
1044 | lsa_header->type = htons(OSPF6_LSTYPE_INTRA_PREFIX); | |
1045 | lsa_header->id = htonl(ls_id++); | |
1046 | lsa_header->adv_router = oa->ospf6->router_id; | |
996c9314 LB |
1047 | lsa_header->seqnum = ospf6_new_ls_seqnum( |
1048 | lsa_header->type, lsa_header->id, | |
1049 | lsa_header->adv_router, oa->lsdb); | |
1050 | lsa_header->length = | |
1051 | htons((caddr_t)op - (caddr_t)lsa_header); | |
9a703f8d CS |
1052 | |
1053 | /* LSA checksum */ | |
1054 | ospf6_lsa_checksum(lsa_header); | |
1055 | ||
1056 | /* Create LSA */ | |
1057 | lsa = ospf6_lsa_create(lsa_header); | |
1058 | ||
1059 | /* Originate */ | |
1060 | ospf6_lsa_originate_area(lsa, oa); | |
1061 | ||
1062 | /* Prepare next buffer */ | |
1063 | memset(buffer, 0, sizeof(buffer)); | |
1064 | lsa_header = (struct ospf6_lsa_header *)buffer; | |
996c9314 LB |
1065 | intra_prefix_lsa = |
1066 | (struct ospf6_intra_prefix_lsa | |
1067 | *)((caddr_t)lsa_header | |
1068 | + sizeof(struct ospf6_lsa_header)); | |
9a703f8d CS |
1069 | |
1070 | /* Fill Intra-Area-Prefix-LSA */ | |
1071 | intra_prefix_lsa->ref_type = htons(OSPF6_LSTYPE_ROUTER); | |
1072 | intra_prefix_lsa->ref_id = htonl(0); | |
1073 | intra_prefix_lsa->ref_adv_router = oa->ospf6->router_id; | |
1074 | ||
1075 | /* Put next set of prefixes to advertise */ | |
1076 | prefix_num = 0; | |
996c9314 LB |
1077 | op = (struct ospf6_prefix |
1078 | *)((caddr_t)intra_prefix_lsa | |
1079 | + sizeof(struct | |
1080 | ospf6_intra_prefix_lsa)); | |
9a703f8d CS |
1081 | } |
1082 | ||
d62a17ae | 1083 | op->prefix_length = route->prefix.prefixlen; |
1084 | op->prefix_options = route->path.prefix_options; | |
1085 | op->prefix_metric = htons(route->path.cost); | |
1086 | memcpy(OSPF6_PREFIX_BODY(op), &route->prefix.u.prefix6, | |
1087 | OSPF6_PREFIX_SPACE(op->prefix_length)); | |
d62a17ae | 1088 | prefix_num++; |
9a703f8d CS |
1089 | |
1090 | op = OSPF6_PREFIX_NEXT(op); | |
d62a17ae | 1091 | } |
1092 | ||
1093 | ospf6_route_table_delete(route_advertise); | |
1094 | ||
1095 | if (prefix_num == 0) { | |
1096 | if (IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX)) | |
1097 | zlog_debug( | |
1098 | "Quit to Advertise Intra-Prefix: no route to advertise"); | |
1099 | return 0; | |
1100 | } | |
1101 | ||
1102 | intra_prefix_lsa->prefix_num = htons(prefix_num); | |
1103 | ||
1104 | /* Fill LSA Header */ | |
1105 | lsa_header->age = 0; | |
1106 | lsa_header->type = htons(OSPF6_LSTYPE_INTRA_PREFIX); | |
9a703f8d | 1107 | lsa_header->id = htonl(ls_id++); |
d62a17ae | 1108 | lsa_header->adv_router = oa->ospf6->router_id; |
1109 | lsa_header->seqnum = | |
1110 | ospf6_new_ls_seqnum(lsa_header->type, lsa_header->id, | |
1111 | lsa_header->adv_router, oa->lsdb); | |
1112 | lsa_header->length = htons((caddr_t)op - (caddr_t)lsa_header); | |
1113 | ||
1114 | /* LSA checksum */ | |
1115 | ospf6_lsa_checksum(lsa_header); | |
1116 | ||
1117 | /* create LSA */ | |
1118 | lsa = ospf6_lsa_create(lsa_header); | |
1119 | ||
1120 | /* Originate */ | |
1121 | ospf6_lsa_originate_area(lsa, oa); | |
1122 | ||
1123 | return 0; | |
508e53e2 | 1124 | } |
718e3744 | 1125 | |
6452df09 | 1126 | |
d62a17ae | 1127 | int ospf6_intra_prefix_lsa_originate_transit(struct thread *thread) |
508e53e2 | 1128 | { |
d62a17ae | 1129 | struct ospf6_interface *oi; |
1130 | ||
1131 | char buffer[OSPF6_MAX_LSASIZE]; | |
1132 | struct ospf6_lsa_header *lsa_header; | |
1133 | struct ospf6_lsa *old, *lsa; | |
1134 | ||
1135 | struct ospf6_intra_prefix_lsa *intra_prefix_lsa; | |
1136 | struct ospf6_neighbor *on; | |
1137 | struct ospf6_route *route; | |
1138 | struct ospf6_prefix *op; | |
1139 | struct listnode *i; | |
1140 | int full_count = 0; | |
1141 | unsigned short prefix_num = 0; | |
1142 | struct ospf6_route_table *route_advertise; | |
1143 | struct ospf6_link_lsa *link_lsa; | |
1144 | char *start, *end, *current; | |
d7c0a89a | 1145 | uint16_t type; |
d62a17ae | 1146 | char buf[PREFIX2STR_BUFFER]; |
1147 | ||
1148 | oi = (struct ospf6_interface *)THREAD_ARG(thread); | |
1149 | oi->thread_intra_prefix_lsa = NULL; | |
1150 | ||
1151 | assert(oi->area); | |
1152 | ||
1153 | /* find previous LSA */ | |
1154 | old = ospf6_lsdb_lookup(htons(OSPF6_LSTYPE_INTRA_PREFIX), | |
1155 | htonl(oi->interface->ifindex), | |
1156 | oi->area->ospf6->router_id, oi->area->lsdb); | |
1157 | ||
1158 | if (CHECK_FLAG(oi->flag, OSPF6_INTERFACE_DISABLE)) { | |
1159 | if (old) | |
1160 | ospf6_lsa_purge(old); | |
1161 | return 0; | |
1162 | } | |
1163 | ||
1164 | if (IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX)) | |
1165 | zlog_debug( | |
1166 | "Originate Intra-Area-Prefix-LSA for interface %s's prefix", | |
1167 | oi->interface->name); | |
1168 | ||
1169 | /* prepare buffer */ | |
1170 | memset(buffer, 0, sizeof(buffer)); | |
1171 | lsa_header = (struct ospf6_lsa_header *)buffer; | |
1172 | intra_prefix_lsa = (struct ospf6_intra_prefix_lsa | |
1173 | *)((caddr_t)lsa_header | |
1174 | + sizeof(struct ospf6_lsa_header)); | |
1175 | ||
1176 | /* Fill Intra-Area-Prefix-LSA */ | |
1177 | intra_prefix_lsa->ref_type = htons(OSPF6_LSTYPE_NETWORK); | |
1178 | intra_prefix_lsa->ref_id = htonl(oi->interface->ifindex); | |
1179 | intra_prefix_lsa->ref_adv_router = oi->area->ospf6->router_id; | |
1180 | ||
1181 | if (oi->state != OSPF6_INTERFACE_DR) { | |
1182 | if (IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX)) | |
1183 | zlog_debug(" Interface is not DR"); | |
1184 | if (old) | |
1185 | ospf6_lsa_purge(old); | |
1186 | return 0; | |
1187 | } | |
1188 | ||
1189 | full_count = 0; | |
1190 | for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, i, on)) | |
1191 | if (on->state == OSPF6_NEIGHBOR_FULL) | |
1192 | full_count++; | |
1193 | ||
1194 | if (full_count == 0) { | |
1195 | if (IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX)) | |
1196 | zlog_debug(" Interface is stub"); | |
1197 | if (old) | |
1198 | ospf6_lsa_purge(old); | |
1199 | return 0; | |
1200 | } | |
1201 | ||
1202 | /* connected prefix to advertise */ | |
1203 | route_advertise = ospf6_route_table_create(0, 0); | |
1204 | ||
1205 | type = ntohs(OSPF6_LSTYPE_LINK); | |
1206 | for (ALL_LSDB_TYPED(oi->lsdb, type, lsa)) { | |
1207 | if (OSPF6_LSA_IS_MAXAGE(lsa)) | |
1208 | continue; | |
1209 | ||
1210 | if (IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX)) | |
1211 | zlog_debug(" include prefix from %s", lsa->name); | |
1212 | ||
1213 | if (lsa->header->adv_router != oi->area->ospf6->router_id) { | |
1214 | on = ospf6_neighbor_lookup(lsa->header->adv_router, oi); | |
1215 | if (on == NULL || on->state != OSPF6_NEIGHBOR_FULL) { | |
1216 | if (IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX)) | |
1217 | zlog_debug( | |
1218 | " Neighbor not found or not Full, ignore"); | |
1219 | continue; | |
1220 | } | |
1221 | } | |
1222 | ||
1223 | link_lsa = (struct ospf6_link_lsa | |
1224 | *)((caddr_t)lsa->header | |
1225 | + sizeof(struct ospf6_lsa_header)); | |
1226 | ||
1227 | prefix_num = (unsigned short)ntohl(link_lsa->prefix_num); | |
1228 | start = (char *)link_lsa + sizeof(struct ospf6_link_lsa); | |
1229 | end = (char *)lsa->header + ntohs(lsa->header->length); | |
1230 | for (current = start; current < end && prefix_num; | |
1231 | current += OSPF6_PREFIX_SIZE(op)) { | |
1232 | op = (struct ospf6_prefix *)current; | |
1233 | if (op->prefix_length == 0 | |
1234 | || current + OSPF6_PREFIX_SIZE(op) > end) | |
1235 | break; | |
1236 | ||
1237 | route = ospf6_route_create(); | |
1238 | ||
1239 | route->type = OSPF6_DEST_TYPE_NETWORK; | |
1240 | route->prefix.family = AF_INET6; | |
1241 | route->prefix.prefixlen = op->prefix_length; | |
1242 | memset(&route->prefix.u.prefix6, 0, | |
1243 | sizeof(struct in6_addr)); | |
1244 | memcpy(&route->prefix.u.prefix6, OSPF6_PREFIX_BODY(op), | |
1245 | OSPF6_PREFIX_SPACE(op->prefix_length)); | |
1246 | ||
1247 | route->path.origin.type = lsa->header->type; | |
1248 | route->path.origin.id = lsa->header->id; | |
1249 | route->path.origin.adv_router = lsa->header->adv_router; | |
1250 | route->path.options[0] = link_lsa->options[0]; | |
1251 | route->path.options[1] = link_lsa->options[1]; | |
1252 | route->path.options[2] = link_lsa->options[2]; | |
1253 | route->path.prefix_options = op->prefix_options; | |
1254 | route->path.area_id = oi->area->area_id; | |
1255 | route->path.type = OSPF6_PATH_TYPE_INTRA; | |
1256 | ||
1257 | if (IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX)) { | |
1258 | prefix2str(&route->prefix, buf, sizeof(buf)); | |
1259 | zlog_debug(" include %s", buf); | |
1260 | } | |
1261 | ||
1262 | ospf6_route_add(route, route_advertise); | |
1263 | prefix_num--; | |
1264 | } | |
1265 | if (current != end && IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX)) | |
1266 | zlog_debug("Trailing garbage in %s", lsa->name); | |
1267 | } | |
1268 | ||
1269 | op = (struct ospf6_prefix *)((caddr_t)intra_prefix_lsa | |
1270 | + sizeof(struct ospf6_intra_prefix_lsa)); | |
1271 | ||
1272 | prefix_num = 0; | |
1273 | for (route = ospf6_route_head(route_advertise); route; | |
1274 | route = ospf6_route_best_next(route)) { | |
1275 | op->prefix_length = route->prefix.prefixlen; | |
1276 | op->prefix_options = route->path.prefix_options; | |
1277 | op->prefix_metric = htons(0); | |
1278 | memcpy(OSPF6_PREFIX_BODY(op), &route->prefix.u.prefix6, | |
1279 | OSPF6_PREFIX_SPACE(op->prefix_length)); | |
1280 | op = OSPF6_PREFIX_NEXT(op); | |
1281 | prefix_num++; | |
1282 | } | |
1283 | ||
1284 | ospf6_route_table_delete(route_advertise); | |
1285 | ||
1286 | if (prefix_num == 0) { | |
1287 | if (IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX)) | |
1288 | zlog_debug( | |
1289 | "Quit to Advertise Intra-Prefix: no route to advertise"); | |
1290 | return 0; | |
1291 | } | |
1292 | ||
1293 | intra_prefix_lsa->prefix_num = htons(prefix_num); | |
1294 | ||
1295 | /* Fill LSA Header */ | |
1296 | lsa_header->age = 0; | |
1297 | lsa_header->type = htons(OSPF6_LSTYPE_INTRA_PREFIX); | |
1298 | lsa_header->id = htonl(oi->interface->ifindex); | |
1299 | lsa_header->adv_router = oi->area->ospf6->router_id; | |
1300 | lsa_header->seqnum = | |
1301 | ospf6_new_ls_seqnum(lsa_header->type, lsa_header->id, | |
1302 | lsa_header->adv_router, oi->area->lsdb); | |
1303 | lsa_header->length = htons((caddr_t)op - (caddr_t)lsa_header); | |
1304 | ||
1305 | /* LSA checksum */ | |
1306 | ospf6_lsa_checksum(lsa_header); | |
1307 | ||
1308 | /* create LSA */ | |
1309 | lsa = ospf6_lsa_create(lsa_header); | |
1310 | ||
1311 | /* Originate */ | |
1312 | ospf6_lsa_originate_area(lsa, oi->area); | |
1313 | ||
1314 | return 0; | |
508e53e2 | 1315 | } |
1316 | ||
6942698d CS |
1317 | static void ospf6_intra_prefix_update_route_origin(struct ospf6_route *oa_route) |
1318 | { | |
1319 | struct ospf6_path *h_path; | |
1320 | struct ospf6_route *g_route, *nroute; | |
1321 | ||
1322 | /* Update Global ospf6 route path */ | |
1323 | g_route = ospf6_route_lookup(&oa_route->prefix, | |
1324 | ospf6->route_table); | |
1325 | ||
1326 | for (ospf6_route_lock(g_route); g_route && | |
1327 | ospf6_route_is_prefix(&oa_route->prefix, g_route); | |
1328 | g_route = nroute) { | |
1329 | nroute = ospf6_route_next(g_route); | |
1330 | if (g_route->type != oa_route->type) | |
1331 | continue; | |
1332 | if (g_route->path.area_id != oa_route->path.area_id) | |
1333 | continue; | |
1334 | if (g_route->path.type != OSPF6_PATH_TYPE_INTRA) | |
1335 | continue; | |
1336 | if (g_route->path.cost != oa_route->path.cost) | |
1337 | continue; | |
1338 | ||
1339 | if (ospf6_route_is_same_origin(g_route, oa_route)) { | |
1340 | h_path = (struct ospf6_path *)listgetdata( | |
1341 | listhead(g_route->paths)); | |
1342 | g_route->path.origin.type = h_path->origin.type; | |
1343 | g_route->path.origin.id = h_path->origin.id; | |
1344 | g_route->path.origin.adv_router = | |
1345 | h_path->origin.adv_router; | |
1346 | break; | |
1347 | } | |
1348 | } | |
1349 | ||
1350 | h_path = (struct ospf6_path *)listgetdata( | |
1351 | listhead(oa_route->paths)); | |
1352 | oa_route->path.origin.type = h_path->origin.type; | |
1353 | oa_route->path.origin.id = h_path->origin.id; | |
1354 | oa_route->path.origin.adv_router = h_path->origin.adv_router; | |
1355 | } | |
1356 | ||
03f3c1c1 CS |
1357 | void ospf6_intra_prefix_route_ecmp_path(struct ospf6_area *oa, |
1358 | struct ospf6_route *old, | |
1359 | struct ospf6_route *route) | |
1360 | { | |
6942698d | 1361 | struct ospf6_route *old_route, *ls_entry; |
03f3c1c1 CS |
1362 | struct ospf6_path *ecmp_path, *o_path = NULL; |
1363 | struct listnode *anode, *anext; | |
1364 | struct listnode *nnode, *rnode, *rnext; | |
1365 | struct ospf6_nexthop *nh, *rnh; | |
1366 | char buf[PREFIX2STR_BUFFER]; | |
1367 | bool route_found = false; | |
6942698d CS |
1368 | struct interface *ifp; |
1369 | struct ospf6_lsa *lsa; | |
1370 | struct ospf6_intra_prefix_lsa *intra_prefix_lsa; | |
03f3c1c1 CS |
1371 | |
1372 | /* check for old entry match with new route origin, | |
1373 | * delete old entry. | |
1374 | */ | |
1375 | for (old_route = old; old_route; old_route = old_route->next) { | |
1376 | bool route_updated = false; | |
1377 | ||
1378 | if (!ospf6_route_is_same(old_route, route) || | |
1379 | (old_route->path.type != route->path.type)) | |
1380 | continue; | |
1381 | ||
1382 | /* Current and New route has same origin, | |
1383 | * delete old entry. | |
1384 | */ | |
1385 | for (ALL_LIST_ELEMENTS(old_route->paths, anode, anext, | |
1386 | o_path)) { | |
1387 | /* Check old route path and route has same | |
1388 | * origin. | |
1389 | */ | |
1390 | if (o_path->area_id != route->path.area_id || | |
1391 | (memcmp(&(o_path)->origin, &(route)->path.origin, | |
1392 | sizeof(struct ospf6_ls_origin)) != 0)) | |
1393 | continue; | |
1394 | ||
1395 | /* Cost is not same then delete current path */ | |
1396 | if (o_path->cost == route->path.cost) | |
1397 | continue; | |
1398 | ||
1399 | if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) { | |
1400 | prefix2str(&old_route->prefix, buf, | |
1401 | sizeof(buf)); | |
1402 | zlog_debug("%s: route %s cost old %u new %u is not same, replace route", | |
1403 | __PRETTY_FUNCTION__, buf, | |
1404 | o_path->cost, route->path.cost); | |
1405 | } | |
1406 | ||
6942698d | 1407 | /* Remove selected current path's nh from |
03f3c1c1 CS |
1408 | * effective nh list. |
1409 | */ | |
1410 | for (ALL_LIST_ELEMENTS_RO(o_path->nh_list, nnode, nh)) { | |
1411 | for (ALL_LIST_ELEMENTS(old_route->nh_list, | |
1412 | rnode, rnext, rnh)) { | |
1413 | if (!ospf6_nexthop_is_same(rnh, nh)) | |
1414 | continue; | |
1415 | listnode_delete(old_route->nh_list, | |
1416 | rnh); | |
1417 | ospf6_nexthop_delete(rnh); | |
1418 | route_updated = true; | |
1419 | } | |
1420 | } | |
1421 | ||
1422 | listnode_delete(old_route->paths, o_path); | |
1423 | ospf6_path_free(o_path); | |
1424 | ||
1425 | /* Current route's path (adv_router info) is similar | |
1426 | * to route being added. | |
1427 | * Replace current route's path with paths list head. | |
1428 | * Update FIB with effective NHs. | |
1429 | */ | |
1430 | if (listcount(old_route->paths)) { | |
03f3c1c1 CS |
1431 | if (route_updated) { |
1432 | for (ALL_LIST_ELEMENTS(old_route->paths, | |
1433 | anode, anext, o_path)) { | |
1434 | ospf6_merge_nexthops( | |
1435 | old_route->nh_list, | |
1436 | o_path->nh_list); | |
1437 | } | |
1438 | /* Update ospf6 route table and | |
1439 | * RIB/FIB with effective | |
1440 | * nh_list | |
1441 | */ | |
1442 | if (oa->route_table->hook_add) | |
1443 | (*oa->route_table->hook_add) | |
1444 | (old_route); | |
6942698d CS |
1445 | |
1446 | if (old_route->path.origin.id == | |
1447 | route->path.origin.id && | |
1448 | old_route->path.origin.adv_router == | |
1449 | route->path.origin.adv_router) { | |
1450 | ospf6_intra_prefix_update_route_origin( | |
1451 | old_route); | |
1452 | } | |
03f3c1c1 CS |
1453 | break; |
1454 | } | |
1455 | } else { | |
1456 | if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) { | |
1457 | prefix2str(&old_route->prefix, buf, | |
1458 | sizeof(buf)); | |
1459 | zlog_debug("%s: route %s old cost %u new cost %u, delete old entry.", | |
1460 | __PRETTY_FUNCTION__, buf, | |
1461 | old_route->path.cost, | |
1462 | route->path.cost); | |
1463 | } | |
6942698d CS |
1464 | if (oa->route_table->hook_remove) |
1465 | ospf6_route_remove(old_route, | |
03f3c1c1 | 1466 | oa->route_table); |
6942698d CS |
1467 | else |
1468 | SET_FLAG(old_route->flag, | |
1469 | OSPF6_ROUTE_REMOVE); | |
03f3c1c1 CS |
1470 | break; |
1471 | } | |
1472 | } | |
1473 | if (route_updated) | |
1474 | break; | |
1475 | } | |
1476 | ||
1477 | for (old_route = old; old_route; old_route = old_route->next) { | |
1478 | ||
1479 | if (!ospf6_route_is_same(old_route, route) || | |
1480 | (old_route->path.type != route->path.type)) | |
1481 | continue; | |
1482 | ||
1483 | /* Old Route and New Route have Equal Cost, Merge NHs */ | |
1484 | if (old_route->path.cost == route->path.cost) { | |
1485 | route_found = true; | |
1486 | ||
1487 | /* check if this path exists already in | |
1488 | * route->paths list, if so, replace nh_list. | |
1489 | */ | |
1490 | for (ALL_LIST_ELEMENTS_RO(old_route->paths, anode, | |
1491 | o_path)) { | |
1492 | if (o_path->area_id == route->path.area_id && | |
1493 | (memcmp(&(o_path)->origin, | |
1494 | &(route)->path.origin, | |
1495 | sizeof(struct ospf6_ls_origin)) == 0)) | |
1496 | break; | |
1497 | } | |
1498 | /* If path is not found in old_route paths's list, | |
1499 | * add a new path to route paths list and merge | |
1500 | * nexthops in route->path->nh_list. | |
1501 | * Otherwise replace existing path's nh_list. | |
1502 | */ | |
1503 | if (o_path == NULL) { | |
1504 | ecmp_path = ospf6_path_dup(&route->path); | |
1505 | ||
1506 | /* Add a nh_list to new ecmp path */ | |
1507 | ospf6_copy_nexthops(ecmp_path->nh_list, | |
1508 | route->nh_list); | |
03f3c1c1 CS |
1509 | /* Add the new path to route's path list */ |
1510 | listnode_add_sort(old_route->paths, ecmp_path); | |
1511 | ||
03f3c1c1 CS |
1512 | if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) { |
1513 | prefix2str(&route->prefix, buf, | |
1514 | sizeof(buf)); | |
6942698d CS |
1515 | zlog_debug( |
1516 | "%s: route %s %p another path added with nh %u, effective paths %u nh %u", | |
03f3c1c1 CS |
1517 | __PRETTY_FUNCTION__, buf, |
1518 | (void *)old_route, | |
1519 | listcount(ecmp_path->nh_list), | |
1520 | old_route->paths ? | |
6942698d | 1521 | listcount(old_route->paths) : 0, |
03f3c1c1 | 1522 | listcount(old_route->nh_list)); |
03f3c1c1 | 1523 | |
03f3c1c1 | 1524 | } |
6942698d | 1525 | } else { |
03f3c1c1 CS |
1526 | list_delete_all_node(o_path->nh_list); |
1527 | ospf6_copy_nexthops(o_path->nh_list, | |
1528 | route->nh_list); | |
1529 | ||
6942698d | 1530 | } |
03f3c1c1 | 1531 | |
6942698d CS |
1532 | list_delete_all_node(old_route->nh_list); |
1533 | ||
1534 | for (ALL_LIST_ELEMENTS_RO(old_route->paths, anode, | |
1535 | o_path)) { | |
1536 | ls_entry = ospf6_route_lookup( | |
1537 | &o_path->ls_prefix, | |
1538 | oa->spf_table); | |
1539 | if (ls_entry == NULL) { | |
1540 | if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) | |
1541 | zlog_debug("%s: ls_prfix %s ls_entry not found.", | |
1542 | __PRETTY_FUNCTION__, | |
1543 | buf); | |
1544 | continue; | |
03f3c1c1 | 1545 | } |
6942698d CS |
1546 | lsa = ospf6_lsdb_lookup(o_path->origin.type, |
1547 | o_path->origin.id, | |
1548 | o_path->origin.adv_router, | |
1549 | oa->lsdb); | |
1550 | if (lsa == NULL) { | |
1551 | if (IS_OSPF6_DEBUG_EXAMIN( | |
1552 | INTRA_PREFIX)) { | |
1553 | struct prefix adv_prefix; | |
03f3c1c1 | 1554 | |
6942698d CS |
1555 | ospf6_linkstate_prefix( |
1556 | o_path->origin.adv_router, | |
1557 | o_path->origin.id, &adv_prefix); | |
1558 | prefix2str(&adv_prefix, buf, | |
1559 | sizeof(buf)); | |
1560 | zlog_debug("%s: adv_router %s lsa not found", | |
1561 | __PRETTY_FUNCTION__, | |
1562 | buf); | |
1563 | } | |
1564 | continue; | |
1565 | } | |
1566 | intra_prefix_lsa = | |
1567 | (struct ospf6_intra_prefix_lsa *) | |
1568 | OSPF6_LSA_HEADER_END(lsa->header); | |
1569 | ||
1570 | if (intra_prefix_lsa->ref_adv_router | |
1571 | == oa->ospf6->router_id) { | |
1572 | ifp = if_lookup_prefix( | |
1573 | &old_route->prefix, | |
1574 | VRF_DEFAULT); | |
1575 | if (ifp) | |
1576 | ospf6_route_add_nexthop( | |
1577 | old_route, | |
1578 | ifp->ifindex, | |
1579 | NULL); | |
1580 | } else { | |
1581 | ospf6_route_merge_nexthops(old_route, | |
1582 | ls_entry); | |
1583 | } | |
03f3c1c1 | 1584 | } |
6942698d CS |
1585 | |
1586 | if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) { | |
1587 | prefix2str(&route->prefix, buf, sizeof(buf)); | |
1588 | zlog_debug("%s: route %s %p with final effective paths %u nh%u", | |
1589 | __PRETTY_FUNCTION__, buf, | |
1590 | (void *)old_route, | |
1591 | old_route->paths ? | |
1592 | listcount(old_route->paths) : 0, | |
1593 | listcount(old_route->nh_list)); | |
1594 | } | |
1595 | ||
1596 | /* used in intra_route_calculation() to add to | |
1597 | * global ospf6 route table. | |
1598 | */ | |
1599 | UNSET_FLAG(old_route->flag, OSPF6_ROUTE_REMOVE); | |
1600 | SET_FLAG(old_route->flag, OSPF6_ROUTE_ADD); | |
1601 | /* Update ospf6 route table and RIB/FIB */ | |
1602 | if (oa->route_table->hook_add) | |
1603 | (*oa->route_table->hook_add)(old_route); | |
03f3c1c1 CS |
1604 | /* Delete the new route its info added to existing |
1605 | * route. | |
1606 | */ | |
1607 | ospf6_route_delete(route); | |
1608 | ||
1609 | break; | |
1610 | } | |
1611 | } | |
1612 | ||
1613 | if (!route_found) { | |
1614 | /* Add new route to existing node in ospf6 route table. */ | |
1615 | ospf6_route_add(route, oa->route_table); | |
1616 | } | |
1617 | } | |
1618 | ||
d62a17ae | 1619 | void ospf6_intra_prefix_lsa_add(struct ospf6_lsa *lsa) |
508e53e2 | 1620 | { |
d62a17ae | 1621 | struct ospf6_area *oa; |
1622 | struct ospf6_intra_prefix_lsa *intra_prefix_lsa; | |
1623 | struct prefix ls_prefix; | |
03f3c1c1 | 1624 | struct ospf6_route *route, *ls_entry, *old; |
d62a17ae | 1625 | int prefix_num; |
1626 | struct ospf6_prefix *op; | |
1627 | char *start, *current, *end; | |
1628 | char buf[PREFIX2STR_BUFFER]; | |
1629 | struct interface *ifp; | |
1630 | int direct_connect = 0; | |
10efbdc2 | 1631 | struct ospf6_path *path; |
d62a17ae | 1632 | |
1633 | if (OSPF6_LSA_IS_MAXAGE(lsa)) | |
1634 | return; | |
1635 | ||
1636 | if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) | |
26e14616 | 1637 | zlog_debug("%s: LSA %s found", __PRETTY_FUNCTION__, lsa->name); |
d62a17ae | 1638 | |
1639 | oa = OSPF6_AREA(lsa->lsdb->data); | |
1640 | ||
1641 | intra_prefix_lsa = | |
1642 | (struct ospf6_intra_prefix_lsa *)OSPF6_LSA_HEADER_END( | |
1643 | lsa->header); | |
1644 | if (intra_prefix_lsa->ref_type == htons(OSPF6_LSTYPE_ROUTER)) | |
1645 | ospf6_linkstate_prefix(intra_prefix_lsa->ref_adv_router, | |
26e14616 | 1646 | intra_prefix_lsa->ref_id, &ls_prefix); |
d62a17ae | 1647 | else if (intra_prefix_lsa->ref_type == htons(OSPF6_LSTYPE_NETWORK)) |
1648 | ospf6_linkstate_prefix(intra_prefix_lsa->ref_adv_router, | |
1649 | intra_prefix_lsa->ref_id, &ls_prefix); | |
1650 | else { | |
1651 | if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) | |
1652 | zlog_debug("Unknown reference LS-type: %#hx", | |
1653 | ntohs(intra_prefix_lsa->ref_type)); | |
1654 | return; | |
1655 | } | |
1656 | ||
1657 | ls_entry = ospf6_route_lookup(&ls_prefix, oa->spf_table); | |
1658 | if (ls_entry == NULL) { | |
1659 | if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) { | |
1660 | ospf6_linkstate_prefix2str(&ls_prefix, buf, | |
1661 | sizeof(buf)); | |
1662 | zlog_debug("LS entry does not exist: %s", buf); | |
1663 | } | |
1664 | return; | |
1665 | } | |
1666 | ||
1667 | if (intra_prefix_lsa->ref_adv_router == oa->ospf6->router_id) { | |
1668 | /* the intra-prefix are directly connected */ | |
1669 | direct_connect = 1; | |
1670 | } | |
1671 | ||
1672 | prefix_num = ntohs(intra_prefix_lsa->prefix_num); | |
1673 | start = (caddr_t)intra_prefix_lsa | |
1674 | + sizeof(struct ospf6_intra_prefix_lsa); | |
1675 | end = OSPF6_LSA_END(lsa->header); | |
1676 | for (current = start; current < end; current += OSPF6_PREFIX_SIZE(op)) { | |
1677 | op = (struct ospf6_prefix *)current; | |
1678 | if (prefix_num == 0) | |
1679 | break; | |
1680 | if (end < current + OSPF6_PREFIX_SIZE(op)) | |
1681 | break; | |
1682 | ||
1683 | /* Appendix A.4.1.1 */ | |
1684 | if (CHECK_FLAG(op->prefix_options, OSPF6_PREFIX_OPTION_NU)) { | |
1685 | if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) { | |
1686 | ospf6_linkstate_prefix2str( | |
1687 | (struct prefix *)OSPF6_PREFIX_BODY(op), | |
1688 | buf, sizeof(buf)); | |
1689 | zlog_debug( | |
1690 | "%s: Skipping Prefix %s has NU option set", | |
1691 | __func__, buf); | |
1692 | } | |
1693 | continue; | |
1694 | } | |
1695 | ||
1696 | route = ospf6_route_create(); | |
1697 | ||
1698 | memset(&route->prefix, 0, sizeof(struct prefix)); | |
1699 | route->prefix.family = AF_INET6; | |
1700 | route->prefix.prefixlen = op->prefix_length; | |
1701 | ospf6_prefix_in6_addr(&route->prefix.u.prefix6, op); | |
1702 | ||
1703 | route->type = OSPF6_DEST_TYPE_NETWORK; | |
1704 | route->path.origin.type = lsa->header->type; | |
1705 | route->path.origin.id = lsa->header->id; | |
1706 | route->path.origin.adv_router = lsa->header->adv_router; | |
1707 | route->path.prefix_options = op->prefix_options; | |
1708 | route->path.area_id = oa->area_id; | |
1709 | route->path.type = OSPF6_PATH_TYPE_INTRA; | |
1710 | route->path.metric_type = 1; | |
1711 | route->path.cost = | |
1712 | ls_entry->path.cost + ntohs(op->prefix_metric); | |
6942698d CS |
1713 | memcpy(&route->path.ls_prefix, &ls_prefix, |
1714 | sizeof(struct prefix)); | |
d62a17ae | 1715 | if (direct_connect) { |
1716 | ifp = if_lookup_prefix(&route->prefix, VRF_DEFAULT); | |
1717 | if (ifp) | |
1718 | ospf6_route_add_nexthop(route, ifp->ifindex, | |
1719 | NULL); | |
1720 | } else { | |
1721 | ospf6_route_copy_nexthops(route, ls_entry); | |
1722 | } | |
1723 | ||
10efbdc2 CS |
1724 | path = ospf6_path_dup(&route->path); |
1725 | ospf6_copy_nexthops(path->nh_list, route->path.nh_list); | |
1726 | listnode_add_sort(route->paths, path); | |
1727 | ||
03f3c1c1 CS |
1728 | old = ospf6_route_lookup(&route->prefix, oa->route_table); |
1729 | if (old && (ospf6_route_cmp(route, old) == 0)) { | |
1730 | if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) { | |
1731 | prefix2str(&route->prefix, buf, sizeof(buf)); | |
6942698d CS |
1732 | zlog_debug("%s Update route: %s old cost %u new cost %u paths %u nh %u", |
1733 | __PRETTY_FUNCTION__, buf, | |
03f3c1c1 | 1734 | old->path.cost, route->path.cost, |
6942698d CS |
1735 | listcount(route->paths), |
1736 | listcount(route->nh_list)); | |
03f3c1c1 CS |
1737 | } |
1738 | ospf6_intra_prefix_route_ecmp_path(oa, old, route); | |
1739 | } else { | |
1740 | if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) { | |
1741 | prefix2str(&route->prefix, buf, sizeof(buf)); | |
6942698d CS |
1742 | zlog_debug("%s route %s add with cost %u paths %u nh %u", |
1743 | __PRETTY_FUNCTION__, buf, | |
1744 | route->path.cost, | |
1745 | listcount(route->paths), | |
1746 | listcount(route->nh_list)); | |
03f3c1c1 CS |
1747 | } |
1748 | ospf6_route_add(route, oa->route_table); | |
d62a17ae | 1749 | } |
d62a17ae | 1750 | prefix_num--; |
e68a6767 DD |
1751 | } |
1752 | ||
d62a17ae | 1753 | if (current != end && IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) |
1754 | zlog_debug("Trailing garbage ignored"); | |
718e3744 | 1755 | } |
1756 | ||
6942698d CS |
1757 | static void ospf6_intra_prefix_lsa_remove_update_route(struct ospf6_lsa *lsa, |
1758 | struct ospf6_area *oa, | |
1759 | struct ospf6_route *route) | |
1760 | { | |
1761 | struct listnode *anode, *anext; | |
1762 | struct listnode *nnode, *rnode, *rnext; | |
1763 | struct ospf6_nexthop *nh, *rnh; | |
1764 | struct ospf6_path *o_path; | |
1765 | bool nh_updated = false; | |
1766 | char buf[PREFIX2STR_BUFFER]; | |
1767 | ||
1768 | /* Iterate all paths of route to find maching | |
1769 | * with LSA remove info. | |
1770 | * If route->path is same, replace | |
1771 | * from paths list. | |
1772 | */ | |
1773 | for (ALL_LIST_ELEMENTS(route->paths, anode, anext, o_path)) { | |
1774 | if ((o_path->origin.type != lsa->header->type) || | |
1775 | (o_path->origin.adv_router != lsa->header->adv_router) || | |
1776 | (o_path->origin.id != lsa->header->id)) | |
1777 | continue; | |
1778 | ||
1779 | if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) { | |
1780 | prefix2str(&route->prefix, buf, sizeof(buf)); | |
1781 | zlog_debug( | |
1782 | "%s: route %s path found with cost %u nh %u to remove.", | |
1783 | __PRETTY_FUNCTION__, buf, o_path->cost, | |
1784 | listcount(o_path->nh_list)); | |
1785 | } | |
1786 | ||
1787 | /* Remove found path's nh_list from | |
1788 | * the route's nh_list. | |
1789 | */ | |
1790 | for (ALL_LIST_ELEMENTS_RO(o_path->nh_list, nnode, nh)) { | |
1791 | for (ALL_LIST_ELEMENTS(route->nh_list, rnode, | |
1792 | rnext, rnh)) { | |
1793 | if (!ospf6_nexthop_is_same(rnh, nh)) | |
1794 | continue; | |
1795 | listnode_delete(route->nh_list, rnh); | |
1796 | ospf6_nexthop_delete(rnh); | |
1797 | } | |
1798 | } | |
1799 | /* Delete the path from route's | |
1800 | * path list | |
1801 | */ | |
1802 | listnode_delete(route->paths, o_path); | |
1803 | ospf6_path_free(o_path); | |
1804 | nh_updated = true; | |
1805 | break; | |
1806 | } | |
1807 | ||
1808 | if (nh_updated) { | |
1809 | /* Iterate all paths and merge nexthop, | |
1810 | * unlesss any of the nexthop similar to | |
1811 | * ones deleted as part of path deletion. | |
1812 | */ | |
1813 | for (ALL_LIST_ELEMENTS(route->paths, anode, anext, o_path)) | |
1814 | ospf6_merge_nexthops(route->nh_list, o_path->nh_list); | |
1815 | ||
1816 | ||
1817 | if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) { | |
1818 | prefix2str(&route->prefix, buf, sizeof(buf)); | |
1819 | zlog_debug("%s: route %s update paths %u nh %u", | |
1820 | __PRETTY_FUNCTION__, buf, | |
1821 | route->paths ? listcount(route->paths) : 0, | |
1822 | route->nh_list ? listcount(route->nh_list) | |
1823 | : 0); | |
1824 | } | |
1825 | ||
1826 | /* Update Global Route table and | |
1827 | * RIB/FIB with effective | |
1828 | * nh_list | |
1829 | */ | |
1830 | if (oa->route_table->hook_add) | |
1831 | (*oa->route_table->hook_add)(route); | |
1832 | ||
1833 | /* route's primary path is similar | |
1834 | * to LSA, replace route's primary | |
1835 | * path with route's paths list | |
1836 | * head. | |
1837 | */ | |
1838 | if ((route->path.origin.id == lsa->header->id) && | |
1839 | (route->path.origin.adv_router == | |
1840 | lsa->header->adv_router)) { | |
1841 | ospf6_intra_prefix_update_route_origin(route); | |
1842 | } | |
1843 | } | |
1844 | ||
1845 | } | |
1846 | ||
d62a17ae | 1847 | void ospf6_intra_prefix_lsa_remove(struct ospf6_lsa *lsa) |
718e3744 | 1848 | { |
d62a17ae | 1849 | struct ospf6_area *oa; |
1850 | struct ospf6_intra_prefix_lsa *intra_prefix_lsa; | |
1851 | struct prefix prefix; | |
6942698d | 1852 | struct ospf6_route *route, *nroute; |
d62a17ae | 1853 | int prefix_num; |
1854 | struct ospf6_prefix *op; | |
1855 | char *start, *current, *end; | |
1856 | char buf[PREFIX2STR_BUFFER]; | |
1857 | ||
1858 | if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) | |
03f3c1c1 CS |
1859 | zlog_debug("%s: %s disappearing", __PRETTY_FUNCTION__, |
1860 | lsa->name); | |
d62a17ae | 1861 | |
1862 | oa = OSPF6_AREA(lsa->lsdb->data); | |
1863 | ||
1864 | intra_prefix_lsa = | |
1865 | (struct ospf6_intra_prefix_lsa *)OSPF6_LSA_HEADER_END( | |
1866 | lsa->header); | |
1867 | ||
1868 | prefix_num = ntohs(intra_prefix_lsa->prefix_num); | |
1869 | start = (caddr_t)intra_prefix_lsa | |
1870 | + sizeof(struct ospf6_intra_prefix_lsa); | |
1871 | end = OSPF6_LSA_END(lsa->header); | |
1872 | for (current = start; current < end; current += OSPF6_PREFIX_SIZE(op)) { | |
1873 | op = (struct ospf6_prefix *)current; | |
1874 | if (prefix_num == 0) | |
1875 | break; | |
1876 | if (end < current + OSPF6_PREFIX_SIZE(op)) | |
1877 | break; | |
1878 | prefix_num--; | |
1879 | ||
1880 | memset(&prefix, 0, sizeof(struct prefix)); | |
1881 | prefix.family = AF_INET6; | |
1882 | prefix.prefixlen = op->prefix_length; | |
1883 | ospf6_prefix_in6_addr(&prefix.u.prefix6, op); | |
1884 | ||
1885 | route = ospf6_route_lookup(&prefix, oa->route_table); | |
1886 | if (route == NULL) | |
1887 | continue; | |
1888 | ||
1889 | for (ospf6_route_lock(route); | |
1890 | route && ospf6_route_is_prefix(&prefix, route); | |
1891 | route = nroute) { | |
1892 | nroute = ospf6_route_next(route); | |
1893 | if (route->type != OSPF6_DEST_TYPE_NETWORK) | |
1894 | continue; | |
1895 | if (route->path.area_id != oa->area_id) | |
1896 | continue; | |
1897 | if (route->path.type != OSPF6_PATH_TYPE_INTRA) | |
1898 | continue; | |
03f3c1c1 CS |
1899 | /* Route has multiple ECMP paths, remove matching |
1900 | * path. Update current route's effective nh list | |
1901 | * after removal of one of the path. | |
1902 | */ | |
1903 | if (listcount(route->paths) > 1) { | |
6942698d CS |
1904 | ospf6_intra_prefix_lsa_remove_update_route( |
1905 | lsa, oa, route); | |
03f3c1c1 CS |
1906 | } else { |
1907 | ||
1908 | if (route->path.origin.type != lsa->header->type | |
1909 | || route->path.origin.id != lsa->header->id | |
1910 | || route->path.origin.adv_router | |
1911 | != lsa->header->adv_router) | |
1912 | continue; | |
1913 | ||
1914 | if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) { | |
1915 | prefix2str(&route->prefix, buf, | |
1916 | sizeof(buf)); | |
6942698d CS |
1917 | zlog_debug("%s: route remove %s with path type %u cost %u paths %u nh %u", |
1918 | __PRETTY_FUNCTION__, buf, | |
1919 | route->path.type, | |
03f3c1c1 | 1920 | route->path.cost, |
6942698d | 1921 | listcount(route->paths), |
03f3c1c1 CS |
1922 | listcount(route->nh_list)); |
1923 | } | |
1924 | ospf6_route_remove(route, oa->route_table); | |
d62a17ae | 1925 | } |
d62a17ae | 1926 | } |
1927 | if (route) | |
1928 | ospf6_route_unlock(route); | |
1929 | } | |
1930 | ||
1931 | if (current != end && IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) | |
1932 | zlog_debug("Trailing garbage ignored"); | |
718e3744 | 1933 | } |
1934 | ||
d62a17ae | 1935 | void ospf6_intra_route_calculation(struct ospf6_area *oa) |
718e3744 | 1936 | { |
d62a17ae | 1937 | struct ospf6_route *route, *nroute; |
d7c0a89a | 1938 | uint16_t type; |
d62a17ae | 1939 | struct ospf6_lsa *lsa; |
1940 | void (*hook_add)(struct ospf6_route *) = NULL; | |
1941 | void (*hook_remove)(struct ospf6_route *) = NULL; | |
1942 | ||
1943 | if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) | |
1944 | zlog_debug("Re-examin intra-routes for area %s", oa->name); | |
1945 | ||
1946 | hook_add = oa->route_table->hook_add; | |
1947 | hook_remove = oa->route_table->hook_remove; | |
1948 | oa->route_table->hook_add = NULL; | |
1949 | oa->route_table->hook_remove = NULL; | |
1950 | ||
1951 | for (route = ospf6_route_head(oa->route_table); route; | |
1952 | route = ospf6_route_next(route)) | |
1953 | route->flag = OSPF6_ROUTE_REMOVE; | |
1954 | ||
1955 | type = htons(OSPF6_LSTYPE_INTRA_PREFIX); | |
1956 | for (ALL_LSDB_TYPED(oa->lsdb, type, lsa)) | |
1957 | ospf6_intra_prefix_lsa_add(lsa); | |
1958 | ||
1959 | oa->route_table->hook_add = hook_add; | |
1960 | oa->route_table->hook_remove = hook_remove; | |
1961 | ||
1962 | for (route = ospf6_route_head(oa->route_table); route; route = nroute) { | |
1963 | nroute = ospf6_route_next(route); | |
1964 | if (CHECK_FLAG(route->flag, OSPF6_ROUTE_REMOVE) | |
1965 | && CHECK_FLAG(route->flag, OSPF6_ROUTE_ADD)) { | |
1966 | UNSET_FLAG(route->flag, OSPF6_ROUTE_REMOVE); | |
1967 | UNSET_FLAG(route->flag, OSPF6_ROUTE_ADD); | |
1968 | } | |
1969 | ||
1970 | if (CHECK_FLAG(route->flag, OSPF6_ROUTE_REMOVE)) | |
1971 | ospf6_route_remove(route, oa->route_table); | |
1972 | else if (CHECK_FLAG(route->flag, OSPF6_ROUTE_ADD) | |
1973 | || CHECK_FLAG(route->flag, OSPF6_ROUTE_CHANGE)) { | |
1974 | if (hook_add) | |
1975 | (*hook_add)(route); | |
1976 | route->flag = 0; | |
1977 | } else { | |
1978 | /* Redo the summaries as things might have changed */ | |
1979 | ospf6_abr_originate_summary(route); | |
1980 | route->flag = 0; | |
1981 | } | |
ca1f4309 | 1982 | } |
508e53e2 | 1983 | |
d62a17ae | 1984 | if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) |
1985 | zlog_debug("Re-examin intra-routes for area %s: Done", | |
1986 | oa->name); | |
718e3744 | 1987 | } |
1988 | ||
d62a17ae | 1989 | static void ospf6_brouter_debug_print(struct ospf6_route *brouter) |
cf1ce250 | 1990 | { |
d7c0a89a | 1991 | uint32_t brouter_id; |
d62a17ae | 1992 | char brouter_name[16]; |
1993 | char area_name[16]; | |
1994 | char destination[64]; | |
68bfcc05 | 1995 | char installed[64], changed[64]; |
d62a17ae | 1996 | struct timeval now, res; |
1997 | char id[16], adv_router[16]; | |
1998 | char capa[16], options[16]; | |
1999 | ||
2000 | brouter_id = ADV_ROUTER_IN_PREFIX(&brouter->prefix); | |
2001 | inet_ntop(AF_INET, &brouter_id, brouter_name, sizeof(brouter_name)); | |
2002 | inet_ntop(AF_INET, &brouter->path.area_id, area_name, | |
2003 | sizeof(area_name)); | |
2004 | ospf6_linkstate_prefix2str(&brouter->prefix, destination, | |
2005 | sizeof(destination)); | |
2006 | ||
2007 | monotime(&now); | |
2008 | timersub(&now, &brouter->installed, &res); | |
2009 | timerstring(&res, installed, sizeof(installed)); | |
2010 | ||
2011 | monotime(&now); | |
2012 | timersub(&now, &brouter->changed, &res); | |
2013 | timerstring(&res, changed, sizeof(changed)); | |
2014 | ||
2015 | inet_ntop(AF_INET, &brouter->path.origin.id, id, sizeof(id)); | |
2016 | inet_ntop(AF_INET, &brouter->path.origin.adv_router, adv_router, | |
2017 | sizeof(adv_router)); | |
2018 | ||
2019 | ospf6_options_printbuf(brouter->path.options, options, sizeof(options)); | |
2020 | ospf6_capability_printbuf(brouter->path.router_bits, capa, | |
2021 | sizeof(capa)); | |
2022 | ||
2023 | zlog_info("Brouter: %s via area %s", brouter_name, area_name); | |
2024 | zlog_info(" memory: prev: %p this: %p next: %p parent rnode: %p", | |
2025 | (void *)brouter->prev, (void *)brouter, (void *)brouter->next, | |
2026 | (void *)brouter->rnode); | |
2027 | zlog_info(" type: %d prefix: %s installed: %s changed: %s", | |
2028 | brouter->type, destination, installed, changed); | |
2029 | zlog_info(" lock: %d flags: %s%s%s%s", brouter->lock, | |
2030 | (CHECK_FLAG(brouter->flag, OSPF6_ROUTE_BEST) ? "B" : "-"), | |
2031 | (CHECK_FLAG(brouter->flag, OSPF6_ROUTE_ADD) ? "A" : "-"), | |
2032 | (CHECK_FLAG(brouter->flag, OSPF6_ROUTE_REMOVE) ? "R" : "-"), | |
2033 | (CHECK_FLAG(brouter->flag, OSPF6_ROUTE_CHANGE) ? "C" : "-")); | |
2034 | zlog_info(" path type: %s ls-origin %s id: %s adv-router %s", | |
2035 | OSPF6_PATH_TYPE_NAME(brouter->path.type), | |
2036 | ospf6_lstype_name(brouter->path.origin.type), id, adv_router); | |
2037 | zlog_info(" options: %s router-bits: %s metric-type: %d metric: %d/%d", | |
2038 | options, capa, brouter->path.metric_type, brouter->path.cost, | |
2039 | brouter->path.u.cost_e2); | |
cf1ce250 PJ |
2040 | } |
2041 | ||
d62a17ae | 2042 | void ospf6_intra_brouter_calculation(struct ospf6_area *oa) |
718e3744 | 2043 | { |
d62a17ae | 2044 | struct ospf6_route *brouter, *nbrouter, *copy; |
2045 | void (*hook_add)(struct ospf6_route *) = NULL; | |
2046 | void (*hook_remove)(struct ospf6_route *) = NULL; | |
d7c0a89a | 2047 | uint32_t brouter_id; |
d62a17ae | 2048 | char brouter_name[16]; |
2049 | ||
2050 | if (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ID(oa->area_id)) | |
2051 | zlog_info("border-router calculation for area %s", oa->name); | |
2052 | ||
2053 | hook_add = oa->ospf6->brouter_table->hook_add; | |
2054 | hook_remove = oa->ospf6->brouter_table->hook_remove; | |
2055 | oa->ospf6->brouter_table->hook_add = NULL; | |
2056 | oa->ospf6->brouter_table->hook_remove = NULL; | |
2057 | ||
2058 | /* withdraw the previous router entries for the area */ | |
2059 | for (brouter = ospf6_route_head(oa->ospf6->brouter_table); brouter; | |
2060 | brouter = ospf6_route_next(brouter)) { | |
2061 | brouter_id = ADV_ROUTER_IN_PREFIX(&brouter->prefix); | |
2062 | inet_ntop(AF_INET, &brouter_id, brouter_name, | |
2063 | sizeof(brouter_name)); | |
c601fa3f | 2064 | |
d62a17ae | 2065 | if (brouter->path.area_id != oa->area_id) |
2066 | continue; | |
c601fa3f | 2067 | |
d62a17ae | 2068 | SET_FLAG(brouter->flag, OSPF6_ROUTE_REMOVE); |
2069 | ||
2070 | if (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ID(brouter_id) | |
2071 | || IS_OSPF6_DEBUG_ROUTE(MEMORY)) { | |
2072 | zlog_info("%p: mark as removing: area %s brouter %s", | |
2073 | (void *)brouter, oa->name, brouter_name); | |
2074 | ospf6_brouter_debug_print(brouter); | |
2075 | } | |
2076 | } | |
2077 | ||
2078 | for (brouter = ospf6_route_head(oa->spf_table); brouter; | |
2079 | brouter = ospf6_route_next(brouter)) { | |
2080 | brouter_id = ADV_ROUTER_IN_PREFIX(&brouter->prefix); | |
2081 | inet_ntop(AF_INET, &brouter_id, brouter_name, | |
2082 | sizeof(brouter_name)); | |
2083 | ||
2084 | if (brouter->type != OSPF6_DEST_TYPE_LINKSTATE) | |
2085 | continue; | |
c601fa3f | 2086 | |
d62a17ae | 2087 | if (ospf6_linkstate_prefix_id(&brouter->prefix) != htonl(0)) |
2088 | continue; | |
c601fa3f | 2089 | |
d62a17ae | 2090 | if (!CHECK_FLAG(brouter->path.router_bits, OSPF6_ROUTER_BIT_E) |
2091 | && !CHECK_FLAG(brouter->path.router_bits, | |
2092 | OSPF6_ROUTER_BIT_B)) | |
2093 | continue; | |
2094 | ||
2095 | if (!OSPF6_OPT_ISSET(brouter->path.options, OSPF6_OPT_V6) | |
2096 | || !OSPF6_OPT_ISSET(brouter->path.options, OSPF6_OPT_R)) | |
2097 | continue; | |
2098 | ||
2099 | copy = ospf6_route_copy(brouter); | |
2100 | copy->type = OSPF6_DEST_TYPE_ROUTER; | |
2101 | copy->path.area_id = oa->area_id; | |
2102 | ospf6_route_add(copy, oa->ospf6->brouter_table); | |
2103 | ||
2104 | if (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ID(brouter_id) | |
2105 | || IS_OSPF6_DEBUG_ROUTE(MEMORY)) { | |
2106 | zlog_info("%p: transfer: area %s brouter %s", | |
2107 | (void *)brouter, oa->name, brouter_name); | |
2108 | ospf6_brouter_debug_print(brouter); | |
2109 | } | |
2110 | } | |
2111 | ||
2112 | oa->ospf6->brouter_table->hook_add = hook_add; | |
2113 | oa->ospf6->brouter_table->hook_remove = hook_remove; | |
2114 | ||
2115 | for (brouter = ospf6_route_head(oa->ospf6->brouter_table); brouter; | |
2116 | brouter = nbrouter) { | |
33fb59c3 QY |
2117 | /* |
2118 | * brouter may have been "deleted" in the last loop iteration. | |
2119 | * If this is the case there is still 1 final refcount lock | |
2120 | * taken by ospf6_route_next, that will be released by the same | |
2121 | * call and result in deletion. To avoid heap UAF we must then | |
2122 | * skip processing the deleted route. | |
2123 | */ | |
2124 | if (brouter->lock == 1) { | |
2125 | nbrouter = ospf6_route_next(brouter); | |
2126 | continue; | |
2127 | } else { | |
2128 | nbrouter = ospf6_route_next(brouter); | |
2129 | } | |
2130 | ||
d62a17ae | 2131 | brouter_id = ADV_ROUTER_IN_PREFIX(&brouter->prefix); |
2132 | inet_ntop(AF_INET, &brouter_id, brouter_name, | |
2133 | sizeof(brouter_name)); | |
2134 | ||
2135 | if (brouter->path.area_id != oa->area_id) | |
2136 | continue; | |
2137 | ||
2138 | if (CHECK_FLAG(brouter->flag, OSPF6_ROUTE_WAS_REMOVED)) | |
2139 | continue; | |
2140 | ||
c601fa3f CS |
2141 | /* After iterating spf_table for all routers including |
2142 | * intra brouter, clear mark for remove flag for | |
2143 | * inter border router if its adv router present in | |
2144 | * SPF table. | |
2145 | */ | |
2146 | if (brouter->path.type == OSPF6_PATH_TYPE_INTER) { | |
2147 | struct prefix adv_prefix; | |
2148 | ||
2149 | ospf6_linkstate_prefix(brouter->path.origin.adv_router, | |
2150 | htonl(0), &adv_prefix); | |
2151 | ||
2152 | if (ospf6_route_lookup(&adv_prefix, oa->spf_table)) { | |
2153 | if (IS_OSPF6_DEBUG_BROUTER) { | |
2154 | zlog_debug("%s: keep inter brouter %s as adv router 0x%x found in spf", | |
2155 | __PRETTY_FUNCTION__, | |
2156 | brouter_name, | |
2157 | brouter->path.origin.adv_router); | |
2158 | ospf6_brouter_debug_print(brouter); | |
2159 | } | |
2160 | UNSET_FLAG(brouter->flag, OSPF6_ROUTE_REMOVE); | |
2161 | } | |
2162 | } | |
2163 | ||
d62a17ae | 2164 | if (CHECK_FLAG(brouter->flag, OSPF6_ROUTE_REMOVE) |
2165 | && CHECK_FLAG(brouter->flag, OSPF6_ROUTE_ADD)) { | |
2166 | UNSET_FLAG(brouter->flag, OSPF6_ROUTE_REMOVE); | |
2167 | UNSET_FLAG(brouter->flag, OSPF6_ROUTE_ADD); | |
2168 | } | |
2169 | ||
2170 | if (CHECK_FLAG(brouter->flag, OSPF6_ROUTE_REMOVE)) { | |
2171 | if (IS_OSPF6_DEBUG_BROUTER | |
2172 | || IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ID( | |
2173 | brouter_id) | |
2174 | || IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ID( | |
2175 | oa->area_id)) | |
2176 | zlog_info("brouter %s disappears via area %s", | |
2177 | brouter_name, oa->name); | |
2178 | ospf6_route_remove(brouter, oa->ospf6->brouter_table); | |
2179 | brouter = NULL; | |
2180 | } else if (CHECK_FLAG(brouter->flag, OSPF6_ROUTE_ADD) | |
2181 | || CHECK_FLAG(brouter->flag, OSPF6_ROUTE_CHANGE)) { | |
2182 | if (IS_OSPF6_DEBUG_BROUTER | |
2183 | || IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ID( | |
2184 | brouter_id) | |
2185 | || IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ID( | |
2186 | oa->area_id)) | |
2187 | zlog_info("brouter %s appears via area %s", | |
2188 | brouter_name, oa->name); | |
2189 | ||
2190 | /* newly added */ | |
2191 | if (hook_add) | |
2192 | (*hook_add)(brouter); | |
2193 | } else { | |
2194 | if (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ID( | |
2195 | brouter_id) | |
2196 | || IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ID( | |
2197 | oa->area_id)) | |
2198 | zlog_info("brouter %s still exists via area %s", | |
2199 | brouter_name, oa->name); | |
2200 | /* But re-originate summaries */ | |
2201 | ospf6_abr_originate_summary(brouter); | |
2202 | } | |
2203 | ||
2204 | if (brouter) { | |
2205 | UNSET_FLAG(brouter->flag, OSPF6_ROUTE_ADD); | |
2206 | UNSET_FLAG(brouter->flag, OSPF6_ROUTE_CHANGE); | |
2207 | } | |
2208 | } | |
2209 | ||
2210 | if (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ID(oa->area_id)) | |
2211 | zlog_info("border-router calculation for area %s: done", | |
2212 | oa->name); | |
718e3744 | 2213 | } |
2214 | ||
996c9314 LB |
2215 | struct ospf6_lsa_handler router_handler = {.lh_type = OSPF6_LSTYPE_ROUTER, |
2216 | .lh_name = "Router", | |
2217 | .lh_short_name = "Rtr", | |
2218 | .lh_show = ospf6_router_lsa_show, | |
2219 | .lh_get_prefix_str = | |
2220 | ospf6_router_lsa_get_nbr_id, | |
2221 | .lh_debug = 0}; | |
2222 | ||
2223 | struct ospf6_lsa_handler network_handler = {.lh_type = OSPF6_LSTYPE_NETWORK, | |
2224 | .lh_name = "Network", | |
2225 | .lh_short_name = "Net", | |
2226 | .lh_show = ospf6_network_lsa_show, | |
2227 | .lh_get_prefix_str = | |
2228 | ospf6_network_lsa_get_ar_id, | |
2229 | .lh_debug = 0}; | |
2230 | ||
2231 | struct ospf6_lsa_handler link_handler = {.lh_type = OSPF6_LSTYPE_LINK, | |
2232 | .lh_name = "Link", | |
2233 | .lh_short_name = "Lnk", | |
2234 | .lh_show = ospf6_link_lsa_show, | |
2235 | .lh_get_prefix_str = | |
2236 | ospf6_link_lsa_get_prefix_str, | |
2237 | .lh_debug = 0}; | |
d62a17ae | 2238 | |
2239 | struct ospf6_lsa_handler intra_prefix_handler = { | |
3981b5c7 VJ |
2240 | .lh_type = OSPF6_LSTYPE_INTRA_PREFIX, |
2241 | .lh_name = "Intra-Prefix", | |
2242 | .lh_short_name = "INP", | |
2243 | .lh_show = ospf6_intra_prefix_lsa_show, | |
2244 | .lh_get_prefix_str = ospf6_intra_prefix_lsa_get_prefix_str, | |
996c9314 | 2245 | .lh_debug = 0}; |
d62a17ae | 2246 | |
2247 | void ospf6_intra_init(void) | |
718e3744 | 2248 | { |
d62a17ae | 2249 | ospf6_install_lsa_handler(&router_handler); |
2250 | ospf6_install_lsa_handler(&network_handler); | |
2251 | ospf6_install_lsa_handler(&link_handler); | |
2252 | ospf6_install_lsa_handler(&intra_prefix_handler); | |
718e3744 | 2253 | } |
2254 | ||
cb4b8845 PJ |
2255 | DEFUN (debug_ospf6_brouter, |
2256 | debug_ospf6_brouter_cmd, | |
2257 | "debug ospf6 border-routers", | |
2258 | DEBUG_STR | |
2259 | OSPF6_STR | |
2260 | "Debug border router\n" | |
2261 | ) | |
2262 | { | |
d62a17ae | 2263 | OSPF6_DEBUG_BROUTER_ON(); |
2264 | return CMD_SUCCESS; | |
cb4b8845 PJ |
2265 | } |
2266 | ||
2267 | DEFUN (no_debug_ospf6_brouter, | |
2268 | no_debug_ospf6_brouter_cmd, | |
2269 | "no debug ospf6 border-routers", | |
2270 | NO_STR | |
2271 | DEBUG_STR | |
2272 | OSPF6_STR | |
2273 | "Debug border router\n" | |
2274 | ) | |
2275 | { | |
d62a17ae | 2276 | OSPF6_DEBUG_BROUTER_OFF(); |
2277 | return CMD_SUCCESS; | |
cb4b8845 PJ |
2278 | } |
2279 | ||
2280 | DEFUN (debug_ospf6_brouter_router, | |
2281 | debug_ospf6_brouter_router_cmd, | |
2282 | "debug ospf6 border-routers router-id A.B.C.D", | |
2283 | DEBUG_STR | |
2284 | OSPF6_STR | |
2285 | "Debug border router\n" | |
2286 | "Debug specific border router\n" | |
2287 | "Specify border-router's router-id\n" | |
2288 | ) | |
2289 | { | |
d62a17ae | 2290 | int idx_ipv4 = 4; |
d7c0a89a | 2291 | uint32_t router_id; |
d62a17ae | 2292 | inet_pton(AF_INET, argv[idx_ipv4]->arg, &router_id); |
2293 | OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ON(router_id); | |
2294 | return CMD_SUCCESS; | |
cb4b8845 PJ |
2295 | } |
2296 | ||
2297 | DEFUN (no_debug_ospf6_brouter_router, | |
2298 | no_debug_ospf6_brouter_router_cmd, | |
2299 | "no debug ospf6 border-routers router-id", | |
2300 | NO_STR | |
2301 | DEBUG_STR | |
2302 | OSPF6_STR | |
2303 | "Debug border router\n" | |
2304 | "Debug specific border router\n" | |
2305 | ) | |
2306 | { | |
d62a17ae | 2307 | OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_OFF(); |
2308 | return CMD_SUCCESS; | |
cb4b8845 PJ |
2309 | } |
2310 | ||
2311 | DEFUN (debug_ospf6_brouter_area, | |
2312 | debug_ospf6_brouter_area_cmd, | |
2313 | "debug ospf6 border-routers area-id A.B.C.D", | |
2314 | DEBUG_STR | |
2315 | OSPF6_STR | |
2316 | "Debug border router\n" | |
2317 | "Debug border routers in specific Area\n" | |
2318 | "Specify Area-ID\n" | |
2319 | ) | |
2320 | { | |
d62a17ae | 2321 | int idx_ipv4 = 4; |
d7c0a89a | 2322 | uint32_t area_id; |
d62a17ae | 2323 | inet_pton(AF_INET, argv[idx_ipv4]->arg, &area_id); |
2324 | OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ON(area_id); | |
2325 | return CMD_SUCCESS; | |
cb4b8845 PJ |
2326 | } |
2327 | ||
2328 | DEFUN (no_debug_ospf6_brouter_area, | |
2329 | no_debug_ospf6_brouter_area_cmd, | |
2330 | "no debug ospf6 border-routers area-id", | |
2331 | NO_STR | |
2332 | DEBUG_STR | |
2333 | OSPF6_STR | |
2334 | "Debug border router\n" | |
2335 | "Debug border routers in specific Area\n" | |
2336 | ) | |
2337 | { | |
d62a17ae | 2338 | OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_OFF(); |
2339 | return CMD_SUCCESS; | |
cb4b8845 PJ |
2340 | } |
2341 | ||
d62a17ae | 2342 | int config_write_ospf6_debug_brouter(struct vty *vty) |
cb4b8845 | 2343 | { |
d62a17ae | 2344 | char buf[16]; |
2345 | if (IS_OSPF6_DEBUG_BROUTER) | |
2346 | vty_out(vty, "debug ospf6 border-routers\n"); | |
2347 | if (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER) { | |
2348 | inet_ntop(AF_INET, &conf_debug_ospf6_brouter_specific_router_id, | |
2349 | buf, sizeof(buf)); | |
2350 | vty_out(vty, "debug ospf6 border-routers router-id %s\n", buf); | |
2351 | } | |
2352 | if (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA) { | |
2353 | inet_ntop(AF_INET, &conf_debug_ospf6_brouter_specific_area_id, | |
2354 | buf, sizeof(buf)); | |
2355 | vty_out(vty, "debug ospf6 border-routers area-id %s\n", buf); | |
2356 | } | |
2357 | return 0; | |
cb4b8845 PJ |
2358 | } |
2359 | ||
d62a17ae | 2360 | void install_element_ospf6_debug_brouter(void) |
cb4b8845 | 2361 | { |
d62a17ae | 2362 | install_element(ENABLE_NODE, &debug_ospf6_brouter_cmd); |
2363 | install_element(ENABLE_NODE, &debug_ospf6_brouter_router_cmd); | |
2364 | install_element(ENABLE_NODE, &debug_ospf6_brouter_area_cmd); | |
2365 | install_element(ENABLE_NODE, &no_debug_ospf6_brouter_cmd); | |
2366 | install_element(ENABLE_NODE, &no_debug_ospf6_brouter_router_cmd); | |
2367 | install_element(ENABLE_NODE, &no_debug_ospf6_brouter_area_cmd); | |
2368 | install_element(CONFIG_NODE, &debug_ospf6_brouter_cmd); | |
2369 | install_element(CONFIG_NODE, &debug_ospf6_brouter_router_cmd); | |
2370 | install_element(CONFIG_NODE, &debug_ospf6_brouter_area_cmd); | |
2371 | install_element(CONFIG_NODE, &no_debug_ospf6_brouter_cmd); | |
2372 | install_element(CONFIG_NODE, &no_debug_ospf6_brouter_router_cmd); | |
2373 | install_element(CONFIG_NODE, &no_debug_ospf6_brouter_area_cmd); | |
cb4b8845 | 2374 | } |