]> git.proxmox.com Git - mirror_frr.git/blob - ospf6d/ospf6_interface.c
Merge remote-tracking branch 'polymorf/master'
[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)
77 {
78 switch (ntohs (lsa->header->type))
79 {
80 case OSPF6_LSTYPE_LINK:
81 if (OSPF6_INTERFACE (lsa->lsdb->data)->state == OSPF6_INTERFACE_DR)
82 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (OSPF6_INTERFACE (lsa->lsdb->data));
83 ospf6_spf_schedule (OSPF6_INTERFACE (lsa->lsdb->data)->area);
84 break;
85
86 default:
87 break;
88 }
89 }
90
91 /* Create new ospf6 interface structure */
92 struct ospf6_interface *
93 ospf6_interface_create (struct interface *ifp)
94 {
95 struct ospf6_interface *oi;
96 unsigned int iobuflen;
97
98 oi = (struct ospf6_interface *)
99 XCALLOC (MTYPE_OSPF6_IF, sizeof (struct ospf6_interface));
100
101 if (!oi)
102 {
103 zlog_err ("Can't malloc ospf6_interface for ifindex %d", ifp->ifindex);
104 return (struct ospf6_interface *) NULL;
105 }
106
107 oi->area = (struct ospf6_area *) NULL;
108 oi->neighbor_list = list_new ();
109 oi->neighbor_list->cmp = ospf6_neighbor_cmp;
110 oi->linklocal_addr = (struct in6_addr *) NULL;
111 oi->instance_id = 0;
112 oi->transdelay = 1;
113 oi->priority = 1;
114
115 oi->hello_interval = 10;
116 oi->dead_interval = 40;
117 oi->rxmt_interval = 5;
118 oi->cost = 1;
119 oi->state = OSPF6_INTERFACE_DOWN;
120 oi->flag = 0;
121 oi->mtu_ignore = 0;
122
123 /* Try to adjust I/O buffer size with IfMtu */
124 oi->ifmtu = ifp->mtu6;
125 iobuflen = ospf6_iobuf_size (ifp->mtu6);
126 if (oi->ifmtu > iobuflen)
127 {
128 if (IS_OSPF6_DEBUG_INTERFACE)
129 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
130 ifp->name, iobuflen);
131 oi->ifmtu = iobuflen;
132 }
133
134 oi->lsupdate_list = ospf6_lsdb_create (oi);
135 oi->lsack_list = ospf6_lsdb_create (oi);
136 oi->lsdb = ospf6_lsdb_create (oi);
137 oi->lsdb->hook_add = ospf6_interface_lsdb_hook;
138 oi->lsdb->hook_remove = ospf6_interface_lsdb_hook;
139 oi->lsdb_self = ospf6_lsdb_create (oi);
140
141 oi->route_connected = OSPF6_ROUTE_TABLE_CREATE (INTERFACE, CONNECTED_ROUTES);
142 oi->route_connected->scope = oi;
143
144 /* link both */
145 oi->interface = ifp;
146 ifp->info = oi;
147
148 return oi;
149 }
150
151 void
152 ospf6_interface_delete (struct ospf6_interface *oi)
153 {
154 struct listnode *node, *nnode;
155 struct ospf6_neighbor *on;
156
157 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
158 ospf6_neighbor_delete (on);
159
160 list_delete (oi->neighbor_list);
161
162 THREAD_OFF (oi->thread_send_hello);
163 THREAD_OFF (oi->thread_send_lsupdate);
164 THREAD_OFF (oi->thread_send_lsack);
165
166 ospf6_lsdb_remove_all (oi->lsdb);
167 ospf6_lsdb_remove_all (oi->lsupdate_list);
168 ospf6_lsdb_remove_all (oi->lsack_list);
169
170 ospf6_lsdb_delete (oi->lsdb);
171 ospf6_lsdb_delete (oi->lsdb_self);
172
173 ospf6_lsdb_delete (oi->lsupdate_list);
174 ospf6_lsdb_delete (oi->lsack_list);
175
176 ospf6_route_table_delete (oi->route_connected);
177
178 /* cut link */
179 oi->interface->info = NULL;
180
181 /* plist_name */
182 if (oi->plist_name)
183 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
184
185 XFREE (MTYPE_OSPF6_IF, oi);
186 }
187
188 void
189 ospf6_interface_enable (struct ospf6_interface *oi)
190 {
191 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
192
193 oi->thread_send_hello =
194 thread_add_event (master, ospf6_hello_send, oi, 0);
195 }
196
197 void
198 ospf6_interface_disable (struct ospf6_interface *oi)
199 {
200 struct listnode *node, *nnode;
201 struct ospf6_neighbor *on;
202
203 SET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
204
205 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
206 ospf6_neighbor_delete (on);
207
208 list_delete_all_node (oi->neighbor_list);
209
210 ospf6_lsdb_remove_all (oi->lsdb);
211 ospf6_lsdb_remove_all (oi->lsupdate_list);
212 ospf6_lsdb_remove_all (oi->lsack_list);
213
214 THREAD_OFF (oi->thread_send_hello);
215 THREAD_OFF (oi->thread_send_lsupdate);
216 THREAD_OFF (oi->thread_send_lsack);
217 }
218
219 static struct in6_addr *
220 ospf6_interface_get_linklocal_address (struct interface *ifp)
221 {
222 struct listnode *n;
223 struct connected *c;
224 struct in6_addr *l = (struct in6_addr *) NULL;
225
226 /* for each connected address */
227 for (ALL_LIST_ELEMENTS_RO (ifp->connected, n, c))
228 {
229 /* if family not AF_INET6, ignore */
230 if (c->address->family != AF_INET6)
231 continue;
232
233 /* linklocal scope check */
234 if (IN6_IS_ADDR_LINKLOCAL (&c->address->u.prefix6))
235 l = &c->address->u.prefix6;
236 }
237 return l;
238 }
239
240 void
241 ospf6_interface_if_add (struct interface *ifp)
242 {
243 struct ospf6_interface *oi;
244 unsigned int iobuflen;
245
246 oi = (struct ospf6_interface *) ifp->info;
247 if (oi == NULL)
248 return;
249
250 /* Try to adjust I/O buffer size with IfMtu */
251 if (oi->ifmtu == 0)
252 oi->ifmtu = ifp->mtu6;
253 iobuflen = ospf6_iobuf_size (ifp->mtu6);
254 if (oi->ifmtu > iobuflen)
255 {
256 if (IS_OSPF6_DEBUG_INTERFACE)
257 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
258 ifp->name, iobuflen);
259 oi->ifmtu = iobuflen;
260 }
261
262 /* interface start */
263 if (oi->area)
264 thread_add_event (master, interface_up, oi, 0);
265 }
266
267 void
268 ospf6_interface_if_del (struct interface *ifp)
269 {
270 struct ospf6_interface *oi;
271
272 oi = (struct ospf6_interface *) ifp->info;
273 if (oi == NULL)
274 return;
275
276 /* interface stop */
277 if (oi->area)
278 thread_execute (master, interface_down, oi, 0);
279
280 listnode_delete (oi->area->if_list, oi);
281 oi->area = (struct ospf6_area *) NULL;
282
283 /* cut link */
284 oi->interface = NULL;
285 ifp->info = NULL;
286
287 ospf6_interface_delete (oi);
288 }
289
290 void
291 ospf6_interface_state_update (struct interface *ifp)
292 {
293 struct ospf6_interface *oi;
294
295 oi = (struct ospf6_interface *) ifp->info;
296 if (oi == NULL)
297 return;
298 if (oi->area == NULL)
299 return;
300
301 if (if_is_up (ifp))
302 thread_add_event (master, interface_up, oi, 0);
303 else
304 thread_add_event (master, interface_down, oi, 0);
305
306 return;
307 }
308
309 void
310 ospf6_interface_connected_route_update (struct interface *ifp)
311 {
312 struct ospf6_interface *oi;
313 struct ospf6_route *route;
314 struct connected *c;
315 struct listnode *node, *nnode;
316
317 oi = (struct ospf6_interface *) ifp->info;
318 if (oi == NULL)
319 return;
320
321 /* reset linklocal pointer */
322 oi->linklocal_addr = ospf6_interface_get_linklocal_address (ifp);
323
324 /* if area is null, do not make connected-route list */
325 if (oi->area == NULL)
326 return;
327
328 /* update "route to advertise" interface route table */
329 ospf6_route_remove_all (oi->route_connected);
330
331 for (ALL_LIST_ELEMENTS (oi->interface->connected, node, nnode, c))
332 {
333 if (c->address->family != AF_INET6)
334 continue;
335
336 CONTINUE_IF_ADDRESS_LINKLOCAL (IS_OSPF6_DEBUG_INTERFACE, c->address);
337 CONTINUE_IF_ADDRESS_UNSPECIFIED (IS_OSPF6_DEBUG_INTERFACE, c->address);
338 CONTINUE_IF_ADDRESS_LOOPBACK (IS_OSPF6_DEBUG_INTERFACE, c->address);
339 CONTINUE_IF_ADDRESS_V4COMPAT (IS_OSPF6_DEBUG_INTERFACE, c->address);
340 CONTINUE_IF_ADDRESS_V4MAPPED (IS_OSPF6_DEBUG_INTERFACE, c->address);
341
342 /* apply filter */
343 if (oi->plist_name)
344 {
345 struct prefix_list *plist;
346 enum prefix_list_type ret;
347 char buf[128];
348
349 prefix2str (c->address, buf, sizeof (buf));
350 plist = prefix_list_lookup (AFI_IP6, oi->plist_name);
351 ret = prefix_list_apply (plist, (void *) c->address);
352 if (ret == PREFIX_DENY)
353 {
354 if (IS_OSPF6_DEBUG_INTERFACE)
355 zlog_debug ("%s on %s filtered by prefix-list %s ",
356 buf, oi->interface->name, oi->plist_name);
357 continue;
358 }
359 }
360
361 route = ospf6_route_create ();
362 memcpy (&route->prefix, c->address, sizeof (struct prefix));
363 apply_mask (&route->prefix);
364 route->type = OSPF6_DEST_TYPE_NETWORK;
365 route->path.area_id = oi->area->area_id;
366 route->path.type = OSPF6_PATH_TYPE_INTRA;
367 route->path.cost = oi->cost;
368 route->nexthop[0].ifindex = oi->interface->ifindex;
369 inet_pton (AF_INET6, "::1", &route->nexthop[0].address);
370 ospf6_route_add (route, oi->route_connected);
371 }
372
373 /* create new Link-LSA */
374 OSPF6_LINK_LSA_SCHEDULE (oi);
375 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
376 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
377 }
378
379 static void
380 ospf6_interface_state_change (u_char next_state, struct ospf6_interface *oi)
381 {
382 u_char prev_state;
383
384 prev_state = oi->state;
385 oi->state = next_state;
386
387 if (prev_state == next_state)
388 return;
389
390 /* log */
391 if (IS_OSPF6_DEBUG_INTERFACE)
392 {
393 zlog_debug ("Interface state change %s: %s -> %s", oi->interface->name,
394 ospf6_interface_state_str[prev_state],
395 ospf6_interface_state_str[next_state]);
396 }
397
398 if ((prev_state == OSPF6_INTERFACE_DR ||
399 prev_state == OSPF6_INTERFACE_BDR) &&
400 (next_state != OSPF6_INTERFACE_DR &&
401 next_state != OSPF6_INTERFACE_BDR))
402 ospf6_leave_alldrouters (oi->interface->ifindex);
403 if ((prev_state != OSPF6_INTERFACE_DR &&
404 prev_state != OSPF6_INTERFACE_BDR) &&
405 (next_state == OSPF6_INTERFACE_DR ||
406 next_state == OSPF6_INTERFACE_BDR))
407 ospf6_join_alldrouters (oi->interface->ifindex);
408
409 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
410 if (next_state == OSPF6_INTERFACE_DOWN)
411 {
412 OSPF6_NETWORK_LSA_EXECUTE (oi);
413 OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT (oi);
414 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
415 }
416 else if (prev_state == OSPF6_INTERFACE_DR ||
417 next_state == OSPF6_INTERFACE_DR)
418 {
419 OSPF6_NETWORK_LSA_SCHEDULE (oi);
420 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
421 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
422 }
423 }
424
425 \f
426 /* DR Election, RFC2328 section 9.4 */
427
428 #define IS_ELIGIBLE(n) \
429 ((n)->state >= OSPF6_NEIGHBOR_TWOWAY && (n)->priority != 0)
430
431 static struct ospf6_neighbor *
432 better_bdrouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
433 {
434 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id) &&
435 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id))
436 return NULL;
437 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id)
438 return b;
439 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id)
440 return a;
441
442 if (a->bdrouter == a->router_id && b->bdrouter != b->router_id)
443 return a;
444 if (a->bdrouter != a->router_id && b->bdrouter == b->router_id)
445 return b;
446
447 if (a->priority > b->priority)
448 return a;
449 if (a->priority < b->priority)
450 return b;
451
452 if (ntohl (a->router_id) > ntohl (b->router_id))
453 return a;
454 if (ntohl (a->router_id) < ntohl (b->router_id))
455 return b;
456
457 zlog_warn ("Router-ID duplicate ?");
458 return a;
459 }
460
461 static struct ospf6_neighbor *
462 better_drouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
463 {
464 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id) &&
465 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id))
466 return NULL;
467 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id)
468 return b;
469 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id)
470 return a;
471
472 if (a->drouter == a->router_id && b->drouter != b->router_id)
473 return a;
474 if (a->drouter != a->router_id && b->drouter == b->router_id)
475 return b;
476
477 if (a->priority > b->priority)
478 return a;
479 if (a->priority < b->priority)
480 return b;
481
482 if (ntohl (a->router_id) > ntohl (b->router_id))
483 return a;
484 if (ntohl (a->router_id) < ntohl (b->router_id))
485 return b;
486
487 zlog_warn ("Router-ID duplicate ?");
488 return a;
489 }
490
491 static u_char
492 dr_election (struct ospf6_interface *oi)
493 {
494 struct listnode *node, *nnode;
495 struct ospf6_neighbor *on, *drouter, *bdrouter, myself;
496 struct ospf6_neighbor *best_drouter, *best_bdrouter;
497 u_char next_state = 0;
498
499 drouter = bdrouter = NULL;
500 best_drouter = best_bdrouter = NULL;
501
502 /* pseudo neighbor myself, including noting current DR/BDR (1) */
503 memset (&myself, 0, sizeof (myself));
504 inet_ntop (AF_INET, &oi->area->ospf6->router_id, myself.name,
505 sizeof (myself.name));
506 myself.state = OSPF6_NEIGHBOR_TWOWAY;
507 myself.drouter = oi->drouter;
508 myself.bdrouter = oi->bdrouter;
509 myself.priority = oi->priority;
510 myself.router_id = oi->area->ospf6->router_id;
511
512 /* Electing BDR (2) */
513 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
514 bdrouter = better_bdrouter (bdrouter, on);
515
516 best_bdrouter = bdrouter;
517 bdrouter = better_bdrouter (best_bdrouter, &myself);
518
519 /* Electing DR (3) */
520 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
521 drouter = better_drouter (drouter, on);
522
523 best_drouter = drouter;
524 drouter = better_drouter (best_drouter, &myself);
525 if (drouter == NULL)
526 drouter = bdrouter;
527
528 /* the router itself is newly/no longer DR/BDR (4) */
529 if ((drouter == &myself && myself.drouter != myself.router_id) ||
530 (drouter != &myself && myself.drouter == myself.router_id) ||
531 (bdrouter == &myself && myself.bdrouter != myself.router_id) ||
532 (bdrouter != &myself && myself.bdrouter == myself.router_id))
533 {
534 myself.drouter = (drouter ? drouter->router_id : htonl (0));
535 myself.bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
536
537 /* compatible to Electing BDR (2) */
538 bdrouter = better_bdrouter (best_bdrouter, &myself);
539
540 /* compatible to Electing DR (3) */
541 drouter = better_drouter (best_drouter, &myself);
542 if (drouter == NULL)
543 drouter = bdrouter;
544 }
545
546 /* Set interface state accordingly (5) */
547 if (drouter && drouter == &myself)
548 next_state = OSPF6_INTERFACE_DR;
549 else if (bdrouter && bdrouter == &myself)
550 next_state = OSPF6_INTERFACE_BDR;
551 else
552 next_state = OSPF6_INTERFACE_DROTHER;
553
554 /* If NBMA, schedule Start for each neighbor having priority of 0 (6) */
555 /* XXX */
556
557 /* If DR or BDR change, invoke AdjOK? for each neighbor (7) */
558 /* RFC 2328 section 12.4. Originating LSAs (3) will be handled
559 accordingly after AdjOK */
560 if (oi->drouter != (drouter ? drouter->router_id : htonl (0)) ||
561 oi->bdrouter != (bdrouter ? bdrouter->router_id : htonl (0)))
562 {
563 if (IS_OSPF6_DEBUG_INTERFACE)
564 zlog_debug ("DR Election on %s: DR: %s BDR: %s", oi->interface->name,
565 (drouter ? drouter->name : "0.0.0.0"),
566 (bdrouter ? bdrouter->name : "0.0.0.0"));
567
568 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, node, on))
569 {
570 if (on->state < OSPF6_NEIGHBOR_TWOWAY)
571 continue;
572 /* Schedule AdjOK. */
573 thread_add_event (master, adj_ok, on, 0);
574 }
575 }
576
577 oi->drouter = (drouter ? drouter->router_id : htonl (0));
578 oi->bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
579 return next_state;
580 }
581
582 \f
583 /* Interface State Machine */
584 int
585 interface_up (struct thread *thread)
586 {
587 struct ospf6_interface *oi;
588
589 oi = (struct ospf6_interface *) THREAD_ARG (thread);
590 assert (oi && oi->interface);
591
592 if (IS_OSPF6_DEBUG_INTERFACE)
593 zlog_debug ("Interface Event %s: [InterfaceUp]",
594 oi->interface->name);
595
596 /* check physical interface is up */
597 if (! if_is_up (oi->interface))
598 {
599 if (IS_OSPF6_DEBUG_INTERFACE)
600 zlog_debug ("Interface %s is down, can't execute [InterfaceUp]",
601 oi->interface->name);
602 return 0;
603 }
604
605 /* if already enabled, do nothing */
606 if (oi->state > OSPF6_INTERFACE_DOWN)
607 {
608 if (IS_OSPF6_DEBUG_INTERFACE)
609 zlog_debug ("Interface %s already enabled",
610 oi->interface->name);
611 return 0;
612 }
613
614 /* Join AllSPFRouters */
615 ospf6_join_allspfrouters (oi->interface->ifindex);
616
617 /* Update interface route */
618 ospf6_interface_connected_route_update (oi->interface);
619
620 /* Schedule Hello */
621 if (! CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
622 thread_add_event (master, ospf6_hello_send, oi, 0);
623
624 /* decide next interface state */
625 if (if_is_pointopoint (oi->interface))
626 ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT, oi);
627 else if (oi->priority == 0)
628 ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER, oi);
629 else
630 {
631 ospf6_interface_state_change (OSPF6_INTERFACE_WAITING, oi);
632 thread_add_timer (master, wait_timer, oi, oi->dead_interval);
633 }
634
635 return 0;
636 }
637
638 int
639 wait_timer (struct thread *thread)
640 {
641 struct ospf6_interface *oi;
642
643 oi = (struct ospf6_interface *) THREAD_ARG (thread);
644 assert (oi && oi->interface);
645
646 if (IS_OSPF6_DEBUG_INTERFACE)
647 zlog_debug ("Interface Event %s: [WaitTimer]",
648 oi->interface->name);
649
650 if (oi->state == OSPF6_INTERFACE_WAITING)
651 ospf6_interface_state_change (dr_election (oi), oi);
652
653 return 0;
654 }
655
656 int
657 backup_seen (struct thread *thread)
658 {
659 struct ospf6_interface *oi;
660
661 oi = (struct ospf6_interface *) THREAD_ARG (thread);
662 assert (oi && oi->interface);
663
664 if (IS_OSPF6_DEBUG_INTERFACE)
665 zlog_debug ("Interface Event %s: [BackupSeen]",
666 oi->interface->name);
667
668 if (oi->state == OSPF6_INTERFACE_WAITING)
669 ospf6_interface_state_change (dr_election (oi), oi);
670
671 return 0;
672 }
673
674 int
675 neighbor_change (struct thread *thread)
676 {
677 struct ospf6_interface *oi;
678
679 oi = (struct ospf6_interface *) THREAD_ARG (thread);
680 assert (oi && oi->interface);
681
682 if (IS_OSPF6_DEBUG_INTERFACE)
683 zlog_debug ("Interface Event %s: [NeighborChange]",
684 oi->interface->name);
685
686 if (oi->state == OSPF6_INTERFACE_DROTHER ||
687 oi->state == OSPF6_INTERFACE_BDR ||
688 oi->state == OSPF6_INTERFACE_DR)
689 ospf6_interface_state_change (dr_election (oi), oi);
690
691 return 0;
692 }
693
694 int
695 interface_down (struct thread *thread)
696 {
697 struct ospf6_interface *oi;
698 struct listnode *node, *nnode;
699 struct ospf6_neighbor *on;
700
701 oi = (struct ospf6_interface *) THREAD_ARG (thread);
702 assert (oi && oi->interface);
703
704 if (IS_OSPF6_DEBUG_INTERFACE)
705 zlog_debug ("Interface Event %s: [InterfaceDown]",
706 oi->interface->name);
707
708 /* Leave AllSPFRouters */
709 if (oi->state > OSPF6_INTERFACE_DOWN)
710 ospf6_leave_allspfrouters (oi->interface->ifindex);
711
712 ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi);
713
714 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
715 ospf6_neighbor_delete (on);
716
717 list_delete_all_node (oi->neighbor_list);
718
719 return 0;
720 }
721
722 \f
723 /* show specified interface structure */
724 static int
725 ospf6_interface_show (struct vty *vty, struct interface *ifp)
726 {
727 struct ospf6_interface *oi;
728 struct connected *c;
729 struct prefix *p;
730 struct listnode *i;
731 char strbuf[64], drouter[32], bdrouter[32];
732 const char *updown[3] = {"down", "up", NULL};
733 const char *type;
734 struct timeval res, now;
735 char duration[32];
736 struct ospf6_lsa *lsa;
737
738 /* check physical interface type */
739 if (if_is_loopback (ifp))
740 type = "LOOPBACK";
741 else if (if_is_broadcast (ifp))
742 type = "BROADCAST";
743 else if (if_is_pointopoint (ifp))
744 type = "POINTOPOINT";
745 else
746 type = "UNKNOWN";
747
748 vty_out (vty, "%s is %s, type %s%s",
749 ifp->name, updown[if_is_up (ifp)], type,
750 VNL);
751 vty_out (vty, " Interface ID: %d%s", ifp->ifindex, VNL);
752
753 if (ifp->info == NULL)
754 {
755 vty_out (vty, " OSPF not enabled on this interface%s", VNL);
756 return 0;
757 }
758 else
759 oi = (struct ospf6_interface *) ifp->info;
760
761 vty_out (vty, " Internet Address:%s", VNL);
762
763 for (ALL_LIST_ELEMENTS_RO (ifp->connected, i, c))
764 {
765 p = c->address;
766 prefix2str (p, strbuf, sizeof (strbuf));
767 switch (p->family)
768 {
769 case AF_INET:
770 vty_out (vty, " inet : %s%s", strbuf,
771 VNL);
772 break;
773 case AF_INET6:
774 vty_out (vty, " inet6: %s%s", strbuf,
775 VNL);
776 break;
777 default:
778 vty_out (vty, " ??? : %s%s", strbuf,
779 VNL);
780 break;
781 }
782 }
783
784 if (oi->area)
785 {
786 vty_out (vty, " Instance ID %d, Interface MTU %d (autodetect: %d)%s",
787 oi->instance_id, oi->ifmtu, ifp->mtu6, VNL);
788 vty_out (vty, " MTU mismatch detection: %s%s", oi->mtu_ignore ?
789 "disabled" : "enabled", VNL);
790 inet_ntop (AF_INET, &oi->area->area_id,
791 strbuf, sizeof (strbuf));
792 vty_out (vty, " Area ID %s, Cost %hu%s", strbuf, oi->cost,
793 VNL);
794 }
795 else
796 vty_out (vty, " Not Attached to Area%s", VNL);
797
798 vty_out (vty, " State %s, Transmit Delay %d sec, Priority %d%s",
799 ospf6_interface_state_str[oi->state],
800 oi->transdelay, oi->priority,
801 VNL);
802 vty_out (vty, " Timer intervals configured:%s", VNL);
803 vty_out (vty, " Hello %d, Dead %d, Retransmit %d%s",
804 oi->hello_interval, oi->dead_interval, oi->rxmt_interval,
805 VNL);
806
807 inet_ntop (AF_INET, &oi->drouter, drouter, sizeof (drouter));
808 inet_ntop (AF_INET, &oi->bdrouter, bdrouter, sizeof (bdrouter));
809 vty_out (vty, " DR: %s BDR: %s%s", drouter, bdrouter, VNL);
810
811 vty_out (vty, " Number of I/F scoped LSAs is %u%s",
812 oi->lsdb->count, VNL);
813
814 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
815
816 timerclear (&res);
817 if (oi->thread_send_lsupdate)
818 timersub (&oi->thread_send_lsupdate->u.sands, &now, &res);
819 timerstring (&res, duration, sizeof (duration));
820 vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
821 oi->lsupdate_list->count, duration,
822 (oi->thread_send_lsupdate ? "on" : "off"),
823 VNL);
824 for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa;
825 lsa = ospf6_lsdb_next (lsa))
826 vty_out (vty, " %s%s", lsa->name, VNL);
827
828 timerclear (&res);
829 if (oi->thread_send_lsack)
830 timersub (&oi->thread_send_lsack->u.sands, &now, &res);
831 timerstring (&res, duration, sizeof (duration));
832 vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
833 oi->lsack_list->count, duration,
834 (oi->thread_send_lsack ? "on" : "off"),
835 VNL);
836 for (lsa = ospf6_lsdb_head (oi->lsack_list); lsa;
837 lsa = ospf6_lsdb_next (lsa))
838 vty_out (vty, " %s%s", lsa->name, VNL);
839
840 return 0;
841 }
842
843 /* show interface */
844 DEFUN (show_ipv6_ospf6_interface,
845 show_ipv6_ospf6_interface_ifname_cmd,
846 "show ipv6 ospf6 interface IFNAME",
847 SHOW_STR
848 IP6_STR
849 OSPF6_STR
850 INTERFACE_STR
851 IFNAME_STR
852 )
853 {
854 struct interface *ifp;
855 struct listnode *i;
856
857 if (argc)
858 {
859 ifp = if_lookup_by_name (argv[0]);
860 if (ifp == NULL)
861 {
862 vty_out (vty, "No such Interface: %s%s", argv[0],
863 VNL);
864 return CMD_WARNING;
865 }
866 ospf6_interface_show (vty, ifp);
867 }
868 else
869 {
870 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
871 ospf6_interface_show (vty, ifp);
872 }
873
874 return CMD_SUCCESS;
875 }
876
877 ALIAS (show_ipv6_ospf6_interface,
878 show_ipv6_ospf6_interface_cmd,
879 "show ipv6 ospf6 interface",
880 SHOW_STR
881 IP6_STR
882 OSPF6_STR
883 INTERFACE_STR
884 )
885
886 DEFUN (show_ipv6_ospf6_interface_ifname_prefix,
887 show_ipv6_ospf6_interface_ifname_prefix_cmd,
888 "show ipv6 ospf6 interface IFNAME prefix",
889 SHOW_STR
890 IP6_STR
891 OSPF6_STR
892 INTERFACE_STR
893 IFNAME_STR
894 "Display connected prefixes to advertise\n"
895 )
896 {
897 struct interface *ifp;
898 struct ospf6_interface *oi;
899
900 ifp = if_lookup_by_name (argv[0]);
901 if (ifp == NULL)
902 {
903 vty_out (vty, "No such Interface: %s%s", argv[0], VNL);
904 return CMD_WARNING;
905 }
906
907 oi = ifp->info;
908 if (oi == NULL)
909 {
910 vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[0], VNL);
911 return CMD_WARNING;
912 }
913
914 argc--;
915 argv++;
916 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
917
918 return CMD_SUCCESS;
919 }
920
921 ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
922 show_ipv6_ospf6_interface_ifname_prefix_detail_cmd,
923 "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)",
924 SHOW_STR
925 IP6_STR
926 OSPF6_STR
927 INTERFACE_STR
928 IFNAME_STR
929 "Display connected prefixes to advertise\n"
930 OSPF6_ROUTE_ADDRESS_STR
931 OSPF6_ROUTE_PREFIX_STR
932 "Dispaly details of the prefixes\n"
933 )
934
935 ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
936 show_ipv6_ospf6_interface_ifname_prefix_match_cmd,
937 "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)",
938 SHOW_STR
939 IP6_STR
940 OSPF6_STR
941 INTERFACE_STR
942 IFNAME_STR
943 "Display connected prefixes to advertise\n"
944 OSPF6_ROUTE_PREFIX_STR
945 OSPF6_ROUTE_MATCH_STR
946 "Dispaly details of the prefixes\n"
947 )
948
949 DEFUN (show_ipv6_ospf6_interface_prefix,
950 show_ipv6_ospf6_interface_prefix_cmd,
951 "show ipv6 ospf6 interface prefix",
952 SHOW_STR
953 IP6_STR
954 OSPF6_STR
955 INTERFACE_STR
956 "Display connected prefixes to advertise\n"
957 )
958 {
959 struct listnode *i;
960 struct ospf6_interface *oi;
961 struct interface *ifp;
962
963 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
964 {
965 oi = (struct ospf6_interface *) ifp->info;
966 if (oi == NULL)
967 continue;
968
969 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
970 }
971
972 return CMD_SUCCESS;
973 }
974
975 ALIAS (show_ipv6_ospf6_interface_prefix,
976 show_ipv6_ospf6_interface_prefix_detail_cmd,
977 "show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)",
978 SHOW_STR
979 IP6_STR
980 OSPF6_STR
981 INTERFACE_STR
982 "Display connected prefixes to advertise\n"
983 OSPF6_ROUTE_ADDRESS_STR
984 OSPF6_ROUTE_PREFIX_STR
985 "Dispaly details of the prefixes\n"
986 )
987
988 ALIAS (show_ipv6_ospf6_interface_prefix,
989 show_ipv6_ospf6_interface_prefix_match_cmd,
990 "show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)",
991 SHOW_STR
992 IP6_STR
993 OSPF6_STR
994 INTERFACE_STR
995 "Display connected prefixes to advertise\n"
996 OSPF6_ROUTE_PREFIX_STR
997 OSPF6_ROUTE_MATCH_STR
998 "Dispaly details of the prefixes\n"
999 )
1000
1001
1002 /* interface variable set command */
1003 DEFUN (ipv6_ospf6_ifmtu,
1004 ipv6_ospf6_ifmtu_cmd,
1005 "ipv6 ospf6 ifmtu <1-65535>",
1006 IP6_STR
1007 OSPF6_STR
1008 "Interface MTU\n"
1009 "OSPFv3 Interface MTU\n"
1010 )
1011 {
1012 struct ospf6_interface *oi;
1013 struct interface *ifp;
1014 unsigned int ifmtu, iobuflen;
1015 struct listnode *node, *nnode;
1016 struct ospf6_neighbor *on;
1017
1018 ifp = (struct interface *) vty->index;
1019 assert (ifp);
1020
1021 oi = (struct ospf6_interface *) ifp->info;
1022 if (oi == NULL)
1023 oi = ospf6_interface_create (ifp);
1024 assert (oi);
1025
1026 ifmtu = strtol (argv[0], NULL, 10);
1027
1028 if (oi->ifmtu == ifmtu)
1029 return CMD_SUCCESS;
1030
1031 if (ifp->mtu6 != 0 && ifp->mtu6 < ifmtu)
1032 {
1033 vty_out (vty, "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)%s",
1034 ifp->name, ifp->mtu6, VNL);
1035 return CMD_WARNING;
1036 }
1037
1038 if (oi->ifmtu < ifmtu)
1039 {
1040 iobuflen = ospf6_iobuf_size (ifmtu);
1041 if (iobuflen < ifmtu)
1042 {
1043 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
1044 ifp->name, iobuflen, VNL);
1045 oi->ifmtu = iobuflen;
1046 }
1047 else
1048 oi->ifmtu = ifmtu;
1049 }
1050 else
1051 oi->ifmtu = ifmtu;
1052
1053 /* re-establish adjacencies */
1054 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
1055 {
1056 THREAD_OFF (on->inactivity_timer);
1057 thread_add_event (master, inactivity_timer, on, 0);
1058 }
1059
1060 return CMD_SUCCESS;
1061 }
1062
1063 DEFUN (no_ipv6_ospf6_ifmtu,
1064 no_ipv6_ospf6_ifmtu_cmd,
1065 "no ipv6 ospf6 ifmtu",
1066 NO_STR
1067 IP6_STR
1068 OSPF6_STR
1069 "Interface MTU\n"
1070 )
1071 {
1072 struct ospf6_interface *oi;
1073 struct interface *ifp;
1074 unsigned int iobuflen;
1075 struct listnode *node, *nnode;
1076 struct ospf6_neighbor *on;
1077
1078 ifp = (struct interface *) vty->index;
1079 assert (ifp);
1080
1081 oi = (struct ospf6_interface *) ifp->info;
1082 if (oi == NULL)
1083 oi = ospf6_interface_create (ifp);
1084 assert (oi);
1085
1086 if (oi->ifmtu < ifp->mtu)
1087 {
1088 iobuflen = ospf6_iobuf_size (ifp->mtu);
1089 if (iobuflen < ifp->mtu)
1090 {
1091 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
1092 ifp->name, iobuflen, VNL);
1093 oi->ifmtu = iobuflen;
1094 }
1095 else
1096 oi->ifmtu = ifp->mtu;
1097 }
1098 else
1099 oi->ifmtu = ifp->mtu;
1100
1101 /* re-establish adjacencies */
1102 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
1103 {
1104 THREAD_OFF (on->inactivity_timer);
1105 thread_add_event (master, inactivity_timer, on, 0);
1106 }
1107
1108 return CMD_SUCCESS;
1109 }
1110
1111 DEFUN (ipv6_ospf6_cost,
1112 ipv6_ospf6_cost_cmd,
1113 "ipv6 ospf6 cost <1-65535>",
1114 IP6_STR
1115 OSPF6_STR
1116 "Interface cost\n"
1117 "Outgoing metric of this interface\n"
1118 )
1119 {
1120 struct ospf6_interface *oi;
1121 struct interface *ifp;
1122 unsigned long int lcost;
1123
1124 ifp = (struct interface *) vty->index;
1125 assert (ifp);
1126
1127 oi = (struct ospf6_interface *) ifp->info;
1128 if (oi == NULL)
1129 oi = ospf6_interface_create (ifp);
1130 assert (oi);
1131
1132 lcost = strtol (argv[0], NULL, 10);
1133
1134 if (lcost > UINT32_MAX)
1135 {
1136 vty_out (vty, "Cost %ld is out of range%s", lcost, VNL);
1137 return CMD_WARNING;
1138 }
1139
1140 if (oi->cost == lcost)
1141 return CMD_SUCCESS;
1142
1143 oi->cost = lcost;
1144
1145 /* update cost held in route_connected list in ospf6_interface */
1146 ospf6_interface_connected_route_update (oi->interface);
1147
1148 /* execute LSA hooks */
1149 if (oi->area)
1150 {
1151 OSPF6_LINK_LSA_SCHEDULE (oi);
1152 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
1153 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1154 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1155 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
1156 }
1157
1158 return CMD_SUCCESS;
1159 }
1160
1161 DEFUN (ipv6_ospf6_hellointerval,
1162 ipv6_ospf6_hellointerval_cmd,
1163 "ipv6 ospf6 hello-interval <1-65535>",
1164 IP6_STR
1165 OSPF6_STR
1166 "Interval time of Hello packets\n"
1167 SECONDS_STR
1168 )
1169 {
1170 struct ospf6_interface *oi;
1171 struct interface *ifp;
1172
1173 ifp = (struct interface *) vty->index;
1174 assert (ifp);
1175
1176 oi = (struct ospf6_interface *) ifp->info;
1177 if (oi == NULL)
1178 oi = ospf6_interface_create (ifp);
1179 assert (oi);
1180
1181 oi->hello_interval = strtol (argv[0], NULL, 10);
1182 return CMD_SUCCESS;
1183 }
1184
1185 /* interface variable set command */
1186 DEFUN (ipv6_ospf6_deadinterval,
1187 ipv6_ospf6_deadinterval_cmd,
1188 "ipv6 ospf6 dead-interval <1-65535>",
1189 IP6_STR
1190 OSPF6_STR
1191 "Interval time after which a neighbor is declared down\n"
1192 SECONDS_STR
1193 )
1194 {
1195 struct ospf6_interface *oi;
1196 struct interface *ifp;
1197
1198 ifp = (struct interface *) vty->index;
1199 assert (ifp);
1200
1201 oi = (struct ospf6_interface *) ifp->info;
1202 if (oi == NULL)
1203 oi = ospf6_interface_create (ifp);
1204 assert (oi);
1205
1206 oi->dead_interval = strtol (argv[0], NULL, 10);
1207 return CMD_SUCCESS;
1208 }
1209
1210 /* interface variable set command */
1211 DEFUN (ipv6_ospf6_transmitdelay,
1212 ipv6_ospf6_transmitdelay_cmd,
1213 "ipv6 ospf6 transmit-delay <1-3600>",
1214 IP6_STR
1215 OSPF6_STR
1216 "Transmit delay of this interface\n"
1217 SECONDS_STR
1218 )
1219 {
1220 struct ospf6_interface *oi;
1221 struct interface *ifp;
1222
1223 ifp = (struct interface *) vty->index;
1224 assert (ifp);
1225
1226 oi = (struct ospf6_interface *) ifp->info;
1227 if (oi == NULL)
1228 oi = ospf6_interface_create (ifp);
1229 assert (oi);
1230
1231 oi->transdelay = strtol (argv[0], NULL, 10);
1232 return CMD_SUCCESS;
1233 }
1234
1235 /* interface variable set command */
1236 DEFUN (ipv6_ospf6_retransmitinterval,
1237 ipv6_ospf6_retransmitinterval_cmd,
1238 "ipv6 ospf6 retransmit-interval <1-65535>",
1239 IP6_STR
1240 OSPF6_STR
1241 "Time between retransmitting lost link state advertisements\n"
1242 SECONDS_STR
1243 )
1244 {
1245 struct ospf6_interface *oi;
1246 struct interface *ifp;
1247
1248 ifp = (struct interface *) vty->index;
1249 assert (ifp);
1250
1251 oi = (struct ospf6_interface *) ifp->info;
1252 if (oi == NULL)
1253 oi = ospf6_interface_create (ifp);
1254 assert (oi);
1255
1256 oi->rxmt_interval = strtol (argv[0], NULL, 10);
1257 return CMD_SUCCESS;
1258 }
1259
1260 /* interface variable set command */
1261 DEFUN (ipv6_ospf6_priority,
1262 ipv6_ospf6_priority_cmd,
1263 "ipv6 ospf6 priority <0-255>",
1264 IP6_STR
1265 OSPF6_STR
1266 "Router priority\n"
1267 "Priority value\n"
1268 )
1269 {
1270 struct ospf6_interface *oi;
1271 struct interface *ifp;
1272
1273 ifp = (struct interface *) vty->index;
1274 assert (ifp);
1275
1276 oi = (struct ospf6_interface *) ifp->info;
1277 if (oi == NULL)
1278 oi = ospf6_interface_create (ifp);
1279 assert (oi);
1280
1281 oi->priority = strtol (argv[0], NULL, 10);
1282
1283 if (oi->area)
1284 ospf6_interface_state_change (dr_election (oi), oi);
1285
1286 return CMD_SUCCESS;
1287 }
1288
1289 DEFUN (ipv6_ospf6_instance,
1290 ipv6_ospf6_instance_cmd,
1291 "ipv6 ospf6 instance-id <0-255>",
1292 IP6_STR
1293 OSPF6_STR
1294 "Instance ID for this interface\n"
1295 "Instance ID value\n"
1296 )
1297 {
1298 struct ospf6_interface *oi;
1299 struct interface *ifp;
1300
1301 ifp = (struct interface *)vty->index;
1302 assert (ifp);
1303
1304 oi = (struct ospf6_interface *)ifp->info;
1305 if (oi == NULL)
1306 oi = ospf6_interface_create (ifp);
1307 assert (oi);
1308
1309 oi->instance_id = strtol (argv[0], NULL, 10);
1310 return CMD_SUCCESS;
1311 }
1312
1313 DEFUN (ipv6_ospf6_passive,
1314 ipv6_ospf6_passive_cmd,
1315 "ipv6 ospf6 passive",
1316 IP6_STR
1317 OSPF6_STR
1318 "passive interface, No adjacency will be formed on this interface\n"
1319 )
1320 {
1321 struct ospf6_interface *oi;
1322 struct interface *ifp;
1323 struct listnode *node, *nnode;
1324 struct ospf6_neighbor *on;
1325
1326 ifp = (struct interface *) vty->index;
1327 assert (ifp);
1328
1329 oi = (struct ospf6_interface *) ifp->info;
1330 if (oi == NULL)
1331 oi = ospf6_interface_create (ifp);
1332 assert (oi);
1333
1334 SET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1335 THREAD_OFF (oi->thread_send_hello);
1336
1337 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
1338 {
1339 THREAD_OFF (on->inactivity_timer);
1340 thread_add_event (master, inactivity_timer, on, 0);
1341 }
1342
1343 return CMD_SUCCESS;
1344 }
1345
1346 DEFUN (no_ipv6_ospf6_passive,
1347 no_ipv6_ospf6_passive_cmd,
1348 "no ipv6 ospf6 passive",
1349 NO_STR
1350 IP6_STR
1351 OSPF6_STR
1352 "passive interface: No Adjacency will be formed on this I/F\n"
1353 )
1354 {
1355 struct ospf6_interface *oi;
1356 struct interface *ifp;
1357
1358 ifp = (struct interface *) vty->index;
1359 assert (ifp);
1360
1361 oi = (struct ospf6_interface *) ifp->info;
1362 if (oi == NULL)
1363 oi = ospf6_interface_create (ifp);
1364 assert (oi);
1365
1366 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1367 THREAD_OFF (oi->thread_send_hello);
1368 oi->thread_send_hello =
1369 thread_add_event (master, ospf6_hello_send, oi, 0);
1370
1371 return CMD_SUCCESS;
1372 }
1373
1374 DEFUN (ipv6_ospf6_mtu_ignore,
1375 ipv6_ospf6_mtu_ignore_cmd,
1376 "ipv6 ospf6 mtu-ignore",
1377 IP6_STR
1378 OSPF6_STR
1379 "Ignore MTU mismatch on this interface\n"
1380 )
1381 {
1382 struct ospf6_interface *oi;
1383 struct interface *ifp;
1384
1385 ifp = (struct interface *) vty->index;
1386 assert (ifp);
1387
1388 oi = (struct ospf6_interface *) ifp->info;
1389 if (oi == NULL)
1390 oi = ospf6_interface_create (ifp);
1391 assert (oi);
1392
1393 oi->mtu_ignore = 1;
1394
1395 return CMD_SUCCESS;
1396 }
1397
1398 DEFUN (no_ipv6_ospf6_mtu_ignore,
1399 no_ipv6_ospf6_mtu_ignore_cmd,
1400 "no ipv6 ospf6 mtu-ignore",
1401 NO_STR
1402 IP6_STR
1403 OSPF6_STR
1404 "Ignore MTU mismatch on this interface\n"
1405 )
1406 {
1407 struct ospf6_interface *oi;
1408 struct interface *ifp;
1409
1410 ifp = (struct interface *) vty->index;
1411 assert (ifp);
1412
1413 oi = (struct ospf6_interface *) ifp->info;
1414 if (oi == NULL)
1415 oi = ospf6_interface_create (ifp);
1416 assert (oi);
1417
1418 oi->mtu_ignore = 0;
1419
1420 return CMD_SUCCESS;
1421 }
1422
1423 DEFUN (ipv6_ospf6_advertise_prefix_list,
1424 ipv6_ospf6_advertise_prefix_list_cmd,
1425 "ipv6 ospf6 advertise prefix-list WORD",
1426 IP6_STR
1427 OSPF6_STR
1428 "Advertising options\n"
1429 "Filter prefix using prefix-list\n"
1430 "Prefix list name\n"
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 if (oi->plist_name)
1445 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1446 oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]);
1447
1448 ospf6_interface_connected_route_update (oi->interface);
1449
1450 if (oi->area)
1451 {
1452 OSPF6_LINK_LSA_SCHEDULE (oi);
1453 if (oi->state == OSPF6_INTERFACE_DR)
1454 {
1455 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1456 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1457 }
1458 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
1459 }
1460
1461 return CMD_SUCCESS;
1462 }
1463
1464 DEFUN (no_ipv6_ospf6_advertise_prefix_list,
1465 no_ipv6_ospf6_advertise_prefix_list_cmd,
1466 "no ipv6 ospf6 advertise prefix-list",
1467 NO_STR
1468 IP6_STR
1469 OSPF6_STR
1470 "Advertising options\n"
1471 "Filter prefix using prefix-list\n"
1472 )
1473 {
1474 struct ospf6_interface *oi;
1475 struct interface *ifp;
1476
1477 ifp = (struct interface *) vty->index;
1478 assert (ifp);
1479
1480 oi = (struct ospf6_interface *) ifp->info;
1481 if (oi == NULL)
1482 oi = ospf6_interface_create (ifp);
1483 assert (oi);
1484
1485 if (oi->plist_name)
1486 {
1487 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1488 oi->plist_name = NULL;
1489 }
1490
1491 ospf6_interface_connected_route_update (oi->interface);
1492
1493 if (oi->area)
1494 {
1495 OSPF6_LINK_LSA_SCHEDULE (oi);
1496 if (oi->state == OSPF6_INTERFACE_DR)
1497 {
1498 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1499 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1500 }
1501 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
1502 }
1503
1504 return CMD_SUCCESS;
1505 }
1506
1507 static int
1508 config_write_ospf6_interface (struct vty *vty)
1509 {
1510 struct listnode *i;
1511 struct ospf6_interface *oi;
1512 struct interface *ifp;
1513
1514 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
1515 {
1516 oi = (struct ospf6_interface *) ifp->info;
1517 if (oi == NULL)
1518 continue;
1519
1520 vty_out (vty, "interface %s%s",
1521 oi->interface->name, VNL);
1522
1523 if (ifp->desc)
1524 vty_out (vty, " description %s%s", ifp->desc, VNL);
1525
1526 if (ifp->mtu6 != oi->ifmtu)
1527 vty_out (vty, " ipv6 ospf6 ifmtu %d%s", oi->ifmtu, VNL);
1528 vty_out (vty, " ipv6 ospf6 cost %d%s",
1529 oi->cost, VNL);
1530 vty_out (vty, " ipv6 ospf6 hello-interval %d%s",
1531 oi->hello_interval, VNL);
1532 vty_out (vty, " ipv6 ospf6 dead-interval %d%s",
1533 oi->dead_interval, VNL);
1534 vty_out (vty, " ipv6 ospf6 retransmit-interval %d%s",
1535 oi->rxmt_interval, VNL);
1536 vty_out (vty, " ipv6 ospf6 priority %d%s",
1537 oi->priority, VNL);
1538 vty_out (vty, " ipv6 ospf6 transmit-delay %d%s",
1539 oi->transdelay, VNL);
1540 vty_out (vty, " ipv6 ospf6 instance-id %d%s",
1541 oi->instance_id, VNL);
1542
1543 if (oi->plist_name)
1544 vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s",
1545 oi->plist_name, VNL);
1546
1547 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
1548 vty_out (vty, " ipv6 ospf6 passive%s", VNL);
1549
1550 if (oi->mtu_ignore)
1551 vty_out (vty, " ipv6 ospf6 mtu-ignore%s", VNL);
1552
1553 vty_out (vty, "!%s", VNL);
1554 }
1555 return 0;
1556 }
1557
1558 static struct cmd_node interface_node =
1559 {
1560 INTERFACE_NODE,
1561 "%s(config-if)# ",
1562 1 /* VTYSH */
1563 };
1564
1565 void
1566 ospf6_interface_init (void)
1567 {
1568 /* Install interface node. */
1569 install_node (&interface_node, config_write_ospf6_interface);
1570
1571 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd);
1572 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1573 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1574 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
1575 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
1576 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1577 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1578 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
1579 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_cmd);
1580 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1581 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1582 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
1583 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
1584 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1585 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1586 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
1587
1588 install_element (CONFIG_NODE, &interface_cmd);
1589 install_default (INTERFACE_NODE);
1590 install_element (INTERFACE_NODE, &interface_desc_cmd);
1591 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
1592 install_element (INTERFACE_NODE, &ipv6_ospf6_cost_cmd);
1593 install_element (INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd);
1594 install_element (INTERFACE_NODE, &no_ipv6_ospf6_ifmtu_cmd);
1595 install_element (INTERFACE_NODE, &ipv6_ospf6_deadinterval_cmd);
1596 install_element (INTERFACE_NODE, &ipv6_ospf6_hellointerval_cmd);
1597 install_element (INTERFACE_NODE, &ipv6_ospf6_priority_cmd);
1598 install_element (INTERFACE_NODE, &ipv6_ospf6_retransmitinterval_cmd);
1599 install_element (INTERFACE_NODE, &ipv6_ospf6_transmitdelay_cmd);
1600 install_element (INTERFACE_NODE, &ipv6_ospf6_instance_cmd);
1601
1602 install_element (INTERFACE_NODE, &ipv6_ospf6_passive_cmd);
1603 install_element (INTERFACE_NODE, &no_ipv6_ospf6_passive_cmd);
1604
1605 install_element (INTERFACE_NODE, &ipv6_ospf6_mtu_ignore_cmd);
1606 install_element (INTERFACE_NODE, &no_ipv6_ospf6_mtu_ignore_cmd);
1607
1608 install_element (INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd);
1609 install_element (INTERFACE_NODE, &no_ipv6_ospf6_advertise_prefix_list_cmd);
1610 }
1611
1612 DEFUN (debug_ospf6_interface,
1613 debug_ospf6_interface_cmd,
1614 "debug ospf6 interface",
1615 DEBUG_STR
1616 OSPF6_STR
1617 "Debug OSPFv3 Interface\n"
1618 )
1619 {
1620 OSPF6_DEBUG_INTERFACE_ON ();
1621 return CMD_SUCCESS;
1622 }
1623
1624 DEFUN (no_debug_ospf6_interface,
1625 no_debug_ospf6_interface_cmd,
1626 "no debug ospf6 interface",
1627 NO_STR
1628 DEBUG_STR
1629 OSPF6_STR
1630 "Debug OSPFv3 Interface\n"
1631 )
1632 {
1633 OSPF6_DEBUG_INTERFACE_OFF ();
1634 return CMD_SUCCESS;
1635 }
1636
1637 int
1638 config_write_ospf6_debug_interface (struct vty *vty)
1639 {
1640 if (IS_OSPF6_DEBUG_INTERFACE)
1641 vty_out (vty, "debug ospf6 interface%s", VNL);
1642 return 0;
1643 }
1644
1645 void
1646 install_element_ospf6_debug_interface (void)
1647 {
1648 install_element (ENABLE_NODE, &debug_ospf6_interface_cmd);
1649 install_element (ENABLE_NODE, &no_debug_ospf6_interface_cmd);
1650 install_element (CONFIG_NODE, &debug_ospf6_interface_cmd);
1651 install_element (CONFIG_NODE, &no_debug_ospf6_interface_cmd);
1652 }
1653
1654