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