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"
44 #include "ospf6_snmp.h"
46 #include "ospf6_bfd.h"
48 DEFINE_MTYPE_STATIC(OSPF6D
, CFG_PLIST_NAME
, "configured prefix list names")
50 unsigned char conf_debug_ospf6_interface
= 0;
52 const char *ospf6_interface_state_str
[] =
65 struct ospf6_interface
*
66 ospf6_interface_lookup_by_ifindex (ifindex_t ifindex
)
68 struct ospf6_interface
*oi
;
69 struct interface
*ifp
;
71 ifp
= if_lookup_by_index (ifindex
);
73 return (struct ospf6_interface
*) NULL
;
75 oi
= (struct ospf6_interface
*) ifp
->info
;
79 /* schedule routing table recalculation */
81 ospf6_interface_lsdb_hook (struct ospf6_lsa
*lsa
, unsigned int reason
)
83 struct ospf6_interface
*oi
;
89 switch (ntohs (lsa
->header
->type
))
91 case OSPF6_LSTYPE_LINK
:
92 if (oi
->state
== OSPF6_INTERFACE_DR
)
93 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi
);
95 ospf6_spf_schedule (oi
->area
->ospf6
, reason
);
104 ospf6_interface_lsdb_hook_add (struct ospf6_lsa
*lsa
)
106 ospf6_interface_lsdb_hook(lsa
, ospf6_lsadd_to_spf_reason(lsa
));
110 ospf6_interface_lsdb_hook_remove (struct ospf6_lsa
*lsa
)
112 ospf6_interface_lsdb_hook(lsa
, ospf6_lsremove_to_spf_reason(lsa
));
116 ospf6_default_iftype(struct interface
*ifp
)
118 if (if_is_pointopoint (ifp
))
119 return OSPF_IFTYPE_POINTOPOINT
;
120 else if (if_is_loopback (ifp
))
121 return OSPF_IFTYPE_LOOPBACK
;
123 return OSPF_IFTYPE_BROADCAST
;
127 ospf6_interface_get_cost (struct ospf6_interface
*oi
)
129 /* If all else fails, use default OSPF cost */
133 bw
= oi
->interface
->bandwidth
? oi
->interface
->bandwidth
: OSPF6_INTERFACE_BANDWIDTH
;
134 refbw
= ospf6
? ospf6
->ref_bandwidth
: OSPF6_REFERENCE_BANDWIDTH
;
136 /* A specifed ip ospf cost overrides a calculated one. */
137 if (CHECK_FLAG (oi
->flag
, OSPF6_INTERFACE_NOAUTOCOST
))
141 cost
= (u_int32_t
) ((double)refbw
/ (double)bw
+ (double)0.5);
142 if (cost
< 1) cost
= 1;
143 else if (cost
> UINT32_MAX
) cost
= UINT32_MAX
;
150 ospf6_interface_recalculate_cost (struct ospf6_interface
*oi
)
154 newcost
= ospf6_interface_get_cost (oi
);
155 if (newcost
== oi
->cost
) return;
158 /* update cost held in route_connected list in ospf6_interface */
159 ospf6_interface_connected_route_update (oi
->interface
);
161 /* execute LSA hooks */
164 OSPF6_LINK_LSA_SCHEDULE (oi
);
165 OSPF6_ROUTER_LSA_SCHEDULE (oi
->area
);
166 OSPF6_NETWORK_LSA_SCHEDULE (oi
);
167 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi
);
168 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi
->area
);
172 /* Create new ospf6 interface structure */
173 struct ospf6_interface
*
174 ospf6_interface_create (struct interface
*ifp
)
176 struct ospf6_interface
*oi
;
177 unsigned int iobuflen
;
179 oi
= (struct ospf6_interface
*)
180 XCALLOC (MTYPE_OSPF6_IF
, sizeof (struct ospf6_interface
));
184 zlog_err ("Can't malloc ospf6_interface for ifindex %d", ifp
->ifindex
);
185 return (struct ospf6_interface
*) NULL
;
188 oi
->area
= (struct ospf6_area
*) NULL
;
189 oi
->neighbor_list
= list_new ();
190 oi
->neighbor_list
->cmp
= ospf6_neighbor_cmp
;
191 oi
->linklocal_addr
= (struct in6_addr
*) NULL
;
192 oi
->instance_id
= OSPF6_INTERFACE_INSTANCE_ID
;
193 oi
->transdelay
= OSPF6_INTERFACE_TRANSDELAY
;
194 oi
->priority
= OSPF6_INTERFACE_PRIORITY
;
196 oi
->hello_interval
= OSPF_HELLO_INTERVAL_DEFAULT
;
197 oi
->dead_interval
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
198 oi
->rxmt_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
199 oi
->type
= ospf6_default_iftype (ifp
);
200 oi
->state
= OSPF6_INTERFACE_DOWN
;
204 /* Try to adjust I/O buffer size with IfMtu */
205 oi
->ifmtu
= ifp
->mtu6
;
206 iobuflen
= ospf6_iobuf_size (ifp
->mtu6
);
207 if (oi
->ifmtu
> iobuflen
)
209 if (IS_OSPF6_DEBUG_INTERFACE
)
210 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
211 ifp
->name
, iobuflen
);
212 oi
->ifmtu
= iobuflen
;
215 oi
->lsupdate_list
= ospf6_lsdb_create (oi
);
216 oi
->lsack_list
= ospf6_lsdb_create (oi
);
217 oi
->lsdb
= ospf6_lsdb_create (oi
);
218 oi
->lsdb
->hook_add
= ospf6_interface_lsdb_hook_add
;
219 oi
->lsdb
->hook_remove
= ospf6_interface_lsdb_hook_remove
;
220 oi
->lsdb_self
= ospf6_lsdb_create (oi
);
222 oi
->route_connected
= OSPF6_ROUTE_TABLE_CREATE (INTERFACE
, CONNECTED_ROUTES
);
223 oi
->route_connected
->scope
= oi
;
230 oi
->cost
= ospf6_interface_get_cost(oi
);
236 ospf6_interface_delete (struct ospf6_interface
*oi
)
238 struct listnode
*node
, *nnode
;
239 struct ospf6_neighbor
*on
;
241 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
242 ospf6_neighbor_delete (on
);
244 list_delete (oi
->neighbor_list
);
246 THREAD_OFF (oi
->thread_send_hello
);
247 THREAD_OFF (oi
->thread_send_lsupdate
);
248 THREAD_OFF (oi
->thread_send_lsack
);
250 ospf6_lsdb_remove_all (oi
->lsdb
);
251 ospf6_lsdb_remove_all (oi
->lsupdate_list
);
252 ospf6_lsdb_remove_all (oi
->lsack_list
);
254 ospf6_lsdb_delete (oi
->lsdb
);
255 ospf6_lsdb_delete (oi
->lsdb_self
);
257 ospf6_lsdb_delete (oi
->lsupdate_list
);
258 ospf6_lsdb_delete (oi
->lsack_list
);
260 ospf6_route_table_delete (oi
->route_connected
);
263 oi
->interface
->info
= NULL
;
267 XFREE (MTYPE_CFG_PLIST_NAME
, oi
->plist_name
);
269 ospf6_bfd_info_free(&(oi
->bfd_info
));
271 XFREE (MTYPE_OSPF6_IF
, oi
);
275 ospf6_interface_enable (struct ospf6_interface
*oi
)
277 UNSET_FLAG (oi
->flag
, OSPF6_INTERFACE_DISABLE
);
278 ospf6_interface_state_update (oi
->interface
);
282 ospf6_interface_disable (struct ospf6_interface
*oi
)
284 SET_FLAG (oi
->flag
, OSPF6_INTERFACE_DISABLE
);
286 thread_execute (master
, interface_down
, oi
, 0);
288 ospf6_lsdb_remove_all (oi
->lsdb
);
289 ospf6_lsdb_remove_all (oi
->lsdb_self
);
290 ospf6_lsdb_remove_all (oi
->lsupdate_list
);
291 ospf6_lsdb_remove_all (oi
->lsack_list
);
293 THREAD_OFF (oi
->thread_send_hello
);
294 THREAD_OFF (oi
->thread_send_lsupdate
);
295 THREAD_OFF (oi
->thread_send_lsack
);
297 THREAD_OFF (oi
->thread_network_lsa
);
298 THREAD_OFF (oi
->thread_link_lsa
);
299 THREAD_OFF (oi
->thread_intra_prefix_lsa
);
302 static struct in6_addr
*
303 ospf6_interface_get_linklocal_address (struct interface
*ifp
)
307 struct in6_addr
*l
= (struct in6_addr
*) NULL
;
309 /* for each connected address */
310 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, n
, c
))
312 /* if family not AF_INET6, ignore */
313 if (c
->address
->family
!= AF_INET6
)
316 /* linklocal scope check */
317 if (IN6_IS_ADDR_LINKLOCAL (&c
->address
->u
.prefix6
))
318 l
= &c
->address
->u
.prefix6
;
324 ospf6_interface_if_add (struct interface
*ifp
)
326 struct ospf6_interface
*oi
;
327 unsigned int iobuflen
;
329 oi
= (struct ospf6_interface
*) ifp
->info
;
333 /* Try to adjust I/O buffer size with IfMtu */
335 oi
->ifmtu
= ifp
->mtu6
;
336 iobuflen
= ospf6_iobuf_size (ifp
->mtu6
);
337 if (oi
->ifmtu
> iobuflen
)
339 if (IS_OSPF6_DEBUG_INTERFACE
)
340 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
341 ifp
->name
, iobuflen
);
342 oi
->ifmtu
= iobuflen
;
345 /* interface start */
346 ospf6_interface_state_update(oi
->interface
);
350 ospf6_interface_if_del (struct interface
*ifp
)
352 struct ospf6_interface
*oi
;
354 oi
= (struct ospf6_interface
*) ifp
->info
;
360 thread_execute (master
, interface_down
, oi
, 0);
362 listnode_delete (oi
->area
->if_list
, oi
);
363 oi
->area
= (struct ospf6_area
*) NULL
;
366 oi
->interface
= NULL
;
369 ospf6_interface_delete (oi
);
373 ospf6_interface_state_update (struct interface
*ifp
)
375 struct ospf6_interface
*oi
;
377 oi
= (struct ospf6_interface
*) ifp
->info
;
380 if (oi
->area
== NULL
)
382 if (CHECK_FLAG (oi
->flag
, OSPF6_INTERFACE_DISABLE
))
385 if (if_is_operative (ifp
)
386 && (ospf6_interface_get_linklocal_address(oi
->interface
)
387 || if_is_loopback(oi
->interface
)))
388 thread_add_event (master
, interface_up
, oi
, 0);
390 thread_add_event (master
, interface_down
, oi
, 0);
396 ospf6_interface_connected_route_update (struct interface
*ifp
)
398 struct ospf6_interface
*oi
;
399 struct ospf6_route
*route
;
401 struct listnode
*node
, *nnode
;
402 struct in6_addr nh_addr
;
404 oi
= (struct ospf6_interface
*) ifp
->info
;
408 /* reset linklocal pointer */
409 oi
->linklocal_addr
= ospf6_interface_get_linklocal_address (ifp
);
411 /* if area is null, do not make connected-route list */
412 if (oi
->area
== NULL
)
415 if (CHECK_FLAG (oi
->flag
, OSPF6_INTERFACE_DISABLE
))
418 /* update "route to advertise" interface route table */
419 ospf6_route_remove_all (oi
->route_connected
);
421 for (ALL_LIST_ELEMENTS (oi
->interface
->connected
, node
, nnode
, c
))
423 if (c
->address
->family
!= AF_INET6
)
426 CONTINUE_IF_ADDRESS_LINKLOCAL (IS_OSPF6_DEBUG_INTERFACE
, c
->address
);
427 CONTINUE_IF_ADDRESS_UNSPECIFIED (IS_OSPF6_DEBUG_INTERFACE
, c
->address
);
428 CONTINUE_IF_ADDRESS_LOOPBACK (IS_OSPF6_DEBUG_INTERFACE
, c
->address
);
429 CONTINUE_IF_ADDRESS_V4COMPAT (IS_OSPF6_DEBUG_INTERFACE
, c
->address
);
430 CONTINUE_IF_ADDRESS_V4MAPPED (IS_OSPF6_DEBUG_INTERFACE
, c
->address
);
435 struct prefix_list
*plist
;
436 enum prefix_list_type ret
;
437 char buf
[PREFIX2STR_BUFFER
];
439 prefix2str (c
->address
, buf
, sizeof (buf
));
440 plist
= prefix_list_lookup (AFI_IP6
, oi
->plist_name
);
441 ret
= prefix_list_apply (plist
, (void *) c
->address
);
442 if (ret
== PREFIX_DENY
)
444 if (IS_OSPF6_DEBUG_INTERFACE
)
445 zlog_debug ("%s on %s filtered by prefix-list %s ",
446 buf
, oi
->interface
->name
, oi
->plist_name
);
451 route
= ospf6_route_create ();
452 memcpy (&route
->prefix
, c
->address
, sizeof (struct prefix
));
453 apply_mask (&route
->prefix
);
454 route
->type
= OSPF6_DEST_TYPE_NETWORK
;
455 route
->path
.area_id
= oi
->area
->area_id
;
456 route
->path
.type
= OSPF6_PATH_TYPE_INTRA
;
457 route
->path
.cost
= oi
->cost
;
458 inet_pton (AF_INET6
, "::1", &nh_addr
);
459 ospf6_route_add_nexthop (route
, oi
->interface
->ifindex
, &nh_addr
);
460 ospf6_route_add (route
, oi
->route_connected
);
463 /* create new Link-LSA */
464 OSPF6_LINK_LSA_SCHEDULE (oi
);
465 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi
);
466 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi
->area
);
470 ospf6_interface_state_change (u_char next_state
, struct ospf6_interface
*oi
)
474 prev_state
= oi
->state
;
475 oi
->state
= next_state
;
477 if (prev_state
== next_state
)
481 if (IS_OSPF6_DEBUG_INTERFACE
)
483 zlog_debug ("Interface state change %s: %s -> %s", oi
->interface
->name
,
484 ospf6_interface_state_str
[prev_state
],
485 ospf6_interface_state_str
[next_state
]);
489 if ((prev_state
== OSPF6_INTERFACE_DR
||
490 prev_state
== OSPF6_INTERFACE_BDR
) &&
491 (next_state
!= OSPF6_INTERFACE_DR
&&
492 next_state
!= OSPF6_INTERFACE_BDR
))
493 ospf6_sso (oi
->interface
->ifindex
, &alldrouters6
, IPV6_LEAVE_GROUP
);
495 if ((prev_state
!= OSPF6_INTERFACE_DR
&&
496 prev_state
!= OSPF6_INTERFACE_BDR
) &&
497 (next_state
== OSPF6_INTERFACE_DR
||
498 next_state
== OSPF6_INTERFACE_BDR
))
499 ospf6_sso (oi
->interface
->ifindex
, &alldrouters6
, IPV6_JOIN_GROUP
);
501 OSPF6_ROUTER_LSA_SCHEDULE (oi
->area
);
502 if (next_state
== OSPF6_INTERFACE_DOWN
)
504 OSPF6_NETWORK_LSA_EXECUTE (oi
);
505 OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT (oi
);
506 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi
->area
);
508 else if (prev_state
== OSPF6_INTERFACE_DR
||
509 next_state
== OSPF6_INTERFACE_DR
)
511 OSPF6_NETWORK_LSA_SCHEDULE (oi
);
512 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi
);
513 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi
->area
);
517 /* Terminal state or regression */
518 if ((next_state
== OSPF6_INTERFACE_POINTTOPOINT
) ||
519 (next_state
== OSPF6_INTERFACE_DROTHER
) ||
520 (next_state
== OSPF6_INTERFACE_BDR
) ||
521 (next_state
== OSPF6_INTERFACE_DR
) ||
522 (next_state
< prev_state
))
523 ospf6TrapIfStateChange (oi
);
529 /* DR Election, RFC2328 section 9.4 */
531 #define IS_ELIGIBLE(n) \
532 ((n)->state >= OSPF6_NEIGHBOR_TWOWAY && (n)->priority != 0)
534 static struct ospf6_neighbor
*
535 better_bdrouter (struct ospf6_neighbor
*a
, struct ospf6_neighbor
*b
)
537 if ((a
== NULL
|| ! IS_ELIGIBLE (a
) || a
->drouter
== a
->router_id
) &&
538 (b
== NULL
|| ! IS_ELIGIBLE (b
) || b
->drouter
== b
->router_id
))
540 else if (a
== NULL
|| ! IS_ELIGIBLE (a
) || a
->drouter
== a
->router_id
)
542 else if (b
== NULL
|| ! IS_ELIGIBLE (b
) || b
->drouter
== b
->router_id
)
545 if (a
->bdrouter
== a
->router_id
&& b
->bdrouter
!= b
->router_id
)
547 if (a
->bdrouter
!= a
->router_id
&& b
->bdrouter
== b
->router_id
)
550 if (a
->priority
> b
->priority
)
552 if (a
->priority
< b
->priority
)
555 if (ntohl (a
->router_id
) > ntohl (b
->router_id
))
557 if (ntohl (a
->router_id
) < ntohl (b
->router_id
))
560 zlog_warn ("Router-ID duplicate ?");
564 static struct ospf6_neighbor
*
565 better_drouter (struct ospf6_neighbor
*a
, struct ospf6_neighbor
*b
)
567 if ((a
== NULL
|| ! IS_ELIGIBLE (a
) || a
->drouter
!= a
->router_id
) &&
568 (b
== NULL
|| ! IS_ELIGIBLE (b
) || b
->drouter
!= b
->router_id
))
570 else if (a
== NULL
|| ! IS_ELIGIBLE (a
) || a
->drouter
!= a
->router_id
)
572 else if (b
== NULL
|| ! IS_ELIGIBLE (b
) || b
->drouter
!= b
->router_id
)
575 if (a
->drouter
== a
->router_id
&& b
->drouter
!= b
->router_id
)
577 if (a
->drouter
!= a
->router_id
&& b
->drouter
== b
->router_id
)
580 if (a
->priority
> b
->priority
)
582 if (a
->priority
< b
->priority
)
585 if (ntohl (a
->router_id
) > ntohl (b
->router_id
))
587 if (ntohl (a
->router_id
) < ntohl (b
->router_id
))
590 zlog_warn ("Router-ID duplicate ?");
595 dr_election (struct ospf6_interface
*oi
)
597 struct listnode
*node
, *nnode
;
598 struct ospf6_neighbor
*on
, *drouter
, *bdrouter
, myself
;
599 struct ospf6_neighbor
*best_drouter
, *best_bdrouter
;
600 u_char next_state
= 0;
602 drouter
= bdrouter
= NULL
;
603 best_drouter
= best_bdrouter
= NULL
;
605 /* pseudo neighbor myself, including noting current DR/BDR (1) */
606 memset (&myself
, 0, sizeof (myself
));
607 inet_ntop (AF_INET
, &oi
->area
->ospf6
->router_id
, myself
.name
,
608 sizeof (myself
.name
));
609 myself
.state
= OSPF6_NEIGHBOR_TWOWAY
;
610 myself
.drouter
= oi
->drouter
;
611 myself
.bdrouter
= oi
->bdrouter
;
612 myself
.priority
= oi
->priority
;
613 myself
.router_id
= oi
->area
->ospf6
->router_id
;
615 /* Electing BDR (2) */
616 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
617 bdrouter
= better_bdrouter (bdrouter
, on
);
619 best_bdrouter
= bdrouter
;
620 bdrouter
= better_bdrouter (best_bdrouter
, &myself
);
622 /* Electing DR (3) */
623 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
624 drouter
= better_drouter (drouter
, on
);
626 best_drouter
= drouter
;
627 drouter
= better_drouter (best_drouter
, &myself
);
631 /* the router itself is newly/no longer DR/BDR (4) */
632 if ((drouter
== &myself
&& myself
.drouter
!= myself
.router_id
) ||
633 (drouter
!= &myself
&& myself
.drouter
== myself
.router_id
) ||
634 (bdrouter
== &myself
&& myself
.bdrouter
!= myself
.router_id
) ||
635 (bdrouter
!= &myself
&& myself
.bdrouter
== myself
.router_id
))
637 myself
.drouter
= (drouter
? drouter
->router_id
: htonl (0));
638 myself
.bdrouter
= (bdrouter
? bdrouter
->router_id
: htonl (0));
640 /* compatible to Electing BDR (2) */
641 bdrouter
= better_bdrouter (best_bdrouter
, &myself
);
643 /* compatible to Electing DR (3) */
644 drouter
= better_drouter (best_drouter
, &myself
);
649 /* Set interface state accordingly (5) */
650 if (drouter
&& drouter
== &myself
)
651 next_state
= OSPF6_INTERFACE_DR
;
652 else if (bdrouter
&& bdrouter
== &myself
)
653 next_state
= OSPF6_INTERFACE_BDR
;
655 next_state
= OSPF6_INTERFACE_DROTHER
;
657 /* If NBMA, schedule Start for each neighbor having priority of 0 (6) */
660 /* If DR or BDR change, invoke AdjOK? for each neighbor (7) */
661 /* RFC 2328 section 12.4. Originating LSAs (3) will be handled
662 accordingly after AdjOK */
663 if (oi
->drouter
!= (drouter
? drouter
->router_id
: htonl (0)) ||
664 oi
->bdrouter
!= (bdrouter
? bdrouter
->router_id
: htonl (0)))
666 if (IS_OSPF6_DEBUG_INTERFACE
)
667 zlog_debug ("DR Election on %s: DR: %s BDR: %s", oi
->interface
->name
,
668 (drouter
? drouter
->name
: "0.0.0.0"),
669 (bdrouter
? bdrouter
->name
: "0.0.0.0"));
671 for (ALL_LIST_ELEMENTS_RO (oi
->neighbor_list
, node
, on
))
673 if (on
->state
< OSPF6_NEIGHBOR_TWOWAY
)
675 /* Schedule AdjOK. */
676 thread_add_event (master
, adj_ok
, on
, 0);
680 oi
->drouter
= (drouter
? drouter
->router_id
: htonl (0));
681 oi
->bdrouter
= (bdrouter
? bdrouter
->router_id
: htonl (0));
686 /* Interface State Machine */
688 interface_up (struct thread
*thread
)
690 struct ospf6_interface
*oi
;
692 oi
= (struct ospf6_interface
*) THREAD_ARG (thread
);
693 assert (oi
&& oi
->interface
);
695 if (IS_OSPF6_DEBUG_INTERFACE
)
696 zlog_debug ("Interface Event %s: [InterfaceUp]",
697 oi
->interface
->name
);
699 /* check physical interface is up */
700 if (! if_is_operative (oi
->interface
))
702 if (IS_OSPF6_DEBUG_INTERFACE
)
703 zlog_debug ("Interface %s is down, can't execute [InterfaceUp]",
704 oi
->interface
->name
);
708 /* check interface has a link-local address */
709 if (! (ospf6_interface_get_linklocal_address(oi
->interface
)
710 || if_is_loopback(oi
->interface
)))
712 if (IS_OSPF6_DEBUG_INTERFACE
)
713 zlog_debug ("Interface %s has no link local address, can't execute [InterfaceUp]",
714 oi
->interface
->name
);
719 ospf6_interface_recalculate_cost (oi
);
721 /* if already enabled, do nothing */
722 if (oi
->state
> OSPF6_INTERFACE_DOWN
)
724 if (IS_OSPF6_DEBUG_INTERFACE
)
725 zlog_debug ("Interface %s already enabled",
726 oi
->interface
->name
);
730 /* If no area assigned, return */
731 if (oi
->area
== NULL
)
733 zlog_debug ("%s: Not scheduleing Hello for %s as there is no area assigned yet", __func__
,
734 oi
->interface
->name
);
738 /* Join AllSPFRouters */
739 if (ospf6_sso (oi
->interface
->ifindex
, &allspfrouters6
, IPV6_JOIN_GROUP
) < 0)
741 if (oi
->sso_try_cnt
++ < OSPF6_INTERFACE_SSO_RETRY_MAX
)
743 zlog_info("Scheduling %s for sso retry, trial count: %d",
744 oi
->interface
->name
, oi
->sso_try_cnt
);
745 thread_add_timer (master
, interface_up
, oi
,
746 OSPF6_INTERFACE_SSO_RETRY_INT
);
750 oi
->sso_try_cnt
= 0; /* Reset on success */
752 /* Update interface route */
753 ospf6_interface_connected_route_update (oi
->interface
);
756 if (! CHECK_FLAG (oi
->flag
, OSPF6_INTERFACE_PASSIVE
) &&
757 !if_is_loopback (oi
->interface
))
758 oi
->thread_send_hello
= thread_add_event (master
, ospf6_hello_send
, oi
, 0);
760 /* decide next interface state */
761 if ((if_is_pointopoint (oi
->interface
)) ||
762 (oi
->type
== OSPF_IFTYPE_POINTOPOINT
)) {
763 ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT
, oi
);
765 else if (oi
->priority
== 0)
766 ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER
, oi
);
769 ospf6_interface_state_change (OSPF6_INTERFACE_WAITING
, oi
);
770 thread_add_timer (master
, wait_timer
, oi
, oi
->dead_interval
);
777 wait_timer (struct thread
*thread
)
779 struct ospf6_interface
*oi
;
781 oi
= (struct ospf6_interface
*) THREAD_ARG (thread
);
782 assert (oi
&& oi
->interface
);
784 if (IS_OSPF6_DEBUG_INTERFACE
)
785 zlog_debug ("Interface Event %s: [WaitTimer]",
786 oi
->interface
->name
);
788 if (oi
->state
== OSPF6_INTERFACE_WAITING
)
789 ospf6_interface_state_change (dr_election (oi
), oi
);
795 backup_seen (struct thread
*thread
)
797 struct ospf6_interface
*oi
;
799 oi
= (struct ospf6_interface
*) THREAD_ARG (thread
);
800 assert (oi
&& oi
->interface
);
802 if (IS_OSPF6_DEBUG_INTERFACE
)
803 zlog_debug ("Interface Event %s: [BackupSeen]",
804 oi
->interface
->name
);
806 if (oi
->state
== OSPF6_INTERFACE_WAITING
)
807 ospf6_interface_state_change (dr_election (oi
), oi
);
813 neighbor_change (struct thread
*thread
)
815 struct ospf6_interface
*oi
;
817 oi
= (struct ospf6_interface
*) THREAD_ARG (thread
);
818 assert (oi
&& oi
->interface
);
820 if (IS_OSPF6_DEBUG_INTERFACE
)
821 zlog_debug ("Interface Event %s: [NeighborChange]",
822 oi
->interface
->name
);
824 if (oi
->state
== OSPF6_INTERFACE_DROTHER
||
825 oi
->state
== OSPF6_INTERFACE_BDR
||
826 oi
->state
== OSPF6_INTERFACE_DR
)
827 ospf6_interface_state_change (dr_election (oi
), oi
);
833 interface_down (struct thread
*thread
)
835 struct ospf6_interface
*oi
;
836 struct listnode
*node
, *nnode
;
837 struct ospf6_neighbor
*on
;
839 oi
= (struct ospf6_interface
*) THREAD_ARG (thread
);
840 assert (oi
&& oi
->interface
);
842 if (IS_OSPF6_DEBUG_INTERFACE
)
843 zlog_debug ("Interface Event %s: [InterfaceDown]",
844 oi
->interface
->name
);
847 THREAD_OFF (oi
->thread_send_hello
);
849 /* Leave AllSPFRouters */
850 if (oi
->state
> OSPF6_INTERFACE_DOWN
)
851 ospf6_sso (oi
->interface
->ifindex
, &allspfrouters6
, IPV6_LEAVE_GROUP
);
853 ospf6_interface_state_change (OSPF6_INTERFACE_DOWN
, oi
);
855 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
856 ospf6_neighbor_delete (on
);
858 list_delete_all_node (oi
->neighbor_list
);
860 /* When interface state is reset, also reset information about
861 * DR election, as it is no longer valid. */
862 oi
->drouter
= oi
->prev_drouter
= htonl(0);
863 oi
->bdrouter
= oi
->prev_bdrouter
= htonl(0);
868 /* show specified interface structure */
870 ospf6_interface_show (struct vty
*vty
, struct interface
*ifp
)
872 struct ospf6_interface
*oi
;
876 char strbuf
[PREFIX2STR_BUFFER
], drouter
[32], bdrouter
[32];
877 const char *updown
[3] = {"down", "up", NULL
};
879 struct timeval res
, now
;
881 struct ospf6_lsa
*lsa
;
883 /* check physical interface type */
884 if (if_is_loopback (ifp
))
886 else if (if_is_broadcast (ifp
))
888 else if (if_is_pointopoint (ifp
))
889 type
= "POINTOPOINT";
893 vty_out (vty
, "%s is %s, type %s%s",
894 ifp
->name
, updown
[if_is_operative (ifp
)], type
,
896 vty_out (vty
, " Interface ID: %d%s", ifp
->ifindex
, VNL
);
898 if (ifp
->info
== NULL
)
900 vty_out (vty
, " OSPF not enabled on this interface%s", VNL
);
904 oi
= (struct ospf6_interface
*) ifp
->info
;
906 vty_out (vty
, " Internet Address:%s", VNL
);
908 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, i
, c
))
911 prefix2str (p
, strbuf
, sizeof (strbuf
));
915 vty_out (vty
, " inet : %s%s", strbuf
,
919 vty_out (vty
, " inet6: %s%s", strbuf
,
923 vty_out (vty
, " ??? : %s%s", strbuf
,
931 vty_out (vty
, " Instance ID %d, Interface MTU %d (autodetect: %d)%s",
932 oi
->instance_id
, oi
->ifmtu
, ifp
->mtu6
, VNL
);
933 vty_out (vty
, " MTU mismatch detection: %s%s", oi
->mtu_ignore
?
934 "disabled" : "enabled", VNL
);
935 inet_ntop (AF_INET
, &oi
->area
->area_id
,
936 strbuf
, sizeof (strbuf
));
937 vty_out (vty
, " Area ID %s, Cost %u%s", strbuf
, oi
->cost
,
941 vty_out (vty
, " Not Attached to Area%s", VNL
);
943 vty_out (vty
, " State %s, Transmit Delay %d sec, Priority %d%s",
944 ospf6_interface_state_str
[oi
->state
],
945 oi
->transdelay
, oi
->priority
,
947 vty_out (vty
, " Timer intervals configured:%s", VNL
);
948 vty_out (vty
, " Hello %d, Dead %d, Retransmit %d%s",
949 oi
->hello_interval
, oi
->dead_interval
, oi
->rxmt_interval
,
952 inet_ntop (AF_INET
, &oi
->drouter
, drouter
, sizeof (drouter
));
953 inet_ntop (AF_INET
, &oi
->bdrouter
, bdrouter
, sizeof (bdrouter
));
954 vty_out (vty
, " DR: %s BDR: %s%s", drouter
, bdrouter
, VNL
);
956 vty_out (vty
, " Number of I/F scoped LSAs is %u%s",
957 oi
->lsdb
->count
, VNL
);
959 quagga_gettime (QUAGGA_CLK_MONOTONIC
, &now
);
962 if (oi
->thread_send_lsupdate
)
963 timersub (&oi
->thread_send_lsupdate
->u
.sands
, &now
, &res
);
964 timerstring (&res
, duration
, sizeof (duration
));
965 vty_out (vty
, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
966 oi
->lsupdate_list
->count
, duration
,
967 (oi
->thread_send_lsupdate
? "on" : "off"),
969 for (lsa
= ospf6_lsdb_head (oi
->lsupdate_list
); lsa
;
970 lsa
= ospf6_lsdb_next (lsa
))
971 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
974 if (oi
->thread_send_lsack
)
975 timersub (&oi
->thread_send_lsack
->u
.sands
, &now
, &res
);
976 timerstring (&res
, duration
, sizeof (duration
));
977 vty_out (vty
, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
978 oi
->lsack_list
->count
, duration
,
979 (oi
->thread_send_lsack
? "on" : "off"),
981 for (lsa
= ospf6_lsdb_head (oi
->lsack_list
); lsa
;
982 lsa
= ospf6_lsdb_next (lsa
))
983 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
984 ospf6_bfd_show_info(vty
, oi
->bfd_info
, 1);
989 DEFUN (show_ipv6_ospf6_interface
,
990 show_ipv6_ospf6_interface_ifname_cmd
,
991 "show ipv6 ospf6 interface [IFNAME]",
999 struct interface
*ifp
;
1004 ifp
= if_lookup_by_name (argv
[idx_ifname
]->arg
);
1007 vty_out (vty
, "No such Interface: %s%s", argv
[idx_ifname
]->arg
,
1011 ospf6_interface_show (vty
, ifp
);
1015 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), i
, ifp
))
1016 ospf6_interface_show (vty
, ifp
);
1024 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
1025 * "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)",
1031 * "Display connected prefixes to advertise\n"
1032 * OSPF6_ROUTE_ADDRESS_STR
1033 * OSPF6_ROUTE_PREFIX_STR
1034 * "Display details of the prefixes\n"
1037 * "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)",
1043 * "Display connected prefixes to advertise\n"
1044 * OSPF6_ROUTE_PREFIX_STR
1045 * OSPF6_ROUTE_MATCH_STR
1046 * "Display details of the prefixes\n"
1050 DEFUN (show_ipv6_ospf6_interface_ifname_prefix
,
1051 show_ipv6_ospf6_interface_ifname_prefix_cmd
,
1052 "show ipv6 ospf6 interface IFNAME prefix",
1058 "Display connected prefixes to advertise\n")
1060 /* CHECK ME argc referenced below */
1062 struct interface
*ifp
;
1063 struct ospf6_interface
*oi
;
1065 ifp
= if_lookup_by_name (argv
[idx_ifname
]->arg
);
1068 vty_out (vty
, "No such Interface: %s%s", argv
[idx_ifname
]->arg
, VNL
);
1075 vty_out (vty
, "OSPFv3 is not enabled on %s%s", argv
[idx_ifname
]->arg
, VNL
);
1079 ospf6_route_table_show (vty
, 6, argc
, argv
, oi
->route_connected
);
1087 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
1088 * "show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)",
1093 * "Display connected prefixes to advertise\n"
1094 * OSPF6_ROUTE_PREFIX_STR
1095 * OSPF6_ROUTE_MATCH_STR
1096 * "Display details of the prefixes\n"
1099 * "show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)",
1104 * "Display connected prefixes to advertise\n"
1105 * OSPF6_ROUTE_ADDRESS_STR
1106 * OSPF6_ROUTE_PREFIX_STR
1107 * "Display details of the prefixes\n"
1111 DEFUN (show_ipv6_ospf6_interface_prefix
,
1112 show_ipv6_ospf6_interface_prefix_cmd
,
1113 "show ipv6 ospf6 interface prefix",
1118 "Display connected prefixes to advertise\n"
1121 /* CHECK ME argc referenced below */
1123 struct ospf6_interface
*oi
;
1124 struct interface
*ifp
;
1126 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), i
, ifp
))
1128 oi
= (struct ospf6_interface
*) ifp
->info
;
1132 ospf6_route_table_show (vty
, 5, argc
, argv
, oi
->route_connected
);
1141 /* interface variable set command */
1142 DEFUN (ipv6_ospf6_ifmtu
,
1143 ipv6_ospf6_ifmtu_cmd
,
1144 "ipv6 ospf6 ifmtu (1-65535)",
1148 "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
[idx_number
]->arg
, 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"
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
[idx_number
]->arg
, 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")
1327 struct ospf6
*o
= vty
->index
;
1328 struct ospf6_area
*oa
;
1329 struct ospf6_interface
*oi
;
1330 struct listnode
*i
, *j
;
1333 refbw
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
1334 if (refbw
< 1 || refbw
> 4294967)
1336 vty_out (vty
, "reference-bandwidth value is invalid%s", VTY_NEWLINE
);
1340 /* If reference bandwidth is changed. */
1341 if ((refbw
) == o
->ref_bandwidth
)
1344 o
->ref_bandwidth
= refbw
;
1345 for (ALL_LIST_ELEMENTS_RO (o
->area_list
, i
, oa
))
1346 for (ALL_LIST_ELEMENTS_RO (oa
->if_list
, j
, oi
))
1347 ospf6_interface_recalculate_cost (oi
);
1352 DEFUN (no_auto_cost_reference_bandwidth
,
1353 no_auto_cost_reference_bandwidth_cmd
,
1354 "no auto-cost reference-bandwidth [1-4294967]",
1356 "Calculate OSPF interface cost according to bandwidth\n"
1357 "Use reference bandwidth method to assign OSPF cost\n"
1358 "The reference bandwidth in terms of Mbits per second\n")
1360 struct ospf6
*o
= vty
->index
;
1361 struct ospf6_area
*oa
;
1362 struct ospf6_interface
*oi
;
1363 struct listnode
*i
, *j
;
1365 if (o
->ref_bandwidth
== OSPF6_REFERENCE_BANDWIDTH
)
1368 o
->ref_bandwidth
= OSPF6_REFERENCE_BANDWIDTH
;
1369 for (ALL_LIST_ELEMENTS_RO (o
->area_list
, i
, oa
))
1370 for (ALL_LIST_ELEMENTS_RO (oa
->if_list
, j
, oi
))
1371 ospf6_interface_recalculate_cost (oi
);
1377 DEFUN (ipv6_ospf6_hellointerval
,
1378 ipv6_ospf6_hellointerval_cmd
,
1379 "ipv6 ospf6 hello-interval (1-65535)",
1382 "Interval time of Hello packets\n"
1387 struct ospf6_interface
*oi
;
1388 struct interface
*ifp
;
1390 ifp
= (struct interface
*) vty
->index
;
1393 oi
= (struct ospf6_interface
*) ifp
->info
;
1395 oi
= ospf6_interface_create (ifp
);
1398 oi
->hello_interval
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
1402 /* interface variable set command */
1403 DEFUN (ipv6_ospf6_deadinterval
,
1404 ipv6_ospf6_deadinterval_cmd
,
1405 "ipv6 ospf6 dead-interval (1-65535)",
1408 "Interval time after which a neighbor is declared down\n"
1413 struct ospf6_interface
*oi
;
1414 struct interface
*ifp
;
1416 ifp
= (struct interface
*) vty
->index
;
1419 oi
= (struct ospf6_interface
*) ifp
->info
;
1421 oi
= ospf6_interface_create (ifp
);
1424 oi
->dead_interval
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
1428 /* interface variable set command */
1429 DEFUN (ipv6_ospf6_transmitdelay
,
1430 ipv6_ospf6_transmitdelay_cmd
,
1431 "ipv6 ospf6 transmit-delay (1-3600)",
1434 "Transmit delay of this interface\n"
1439 struct ospf6_interface
*oi
;
1440 struct interface
*ifp
;
1442 ifp
= (struct interface
*) vty
->index
;
1445 oi
= (struct ospf6_interface
*) ifp
->info
;
1447 oi
= ospf6_interface_create (ifp
);
1450 oi
->transdelay
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
1454 /* interface variable set command */
1455 DEFUN (ipv6_ospf6_retransmitinterval
,
1456 ipv6_ospf6_retransmitinterval_cmd
,
1457 "ipv6 ospf6 retransmit-interval (1-65535)",
1460 "Time between retransmitting lost link state advertisements\n"
1465 struct ospf6_interface
*oi
;
1466 struct interface
*ifp
;
1468 ifp
= (struct interface
*) vty
->index
;
1471 oi
= (struct ospf6_interface
*) ifp
->info
;
1473 oi
= ospf6_interface_create (ifp
);
1476 oi
->rxmt_interval
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
1480 /* interface variable set command */
1481 DEFUN (ipv6_ospf6_priority
,
1482 ipv6_ospf6_priority_cmd
,
1483 "ipv6 ospf6 priority (0-255)",
1491 struct ospf6_interface
*oi
;
1492 struct interface
*ifp
;
1494 ifp
= (struct interface
*) vty
->index
;
1497 oi
= (struct ospf6_interface
*) ifp
->info
;
1499 oi
= ospf6_interface_create (ifp
);
1502 oi
->priority
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
1505 (oi
->state
== OSPF6_INTERFACE_DROTHER
||
1506 oi
->state
== OSPF6_INTERFACE_BDR
||
1507 oi
->state
== OSPF6_INTERFACE_DR
))
1508 ospf6_interface_state_change (dr_election (oi
), oi
);
1513 DEFUN (ipv6_ospf6_instance
,
1514 ipv6_ospf6_instance_cmd
,
1515 "ipv6 ospf6 instance-id (0-255)",
1518 "Instance ID for this interface\n"
1519 "Instance ID value\n"
1523 struct ospf6_interface
*oi
;
1524 struct interface
*ifp
;
1526 ifp
= (struct interface
*)vty
->index
;
1529 oi
= (struct ospf6_interface
*)ifp
->info
;
1531 oi
= ospf6_interface_create (ifp
);
1534 oi
->instance_id
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
1538 DEFUN (ipv6_ospf6_passive
,
1539 ipv6_ospf6_passive_cmd
,
1540 "ipv6 ospf6 passive",
1543 "passive interface, No adjacency will be formed on this interface\n"
1546 struct ospf6_interface
*oi
;
1547 struct interface
*ifp
;
1548 struct listnode
*node
, *nnode
;
1549 struct ospf6_neighbor
*on
;
1551 ifp
= (struct interface
*) vty
->index
;
1554 oi
= (struct ospf6_interface
*) ifp
->info
;
1556 oi
= ospf6_interface_create (ifp
);
1559 SET_FLAG (oi
->flag
, OSPF6_INTERFACE_PASSIVE
);
1560 THREAD_OFF (oi
->thread_send_hello
);
1562 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
1564 THREAD_OFF (on
->inactivity_timer
);
1565 thread_add_event (master
, inactivity_timer
, on
, 0);
1571 DEFUN (no_ipv6_ospf6_passive
,
1572 no_ipv6_ospf6_passive_cmd
,
1573 "no ipv6 ospf6 passive",
1577 "passive interface: No Adjacency will be formed on this I/F\n"
1580 struct ospf6_interface
*oi
;
1581 struct interface
*ifp
;
1583 ifp
= (struct interface
*) vty
->index
;
1586 oi
= (struct ospf6_interface
*) ifp
->info
;
1588 oi
= ospf6_interface_create (ifp
);
1591 UNSET_FLAG (oi
->flag
, OSPF6_INTERFACE_PASSIVE
);
1592 THREAD_OFF (oi
->thread_send_hello
);
1593 oi
->thread_send_hello
=
1594 thread_add_event (master
, ospf6_hello_send
, oi
, 0);
1599 DEFUN (ipv6_ospf6_mtu_ignore
,
1600 ipv6_ospf6_mtu_ignore_cmd
,
1601 "ipv6 ospf6 mtu-ignore",
1604 "Ignore MTU mismatch on this interface\n"
1607 struct ospf6_interface
*oi
;
1608 struct interface
*ifp
;
1610 ifp
= (struct interface
*) vty
->index
;
1613 oi
= (struct ospf6_interface
*) ifp
->info
;
1615 oi
= ospf6_interface_create (ifp
);
1623 DEFUN (no_ipv6_ospf6_mtu_ignore
,
1624 no_ipv6_ospf6_mtu_ignore_cmd
,
1625 "no ipv6 ospf6 mtu-ignore",
1629 "Ignore MTU mismatch on this interface\n"
1632 struct ospf6_interface
*oi
;
1633 struct interface
*ifp
;
1635 ifp
= (struct interface
*) vty
->index
;
1638 oi
= (struct ospf6_interface
*) ifp
->info
;
1640 oi
= ospf6_interface_create (ifp
);
1648 DEFUN (ipv6_ospf6_advertise_prefix_list
,
1649 ipv6_ospf6_advertise_prefix_list_cmd
,
1650 "ipv6 ospf6 advertise prefix-list WORD",
1653 "Advertising options\n"
1654 "Filter prefix using prefix-list\n"
1655 "Prefix list name\n"
1659 struct ospf6_interface
*oi
;
1660 struct interface
*ifp
;
1662 ifp
= (struct interface
*) vty
->index
;
1665 oi
= (struct ospf6_interface
*) ifp
->info
;
1667 oi
= ospf6_interface_create (ifp
);
1671 XFREE (MTYPE_CFG_PLIST_NAME
, oi
->plist_name
);
1672 oi
->plist_name
= XSTRDUP (MTYPE_CFG_PLIST_NAME
, argv
[idx_word
]->arg
);
1674 ospf6_interface_connected_route_update (oi
->interface
);
1678 OSPF6_LINK_LSA_SCHEDULE (oi
);
1679 if (oi
->state
== OSPF6_INTERFACE_DR
)
1681 OSPF6_NETWORK_LSA_SCHEDULE (oi
);
1682 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi
);
1684 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi
->area
);
1690 DEFUN (no_ipv6_ospf6_advertise_prefix_list
,
1691 no_ipv6_ospf6_advertise_prefix_list_cmd
,
1692 "no ipv6 ospf6 advertise prefix-list",
1696 "Advertising options\n"
1697 "Filter prefix using prefix-list\n"
1700 struct ospf6_interface
*oi
;
1701 struct interface
*ifp
;
1703 ifp
= (struct interface
*) vty
->index
;
1706 oi
= (struct ospf6_interface
*) ifp
->info
;
1708 oi
= ospf6_interface_create (ifp
);
1713 XFREE (MTYPE_CFG_PLIST_NAME
, oi
->plist_name
);
1714 oi
->plist_name
= NULL
;
1717 ospf6_interface_connected_route_update (oi
->interface
);
1721 OSPF6_LINK_LSA_SCHEDULE (oi
);
1722 if (oi
->state
== OSPF6_INTERFACE_DR
)
1724 OSPF6_NETWORK_LSA_SCHEDULE (oi
);
1725 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi
);
1727 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi
->area
);
1733 DEFUN (ipv6_ospf6_network
,
1734 ipv6_ospf6_network_cmd
,
1735 "ipv6 ospf6 network <broadcast|point-to-point>",
1739 "Specify OSPFv6 broadcast network\n"
1740 "Specify OSPF6 point-to-point network\n"
1743 int idx_network
= 3;
1744 struct ospf6_interface
*oi
;
1745 struct interface
*ifp
;
1747 ifp
= (struct interface
*) vty
->index
;
1750 oi
= (struct ospf6_interface
*) ifp
->info
;
1752 oi
= ospf6_interface_create (ifp
);
1756 if (strncmp (argv
[idx_network
]->arg
, "b", 1) == 0)
1758 if (oi
->type
== OSPF_IFTYPE_BROADCAST
)
1761 oi
->type
= OSPF_IFTYPE_BROADCAST
;
1763 else if (strncmp (argv
[idx_network
]->arg
, "point-to-p", 10) == 0)
1765 if (oi
->type
== OSPF_IFTYPE_POINTOPOINT
) {
1768 oi
->type
= OSPF_IFTYPE_POINTOPOINT
;
1771 /* Reset the interface */
1772 thread_add_event (master
, interface_down
, oi
, 0);
1773 thread_add_event (master
, interface_up
, oi
, 0);
1778 DEFUN (no_ipv6_ospf6_network
,
1779 no_ipv6_ospf6_network_cmd
,
1780 "no ipv6 ospf6 network",
1785 "Default to whatever interface type system specifies"
1788 struct ospf6_interface
*oi
;
1789 struct interface
*ifp
;
1792 ifp
= (struct interface
*) vty
->index
;
1795 oi
= (struct ospf6_interface
*) ifp
->info
;
1800 type
= ospf6_default_iftype (ifp
);
1801 if (oi
->type
== type
)
1807 /* Reset the interface */
1808 thread_add_event (master
, interface_down
, oi
, 0);
1809 thread_add_event (master
, interface_up
, oi
, 0);
1815 config_write_ospf6_interface (struct vty
*vty
)
1818 struct ospf6_interface
*oi
;
1819 struct interface
*ifp
;
1821 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), i
, ifp
))
1823 oi
= (struct ospf6_interface
*) ifp
->info
;
1827 vty_out (vty
, "interface %s%s",
1828 oi
->interface
->name
, VNL
);
1831 vty_out (vty
, " description %s%s", ifp
->desc
, VNL
);
1832 if (ifp
->mtu6
!= oi
->ifmtu
)
1833 vty_out (vty
, " ipv6 ospf6 ifmtu %d%s", oi
->ifmtu
, VNL
);
1835 if (CHECK_FLAG (oi
->flag
, OSPF6_INTERFACE_NOAUTOCOST
))
1836 vty_out (vty
, " ipv6 ospf6 cost %d%s",
1839 if (oi
->hello_interval
!= OSPF6_INTERFACE_HELLO_INTERVAL
)
1840 vty_out (vty
, " ipv6 ospf6 hello-interval %d%s",
1841 oi
->hello_interval
, VNL
);
1843 if (oi
->dead_interval
!= OSPF6_INTERFACE_DEAD_INTERVAL
)
1844 vty_out (vty
, " ipv6 ospf6 dead-interval %d%s",
1845 oi
->dead_interval
, VNL
);
1847 if (oi
->rxmt_interval
!= OSPF6_INTERFACE_RXMT_INTERVAL
)
1848 vty_out (vty
, " ipv6 ospf6 retransmit-interval %d%s",
1849 oi
->rxmt_interval
, VNL
);
1851 if (oi
->priority
!= OSPF6_INTERFACE_PRIORITY
)
1852 vty_out (vty
, " ipv6 ospf6 priority %d%s",
1855 if (oi
->transdelay
!= OSPF6_INTERFACE_TRANSDELAY
)
1856 vty_out (vty
, " ipv6 ospf6 transmit-delay %d%s",
1857 oi
->transdelay
, VNL
);
1859 if (oi
->instance_id
!= OSPF6_INTERFACE_INSTANCE_ID
)
1860 vty_out (vty
, " ipv6 ospf6 instance-id %d%s",
1861 oi
->instance_id
, VNL
);
1864 vty_out (vty
, " ipv6 ospf6 advertise prefix-list %s%s",
1865 oi
->plist_name
, VNL
);
1867 if (CHECK_FLAG (oi
->flag
, OSPF6_INTERFACE_PASSIVE
))
1868 vty_out (vty
, " ipv6 ospf6 passive%s", VNL
);
1871 vty_out (vty
, " ipv6 ospf6 mtu-ignore%s", VNL
);
1873 if (oi
->type
!= ospf6_default_iftype(ifp
))
1875 if (oi
->type
== OSPF_IFTYPE_POINTOPOINT
)
1876 vty_out (vty
, " ipv6 ospf6 network point-to-point%s", VNL
);
1877 else if (oi
->type
== OSPF_IFTYPE_BROADCAST
)
1878 vty_out (vty
, " ipv6 ospf6 network broadcast%s", VNL
);
1881 ospf6_bfd_write_config(vty
, oi
);
1883 vty_out (vty
, "!%s", VNL
);
1888 static struct cmd_node interface_node
=
1896 ospf6_interface_init (void)
1898 /* Install interface node. */
1899 install_node (&interface_node
, config_write_ospf6_interface
);
1901 install_element (VIEW_NODE
, &show_ipv6_ospf6_interface_prefix_cmd
);
1902 install_element (VIEW_NODE
, &show_ipv6_ospf6_interface_ifname_cmd
);
1903 install_element (VIEW_NODE
, &show_ipv6_ospf6_interface_ifname_prefix_cmd
);
1904 install_element (ENABLE_NODE
, &show_ipv6_ospf6_interface_prefix_cmd
);
1905 install_element (ENABLE_NODE
, &show_ipv6_ospf6_interface_ifname_cmd
);
1906 install_element (ENABLE_NODE
, &show_ipv6_ospf6_interface_ifname_prefix_cmd
);
1908 install_element (CONFIG_NODE
, &interface_cmd
);
1909 install_default (INTERFACE_NODE
);
1910 install_element (INTERFACE_NODE
, &interface_desc_cmd
);
1911 install_element (INTERFACE_NODE
, &no_interface_desc_cmd
);
1912 install_element (INTERFACE_NODE
, &ipv6_ospf6_cost_cmd
);
1913 install_element (INTERFACE_NODE
, &no_ipv6_ospf6_cost_cmd
);
1914 install_element (INTERFACE_NODE
, &ipv6_ospf6_ifmtu_cmd
);
1915 install_element (INTERFACE_NODE
, &no_ipv6_ospf6_ifmtu_cmd
);
1916 install_element (INTERFACE_NODE
, &ipv6_ospf6_deadinterval_cmd
);
1917 install_element (INTERFACE_NODE
, &ipv6_ospf6_hellointerval_cmd
);
1918 install_element (INTERFACE_NODE
, &ipv6_ospf6_priority_cmd
);
1919 install_element (INTERFACE_NODE
, &ipv6_ospf6_retransmitinterval_cmd
);
1920 install_element (INTERFACE_NODE
, &ipv6_ospf6_transmitdelay_cmd
);
1921 install_element (INTERFACE_NODE
, &ipv6_ospf6_instance_cmd
);
1923 install_element (INTERFACE_NODE
, &ipv6_ospf6_passive_cmd
);
1924 install_element (INTERFACE_NODE
, &no_ipv6_ospf6_passive_cmd
);
1926 install_element (INTERFACE_NODE
, &ipv6_ospf6_mtu_ignore_cmd
);
1927 install_element (INTERFACE_NODE
, &no_ipv6_ospf6_mtu_ignore_cmd
);
1929 install_element (INTERFACE_NODE
, &ipv6_ospf6_advertise_prefix_list_cmd
);
1930 install_element (INTERFACE_NODE
, &no_ipv6_ospf6_advertise_prefix_list_cmd
);
1932 install_element (INTERFACE_NODE
, &ipv6_ospf6_network_cmd
);
1933 install_element (INTERFACE_NODE
, &no_ipv6_ospf6_network_cmd
);
1935 /* reference bandwidth commands */
1936 install_element (OSPF6_NODE
, &auto_cost_reference_bandwidth_cmd
);
1937 install_element (OSPF6_NODE
, &no_auto_cost_reference_bandwidth_cmd
);
1940 /* Clear the specified interface structure */
1942 ospf6_interface_clear (struct vty
*vty
, struct interface
*ifp
)
1944 struct ospf6_interface
*oi
;
1946 if (!if_is_operative (ifp
))
1949 if (ifp
->info
== NULL
)
1952 oi
= (struct ospf6_interface
*) ifp
->info
;
1954 if (IS_OSPF6_DEBUG_INTERFACE
)
1955 zlog_debug ("Interface %s: clear by reset", ifp
->name
);
1957 /* Reset the interface */
1958 thread_add_event (master
, interface_down
, oi
, 0);
1959 thread_add_event (master
, interface_up
, oi
, 0);
1962 /* Clear interface */
1963 DEFUN (clear_ipv6_ospf6_interface
,
1964 clear_ipv6_ospf6_interface_cmd
,
1965 "clear ipv6 ospf6 interface [IFNAME]",
1974 struct interface
*ifp
;
1975 struct listnode
*node
;
1977 if (argc
== 4) /* Clear all the ospfv3 interfaces. */
1979 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
1980 ospf6_interface_clear (vty
, ifp
);
1982 else /* Interface name is specified. */
1984 if ((ifp
= if_lookup_by_name (argv
[idx_ifname
]->arg
)) == NULL
)
1986 vty_out (vty
, "No such Interface: %s%s", argv
[idx_ifname
]->arg
, VNL
);
1989 ospf6_interface_clear (vty
, ifp
);
1996 install_element_ospf6_clear_interface (void)
1998 install_element (ENABLE_NODE
, &clear_ipv6_ospf6_interface_cmd
);
2001 DEFUN (debug_ospf6_interface
,
2002 debug_ospf6_interface_cmd
,
2003 "debug ospf6 interface",
2006 "Debug OSPFv3 Interface\n"
2009 OSPF6_DEBUG_INTERFACE_ON ();
2013 DEFUN (no_debug_ospf6_interface
,
2014 no_debug_ospf6_interface_cmd
,
2015 "no debug ospf6 interface",
2019 "Debug OSPFv3 Interface\n"
2022 OSPF6_DEBUG_INTERFACE_OFF ();
2027 config_write_ospf6_debug_interface (struct vty
*vty
)
2029 if (IS_OSPF6_DEBUG_INTERFACE
)
2030 vty_out (vty
, "debug ospf6 interface%s", VNL
);
2035 install_element_ospf6_debug_interface (void)
2037 install_element (ENABLE_NODE
, &debug_ospf6_interface_cmd
);
2038 install_element (ENABLE_NODE
, &no_debug_ospf6_interface_cmd
);
2039 install_element (CONFIG_NODE
, &debug_ospf6_interface_cmd
);
2040 install_element (CONFIG_NODE
, &no_debug_ospf6_interface_cmd
);