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.
32 #include "ospf6_lsa.h"
33 #include "ospf6_lsdb.h"
34 #include "ospf6_network.h"
35 #include "ospf6_message.h"
36 #include "ospf6_route.h"
37 #include "ospf6_top.h"
38 #include "ospf6_area.h"
39 #include "ospf6_interface.h"
40 #include "ospf6_neighbor.h"
41 #include "ospf6_intra.h"
42 #include "ospf6_spf.h"
45 unsigned char conf_debug_ospf6_interface
= 0;
47 const char *ospf6_interface_state_str
[] =
60 struct ospf6_interface
*
61 ospf6_interface_lookup_by_ifindex (int ifindex
)
63 struct ospf6_interface
*oi
;
64 struct interface
*ifp
;
66 ifp
= if_lookup_by_index (ifindex
);
68 return (struct ospf6_interface
*) NULL
;
70 oi
= (struct ospf6_interface
*) ifp
->info
;
74 /* schedule routing table recalculation */
76 ospf6_interface_lsdb_hook (struct ospf6_lsa
*lsa
, unsigned int reason
)
78 struct ospf6_interface
*oi
;
84 switch (ntohs (lsa
->header
->type
))
86 case OSPF6_LSTYPE_LINK
:
87 if (oi
->state
== OSPF6_INTERFACE_DR
)
88 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi
);
89 ospf6_spf_schedule (oi
->area
->ospf6
, reason
);
98 ospf6_interface_lsdb_hook_add (struct ospf6_lsa
*lsa
)
100 ospf6_interface_lsdb_hook(lsa
, ospf6_lsadd_to_spf_reason(lsa
));
104 ospf6_interface_lsdb_hook_remove (struct ospf6_lsa
*lsa
)
106 ospf6_interface_lsdb_hook(lsa
, ospf6_lsremove_to_spf_reason(lsa
));
110 ospf6_default_iftype(struct interface
*ifp
)
112 if (if_is_pointopoint (ifp
))
113 return OSPF_IFTYPE_POINTOPOINT
;
114 else if (if_is_loopback (ifp
))
115 return OSPF_IFTYPE_LOOPBACK
;
117 return OSPF_IFTYPE_BROADCAST
;
121 ospf6_interface_get_cost (struct ospf6_interface
*oi
)
123 /* If all else fails, use default OSPF cost */
127 bw
= oi
->interface
->bandwidth
? oi
->interface
->bandwidth
: OSPF6_INTERFACE_BANDWIDTH
;
128 refbw
= ospf6
? ospf6
->ref_bandwidth
: OSPF6_REFERENCE_BANDWIDTH
;
130 /* A specifed ip ospf cost overrides a calculated one. */
131 if (CHECK_FLAG (oi
->flag
, OSPF6_INTERFACE_NOAUTOCOST
))
135 cost
= (u_int32_t
) ((double)refbw
/ (double)bw
+ (double)0.5);
136 if (cost
< 1) cost
= 1;
137 else if (cost
> UINT32_MAX
) cost
= UINT32_MAX
;
144 ospf6_interface_recalculate_cost (struct ospf6_interface
*oi
)
148 newcost
= ospf6_interface_get_cost (oi
);
149 if (newcost
== oi
->cost
) return;
152 /* update cost held in route_connected list in ospf6_interface */
153 ospf6_interface_connected_route_update (oi
->interface
);
155 /* execute LSA hooks */
158 OSPF6_LINK_LSA_SCHEDULE (oi
);
159 OSPF6_ROUTER_LSA_SCHEDULE (oi
->area
);
160 OSPF6_NETWORK_LSA_SCHEDULE (oi
);
161 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi
);
162 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi
->area
);
166 /* Create new ospf6 interface structure */
167 struct ospf6_interface
*
168 ospf6_interface_create (struct interface
*ifp
)
170 struct ospf6_interface
*oi
;
171 unsigned int iobuflen
;
173 oi
= (struct ospf6_interface
*)
174 XCALLOC (MTYPE_OSPF6_IF
, sizeof (struct ospf6_interface
));
178 zlog_err ("Can't malloc ospf6_interface for ifindex %d", ifp
->ifindex
);
179 return (struct ospf6_interface
*) NULL
;
182 oi
->area
= (struct ospf6_area
*) NULL
;
183 oi
->neighbor_list
= list_new ();
184 oi
->neighbor_list
->cmp
= ospf6_neighbor_cmp
;
185 oi
->linklocal_addr
= (struct in6_addr
*) NULL
;
186 oi
->instance_id
= OSPF6_INTERFACE_INSTANCE_ID
;
187 oi
->transdelay
= OSPF6_INTERFACE_TRANSDELAY
;
188 oi
->priority
= OSPF6_INTERFACE_PRIORITY
;
190 oi
->hello_interval
= OSPF_HELLO_INTERVAL_DEFAULT
;
191 oi
->dead_interval
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
192 oi
->rxmt_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
193 oi
->type
= ospf6_default_iftype (ifp
);
194 oi
->state
= OSPF6_INTERFACE_DOWN
;
198 /* Try to adjust I/O buffer size with IfMtu */
199 oi
->ifmtu
= ifp
->mtu6
;
200 iobuflen
= ospf6_iobuf_size (ifp
->mtu6
);
201 if (oi
->ifmtu
> iobuflen
)
203 if (IS_OSPF6_DEBUG_INTERFACE
)
204 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
205 ifp
->name
, iobuflen
);
206 oi
->ifmtu
= iobuflen
;
209 oi
->lsupdate_list
= ospf6_lsdb_create (oi
);
210 oi
->lsack_list
= ospf6_lsdb_create (oi
);
211 oi
->lsdb
= ospf6_lsdb_create (oi
);
212 oi
->lsdb
->hook_add
= ospf6_interface_lsdb_hook_add
;
213 oi
->lsdb
->hook_remove
= ospf6_interface_lsdb_hook_remove
;
214 oi
->lsdb_self
= ospf6_lsdb_create (oi
);
216 oi
->route_connected
= OSPF6_ROUTE_TABLE_CREATE (INTERFACE
, CONNECTED_ROUTES
);
217 oi
->route_connected
->scope
= oi
;
224 oi
->cost
= ospf6_interface_get_cost(oi
);
230 ospf6_interface_delete (struct ospf6_interface
*oi
)
232 struct listnode
*node
, *nnode
;
233 struct ospf6_neighbor
*on
;
235 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
236 ospf6_neighbor_delete (on
);
238 list_delete (oi
->neighbor_list
);
240 THREAD_OFF (oi
->thread_send_hello
);
241 THREAD_OFF (oi
->thread_send_lsupdate
);
242 THREAD_OFF (oi
->thread_send_lsack
);
244 ospf6_lsdb_remove_all (oi
->lsdb
);
245 ospf6_lsdb_remove_all (oi
->lsupdate_list
);
246 ospf6_lsdb_remove_all (oi
->lsack_list
);
248 ospf6_lsdb_delete (oi
->lsdb
);
249 ospf6_lsdb_delete (oi
->lsdb_self
);
251 ospf6_lsdb_delete (oi
->lsupdate_list
);
252 ospf6_lsdb_delete (oi
->lsack_list
);
254 ospf6_route_table_delete (oi
->route_connected
);
257 oi
->interface
->info
= NULL
;
261 XFREE (MTYPE_PREFIX_LIST_STR
, oi
->plist_name
);
263 XFREE (MTYPE_OSPF6_IF
, oi
);
267 ospf6_interface_enable (struct ospf6_interface
*oi
)
269 UNSET_FLAG (oi
->flag
, OSPF6_INTERFACE_DISABLE
);
270 ospf6_interface_state_update (oi
->interface
);
274 ospf6_interface_disable (struct ospf6_interface
*oi
)
276 SET_FLAG (oi
->flag
, OSPF6_INTERFACE_DISABLE
);
278 thread_execute (master
, interface_down
, oi
, 0);
280 ospf6_lsdb_remove_all (oi
->lsdb
);
281 ospf6_lsdb_remove_all (oi
->lsdb_self
);
282 ospf6_lsdb_remove_all (oi
->lsupdate_list
);
283 ospf6_lsdb_remove_all (oi
->lsack_list
);
285 THREAD_OFF (oi
->thread_send_hello
);
286 THREAD_OFF (oi
->thread_send_lsupdate
);
287 THREAD_OFF (oi
->thread_send_lsack
);
289 THREAD_OFF (oi
->thread_network_lsa
);
290 THREAD_OFF (oi
->thread_link_lsa
);
291 THREAD_OFF (oi
->thread_intra_prefix_lsa
);
294 static struct in6_addr
*
295 ospf6_interface_get_linklocal_address (struct interface
*ifp
)
299 struct in6_addr
*l
= (struct in6_addr
*) NULL
;
301 /* for each connected address */
302 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, n
, c
))
304 /* if family not AF_INET6, ignore */
305 if (c
->address
->family
!= AF_INET6
)
308 /* linklocal scope check */
309 if (IN6_IS_ADDR_LINKLOCAL (&c
->address
->u
.prefix6
))
310 l
= &c
->address
->u
.prefix6
;
316 ospf6_interface_if_add (struct interface
*ifp
)
318 struct ospf6_interface
*oi
;
319 unsigned int iobuflen
;
321 oi
= (struct ospf6_interface
*) ifp
->info
;
325 /* Try to adjust I/O buffer size with IfMtu */
327 oi
->ifmtu
= ifp
->mtu6
;
328 iobuflen
= ospf6_iobuf_size (ifp
->mtu6
);
329 if (oi
->ifmtu
> iobuflen
)
331 if (IS_OSPF6_DEBUG_INTERFACE
)
332 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
333 ifp
->name
, iobuflen
);
334 oi
->ifmtu
= iobuflen
;
337 /* interface start */
338 ospf6_interface_state_update(oi
->interface
);
342 ospf6_interface_if_del (struct interface
*ifp
)
344 struct ospf6_interface
*oi
;
346 oi
= (struct ospf6_interface
*) ifp
->info
;
352 thread_execute (master
, interface_down
, oi
, 0);
354 listnode_delete (oi
->area
->if_list
, oi
);
355 oi
->area
= (struct ospf6_area
*) NULL
;
358 oi
->interface
= NULL
;
361 ospf6_interface_delete (oi
);
365 ospf6_interface_state_update (struct interface
*ifp
)
367 struct ospf6_interface
*oi
;
369 oi
= (struct ospf6_interface
*) ifp
->info
;
372 if (oi
->area
== NULL
)
374 if (CHECK_FLAG (oi
->flag
, OSPF6_INTERFACE_DISABLE
))
377 if (if_is_operative (ifp
)
378 && (ospf6_interface_get_linklocal_address(oi
->interface
)
379 || if_is_loopback(oi
->interface
)))
380 thread_add_event (master
, interface_up
, oi
, 0);
382 thread_add_event (master
, interface_down
, oi
, 0);
388 ospf6_interface_connected_route_update (struct interface
*ifp
)
390 struct ospf6_interface
*oi
;
391 struct ospf6_route
*route
;
393 struct listnode
*node
, *nnode
;
394 struct in6_addr nh_addr
;
396 oi
= (struct ospf6_interface
*) ifp
->info
;
400 /* reset linklocal pointer */
401 oi
->linklocal_addr
= ospf6_interface_get_linklocal_address (ifp
);
403 /* if area is null, do not make connected-route list */
404 if (oi
->area
== NULL
)
407 if (CHECK_FLAG (oi
->flag
, OSPF6_INTERFACE_DISABLE
))
410 /* update "route to advertise" interface route table */
411 ospf6_route_remove_all (oi
->route_connected
);
413 for (ALL_LIST_ELEMENTS (oi
->interface
->connected
, node
, nnode
, c
))
415 if (c
->address
->family
!= AF_INET6
)
418 CONTINUE_IF_ADDRESS_LINKLOCAL (IS_OSPF6_DEBUG_INTERFACE
, c
->address
);
419 CONTINUE_IF_ADDRESS_UNSPECIFIED (IS_OSPF6_DEBUG_INTERFACE
, c
->address
);
420 CONTINUE_IF_ADDRESS_LOOPBACK (IS_OSPF6_DEBUG_INTERFACE
, c
->address
);
421 CONTINUE_IF_ADDRESS_V4COMPAT (IS_OSPF6_DEBUG_INTERFACE
, c
->address
);
422 CONTINUE_IF_ADDRESS_V4MAPPED (IS_OSPF6_DEBUG_INTERFACE
, c
->address
);
427 struct prefix_list
*plist
;
428 enum prefix_list_type ret
;
431 prefix2str (c
->address
, buf
, sizeof (buf
));
432 plist
= prefix_list_lookup (AFI_IP6
, oi
->plist_name
);
433 ret
= prefix_list_apply (plist
, (void *) c
->address
);
434 if (ret
== PREFIX_DENY
)
436 if (IS_OSPF6_DEBUG_INTERFACE
)
437 zlog_debug ("%s on %s filtered by prefix-list %s ",
438 buf
, oi
->interface
->name
, oi
->plist_name
);
443 route
= ospf6_route_create ();
444 memcpy (&route
->prefix
, c
->address
, sizeof (struct prefix
));
445 apply_mask (&route
->prefix
);
446 route
->type
= OSPF6_DEST_TYPE_NETWORK
;
447 route
->path
.area_id
= oi
->area
->area_id
;
448 route
->path
.type
= OSPF6_PATH_TYPE_INTRA
;
449 route
->path
.cost
= oi
->cost
;
450 inet_pton (AF_INET6
, "::1", &nh_addr
);
451 ospf6_route_add_nexthop (route
, oi
->interface
->ifindex
, &nh_addr
);
452 ospf6_route_add (route
, oi
->route_connected
);
455 /* create new Link-LSA */
456 OSPF6_LINK_LSA_SCHEDULE (oi
);
457 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi
);
458 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi
->area
);
462 ospf6_interface_state_change (u_char next_state
, struct ospf6_interface
*oi
)
466 prev_state
= oi
->state
;
467 oi
->state
= next_state
;
469 if (prev_state
== next_state
)
473 if (IS_OSPF6_DEBUG_INTERFACE
)
475 zlog_debug ("Interface state change %s: %s -> %s", oi
->interface
->name
,
476 ospf6_interface_state_str
[prev_state
],
477 ospf6_interface_state_str
[next_state
]);
481 if ((prev_state
== OSPF6_INTERFACE_DR
||
482 prev_state
== OSPF6_INTERFACE_BDR
) &&
483 (next_state
!= OSPF6_INTERFACE_DR
&&
484 next_state
!= OSPF6_INTERFACE_BDR
))
485 ospf6_sso (oi
->interface
->ifindex
, &alldrouters6
, IPV6_LEAVE_GROUP
);
487 if ((prev_state
!= OSPF6_INTERFACE_DR
&&
488 prev_state
!= OSPF6_INTERFACE_BDR
) &&
489 (next_state
== OSPF6_INTERFACE_DR
||
490 next_state
== OSPF6_INTERFACE_BDR
))
491 ospf6_sso (oi
->interface
->ifindex
, &alldrouters6
, IPV6_JOIN_GROUP
);
493 OSPF6_ROUTER_LSA_SCHEDULE (oi
->area
);
494 if (next_state
== OSPF6_INTERFACE_DOWN
)
496 OSPF6_NETWORK_LSA_EXECUTE (oi
);
497 OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT (oi
);
498 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi
->area
);
500 else if (prev_state
== OSPF6_INTERFACE_DR
||
501 next_state
== OSPF6_INTERFACE_DR
)
503 OSPF6_NETWORK_LSA_SCHEDULE (oi
);
504 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi
);
505 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi
->area
);
509 /* Terminal state or regression */
510 if ((next_state
== OSPF6_INTERFACE_POINTTOPOINT
) ||
511 (next_state
== OSPF6_INTERFACE_DROTHER
) ||
512 (next_state
== OSPF6_INTERFACE_BDR
) ||
513 (next_state
== OSPF6_INTERFACE_DR
) ||
514 (next_state
< prev_state
))
515 ospf6TrapIfStateChange (oi
);
521 /* DR Election, RFC2328 section 9.4 */
523 #define IS_ELIGIBLE(n) \
524 ((n)->state >= OSPF6_NEIGHBOR_TWOWAY && (n)->priority != 0)
526 static struct ospf6_neighbor
*
527 better_bdrouter (struct ospf6_neighbor
*a
, struct ospf6_neighbor
*b
)
529 if ((a
== NULL
|| ! IS_ELIGIBLE (a
) || a
->drouter
== a
->router_id
) &&
530 (b
== NULL
|| ! IS_ELIGIBLE (b
) || b
->drouter
== b
->router_id
))
532 else if (a
== NULL
|| ! IS_ELIGIBLE (a
) || a
->drouter
== a
->router_id
)
534 else if (b
== NULL
|| ! IS_ELIGIBLE (b
) || b
->drouter
== b
->router_id
)
537 if (a
->bdrouter
== a
->router_id
&& b
->bdrouter
!= b
->router_id
)
539 if (a
->bdrouter
!= a
->router_id
&& b
->bdrouter
== b
->router_id
)
542 if (a
->priority
> b
->priority
)
544 if (a
->priority
< b
->priority
)
547 if (ntohl (a
->router_id
) > ntohl (b
->router_id
))
549 if (ntohl (a
->router_id
) < ntohl (b
->router_id
))
552 zlog_warn ("Router-ID duplicate ?");
556 static struct ospf6_neighbor
*
557 better_drouter (struct ospf6_neighbor
*a
, struct ospf6_neighbor
*b
)
559 if ((a
== NULL
|| ! IS_ELIGIBLE (a
) || a
->drouter
!= a
->router_id
) &&
560 (b
== NULL
|| ! IS_ELIGIBLE (b
) || b
->drouter
!= b
->router_id
))
562 else if (a
== NULL
|| ! IS_ELIGIBLE (a
) || a
->drouter
!= a
->router_id
)
564 else if (b
== NULL
|| ! IS_ELIGIBLE (b
) || b
->drouter
!= b
->router_id
)
567 if (a
->drouter
== a
->router_id
&& b
->drouter
!= b
->router_id
)
569 if (a
->drouter
!= a
->router_id
&& b
->drouter
== b
->router_id
)
572 if (a
->priority
> b
->priority
)
574 if (a
->priority
< b
->priority
)
577 if (ntohl (a
->router_id
) > ntohl (b
->router_id
))
579 if (ntohl (a
->router_id
) < ntohl (b
->router_id
))
582 zlog_warn ("Router-ID duplicate ?");
587 dr_election (struct ospf6_interface
*oi
)
589 struct listnode
*node
, *nnode
;
590 struct ospf6_neighbor
*on
, *drouter
, *bdrouter
, myself
;
591 struct ospf6_neighbor
*best_drouter
, *best_bdrouter
;
592 u_char next_state
= 0;
594 drouter
= bdrouter
= NULL
;
595 best_drouter
= best_bdrouter
= NULL
;
597 /* pseudo neighbor myself, including noting current DR/BDR (1) */
598 memset (&myself
, 0, sizeof (myself
));
599 inet_ntop (AF_INET
, &oi
->area
->ospf6
->router_id
, myself
.name
,
600 sizeof (myself
.name
));
601 myself
.state
= OSPF6_NEIGHBOR_TWOWAY
;
602 myself
.drouter
= oi
->drouter
;
603 myself
.bdrouter
= oi
->bdrouter
;
604 myself
.priority
= oi
->priority
;
605 myself
.router_id
= oi
->area
->ospf6
->router_id
;
607 /* Electing BDR (2) */
608 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
609 bdrouter
= better_bdrouter (bdrouter
, on
);
611 best_bdrouter
= bdrouter
;
612 bdrouter
= better_bdrouter (best_bdrouter
, &myself
);
614 /* Electing DR (3) */
615 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
616 drouter
= better_drouter (drouter
, on
);
618 best_drouter
= drouter
;
619 drouter
= better_drouter (best_drouter
, &myself
);
623 /* the router itself is newly/no longer DR/BDR (4) */
624 if ((drouter
== &myself
&& myself
.drouter
!= myself
.router_id
) ||
625 (drouter
!= &myself
&& myself
.drouter
== myself
.router_id
) ||
626 (bdrouter
== &myself
&& myself
.bdrouter
!= myself
.router_id
) ||
627 (bdrouter
!= &myself
&& myself
.bdrouter
== myself
.router_id
))
629 myself
.drouter
= (drouter
? drouter
->router_id
: htonl (0));
630 myself
.bdrouter
= (bdrouter
? bdrouter
->router_id
: htonl (0));
632 /* compatible to Electing BDR (2) */
633 bdrouter
= better_bdrouter (best_bdrouter
, &myself
);
635 /* compatible to Electing DR (3) */
636 drouter
= better_drouter (best_drouter
, &myself
);
641 /* Set interface state accordingly (5) */
642 if (drouter
&& drouter
== &myself
)
643 next_state
= OSPF6_INTERFACE_DR
;
644 else if (bdrouter
&& bdrouter
== &myself
)
645 next_state
= OSPF6_INTERFACE_BDR
;
647 next_state
= OSPF6_INTERFACE_DROTHER
;
649 /* If NBMA, schedule Start for each neighbor having priority of 0 (6) */
652 /* If DR or BDR change, invoke AdjOK? for each neighbor (7) */
653 /* RFC 2328 section 12.4. Originating LSAs (3) will be handled
654 accordingly after AdjOK */
655 if (oi
->drouter
!= (drouter
? drouter
->router_id
: htonl (0)) ||
656 oi
->bdrouter
!= (bdrouter
? bdrouter
->router_id
: htonl (0)))
658 if (IS_OSPF6_DEBUG_INTERFACE
)
659 zlog_debug ("DR Election on %s: DR: %s BDR: %s", oi
->interface
->name
,
660 (drouter
? drouter
->name
: "0.0.0.0"),
661 (bdrouter
? bdrouter
->name
: "0.0.0.0"));
663 for (ALL_LIST_ELEMENTS_RO (oi
->neighbor_list
, node
, on
))
665 if (on
->state
< OSPF6_NEIGHBOR_TWOWAY
)
667 /* Schedule AdjOK. */
668 thread_add_event (master
, adj_ok
, on
, 0);
672 oi
->drouter
= (drouter
? drouter
->router_id
: htonl (0));
673 oi
->bdrouter
= (bdrouter
? bdrouter
->router_id
: htonl (0));
678 /* Interface State Machine */
680 interface_up (struct thread
*thread
)
682 struct ospf6_interface
*oi
;
684 oi
= (struct ospf6_interface
*) THREAD_ARG (thread
);
685 assert (oi
&& oi
->interface
);
687 if (IS_OSPF6_DEBUG_INTERFACE
)
688 zlog_debug ("Interface Event %s: [InterfaceUp]",
689 oi
->interface
->name
);
691 /* check physical interface is up */
692 if (! if_is_operative (oi
->interface
))
694 if (IS_OSPF6_DEBUG_INTERFACE
)
695 zlog_debug ("Interface %s is down, can't execute [InterfaceUp]",
696 oi
->interface
->name
);
700 /* check interface has a link-local address */
701 if (! (ospf6_interface_get_linklocal_address(oi
->interface
)
702 || if_is_loopback(oi
->interface
)))
704 if (IS_OSPF6_DEBUG_INTERFACE
)
705 zlog_debug ("Interface %s has no link local address, can't execute [InterfaceUp]",
706 oi
->interface
->name
);
711 ospf6_interface_recalculate_cost (oi
);
713 /* if already enabled, do nothing */
714 if (oi
->state
> OSPF6_INTERFACE_DOWN
)
716 if (IS_OSPF6_DEBUG_INTERFACE
)
717 zlog_debug ("Interface %s already enabled",
718 oi
->interface
->name
);
722 /* If no area assigned, return */
723 if (oi
->area
== NULL
)
725 zlog_debug ("%s: Not scheduleing Hello for %s as there is no area assigned yet", __func__
,
726 oi
->interface
->name
);
730 /* Join AllSPFRouters */
731 if (ospf6_sso (oi
->interface
->ifindex
, &allspfrouters6
, IPV6_JOIN_GROUP
) < 0)
733 if (oi
->sso_try_cnt
++ < OSPF6_INTERFACE_SSO_RETRY_MAX
)
735 zlog_info("Scheduling %s for sso retry, trial count: %d",
736 oi
->interface
->name
, oi
->sso_try_cnt
);
737 thread_add_timer (master
, interface_up
, oi
,
738 OSPF6_INTERFACE_SSO_RETRY_INT
);
742 oi
->sso_try_cnt
= 0; /* Reset on success */
744 /* Update interface route */
745 ospf6_interface_connected_route_update (oi
->interface
);
748 if (! CHECK_FLAG (oi
->flag
, OSPF6_INTERFACE_PASSIVE
))
749 oi
->thread_send_hello
= thread_add_event (master
, ospf6_hello_send
, oi
, 0);
751 /* decide next interface state */
752 if ((if_is_pointopoint (oi
->interface
)) ||
753 (oi
->type
== OSPF_IFTYPE_POINTOPOINT
)) {
754 ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT
, oi
);
756 else if (oi
->priority
== 0)
757 ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER
, oi
);
760 ospf6_interface_state_change (OSPF6_INTERFACE_WAITING
, oi
);
761 thread_add_timer (master
, wait_timer
, oi
, oi
->dead_interval
);
768 wait_timer (struct thread
*thread
)
770 struct ospf6_interface
*oi
;
772 oi
= (struct ospf6_interface
*) THREAD_ARG (thread
);
773 assert (oi
&& oi
->interface
);
775 if (IS_OSPF6_DEBUG_INTERFACE
)
776 zlog_debug ("Interface Event %s: [WaitTimer]",
777 oi
->interface
->name
);
779 if (oi
->state
== OSPF6_INTERFACE_WAITING
)
780 ospf6_interface_state_change (dr_election (oi
), oi
);
786 backup_seen (struct thread
*thread
)
788 struct ospf6_interface
*oi
;
790 oi
= (struct ospf6_interface
*) THREAD_ARG (thread
);
791 assert (oi
&& oi
->interface
);
793 if (IS_OSPF6_DEBUG_INTERFACE
)
794 zlog_debug ("Interface Event %s: [BackupSeen]",
795 oi
->interface
->name
);
797 if (oi
->state
== OSPF6_INTERFACE_WAITING
)
798 ospf6_interface_state_change (dr_election (oi
), oi
);
804 neighbor_change (struct thread
*thread
)
806 struct ospf6_interface
*oi
;
808 oi
= (struct ospf6_interface
*) THREAD_ARG (thread
);
809 assert (oi
&& oi
->interface
);
811 if (IS_OSPF6_DEBUG_INTERFACE
)
812 zlog_debug ("Interface Event %s: [NeighborChange]",
813 oi
->interface
->name
);
815 if (oi
->state
== OSPF6_INTERFACE_DROTHER
||
816 oi
->state
== OSPF6_INTERFACE_BDR
||
817 oi
->state
== OSPF6_INTERFACE_DR
)
818 ospf6_interface_state_change (dr_election (oi
), oi
);
824 interface_down (struct thread
*thread
)
826 struct ospf6_interface
*oi
;
827 struct listnode
*node
, *nnode
;
828 struct ospf6_neighbor
*on
;
830 oi
= (struct ospf6_interface
*) THREAD_ARG (thread
);
831 assert (oi
&& oi
->interface
);
833 if (IS_OSPF6_DEBUG_INTERFACE
)
834 zlog_debug ("Interface Event %s: [InterfaceDown]",
835 oi
->interface
->name
);
838 THREAD_OFF (oi
->thread_send_hello
);
840 /* Leave AllSPFRouters */
841 if (oi
->state
> OSPF6_INTERFACE_DOWN
)
842 ospf6_sso (oi
->interface
->ifindex
, &allspfrouters6
, IPV6_LEAVE_GROUP
);
844 ospf6_interface_state_change (OSPF6_INTERFACE_DOWN
, oi
);
846 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
847 ospf6_neighbor_delete (on
);
849 list_delete_all_node (oi
->neighbor_list
);
851 /* When interface state is reset, also reset information about
852 * DR election, as it is no longer valid. */
853 oi
->drouter
= oi
->prev_drouter
= htonl(0);
854 oi
->bdrouter
= oi
->prev_bdrouter
= htonl(0);
859 /* show specified interface structure */
861 ospf6_interface_show (struct vty
*vty
, struct interface
*ifp
)
863 struct ospf6_interface
*oi
;
867 char strbuf
[64], drouter
[32], bdrouter
[32];
868 const char *updown
[3] = {"down", "up", NULL
};
870 struct timeval res
, now
;
872 struct ospf6_lsa
*lsa
;
874 /* check physical interface type */
875 if (if_is_loopback (ifp
))
877 else if (if_is_broadcast (ifp
))
879 else if (if_is_pointopoint (ifp
))
880 type
= "POINTOPOINT";
884 vty_out (vty
, "%s is %s, type %s%s",
885 ifp
->name
, updown
[if_is_operative (ifp
)], type
,
887 vty_out (vty
, " Interface ID: %d%s", ifp
->ifindex
, VNL
);
889 if (ifp
->info
== NULL
)
891 vty_out (vty
, " OSPF not enabled on this interface%s", VNL
);
895 oi
= (struct ospf6_interface
*) ifp
->info
;
897 vty_out (vty
, " Internet Address:%s", VNL
);
899 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, i
, c
))
902 prefix2str (p
, strbuf
, sizeof (strbuf
));
906 vty_out (vty
, " inet : %s%s", strbuf
,
910 vty_out (vty
, " inet6: %s%s", strbuf
,
914 vty_out (vty
, " ??? : %s%s", strbuf
,
922 vty_out (vty
, " Instance ID %d, Interface MTU %d (autodetect: %d)%s",
923 oi
->instance_id
, oi
->ifmtu
, ifp
->mtu6
, VNL
);
924 vty_out (vty
, " MTU mismatch detection: %s%s", oi
->mtu_ignore
?
925 "disabled" : "enabled", VNL
);
926 inet_ntop (AF_INET
, &oi
->area
->area_id
,
927 strbuf
, sizeof (strbuf
));
928 vty_out (vty
, " Area ID %s, Cost %hu%s", strbuf
, oi
->cost
,
932 vty_out (vty
, " Not Attached to Area%s", VNL
);
934 vty_out (vty
, " State %s, Transmit Delay %d sec, Priority %d%s",
935 ospf6_interface_state_str
[oi
->state
],
936 oi
->transdelay
, oi
->priority
,
938 vty_out (vty
, " Timer intervals configured:%s", VNL
);
939 vty_out (vty
, " Hello %d, Dead %d, Retransmit %d%s",
940 oi
->hello_interval
, oi
->dead_interval
, oi
->rxmt_interval
,
943 inet_ntop (AF_INET
, &oi
->drouter
, drouter
, sizeof (drouter
));
944 inet_ntop (AF_INET
, &oi
->bdrouter
, bdrouter
, sizeof (bdrouter
));
945 vty_out (vty
, " DR: %s BDR: %s%s", drouter
, bdrouter
, VNL
);
947 vty_out (vty
, " Number of I/F scoped LSAs is %u%s",
948 oi
->lsdb
->count
, VNL
);
950 quagga_gettime (QUAGGA_CLK_MONOTONIC
, &now
);
953 if (oi
->thread_send_lsupdate
)
954 timersub (&oi
->thread_send_lsupdate
->u
.sands
, &now
, &res
);
955 timerstring (&res
, duration
, sizeof (duration
));
956 vty_out (vty
, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
957 oi
->lsupdate_list
->count
, duration
,
958 (oi
->thread_send_lsupdate
? "on" : "off"),
960 for (lsa
= ospf6_lsdb_head (oi
->lsupdate_list
); lsa
;
961 lsa
= ospf6_lsdb_next (lsa
))
962 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
965 if (oi
->thread_send_lsack
)
966 timersub (&oi
->thread_send_lsack
->u
.sands
, &now
, &res
);
967 timerstring (&res
, duration
, sizeof (duration
));
968 vty_out (vty
, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
969 oi
->lsack_list
->count
, duration
,
970 (oi
->thread_send_lsack
? "on" : "off"),
972 for (lsa
= ospf6_lsdb_head (oi
->lsack_list
); lsa
;
973 lsa
= ospf6_lsdb_next (lsa
))
974 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
980 DEFUN (show_ipv6_ospf6_interface
,
981 show_ipv6_ospf6_interface_ifname_cmd
,
982 "show ipv6 ospf6 interface IFNAME",
990 struct interface
*ifp
;
995 ifp
= if_lookup_by_name (argv
[0]);
998 vty_out (vty
, "No such Interface: %s%s", argv
[0],
1002 ospf6_interface_show (vty
, ifp
);
1006 for (ALL_LIST_ELEMENTS_RO (iflist
, i
, ifp
))
1007 ospf6_interface_show (vty
, ifp
);
1013 ALIAS (show_ipv6_ospf6_interface
,
1014 show_ipv6_ospf6_interface_cmd
,
1015 "show ipv6 ospf6 interface",
1022 DEFUN (show_ipv6_ospf6_interface_ifname_prefix
,
1023 show_ipv6_ospf6_interface_ifname_prefix_cmd
,
1024 "show ipv6 ospf6 interface IFNAME prefix",
1030 "Display connected prefixes to advertise\n"
1033 struct interface
*ifp
;
1034 struct ospf6_interface
*oi
;
1036 ifp
= if_lookup_by_name (argv
[0]);
1039 vty_out (vty
, "No such Interface: %s%s", argv
[0], VNL
);
1046 vty_out (vty
, "OSPFv3 is not enabled on %s%s", argv
[0], VNL
);
1052 ospf6_route_table_show (vty
, argc
, argv
, oi
->route_connected
);
1057 ALIAS (show_ipv6_ospf6_interface_ifname_prefix
,
1058 show_ipv6_ospf6_interface_ifname_prefix_detail_cmd
,
1059 "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)",
1065 "Display connected prefixes to advertise\n"
1066 OSPF6_ROUTE_ADDRESS_STR
1067 OSPF6_ROUTE_PREFIX_STR
1068 "Display details of the prefixes\n"
1071 ALIAS (show_ipv6_ospf6_interface_ifname_prefix
,
1072 show_ipv6_ospf6_interface_ifname_prefix_match_cmd
,
1073 "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)",
1079 "Display connected prefixes to advertise\n"
1080 OSPF6_ROUTE_PREFIX_STR
1081 OSPF6_ROUTE_MATCH_STR
1082 "Display details of the prefixes\n"
1085 DEFUN (show_ipv6_ospf6_interface_prefix
,
1086 show_ipv6_ospf6_interface_prefix_cmd
,
1087 "show ipv6 ospf6 interface prefix",
1092 "Display connected prefixes to advertise\n"
1096 struct ospf6_interface
*oi
;
1097 struct interface
*ifp
;
1099 for (ALL_LIST_ELEMENTS_RO (iflist
, i
, ifp
))
1101 oi
= (struct ospf6_interface
*) ifp
->info
;
1105 ospf6_route_table_show (vty
, argc
, argv
, oi
->route_connected
);
1111 ALIAS (show_ipv6_ospf6_interface_prefix
,
1112 show_ipv6_ospf6_interface_prefix_detail_cmd
,
1113 "show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)",
1118 "Display connected prefixes to advertise\n"
1119 OSPF6_ROUTE_ADDRESS_STR
1120 OSPF6_ROUTE_PREFIX_STR
1121 "Display details of the prefixes\n"
1124 ALIAS (show_ipv6_ospf6_interface_prefix
,
1125 show_ipv6_ospf6_interface_prefix_match_cmd
,
1126 "show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)",
1131 "Display connected prefixes to advertise\n"
1132 OSPF6_ROUTE_PREFIX_STR
1133 OSPF6_ROUTE_MATCH_STR
1134 "Display details of the prefixes\n"
1138 /* interface variable set command */
1139 DEFUN (ipv6_ospf6_ifmtu
,
1140 ipv6_ospf6_ifmtu_cmd
,
1141 "ipv6 ospf6 ifmtu <1-65535>",
1145 "OSPFv3 Interface MTU\n"
1148 struct ospf6_interface
*oi
;
1149 struct interface
*ifp
;
1150 unsigned int ifmtu
, iobuflen
;
1151 struct listnode
*node
, *nnode
;
1152 struct ospf6_neighbor
*on
;
1154 ifp
= (struct interface
*) vty
->index
;
1157 oi
= (struct ospf6_interface
*) ifp
->info
;
1159 oi
= ospf6_interface_create (ifp
);
1162 ifmtu
= strtol (argv
[0], NULL
, 10);
1164 if (oi
->ifmtu
== ifmtu
)
1167 if (ifp
->mtu6
!= 0 && ifp
->mtu6
< ifmtu
)
1169 vty_out (vty
, "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)%s",
1170 ifp
->name
, ifp
->mtu6
, VNL
);
1174 if (oi
->ifmtu
< ifmtu
)
1176 iobuflen
= ospf6_iobuf_size (ifmtu
);
1177 if (iobuflen
< ifmtu
)
1179 vty_out (vty
, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
1180 ifp
->name
, iobuflen
, VNL
);
1181 oi
->ifmtu
= iobuflen
;
1189 /* re-establish adjacencies */
1190 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
1192 THREAD_OFF (on
->inactivity_timer
);
1193 thread_add_event (master
, inactivity_timer
, on
, 0);
1199 DEFUN (no_ipv6_ospf6_ifmtu
,
1200 no_ipv6_ospf6_ifmtu_cmd
,
1201 "no ipv6 ospf6 ifmtu",
1208 struct ospf6_interface
*oi
;
1209 struct interface
*ifp
;
1210 unsigned int iobuflen
;
1211 struct listnode
*node
, *nnode
;
1212 struct ospf6_neighbor
*on
;
1214 ifp
= (struct interface
*) vty
->index
;
1217 oi
= (struct ospf6_interface
*) ifp
->info
;
1219 oi
= ospf6_interface_create (ifp
);
1222 if (oi
->ifmtu
< ifp
->mtu
)
1224 iobuflen
= ospf6_iobuf_size (ifp
->mtu
);
1225 if (iobuflen
< ifp
->mtu
)
1227 vty_out (vty
, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
1228 ifp
->name
, iobuflen
, VNL
);
1229 oi
->ifmtu
= iobuflen
;
1232 oi
->ifmtu
= ifp
->mtu
;
1235 oi
->ifmtu
= ifp
->mtu
;
1237 /* re-establish adjacencies */
1238 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
1240 THREAD_OFF (on
->inactivity_timer
);
1241 thread_add_event (master
, inactivity_timer
, on
, 0);
1247 DEFUN (ipv6_ospf6_cost
,
1248 ipv6_ospf6_cost_cmd
,
1249 "ipv6 ospf6 cost <1-65535>",
1253 "Outgoing metric of this interface\n"
1256 struct ospf6_interface
*oi
;
1257 struct interface
*ifp
;
1258 unsigned long int lcost
;
1260 ifp
= (struct interface
*) vty
->index
;
1263 oi
= (struct ospf6_interface
*) ifp
->info
;
1265 oi
= ospf6_interface_create (ifp
);
1268 lcost
= strtol (argv
[0], NULL
, 10);
1270 if (lcost
> UINT32_MAX
)
1272 vty_out (vty
, "Cost %ld is out of range%s", lcost
, VNL
);
1276 if (oi
->cost
== lcost
)
1280 SET_FLAG (oi
->flag
, OSPF6_INTERFACE_NOAUTOCOST
);
1282 ospf6_interface_recalculate_cost(oi
);
1287 DEFUN (no_ipv6_ospf6_cost
,
1288 no_ipv6_ospf6_cost_cmd
,
1289 "no ipv6 ospf6 cost",
1293 "Calculate interface cost from bandwidth\n"
1296 struct ospf6_interface
*oi
;
1297 struct interface
*ifp
;
1298 unsigned long int lcost
;
1300 ifp
= (struct interface
*) vty
->index
;
1303 oi
= (struct ospf6_interface
*) ifp
->info
;
1305 oi
= ospf6_interface_create (ifp
);
1308 UNSET_FLAG (oi
->flag
, OSPF6_INTERFACE_NOAUTOCOST
);
1310 ospf6_interface_recalculate_cost(oi
);
1315 DEFUN (auto_cost_reference_bandwidth
,
1316 auto_cost_reference_bandwidth_cmd
,
1317 "auto-cost reference-bandwidth <1-4294967>",
1318 "Calculate OSPF interface cost according to bandwidth\n"
1319 "Use reference bandwidth method to assign OSPF cost\n"
1320 "The reference bandwidth in terms of Mbits per second\n")
1322 struct ospf6
*o
= vty
->index
;
1323 struct ospf6_area
*oa
;
1324 struct ospf6_interface
*oi
;
1325 struct listnode
*i
, *j
;
1328 refbw
= strtol (argv
[0], NULL
, 10);
1329 if (refbw
< 1 || refbw
> 4294967)
1331 vty_out (vty
, "reference-bandwidth value is invalid%s", VTY_NEWLINE
);
1335 /* If reference bandwidth is changed. */
1336 if ((refbw
* 1000) == o
->ref_bandwidth
)
1339 o
->ref_bandwidth
= refbw
* 1000;
1340 for (ALL_LIST_ELEMENTS_RO (o
->area_list
, i
, oa
))
1341 for (ALL_LIST_ELEMENTS_RO (oa
->if_list
, j
, oi
))
1342 ospf6_interface_recalculate_cost (oi
);
1347 DEFUN (no_auto_cost_reference_bandwidth
,
1348 no_auto_cost_reference_bandwidth_cmd
,
1349 "no auto-cost reference-bandwidth",
1351 "Calculate OSPF interface cost according to bandwidth\n"
1352 "Use reference bandwidth method to assign OSPF cost\n")
1354 struct ospf6
*o
= vty
->index
;
1355 struct ospf6_area
*oa
;
1356 struct ospf6_interface
*oi
;
1357 struct listnode
*i
, *j
;
1359 if (o
->ref_bandwidth
== OSPF6_REFERENCE_BANDWIDTH
)
1362 o
->ref_bandwidth
= OSPF6_REFERENCE_BANDWIDTH
;
1363 for (ALL_LIST_ELEMENTS_RO (o
->area_list
, i
, oa
))
1364 for (ALL_LIST_ELEMENTS_RO (oa
->if_list
, j
, oi
))
1365 ospf6_interface_recalculate_cost (oi
);
1370 DEFUN (ipv6_ospf6_hellointerval
,
1371 ipv6_ospf6_hellointerval_cmd
,
1372 "ipv6 ospf6 hello-interval <1-65535>",
1375 "Interval time of Hello packets\n"
1379 struct ospf6_interface
*oi
;
1380 struct interface
*ifp
;
1382 ifp
= (struct interface
*) vty
->index
;
1385 oi
= (struct ospf6_interface
*) ifp
->info
;
1387 oi
= ospf6_interface_create (ifp
);
1390 oi
->hello_interval
= strtol (argv
[0], NULL
, 10);
1394 /* interface variable set command */
1395 DEFUN (ipv6_ospf6_deadinterval
,
1396 ipv6_ospf6_deadinterval_cmd
,
1397 "ipv6 ospf6 dead-interval <1-65535>",
1400 "Interval time after which a neighbor is declared down\n"
1404 struct ospf6_interface
*oi
;
1405 struct interface
*ifp
;
1407 ifp
= (struct interface
*) vty
->index
;
1410 oi
= (struct ospf6_interface
*) ifp
->info
;
1412 oi
= ospf6_interface_create (ifp
);
1415 oi
->dead_interval
= strtol (argv
[0], NULL
, 10);
1419 /* interface variable set command */
1420 DEFUN (ipv6_ospf6_transmitdelay
,
1421 ipv6_ospf6_transmitdelay_cmd
,
1422 "ipv6 ospf6 transmit-delay <1-3600>",
1425 "Transmit delay of this interface\n"
1429 struct ospf6_interface
*oi
;
1430 struct interface
*ifp
;
1432 ifp
= (struct interface
*) vty
->index
;
1435 oi
= (struct ospf6_interface
*) ifp
->info
;
1437 oi
= ospf6_interface_create (ifp
);
1440 oi
->transdelay
= strtol (argv
[0], NULL
, 10);
1444 /* interface variable set command */
1445 DEFUN (ipv6_ospf6_retransmitinterval
,
1446 ipv6_ospf6_retransmitinterval_cmd
,
1447 "ipv6 ospf6 retransmit-interval <1-65535>",
1450 "Time between retransmitting lost link state advertisements\n"
1454 struct ospf6_interface
*oi
;
1455 struct interface
*ifp
;
1457 ifp
= (struct interface
*) vty
->index
;
1460 oi
= (struct ospf6_interface
*) ifp
->info
;
1462 oi
= ospf6_interface_create (ifp
);
1465 oi
->rxmt_interval
= strtol (argv
[0], NULL
, 10);
1469 /* interface variable set command */
1470 DEFUN (ipv6_ospf6_priority
,
1471 ipv6_ospf6_priority_cmd
,
1472 "ipv6 ospf6 priority <0-255>",
1479 struct ospf6_interface
*oi
;
1480 struct interface
*ifp
;
1482 ifp
= (struct interface
*) vty
->index
;
1485 oi
= (struct ospf6_interface
*) ifp
->info
;
1487 oi
= ospf6_interface_create (ifp
);
1490 oi
->priority
= strtol (argv
[0], NULL
, 10);
1493 (oi
->state
== OSPF6_INTERFACE_DROTHER
||
1494 oi
->state
== OSPF6_INTERFACE_BDR
||
1495 oi
->state
== OSPF6_INTERFACE_DR
))
1496 ospf6_interface_state_change (dr_election (oi
), oi
);
1501 DEFUN (ipv6_ospf6_instance
,
1502 ipv6_ospf6_instance_cmd
,
1503 "ipv6 ospf6 instance-id <0-255>",
1506 "Instance ID for this interface\n"
1507 "Instance ID value\n"
1510 struct ospf6_interface
*oi
;
1511 struct interface
*ifp
;
1513 ifp
= (struct interface
*)vty
->index
;
1516 oi
= (struct ospf6_interface
*)ifp
->info
;
1518 oi
= ospf6_interface_create (ifp
);
1521 oi
->instance_id
= strtol (argv
[0], NULL
, 10);
1525 DEFUN (ipv6_ospf6_passive
,
1526 ipv6_ospf6_passive_cmd
,
1527 "ipv6 ospf6 passive",
1530 "passive interface, No adjacency will be formed on this interface\n"
1533 struct ospf6_interface
*oi
;
1534 struct interface
*ifp
;
1535 struct listnode
*node
, *nnode
;
1536 struct ospf6_neighbor
*on
;
1538 ifp
= (struct interface
*) vty
->index
;
1541 oi
= (struct ospf6_interface
*) ifp
->info
;
1543 oi
= ospf6_interface_create (ifp
);
1546 SET_FLAG (oi
->flag
, OSPF6_INTERFACE_PASSIVE
);
1547 THREAD_OFF (oi
->thread_send_hello
);
1549 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
1551 THREAD_OFF (on
->inactivity_timer
);
1552 thread_add_event (master
, inactivity_timer
, on
, 0);
1558 DEFUN (no_ipv6_ospf6_passive
,
1559 no_ipv6_ospf6_passive_cmd
,
1560 "no ipv6 ospf6 passive",
1564 "passive interface: No Adjacency will be formed on this I/F\n"
1567 struct ospf6_interface
*oi
;
1568 struct interface
*ifp
;
1570 ifp
= (struct interface
*) vty
->index
;
1573 oi
= (struct ospf6_interface
*) ifp
->info
;
1575 oi
= ospf6_interface_create (ifp
);
1578 UNSET_FLAG (oi
->flag
, OSPF6_INTERFACE_PASSIVE
);
1579 THREAD_OFF (oi
->thread_send_hello
);
1580 oi
->thread_send_hello
=
1581 thread_add_event (master
, ospf6_hello_send
, oi
, 0);
1586 DEFUN (ipv6_ospf6_mtu_ignore
,
1587 ipv6_ospf6_mtu_ignore_cmd
,
1588 "ipv6 ospf6 mtu-ignore",
1591 "Ignore MTU mismatch on this interface\n"
1594 struct ospf6_interface
*oi
;
1595 struct interface
*ifp
;
1597 ifp
= (struct interface
*) vty
->index
;
1600 oi
= (struct ospf6_interface
*) ifp
->info
;
1602 oi
= ospf6_interface_create (ifp
);
1610 DEFUN (no_ipv6_ospf6_mtu_ignore
,
1611 no_ipv6_ospf6_mtu_ignore_cmd
,
1612 "no ipv6 ospf6 mtu-ignore",
1616 "Ignore MTU mismatch on this interface\n"
1619 struct ospf6_interface
*oi
;
1620 struct interface
*ifp
;
1622 ifp
= (struct interface
*) vty
->index
;
1625 oi
= (struct ospf6_interface
*) ifp
->info
;
1627 oi
= ospf6_interface_create (ifp
);
1635 DEFUN (ipv6_ospf6_advertise_prefix_list
,
1636 ipv6_ospf6_advertise_prefix_list_cmd
,
1637 "ipv6 ospf6 advertise prefix-list WORD",
1640 "Advertising options\n"
1641 "Filter prefix using prefix-list\n"
1642 "Prefix list name\n"
1645 struct ospf6_interface
*oi
;
1646 struct interface
*ifp
;
1648 ifp
= (struct interface
*) vty
->index
;
1651 oi
= (struct ospf6_interface
*) ifp
->info
;
1653 oi
= ospf6_interface_create (ifp
);
1657 XFREE (MTYPE_PREFIX_LIST_STR
, oi
->plist_name
);
1658 oi
->plist_name
= XSTRDUP (MTYPE_PREFIX_LIST_STR
, argv
[0]);
1660 ospf6_interface_connected_route_update (oi
->interface
);
1664 OSPF6_LINK_LSA_SCHEDULE (oi
);
1665 if (oi
->state
== OSPF6_INTERFACE_DR
)
1667 OSPF6_NETWORK_LSA_SCHEDULE (oi
);
1668 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi
);
1670 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi
->area
);
1676 DEFUN (no_ipv6_ospf6_advertise_prefix_list
,
1677 no_ipv6_ospf6_advertise_prefix_list_cmd
,
1678 "no ipv6 ospf6 advertise prefix-list",
1682 "Advertising options\n"
1683 "Filter prefix using prefix-list\n"
1686 struct ospf6_interface
*oi
;
1687 struct interface
*ifp
;
1689 ifp
= (struct interface
*) vty
->index
;
1692 oi
= (struct ospf6_interface
*) ifp
->info
;
1694 oi
= ospf6_interface_create (ifp
);
1699 XFREE (MTYPE_PREFIX_LIST_STR
, oi
->plist_name
);
1700 oi
->plist_name
= NULL
;
1703 ospf6_interface_connected_route_update (oi
->interface
);
1707 OSPF6_LINK_LSA_SCHEDULE (oi
);
1708 if (oi
->state
== OSPF6_INTERFACE_DR
)
1710 OSPF6_NETWORK_LSA_SCHEDULE (oi
);
1711 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi
);
1713 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi
->area
);
1719 DEFUN (ipv6_ospf6_network
,
1720 ipv6_ospf6_network_cmd
,
1721 "ipv6 ospf6 network (broadcast|point-to-point)",
1725 "Specify OSPFv6 broadcast network\n"
1726 "Specify OSPF6 point-to-point network\n"
1729 struct ospf6_interface
*oi
;
1730 struct interface
*ifp
;
1732 ifp
= (struct interface
*) vty
->index
;
1735 oi
= (struct ospf6_interface
*) ifp
->info
;
1737 oi
= ospf6_interface_create (ifp
);
1741 if (strncmp (argv
[0], "b", 1) == 0)
1743 if (oi
->type
== OSPF_IFTYPE_BROADCAST
)
1746 oi
->type
= OSPF_IFTYPE_BROADCAST
;
1748 else if (strncmp (argv
[0], "point-to-p", 10) == 0)
1750 if (oi
->type
== OSPF_IFTYPE_POINTOPOINT
) {
1753 oi
->type
= OSPF_IFTYPE_POINTOPOINT
;
1756 /* Reset the interface */
1757 thread_add_event (master
, interface_down
, oi
, 0);
1758 thread_add_event (master
, interface_up
, oi
, 0);
1763 DEFUN (no_ipv6_ospf6_network
,
1764 no_ipv6_ospf6_network_cmd
,
1765 "no ipv6 ospf6 network",
1770 "Default to whatever interface type system specifies"
1773 struct ospf6_interface
*oi
;
1774 struct interface
*ifp
;
1777 ifp
= (struct interface
*) vty
->index
;
1780 oi
= (struct ospf6_interface
*) ifp
->info
;
1785 type
= ospf6_default_iftype (ifp
);
1786 if (oi
->type
== type
)
1792 /* Reset the interface */
1793 thread_add_event (master
, interface_down
, oi
, 0);
1794 thread_add_event (master
, interface_up
, oi
, 0);
1800 config_write_ospf6_interface (struct vty
*vty
)
1803 struct ospf6_interface
*oi
;
1804 struct interface
*ifp
;
1806 for (ALL_LIST_ELEMENTS_RO (iflist
, i
, ifp
))
1808 oi
= (struct ospf6_interface
*) ifp
->info
;
1812 vty_out (vty
, "interface %s%s",
1813 oi
->interface
->name
, VNL
);
1816 vty_out (vty
, " description %s%s", ifp
->desc
, VNL
);
1817 if (ifp
->mtu6
!= oi
->ifmtu
)
1818 vty_out (vty
, " ipv6 ospf6 ifmtu %d%s", oi
->ifmtu
, VNL
);
1820 if (CHECK_FLAG (oi
->flag
, OSPF6_INTERFACE_NOAUTOCOST
))
1821 vty_out (vty
, " ipv6 ospf6 cost %d%s",
1824 if (oi
->hello_interval
!= OSPF6_INTERFACE_HELLO_INTERVAL
)
1825 vty_out (vty
, " ipv6 ospf6 hello-interval %d%s",
1826 oi
->hello_interval
, VNL
);
1828 if (oi
->dead_interval
!= OSPF6_INTERFACE_DEAD_INTERVAL
)
1829 vty_out (vty
, " ipv6 ospf6 dead-interval %d%s",
1830 oi
->dead_interval
, VNL
);
1832 if (oi
->rxmt_interval
!= OSPF6_INTERFACE_RXMT_INTERVAL
)
1833 vty_out (vty
, " ipv6 ospf6 retransmit-interval %d%s",
1834 oi
->rxmt_interval
, VNL
);
1836 if (oi
->priority
!= OSPF6_INTERFACE_PRIORITY
)
1837 vty_out (vty
, " ipv6 ospf6 priority %d%s",
1840 if (oi
->transdelay
!= OSPF6_INTERFACE_TRANSDELAY
)
1841 vty_out (vty
, " ipv6 ospf6 transmit-delay %d%s",
1842 oi
->transdelay
, VNL
);
1844 if (oi
->instance_id
!= OSPF6_INTERFACE_INSTANCE_ID
)
1845 vty_out (vty
, " ipv6 ospf6 instance-id %d%s",
1846 oi
->instance_id
, VNL
);
1849 vty_out (vty
, " ipv6 ospf6 advertise prefix-list %s%s",
1850 oi
->plist_name
, VNL
);
1852 if (CHECK_FLAG (oi
->flag
, OSPF6_INTERFACE_PASSIVE
))
1853 vty_out (vty
, " ipv6 ospf6 passive%s", VNL
);
1856 vty_out (vty
, " ipv6 ospf6 mtu-ignore%s", VNL
);
1858 if (oi
->type
== OSPF_IFTYPE_POINTOPOINT
)
1859 vty_out (vty
, " ipv6 ospf6 network point-to-point%s", VNL
);
1860 else if (oi
->type
== OSPF_IFTYPE_BROADCAST
)
1861 vty_out (vty
, " ipv6 ospf6 network broadcast%s", VNL
);
1863 vty_out (vty
, "!%s", VNL
);
1868 static struct cmd_node interface_node
=
1876 ospf6_interface_init (void)
1878 /* Install interface node. */
1879 install_node (&interface_node
, config_write_ospf6_interface
);
1881 install_element (VIEW_NODE
, &show_ipv6_ospf6_interface_cmd
);
1882 install_element (VIEW_NODE
, &show_ipv6_ospf6_interface_prefix_cmd
);
1883 install_element (VIEW_NODE
, &show_ipv6_ospf6_interface_prefix_detail_cmd
);
1884 install_element (VIEW_NODE
, &show_ipv6_ospf6_interface_prefix_match_cmd
);
1885 install_element (VIEW_NODE
, &show_ipv6_ospf6_interface_ifname_cmd
);
1886 install_element (VIEW_NODE
, &show_ipv6_ospf6_interface_ifname_prefix_cmd
);
1887 install_element (VIEW_NODE
, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd
);
1888 install_element (VIEW_NODE
, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd
);
1889 install_element (ENABLE_NODE
, &show_ipv6_ospf6_interface_cmd
);
1890 install_element (ENABLE_NODE
, &show_ipv6_ospf6_interface_prefix_cmd
);
1891 install_element (ENABLE_NODE
, &show_ipv6_ospf6_interface_prefix_detail_cmd
);
1892 install_element (ENABLE_NODE
, &show_ipv6_ospf6_interface_prefix_match_cmd
);
1893 install_element (ENABLE_NODE
, &show_ipv6_ospf6_interface_ifname_cmd
);
1894 install_element (ENABLE_NODE
, &show_ipv6_ospf6_interface_ifname_prefix_cmd
);
1895 install_element (ENABLE_NODE
, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd
);
1896 install_element (ENABLE_NODE
, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd
);
1898 install_element (CONFIG_NODE
, &interface_cmd
);
1899 install_default (INTERFACE_NODE
);
1900 install_element (INTERFACE_NODE
, &interface_desc_cmd
);
1901 install_element (INTERFACE_NODE
, &no_interface_desc_cmd
);
1902 install_element (INTERFACE_NODE
, &ipv6_ospf6_cost_cmd
);
1903 install_element (INTERFACE_NODE
, &no_ipv6_ospf6_cost_cmd
);
1904 install_element (INTERFACE_NODE
, &ipv6_ospf6_ifmtu_cmd
);
1905 install_element (INTERFACE_NODE
, &no_ipv6_ospf6_ifmtu_cmd
);
1906 install_element (INTERFACE_NODE
, &ipv6_ospf6_deadinterval_cmd
);
1907 install_element (INTERFACE_NODE
, &ipv6_ospf6_hellointerval_cmd
);
1908 install_element (INTERFACE_NODE
, &ipv6_ospf6_priority_cmd
);
1909 install_element (INTERFACE_NODE
, &ipv6_ospf6_retransmitinterval_cmd
);
1910 install_element (INTERFACE_NODE
, &ipv6_ospf6_transmitdelay_cmd
);
1911 install_element (INTERFACE_NODE
, &ipv6_ospf6_instance_cmd
);
1913 install_element (INTERFACE_NODE
, &ipv6_ospf6_passive_cmd
);
1914 install_element (INTERFACE_NODE
, &no_ipv6_ospf6_passive_cmd
);
1916 install_element (INTERFACE_NODE
, &ipv6_ospf6_mtu_ignore_cmd
);
1917 install_element (INTERFACE_NODE
, &no_ipv6_ospf6_mtu_ignore_cmd
);
1919 install_element (INTERFACE_NODE
, &ipv6_ospf6_advertise_prefix_list_cmd
);
1920 install_element (INTERFACE_NODE
, &no_ipv6_ospf6_advertise_prefix_list_cmd
);
1922 install_element (INTERFACE_NODE
, &ipv6_ospf6_network_cmd
);
1923 install_element (INTERFACE_NODE
, &no_ipv6_ospf6_network_cmd
);
1925 /* reference bandwidth commands */
1926 install_element (OSPF6_NODE
, &auto_cost_reference_bandwidth_cmd
);
1927 install_element (OSPF6_NODE
, &no_auto_cost_reference_bandwidth_cmd
);
1930 /* Clear the specified interface structure */
1932 ospf6_interface_clear (struct vty
*vty
, struct interface
*ifp
)
1934 struct ospf6_interface
*oi
;
1936 if (!if_is_operative (ifp
))
1939 if (ifp
->info
== NULL
)
1942 oi
= (struct ospf6_interface
*) ifp
->info
;
1944 if (IS_OSPF6_DEBUG_INTERFACE
)
1945 zlog_debug ("Interface %s: clear by reset", ifp
->name
);
1947 /* Reset the interface */
1948 thread_add_event (master
, interface_down
, oi
, 0);
1949 thread_add_event (master
, interface_up
, oi
, 0);
1952 /* Clear interface */
1953 DEFUN (clear_ipv6_ospf6_interface
,
1954 clear_ipv6_ospf6_interface_cmd
,
1955 "clear ipv6 ospf6 interface [IFNAME]",
1963 struct interface
*ifp
;
1964 struct listnode
*node
;
1966 if (argc
== 0) /* Clear all the ospfv3 interfaces. */
1968 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
1969 ospf6_interface_clear (vty
, ifp
);
1971 else /* Interface name is specified. */
1973 if ((ifp
= if_lookup_by_name (argv
[0])) == NULL
)
1975 vty_out (vty
, "No such Interface: %s%s", argv
[0], VNL
);
1978 ospf6_interface_clear (vty
, ifp
);
1985 install_element_ospf6_clear_interface (void)
1987 install_element (ENABLE_NODE
, &clear_ipv6_ospf6_interface_cmd
);
1990 DEFUN (debug_ospf6_interface
,
1991 debug_ospf6_interface_cmd
,
1992 "debug ospf6 interface",
1995 "Debug OSPFv3 Interface\n"
1998 OSPF6_DEBUG_INTERFACE_ON ();
2002 DEFUN (no_debug_ospf6_interface
,
2003 no_debug_ospf6_interface_cmd
,
2004 "no debug ospf6 interface",
2008 "Debug OSPFv3 Interface\n"
2011 OSPF6_DEBUG_INTERFACE_OFF ();
2016 config_write_ospf6_debug_interface (struct vty
*vty
)
2018 if (IS_OSPF6_DEBUG_INTERFACE
)
2019 vty_out (vty
, "debug ospf6 interface%s", VNL
);
2024 install_element_ospf6_debug_interface (void)
2026 install_element (ENABLE_NODE
, &debug_ospf6_interface_cmd
);
2027 install_element (ENABLE_NODE
, &no_debug_ospf6_interface_cmd
);
2028 install_element (CONFIG_NODE
, &debug_ospf6_interface_cmd
);
2029 install_element (CONFIG_NODE
, &no_debug_ospf6_interface_cmd
);