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.
33 #include "ospf6_lsa.h"
34 #include "ospf6_lsdb.h"
35 #include "ospf6_network.h"
36 #include "ospf6_message.h"
37 #include "ospf6_route.h"
38 #include "ospf6_top.h"
39 #include "ospf6_area.h"
40 #include "ospf6_interface.h"
41 #include "ospf6_neighbor.h"
42 #include "ospf6_intra.h"
43 #include "ospf6_spf.h"
45 #include "ospf6_bfd.h"
47 unsigned char conf_debug_ospf6_interface
= 0;
49 const char *ospf6_interface_state_str
[] =
62 struct ospf6_interface
*
63 ospf6_interface_lookup_by_ifindex (int ifindex
)
65 struct ospf6_interface
*oi
;
66 struct interface
*ifp
;
68 ifp
= if_lookup_by_index (ifindex
);
70 return (struct ospf6_interface
*) NULL
;
72 oi
= (struct ospf6_interface
*) ifp
->info
;
76 /* schedule routing table recalculation */
78 ospf6_interface_lsdb_hook (struct ospf6_lsa
*lsa
, unsigned int reason
)
80 struct ospf6_interface
*oi
;
86 switch (ntohs (lsa
->header
->type
))
88 case OSPF6_LSTYPE_LINK
:
89 if (oi
->state
== OSPF6_INTERFACE_DR
)
90 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi
);
91 ospf6_spf_schedule (oi
->area
->ospf6
, reason
);
100 ospf6_interface_lsdb_hook_add (struct ospf6_lsa
*lsa
)
102 ospf6_interface_lsdb_hook(lsa
, ospf6_lsadd_to_spf_reason(lsa
));
106 ospf6_interface_lsdb_hook_remove (struct ospf6_lsa
*lsa
)
108 ospf6_interface_lsdb_hook(lsa
, ospf6_lsremove_to_spf_reason(lsa
));
112 ospf6_default_iftype(struct interface
*ifp
)
114 if (if_is_pointopoint (ifp
))
115 return OSPF_IFTYPE_POINTOPOINT
;
116 else if (if_is_loopback (ifp
))
117 return OSPF_IFTYPE_LOOPBACK
;
119 return OSPF_IFTYPE_BROADCAST
;
123 ospf6_interface_get_cost (struct ospf6_interface
*oi
)
125 /* If all else fails, use default OSPF cost */
129 bw
= oi
->interface
->bandwidth
? oi
->interface
->bandwidth
: OSPF6_INTERFACE_BANDWIDTH
;
130 refbw
= ospf6
? ospf6
->ref_bandwidth
: OSPF6_REFERENCE_BANDWIDTH
;
132 /* A specifed ip ospf cost overrides a calculated one. */
133 if (CHECK_FLAG (oi
->flag
, OSPF6_INTERFACE_NOAUTOCOST
))
137 cost
= (u_int32_t
) ((double)refbw
/ (double)bw
+ (double)0.5);
138 if (cost
< 1) cost
= 1;
139 else if (cost
> UINT32_MAX
) cost
= UINT32_MAX
;
146 ospf6_interface_recalculate_cost (struct ospf6_interface
*oi
)
150 newcost
= ospf6_interface_get_cost (oi
);
151 if (newcost
== oi
->cost
) return;
154 /* update cost held in route_connected list in ospf6_interface */
155 ospf6_interface_connected_route_update (oi
->interface
);
157 /* execute LSA hooks */
160 OSPF6_LINK_LSA_SCHEDULE (oi
);
161 OSPF6_ROUTER_LSA_SCHEDULE (oi
->area
);
162 OSPF6_NETWORK_LSA_SCHEDULE (oi
);
163 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi
);
164 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi
->area
);
168 /* Create new ospf6 interface structure */
169 struct ospf6_interface
*
170 ospf6_interface_create (struct interface
*ifp
)
172 struct ospf6_interface
*oi
;
173 unsigned int iobuflen
;
175 oi
= (struct ospf6_interface
*)
176 XCALLOC (MTYPE_OSPF6_IF
, sizeof (struct ospf6_interface
));
180 zlog_err ("Can't malloc ospf6_interface for ifindex %d", ifp
->ifindex
);
181 return (struct ospf6_interface
*) NULL
;
184 oi
->area
= (struct ospf6_area
*) NULL
;
185 oi
->neighbor_list
= list_new ();
186 oi
->neighbor_list
->cmp
= ospf6_neighbor_cmp
;
187 oi
->linklocal_addr
= (struct in6_addr
*) NULL
;
188 oi
->instance_id
= OSPF6_INTERFACE_INSTANCE_ID
;
189 oi
->transdelay
= OSPF6_INTERFACE_TRANSDELAY
;
190 oi
->priority
= OSPF6_INTERFACE_PRIORITY
;
192 oi
->hello_interval
= OSPF_HELLO_INTERVAL_DEFAULT
;
193 oi
->dead_interval
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
194 oi
->rxmt_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
195 oi
->type
= ospf6_default_iftype (ifp
);
196 oi
->state
= OSPF6_INTERFACE_DOWN
;
200 /* Try to adjust I/O buffer size with IfMtu */
201 oi
->ifmtu
= ifp
->mtu6
;
202 iobuflen
= ospf6_iobuf_size (ifp
->mtu6
);
203 if (oi
->ifmtu
> iobuflen
)
205 if (IS_OSPF6_DEBUG_INTERFACE
)
206 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
207 ifp
->name
, iobuflen
);
208 oi
->ifmtu
= iobuflen
;
211 oi
->lsupdate_list
= ospf6_lsdb_create (oi
);
212 oi
->lsack_list
= ospf6_lsdb_create (oi
);
213 oi
->lsdb
= ospf6_lsdb_create (oi
);
214 oi
->lsdb
->hook_add
= ospf6_interface_lsdb_hook_add
;
215 oi
->lsdb
->hook_remove
= ospf6_interface_lsdb_hook_remove
;
216 oi
->lsdb_self
= ospf6_lsdb_create (oi
);
218 oi
->route_connected
= OSPF6_ROUTE_TABLE_CREATE (INTERFACE
, CONNECTED_ROUTES
);
219 oi
->route_connected
->scope
= oi
;
226 oi
->cost
= ospf6_interface_get_cost(oi
);
232 ospf6_interface_delete (struct ospf6_interface
*oi
)
234 struct listnode
*node
, *nnode
;
235 struct ospf6_neighbor
*on
;
237 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
238 ospf6_neighbor_delete (on
);
240 list_delete (oi
->neighbor_list
);
242 THREAD_OFF (oi
->thread_send_hello
);
243 THREAD_OFF (oi
->thread_send_lsupdate
);
244 THREAD_OFF (oi
->thread_send_lsack
);
246 ospf6_lsdb_remove_all (oi
->lsdb
);
247 ospf6_lsdb_remove_all (oi
->lsupdate_list
);
248 ospf6_lsdb_remove_all (oi
->lsack_list
);
250 ospf6_lsdb_delete (oi
->lsdb
);
251 ospf6_lsdb_delete (oi
->lsdb_self
);
253 ospf6_lsdb_delete (oi
->lsupdate_list
);
254 ospf6_lsdb_delete (oi
->lsack_list
);
256 ospf6_route_table_delete (oi
->route_connected
);
259 oi
->interface
->info
= NULL
;
263 XFREE (MTYPE_PREFIX_LIST_STR
, oi
->plist_name
);
265 bfd_info_free(&(oi
->bfd_info
));
267 XFREE (MTYPE_OSPF6_IF
, oi
);
271 ospf6_interface_enable (struct ospf6_interface
*oi
)
273 UNSET_FLAG (oi
->flag
, OSPF6_INTERFACE_DISABLE
);
274 ospf6_interface_state_update (oi
->interface
);
278 ospf6_interface_disable (struct ospf6_interface
*oi
)
280 SET_FLAG (oi
->flag
, OSPF6_INTERFACE_DISABLE
);
282 thread_execute (master
, interface_down
, oi
, 0);
284 ospf6_lsdb_remove_all (oi
->lsdb
);
285 ospf6_lsdb_remove_all (oi
->lsdb_self
);
286 ospf6_lsdb_remove_all (oi
->lsupdate_list
);
287 ospf6_lsdb_remove_all (oi
->lsack_list
);
289 THREAD_OFF (oi
->thread_send_hello
);
290 THREAD_OFF (oi
->thread_send_lsupdate
);
291 THREAD_OFF (oi
->thread_send_lsack
);
293 THREAD_OFF (oi
->thread_network_lsa
);
294 THREAD_OFF (oi
->thread_link_lsa
);
295 THREAD_OFF (oi
->thread_intra_prefix_lsa
);
298 static struct in6_addr
*
299 ospf6_interface_get_linklocal_address (struct interface
*ifp
)
303 struct in6_addr
*l
= (struct in6_addr
*) NULL
;
305 /* for each connected address */
306 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, n
, c
))
308 /* if family not AF_INET6, ignore */
309 if (c
->address
->family
!= AF_INET6
)
312 /* linklocal scope check */
313 if (IN6_IS_ADDR_LINKLOCAL (&c
->address
->u
.prefix6
))
314 l
= &c
->address
->u
.prefix6
;
320 ospf6_interface_if_add (struct interface
*ifp
)
322 struct ospf6_interface
*oi
;
323 unsigned int iobuflen
;
325 oi
= (struct ospf6_interface
*) ifp
->info
;
329 /* Try to adjust I/O buffer size with IfMtu */
331 oi
->ifmtu
= ifp
->mtu6
;
332 iobuflen
= ospf6_iobuf_size (ifp
->mtu6
);
333 if (oi
->ifmtu
> iobuflen
)
335 if (IS_OSPF6_DEBUG_INTERFACE
)
336 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
337 ifp
->name
, iobuflen
);
338 oi
->ifmtu
= iobuflen
;
341 /* interface start */
342 ospf6_interface_state_update(oi
->interface
);
346 ospf6_interface_if_del (struct interface
*ifp
)
348 struct ospf6_interface
*oi
;
350 oi
= (struct ospf6_interface
*) ifp
->info
;
356 thread_execute (master
, interface_down
, oi
, 0);
358 listnode_delete (oi
->area
->if_list
, oi
);
359 oi
->area
= (struct ospf6_area
*) NULL
;
362 oi
->interface
= NULL
;
365 ospf6_interface_delete (oi
);
369 ospf6_interface_state_update (struct interface
*ifp
)
371 struct ospf6_interface
*oi
;
373 oi
= (struct ospf6_interface
*) ifp
->info
;
376 if (oi
->area
== NULL
)
378 if (CHECK_FLAG (oi
->flag
, OSPF6_INTERFACE_DISABLE
))
381 if (if_is_operative (ifp
)
382 && (ospf6_interface_get_linklocal_address(oi
->interface
)
383 || if_is_loopback(oi
->interface
)))
384 thread_add_event (master
, interface_up
, oi
, 0);
386 thread_add_event (master
, interface_down
, oi
, 0);
392 ospf6_interface_connected_route_update (struct interface
*ifp
)
394 struct ospf6_interface
*oi
;
395 struct ospf6_route
*route
;
397 struct listnode
*node
, *nnode
;
398 struct in6_addr nh_addr
;
400 oi
= (struct ospf6_interface
*) ifp
->info
;
404 /* reset linklocal pointer */
405 oi
->linklocal_addr
= ospf6_interface_get_linklocal_address (ifp
);
407 /* if area is null, do not make connected-route list */
408 if (oi
->area
== NULL
)
411 if (CHECK_FLAG (oi
->flag
, OSPF6_INTERFACE_DISABLE
))
414 /* update "route to advertise" interface route table */
415 ospf6_route_remove_all (oi
->route_connected
);
417 for (ALL_LIST_ELEMENTS (oi
->interface
->connected
, node
, nnode
, c
))
419 if (c
->address
->family
!= AF_INET6
)
422 CONTINUE_IF_ADDRESS_LINKLOCAL (IS_OSPF6_DEBUG_INTERFACE
, c
->address
);
423 CONTINUE_IF_ADDRESS_UNSPECIFIED (IS_OSPF6_DEBUG_INTERFACE
, c
->address
);
424 CONTINUE_IF_ADDRESS_LOOPBACK (IS_OSPF6_DEBUG_INTERFACE
, c
->address
);
425 CONTINUE_IF_ADDRESS_V4COMPAT (IS_OSPF6_DEBUG_INTERFACE
, c
->address
);
426 CONTINUE_IF_ADDRESS_V4MAPPED (IS_OSPF6_DEBUG_INTERFACE
, c
->address
);
431 struct prefix_list
*plist
;
432 enum prefix_list_type ret
;
435 prefix2str (c
->address
, buf
, sizeof (buf
));
436 plist
= prefix_list_lookup (AFI_IP6
, oi
->plist_name
);
437 ret
= prefix_list_apply (plist
, (void *) c
->address
);
438 if (ret
== PREFIX_DENY
)
440 if (IS_OSPF6_DEBUG_INTERFACE
)
441 zlog_debug ("%s on %s filtered by prefix-list %s ",
442 buf
, oi
->interface
->name
, oi
->plist_name
);
447 route
= ospf6_route_create ();
448 memcpy (&route
->prefix
, c
->address
, sizeof (struct prefix
));
449 apply_mask (&route
->prefix
);
450 route
->type
= OSPF6_DEST_TYPE_NETWORK
;
451 route
->path
.area_id
= oi
->area
->area_id
;
452 route
->path
.type
= OSPF6_PATH_TYPE_INTRA
;
453 route
->path
.cost
= oi
->cost
;
454 inet_pton (AF_INET6
, "::1", &nh_addr
);
455 ospf6_route_add_nexthop (route
, oi
->interface
->ifindex
, &nh_addr
);
456 ospf6_route_add (route
, oi
->route_connected
);
459 /* create new Link-LSA */
460 OSPF6_LINK_LSA_SCHEDULE (oi
);
461 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi
);
462 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi
->area
);
466 ospf6_interface_state_change (u_char next_state
, struct ospf6_interface
*oi
)
470 prev_state
= oi
->state
;
471 oi
->state
= next_state
;
473 if (prev_state
== next_state
)
477 if (IS_OSPF6_DEBUG_INTERFACE
)
479 zlog_debug ("Interface state change %s: %s -> %s", oi
->interface
->name
,
480 ospf6_interface_state_str
[prev_state
],
481 ospf6_interface_state_str
[next_state
]);
485 if ((prev_state
== OSPF6_INTERFACE_DR
||
486 prev_state
== OSPF6_INTERFACE_BDR
) &&
487 (next_state
!= OSPF6_INTERFACE_DR
&&
488 next_state
!= OSPF6_INTERFACE_BDR
))
489 ospf6_sso (oi
->interface
->ifindex
, &alldrouters6
, IPV6_LEAVE_GROUP
);
491 if ((prev_state
!= OSPF6_INTERFACE_DR
&&
492 prev_state
!= OSPF6_INTERFACE_BDR
) &&
493 (next_state
== OSPF6_INTERFACE_DR
||
494 next_state
== OSPF6_INTERFACE_BDR
))
495 ospf6_sso (oi
->interface
->ifindex
, &alldrouters6
, IPV6_JOIN_GROUP
);
497 OSPF6_ROUTER_LSA_SCHEDULE (oi
->area
);
498 if (next_state
== OSPF6_INTERFACE_DOWN
)
500 OSPF6_NETWORK_LSA_EXECUTE (oi
);
501 OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT (oi
);
502 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi
->area
);
504 else if (prev_state
== OSPF6_INTERFACE_DR
||
505 next_state
== OSPF6_INTERFACE_DR
)
507 OSPF6_NETWORK_LSA_SCHEDULE (oi
);
508 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi
);
509 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi
->area
);
513 /* Terminal state or regression */
514 if ((next_state
== OSPF6_INTERFACE_POINTTOPOINT
) ||
515 (next_state
== OSPF6_INTERFACE_DROTHER
) ||
516 (next_state
== OSPF6_INTERFACE_BDR
) ||
517 (next_state
== OSPF6_INTERFACE_DR
) ||
518 (next_state
< prev_state
))
519 ospf6TrapIfStateChange (oi
);
525 /* DR Election, RFC2328 section 9.4 */
527 #define IS_ELIGIBLE(n) \
528 ((n)->state >= OSPF6_NEIGHBOR_TWOWAY && (n)->priority != 0)
530 static struct ospf6_neighbor
*
531 better_bdrouter (struct ospf6_neighbor
*a
, struct ospf6_neighbor
*b
)
533 if ((a
== NULL
|| ! IS_ELIGIBLE (a
) || a
->drouter
== a
->router_id
) &&
534 (b
== NULL
|| ! IS_ELIGIBLE (b
) || b
->drouter
== b
->router_id
))
536 else if (a
== NULL
|| ! IS_ELIGIBLE (a
) || a
->drouter
== a
->router_id
)
538 else if (b
== NULL
|| ! IS_ELIGIBLE (b
) || b
->drouter
== b
->router_id
)
541 if (a
->bdrouter
== a
->router_id
&& b
->bdrouter
!= b
->router_id
)
543 if (a
->bdrouter
!= a
->router_id
&& b
->bdrouter
== b
->router_id
)
546 if (a
->priority
> b
->priority
)
548 if (a
->priority
< b
->priority
)
551 if (ntohl (a
->router_id
) > ntohl (b
->router_id
))
553 if (ntohl (a
->router_id
) < ntohl (b
->router_id
))
556 zlog_warn ("Router-ID duplicate ?");
560 static struct ospf6_neighbor
*
561 better_drouter (struct ospf6_neighbor
*a
, struct ospf6_neighbor
*b
)
563 if ((a
== NULL
|| ! IS_ELIGIBLE (a
) || a
->drouter
!= a
->router_id
) &&
564 (b
== NULL
|| ! IS_ELIGIBLE (b
) || b
->drouter
!= b
->router_id
))
566 else if (a
== NULL
|| ! IS_ELIGIBLE (a
) || a
->drouter
!= a
->router_id
)
568 else if (b
== NULL
|| ! IS_ELIGIBLE (b
) || b
->drouter
!= b
->router_id
)
571 if (a
->drouter
== a
->router_id
&& b
->drouter
!= b
->router_id
)
573 if (a
->drouter
!= a
->router_id
&& b
->drouter
== b
->router_id
)
576 if (a
->priority
> b
->priority
)
578 if (a
->priority
< b
->priority
)
581 if (ntohl (a
->router_id
) > ntohl (b
->router_id
))
583 if (ntohl (a
->router_id
) < ntohl (b
->router_id
))
586 zlog_warn ("Router-ID duplicate ?");
591 dr_election (struct ospf6_interface
*oi
)
593 struct listnode
*node
, *nnode
;
594 struct ospf6_neighbor
*on
, *drouter
, *bdrouter
, myself
;
595 struct ospf6_neighbor
*best_drouter
, *best_bdrouter
;
596 u_char next_state
= 0;
598 drouter
= bdrouter
= NULL
;
599 best_drouter
= best_bdrouter
= NULL
;
601 /* pseudo neighbor myself, including noting current DR/BDR (1) */
602 memset (&myself
, 0, sizeof (myself
));
603 inet_ntop (AF_INET
, &oi
->area
->ospf6
->router_id
, myself
.name
,
604 sizeof (myself
.name
));
605 myself
.state
= OSPF6_NEIGHBOR_TWOWAY
;
606 myself
.drouter
= oi
->drouter
;
607 myself
.bdrouter
= oi
->bdrouter
;
608 myself
.priority
= oi
->priority
;
609 myself
.router_id
= oi
->area
->ospf6
->router_id
;
611 /* Electing BDR (2) */
612 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
613 bdrouter
= better_bdrouter (bdrouter
, on
);
615 best_bdrouter
= bdrouter
;
616 bdrouter
= better_bdrouter (best_bdrouter
, &myself
);
618 /* Electing DR (3) */
619 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
620 drouter
= better_drouter (drouter
, on
);
622 best_drouter
= drouter
;
623 drouter
= better_drouter (best_drouter
, &myself
);
627 /* the router itself is newly/no longer DR/BDR (4) */
628 if ((drouter
== &myself
&& myself
.drouter
!= myself
.router_id
) ||
629 (drouter
!= &myself
&& myself
.drouter
== myself
.router_id
) ||
630 (bdrouter
== &myself
&& myself
.bdrouter
!= myself
.router_id
) ||
631 (bdrouter
!= &myself
&& myself
.bdrouter
== myself
.router_id
))
633 myself
.drouter
= (drouter
? drouter
->router_id
: htonl (0));
634 myself
.bdrouter
= (bdrouter
? bdrouter
->router_id
: htonl (0));
636 /* compatible to Electing BDR (2) */
637 bdrouter
= better_bdrouter (best_bdrouter
, &myself
);
639 /* compatible to Electing DR (3) */
640 drouter
= better_drouter (best_drouter
, &myself
);
645 /* Set interface state accordingly (5) */
646 if (drouter
&& drouter
== &myself
)
647 next_state
= OSPF6_INTERFACE_DR
;
648 else if (bdrouter
&& bdrouter
== &myself
)
649 next_state
= OSPF6_INTERFACE_BDR
;
651 next_state
= OSPF6_INTERFACE_DROTHER
;
653 /* If NBMA, schedule Start for each neighbor having priority of 0 (6) */
656 /* If DR or BDR change, invoke AdjOK? for each neighbor (7) */
657 /* RFC 2328 section 12.4. Originating LSAs (3) will be handled
658 accordingly after AdjOK */
659 if (oi
->drouter
!= (drouter
? drouter
->router_id
: htonl (0)) ||
660 oi
->bdrouter
!= (bdrouter
? bdrouter
->router_id
: htonl (0)))
662 if (IS_OSPF6_DEBUG_INTERFACE
)
663 zlog_debug ("DR Election on %s: DR: %s BDR: %s", oi
->interface
->name
,
664 (drouter
? drouter
->name
: "0.0.0.0"),
665 (bdrouter
? bdrouter
->name
: "0.0.0.0"));
667 for (ALL_LIST_ELEMENTS_RO (oi
->neighbor_list
, node
, on
))
669 if (on
->state
< OSPF6_NEIGHBOR_TWOWAY
)
671 /* Schedule AdjOK. */
672 thread_add_event (master
, adj_ok
, on
, 0);
676 oi
->drouter
= (drouter
? drouter
->router_id
: htonl (0));
677 oi
->bdrouter
= (bdrouter
? bdrouter
->router_id
: htonl (0));
682 /* Interface State Machine */
684 interface_up (struct thread
*thread
)
686 struct ospf6_interface
*oi
;
688 oi
= (struct ospf6_interface
*) THREAD_ARG (thread
);
689 assert (oi
&& oi
->interface
);
691 if (IS_OSPF6_DEBUG_INTERFACE
)
692 zlog_debug ("Interface Event %s: [InterfaceUp]",
693 oi
->interface
->name
);
695 /* check physical interface is up */
696 if (! if_is_operative (oi
->interface
))
698 if (IS_OSPF6_DEBUG_INTERFACE
)
699 zlog_debug ("Interface %s is down, can't execute [InterfaceUp]",
700 oi
->interface
->name
);
704 /* check interface has a link-local address */
705 if (! (ospf6_interface_get_linklocal_address(oi
->interface
)
706 || if_is_loopback(oi
->interface
)))
708 if (IS_OSPF6_DEBUG_INTERFACE
)
709 zlog_debug ("Interface %s has no link local address, can't execute [InterfaceUp]",
710 oi
->interface
->name
);
715 ospf6_interface_recalculate_cost (oi
);
717 /* if already enabled, do nothing */
718 if (oi
->state
> OSPF6_INTERFACE_DOWN
)
720 if (IS_OSPF6_DEBUG_INTERFACE
)
721 zlog_debug ("Interface %s already enabled",
722 oi
->interface
->name
);
726 /* If no area assigned, return */
727 if (oi
->area
== NULL
)
729 zlog_debug ("%s: Not scheduleing Hello for %s as there is no area assigned yet", __func__
,
730 oi
->interface
->name
);
734 /* Join AllSPFRouters */
735 if (ospf6_sso (oi
->interface
->ifindex
, &allspfrouters6
, IPV6_JOIN_GROUP
) < 0)
737 if (oi
->sso_try_cnt
++ < OSPF6_INTERFACE_SSO_RETRY_MAX
)
739 zlog_info("Scheduling %s for sso retry, trial count: %d",
740 oi
->interface
->name
, oi
->sso_try_cnt
);
741 thread_add_timer (master
, interface_up
, oi
,
742 OSPF6_INTERFACE_SSO_RETRY_INT
);
746 oi
->sso_try_cnt
= 0; /* Reset on success */
748 /* Update interface route */
749 ospf6_interface_connected_route_update (oi
->interface
);
752 if (! CHECK_FLAG (oi
->flag
, OSPF6_INTERFACE_PASSIVE
))
753 oi
->thread_send_hello
= thread_add_event (master
, ospf6_hello_send
, oi
, 0);
755 /* decide next interface state */
756 if ((if_is_pointopoint (oi
->interface
)) ||
757 (oi
->type
== OSPF_IFTYPE_POINTOPOINT
)) {
758 ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT
, oi
);
760 else if (oi
->priority
== 0)
761 ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER
, oi
);
764 ospf6_interface_state_change (OSPF6_INTERFACE_WAITING
, oi
);
765 thread_add_timer (master
, wait_timer
, oi
, oi
->dead_interval
);
772 wait_timer (struct thread
*thread
)
774 struct ospf6_interface
*oi
;
776 oi
= (struct ospf6_interface
*) THREAD_ARG (thread
);
777 assert (oi
&& oi
->interface
);
779 if (IS_OSPF6_DEBUG_INTERFACE
)
780 zlog_debug ("Interface Event %s: [WaitTimer]",
781 oi
->interface
->name
);
783 if (oi
->state
== OSPF6_INTERFACE_WAITING
)
784 ospf6_interface_state_change (dr_election (oi
), oi
);
790 backup_seen (struct thread
*thread
)
792 struct ospf6_interface
*oi
;
794 oi
= (struct ospf6_interface
*) THREAD_ARG (thread
);
795 assert (oi
&& oi
->interface
);
797 if (IS_OSPF6_DEBUG_INTERFACE
)
798 zlog_debug ("Interface Event %s: [BackupSeen]",
799 oi
->interface
->name
);
801 if (oi
->state
== OSPF6_INTERFACE_WAITING
)
802 ospf6_interface_state_change (dr_election (oi
), oi
);
808 neighbor_change (struct thread
*thread
)
810 struct ospf6_interface
*oi
;
812 oi
= (struct ospf6_interface
*) THREAD_ARG (thread
);
813 assert (oi
&& oi
->interface
);
815 if (IS_OSPF6_DEBUG_INTERFACE
)
816 zlog_debug ("Interface Event %s: [NeighborChange]",
817 oi
->interface
->name
);
819 if (oi
->state
== OSPF6_INTERFACE_DROTHER
||
820 oi
->state
== OSPF6_INTERFACE_BDR
||
821 oi
->state
== OSPF6_INTERFACE_DR
)
822 ospf6_interface_state_change (dr_election (oi
), oi
);
828 interface_down (struct thread
*thread
)
830 struct ospf6_interface
*oi
;
831 struct listnode
*node
, *nnode
;
832 struct ospf6_neighbor
*on
;
834 oi
= (struct ospf6_interface
*) THREAD_ARG (thread
);
835 assert (oi
&& oi
->interface
);
837 if (IS_OSPF6_DEBUG_INTERFACE
)
838 zlog_debug ("Interface Event %s: [InterfaceDown]",
839 oi
->interface
->name
);
842 THREAD_OFF (oi
->thread_send_hello
);
844 /* Leave AllSPFRouters */
845 if (oi
->state
> OSPF6_INTERFACE_DOWN
)
846 ospf6_sso (oi
->interface
->ifindex
, &allspfrouters6
, IPV6_LEAVE_GROUP
);
848 ospf6_interface_state_change (OSPF6_INTERFACE_DOWN
, oi
);
850 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
851 ospf6_neighbor_delete (on
);
853 list_delete_all_node (oi
->neighbor_list
);
855 /* When interface state is reset, also reset information about
856 * DR election, as it is no longer valid. */
857 oi
->drouter
= oi
->prev_drouter
= htonl(0);
858 oi
->bdrouter
= oi
->prev_bdrouter
= htonl(0);
863 /* show specified interface structure */
865 ospf6_interface_show (struct vty
*vty
, struct interface
*ifp
)
867 struct ospf6_interface
*oi
;
871 char strbuf
[64], drouter
[32], bdrouter
[32];
872 const char *updown
[3] = {"down", "up", NULL
};
874 struct timeval res
, now
;
876 struct ospf6_lsa
*lsa
;
878 /* check physical interface type */
879 if (if_is_loopback (ifp
))
881 else if (if_is_broadcast (ifp
))
883 else if (if_is_pointopoint (ifp
))
884 type
= "POINTOPOINT";
888 vty_out (vty
, "%s is %s, type %s%s",
889 ifp
->name
, updown
[if_is_operative (ifp
)], type
,
891 vty_out (vty
, " Interface ID: %d%s", ifp
->ifindex
, VNL
);
893 if (ifp
->info
== NULL
)
895 vty_out (vty
, " OSPF not enabled on this interface%s", VNL
);
899 oi
= (struct ospf6_interface
*) ifp
->info
;
901 vty_out (vty
, " Internet Address:%s", VNL
);
903 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, i
, c
))
906 prefix2str (p
, strbuf
, sizeof (strbuf
));
910 vty_out (vty
, " inet : %s%s", strbuf
,
914 vty_out (vty
, " inet6: %s%s", strbuf
,
918 vty_out (vty
, " ??? : %s%s", strbuf
,
926 vty_out (vty
, " Instance ID %d, Interface MTU %d (autodetect: %d)%s",
927 oi
->instance_id
, oi
->ifmtu
, ifp
->mtu6
, VNL
);
928 vty_out (vty
, " MTU mismatch detection: %s%s", oi
->mtu_ignore
?
929 "disabled" : "enabled", VNL
);
930 inet_ntop (AF_INET
, &oi
->area
->area_id
,
931 strbuf
, sizeof (strbuf
));
932 vty_out (vty
, " Area ID %s, Cost %hu%s", strbuf
, oi
->cost
,
936 vty_out (vty
, " Not Attached to Area%s", VNL
);
938 vty_out (vty
, " State %s, Transmit Delay %d sec, Priority %d%s",
939 ospf6_interface_state_str
[oi
->state
],
940 oi
->transdelay
, oi
->priority
,
942 vty_out (vty
, " Timer intervals configured:%s", VNL
);
943 vty_out (vty
, " Hello %d, Dead %d, Retransmit %d%s",
944 oi
->hello_interval
, oi
->dead_interval
, oi
->rxmt_interval
,
947 inet_ntop (AF_INET
, &oi
->drouter
, drouter
, sizeof (drouter
));
948 inet_ntop (AF_INET
, &oi
->bdrouter
, bdrouter
, sizeof (bdrouter
));
949 vty_out (vty
, " DR: %s BDR: %s%s", drouter
, bdrouter
, VNL
);
951 vty_out (vty
, " Number of I/F scoped LSAs is %u%s",
952 oi
->lsdb
->count
, VNL
);
954 quagga_gettime (QUAGGA_CLK_MONOTONIC
, &now
);
957 if (oi
->thread_send_lsupdate
)
958 timersub (&oi
->thread_send_lsupdate
->u
.sands
, &now
, &res
);
959 timerstring (&res
, duration
, sizeof (duration
));
960 vty_out (vty
, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
961 oi
->lsupdate_list
->count
, duration
,
962 (oi
->thread_send_lsupdate
? "on" : "off"),
964 for (lsa
= ospf6_lsdb_head (oi
->lsupdate_list
); lsa
;
965 lsa
= ospf6_lsdb_next (lsa
))
966 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
969 if (oi
->thread_send_lsack
)
970 timersub (&oi
->thread_send_lsack
->u
.sands
, &now
, &res
);
971 timerstring (&res
, duration
, sizeof (duration
));
972 vty_out (vty
, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
973 oi
->lsack_list
->count
, duration
,
974 (oi
->thread_send_lsack
? "on" : "off"),
976 for (lsa
= ospf6_lsdb_head (oi
->lsack_list
); lsa
;
977 lsa
= ospf6_lsdb_next (lsa
))
978 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
984 DEFUN (show_ipv6_ospf6_interface
,
985 show_ipv6_ospf6_interface_ifname_cmd
,
986 "show ipv6 ospf6 interface IFNAME",
994 struct interface
*ifp
;
999 ifp
= if_lookup_by_name (argv
[0]);
1002 vty_out (vty
, "No such Interface: %s%s", argv
[0],
1006 ospf6_interface_show (vty
, ifp
);
1010 for (ALL_LIST_ELEMENTS_RO (iflist
, i
, ifp
))
1011 ospf6_interface_show (vty
, ifp
);
1017 ALIAS (show_ipv6_ospf6_interface
,
1018 show_ipv6_ospf6_interface_cmd
,
1019 "show ipv6 ospf6 interface",
1026 DEFUN (show_ipv6_ospf6_interface_ifname_prefix
,
1027 show_ipv6_ospf6_interface_ifname_prefix_cmd
,
1028 "show ipv6 ospf6 interface IFNAME prefix",
1034 "Display connected prefixes to advertise\n"
1037 struct interface
*ifp
;
1038 struct ospf6_interface
*oi
;
1040 ifp
= if_lookup_by_name (argv
[0]);
1043 vty_out (vty
, "No such Interface: %s%s", argv
[0], VNL
);
1050 vty_out (vty
, "OSPFv3 is not enabled on %s%s", argv
[0], VNL
);
1056 ospf6_route_table_show (vty
, argc
, argv
, oi
->route_connected
);
1061 ALIAS (show_ipv6_ospf6_interface_ifname_prefix
,
1062 show_ipv6_ospf6_interface_ifname_prefix_detail_cmd
,
1063 "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)",
1069 "Display connected prefixes to advertise\n"
1070 OSPF6_ROUTE_ADDRESS_STR
1071 OSPF6_ROUTE_PREFIX_STR
1072 "Display details of the prefixes\n"
1075 ALIAS (show_ipv6_ospf6_interface_ifname_prefix
,
1076 show_ipv6_ospf6_interface_ifname_prefix_match_cmd
,
1077 "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)",
1083 "Display connected prefixes to advertise\n"
1084 OSPF6_ROUTE_PREFIX_STR
1085 OSPF6_ROUTE_MATCH_STR
1086 "Display details of the prefixes\n"
1089 DEFUN (show_ipv6_ospf6_interface_prefix
,
1090 show_ipv6_ospf6_interface_prefix_cmd
,
1091 "show ipv6 ospf6 interface prefix",
1096 "Display connected prefixes to advertise\n"
1100 struct ospf6_interface
*oi
;
1101 struct interface
*ifp
;
1103 for (ALL_LIST_ELEMENTS_RO (iflist
, i
, ifp
))
1105 oi
= (struct ospf6_interface
*) ifp
->info
;
1109 ospf6_route_table_show (vty
, argc
, argv
, oi
->route_connected
);
1115 ALIAS (show_ipv6_ospf6_interface_prefix
,
1116 show_ipv6_ospf6_interface_prefix_detail_cmd
,
1117 "show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)",
1122 "Display connected prefixes to advertise\n"
1123 OSPF6_ROUTE_ADDRESS_STR
1124 OSPF6_ROUTE_PREFIX_STR
1125 "Display details of the prefixes\n"
1128 ALIAS (show_ipv6_ospf6_interface_prefix
,
1129 show_ipv6_ospf6_interface_prefix_match_cmd
,
1130 "show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)",
1135 "Display connected prefixes to advertise\n"
1136 OSPF6_ROUTE_PREFIX_STR
1137 OSPF6_ROUTE_MATCH_STR
1138 "Display details of the prefixes\n"
1142 /* interface variable set command */
1143 DEFUN (ipv6_ospf6_ifmtu
,
1144 ipv6_ospf6_ifmtu_cmd
,
1145 "ipv6 ospf6 ifmtu <1-65535>",
1149 "OSPFv3 Interface MTU\n"
1152 struct ospf6_interface
*oi
;
1153 struct interface
*ifp
;
1154 unsigned int ifmtu
, iobuflen
;
1155 struct listnode
*node
, *nnode
;
1156 struct ospf6_neighbor
*on
;
1158 ifp
= (struct interface
*) vty
->index
;
1161 oi
= (struct ospf6_interface
*) ifp
->info
;
1163 oi
= ospf6_interface_create (ifp
);
1166 ifmtu
= strtol (argv
[0], NULL
, 10);
1168 if (oi
->ifmtu
== ifmtu
)
1171 if (ifp
->mtu6
!= 0 && ifp
->mtu6
< ifmtu
)
1173 vty_out (vty
, "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)%s",
1174 ifp
->name
, ifp
->mtu6
, VNL
);
1178 if (oi
->ifmtu
< ifmtu
)
1180 iobuflen
= ospf6_iobuf_size (ifmtu
);
1181 if (iobuflen
< ifmtu
)
1183 vty_out (vty
, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
1184 ifp
->name
, iobuflen
, VNL
);
1185 oi
->ifmtu
= iobuflen
;
1193 /* re-establish adjacencies */
1194 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
1196 THREAD_OFF (on
->inactivity_timer
);
1197 thread_add_event (master
, inactivity_timer
, on
, 0);
1203 DEFUN (no_ipv6_ospf6_ifmtu
,
1204 no_ipv6_ospf6_ifmtu_cmd
,
1205 "no ipv6 ospf6 ifmtu",
1212 struct ospf6_interface
*oi
;
1213 struct interface
*ifp
;
1214 unsigned int iobuflen
;
1215 struct listnode
*node
, *nnode
;
1216 struct ospf6_neighbor
*on
;
1218 ifp
= (struct interface
*) vty
->index
;
1221 oi
= (struct ospf6_interface
*) ifp
->info
;
1223 oi
= ospf6_interface_create (ifp
);
1226 if (oi
->ifmtu
< ifp
->mtu
)
1228 iobuflen
= ospf6_iobuf_size (ifp
->mtu
);
1229 if (iobuflen
< ifp
->mtu
)
1231 vty_out (vty
, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
1232 ifp
->name
, iobuflen
, VNL
);
1233 oi
->ifmtu
= iobuflen
;
1236 oi
->ifmtu
= ifp
->mtu
;
1239 oi
->ifmtu
= ifp
->mtu
;
1241 /* re-establish adjacencies */
1242 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
1244 THREAD_OFF (on
->inactivity_timer
);
1245 thread_add_event (master
, inactivity_timer
, on
, 0);
1251 DEFUN (ipv6_ospf6_cost
,
1252 ipv6_ospf6_cost_cmd
,
1253 "ipv6 ospf6 cost <1-65535>",
1257 "Outgoing metric of this interface\n"
1260 struct ospf6_interface
*oi
;
1261 struct interface
*ifp
;
1262 unsigned long int lcost
;
1264 ifp
= (struct interface
*) vty
->index
;
1267 oi
= (struct ospf6_interface
*) ifp
->info
;
1269 oi
= ospf6_interface_create (ifp
);
1272 lcost
= strtol (argv
[0], NULL
, 10);
1274 if (lcost
> UINT32_MAX
)
1276 vty_out (vty
, "Cost %ld is out of range%s", lcost
, VNL
);
1280 if (oi
->cost
== lcost
)
1284 SET_FLAG (oi
->flag
, OSPF6_INTERFACE_NOAUTOCOST
);
1286 ospf6_interface_recalculate_cost(oi
);
1291 DEFUN (no_ipv6_ospf6_cost
,
1292 no_ipv6_ospf6_cost_cmd
,
1293 "no ipv6 ospf6 cost",
1297 "Calculate interface cost from bandwidth\n"
1300 struct ospf6_interface
*oi
;
1301 struct interface
*ifp
;
1303 ifp
= (struct interface
*) vty
->index
;
1306 oi
= (struct ospf6_interface
*) ifp
->info
;
1308 oi
= ospf6_interface_create (ifp
);
1311 UNSET_FLAG (oi
->flag
, OSPF6_INTERFACE_NOAUTOCOST
);
1313 ospf6_interface_recalculate_cost(oi
);
1318 DEFUN (auto_cost_reference_bandwidth
,
1319 auto_cost_reference_bandwidth_cmd
,
1320 "auto-cost reference-bandwidth <1-4294967>",
1321 "Calculate OSPF interface cost according to bandwidth\n"
1322 "Use reference bandwidth method to assign OSPF cost\n"
1323 "The reference bandwidth in terms of Mbits per second\n")
1325 struct ospf6
*o
= vty
->index
;
1326 struct ospf6_area
*oa
;
1327 struct ospf6_interface
*oi
;
1328 struct listnode
*i
, *j
;
1331 refbw
= strtol (argv
[0], NULL
, 10);
1332 if (refbw
< 1 || refbw
> 4294967)
1334 vty_out (vty
, "reference-bandwidth value is invalid%s", VTY_NEWLINE
);
1338 /* If reference bandwidth is changed. */
1339 if ((refbw
* 1000) == o
->ref_bandwidth
)
1342 o
->ref_bandwidth
= refbw
* 1000;
1343 for (ALL_LIST_ELEMENTS_RO (o
->area_list
, i
, oa
))
1344 for (ALL_LIST_ELEMENTS_RO (oa
->if_list
, j
, oi
))
1345 ospf6_interface_recalculate_cost (oi
);
1350 DEFUN (no_auto_cost_reference_bandwidth
,
1351 no_auto_cost_reference_bandwidth_cmd
,
1352 "no auto-cost reference-bandwidth",
1354 "Calculate OSPF interface cost according to bandwidth\n"
1355 "Use reference bandwidth method to assign OSPF cost\n")
1357 struct ospf6
*o
= vty
->index
;
1358 struct ospf6_area
*oa
;
1359 struct ospf6_interface
*oi
;
1360 struct listnode
*i
, *j
;
1362 if (o
->ref_bandwidth
== OSPF6_REFERENCE_BANDWIDTH
)
1365 o
->ref_bandwidth
= OSPF6_REFERENCE_BANDWIDTH
;
1366 for (ALL_LIST_ELEMENTS_RO (o
->area_list
, i
, oa
))
1367 for (ALL_LIST_ELEMENTS_RO (oa
->if_list
, j
, oi
))
1368 ospf6_interface_recalculate_cost (oi
);
1373 DEFUN (ipv6_ospf6_hellointerval
,
1374 ipv6_ospf6_hellointerval_cmd
,
1375 "ipv6 ospf6 hello-interval <1-65535>",
1378 "Interval time of Hello packets\n"
1382 struct ospf6_interface
*oi
;
1383 struct interface
*ifp
;
1385 ifp
= (struct interface
*) vty
->index
;
1388 oi
= (struct ospf6_interface
*) ifp
->info
;
1390 oi
= ospf6_interface_create (ifp
);
1393 oi
->hello_interval
= strtol (argv
[0], NULL
, 10);
1397 /* interface variable set command */
1398 DEFUN (ipv6_ospf6_deadinterval
,
1399 ipv6_ospf6_deadinterval_cmd
,
1400 "ipv6 ospf6 dead-interval <1-65535>",
1403 "Interval time after which a neighbor is declared down\n"
1407 struct ospf6_interface
*oi
;
1408 struct interface
*ifp
;
1410 ifp
= (struct interface
*) vty
->index
;
1413 oi
= (struct ospf6_interface
*) ifp
->info
;
1415 oi
= ospf6_interface_create (ifp
);
1418 oi
->dead_interval
= strtol (argv
[0], NULL
, 10);
1422 /* interface variable set command */
1423 DEFUN (ipv6_ospf6_transmitdelay
,
1424 ipv6_ospf6_transmitdelay_cmd
,
1425 "ipv6 ospf6 transmit-delay <1-3600>",
1428 "Transmit delay of this interface\n"
1432 struct ospf6_interface
*oi
;
1433 struct interface
*ifp
;
1435 ifp
= (struct interface
*) vty
->index
;
1438 oi
= (struct ospf6_interface
*) ifp
->info
;
1440 oi
= ospf6_interface_create (ifp
);
1443 oi
->transdelay
= strtol (argv
[0], NULL
, 10);
1447 /* interface variable set command */
1448 DEFUN (ipv6_ospf6_retransmitinterval
,
1449 ipv6_ospf6_retransmitinterval_cmd
,
1450 "ipv6 ospf6 retransmit-interval <1-65535>",
1453 "Time between retransmitting lost link state advertisements\n"
1457 struct ospf6_interface
*oi
;
1458 struct interface
*ifp
;
1460 ifp
= (struct interface
*) vty
->index
;
1463 oi
= (struct ospf6_interface
*) ifp
->info
;
1465 oi
= ospf6_interface_create (ifp
);
1468 oi
->rxmt_interval
= strtol (argv
[0], NULL
, 10);
1472 /* interface variable set command */
1473 DEFUN (ipv6_ospf6_priority
,
1474 ipv6_ospf6_priority_cmd
,
1475 "ipv6 ospf6 priority <0-255>",
1482 struct ospf6_interface
*oi
;
1483 struct interface
*ifp
;
1485 ifp
= (struct interface
*) vty
->index
;
1488 oi
= (struct ospf6_interface
*) ifp
->info
;
1490 oi
= ospf6_interface_create (ifp
);
1493 oi
->priority
= strtol (argv
[0], NULL
, 10);
1496 (oi
->state
== OSPF6_INTERFACE_DROTHER
||
1497 oi
->state
== OSPF6_INTERFACE_BDR
||
1498 oi
->state
== OSPF6_INTERFACE_DR
))
1499 ospf6_interface_state_change (dr_election (oi
), oi
);
1504 DEFUN (ipv6_ospf6_instance
,
1505 ipv6_ospf6_instance_cmd
,
1506 "ipv6 ospf6 instance-id <0-255>",
1509 "Instance ID for this interface\n"
1510 "Instance ID value\n"
1513 struct ospf6_interface
*oi
;
1514 struct interface
*ifp
;
1516 ifp
= (struct interface
*)vty
->index
;
1519 oi
= (struct ospf6_interface
*)ifp
->info
;
1521 oi
= ospf6_interface_create (ifp
);
1524 oi
->instance_id
= strtol (argv
[0], NULL
, 10);
1528 DEFUN (ipv6_ospf6_passive
,
1529 ipv6_ospf6_passive_cmd
,
1530 "ipv6 ospf6 passive",
1533 "passive interface, No adjacency will be formed on this interface\n"
1536 struct ospf6_interface
*oi
;
1537 struct interface
*ifp
;
1538 struct listnode
*node
, *nnode
;
1539 struct ospf6_neighbor
*on
;
1541 ifp
= (struct interface
*) vty
->index
;
1544 oi
= (struct ospf6_interface
*) ifp
->info
;
1546 oi
= ospf6_interface_create (ifp
);
1549 SET_FLAG (oi
->flag
, OSPF6_INTERFACE_PASSIVE
);
1550 THREAD_OFF (oi
->thread_send_hello
);
1552 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
1554 THREAD_OFF (on
->inactivity_timer
);
1555 thread_add_event (master
, inactivity_timer
, on
, 0);
1561 DEFUN (no_ipv6_ospf6_passive
,
1562 no_ipv6_ospf6_passive_cmd
,
1563 "no ipv6 ospf6 passive",
1567 "passive interface: No Adjacency will be formed on this I/F\n"
1570 struct ospf6_interface
*oi
;
1571 struct interface
*ifp
;
1573 ifp
= (struct interface
*) vty
->index
;
1576 oi
= (struct ospf6_interface
*) ifp
->info
;
1578 oi
= ospf6_interface_create (ifp
);
1581 UNSET_FLAG (oi
->flag
, OSPF6_INTERFACE_PASSIVE
);
1582 THREAD_OFF (oi
->thread_send_hello
);
1583 oi
->thread_send_hello
=
1584 thread_add_event (master
, ospf6_hello_send
, oi
, 0);
1589 DEFUN (ipv6_ospf6_mtu_ignore
,
1590 ipv6_ospf6_mtu_ignore_cmd
,
1591 "ipv6 ospf6 mtu-ignore",
1594 "Ignore MTU mismatch on this interface\n"
1597 struct ospf6_interface
*oi
;
1598 struct interface
*ifp
;
1600 ifp
= (struct interface
*) vty
->index
;
1603 oi
= (struct ospf6_interface
*) ifp
->info
;
1605 oi
= ospf6_interface_create (ifp
);
1613 DEFUN (no_ipv6_ospf6_mtu_ignore
,
1614 no_ipv6_ospf6_mtu_ignore_cmd
,
1615 "no ipv6 ospf6 mtu-ignore",
1619 "Ignore MTU mismatch on this interface\n"
1622 struct ospf6_interface
*oi
;
1623 struct interface
*ifp
;
1625 ifp
= (struct interface
*) vty
->index
;
1628 oi
= (struct ospf6_interface
*) ifp
->info
;
1630 oi
= ospf6_interface_create (ifp
);
1638 DEFUN (ipv6_ospf6_advertise_prefix_list
,
1639 ipv6_ospf6_advertise_prefix_list_cmd
,
1640 "ipv6 ospf6 advertise prefix-list WORD",
1643 "Advertising options\n"
1644 "Filter prefix using prefix-list\n"
1645 "Prefix list name\n"
1648 struct ospf6_interface
*oi
;
1649 struct interface
*ifp
;
1651 ifp
= (struct interface
*) vty
->index
;
1654 oi
= (struct ospf6_interface
*) ifp
->info
;
1656 oi
= ospf6_interface_create (ifp
);
1660 XFREE (MTYPE_PREFIX_LIST_STR
, oi
->plist_name
);
1661 oi
->plist_name
= XSTRDUP (MTYPE_PREFIX_LIST_STR
, argv
[0]);
1663 ospf6_interface_connected_route_update (oi
->interface
);
1667 OSPF6_LINK_LSA_SCHEDULE (oi
);
1668 if (oi
->state
== OSPF6_INTERFACE_DR
)
1670 OSPF6_NETWORK_LSA_SCHEDULE (oi
);
1671 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi
);
1673 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi
->area
);
1679 DEFUN (no_ipv6_ospf6_advertise_prefix_list
,
1680 no_ipv6_ospf6_advertise_prefix_list_cmd
,
1681 "no ipv6 ospf6 advertise prefix-list",
1685 "Advertising options\n"
1686 "Filter prefix using prefix-list\n"
1689 struct ospf6_interface
*oi
;
1690 struct interface
*ifp
;
1692 ifp
= (struct interface
*) vty
->index
;
1695 oi
= (struct ospf6_interface
*) ifp
->info
;
1697 oi
= ospf6_interface_create (ifp
);
1702 XFREE (MTYPE_PREFIX_LIST_STR
, oi
->plist_name
);
1703 oi
->plist_name
= NULL
;
1706 ospf6_interface_connected_route_update (oi
->interface
);
1710 OSPF6_LINK_LSA_SCHEDULE (oi
);
1711 if (oi
->state
== OSPF6_INTERFACE_DR
)
1713 OSPF6_NETWORK_LSA_SCHEDULE (oi
);
1714 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi
);
1716 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi
->area
);
1722 DEFUN (ipv6_ospf6_network
,
1723 ipv6_ospf6_network_cmd
,
1724 "ipv6 ospf6 network (broadcast|point-to-point)",
1728 "Specify OSPFv6 broadcast network\n"
1729 "Specify OSPF6 point-to-point network\n"
1732 struct ospf6_interface
*oi
;
1733 struct interface
*ifp
;
1735 ifp
= (struct interface
*) vty
->index
;
1738 oi
= (struct ospf6_interface
*) ifp
->info
;
1740 oi
= ospf6_interface_create (ifp
);
1744 if (strncmp (argv
[0], "b", 1) == 0)
1746 if (oi
->type
== OSPF_IFTYPE_BROADCAST
)
1749 oi
->type
= OSPF_IFTYPE_BROADCAST
;
1751 else if (strncmp (argv
[0], "point-to-p", 10) == 0)
1753 if (oi
->type
== OSPF_IFTYPE_POINTOPOINT
) {
1756 oi
->type
= OSPF_IFTYPE_POINTOPOINT
;
1759 /* Reset the interface */
1760 thread_add_event (master
, interface_down
, oi
, 0);
1761 thread_add_event (master
, interface_up
, oi
, 0);
1766 DEFUN (no_ipv6_ospf6_network
,
1767 no_ipv6_ospf6_network_cmd
,
1768 "no ipv6 ospf6 network",
1773 "Default to whatever interface type system specifies"
1776 struct ospf6_interface
*oi
;
1777 struct interface
*ifp
;
1780 ifp
= (struct interface
*) vty
->index
;
1783 oi
= (struct ospf6_interface
*) ifp
->info
;
1788 type
= ospf6_default_iftype (ifp
);
1789 if (oi
->type
== type
)
1795 /* Reset the interface */
1796 thread_add_event (master
, interface_down
, oi
, 0);
1797 thread_add_event (master
, interface_up
, oi
, 0);
1803 config_write_ospf6_interface (struct vty
*vty
)
1806 struct ospf6_interface
*oi
;
1807 struct interface
*ifp
;
1809 for (ALL_LIST_ELEMENTS_RO (iflist
, i
, ifp
))
1811 oi
= (struct ospf6_interface
*) ifp
->info
;
1815 vty_out (vty
, "interface %s%s",
1816 oi
->interface
->name
, VNL
);
1819 vty_out (vty
, " description %s%s", ifp
->desc
, VNL
);
1820 if (ifp
->mtu6
!= oi
->ifmtu
)
1821 vty_out (vty
, " ipv6 ospf6 ifmtu %d%s", oi
->ifmtu
, VNL
);
1823 if (CHECK_FLAG (oi
->flag
, OSPF6_INTERFACE_NOAUTOCOST
))
1824 vty_out (vty
, " ipv6 ospf6 cost %d%s",
1827 if (oi
->hello_interval
!= OSPF6_INTERFACE_HELLO_INTERVAL
)
1828 vty_out (vty
, " ipv6 ospf6 hello-interval %d%s",
1829 oi
->hello_interval
, VNL
);
1831 if (oi
->dead_interval
!= OSPF6_INTERFACE_DEAD_INTERVAL
)
1832 vty_out (vty
, " ipv6 ospf6 dead-interval %d%s",
1833 oi
->dead_interval
, VNL
);
1835 if (oi
->rxmt_interval
!= OSPF6_INTERFACE_RXMT_INTERVAL
)
1836 vty_out (vty
, " ipv6 ospf6 retransmit-interval %d%s",
1837 oi
->rxmt_interval
, VNL
);
1839 if (oi
->priority
!= OSPF6_INTERFACE_PRIORITY
)
1840 vty_out (vty
, " ipv6 ospf6 priority %d%s",
1843 if (oi
->transdelay
!= OSPF6_INTERFACE_TRANSDELAY
)
1844 vty_out (vty
, " ipv6 ospf6 transmit-delay %d%s",
1845 oi
->transdelay
, VNL
);
1847 if (oi
->instance_id
!= OSPF6_INTERFACE_INSTANCE_ID
)
1848 vty_out (vty
, " ipv6 ospf6 instance-id %d%s",
1849 oi
->instance_id
, VNL
);
1852 vty_out (vty
, " ipv6 ospf6 advertise prefix-list %s%s",
1853 oi
->plist_name
, VNL
);
1855 if (CHECK_FLAG (oi
->flag
, OSPF6_INTERFACE_PASSIVE
))
1856 vty_out (vty
, " ipv6 ospf6 passive%s", VNL
);
1859 vty_out (vty
, " ipv6 ospf6 mtu-ignore%s", VNL
);
1861 if (oi
->type
== OSPF_IFTYPE_POINTOPOINT
)
1862 vty_out (vty
, " ipv6 ospf6 network point-to-point%s", VNL
);
1863 else if (oi
->type
== OSPF_IFTYPE_BROADCAST
)
1864 vty_out (vty
, " ipv6 ospf6 network broadcast%s", VNL
);
1866 ospf6_bfd_write_config(vty
, oi
);
1868 vty_out (vty
, "!%s", VNL
);
1873 static struct cmd_node interface_node
=
1881 ospf6_interface_init (void)
1883 /* Install interface node. */
1884 install_node (&interface_node
, config_write_ospf6_interface
);
1886 install_element (VIEW_NODE
, &show_ipv6_ospf6_interface_cmd
);
1887 install_element (VIEW_NODE
, &show_ipv6_ospf6_interface_prefix_cmd
);
1888 install_element (VIEW_NODE
, &show_ipv6_ospf6_interface_prefix_detail_cmd
);
1889 install_element (VIEW_NODE
, &show_ipv6_ospf6_interface_prefix_match_cmd
);
1890 install_element (VIEW_NODE
, &show_ipv6_ospf6_interface_ifname_cmd
);
1891 install_element (VIEW_NODE
, &show_ipv6_ospf6_interface_ifname_prefix_cmd
);
1892 install_element (VIEW_NODE
, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd
);
1893 install_element (VIEW_NODE
, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd
);
1894 install_element (ENABLE_NODE
, &show_ipv6_ospf6_interface_cmd
);
1895 install_element (ENABLE_NODE
, &show_ipv6_ospf6_interface_prefix_cmd
);
1896 install_element (ENABLE_NODE
, &show_ipv6_ospf6_interface_prefix_detail_cmd
);
1897 install_element (ENABLE_NODE
, &show_ipv6_ospf6_interface_prefix_match_cmd
);
1898 install_element (ENABLE_NODE
, &show_ipv6_ospf6_interface_ifname_cmd
);
1899 install_element (ENABLE_NODE
, &show_ipv6_ospf6_interface_ifname_prefix_cmd
);
1900 install_element (ENABLE_NODE
, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd
);
1901 install_element (ENABLE_NODE
, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd
);
1903 install_element (CONFIG_NODE
, &interface_cmd
);
1904 install_default (INTERFACE_NODE
);
1905 install_element (INTERFACE_NODE
, &interface_desc_cmd
);
1906 install_element (INTERFACE_NODE
, &no_interface_desc_cmd
);
1907 install_element (INTERFACE_NODE
, &ipv6_ospf6_cost_cmd
);
1908 install_element (INTERFACE_NODE
, &no_ipv6_ospf6_cost_cmd
);
1909 install_element (INTERFACE_NODE
, &ipv6_ospf6_ifmtu_cmd
);
1910 install_element (INTERFACE_NODE
, &no_ipv6_ospf6_ifmtu_cmd
);
1911 install_element (INTERFACE_NODE
, &ipv6_ospf6_deadinterval_cmd
);
1912 install_element (INTERFACE_NODE
, &ipv6_ospf6_hellointerval_cmd
);
1913 install_element (INTERFACE_NODE
, &ipv6_ospf6_priority_cmd
);
1914 install_element (INTERFACE_NODE
, &ipv6_ospf6_retransmitinterval_cmd
);
1915 install_element (INTERFACE_NODE
, &ipv6_ospf6_transmitdelay_cmd
);
1916 install_element (INTERFACE_NODE
, &ipv6_ospf6_instance_cmd
);
1918 install_element (INTERFACE_NODE
, &ipv6_ospf6_passive_cmd
);
1919 install_element (INTERFACE_NODE
, &no_ipv6_ospf6_passive_cmd
);
1921 install_element (INTERFACE_NODE
, &ipv6_ospf6_mtu_ignore_cmd
);
1922 install_element (INTERFACE_NODE
, &no_ipv6_ospf6_mtu_ignore_cmd
);
1924 install_element (INTERFACE_NODE
, &ipv6_ospf6_advertise_prefix_list_cmd
);
1925 install_element (INTERFACE_NODE
, &no_ipv6_ospf6_advertise_prefix_list_cmd
);
1927 install_element (INTERFACE_NODE
, &ipv6_ospf6_network_cmd
);
1928 install_element (INTERFACE_NODE
, &no_ipv6_ospf6_network_cmd
);
1930 /* reference bandwidth commands */
1931 install_element (OSPF6_NODE
, &auto_cost_reference_bandwidth_cmd
);
1932 install_element (OSPF6_NODE
, &no_auto_cost_reference_bandwidth_cmd
);
1935 /* Clear the specified interface structure */
1937 ospf6_interface_clear (struct vty
*vty
, struct interface
*ifp
)
1939 struct ospf6_interface
*oi
;
1941 if (!if_is_operative (ifp
))
1944 if (ifp
->info
== NULL
)
1947 oi
= (struct ospf6_interface
*) ifp
->info
;
1949 if (IS_OSPF6_DEBUG_INTERFACE
)
1950 zlog_debug ("Interface %s: clear by reset", ifp
->name
);
1952 /* Reset the interface */
1953 thread_add_event (master
, interface_down
, oi
, 0);
1954 thread_add_event (master
, interface_up
, oi
, 0);
1957 /* Clear interface */
1958 DEFUN (clear_ipv6_ospf6_interface
,
1959 clear_ipv6_ospf6_interface_cmd
,
1960 "clear ipv6 ospf6 interface [IFNAME]",
1968 struct interface
*ifp
;
1969 struct listnode
*node
;
1971 if (argc
== 0) /* Clear all the ospfv3 interfaces. */
1973 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
1974 ospf6_interface_clear (vty
, ifp
);
1976 else /* Interface name is specified. */
1978 if ((ifp
= if_lookup_by_name (argv
[0])) == NULL
)
1980 vty_out (vty
, "No such Interface: %s%s", argv
[0], VNL
);
1983 ospf6_interface_clear (vty
, ifp
);
1990 install_element_ospf6_clear_interface (void)
1992 install_element (ENABLE_NODE
, &clear_ipv6_ospf6_interface_cmd
);
1995 DEFUN (debug_ospf6_interface
,
1996 debug_ospf6_interface_cmd
,
1997 "debug ospf6 interface",
2000 "Debug OSPFv3 Interface\n"
2003 OSPF6_DEBUG_INTERFACE_ON ();
2007 DEFUN (no_debug_ospf6_interface
,
2008 no_debug_ospf6_interface_cmd
,
2009 "no debug ospf6 interface",
2013 "Debug OSPFv3 Interface\n"
2016 OSPF6_DEBUG_INTERFACE_OFF ();
2021 config_write_ospf6_debug_interface (struct vty
*vty
)
2023 if (IS_OSPF6_DEBUG_INTERFACE
)
2024 vty_out (vty
, "debug ospf6 interface%s", VNL
);
2029 install_element_ospf6_debug_interface (void)
2031 install_element (ENABLE_NODE
, &debug_ospf6_interface_cmd
);
2032 install_element (ENABLE_NODE
, &no_debug_ospf6_interface_cmd
);
2033 install_element (CONFIG_NODE
, &debug_ospf6_interface_cmd
);
2034 install_element (CONFIG_NODE
, &no_debug_ospf6_interface_cmd
);