]> git.proxmox.com Git - mirror_frr.git/blob - ospf6d/ospf6_interface.c
Fixup of warnings in the code
[mirror_frr.git] / ospf6d / ospf6_interface.c
1 /*
2 * Copyright (C) 2003 Yasuhiro Ohara
3 *
4 * This file is part of GNU Zebra.
5 *
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #include <zebra.h>
23
24 #include "memory.h"
25 #include "if.h"
26 #include "log.h"
27 #include "command.h"
28 #include "thread.h"
29 #include "prefix.h"
30 #include "plist.h"
31 #include "zclient.h"
32 #include "bfd.h"
33
34 #include "ospf6_lsa.h"
35 #include "ospf6_lsdb.h"
36 #include "ospf6_network.h"
37 #include "ospf6_message.h"
38 #include "ospf6_route.h"
39 #include "ospf6_top.h"
40 #include "ospf6_area.h"
41 #include "ospf6_interface.h"
42 #include "ospf6_neighbor.h"
43 #include "ospf6_intra.h"
44 #include "ospf6_spf.h"
45 #include "ospf6d.h"
46 #include "ospf6_bfd.h"
47
48 unsigned char conf_debug_ospf6_interface = 0;
49
50 const char *ospf6_interface_state_str[] =
51 {
52 "None",
53 "Down",
54 "Loopback",
55 "Waiting",
56 "PointToPoint",
57 "DROther",
58 "BDR",
59 "DR",
60 NULL
61 };
62
63 struct ospf6_interface *
64 ospf6_interface_lookup_by_ifindex (int ifindex)
65 {
66 struct ospf6_interface *oi;
67 struct interface *ifp;
68
69 ifp = if_lookup_by_index (ifindex);
70 if (ifp == NULL)
71 return (struct ospf6_interface *) NULL;
72
73 oi = (struct ospf6_interface *) ifp->info;
74 return oi;
75 }
76
77 /* schedule routing table recalculation */
78 static void
79 ospf6_interface_lsdb_hook (struct ospf6_lsa *lsa, unsigned int reason)
80 {
81 struct ospf6_interface *oi;
82
83 if (lsa == NULL)
84 return;
85
86 oi = lsa->lsdb->data;
87 switch (ntohs (lsa->header->type))
88 {
89 case OSPF6_LSTYPE_LINK:
90 if (oi->state == OSPF6_INTERFACE_DR)
91 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
92 ospf6_spf_schedule (oi->area->ospf6, reason);
93 break;
94
95 default:
96 break;
97 }
98 }
99
100 static void
101 ospf6_interface_lsdb_hook_add (struct ospf6_lsa *lsa)
102 {
103 ospf6_interface_lsdb_hook(lsa, ospf6_lsadd_to_spf_reason(lsa));
104 }
105
106 static void
107 ospf6_interface_lsdb_hook_remove (struct ospf6_lsa *lsa)
108 {
109 ospf6_interface_lsdb_hook(lsa, ospf6_lsremove_to_spf_reason(lsa));
110 }
111
112 static u_char
113 ospf6_default_iftype(struct interface *ifp)
114 {
115 if (if_is_pointopoint (ifp))
116 return OSPF_IFTYPE_POINTOPOINT;
117 else if (if_is_loopback (ifp))
118 return OSPF_IFTYPE_LOOPBACK;
119 else
120 return OSPF_IFTYPE_BROADCAST;
121 }
122
123 static u_int32_t
124 ospf6_interface_get_cost (struct ospf6_interface *oi)
125 {
126 /* If all else fails, use default OSPF cost */
127 u_int32_t cost;
128 u_int32_t bw, refbw;
129
130 bw = oi->interface->bandwidth ? oi->interface->bandwidth : OSPF6_INTERFACE_BANDWIDTH;
131 refbw = ospf6 ? ospf6->ref_bandwidth : OSPF6_REFERENCE_BANDWIDTH;
132
133 /* A specifed ip ospf cost overrides a calculated one. */
134 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST))
135 cost = oi->cost;
136 else
137 {
138 cost = (u_int32_t) ((double)refbw / (double)bw + (double)0.5);
139 if (cost < 1) cost = 1;
140 else if (cost > UINT32_MAX) cost = UINT32_MAX;
141 }
142
143 return cost;
144 }
145
146 static void
147 ospf6_interface_recalculate_cost (struct ospf6_interface *oi)
148 {
149 u_int32_t newcost;
150
151 newcost = ospf6_interface_get_cost (oi);
152 if (newcost == oi->cost) return;
153 oi->cost = newcost;
154
155 /* update cost held in route_connected list in ospf6_interface */
156 ospf6_interface_connected_route_update (oi->interface);
157
158 /* execute LSA hooks */
159 if (oi->area)
160 {
161 OSPF6_LINK_LSA_SCHEDULE (oi);
162 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
163 OSPF6_NETWORK_LSA_SCHEDULE (oi);
164 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
165 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
166 }
167 }
168
169 /* Create new ospf6 interface structure */
170 struct ospf6_interface *
171 ospf6_interface_create (struct interface *ifp)
172 {
173 struct ospf6_interface *oi;
174 unsigned int iobuflen;
175
176 oi = (struct ospf6_interface *)
177 XCALLOC (MTYPE_OSPF6_IF, sizeof (struct ospf6_interface));
178
179 if (!oi)
180 {
181 zlog_err ("Can't malloc ospf6_interface for ifindex %d", ifp->ifindex);
182 return (struct ospf6_interface *) NULL;
183 }
184
185 oi->area = (struct ospf6_area *) NULL;
186 oi->neighbor_list = list_new ();
187 oi->neighbor_list->cmp = ospf6_neighbor_cmp;
188 oi->linklocal_addr = (struct in6_addr *) NULL;
189 oi->instance_id = OSPF6_INTERFACE_INSTANCE_ID;
190 oi->transdelay = OSPF6_INTERFACE_TRANSDELAY;
191 oi->priority = OSPF6_INTERFACE_PRIORITY;
192
193 oi->hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
194 oi->dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
195 oi->rxmt_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
196 oi->type = ospf6_default_iftype (ifp);
197 oi->state = OSPF6_INTERFACE_DOWN;
198 oi->flag = 0;
199 oi->mtu_ignore = 0;
200
201 /* Try to adjust I/O buffer size with IfMtu */
202 oi->ifmtu = ifp->mtu6;
203 iobuflen = ospf6_iobuf_size (ifp->mtu6);
204 if (oi->ifmtu > iobuflen)
205 {
206 if (IS_OSPF6_DEBUG_INTERFACE)
207 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
208 ifp->name, iobuflen);
209 oi->ifmtu = iobuflen;
210 }
211
212 oi->lsupdate_list = ospf6_lsdb_create (oi);
213 oi->lsack_list = ospf6_lsdb_create (oi);
214 oi->lsdb = ospf6_lsdb_create (oi);
215 oi->lsdb->hook_add = ospf6_interface_lsdb_hook_add;
216 oi->lsdb->hook_remove = ospf6_interface_lsdb_hook_remove;
217 oi->lsdb_self = ospf6_lsdb_create (oi);
218
219 oi->route_connected = OSPF6_ROUTE_TABLE_CREATE (INTERFACE, CONNECTED_ROUTES);
220 oi->route_connected->scope = oi;
221
222 /* link both */
223 oi->interface = ifp;
224 ifp->info = oi;
225
226 /* Compute cost. */
227 oi->cost = ospf6_interface_get_cost(oi);
228
229 return oi;
230 }
231
232 void
233 ospf6_interface_delete (struct ospf6_interface *oi)
234 {
235 struct listnode *node, *nnode;
236 struct ospf6_neighbor *on;
237
238 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
239 ospf6_neighbor_delete (on);
240
241 list_delete (oi->neighbor_list);
242
243 THREAD_OFF (oi->thread_send_hello);
244 THREAD_OFF (oi->thread_send_lsupdate);
245 THREAD_OFF (oi->thread_send_lsack);
246
247 ospf6_lsdb_remove_all (oi->lsdb);
248 ospf6_lsdb_remove_all (oi->lsupdate_list);
249 ospf6_lsdb_remove_all (oi->lsack_list);
250
251 ospf6_lsdb_delete (oi->lsdb);
252 ospf6_lsdb_delete (oi->lsdb_self);
253
254 ospf6_lsdb_delete (oi->lsupdate_list);
255 ospf6_lsdb_delete (oi->lsack_list);
256
257 ospf6_route_table_delete (oi->route_connected);
258
259 /* cut link */
260 oi->interface->info = NULL;
261
262 /* plist_name */
263 if (oi->plist_name)
264 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
265
266 bfd_info_free(&(oi->bfd_info));
267
268 XFREE (MTYPE_OSPF6_IF, oi);
269 }
270
271 void
272 ospf6_interface_enable (struct ospf6_interface *oi)
273 {
274 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
275 ospf6_interface_state_update (oi->interface);
276 }
277
278 void
279 ospf6_interface_disable (struct ospf6_interface *oi)
280 {
281 SET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
282
283 thread_execute (master, interface_down, oi, 0);
284
285 ospf6_lsdb_remove_all (oi->lsdb);
286 ospf6_lsdb_remove_all (oi->lsdb_self);
287 ospf6_lsdb_remove_all (oi->lsupdate_list);
288 ospf6_lsdb_remove_all (oi->lsack_list);
289
290 THREAD_OFF (oi->thread_send_hello);
291 THREAD_OFF (oi->thread_send_lsupdate);
292 THREAD_OFF (oi->thread_send_lsack);
293
294 THREAD_OFF (oi->thread_network_lsa);
295 THREAD_OFF (oi->thread_link_lsa);
296 THREAD_OFF (oi->thread_intra_prefix_lsa);
297 }
298
299 static struct in6_addr *
300 ospf6_interface_get_linklocal_address (struct interface *ifp)
301 {
302 struct listnode *n;
303 struct connected *c;
304 struct in6_addr *l = (struct in6_addr *) NULL;
305
306 /* for each connected address */
307 for (ALL_LIST_ELEMENTS_RO (ifp->connected, n, c))
308 {
309 /* if family not AF_INET6, ignore */
310 if (c->address->family != AF_INET6)
311 continue;
312
313 /* linklocal scope check */
314 if (IN6_IS_ADDR_LINKLOCAL (&c->address->u.prefix6))
315 l = &c->address->u.prefix6;
316 }
317 return l;
318 }
319
320 void
321 ospf6_interface_if_add (struct interface *ifp)
322 {
323 struct ospf6_interface *oi;
324 unsigned int iobuflen;
325
326 oi = (struct ospf6_interface *) ifp->info;
327 if (oi == NULL)
328 return;
329
330 /* Try to adjust I/O buffer size with IfMtu */
331 if (oi->ifmtu == 0)
332 oi->ifmtu = ifp->mtu6;
333 iobuflen = ospf6_iobuf_size (ifp->mtu6);
334 if (oi->ifmtu > iobuflen)
335 {
336 if (IS_OSPF6_DEBUG_INTERFACE)
337 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
338 ifp->name, iobuflen);
339 oi->ifmtu = iobuflen;
340 }
341
342 /* interface start */
343 ospf6_interface_state_update(oi->interface);
344 }
345
346 void
347 ospf6_interface_if_del (struct interface *ifp)
348 {
349 struct ospf6_interface *oi;
350
351 oi = (struct ospf6_interface *) ifp->info;
352 if (oi == NULL)
353 return;
354
355 /* interface stop */
356 if (oi->area)
357 thread_execute (master, interface_down, oi, 0);
358
359 listnode_delete (oi->area->if_list, oi);
360 oi->area = (struct ospf6_area *) NULL;
361
362 /* cut link */
363 oi->interface = NULL;
364 ifp->info = NULL;
365
366 ospf6_interface_delete (oi);
367 }
368
369 void
370 ospf6_interface_state_update (struct interface *ifp)
371 {
372 struct ospf6_interface *oi;
373
374 oi = (struct ospf6_interface *) ifp->info;
375 if (oi == NULL)
376 return;
377 if (oi->area == NULL)
378 return;
379 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE))
380 return;
381
382 if (if_is_operative (ifp)
383 && (ospf6_interface_get_linklocal_address(oi->interface)
384 || if_is_loopback(oi->interface)))
385 thread_add_event (master, interface_up, oi, 0);
386 else
387 thread_add_event (master, interface_down, oi, 0);
388
389 return;
390 }
391
392 void
393 ospf6_interface_connected_route_update (struct interface *ifp)
394 {
395 struct ospf6_interface *oi;
396 struct ospf6_route *route;
397 struct connected *c;
398 struct listnode *node, *nnode;
399 struct in6_addr nh_addr;
400
401 oi = (struct ospf6_interface *) ifp->info;
402 if (oi == NULL)
403 return;
404
405 /* reset linklocal pointer */
406 oi->linklocal_addr = ospf6_interface_get_linklocal_address (ifp);
407
408 /* if area is null, do not make connected-route list */
409 if (oi->area == NULL)
410 return;
411
412 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE))
413 return;
414
415 /* update "route to advertise" interface route table */
416 ospf6_route_remove_all (oi->route_connected);
417
418 for (ALL_LIST_ELEMENTS (oi->interface->connected, node, nnode, c))
419 {
420 if (c->address->family != AF_INET6)
421 continue;
422
423 CONTINUE_IF_ADDRESS_LINKLOCAL (IS_OSPF6_DEBUG_INTERFACE, c->address);
424 CONTINUE_IF_ADDRESS_UNSPECIFIED (IS_OSPF6_DEBUG_INTERFACE, c->address);
425 CONTINUE_IF_ADDRESS_LOOPBACK (IS_OSPF6_DEBUG_INTERFACE, c->address);
426 CONTINUE_IF_ADDRESS_V4COMPAT (IS_OSPF6_DEBUG_INTERFACE, c->address);
427 CONTINUE_IF_ADDRESS_V4MAPPED (IS_OSPF6_DEBUG_INTERFACE, c->address);
428
429 /* apply filter */
430 if (oi->plist_name)
431 {
432 struct prefix_list *plist;
433 enum prefix_list_type ret;
434 char buf[128];
435
436 prefix2str (c->address, buf, sizeof (buf));
437 plist = prefix_list_lookup (AFI_IP6, oi->plist_name);
438 ret = prefix_list_apply (plist, (void *) c->address);
439 if (ret == PREFIX_DENY)
440 {
441 if (IS_OSPF6_DEBUG_INTERFACE)
442 zlog_debug ("%s on %s filtered by prefix-list %s ",
443 buf, oi->interface->name, oi->plist_name);
444 continue;
445 }
446 }
447
448 route = ospf6_route_create ();
449 memcpy (&route->prefix, c->address, sizeof (struct prefix));
450 apply_mask (&route->prefix);
451 route->type = OSPF6_DEST_TYPE_NETWORK;
452 route->path.area_id = oi->area->area_id;
453 route->path.type = OSPF6_PATH_TYPE_INTRA;
454 route->path.cost = oi->cost;
455 inet_pton (AF_INET6, "::1", &nh_addr);
456 ospf6_route_add_nexthop (route, oi->interface->ifindex, &nh_addr);
457 ospf6_route_add (route, oi->route_connected);
458 }
459
460 /* create new Link-LSA */
461 OSPF6_LINK_LSA_SCHEDULE (oi);
462 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
463 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
464 }
465
466 static void
467 ospf6_interface_state_change (u_char next_state, struct ospf6_interface *oi)
468 {
469 u_char prev_state;
470
471 prev_state = oi->state;
472 oi->state = next_state;
473
474 if (prev_state == next_state)
475 return;
476
477 /* log */
478 if (IS_OSPF6_DEBUG_INTERFACE)
479 {
480 zlog_debug ("Interface state change %s: %s -> %s", oi->interface->name,
481 ospf6_interface_state_str[prev_state],
482 ospf6_interface_state_str[next_state]);
483 }
484 oi->state_change++;
485
486 if ((prev_state == OSPF6_INTERFACE_DR ||
487 prev_state == OSPF6_INTERFACE_BDR) &&
488 (next_state != OSPF6_INTERFACE_DR &&
489 next_state != OSPF6_INTERFACE_BDR))
490 ospf6_sso (oi->interface->ifindex, &alldrouters6, IPV6_LEAVE_GROUP);
491
492 if ((prev_state != OSPF6_INTERFACE_DR &&
493 prev_state != OSPF6_INTERFACE_BDR) &&
494 (next_state == OSPF6_INTERFACE_DR ||
495 next_state == OSPF6_INTERFACE_BDR))
496 ospf6_sso (oi->interface->ifindex, &alldrouters6, IPV6_JOIN_GROUP);
497
498 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
499 if (next_state == OSPF6_INTERFACE_DOWN)
500 {
501 OSPF6_NETWORK_LSA_EXECUTE (oi);
502 OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT (oi);
503 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
504 }
505 else if (prev_state == OSPF6_INTERFACE_DR ||
506 next_state == OSPF6_INTERFACE_DR)
507 {
508 OSPF6_NETWORK_LSA_SCHEDULE (oi);
509 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
510 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
511 }
512
513 #ifdef HAVE_SNMP
514 /* Terminal state or regression */
515 if ((next_state == OSPF6_INTERFACE_POINTTOPOINT) ||
516 (next_state == OSPF6_INTERFACE_DROTHER) ||
517 (next_state == OSPF6_INTERFACE_BDR) ||
518 (next_state == OSPF6_INTERFACE_DR) ||
519 (next_state < prev_state))
520 ospf6TrapIfStateChange (oi);
521 #endif
522
523 }
524
525
526 /* DR Election, RFC2328 section 9.4 */
527
528 #define IS_ELIGIBLE(n) \
529 ((n)->state >= OSPF6_NEIGHBOR_TWOWAY && (n)->priority != 0)
530
531 static struct ospf6_neighbor *
532 better_bdrouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
533 {
534 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id) &&
535 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id))
536 return NULL;
537 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id)
538 return b;
539 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id)
540 return a;
541
542 if (a->bdrouter == a->router_id && b->bdrouter != b->router_id)
543 return a;
544 if (a->bdrouter != a->router_id && b->bdrouter == b->router_id)
545 return b;
546
547 if (a->priority > b->priority)
548 return a;
549 if (a->priority < b->priority)
550 return b;
551
552 if (ntohl (a->router_id) > ntohl (b->router_id))
553 return a;
554 if (ntohl (a->router_id) < ntohl (b->router_id))
555 return b;
556
557 zlog_warn ("Router-ID duplicate ?");
558 return a;
559 }
560
561 static struct ospf6_neighbor *
562 better_drouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
563 {
564 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id) &&
565 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id))
566 return NULL;
567 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id)
568 return b;
569 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id)
570 return a;
571
572 if (a->drouter == a->router_id && b->drouter != b->router_id)
573 return a;
574 if (a->drouter != a->router_id && b->drouter == b->router_id)
575 return b;
576
577 if (a->priority > b->priority)
578 return a;
579 if (a->priority < b->priority)
580 return b;
581
582 if (ntohl (a->router_id) > ntohl (b->router_id))
583 return a;
584 if (ntohl (a->router_id) < ntohl (b->router_id))
585 return b;
586
587 zlog_warn ("Router-ID duplicate ?");
588 return a;
589 }
590
591 static u_char
592 dr_election (struct ospf6_interface *oi)
593 {
594 struct listnode *node, *nnode;
595 struct ospf6_neighbor *on, *drouter, *bdrouter, myself;
596 struct ospf6_neighbor *best_drouter, *best_bdrouter;
597 u_char next_state = 0;
598
599 drouter = bdrouter = NULL;
600 best_drouter = best_bdrouter = NULL;
601
602 /* pseudo neighbor myself, including noting current DR/BDR (1) */
603 memset (&myself, 0, sizeof (myself));
604 inet_ntop (AF_INET, &oi->area->ospf6->router_id, myself.name,
605 sizeof (myself.name));
606 myself.state = OSPF6_NEIGHBOR_TWOWAY;
607 myself.drouter = oi->drouter;
608 myself.bdrouter = oi->bdrouter;
609 myself.priority = oi->priority;
610 myself.router_id = oi->area->ospf6->router_id;
611
612 /* Electing BDR (2) */
613 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
614 bdrouter = better_bdrouter (bdrouter, on);
615
616 best_bdrouter = bdrouter;
617 bdrouter = better_bdrouter (best_bdrouter, &myself);
618
619 /* Electing DR (3) */
620 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
621 drouter = better_drouter (drouter, on);
622
623 best_drouter = drouter;
624 drouter = better_drouter (best_drouter, &myself);
625 if (drouter == NULL)
626 drouter = bdrouter;
627
628 /* the router itself is newly/no longer DR/BDR (4) */
629 if ((drouter == &myself && myself.drouter != myself.router_id) ||
630 (drouter != &myself && myself.drouter == myself.router_id) ||
631 (bdrouter == &myself && myself.bdrouter != myself.router_id) ||
632 (bdrouter != &myself && myself.bdrouter == myself.router_id))
633 {
634 myself.drouter = (drouter ? drouter->router_id : htonl (0));
635 myself.bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
636
637 /* compatible to Electing BDR (2) */
638 bdrouter = better_bdrouter (best_bdrouter, &myself);
639
640 /* compatible to Electing DR (3) */
641 drouter = better_drouter (best_drouter, &myself);
642 if (drouter == NULL)
643 drouter = bdrouter;
644 }
645
646 /* Set interface state accordingly (5) */
647 if (drouter && drouter == &myself)
648 next_state = OSPF6_INTERFACE_DR;
649 else if (bdrouter && bdrouter == &myself)
650 next_state = OSPF6_INTERFACE_BDR;
651 else
652 next_state = OSPF6_INTERFACE_DROTHER;
653
654 /* If NBMA, schedule Start for each neighbor having priority of 0 (6) */
655 /* XXX */
656
657 /* If DR or BDR change, invoke AdjOK? for each neighbor (7) */
658 /* RFC 2328 section 12.4. Originating LSAs (3) will be handled
659 accordingly after AdjOK */
660 if (oi->drouter != (drouter ? drouter->router_id : htonl (0)) ||
661 oi->bdrouter != (bdrouter ? bdrouter->router_id : htonl (0)))
662 {
663 if (IS_OSPF6_DEBUG_INTERFACE)
664 zlog_debug ("DR Election on %s: DR: %s BDR: %s", oi->interface->name,
665 (drouter ? drouter->name : "0.0.0.0"),
666 (bdrouter ? bdrouter->name : "0.0.0.0"));
667
668 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, node, on))
669 {
670 if (on->state < OSPF6_NEIGHBOR_TWOWAY)
671 continue;
672 /* Schedule AdjOK. */
673 thread_add_event (master, adj_ok, on, 0);
674 }
675 }
676
677 oi->drouter = (drouter ? drouter->router_id : htonl (0));
678 oi->bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
679 return next_state;
680 }
681
682
683 /* Interface State Machine */
684 int
685 interface_up (struct thread *thread)
686 {
687 struct ospf6_interface *oi;
688
689 oi = (struct ospf6_interface *) THREAD_ARG (thread);
690 assert (oi && oi->interface);
691
692 if (IS_OSPF6_DEBUG_INTERFACE)
693 zlog_debug ("Interface Event %s: [InterfaceUp]",
694 oi->interface->name);
695
696 /* check physical interface is up */
697 if (! if_is_operative (oi->interface))
698 {
699 if (IS_OSPF6_DEBUG_INTERFACE)
700 zlog_debug ("Interface %s is down, can't execute [InterfaceUp]",
701 oi->interface->name);
702 return 0;
703 }
704
705 /* check interface has a link-local address */
706 if (! (ospf6_interface_get_linklocal_address(oi->interface)
707 || if_is_loopback(oi->interface)))
708 {
709 if (IS_OSPF6_DEBUG_INTERFACE)
710 zlog_debug ("Interface %s has no link local address, can't execute [InterfaceUp]",
711 oi->interface->name);
712 return 0;
713 }
714
715 /* Recompute cost */
716 ospf6_interface_recalculate_cost (oi);
717
718 /* if already enabled, do nothing */
719 if (oi->state > OSPF6_INTERFACE_DOWN)
720 {
721 if (IS_OSPF6_DEBUG_INTERFACE)
722 zlog_debug ("Interface %s already enabled",
723 oi->interface->name);
724 return 0;
725 }
726
727 /* If no area assigned, return */
728 if (oi->area == NULL)
729 {
730 zlog_debug ("%s: Not scheduleing Hello for %s as there is no area assigned yet", __func__,
731 oi->interface->name);
732 return 0;
733 }
734
735 /* Join AllSPFRouters */
736 if (ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_JOIN_GROUP) < 0)
737 {
738 if (oi->sso_try_cnt++ < OSPF6_INTERFACE_SSO_RETRY_MAX)
739 {
740 zlog_info("Scheduling %s for sso retry, trial count: %d",
741 oi->interface->name, oi->sso_try_cnt);
742 thread_add_timer (master, interface_up, oi,
743 OSPF6_INTERFACE_SSO_RETRY_INT);
744 }
745 return 0;
746 }
747 oi->sso_try_cnt = 0; /* Reset on success */
748
749 /* Update interface route */
750 ospf6_interface_connected_route_update (oi->interface);
751
752 /* Schedule Hello */
753 if (! CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
754 oi->thread_send_hello = thread_add_event (master, ospf6_hello_send, oi, 0);
755
756 /* decide next interface state */
757 if ((if_is_pointopoint (oi->interface)) ||
758 (oi->type == OSPF_IFTYPE_POINTOPOINT)) {
759 ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT, oi);
760 }
761 else if (oi->priority == 0)
762 ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER, oi);
763 else
764 {
765 ospf6_interface_state_change (OSPF6_INTERFACE_WAITING, oi);
766 thread_add_timer (master, wait_timer, oi, oi->dead_interval);
767 }
768
769 return 0;
770 }
771
772 int
773 wait_timer (struct thread *thread)
774 {
775 struct ospf6_interface *oi;
776
777 oi = (struct ospf6_interface *) THREAD_ARG (thread);
778 assert (oi && oi->interface);
779
780 if (IS_OSPF6_DEBUG_INTERFACE)
781 zlog_debug ("Interface Event %s: [WaitTimer]",
782 oi->interface->name);
783
784 if (oi->state == OSPF6_INTERFACE_WAITING)
785 ospf6_interface_state_change (dr_election (oi), oi);
786
787 return 0;
788 }
789
790 int
791 backup_seen (struct thread *thread)
792 {
793 struct ospf6_interface *oi;
794
795 oi = (struct ospf6_interface *) THREAD_ARG (thread);
796 assert (oi && oi->interface);
797
798 if (IS_OSPF6_DEBUG_INTERFACE)
799 zlog_debug ("Interface Event %s: [BackupSeen]",
800 oi->interface->name);
801
802 if (oi->state == OSPF6_INTERFACE_WAITING)
803 ospf6_interface_state_change (dr_election (oi), oi);
804
805 return 0;
806 }
807
808 int
809 neighbor_change (struct thread *thread)
810 {
811 struct ospf6_interface *oi;
812
813 oi = (struct ospf6_interface *) THREAD_ARG (thread);
814 assert (oi && oi->interface);
815
816 if (IS_OSPF6_DEBUG_INTERFACE)
817 zlog_debug ("Interface Event %s: [NeighborChange]",
818 oi->interface->name);
819
820 if (oi->state == OSPF6_INTERFACE_DROTHER ||
821 oi->state == OSPF6_INTERFACE_BDR ||
822 oi->state == OSPF6_INTERFACE_DR)
823 ospf6_interface_state_change (dr_election (oi), oi);
824
825 return 0;
826 }
827
828 int
829 interface_down (struct thread *thread)
830 {
831 struct ospf6_interface *oi;
832 struct listnode *node, *nnode;
833 struct ospf6_neighbor *on;
834
835 oi = (struct ospf6_interface *) THREAD_ARG (thread);
836 assert (oi && oi->interface);
837
838 if (IS_OSPF6_DEBUG_INTERFACE)
839 zlog_debug ("Interface Event %s: [InterfaceDown]",
840 oi->interface->name);
841
842 /* Stop Hellos */
843 THREAD_OFF (oi->thread_send_hello);
844
845 /* Leave AllSPFRouters */
846 if (oi->state > OSPF6_INTERFACE_DOWN)
847 ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_LEAVE_GROUP);
848
849 ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi);
850
851 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
852 ospf6_neighbor_delete (on);
853
854 list_delete_all_node (oi->neighbor_list);
855
856 /* When interface state is reset, also reset information about
857 * DR election, as it is no longer valid. */
858 oi->drouter = oi->prev_drouter = htonl(0);
859 oi->bdrouter = oi->prev_bdrouter = htonl(0);
860 return 0;
861 }
862
863
864 /* show specified interface structure */
865 static int
866 ospf6_interface_show (struct vty *vty, struct interface *ifp)
867 {
868 struct ospf6_interface *oi;
869 struct connected *c;
870 struct prefix *p;
871 struct listnode *i;
872 char strbuf[64], drouter[32], bdrouter[32];
873 const char *updown[3] = {"down", "up", NULL};
874 const char *type;
875 struct timeval res, now;
876 char duration[32];
877 struct ospf6_lsa *lsa;
878
879 /* check physical interface type */
880 if (if_is_loopback (ifp))
881 type = "LOOPBACK";
882 else if (if_is_broadcast (ifp))
883 type = "BROADCAST";
884 else if (if_is_pointopoint (ifp))
885 type = "POINTOPOINT";
886 else
887 type = "UNKNOWN";
888
889 vty_out (vty, "%s is %s, type %s%s",
890 ifp->name, updown[if_is_operative (ifp)], type,
891 VNL);
892 vty_out (vty, " Interface ID: %d%s", ifp->ifindex, VNL);
893
894 if (ifp->info == NULL)
895 {
896 vty_out (vty, " OSPF not enabled on this interface%s", VNL);
897 return 0;
898 }
899 else
900 oi = (struct ospf6_interface *) ifp->info;
901
902 vty_out (vty, " Internet Address:%s", VNL);
903
904 for (ALL_LIST_ELEMENTS_RO (ifp->connected, i, c))
905 {
906 p = c->address;
907 prefix2str (p, strbuf, sizeof (strbuf));
908 switch (p->family)
909 {
910 case AF_INET:
911 vty_out (vty, " inet : %s%s", strbuf,
912 VNL);
913 break;
914 case AF_INET6:
915 vty_out (vty, " inet6: %s%s", strbuf,
916 VNL);
917 break;
918 default:
919 vty_out (vty, " ??? : %s%s", strbuf,
920 VNL);
921 break;
922 }
923 }
924
925 if (oi->area)
926 {
927 vty_out (vty, " Instance ID %d, Interface MTU %d (autodetect: %d)%s",
928 oi->instance_id, oi->ifmtu, ifp->mtu6, VNL);
929 vty_out (vty, " MTU mismatch detection: %s%s", oi->mtu_ignore ?
930 "disabled" : "enabled", VNL);
931 inet_ntop (AF_INET, &oi->area->area_id,
932 strbuf, sizeof (strbuf));
933 vty_out (vty, " Area ID %s, Cost %hu%s", strbuf, oi->cost,
934 VNL);
935 }
936 else
937 vty_out (vty, " Not Attached to Area%s", VNL);
938
939 vty_out (vty, " State %s, Transmit Delay %d sec, Priority %d%s",
940 ospf6_interface_state_str[oi->state],
941 oi->transdelay, oi->priority,
942 VNL);
943 vty_out (vty, " Timer intervals configured:%s", VNL);
944 vty_out (vty, " Hello %d, Dead %d, Retransmit %d%s",
945 oi->hello_interval, oi->dead_interval, oi->rxmt_interval,
946 VNL);
947
948 inet_ntop (AF_INET, &oi->drouter, drouter, sizeof (drouter));
949 inet_ntop (AF_INET, &oi->bdrouter, bdrouter, sizeof (bdrouter));
950 vty_out (vty, " DR: %s BDR: %s%s", drouter, bdrouter, VNL);
951
952 vty_out (vty, " Number of I/F scoped LSAs is %u%s",
953 oi->lsdb->count, VNL);
954
955 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
956
957 timerclear (&res);
958 if (oi->thread_send_lsupdate)
959 timersub (&oi->thread_send_lsupdate->u.sands, &now, &res);
960 timerstring (&res, duration, sizeof (duration));
961 vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
962 oi->lsupdate_list->count, duration,
963 (oi->thread_send_lsupdate ? "on" : "off"),
964 VNL);
965 for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa;
966 lsa = ospf6_lsdb_next (lsa))
967 vty_out (vty, " %s%s", lsa->name, VNL);
968
969 timerclear (&res);
970 if (oi->thread_send_lsack)
971 timersub (&oi->thread_send_lsack->u.sands, &now, &res);
972 timerstring (&res, duration, sizeof (duration));
973 vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
974 oi->lsack_list->count, duration,
975 (oi->thread_send_lsack ? "on" : "off"),
976 VNL);
977 for (lsa = ospf6_lsdb_head (oi->lsack_list); lsa;
978 lsa = ospf6_lsdb_next (lsa))
979 vty_out (vty, " %s%s", lsa->name, VNL);
980
981 return 0;
982 }
983
984 /* show interface */
985 DEFUN (show_ipv6_ospf6_interface,
986 show_ipv6_ospf6_interface_ifname_cmd,
987 "show ipv6 ospf6 interface IFNAME",
988 SHOW_STR
989 IP6_STR
990 OSPF6_STR
991 INTERFACE_STR
992 IFNAME_STR
993 )
994 {
995 struct interface *ifp;
996 struct listnode *i;
997
998 if (argc)
999 {
1000 ifp = if_lookup_by_name (argv[0]);
1001 if (ifp == NULL)
1002 {
1003 vty_out (vty, "No such Interface: %s%s", argv[0],
1004 VNL);
1005 return CMD_WARNING;
1006 }
1007 ospf6_interface_show (vty, ifp);
1008 }
1009 else
1010 {
1011 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
1012 ospf6_interface_show (vty, ifp);
1013 }
1014
1015 return CMD_SUCCESS;
1016 }
1017
1018 ALIAS (show_ipv6_ospf6_interface,
1019 show_ipv6_ospf6_interface_cmd,
1020 "show ipv6 ospf6 interface",
1021 SHOW_STR
1022 IP6_STR
1023 OSPF6_STR
1024 INTERFACE_STR
1025 )
1026
1027 DEFUN (show_ipv6_ospf6_interface_ifname_prefix,
1028 show_ipv6_ospf6_interface_ifname_prefix_cmd,
1029 "show ipv6 ospf6 interface IFNAME prefix",
1030 SHOW_STR
1031 IP6_STR
1032 OSPF6_STR
1033 INTERFACE_STR
1034 IFNAME_STR
1035 "Display connected prefixes to advertise\n"
1036 )
1037 {
1038 struct interface *ifp;
1039 struct ospf6_interface *oi;
1040
1041 ifp = if_lookup_by_name (argv[0]);
1042 if (ifp == NULL)
1043 {
1044 vty_out (vty, "No such Interface: %s%s", argv[0], VNL);
1045 return CMD_WARNING;
1046 }
1047
1048 oi = ifp->info;
1049 if (oi == NULL)
1050 {
1051 vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[0], VNL);
1052 return CMD_WARNING;
1053 }
1054
1055 argc--;
1056 argv++;
1057 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
1058
1059 return CMD_SUCCESS;
1060 }
1061
1062 ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
1063 show_ipv6_ospf6_interface_ifname_prefix_detail_cmd,
1064 "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)",
1065 SHOW_STR
1066 IP6_STR
1067 OSPF6_STR
1068 INTERFACE_STR
1069 IFNAME_STR
1070 "Display connected prefixes to advertise\n"
1071 OSPF6_ROUTE_ADDRESS_STR
1072 OSPF6_ROUTE_PREFIX_STR
1073 "Display details of the prefixes\n"
1074 )
1075
1076 ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
1077 show_ipv6_ospf6_interface_ifname_prefix_match_cmd,
1078 "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)",
1079 SHOW_STR
1080 IP6_STR
1081 OSPF6_STR
1082 INTERFACE_STR
1083 IFNAME_STR
1084 "Display connected prefixes to advertise\n"
1085 OSPF6_ROUTE_PREFIX_STR
1086 OSPF6_ROUTE_MATCH_STR
1087 "Display details of the prefixes\n"
1088 )
1089
1090 DEFUN (show_ipv6_ospf6_interface_prefix,
1091 show_ipv6_ospf6_interface_prefix_cmd,
1092 "show ipv6 ospf6 interface prefix",
1093 SHOW_STR
1094 IP6_STR
1095 OSPF6_STR
1096 INTERFACE_STR
1097 "Display connected prefixes to advertise\n"
1098 )
1099 {
1100 struct listnode *i;
1101 struct ospf6_interface *oi;
1102 struct interface *ifp;
1103
1104 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
1105 {
1106 oi = (struct ospf6_interface *) ifp->info;
1107 if (oi == NULL)
1108 continue;
1109
1110 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
1111 }
1112
1113 return CMD_SUCCESS;
1114 }
1115
1116 ALIAS (show_ipv6_ospf6_interface_prefix,
1117 show_ipv6_ospf6_interface_prefix_detail_cmd,
1118 "show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)",
1119 SHOW_STR
1120 IP6_STR
1121 OSPF6_STR
1122 INTERFACE_STR
1123 "Display connected prefixes to advertise\n"
1124 OSPF6_ROUTE_ADDRESS_STR
1125 OSPF6_ROUTE_PREFIX_STR
1126 "Display details of the prefixes\n"
1127 )
1128
1129 ALIAS (show_ipv6_ospf6_interface_prefix,
1130 show_ipv6_ospf6_interface_prefix_match_cmd,
1131 "show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)",
1132 SHOW_STR
1133 IP6_STR
1134 OSPF6_STR
1135 INTERFACE_STR
1136 "Display connected prefixes to advertise\n"
1137 OSPF6_ROUTE_PREFIX_STR
1138 OSPF6_ROUTE_MATCH_STR
1139 "Display details of the prefixes\n"
1140 )
1141
1142
1143 /* interface variable set command */
1144 DEFUN (ipv6_ospf6_ifmtu,
1145 ipv6_ospf6_ifmtu_cmd,
1146 "ipv6 ospf6 ifmtu <1-65535>",
1147 IP6_STR
1148 OSPF6_STR
1149 "Interface MTU\n"
1150 "OSPFv3 Interface MTU\n"
1151 )
1152 {
1153 struct ospf6_interface *oi;
1154 struct interface *ifp;
1155 unsigned int ifmtu, iobuflen;
1156 struct listnode *node, *nnode;
1157 struct ospf6_neighbor *on;
1158
1159 ifp = (struct interface *) vty->index;
1160 assert (ifp);
1161
1162 oi = (struct ospf6_interface *) ifp->info;
1163 if (oi == NULL)
1164 oi = ospf6_interface_create (ifp);
1165 assert (oi);
1166
1167 ifmtu = strtol (argv[0], NULL, 10);
1168
1169 if (oi->ifmtu == ifmtu)
1170 return CMD_SUCCESS;
1171
1172 if (ifp->mtu6 != 0 && ifp->mtu6 < ifmtu)
1173 {
1174 vty_out (vty, "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)%s",
1175 ifp->name, ifp->mtu6, VNL);
1176 return CMD_WARNING;
1177 }
1178
1179 if (oi->ifmtu < ifmtu)
1180 {
1181 iobuflen = ospf6_iobuf_size (ifmtu);
1182 if (iobuflen < ifmtu)
1183 {
1184 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
1185 ifp->name, iobuflen, VNL);
1186 oi->ifmtu = iobuflen;
1187 }
1188 else
1189 oi->ifmtu = ifmtu;
1190 }
1191 else
1192 oi->ifmtu = ifmtu;
1193
1194 /* re-establish adjacencies */
1195 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
1196 {
1197 THREAD_OFF (on->inactivity_timer);
1198 thread_add_event (master, inactivity_timer, on, 0);
1199 }
1200
1201 return CMD_SUCCESS;
1202 }
1203
1204 DEFUN (no_ipv6_ospf6_ifmtu,
1205 no_ipv6_ospf6_ifmtu_cmd,
1206 "no ipv6 ospf6 ifmtu",
1207 NO_STR
1208 IP6_STR
1209 OSPF6_STR
1210 "Interface MTU\n"
1211 )
1212 {
1213 struct ospf6_interface *oi;
1214 struct interface *ifp;
1215 unsigned int iobuflen;
1216 struct listnode *node, *nnode;
1217 struct ospf6_neighbor *on;
1218
1219 ifp = (struct interface *) vty->index;
1220 assert (ifp);
1221
1222 oi = (struct ospf6_interface *) ifp->info;
1223 if (oi == NULL)
1224 oi = ospf6_interface_create (ifp);
1225 assert (oi);
1226
1227 if (oi->ifmtu < ifp->mtu)
1228 {
1229 iobuflen = ospf6_iobuf_size (ifp->mtu);
1230 if (iobuflen < ifp->mtu)
1231 {
1232 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
1233 ifp->name, iobuflen, VNL);
1234 oi->ifmtu = iobuflen;
1235 }
1236 else
1237 oi->ifmtu = ifp->mtu;
1238 }
1239 else
1240 oi->ifmtu = ifp->mtu;
1241
1242 /* re-establish adjacencies */
1243 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
1244 {
1245 THREAD_OFF (on->inactivity_timer);
1246 thread_add_event (master, inactivity_timer, on, 0);
1247 }
1248
1249 return CMD_SUCCESS;
1250 }
1251
1252 DEFUN (ipv6_ospf6_cost,
1253 ipv6_ospf6_cost_cmd,
1254 "ipv6 ospf6 cost <1-65535>",
1255 IP6_STR
1256 OSPF6_STR
1257 "Interface cost\n"
1258 "Outgoing metric of this interface\n"
1259 )
1260 {
1261 struct ospf6_interface *oi;
1262 struct interface *ifp;
1263 unsigned long int lcost;
1264
1265 ifp = (struct interface *) vty->index;
1266 assert (ifp);
1267
1268 oi = (struct ospf6_interface *) ifp->info;
1269 if (oi == NULL)
1270 oi = ospf6_interface_create (ifp);
1271 assert (oi);
1272
1273 lcost = strtol (argv[0], NULL, 10);
1274
1275 if (lcost > UINT32_MAX)
1276 {
1277 vty_out (vty, "Cost %ld is out of range%s", lcost, VNL);
1278 return CMD_WARNING;
1279 }
1280
1281 if (oi->cost == lcost)
1282 return CMD_SUCCESS;
1283
1284 oi->cost = lcost;
1285 SET_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST);
1286
1287 ospf6_interface_recalculate_cost(oi);
1288
1289 return CMD_SUCCESS;
1290 }
1291
1292 DEFUN (no_ipv6_ospf6_cost,
1293 no_ipv6_ospf6_cost_cmd,
1294 "no ipv6 ospf6 cost",
1295 NO_STR
1296 IP6_STR
1297 OSPF6_STR
1298 "Calculate interface cost from bandwidth\n"
1299 )
1300 {
1301 struct ospf6_interface *oi;
1302 struct interface *ifp;
1303
1304 ifp = (struct interface *) vty->index;
1305 assert (ifp);
1306
1307 oi = (struct ospf6_interface *) ifp->info;
1308 if (oi == NULL)
1309 oi = ospf6_interface_create (ifp);
1310 assert (oi);
1311
1312 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST);
1313
1314 ospf6_interface_recalculate_cost(oi);
1315
1316 return CMD_SUCCESS;
1317 }
1318
1319 DEFUN (auto_cost_reference_bandwidth,
1320 auto_cost_reference_bandwidth_cmd,
1321 "auto-cost reference-bandwidth <1-4294967>",
1322 "Calculate OSPF interface cost according to bandwidth\n"
1323 "Use reference bandwidth method to assign OSPF cost\n"
1324 "The reference bandwidth in terms of Mbits per second\n")
1325 {
1326 struct ospf6 *o = vty->index;
1327 struct ospf6_area *oa;
1328 struct ospf6_interface *oi;
1329 struct listnode *i, *j;
1330 u_int32_t refbw;
1331
1332 refbw = strtol (argv[0], NULL, 10);
1333 if (refbw < 1 || refbw > 4294967)
1334 {
1335 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
1336 return CMD_WARNING;
1337 }
1338
1339 /* If reference bandwidth is changed. */
1340 if ((refbw * 1000) == o->ref_bandwidth)
1341 return CMD_SUCCESS;
1342
1343 o->ref_bandwidth = refbw * 1000;
1344 for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
1345 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
1346 ospf6_interface_recalculate_cost (oi);
1347
1348 return CMD_SUCCESS;
1349 }
1350
1351 DEFUN (no_auto_cost_reference_bandwidth,
1352 no_auto_cost_reference_bandwidth_cmd,
1353 "no auto-cost reference-bandwidth",
1354 NO_STR
1355 "Calculate OSPF interface cost according to bandwidth\n"
1356 "Use reference bandwidth method to assign OSPF cost\n")
1357 {
1358 struct ospf6 *o = vty->index;
1359 struct ospf6_area *oa;
1360 struct ospf6_interface *oi;
1361 struct listnode *i, *j;
1362
1363 if (o->ref_bandwidth == OSPF6_REFERENCE_BANDWIDTH)
1364 return CMD_SUCCESS;
1365
1366 o->ref_bandwidth = OSPF6_REFERENCE_BANDWIDTH;
1367 for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
1368 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
1369 ospf6_interface_recalculate_cost (oi);
1370
1371 return CMD_SUCCESS;
1372 }
1373
1374 DEFUN (ipv6_ospf6_hellointerval,
1375 ipv6_ospf6_hellointerval_cmd,
1376 "ipv6 ospf6 hello-interval <1-65535>",
1377 IP6_STR
1378 OSPF6_STR
1379 "Interval time of Hello packets\n"
1380 SECONDS_STR
1381 )
1382 {
1383 struct ospf6_interface *oi;
1384 struct interface *ifp;
1385
1386 ifp = (struct interface *) vty->index;
1387 assert (ifp);
1388
1389 oi = (struct ospf6_interface *) ifp->info;
1390 if (oi == NULL)
1391 oi = ospf6_interface_create (ifp);
1392 assert (oi);
1393
1394 oi->hello_interval = strtol (argv[0], NULL, 10);
1395 return CMD_SUCCESS;
1396 }
1397
1398 /* interface variable set command */
1399 DEFUN (ipv6_ospf6_deadinterval,
1400 ipv6_ospf6_deadinterval_cmd,
1401 "ipv6 ospf6 dead-interval <1-65535>",
1402 IP6_STR
1403 OSPF6_STR
1404 "Interval time after which a neighbor is declared down\n"
1405 SECONDS_STR
1406 )
1407 {
1408 struct ospf6_interface *oi;
1409 struct interface *ifp;
1410
1411 ifp = (struct interface *) vty->index;
1412 assert (ifp);
1413
1414 oi = (struct ospf6_interface *) ifp->info;
1415 if (oi == NULL)
1416 oi = ospf6_interface_create (ifp);
1417 assert (oi);
1418
1419 oi->dead_interval = strtol (argv[0], NULL, 10);
1420 return CMD_SUCCESS;
1421 }
1422
1423 /* interface variable set command */
1424 DEFUN (ipv6_ospf6_transmitdelay,
1425 ipv6_ospf6_transmitdelay_cmd,
1426 "ipv6 ospf6 transmit-delay <1-3600>",
1427 IP6_STR
1428 OSPF6_STR
1429 "Transmit delay of this interface\n"
1430 SECONDS_STR
1431 )
1432 {
1433 struct ospf6_interface *oi;
1434 struct interface *ifp;
1435
1436 ifp = (struct interface *) vty->index;
1437 assert (ifp);
1438
1439 oi = (struct ospf6_interface *) ifp->info;
1440 if (oi == NULL)
1441 oi = ospf6_interface_create (ifp);
1442 assert (oi);
1443
1444 oi->transdelay = strtol (argv[0], NULL, 10);
1445 return CMD_SUCCESS;
1446 }
1447
1448 /* interface variable set command */
1449 DEFUN (ipv6_ospf6_retransmitinterval,
1450 ipv6_ospf6_retransmitinterval_cmd,
1451 "ipv6 ospf6 retransmit-interval <1-65535>",
1452 IP6_STR
1453 OSPF6_STR
1454 "Time between retransmitting lost link state advertisements\n"
1455 SECONDS_STR
1456 )
1457 {
1458 struct ospf6_interface *oi;
1459 struct interface *ifp;
1460
1461 ifp = (struct interface *) vty->index;
1462 assert (ifp);
1463
1464 oi = (struct ospf6_interface *) ifp->info;
1465 if (oi == NULL)
1466 oi = ospf6_interface_create (ifp);
1467 assert (oi);
1468
1469 oi->rxmt_interval = strtol (argv[0], NULL, 10);
1470 return CMD_SUCCESS;
1471 }
1472
1473 /* interface variable set command */
1474 DEFUN (ipv6_ospf6_priority,
1475 ipv6_ospf6_priority_cmd,
1476 "ipv6 ospf6 priority <0-255>",
1477 IP6_STR
1478 OSPF6_STR
1479 "Router priority\n"
1480 "Priority value\n"
1481 )
1482 {
1483 struct ospf6_interface *oi;
1484 struct interface *ifp;
1485
1486 ifp = (struct interface *) vty->index;
1487 assert (ifp);
1488
1489 oi = (struct ospf6_interface *) ifp->info;
1490 if (oi == NULL)
1491 oi = ospf6_interface_create (ifp);
1492 assert (oi);
1493
1494 oi->priority = strtol (argv[0], NULL, 10);
1495
1496 if (oi->area &&
1497 (oi->state == OSPF6_INTERFACE_DROTHER ||
1498 oi->state == OSPF6_INTERFACE_BDR ||
1499 oi->state == OSPF6_INTERFACE_DR))
1500 ospf6_interface_state_change (dr_election (oi), oi);
1501
1502 return CMD_SUCCESS;
1503 }
1504
1505 DEFUN (ipv6_ospf6_instance,
1506 ipv6_ospf6_instance_cmd,
1507 "ipv6 ospf6 instance-id <0-255>",
1508 IP6_STR
1509 OSPF6_STR
1510 "Instance ID for this interface\n"
1511 "Instance ID value\n"
1512 )
1513 {
1514 struct ospf6_interface *oi;
1515 struct interface *ifp;
1516
1517 ifp = (struct interface *)vty->index;
1518 assert (ifp);
1519
1520 oi = (struct ospf6_interface *)ifp->info;
1521 if (oi == NULL)
1522 oi = ospf6_interface_create (ifp);
1523 assert (oi);
1524
1525 oi->instance_id = strtol (argv[0], NULL, 10);
1526 return CMD_SUCCESS;
1527 }
1528
1529 DEFUN (ipv6_ospf6_passive,
1530 ipv6_ospf6_passive_cmd,
1531 "ipv6 ospf6 passive",
1532 IP6_STR
1533 OSPF6_STR
1534 "passive interface, No adjacency will be formed on this interface\n"
1535 )
1536 {
1537 struct ospf6_interface *oi;
1538 struct interface *ifp;
1539 struct listnode *node, *nnode;
1540 struct ospf6_neighbor *on;
1541
1542 ifp = (struct interface *) vty->index;
1543 assert (ifp);
1544
1545 oi = (struct ospf6_interface *) ifp->info;
1546 if (oi == NULL)
1547 oi = ospf6_interface_create (ifp);
1548 assert (oi);
1549
1550 SET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1551 THREAD_OFF (oi->thread_send_hello);
1552
1553 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
1554 {
1555 THREAD_OFF (on->inactivity_timer);
1556 thread_add_event (master, inactivity_timer, on, 0);
1557 }
1558
1559 return CMD_SUCCESS;
1560 }
1561
1562 DEFUN (no_ipv6_ospf6_passive,
1563 no_ipv6_ospf6_passive_cmd,
1564 "no ipv6 ospf6 passive",
1565 NO_STR
1566 IP6_STR
1567 OSPF6_STR
1568 "passive interface: No Adjacency will be formed on this I/F\n"
1569 )
1570 {
1571 struct ospf6_interface *oi;
1572 struct interface *ifp;
1573
1574 ifp = (struct interface *) vty->index;
1575 assert (ifp);
1576
1577 oi = (struct ospf6_interface *) ifp->info;
1578 if (oi == NULL)
1579 oi = ospf6_interface_create (ifp);
1580 assert (oi);
1581
1582 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1583 THREAD_OFF (oi->thread_send_hello);
1584 oi->thread_send_hello =
1585 thread_add_event (master, ospf6_hello_send, oi, 0);
1586
1587 return CMD_SUCCESS;
1588 }
1589
1590 DEFUN (ipv6_ospf6_mtu_ignore,
1591 ipv6_ospf6_mtu_ignore_cmd,
1592 "ipv6 ospf6 mtu-ignore",
1593 IP6_STR
1594 OSPF6_STR
1595 "Ignore MTU mismatch on this interface\n"
1596 )
1597 {
1598 struct ospf6_interface *oi;
1599 struct interface *ifp;
1600
1601 ifp = (struct interface *) vty->index;
1602 assert (ifp);
1603
1604 oi = (struct ospf6_interface *) ifp->info;
1605 if (oi == NULL)
1606 oi = ospf6_interface_create (ifp);
1607 assert (oi);
1608
1609 oi->mtu_ignore = 1;
1610
1611 return CMD_SUCCESS;
1612 }
1613
1614 DEFUN (no_ipv6_ospf6_mtu_ignore,
1615 no_ipv6_ospf6_mtu_ignore_cmd,
1616 "no ipv6 ospf6 mtu-ignore",
1617 NO_STR
1618 IP6_STR
1619 OSPF6_STR
1620 "Ignore MTU mismatch on this interface\n"
1621 )
1622 {
1623 struct ospf6_interface *oi;
1624 struct interface *ifp;
1625
1626 ifp = (struct interface *) vty->index;
1627 assert (ifp);
1628
1629 oi = (struct ospf6_interface *) ifp->info;
1630 if (oi == NULL)
1631 oi = ospf6_interface_create (ifp);
1632 assert (oi);
1633
1634 oi->mtu_ignore = 0;
1635
1636 return CMD_SUCCESS;
1637 }
1638
1639 DEFUN (ipv6_ospf6_advertise_prefix_list,
1640 ipv6_ospf6_advertise_prefix_list_cmd,
1641 "ipv6 ospf6 advertise prefix-list WORD",
1642 IP6_STR
1643 OSPF6_STR
1644 "Advertising options\n"
1645 "Filter prefix using prefix-list\n"
1646 "Prefix list name\n"
1647 )
1648 {
1649 struct ospf6_interface *oi;
1650 struct interface *ifp;
1651
1652 ifp = (struct interface *) vty->index;
1653 assert (ifp);
1654
1655 oi = (struct ospf6_interface *) ifp->info;
1656 if (oi == NULL)
1657 oi = ospf6_interface_create (ifp);
1658 assert (oi);
1659
1660 if (oi->plist_name)
1661 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1662 oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]);
1663
1664 ospf6_interface_connected_route_update (oi->interface);
1665
1666 if (oi->area)
1667 {
1668 OSPF6_LINK_LSA_SCHEDULE (oi);
1669 if (oi->state == OSPF6_INTERFACE_DR)
1670 {
1671 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1672 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1673 }
1674 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
1675 }
1676
1677 return CMD_SUCCESS;
1678 }
1679
1680 DEFUN (no_ipv6_ospf6_advertise_prefix_list,
1681 no_ipv6_ospf6_advertise_prefix_list_cmd,
1682 "no ipv6 ospf6 advertise prefix-list",
1683 NO_STR
1684 IP6_STR
1685 OSPF6_STR
1686 "Advertising options\n"
1687 "Filter prefix using prefix-list\n"
1688 )
1689 {
1690 struct ospf6_interface *oi;
1691 struct interface *ifp;
1692
1693 ifp = (struct interface *) vty->index;
1694 assert (ifp);
1695
1696 oi = (struct ospf6_interface *) ifp->info;
1697 if (oi == NULL)
1698 oi = ospf6_interface_create (ifp);
1699 assert (oi);
1700
1701 if (oi->plist_name)
1702 {
1703 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1704 oi->plist_name = NULL;
1705 }
1706
1707 ospf6_interface_connected_route_update (oi->interface);
1708
1709 if (oi->area)
1710 {
1711 OSPF6_LINK_LSA_SCHEDULE (oi);
1712 if (oi->state == OSPF6_INTERFACE_DR)
1713 {
1714 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1715 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1716 }
1717 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
1718 }
1719
1720 return CMD_SUCCESS;
1721 }
1722
1723 DEFUN (ipv6_ospf6_network,
1724 ipv6_ospf6_network_cmd,
1725 "ipv6 ospf6 network (broadcast|point-to-point)",
1726 IP6_STR
1727 OSPF6_STR
1728 "Network Type\n"
1729 "Specify OSPFv6 broadcast network\n"
1730 "Specify OSPF6 point-to-point network\n"
1731 )
1732 {
1733 struct ospf6_interface *oi;
1734 struct interface *ifp;
1735
1736 ifp = (struct interface *) vty->index;
1737 assert (ifp);
1738
1739 oi = (struct ospf6_interface *) ifp->info;
1740 if (oi == NULL) {
1741 oi = ospf6_interface_create (ifp);
1742 }
1743 assert (oi);
1744
1745 if (strncmp (argv[0], "b", 1) == 0)
1746 {
1747 if (oi->type == OSPF_IFTYPE_BROADCAST)
1748 return CMD_SUCCESS;
1749
1750 oi->type = OSPF_IFTYPE_BROADCAST;
1751 }
1752 else if (strncmp (argv[0], "point-to-p", 10) == 0)
1753 {
1754 if (oi->type == OSPF_IFTYPE_POINTOPOINT) {
1755 return CMD_SUCCESS;
1756 }
1757 oi->type = OSPF_IFTYPE_POINTOPOINT;
1758 }
1759
1760 /* Reset the interface */
1761 thread_add_event (master, interface_down, oi, 0);
1762 thread_add_event (master, interface_up, oi, 0);
1763
1764 return CMD_SUCCESS;
1765 }
1766
1767 DEFUN (no_ipv6_ospf6_network,
1768 no_ipv6_ospf6_network_cmd,
1769 "no ipv6 ospf6 network",
1770 NO_STR
1771 IP6_STR
1772 OSPF6_STR
1773 "Network Type\n"
1774 "Default to whatever interface type system specifies"
1775 )
1776 {
1777 struct ospf6_interface *oi;
1778 struct interface *ifp;
1779 int type;
1780
1781 ifp = (struct interface *) vty->index;
1782 assert (ifp);
1783
1784 oi = (struct ospf6_interface *) ifp->info;
1785 if (oi == NULL) {
1786 return CMD_SUCCESS;
1787 }
1788
1789 type = ospf6_default_iftype (ifp);
1790 if (oi->type == type)
1791 {
1792 return CMD_SUCCESS;
1793 }
1794 oi->type = type;
1795
1796 /* Reset the interface */
1797 thread_add_event (master, interface_down, oi, 0);
1798 thread_add_event (master, interface_up, oi, 0);
1799
1800 return CMD_SUCCESS;
1801 }
1802
1803 static int
1804 config_write_ospf6_interface (struct vty *vty)
1805 {
1806 struct listnode *i;
1807 struct ospf6_interface *oi;
1808 struct interface *ifp;
1809
1810 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
1811 {
1812 oi = (struct ospf6_interface *) ifp->info;
1813 if (oi == NULL)
1814 continue;
1815
1816 vty_out (vty, "interface %s%s",
1817 oi->interface->name, VNL);
1818
1819 if (ifp->desc)
1820 vty_out (vty, " description %s%s", ifp->desc, VNL);
1821 if (ifp->mtu6 != oi->ifmtu)
1822 vty_out (vty, " ipv6 ospf6 ifmtu %d%s", oi->ifmtu, VNL);
1823
1824 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST))
1825 vty_out (vty, " ipv6 ospf6 cost %d%s",
1826 oi->cost, VNL);
1827
1828 if (oi->hello_interval != OSPF6_INTERFACE_HELLO_INTERVAL)
1829 vty_out (vty, " ipv6 ospf6 hello-interval %d%s",
1830 oi->hello_interval, VNL);
1831
1832 if (oi->dead_interval != OSPF6_INTERFACE_DEAD_INTERVAL)
1833 vty_out (vty, " ipv6 ospf6 dead-interval %d%s",
1834 oi->dead_interval, VNL);
1835
1836 if (oi->rxmt_interval != OSPF6_INTERFACE_RXMT_INTERVAL)
1837 vty_out (vty, " ipv6 ospf6 retransmit-interval %d%s",
1838 oi->rxmt_interval, VNL);
1839
1840 if (oi->priority != OSPF6_INTERFACE_PRIORITY)
1841 vty_out (vty, " ipv6 ospf6 priority %d%s",
1842 oi->priority, VNL);
1843
1844 if (oi->transdelay != OSPF6_INTERFACE_TRANSDELAY)
1845 vty_out (vty, " ipv6 ospf6 transmit-delay %d%s",
1846 oi->transdelay, VNL);
1847
1848 if (oi->instance_id != OSPF6_INTERFACE_INSTANCE_ID)
1849 vty_out (vty, " ipv6 ospf6 instance-id %d%s",
1850 oi->instance_id, VNL);
1851
1852 if (oi->plist_name)
1853 vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s",
1854 oi->plist_name, VNL);
1855
1856 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
1857 vty_out (vty, " ipv6 ospf6 passive%s", VNL);
1858
1859 if (oi->mtu_ignore)
1860 vty_out (vty, " ipv6 ospf6 mtu-ignore%s", VNL);
1861
1862 if (oi->type == OSPF_IFTYPE_POINTOPOINT)
1863 vty_out (vty, " ipv6 ospf6 network point-to-point%s", VNL);
1864 else if (oi->type == OSPF_IFTYPE_BROADCAST)
1865 vty_out (vty, " ipv6 ospf6 network broadcast%s", VNL);
1866
1867 ospf6_bfd_write_config(vty, oi);
1868
1869 vty_out (vty, "!%s", VNL);
1870 }
1871 return 0;
1872 }
1873
1874 static struct cmd_node interface_node =
1875 {
1876 INTERFACE_NODE,
1877 "%s(config-if)# ",
1878 1 /* VTYSH */
1879 };
1880
1881 void
1882 ospf6_interface_init (void)
1883 {
1884 /* Install interface node. */
1885 install_node (&interface_node, config_write_ospf6_interface);
1886
1887 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd);
1888 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1889 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1890 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
1891 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
1892 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1893 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1894 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
1895 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_cmd);
1896 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1897 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1898 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
1899 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
1900 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1901 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1902 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
1903
1904 install_element (CONFIG_NODE, &interface_cmd);
1905 install_default (INTERFACE_NODE);
1906 install_element (INTERFACE_NODE, &interface_desc_cmd);
1907 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
1908 install_element (INTERFACE_NODE, &ipv6_ospf6_cost_cmd);
1909 install_element (INTERFACE_NODE, &no_ipv6_ospf6_cost_cmd);
1910 install_element (INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd);
1911 install_element (INTERFACE_NODE, &no_ipv6_ospf6_ifmtu_cmd);
1912 install_element (INTERFACE_NODE, &ipv6_ospf6_deadinterval_cmd);
1913 install_element (INTERFACE_NODE, &ipv6_ospf6_hellointerval_cmd);
1914 install_element (INTERFACE_NODE, &ipv6_ospf6_priority_cmd);
1915 install_element (INTERFACE_NODE, &ipv6_ospf6_retransmitinterval_cmd);
1916 install_element (INTERFACE_NODE, &ipv6_ospf6_transmitdelay_cmd);
1917 install_element (INTERFACE_NODE, &ipv6_ospf6_instance_cmd);
1918
1919 install_element (INTERFACE_NODE, &ipv6_ospf6_passive_cmd);
1920 install_element (INTERFACE_NODE, &no_ipv6_ospf6_passive_cmd);
1921
1922 install_element (INTERFACE_NODE, &ipv6_ospf6_mtu_ignore_cmd);
1923 install_element (INTERFACE_NODE, &no_ipv6_ospf6_mtu_ignore_cmd);
1924
1925 install_element (INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd);
1926 install_element (INTERFACE_NODE, &no_ipv6_ospf6_advertise_prefix_list_cmd);
1927
1928 install_element (INTERFACE_NODE, &ipv6_ospf6_network_cmd);
1929 install_element (INTERFACE_NODE, &no_ipv6_ospf6_network_cmd);
1930
1931 /* reference bandwidth commands */
1932 install_element (OSPF6_NODE, &auto_cost_reference_bandwidth_cmd);
1933 install_element (OSPF6_NODE, &no_auto_cost_reference_bandwidth_cmd);
1934 }
1935
1936 /* Clear the specified interface structure */
1937 static void
1938 ospf6_interface_clear (struct vty *vty, struct interface *ifp)
1939 {
1940 struct ospf6_interface *oi;
1941
1942 if (!if_is_operative (ifp))
1943 return;
1944
1945 if (ifp->info == NULL)
1946 return;
1947
1948 oi = (struct ospf6_interface *) ifp->info;
1949
1950 if (IS_OSPF6_DEBUG_INTERFACE)
1951 zlog_debug ("Interface %s: clear by reset", ifp->name);
1952
1953 /* Reset the interface */
1954 thread_add_event (master, interface_down, oi, 0);
1955 thread_add_event (master, interface_up, oi, 0);
1956 }
1957
1958 /* Clear interface */
1959 DEFUN (clear_ipv6_ospf6_interface,
1960 clear_ipv6_ospf6_interface_cmd,
1961 "clear ipv6 ospf6 interface [IFNAME]",
1962 CLEAR_STR
1963 IP6_STR
1964 OSPF6_STR
1965 INTERFACE_STR
1966 IFNAME_STR
1967 )
1968 {
1969 struct interface *ifp;
1970 struct listnode *node;
1971
1972 if (argc == 0) /* Clear all the ospfv3 interfaces. */
1973 {
1974 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
1975 ospf6_interface_clear (vty, ifp);
1976 }
1977 else /* Interface name is specified. */
1978 {
1979 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
1980 {
1981 vty_out (vty, "No such Interface: %s%s", argv[0], VNL);
1982 return CMD_WARNING;
1983 }
1984 ospf6_interface_clear (vty, ifp);
1985 }
1986
1987 return CMD_SUCCESS;
1988 }
1989
1990 void
1991 install_element_ospf6_clear_interface (void)
1992 {
1993 install_element (ENABLE_NODE, &clear_ipv6_ospf6_interface_cmd);
1994 }
1995
1996 DEFUN (debug_ospf6_interface,
1997 debug_ospf6_interface_cmd,
1998 "debug ospf6 interface",
1999 DEBUG_STR
2000 OSPF6_STR
2001 "Debug OSPFv3 Interface\n"
2002 )
2003 {
2004 OSPF6_DEBUG_INTERFACE_ON ();
2005 return CMD_SUCCESS;
2006 }
2007
2008 DEFUN (no_debug_ospf6_interface,
2009 no_debug_ospf6_interface_cmd,
2010 "no debug ospf6 interface",
2011 NO_STR
2012 DEBUG_STR
2013 OSPF6_STR
2014 "Debug OSPFv3 Interface\n"
2015 )
2016 {
2017 OSPF6_DEBUG_INTERFACE_OFF ();
2018 return CMD_SUCCESS;
2019 }
2020
2021 int
2022 config_write_ospf6_debug_interface (struct vty *vty)
2023 {
2024 if (IS_OSPF6_DEBUG_INTERFACE)
2025 vty_out (vty, "debug ospf6 interface%s", VNL);
2026 return 0;
2027 }
2028
2029 void
2030 install_element_ospf6_debug_interface (void)
2031 {
2032 install_element (ENABLE_NODE, &debug_ospf6_interface_cmd);
2033 install_element (ENABLE_NODE, &no_debug_ospf6_interface_cmd);
2034 install_element (CONFIG_NODE, &debug_ospf6_interface_cmd);
2035 install_element (CONFIG_NODE, &no_debug_ospf6_interface_cmd);
2036 }
2037
2038