2 * Copyright (C) 2003 Yasuhiro Ohara
4 * This file is part of GNU Zebra.
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
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.
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.
34 #include "ospf6_lsa.h"
35 #include "ospf6_lsdb.h"
36 #include "ospf6_network.h"
37 #include "ospf6_message.h"
38 #include "ospf6_route.h"
39 #include "ospf6_top.h"
40 #include "ospf6_area.h"
41 #include "ospf6_interface.h"
42 #include "ospf6_neighbor.h"
43 #include "ospf6_intra.h"
44 #include "ospf6_spf.h"
46 #include "ospf6_bfd.h"
48 unsigned char conf_debug_ospf6_interface
= 0;
50 const char *ospf6_interface_state_str
[] =
63 struct ospf6_interface
*
64 ospf6_interface_lookup_by_ifindex (int ifindex
)
66 struct ospf6_interface
*oi
;
67 struct interface
*ifp
;
69 ifp
= if_lookup_by_index (ifindex
);
71 return (struct ospf6_interface
*) NULL
;
73 oi
= (struct ospf6_interface
*) ifp
->info
;
77 /* schedule routing table recalculation */
79 ospf6_interface_lsdb_hook (struct ospf6_lsa
*lsa
, unsigned int reason
)
81 struct ospf6_interface
*oi
;
87 switch (ntohs (lsa
->header
->type
))
89 case OSPF6_LSTYPE_LINK
:
90 if (oi
->state
== OSPF6_INTERFACE_DR
)
91 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi
);
92 ospf6_spf_schedule (oi
->area
->ospf6
, reason
);
101 ospf6_interface_lsdb_hook_add (struct ospf6_lsa
*lsa
)
103 ospf6_interface_lsdb_hook(lsa
, ospf6_lsadd_to_spf_reason(lsa
));
107 ospf6_interface_lsdb_hook_remove (struct ospf6_lsa
*lsa
)
109 ospf6_interface_lsdb_hook(lsa
, ospf6_lsremove_to_spf_reason(lsa
));
113 ospf6_default_iftype(struct interface
*ifp
)
115 if (if_is_pointopoint (ifp
))
116 return OSPF_IFTYPE_POINTOPOINT
;
117 else if (if_is_loopback (ifp
))
118 return OSPF_IFTYPE_LOOPBACK
;
120 return OSPF_IFTYPE_BROADCAST
;
124 ospf6_interface_get_cost (struct ospf6_interface
*oi
)
126 /* If all else fails, use default OSPF cost */
130 bw
= oi
->interface
->bandwidth
? oi
->interface
->bandwidth
: OSPF6_INTERFACE_BANDWIDTH
;
131 refbw
= ospf6
? ospf6
->ref_bandwidth
: OSPF6_REFERENCE_BANDWIDTH
;
133 /* A specifed ip ospf cost overrides a calculated one. */
134 if (CHECK_FLAG (oi
->flag
, OSPF6_INTERFACE_NOAUTOCOST
))
138 cost
= (u_int32_t
) ((double)refbw
/ (double)bw
+ (double)0.5);
139 if (cost
< 1) cost
= 1;
140 else if (cost
> UINT32_MAX
) cost
= UINT32_MAX
;
147 ospf6_interface_recalculate_cost (struct ospf6_interface
*oi
)
151 newcost
= ospf6_interface_get_cost (oi
);
152 if (newcost
== oi
->cost
) return;
155 /* update cost held in route_connected list in ospf6_interface */
156 ospf6_interface_connected_route_update (oi
->interface
);
158 /* execute LSA hooks */
161 OSPF6_LINK_LSA_SCHEDULE (oi
);
162 OSPF6_ROUTER_LSA_SCHEDULE (oi
->area
);
163 OSPF6_NETWORK_LSA_SCHEDULE (oi
);
164 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi
);
165 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi
->area
);
169 /* Create new ospf6 interface structure */
170 struct ospf6_interface
*
171 ospf6_interface_create (struct interface
*ifp
)
173 struct ospf6_interface
*oi
;
174 unsigned int iobuflen
;
176 oi
= (struct ospf6_interface
*)
177 XCALLOC (MTYPE_OSPF6_IF
, sizeof (struct ospf6_interface
));
181 zlog_err ("Can't malloc ospf6_interface for ifindex %d", ifp
->ifindex
);
182 return (struct ospf6_interface
*) NULL
;
185 oi
->area
= (struct ospf6_area
*) NULL
;
186 oi
->neighbor_list
= list_new ();
187 oi
->neighbor_list
->cmp
= ospf6_neighbor_cmp
;
188 oi
->linklocal_addr
= (struct in6_addr
*) NULL
;
189 oi
->instance_id
= OSPF6_INTERFACE_INSTANCE_ID
;
190 oi
->transdelay
= OSPF6_INTERFACE_TRANSDELAY
;
191 oi
->priority
= OSPF6_INTERFACE_PRIORITY
;
193 oi
->hello_interval
= OSPF_HELLO_INTERVAL_DEFAULT
;
194 oi
->dead_interval
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
195 oi
->rxmt_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
196 oi
->type
= ospf6_default_iftype (ifp
);
197 oi
->state
= OSPF6_INTERFACE_DOWN
;
201 /* Try to adjust I/O buffer size with IfMtu */
202 oi
->ifmtu
= ifp
->mtu6
;
203 iobuflen
= ospf6_iobuf_size (ifp
->mtu6
);
204 if (oi
->ifmtu
> iobuflen
)
206 if (IS_OSPF6_DEBUG_INTERFACE
)
207 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
208 ifp
->name
, iobuflen
);
209 oi
->ifmtu
= iobuflen
;
212 oi
->lsupdate_list
= ospf6_lsdb_create (oi
);
213 oi
->lsack_list
= ospf6_lsdb_create (oi
);
214 oi
->lsdb
= ospf6_lsdb_create (oi
);
215 oi
->lsdb
->hook_add
= ospf6_interface_lsdb_hook_add
;
216 oi
->lsdb
->hook_remove
= ospf6_interface_lsdb_hook_remove
;
217 oi
->lsdb_self
= ospf6_lsdb_create (oi
);
219 oi
->route_connected
= OSPF6_ROUTE_TABLE_CREATE (INTERFACE
, CONNECTED_ROUTES
);
220 oi
->route_connected
->scope
= oi
;
227 oi
->cost
= ospf6_interface_get_cost(oi
);
233 ospf6_interface_delete (struct ospf6_interface
*oi
)
235 struct listnode
*node
, *nnode
;
236 struct ospf6_neighbor
*on
;
238 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
239 ospf6_neighbor_delete (on
);
241 list_delete (oi
->neighbor_list
);
243 THREAD_OFF (oi
->thread_send_hello
);
244 THREAD_OFF (oi
->thread_send_lsupdate
);
245 THREAD_OFF (oi
->thread_send_lsack
);
247 ospf6_lsdb_remove_all (oi
->lsdb
);
248 ospf6_lsdb_remove_all (oi
->lsupdate_list
);
249 ospf6_lsdb_remove_all (oi
->lsack_list
);
251 ospf6_lsdb_delete (oi
->lsdb
);
252 ospf6_lsdb_delete (oi
->lsdb_self
);
254 ospf6_lsdb_delete (oi
->lsupdate_list
);
255 ospf6_lsdb_delete (oi
->lsack_list
);
257 ospf6_route_table_delete (oi
->route_connected
);
260 oi
->interface
->info
= NULL
;
264 XFREE (MTYPE_PREFIX_LIST_STR
, oi
->plist_name
);
266 bfd_info_free(&(oi
->bfd_info
));
268 XFREE (MTYPE_OSPF6_IF
, oi
);
272 ospf6_interface_enable (struct ospf6_interface
*oi
)
274 UNSET_FLAG (oi
->flag
, OSPF6_INTERFACE_DISABLE
);
275 ospf6_interface_state_update (oi
->interface
);
279 ospf6_interface_disable (struct ospf6_interface
*oi
)
281 SET_FLAG (oi
->flag
, OSPF6_INTERFACE_DISABLE
);
283 thread_execute (master
, interface_down
, oi
, 0);
285 ospf6_lsdb_remove_all (oi
->lsdb
);
286 ospf6_lsdb_remove_all (oi
->lsdb_self
);
287 ospf6_lsdb_remove_all (oi
->lsupdate_list
);
288 ospf6_lsdb_remove_all (oi
->lsack_list
);
290 THREAD_OFF (oi
->thread_send_hello
);
291 THREAD_OFF (oi
->thread_send_lsupdate
);
292 THREAD_OFF (oi
->thread_send_lsack
);
294 THREAD_OFF (oi
->thread_network_lsa
);
295 THREAD_OFF (oi
->thread_link_lsa
);
296 THREAD_OFF (oi
->thread_intra_prefix_lsa
);
299 static struct in6_addr
*
300 ospf6_interface_get_linklocal_address (struct interface
*ifp
)
304 struct in6_addr
*l
= (struct in6_addr
*) NULL
;
306 /* for each connected address */
307 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, n
, c
))
309 /* if family not AF_INET6, ignore */
310 if (c
->address
->family
!= AF_INET6
)
313 /* linklocal scope check */
314 if (IN6_IS_ADDR_LINKLOCAL (&c
->address
->u
.prefix6
))
315 l
= &c
->address
->u
.prefix6
;
321 ospf6_interface_if_add (struct interface
*ifp
)
323 struct ospf6_interface
*oi
;
324 unsigned int iobuflen
;
326 oi
= (struct ospf6_interface
*) ifp
->info
;
330 /* Try to adjust I/O buffer size with IfMtu */
332 oi
->ifmtu
= ifp
->mtu6
;
333 iobuflen
= ospf6_iobuf_size (ifp
->mtu6
);
334 if (oi
->ifmtu
> iobuflen
)
336 if (IS_OSPF6_DEBUG_INTERFACE
)
337 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
338 ifp
->name
, iobuflen
);
339 oi
->ifmtu
= iobuflen
;
342 /* interface start */
343 ospf6_interface_state_update(oi
->interface
);
347 ospf6_interface_if_del (struct interface
*ifp
)
349 struct ospf6_interface
*oi
;
351 oi
= (struct ospf6_interface
*) ifp
->info
;
357 thread_execute (master
, interface_down
, oi
, 0);
359 listnode_delete (oi
->area
->if_list
, oi
);
360 oi
->area
= (struct ospf6_area
*) NULL
;
363 oi
->interface
= NULL
;
366 ospf6_interface_delete (oi
);
370 ospf6_interface_state_update (struct interface
*ifp
)
372 struct ospf6_interface
*oi
;
374 oi
= (struct ospf6_interface
*) ifp
->info
;
377 if (oi
->area
== NULL
)
379 if (CHECK_FLAG (oi
->flag
, OSPF6_INTERFACE_DISABLE
))
382 if (if_is_operative (ifp
)
383 && (ospf6_interface_get_linklocal_address(oi
->interface
)
384 || if_is_loopback(oi
->interface
)))
385 thread_add_event (master
, interface_up
, oi
, 0);
387 thread_add_event (master
, interface_down
, oi
, 0);
393 ospf6_interface_connected_route_update (struct interface
*ifp
)
395 struct ospf6_interface
*oi
;
396 struct ospf6_route
*route
;
398 struct listnode
*node
, *nnode
;
399 struct in6_addr nh_addr
;
401 oi
= (struct ospf6_interface
*) ifp
->info
;
405 /* reset linklocal pointer */
406 oi
->linklocal_addr
= ospf6_interface_get_linklocal_address (ifp
);
408 /* if area is null, do not make connected-route list */
409 if (oi
->area
== NULL
)
412 if (CHECK_FLAG (oi
->flag
, OSPF6_INTERFACE_DISABLE
))
415 /* update "route to advertise" interface route table */
416 ospf6_route_remove_all (oi
->route_connected
);
418 for (ALL_LIST_ELEMENTS (oi
->interface
->connected
, node
, nnode
, c
))
420 if (c
->address
->family
!= AF_INET6
)
423 CONTINUE_IF_ADDRESS_LINKLOCAL (IS_OSPF6_DEBUG_INTERFACE
, c
->address
);
424 CONTINUE_IF_ADDRESS_UNSPECIFIED (IS_OSPF6_DEBUG_INTERFACE
, c
->address
);
425 CONTINUE_IF_ADDRESS_LOOPBACK (IS_OSPF6_DEBUG_INTERFACE
, c
->address
);
426 CONTINUE_IF_ADDRESS_V4COMPAT (IS_OSPF6_DEBUG_INTERFACE
, c
->address
);
427 CONTINUE_IF_ADDRESS_V4MAPPED (IS_OSPF6_DEBUG_INTERFACE
, c
->address
);
432 struct prefix_list
*plist
;
433 enum prefix_list_type ret
;
436 prefix2str (c
->address
, buf
, sizeof (buf
));
437 plist
= prefix_list_lookup (AFI_IP6
, oi
->plist_name
);
438 ret
= prefix_list_apply (plist
, (void *) c
->address
);
439 if (ret
== PREFIX_DENY
)
441 if (IS_OSPF6_DEBUG_INTERFACE
)
442 zlog_debug ("%s on %s filtered by prefix-list %s ",
443 buf
, oi
->interface
->name
, oi
->plist_name
);
448 route
= ospf6_route_create ();
449 memcpy (&route
->prefix
, c
->address
, sizeof (struct prefix
));
450 apply_mask (&route
->prefix
);
451 route
->type
= OSPF6_DEST_TYPE_NETWORK
;
452 route
->path
.area_id
= oi
->area
->area_id
;
453 route
->path
.type
= OSPF6_PATH_TYPE_INTRA
;
454 route
->path
.cost
= oi
->cost
;
455 inet_pton (AF_INET6
, "::1", &nh_addr
);
456 ospf6_route_add_nexthop (route
, oi
->interface
->ifindex
, &nh_addr
);
457 ospf6_route_add (route
, oi
->route_connected
);
460 /* create new Link-LSA */
461 OSPF6_LINK_LSA_SCHEDULE (oi
);
462 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi
);
463 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi
->area
);
467 ospf6_interface_state_change (u_char next_state
, struct ospf6_interface
*oi
)
471 prev_state
= oi
->state
;
472 oi
->state
= next_state
;
474 if (prev_state
== next_state
)
478 if (IS_OSPF6_DEBUG_INTERFACE
)
480 zlog_debug ("Interface state change %s: %s -> %s", oi
->interface
->name
,
481 ospf6_interface_state_str
[prev_state
],
482 ospf6_interface_state_str
[next_state
]);
486 if ((prev_state
== OSPF6_INTERFACE_DR
||
487 prev_state
== OSPF6_INTERFACE_BDR
) &&
488 (next_state
!= OSPF6_INTERFACE_DR
&&
489 next_state
!= OSPF6_INTERFACE_BDR
))
490 ospf6_sso (oi
->interface
->ifindex
, &alldrouters6
, IPV6_LEAVE_GROUP
);
492 if ((prev_state
!= OSPF6_INTERFACE_DR
&&
493 prev_state
!= OSPF6_INTERFACE_BDR
) &&
494 (next_state
== OSPF6_INTERFACE_DR
||
495 next_state
== OSPF6_INTERFACE_BDR
))
496 ospf6_sso (oi
->interface
->ifindex
, &alldrouters6
, IPV6_JOIN_GROUP
);
498 OSPF6_ROUTER_LSA_SCHEDULE (oi
->area
);
499 if (next_state
== OSPF6_INTERFACE_DOWN
)
501 OSPF6_NETWORK_LSA_EXECUTE (oi
);
502 OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT (oi
);
503 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi
->area
);
505 else if (prev_state
== OSPF6_INTERFACE_DR
||
506 next_state
== OSPF6_INTERFACE_DR
)
508 OSPF6_NETWORK_LSA_SCHEDULE (oi
);
509 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi
);
510 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi
->area
);
514 /* Terminal state or regression */
515 if ((next_state
== OSPF6_INTERFACE_POINTTOPOINT
) ||
516 (next_state
== OSPF6_INTERFACE_DROTHER
) ||
517 (next_state
== OSPF6_INTERFACE_BDR
) ||
518 (next_state
== OSPF6_INTERFACE_DR
) ||
519 (next_state
< prev_state
))
520 ospf6TrapIfStateChange (oi
);
526 /* DR Election, RFC2328 section 9.4 */
528 #define IS_ELIGIBLE(n) \
529 ((n)->state >= OSPF6_NEIGHBOR_TWOWAY && (n)->priority != 0)
531 static struct ospf6_neighbor
*
532 better_bdrouter (struct ospf6_neighbor
*a
, struct ospf6_neighbor
*b
)
534 if ((a
== NULL
|| ! IS_ELIGIBLE (a
) || a
->drouter
== a
->router_id
) &&
535 (b
== NULL
|| ! IS_ELIGIBLE (b
) || b
->drouter
== b
->router_id
))
537 else if (a
== NULL
|| ! IS_ELIGIBLE (a
) || a
->drouter
== a
->router_id
)
539 else if (b
== NULL
|| ! IS_ELIGIBLE (b
) || b
->drouter
== b
->router_id
)
542 if (a
->bdrouter
== a
->router_id
&& b
->bdrouter
!= b
->router_id
)
544 if (a
->bdrouter
!= a
->router_id
&& b
->bdrouter
== b
->router_id
)
547 if (a
->priority
> b
->priority
)
549 if (a
->priority
< b
->priority
)
552 if (ntohl (a
->router_id
) > ntohl (b
->router_id
))
554 if (ntohl (a
->router_id
) < ntohl (b
->router_id
))
557 zlog_warn ("Router-ID duplicate ?");
561 static struct ospf6_neighbor
*
562 better_drouter (struct ospf6_neighbor
*a
, struct ospf6_neighbor
*b
)
564 if ((a
== NULL
|| ! IS_ELIGIBLE (a
) || a
->drouter
!= a
->router_id
) &&
565 (b
== NULL
|| ! IS_ELIGIBLE (b
) || b
->drouter
!= b
->router_id
))
567 else if (a
== NULL
|| ! IS_ELIGIBLE (a
) || a
->drouter
!= a
->router_id
)
569 else if (b
== NULL
|| ! IS_ELIGIBLE (b
) || b
->drouter
!= b
->router_id
)
572 if (a
->drouter
== a
->router_id
&& b
->drouter
!= b
->router_id
)
574 if (a
->drouter
!= a
->router_id
&& b
->drouter
== b
->router_id
)
577 if (a
->priority
> b
->priority
)
579 if (a
->priority
< b
->priority
)
582 if (ntohl (a
->router_id
) > ntohl (b
->router_id
))
584 if (ntohl (a
->router_id
) < ntohl (b
->router_id
))
587 zlog_warn ("Router-ID duplicate ?");
592 dr_election (struct ospf6_interface
*oi
)
594 struct listnode
*node
, *nnode
;
595 struct ospf6_neighbor
*on
, *drouter
, *bdrouter
, myself
;
596 struct ospf6_neighbor
*best_drouter
, *best_bdrouter
;
597 u_char next_state
= 0;
599 drouter
= bdrouter
= NULL
;
600 best_drouter
= best_bdrouter
= NULL
;
602 /* pseudo neighbor myself, including noting current DR/BDR (1) */
603 memset (&myself
, 0, sizeof (myself
));
604 inet_ntop (AF_INET
, &oi
->area
->ospf6
->router_id
, myself
.name
,
605 sizeof (myself
.name
));
606 myself
.state
= OSPF6_NEIGHBOR_TWOWAY
;
607 myself
.drouter
= oi
->drouter
;
608 myself
.bdrouter
= oi
->bdrouter
;
609 myself
.priority
= oi
->priority
;
610 myself
.router_id
= oi
->area
->ospf6
->router_id
;
612 /* Electing BDR (2) */
613 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
614 bdrouter
= better_bdrouter (bdrouter
, on
);
616 best_bdrouter
= bdrouter
;
617 bdrouter
= better_bdrouter (best_bdrouter
, &myself
);
619 /* Electing DR (3) */
620 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
621 drouter
= better_drouter (drouter
, on
);
623 best_drouter
= drouter
;
624 drouter
= better_drouter (best_drouter
, &myself
);
628 /* the router itself is newly/no longer DR/BDR (4) */
629 if ((drouter
== &myself
&& myself
.drouter
!= myself
.router_id
) ||
630 (drouter
!= &myself
&& myself
.drouter
== myself
.router_id
) ||
631 (bdrouter
== &myself
&& myself
.bdrouter
!= myself
.router_id
) ||
632 (bdrouter
!= &myself
&& myself
.bdrouter
== myself
.router_id
))
634 myself
.drouter
= (drouter
? drouter
->router_id
: htonl (0));
635 myself
.bdrouter
= (bdrouter
? bdrouter
->router_id
: htonl (0));
637 /* compatible to Electing BDR (2) */
638 bdrouter
= better_bdrouter (best_bdrouter
, &myself
);
640 /* compatible to Electing DR (3) */
641 drouter
= better_drouter (best_drouter
, &myself
);
646 /* Set interface state accordingly (5) */
647 if (drouter
&& drouter
== &myself
)
648 next_state
= OSPF6_INTERFACE_DR
;
649 else if (bdrouter
&& bdrouter
== &myself
)
650 next_state
= OSPF6_INTERFACE_BDR
;
652 next_state
= OSPF6_INTERFACE_DROTHER
;
654 /* If NBMA, schedule Start for each neighbor having priority of 0 (6) */
657 /* If DR or BDR change, invoke AdjOK? for each neighbor (7) */
658 /* RFC 2328 section 12.4. Originating LSAs (3) will be handled
659 accordingly after AdjOK */
660 if (oi
->drouter
!= (drouter
? drouter
->router_id
: htonl (0)) ||
661 oi
->bdrouter
!= (bdrouter
? bdrouter
->router_id
: htonl (0)))
663 if (IS_OSPF6_DEBUG_INTERFACE
)
664 zlog_debug ("DR Election on %s: DR: %s BDR: %s", oi
->interface
->name
,
665 (drouter
? drouter
->name
: "0.0.0.0"),
666 (bdrouter
? bdrouter
->name
: "0.0.0.0"));
668 for (ALL_LIST_ELEMENTS_RO (oi
->neighbor_list
, node
, on
))
670 if (on
->state
< OSPF6_NEIGHBOR_TWOWAY
)
672 /* Schedule AdjOK. */
673 thread_add_event (master
, adj_ok
, on
, 0);
677 oi
->drouter
= (drouter
? drouter
->router_id
: htonl (0));
678 oi
->bdrouter
= (bdrouter
? bdrouter
->router_id
: htonl (0));
683 /* Interface State Machine */
685 interface_up (struct thread
*thread
)
687 struct ospf6_interface
*oi
;
689 oi
= (struct ospf6_interface
*) THREAD_ARG (thread
);
690 assert (oi
&& oi
->interface
);
692 if (IS_OSPF6_DEBUG_INTERFACE
)
693 zlog_debug ("Interface Event %s: [InterfaceUp]",
694 oi
->interface
->name
);
696 /* check physical interface is up */
697 if (! if_is_operative (oi
->interface
))
699 if (IS_OSPF6_DEBUG_INTERFACE
)
700 zlog_debug ("Interface %s is down, can't execute [InterfaceUp]",
701 oi
->interface
->name
);
705 /* check interface has a link-local address */
706 if (! (ospf6_interface_get_linklocal_address(oi
->interface
)
707 || if_is_loopback(oi
->interface
)))
709 if (IS_OSPF6_DEBUG_INTERFACE
)
710 zlog_debug ("Interface %s has no link local address, can't execute [InterfaceUp]",
711 oi
->interface
->name
);
716 ospf6_interface_recalculate_cost (oi
);
718 /* if already enabled, do nothing */
719 if (oi
->state
> OSPF6_INTERFACE_DOWN
)
721 if (IS_OSPF6_DEBUG_INTERFACE
)
722 zlog_debug ("Interface %s already enabled",
723 oi
->interface
->name
);
727 /* If no area assigned, return */
728 if (oi
->area
== NULL
)
730 zlog_debug ("%s: Not scheduleing Hello for %s as there is no area assigned yet", __func__
,
731 oi
->interface
->name
);
735 /* Join AllSPFRouters */
736 if (ospf6_sso (oi
->interface
->ifindex
, &allspfrouters6
, IPV6_JOIN_GROUP
) < 0)
738 if (oi
->sso_try_cnt
++ < OSPF6_INTERFACE_SSO_RETRY_MAX
)
740 zlog_info("Scheduling %s for sso retry, trial count: %d",
741 oi
->interface
->name
, oi
->sso_try_cnt
);
742 thread_add_timer (master
, interface_up
, oi
,
743 OSPF6_INTERFACE_SSO_RETRY_INT
);
747 oi
->sso_try_cnt
= 0; /* Reset on success */
749 /* Update interface route */
750 ospf6_interface_connected_route_update (oi
->interface
);
753 if (! CHECK_FLAG (oi
->flag
, OSPF6_INTERFACE_PASSIVE
))
754 oi
->thread_send_hello
= thread_add_event (master
, ospf6_hello_send
, oi
, 0);
756 /* decide next interface state */
757 if ((if_is_pointopoint (oi
->interface
)) ||
758 (oi
->type
== OSPF_IFTYPE_POINTOPOINT
)) {
759 ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT
, oi
);
761 else if (oi
->priority
== 0)
762 ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER
, oi
);
765 ospf6_interface_state_change (OSPF6_INTERFACE_WAITING
, oi
);
766 thread_add_timer (master
, wait_timer
, oi
, oi
->dead_interval
);
773 wait_timer (struct thread
*thread
)
775 struct ospf6_interface
*oi
;
777 oi
= (struct ospf6_interface
*) THREAD_ARG (thread
);
778 assert (oi
&& oi
->interface
);
780 if (IS_OSPF6_DEBUG_INTERFACE
)
781 zlog_debug ("Interface Event %s: [WaitTimer]",
782 oi
->interface
->name
);
784 if (oi
->state
== OSPF6_INTERFACE_WAITING
)
785 ospf6_interface_state_change (dr_election (oi
), oi
);
791 backup_seen (struct thread
*thread
)
793 struct ospf6_interface
*oi
;
795 oi
= (struct ospf6_interface
*) THREAD_ARG (thread
);
796 assert (oi
&& oi
->interface
);
798 if (IS_OSPF6_DEBUG_INTERFACE
)
799 zlog_debug ("Interface Event %s: [BackupSeen]",
800 oi
->interface
->name
);
802 if (oi
->state
== OSPF6_INTERFACE_WAITING
)
803 ospf6_interface_state_change (dr_election (oi
), oi
);
809 neighbor_change (struct thread
*thread
)
811 struct ospf6_interface
*oi
;
813 oi
= (struct ospf6_interface
*) THREAD_ARG (thread
);
814 assert (oi
&& oi
->interface
);
816 if (IS_OSPF6_DEBUG_INTERFACE
)
817 zlog_debug ("Interface Event %s: [NeighborChange]",
818 oi
->interface
->name
);
820 if (oi
->state
== OSPF6_INTERFACE_DROTHER
||
821 oi
->state
== OSPF6_INTERFACE_BDR
||
822 oi
->state
== OSPF6_INTERFACE_DR
)
823 ospf6_interface_state_change (dr_election (oi
), oi
);
829 interface_down (struct thread
*thread
)
831 struct ospf6_interface
*oi
;
832 struct listnode
*node
, *nnode
;
833 struct ospf6_neighbor
*on
;
835 oi
= (struct ospf6_interface
*) THREAD_ARG (thread
);
836 assert (oi
&& oi
->interface
);
838 if (IS_OSPF6_DEBUG_INTERFACE
)
839 zlog_debug ("Interface Event %s: [InterfaceDown]",
840 oi
->interface
->name
);
843 THREAD_OFF (oi
->thread_send_hello
);
845 /* Leave AllSPFRouters */
846 if (oi
->state
> OSPF6_INTERFACE_DOWN
)
847 ospf6_sso (oi
->interface
->ifindex
, &allspfrouters6
, IPV6_LEAVE_GROUP
);
849 ospf6_interface_state_change (OSPF6_INTERFACE_DOWN
, oi
);
851 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
852 ospf6_neighbor_delete (on
);
854 list_delete_all_node (oi
->neighbor_list
);
856 /* When interface state is reset, also reset information about
857 * DR election, as it is no longer valid. */
858 oi
->drouter
= oi
->prev_drouter
= htonl(0);
859 oi
->bdrouter
= oi
->prev_bdrouter
= htonl(0);
864 /* show specified interface structure */
866 ospf6_interface_show (struct vty
*vty
, struct interface
*ifp
)
868 struct ospf6_interface
*oi
;
872 char strbuf
[64], drouter
[32], bdrouter
[32];
873 const char *updown
[3] = {"down", "up", NULL
};
875 struct timeval res
, now
;
877 struct ospf6_lsa
*lsa
;
879 /* check physical interface type */
880 if (if_is_loopback (ifp
))
882 else if (if_is_broadcast (ifp
))
884 else if (if_is_pointopoint (ifp
))
885 type
= "POINTOPOINT";
889 vty_out (vty
, "%s is %s, type %s%s",
890 ifp
->name
, updown
[if_is_operative (ifp
)], type
,
892 vty_out (vty
, " Interface ID: %d%s", ifp
->ifindex
, VNL
);
894 if (ifp
->info
== NULL
)
896 vty_out (vty
, " OSPF not enabled on this interface%s", VNL
);
900 oi
= (struct ospf6_interface
*) ifp
->info
;
902 vty_out (vty
, " Internet Address:%s", VNL
);
904 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, i
, c
))
907 prefix2str (p
, strbuf
, sizeof (strbuf
));
911 vty_out (vty
, " inet : %s%s", strbuf
,
915 vty_out (vty
, " inet6: %s%s", strbuf
,
919 vty_out (vty
, " ??? : %s%s", strbuf
,
927 vty_out (vty
, " Instance ID %d, Interface MTU %d (autodetect: %d)%s",
928 oi
->instance_id
, oi
->ifmtu
, ifp
->mtu6
, VNL
);
929 vty_out (vty
, " MTU mismatch detection: %s%s", oi
->mtu_ignore
?
930 "disabled" : "enabled", VNL
);
931 inet_ntop (AF_INET
, &oi
->area
->area_id
,
932 strbuf
, sizeof (strbuf
));
933 vty_out (vty
, " Area ID %s, Cost %hu%s", strbuf
, oi
->cost
,
937 vty_out (vty
, " Not Attached to Area%s", VNL
);
939 vty_out (vty
, " State %s, Transmit Delay %d sec, Priority %d%s",
940 ospf6_interface_state_str
[oi
->state
],
941 oi
->transdelay
, oi
->priority
,
943 vty_out (vty
, " Timer intervals configured:%s", VNL
);
944 vty_out (vty
, " Hello %d, Dead %d, Retransmit %d%s",
945 oi
->hello_interval
, oi
->dead_interval
, oi
->rxmt_interval
,
948 inet_ntop (AF_INET
, &oi
->drouter
, drouter
, sizeof (drouter
));
949 inet_ntop (AF_INET
, &oi
->bdrouter
, bdrouter
, sizeof (bdrouter
));
950 vty_out (vty
, " DR: %s BDR: %s%s", drouter
, bdrouter
, VNL
);
952 vty_out (vty
, " Number of I/F scoped LSAs is %u%s",
953 oi
->lsdb
->count
, VNL
);
955 quagga_gettime (QUAGGA_CLK_MONOTONIC
, &now
);
958 if (oi
->thread_send_lsupdate
)
959 timersub (&oi
->thread_send_lsupdate
->u
.sands
, &now
, &res
);
960 timerstring (&res
, duration
, sizeof (duration
));
961 vty_out (vty
, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
962 oi
->lsupdate_list
->count
, duration
,
963 (oi
->thread_send_lsupdate
? "on" : "off"),
965 for (lsa
= ospf6_lsdb_head (oi
->lsupdate_list
); lsa
;
966 lsa
= ospf6_lsdb_next (lsa
))
967 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
970 if (oi
->thread_send_lsack
)
971 timersub (&oi
->thread_send_lsack
->u
.sands
, &now
, &res
);
972 timerstring (&res
, duration
, sizeof (duration
));
973 vty_out (vty
, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
974 oi
->lsack_list
->count
, duration
,
975 (oi
->thread_send_lsack
? "on" : "off"),
977 for (lsa
= ospf6_lsdb_head (oi
->lsack_list
); lsa
;
978 lsa
= ospf6_lsdb_next (lsa
))
979 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
985 DEFUN (show_ipv6_ospf6_interface
,
986 show_ipv6_ospf6_interface_ifname_cmd
,
987 "show ipv6 ospf6 interface IFNAME",
995 struct interface
*ifp
;
1000 ifp
= if_lookup_by_name (argv
[0]);
1003 vty_out (vty
, "No such Interface: %s%s", argv
[0],
1007 ospf6_interface_show (vty
, ifp
);
1011 for (ALL_LIST_ELEMENTS_RO (iflist
, i
, ifp
))
1012 ospf6_interface_show (vty
, ifp
);
1018 ALIAS (show_ipv6_ospf6_interface
,
1019 show_ipv6_ospf6_interface_cmd
,
1020 "show ipv6 ospf6 interface",
1027 DEFUN (show_ipv6_ospf6_interface_ifname_prefix
,
1028 show_ipv6_ospf6_interface_ifname_prefix_cmd
,
1029 "show ipv6 ospf6 interface IFNAME prefix",
1035 "Display connected prefixes to advertise\n"
1038 struct interface
*ifp
;
1039 struct ospf6_interface
*oi
;
1041 ifp
= if_lookup_by_name (argv
[0]);
1044 vty_out (vty
, "No such Interface: %s%s", argv
[0], VNL
);
1051 vty_out (vty
, "OSPFv3 is not enabled on %s%s", argv
[0], VNL
);
1057 ospf6_route_table_show (vty
, argc
, argv
, oi
->route_connected
);
1062 ALIAS (show_ipv6_ospf6_interface_ifname_prefix
,
1063 show_ipv6_ospf6_interface_ifname_prefix_detail_cmd
,
1064 "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)",
1070 "Display connected prefixes to advertise\n"
1071 OSPF6_ROUTE_ADDRESS_STR
1072 OSPF6_ROUTE_PREFIX_STR
1073 "Display details of the prefixes\n"
1076 ALIAS (show_ipv6_ospf6_interface_ifname_prefix
,
1077 show_ipv6_ospf6_interface_ifname_prefix_match_cmd
,
1078 "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)",
1084 "Display connected prefixes to advertise\n"
1085 OSPF6_ROUTE_PREFIX_STR
1086 OSPF6_ROUTE_MATCH_STR
1087 "Display details of the prefixes\n"
1090 DEFUN (show_ipv6_ospf6_interface_prefix
,
1091 show_ipv6_ospf6_interface_prefix_cmd
,
1092 "show ipv6 ospf6 interface prefix",
1097 "Display connected prefixes to advertise\n"
1101 struct ospf6_interface
*oi
;
1102 struct interface
*ifp
;
1104 for (ALL_LIST_ELEMENTS_RO (iflist
, i
, ifp
))
1106 oi
= (struct ospf6_interface
*) ifp
->info
;
1110 ospf6_route_table_show (vty
, argc
, argv
, oi
->route_connected
);
1116 ALIAS (show_ipv6_ospf6_interface_prefix
,
1117 show_ipv6_ospf6_interface_prefix_detail_cmd
,
1118 "show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)",
1123 "Display connected prefixes to advertise\n"
1124 OSPF6_ROUTE_ADDRESS_STR
1125 OSPF6_ROUTE_PREFIX_STR
1126 "Display details of the prefixes\n"
1129 ALIAS (show_ipv6_ospf6_interface_prefix
,
1130 show_ipv6_ospf6_interface_prefix_match_cmd
,
1131 "show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)",
1136 "Display connected prefixes to advertise\n"
1137 OSPF6_ROUTE_PREFIX_STR
1138 OSPF6_ROUTE_MATCH_STR
1139 "Display details of the prefixes\n"
1143 /* interface variable set command */
1144 DEFUN (ipv6_ospf6_ifmtu
,
1145 ipv6_ospf6_ifmtu_cmd
,
1146 "ipv6 ospf6 ifmtu <1-65535>",
1150 "OSPFv3 Interface MTU\n"
1153 struct ospf6_interface
*oi
;
1154 struct interface
*ifp
;
1155 unsigned int ifmtu
, iobuflen
;
1156 struct listnode
*node
, *nnode
;
1157 struct ospf6_neighbor
*on
;
1159 ifp
= (struct interface
*) vty
->index
;
1162 oi
= (struct ospf6_interface
*) ifp
->info
;
1164 oi
= ospf6_interface_create (ifp
);
1167 ifmtu
= strtol (argv
[0], NULL
, 10);
1169 if (oi
->ifmtu
== ifmtu
)
1172 if (ifp
->mtu6
!= 0 && ifp
->mtu6
< ifmtu
)
1174 vty_out (vty
, "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)%s",
1175 ifp
->name
, ifp
->mtu6
, VNL
);
1179 if (oi
->ifmtu
< ifmtu
)
1181 iobuflen
= ospf6_iobuf_size (ifmtu
);
1182 if (iobuflen
< ifmtu
)
1184 vty_out (vty
, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
1185 ifp
->name
, iobuflen
, VNL
);
1186 oi
->ifmtu
= iobuflen
;
1194 /* re-establish adjacencies */
1195 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
1197 THREAD_OFF (on
->inactivity_timer
);
1198 thread_add_event (master
, inactivity_timer
, on
, 0);
1204 DEFUN (no_ipv6_ospf6_ifmtu
,
1205 no_ipv6_ospf6_ifmtu_cmd
,
1206 "no ipv6 ospf6 ifmtu",
1213 struct ospf6_interface
*oi
;
1214 struct interface
*ifp
;
1215 unsigned int iobuflen
;
1216 struct listnode
*node
, *nnode
;
1217 struct ospf6_neighbor
*on
;
1219 ifp
= (struct interface
*) vty
->index
;
1222 oi
= (struct ospf6_interface
*) ifp
->info
;
1224 oi
= ospf6_interface_create (ifp
);
1227 if (oi
->ifmtu
< ifp
->mtu
)
1229 iobuflen
= ospf6_iobuf_size (ifp
->mtu
);
1230 if (iobuflen
< ifp
->mtu
)
1232 vty_out (vty
, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
1233 ifp
->name
, iobuflen
, VNL
);
1234 oi
->ifmtu
= iobuflen
;
1237 oi
->ifmtu
= ifp
->mtu
;
1240 oi
->ifmtu
= ifp
->mtu
;
1242 /* re-establish adjacencies */
1243 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
1245 THREAD_OFF (on
->inactivity_timer
);
1246 thread_add_event (master
, inactivity_timer
, on
, 0);
1252 DEFUN (ipv6_ospf6_cost
,
1253 ipv6_ospf6_cost_cmd
,
1254 "ipv6 ospf6 cost <1-65535>",
1258 "Outgoing metric of this interface\n"
1261 struct ospf6_interface
*oi
;
1262 struct interface
*ifp
;
1263 unsigned long int lcost
;
1265 ifp
= (struct interface
*) vty
->index
;
1268 oi
= (struct ospf6_interface
*) ifp
->info
;
1270 oi
= ospf6_interface_create (ifp
);
1273 lcost
= strtol (argv
[0], NULL
, 10);
1275 if (lcost
> UINT32_MAX
)
1277 vty_out (vty
, "Cost %ld is out of range%s", lcost
, VNL
);
1281 if (oi
->cost
== lcost
)
1285 SET_FLAG (oi
->flag
, OSPF6_INTERFACE_NOAUTOCOST
);
1287 ospf6_interface_recalculate_cost(oi
);
1292 DEFUN (no_ipv6_ospf6_cost
,
1293 no_ipv6_ospf6_cost_cmd
,
1294 "no ipv6 ospf6 cost",
1298 "Calculate interface cost from bandwidth\n"
1301 struct ospf6_interface
*oi
;
1302 struct interface
*ifp
;
1304 ifp
= (struct interface
*) vty
->index
;
1307 oi
= (struct ospf6_interface
*) ifp
->info
;
1309 oi
= ospf6_interface_create (ifp
);
1312 UNSET_FLAG (oi
->flag
, OSPF6_INTERFACE_NOAUTOCOST
);
1314 ospf6_interface_recalculate_cost(oi
);
1319 DEFUN (auto_cost_reference_bandwidth
,
1320 auto_cost_reference_bandwidth_cmd
,
1321 "auto-cost reference-bandwidth <1-4294967>",
1322 "Calculate OSPF interface cost according to bandwidth\n"
1323 "Use reference bandwidth method to assign OSPF cost\n"
1324 "The reference bandwidth in terms of Mbits per second\n")
1326 struct ospf6
*o
= vty
->index
;
1327 struct ospf6_area
*oa
;
1328 struct ospf6_interface
*oi
;
1329 struct listnode
*i
, *j
;
1332 refbw
= strtol (argv
[0], NULL
, 10);
1333 if (refbw
< 1 || refbw
> 4294967)
1335 vty_out (vty
, "reference-bandwidth value is invalid%s", VTY_NEWLINE
);
1339 /* If reference bandwidth is changed. */
1340 if ((refbw
* 1000) == o
->ref_bandwidth
)
1343 o
->ref_bandwidth
= refbw
* 1000;
1344 for (ALL_LIST_ELEMENTS_RO (o
->area_list
, i
, oa
))
1345 for (ALL_LIST_ELEMENTS_RO (oa
->if_list
, j
, oi
))
1346 ospf6_interface_recalculate_cost (oi
);
1351 DEFUN (no_auto_cost_reference_bandwidth
,
1352 no_auto_cost_reference_bandwidth_cmd
,
1353 "no auto-cost reference-bandwidth",
1355 "Calculate OSPF interface cost according to bandwidth\n"
1356 "Use reference bandwidth method to assign OSPF cost\n")
1358 struct ospf6
*o
= vty
->index
;
1359 struct ospf6_area
*oa
;
1360 struct ospf6_interface
*oi
;
1361 struct listnode
*i
, *j
;
1363 if (o
->ref_bandwidth
== OSPF6_REFERENCE_BANDWIDTH
)
1366 o
->ref_bandwidth
= OSPF6_REFERENCE_BANDWIDTH
;
1367 for (ALL_LIST_ELEMENTS_RO (o
->area_list
, i
, oa
))
1368 for (ALL_LIST_ELEMENTS_RO (oa
->if_list
, j
, oi
))
1369 ospf6_interface_recalculate_cost (oi
);
1374 DEFUN (ipv6_ospf6_hellointerval
,
1375 ipv6_ospf6_hellointerval_cmd
,
1376 "ipv6 ospf6 hello-interval <1-65535>",
1379 "Interval time of Hello packets\n"
1383 struct ospf6_interface
*oi
;
1384 struct interface
*ifp
;
1386 ifp
= (struct interface
*) vty
->index
;
1389 oi
= (struct ospf6_interface
*) ifp
->info
;
1391 oi
= ospf6_interface_create (ifp
);
1394 oi
->hello_interval
= strtol (argv
[0], NULL
, 10);
1398 /* interface variable set command */
1399 DEFUN (ipv6_ospf6_deadinterval
,
1400 ipv6_ospf6_deadinterval_cmd
,
1401 "ipv6 ospf6 dead-interval <1-65535>",
1404 "Interval time after which a neighbor is declared down\n"
1408 struct ospf6_interface
*oi
;
1409 struct interface
*ifp
;
1411 ifp
= (struct interface
*) vty
->index
;
1414 oi
= (struct ospf6_interface
*) ifp
->info
;
1416 oi
= ospf6_interface_create (ifp
);
1419 oi
->dead_interval
= strtol (argv
[0], NULL
, 10);
1423 /* interface variable set command */
1424 DEFUN (ipv6_ospf6_transmitdelay
,
1425 ipv6_ospf6_transmitdelay_cmd
,
1426 "ipv6 ospf6 transmit-delay <1-3600>",
1429 "Transmit delay of this interface\n"
1433 struct ospf6_interface
*oi
;
1434 struct interface
*ifp
;
1436 ifp
= (struct interface
*) vty
->index
;
1439 oi
= (struct ospf6_interface
*) ifp
->info
;
1441 oi
= ospf6_interface_create (ifp
);
1444 oi
->transdelay
= strtol (argv
[0], NULL
, 10);
1448 /* interface variable set command */
1449 DEFUN (ipv6_ospf6_retransmitinterval
,
1450 ipv6_ospf6_retransmitinterval_cmd
,
1451 "ipv6 ospf6 retransmit-interval <1-65535>",
1454 "Time between retransmitting lost link state advertisements\n"
1458 struct ospf6_interface
*oi
;
1459 struct interface
*ifp
;
1461 ifp
= (struct interface
*) vty
->index
;
1464 oi
= (struct ospf6_interface
*) ifp
->info
;
1466 oi
= ospf6_interface_create (ifp
);
1469 oi
->rxmt_interval
= strtol (argv
[0], NULL
, 10);
1473 /* interface variable set command */
1474 DEFUN (ipv6_ospf6_priority
,
1475 ipv6_ospf6_priority_cmd
,
1476 "ipv6 ospf6 priority <0-255>",
1483 struct ospf6_interface
*oi
;
1484 struct interface
*ifp
;
1486 ifp
= (struct interface
*) vty
->index
;
1489 oi
= (struct ospf6_interface
*) ifp
->info
;
1491 oi
= ospf6_interface_create (ifp
);
1494 oi
->priority
= strtol (argv
[0], NULL
, 10);
1497 (oi
->state
== OSPF6_INTERFACE_DROTHER
||
1498 oi
->state
== OSPF6_INTERFACE_BDR
||
1499 oi
->state
== OSPF6_INTERFACE_DR
))
1500 ospf6_interface_state_change (dr_election (oi
), oi
);
1505 DEFUN (ipv6_ospf6_instance
,
1506 ipv6_ospf6_instance_cmd
,
1507 "ipv6 ospf6 instance-id <0-255>",
1510 "Instance ID for this interface\n"
1511 "Instance ID value\n"
1514 struct ospf6_interface
*oi
;
1515 struct interface
*ifp
;
1517 ifp
= (struct interface
*)vty
->index
;
1520 oi
= (struct ospf6_interface
*)ifp
->info
;
1522 oi
= ospf6_interface_create (ifp
);
1525 oi
->instance_id
= strtol (argv
[0], NULL
, 10);
1529 DEFUN (ipv6_ospf6_passive
,
1530 ipv6_ospf6_passive_cmd
,
1531 "ipv6 ospf6 passive",
1534 "passive interface, No adjacency will be formed on this interface\n"
1537 struct ospf6_interface
*oi
;
1538 struct interface
*ifp
;
1539 struct listnode
*node
, *nnode
;
1540 struct ospf6_neighbor
*on
;
1542 ifp
= (struct interface
*) vty
->index
;
1545 oi
= (struct ospf6_interface
*) ifp
->info
;
1547 oi
= ospf6_interface_create (ifp
);
1550 SET_FLAG (oi
->flag
, OSPF6_INTERFACE_PASSIVE
);
1551 THREAD_OFF (oi
->thread_send_hello
);
1553 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
1555 THREAD_OFF (on
->inactivity_timer
);
1556 thread_add_event (master
, inactivity_timer
, on
, 0);
1562 DEFUN (no_ipv6_ospf6_passive
,
1563 no_ipv6_ospf6_passive_cmd
,
1564 "no ipv6 ospf6 passive",
1568 "passive interface: No Adjacency will be formed on this I/F\n"
1571 struct ospf6_interface
*oi
;
1572 struct interface
*ifp
;
1574 ifp
= (struct interface
*) vty
->index
;
1577 oi
= (struct ospf6_interface
*) ifp
->info
;
1579 oi
= ospf6_interface_create (ifp
);
1582 UNSET_FLAG (oi
->flag
, OSPF6_INTERFACE_PASSIVE
);
1583 THREAD_OFF (oi
->thread_send_hello
);
1584 oi
->thread_send_hello
=
1585 thread_add_event (master
, ospf6_hello_send
, oi
, 0);
1590 DEFUN (ipv6_ospf6_mtu_ignore
,
1591 ipv6_ospf6_mtu_ignore_cmd
,
1592 "ipv6 ospf6 mtu-ignore",
1595 "Ignore MTU mismatch on this interface\n"
1598 struct ospf6_interface
*oi
;
1599 struct interface
*ifp
;
1601 ifp
= (struct interface
*) vty
->index
;
1604 oi
= (struct ospf6_interface
*) ifp
->info
;
1606 oi
= ospf6_interface_create (ifp
);
1614 DEFUN (no_ipv6_ospf6_mtu_ignore
,
1615 no_ipv6_ospf6_mtu_ignore_cmd
,
1616 "no ipv6 ospf6 mtu-ignore",
1620 "Ignore MTU mismatch on this interface\n"
1623 struct ospf6_interface
*oi
;
1624 struct interface
*ifp
;
1626 ifp
= (struct interface
*) vty
->index
;
1629 oi
= (struct ospf6_interface
*) ifp
->info
;
1631 oi
= ospf6_interface_create (ifp
);
1639 DEFUN (ipv6_ospf6_advertise_prefix_list
,
1640 ipv6_ospf6_advertise_prefix_list_cmd
,
1641 "ipv6 ospf6 advertise prefix-list WORD",
1644 "Advertising options\n"
1645 "Filter prefix using prefix-list\n"
1646 "Prefix list name\n"
1649 struct ospf6_interface
*oi
;
1650 struct interface
*ifp
;
1652 ifp
= (struct interface
*) vty
->index
;
1655 oi
= (struct ospf6_interface
*) ifp
->info
;
1657 oi
= ospf6_interface_create (ifp
);
1661 XFREE (MTYPE_PREFIX_LIST_STR
, oi
->plist_name
);
1662 oi
->plist_name
= XSTRDUP (MTYPE_PREFIX_LIST_STR
, argv
[0]);
1664 ospf6_interface_connected_route_update (oi
->interface
);
1668 OSPF6_LINK_LSA_SCHEDULE (oi
);
1669 if (oi
->state
== OSPF6_INTERFACE_DR
)
1671 OSPF6_NETWORK_LSA_SCHEDULE (oi
);
1672 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi
);
1674 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi
->area
);
1680 DEFUN (no_ipv6_ospf6_advertise_prefix_list
,
1681 no_ipv6_ospf6_advertise_prefix_list_cmd
,
1682 "no ipv6 ospf6 advertise prefix-list",
1686 "Advertising options\n"
1687 "Filter prefix using prefix-list\n"
1690 struct ospf6_interface
*oi
;
1691 struct interface
*ifp
;
1693 ifp
= (struct interface
*) vty
->index
;
1696 oi
= (struct ospf6_interface
*) ifp
->info
;
1698 oi
= ospf6_interface_create (ifp
);
1703 XFREE (MTYPE_PREFIX_LIST_STR
, oi
->plist_name
);
1704 oi
->plist_name
= NULL
;
1707 ospf6_interface_connected_route_update (oi
->interface
);
1711 OSPF6_LINK_LSA_SCHEDULE (oi
);
1712 if (oi
->state
== OSPF6_INTERFACE_DR
)
1714 OSPF6_NETWORK_LSA_SCHEDULE (oi
);
1715 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi
);
1717 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi
->area
);
1723 DEFUN (ipv6_ospf6_network
,
1724 ipv6_ospf6_network_cmd
,
1725 "ipv6 ospf6 network (broadcast|point-to-point)",
1729 "Specify OSPFv6 broadcast network\n"
1730 "Specify OSPF6 point-to-point network\n"
1733 struct ospf6_interface
*oi
;
1734 struct interface
*ifp
;
1736 ifp
= (struct interface
*) vty
->index
;
1739 oi
= (struct ospf6_interface
*) ifp
->info
;
1741 oi
= ospf6_interface_create (ifp
);
1745 if (strncmp (argv
[0], "b", 1) == 0)
1747 if (oi
->type
== OSPF_IFTYPE_BROADCAST
)
1750 oi
->type
= OSPF_IFTYPE_BROADCAST
;
1752 else if (strncmp (argv
[0], "point-to-p", 10) == 0)
1754 if (oi
->type
== OSPF_IFTYPE_POINTOPOINT
) {
1757 oi
->type
= OSPF_IFTYPE_POINTOPOINT
;
1760 /* Reset the interface */
1761 thread_add_event (master
, interface_down
, oi
, 0);
1762 thread_add_event (master
, interface_up
, oi
, 0);
1767 DEFUN (no_ipv6_ospf6_network
,
1768 no_ipv6_ospf6_network_cmd
,
1769 "no ipv6 ospf6 network",
1774 "Default to whatever interface type system specifies"
1777 struct ospf6_interface
*oi
;
1778 struct interface
*ifp
;
1781 ifp
= (struct interface
*) vty
->index
;
1784 oi
= (struct ospf6_interface
*) ifp
->info
;
1789 type
= ospf6_default_iftype (ifp
);
1790 if (oi
->type
== type
)
1796 /* Reset the interface */
1797 thread_add_event (master
, interface_down
, oi
, 0);
1798 thread_add_event (master
, interface_up
, oi
, 0);
1804 config_write_ospf6_interface (struct vty
*vty
)
1807 struct ospf6_interface
*oi
;
1808 struct interface
*ifp
;
1810 for (ALL_LIST_ELEMENTS_RO (iflist
, i
, ifp
))
1812 oi
= (struct ospf6_interface
*) ifp
->info
;
1816 vty_out (vty
, "interface %s%s",
1817 oi
->interface
->name
, VNL
);
1820 vty_out (vty
, " description %s%s", ifp
->desc
, VNL
);
1821 if (ifp
->mtu6
!= oi
->ifmtu
)
1822 vty_out (vty
, " ipv6 ospf6 ifmtu %d%s", oi
->ifmtu
, VNL
);
1824 if (CHECK_FLAG (oi
->flag
, OSPF6_INTERFACE_NOAUTOCOST
))
1825 vty_out (vty
, " ipv6 ospf6 cost %d%s",
1828 if (oi
->hello_interval
!= OSPF6_INTERFACE_HELLO_INTERVAL
)
1829 vty_out (vty
, " ipv6 ospf6 hello-interval %d%s",
1830 oi
->hello_interval
, VNL
);
1832 if (oi
->dead_interval
!= OSPF6_INTERFACE_DEAD_INTERVAL
)
1833 vty_out (vty
, " ipv6 ospf6 dead-interval %d%s",
1834 oi
->dead_interval
, VNL
);
1836 if (oi
->rxmt_interval
!= OSPF6_INTERFACE_RXMT_INTERVAL
)
1837 vty_out (vty
, " ipv6 ospf6 retransmit-interval %d%s",
1838 oi
->rxmt_interval
, VNL
);
1840 if (oi
->priority
!= OSPF6_INTERFACE_PRIORITY
)
1841 vty_out (vty
, " ipv6 ospf6 priority %d%s",
1844 if (oi
->transdelay
!= OSPF6_INTERFACE_TRANSDELAY
)
1845 vty_out (vty
, " ipv6 ospf6 transmit-delay %d%s",
1846 oi
->transdelay
, VNL
);
1848 if (oi
->instance_id
!= OSPF6_INTERFACE_INSTANCE_ID
)
1849 vty_out (vty
, " ipv6 ospf6 instance-id %d%s",
1850 oi
->instance_id
, VNL
);
1853 vty_out (vty
, " ipv6 ospf6 advertise prefix-list %s%s",
1854 oi
->plist_name
, VNL
);
1856 if (CHECK_FLAG (oi
->flag
, OSPF6_INTERFACE_PASSIVE
))
1857 vty_out (vty
, " ipv6 ospf6 passive%s", VNL
);
1860 vty_out (vty
, " ipv6 ospf6 mtu-ignore%s", VNL
);
1862 if (oi
->type
== OSPF_IFTYPE_POINTOPOINT
)
1863 vty_out (vty
, " ipv6 ospf6 network point-to-point%s", VNL
);
1864 else if (oi
->type
== OSPF_IFTYPE_BROADCAST
)
1865 vty_out (vty
, " ipv6 ospf6 network broadcast%s", VNL
);
1867 ospf6_bfd_write_config(vty
, oi
);
1869 vty_out (vty
, "!%s", VNL
);
1874 static struct cmd_node interface_node
=
1882 ospf6_interface_init (void)
1884 /* Install interface node. */
1885 install_node (&interface_node
, config_write_ospf6_interface
);
1887 install_element (VIEW_NODE
, &show_ipv6_ospf6_interface_cmd
);
1888 install_element (VIEW_NODE
, &show_ipv6_ospf6_interface_prefix_cmd
);
1889 install_element (VIEW_NODE
, &show_ipv6_ospf6_interface_prefix_detail_cmd
);
1890 install_element (VIEW_NODE
, &show_ipv6_ospf6_interface_prefix_match_cmd
);
1891 install_element (VIEW_NODE
, &show_ipv6_ospf6_interface_ifname_cmd
);
1892 install_element (VIEW_NODE
, &show_ipv6_ospf6_interface_ifname_prefix_cmd
);
1893 install_element (VIEW_NODE
, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd
);
1894 install_element (VIEW_NODE
, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd
);
1895 install_element (ENABLE_NODE
, &show_ipv6_ospf6_interface_cmd
);
1896 install_element (ENABLE_NODE
, &show_ipv6_ospf6_interface_prefix_cmd
);
1897 install_element (ENABLE_NODE
, &show_ipv6_ospf6_interface_prefix_detail_cmd
);
1898 install_element (ENABLE_NODE
, &show_ipv6_ospf6_interface_prefix_match_cmd
);
1899 install_element (ENABLE_NODE
, &show_ipv6_ospf6_interface_ifname_cmd
);
1900 install_element (ENABLE_NODE
, &show_ipv6_ospf6_interface_ifname_prefix_cmd
);
1901 install_element (ENABLE_NODE
, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd
);
1902 install_element (ENABLE_NODE
, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd
);
1904 install_element (CONFIG_NODE
, &interface_cmd
);
1905 install_default (INTERFACE_NODE
);
1906 install_element (INTERFACE_NODE
, &interface_desc_cmd
);
1907 install_element (INTERFACE_NODE
, &no_interface_desc_cmd
);
1908 install_element (INTERFACE_NODE
, &ipv6_ospf6_cost_cmd
);
1909 install_element (INTERFACE_NODE
, &no_ipv6_ospf6_cost_cmd
);
1910 install_element (INTERFACE_NODE
, &ipv6_ospf6_ifmtu_cmd
);
1911 install_element (INTERFACE_NODE
, &no_ipv6_ospf6_ifmtu_cmd
);
1912 install_element (INTERFACE_NODE
, &ipv6_ospf6_deadinterval_cmd
);
1913 install_element (INTERFACE_NODE
, &ipv6_ospf6_hellointerval_cmd
);
1914 install_element (INTERFACE_NODE
, &ipv6_ospf6_priority_cmd
);
1915 install_element (INTERFACE_NODE
, &ipv6_ospf6_retransmitinterval_cmd
);
1916 install_element (INTERFACE_NODE
, &ipv6_ospf6_transmitdelay_cmd
);
1917 install_element (INTERFACE_NODE
, &ipv6_ospf6_instance_cmd
);
1919 install_element (INTERFACE_NODE
, &ipv6_ospf6_passive_cmd
);
1920 install_element (INTERFACE_NODE
, &no_ipv6_ospf6_passive_cmd
);
1922 install_element (INTERFACE_NODE
, &ipv6_ospf6_mtu_ignore_cmd
);
1923 install_element (INTERFACE_NODE
, &no_ipv6_ospf6_mtu_ignore_cmd
);
1925 install_element (INTERFACE_NODE
, &ipv6_ospf6_advertise_prefix_list_cmd
);
1926 install_element (INTERFACE_NODE
, &no_ipv6_ospf6_advertise_prefix_list_cmd
);
1928 install_element (INTERFACE_NODE
, &ipv6_ospf6_network_cmd
);
1929 install_element (INTERFACE_NODE
, &no_ipv6_ospf6_network_cmd
);
1931 /* reference bandwidth commands */
1932 install_element (OSPF6_NODE
, &auto_cost_reference_bandwidth_cmd
);
1933 install_element (OSPF6_NODE
, &no_auto_cost_reference_bandwidth_cmd
);
1936 /* Clear the specified interface structure */
1938 ospf6_interface_clear (struct vty
*vty
, struct interface
*ifp
)
1940 struct ospf6_interface
*oi
;
1942 if (!if_is_operative (ifp
))
1945 if (ifp
->info
== NULL
)
1948 oi
= (struct ospf6_interface
*) ifp
->info
;
1950 if (IS_OSPF6_DEBUG_INTERFACE
)
1951 zlog_debug ("Interface %s: clear by reset", ifp
->name
);
1953 /* Reset the interface */
1954 thread_add_event (master
, interface_down
, oi
, 0);
1955 thread_add_event (master
, interface_up
, oi
, 0);
1958 /* Clear interface */
1959 DEFUN (clear_ipv6_ospf6_interface
,
1960 clear_ipv6_ospf6_interface_cmd
,
1961 "clear ipv6 ospf6 interface [IFNAME]",
1969 struct interface
*ifp
;
1970 struct listnode
*node
;
1972 if (argc
== 0) /* Clear all the ospfv3 interfaces. */
1974 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
1975 ospf6_interface_clear (vty
, ifp
);
1977 else /* Interface name is specified. */
1979 if ((ifp
= if_lookup_by_name (argv
[0])) == NULL
)
1981 vty_out (vty
, "No such Interface: %s%s", argv
[0], VNL
);
1984 ospf6_interface_clear (vty
, ifp
);
1991 install_element_ospf6_clear_interface (void)
1993 install_element (ENABLE_NODE
, &clear_ipv6_ospf6_interface_cmd
);
1996 DEFUN (debug_ospf6_interface
,
1997 debug_ospf6_interface_cmd
,
1998 "debug ospf6 interface",
2001 "Debug OSPFv3 Interface\n"
2004 OSPF6_DEBUG_INTERFACE_ON ();
2008 DEFUN (no_debug_ospf6_interface
,
2009 no_debug_ospf6_interface_cmd
,
2010 "no debug ospf6 interface",
2014 "Debug OSPFv3 Interface\n"
2017 OSPF6_DEBUG_INTERFACE_OFF ();
2022 config_write_ospf6_debug_interface (struct vty
*vty
)
2024 if (IS_OSPF6_DEBUG_INTERFACE
)
2025 vty_out (vty
, "debug ospf6 interface%s", VNL
);
2030 install_element_ospf6_debug_interface (void)
2032 install_element (ENABLE_NODE
, &debug_ospf6_interface_cmd
);
2033 install_element (ENABLE_NODE
, &no_debug_ospf6_interface_cmd
);
2034 install_element (CONFIG_NODE
, &debug_ospf6_interface_cmd
);
2035 install_element (CONFIG_NODE
, &no_debug_ospf6_interface_cmd
);