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")
49 DEFINE_QOBJ_TYPE(ospf6_interface
)
51 unsigned char conf_debug_ospf6_interface
= 0;
53 const char *ospf6_interface_state_str
[] =
66 struct ospf6_interface
*
67 ospf6_interface_lookup_by_ifindex (ifindex_t ifindex
)
69 struct ospf6_interface
*oi
;
70 struct interface
*ifp
;
72 ifp
= if_lookup_by_index (ifindex
);
74 return (struct ospf6_interface
*) NULL
;
76 oi
= (struct ospf6_interface
*) ifp
->info
;
80 /* schedule routing table recalculation */
82 ospf6_interface_lsdb_hook (struct ospf6_lsa
*lsa
, unsigned int reason
)
84 struct ospf6_interface
*oi
;
90 switch (ntohs (lsa
->header
->type
))
92 case OSPF6_LSTYPE_LINK
:
93 if (oi
->state
== OSPF6_INTERFACE_DR
)
94 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi
);
96 ospf6_spf_schedule (oi
->area
->ospf6
, reason
);
105 ospf6_interface_lsdb_hook_add (struct ospf6_lsa
*lsa
)
107 ospf6_interface_lsdb_hook(lsa
, ospf6_lsadd_to_spf_reason(lsa
));
111 ospf6_interface_lsdb_hook_remove (struct ospf6_lsa
*lsa
)
113 ospf6_interface_lsdb_hook(lsa
, ospf6_lsremove_to_spf_reason(lsa
));
117 ospf6_default_iftype(struct interface
*ifp
)
119 if (if_is_pointopoint (ifp
))
120 return OSPF_IFTYPE_POINTOPOINT
;
121 else if (if_is_loopback (ifp
))
122 return OSPF_IFTYPE_LOOPBACK
;
124 return OSPF_IFTYPE_BROADCAST
;
128 ospf6_interface_get_cost (struct ospf6_interface
*oi
)
130 /* If all else fails, use default OSPF cost */
134 bw
= oi
->interface
->bandwidth
? oi
->interface
->bandwidth
: OSPF6_INTERFACE_BANDWIDTH
;
135 refbw
= ospf6
? ospf6
->ref_bandwidth
: OSPF6_REFERENCE_BANDWIDTH
;
137 /* A specifed ip ospf cost overrides a calculated one. */
138 if (CHECK_FLAG (oi
->flag
, OSPF6_INTERFACE_NOAUTOCOST
))
142 cost
= (u_int32_t
) ((double)refbw
/ (double)bw
+ (double)0.5);
143 if (cost
< 1) cost
= 1;
144 else if (cost
> UINT32_MAX
) cost
= UINT32_MAX
;
151 ospf6_interface_recalculate_cost (struct ospf6_interface
*oi
)
155 newcost
= ospf6_interface_get_cost (oi
);
156 if (newcost
== oi
->cost
) return;
159 /* update cost held in route_connected list in ospf6_interface */
160 ospf6_interface_connected_route_update (oi
->interface
);
162 /* execute LSA hooks */
165 OSPF6_LINK_LSA_SCHEDULE (oi
);
166 OSPF6_ROUTER_LSA_SCHEDULE (oi
->area
);
167 OSPF6_NETWORK_LSA_SCHEDULE (oi
);
168 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi
);
169 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi
->area
);
173 /* Create new ospf6 interface structure */
174 struct ospf6_interface
*
175 ospf6_interface_create (struct interface
*ifp
)
177 struct ospf6_interface
*oi
;
178 unsigned int iobuflen
;
180 oi
= (struct ospf6_interface
*)
181 XCALLOC (MTYPE_OSPF6_IF
, sizeof (struct ospf6_interface
));
185 zlog_err ("Can't malloc ospf6_interface for ifindex %d", ifp
->ifindex
);
186 return (struct ospf6_interface
*) NULL
;
189 oi
->area
= (struct ospf6_area
*) NULL
;
190 oi
->neighbor_list
= list_new ();
191 oi
->neighbor_list
->cmp
= ospf6_neighbor_cmp
;
192 oi
->linklocal_addr
= (struct in6_addr
*) NULL
;
193 oi
->instance_id
= OSPF6_INTERFACE_INSTANCE_ID
;
194 oi
->transdelay
= OSPF6_INTERFACE_TRANSDELAY
;
195 oi
->priority
= OSPF6_INTERFACE_PRIORITY
;
197 oi
->hello_interval
= OSPF_HELLO_INTERVAL_DEFAULT
;
198 oi
->dead_interval
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
199 oi
->rxmt_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
200 oi
->type
= ospf6_default_iftype (ifp
);
201 oi
->state
= OSPF6_INTERFACE_DOWN
;
205 /* Try to adjust I/O buffer size with IfMtu */
206 oi
->ifmtu
= ifp
->mtu6
;
207 iobuflen
= ospf6_iobuf_size (ifp
->mtu6
);
208 if (oi
->ifmtu
> iobuflen
)
210 if (IS_OSPF6_DEBUG_INTERFACE
)
211 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
212 ifp
->name
, iobuflen
);
213 oi
->ifmtu
= iobuflen
;
216 QOBJ_REG (oi
, ospf6_interface
);
218 oi
->lsupdate_list
= ospf6_lsdb_create (oi
);
219 oi
->lsack_list
= ospf6_lsdb_create (oi
);
220 oi
->lsdb
= ospf6_lsdb_create (oi
);
221 oi
->lsdb
->hook_add
= ospf6_interface_lsdb_hook_add
;
222 oi
->lsdb
->hook_remove
= ospf6_interface_lsdb_hook_remove
;
223 oi
->lsdb_self
= ospf6_lsdb_create (oi
);
225 oi
->route_connected
= OSPF6_ROUTE_TABLE_CREATE (INTERFACE
, CONNECTED_ROUTES
);
226 oi
->route_connected
->scope
= oi
;
233 oi
->cost
= ospf6_interface_get_cost(oi
);
239 ospf6_interface_delete (struct ospf6_interface
*oi
)
241 struct listnode
*node
, *nnode
;
242 struct ospf6_neighbor
*on
;
246 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
247 ospf6_neighbor_delete (on
);
249 list_delete (oi
->neighbor_list
);
251 THREAD_OFF (oi
->thread_send_hello
);
252 THREAD_OFF (oi
->thread_send_lsupdate
);
253 THREAD_OFF (oi
->thread_send_lsack
);
255 ospf6_lsdb_remove_all (oi
->lsdb
);
256 ospf6_lsdb_remove_all (oi
->lsupdate_list
);
257 ospf6_lsdb_remove_all (oi
->lsack_list
);
259 ospf6_lsdb_delete (oi
->lsdb
);
260 ospf6_lsdb_delete (oi
->lsdb_self
);
262 ospf6_lsdb_delete (oi
->lsupdate_list
);
263 ospf6_lsdb_delete (oi
->lsack_list
);
265 ospf6_route_table_delete (oi
->route_connected
);
268 oi
->interface
->info
= NULL
;
272 XFREE (MTYPE_CFG_PLIST_NAME
, oi
->plist_name
);
274 ospf6_bfd_info_free(&(oi
->bfd_info
));
276 XFREE (MTYPE_OSPF6_IF
, oi
);
280 ospf6_interface_enable (struct ospf6_interface
*oi
)
282 UNSET_FLAG (oi
->flag
, OSPF6_INTERFACE_DISABLE
);
283 ospf6_interface_state_update (oi
->interface
);
287 ospf6_interface_disable (struct ospf6_interface
*oi
)
289 SET_FLAG (oi
->flag
, OSPF6_INTERFACE_DISABLE
);
291 thread_execute (master
, interface_down
, oi
, 0);
293 ospf6_lsdb_remove_all (oi
->lsdb
);
294 ospf6_lsdb_remove_all (oi
->lsdb_self
);
295 ospf6_lsdb_remove_all (oi
->lsupdate_list
);
296 ospf6_lsdb_remove_all (oi
->lsack_list
);
298 THREAD_OFF (oi
->thread_send_hello
);
299 THREAD_OFF (oi
->thread_send_lsupdate
);
300 THREAD_OFF (oi
->thread_send_lsack
);
302 THREAD_OFF (oi
->thread_network_lsa
);
303 THREAD_OFF (oi
->thread_link_lsa
);
304 THREAD_OFF (oi
->thread_intra_prefix_lsa
);
307 static struct in6_addr
*
308 ospf6_interface_get_linklocal_address (struct interface
*ifp
)
312 struct in6_addr
*l
= (struct in6_addr
*) NULL
;
314 /* for each connected address */
315 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, n
, c
))
317 /* if family not AF_INET6, ignore */
318 if (c
->address
->family
!= AF_INET6
)
321 /* linklocal scope check */
322 if (IN6_IS_ADDR_LINKLOCAL (&c
->address
->u
.prefix6
))
323 l
= &c
->address
->u
.prefix6
;
329 ospf6_interface_if_add (struct interface
*ifp
)
331 struct ospf6_interface
*oi
;
332 unsigned int iobuflen
;
334 oi
= (struct ospf6_interface
*) ifp
->info
;
338 /* Try to adjust I/O buffer size with IfMtu */
340 oi
->ifmtu
= ifp
->mtu6
;
341 iobuflen
= ospf6_iobuf_size (ifp
->mtu6
);
342 if (oi
->ifmtu
> iobuflen
)
344 if (IS_OSPF6_DEBUG_INTERFACE
)
345 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
346 ifp
->name
, iobuflen
);
347 oi
->ifmtu
= iobuflen
;
350 /* interface start */
351 ospf6_interface_state_update(oi
->interface
);
355 ospf6_interface_if_del (struct interface
*ifp
)
357 struct ospf6_interface
*oi
;
359 oi
= (struct ospf6_interface
*) ifp
->info
;
365 thread_execute (master
, interface_down
, oi
, 0);
367 listnode_delete (oi
->area
->if_list
, oi
);
368 oi
->area
= (struct ospf6_area
*) NULL
;
371 oi
->interface
= NULL
;
374 ospf6_interface_delete (oi
);
378 ospf6_interface_state_update (struct interface
*ifp
)
380 struct ospf6_interface
*oi
;
382 oi
= (struct ospf6_interface
*) ifp
->info
;
385 if (oi
->area
== NULL
)
387 if (CHECK_FLAG (oi
->flag
, OSPF6_INTERFACE_DISABLE
))
390 if (if_is_operative (ifp
)
391 && (ospf6_interface_get_linklocal_address(oi
->interface
)
392 || if_is_loopback(oi
->interface
)))
393 thread_add_event (master
, interface_up
, oi
, 0);
395 thread_add_event (master
, interface_down
, oi
, 0);
401 ospf6_interface_connected_route_update (struct interface
*ifp
)
403 struct ospf6_interface
*oi
;
404 struct ospf6_route
*route
;
406 struct listnode
*node
, *nnode
;
407 struct in6_addr nh_addr
;
409 oi
= (struct ospf6_interface
*) ifp
->info
;
413 /* reset linklocal pointer */
414 oi
->linklocal_addr
= ospf6_interface_get_linklocal_address (ifp
);
416 /* if area is null, do not make connected-route list */
417 if (oi
->area
== NULL
)
420 if (CHECK_FLAG (oi
->flag
, OSPF6_INTERFACE_DISABLE
))
423 /* update "route to advertise" interface route table */
424 ospf6_route_remove_all (oi
->route_connected
);
426 for (ALL_LIST_ELEMENTS (oi
->interface
->connected
, node
, nnode
, c
))
428 if (c
->address
->family
!= AF_INET6
)
431 CONTINUE_IF_ADDRESS_LINKLOCAL (IS_OSPF6_DEBUG_INTERFACE
, c
->address
);
432 CONTINUE_IF_ADDRESS_UNSPECIFIED (IS_OSPF6_DEBUG_INTERFACE
, c
->address
);
433 CONTINUE_IF_ADDRESS_LOOPBACK (IS_OSPF6_DEBUG_INTERFACE
, c
->address
);
434 CONTINUE_IF_ADDRESS_V4COMPAT (IS_OSPF6_DEBUG_INTERFACE
, c
->address
);
435 CONTINUE_IF_ADDRESS_V4MAPPED (IS_OSPF6_DEBUG_INTERFACE
, c
->address
);
440 struct prefix_list
*plist
;
441 enum prefix_list_type ret
;
442 char buf
[PREFIX2STR_BUFFER
];
444 prefix2str (c
->address
, buf
, sizeof (buf
));
445 plist
= prefix_list_lookup (AFI_IP6
, oi
->plist_name
);
446 ret
= prefix_list_apply (plist
, (void *) c
->address
);
447 if (ret
== PREFIX_DENY
)
449 if (IS_OSPF6_DEBUG_INTERFACE
)
450 zlog_debug ("%s on %s filtered by prefix-list %s ",
451 buf
, oi
->interface
->name
, oi
->plist_name
);
456 route
= ospf6_route_create ();
457 memcpy (&route
->prefix
, c
->address
, sizeof (struct prefix
));
458 apply_mask (&route
->prefix
);
459 route
->type
= OSPF6_DEST_TYPE_NETWORK
;
460 route
->path
.area_id
= oi
->area
->area_id
;
461 route
->path
.type
= OSPF6_PATH_TYPE_INTRA
;
462 route
->path
.cost
= oi
->cost
;
463 inet_pton (AF_INET6
, "::1", &nh_addr
);
464 ospf6_route_add_nexthop (route
, oi
->interface
->ifindex
, &nh_addr
);
465 ospf6_route_add (route
, oi
->route_connected
);
468 /* create new Link-LSA */
469 OSPF6_LINK_LSA_SCHEDULE (oi
);
470 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi
);
471 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi
->area
);
475 ospf6_interface_state_change (u_char next_state
, struct ospf6_interface
*oi
)
479 prev_state
= oi
->state
;
480 oi
->state
= next_state
;
482 if (prev_state
== next_state
)
486 if (IS_OSPF6_DEBUG_INTERFACE
)
488 zlog_debug ("Interface state change %s: %s -> %s", oi
->interface
->name
,
489 ospf6_interface_state_str
[prev_state
],
490 ospf6_interface_state_str
[next_state
]);
494 if ((prev_state
== OSPF6_INTERFACE_DR
||
495 prev_state
== OSPF6_INTERFACE_BDR
) &&
496 (next_state
!= OSPF6_INTERFACE_DR
&&
497 next_state
!= OSPF6_INTERFACE_BDR
))
498 ospf6_sso (oi
->interface
->ifindex
, &alldrouters6
, IPV6_LEAVE_GROUP
);
500 if ((prev_state
!= OSPF6_INTERFACE_DR
&&
501 prev_state
!= OSPF6_INTERFACE_BDR
) &&
502 (next_state
== OSPF6_INTERFACE_DR
||
503 next_state
== OSPF6_INTERFACE_BDR
))
504 ospf6_sso (oi
->interface
->ifindex
, &alldrouters6
, IPV6_JOIN_GROUP
);
506 OSPF6_ROUTER_LSA_SCHEDULE (oi
->area
);
507 if (next_state
== OSPF6_INTERFACE_DOWN
)
509 OSPF6_NETWORK_LSA_EXECUTE (oi
);
510 OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT (oi
);
511 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi
->area
);
513 else if (prev_state
== OSPF6_INTERFACE_DR
||
514 next_state
== OSPF6_INTERFACE_DR
)
516 OSPF6_NETWORK_LSA_SCHEDULE (oi
);
517 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi
);
518 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi
->area
);
522 /* Terminal state or regression */
523 if ((next_state
== OSPF6_INTERFACE_POINTTOPOINT
) ||
524 (next_state
== OSPF6_INTERFACE_DROTHER
) ||
525 (next_state
== OSPF6_INTERFACE_BDR
) ||
526 (next_state
== OSPF6_INTERFACE_DR
) ||
527 (next_state
< prev_state
))
528 ospf6TrapIfStateChange (oi
);
534 /* DR Election, RFC2328 section 9.4 */
536 #define IS_ELIGIBLE(n) \
537 ((n)->state >= OSPF6_NEIGHBOR_TWOWAY && (n)->priority != 0)
539 static struct ospf6_neighbor
*
540 better_bdrouter (struct ospf6_neighbor
*a
, struct ospf6_neighbor
*b
)
542 if ((a
== NULL
|| ! IS_ELIGIBLE (a
) || a
->drouter
== a
->router_id
) &&
543 (b
== NULL
|| ! IS_ELIGIBLE (b
) || b
->drouter
== b
->router_id
))
545 else if (a
== NULL
|| ! IS_ELIGIBLE (a
) || a
->drouter
== a
->router_id
)
547 else if (b
== NULL
|| ! IS_ELIGIBLE (b
) || b
->drouter
== b
->router_id
)
550 if (a
->bdrouter
== a
->router_id
&& b
->bdrouter
!= b
->router_id
)
552 if (a
->bdrouter
!= a
->router_id
&& b
->bdrouter
== b
->router_id
)
555 if (a
->priority
> b
->priority
)
557 if (a
->priority
< b
->priority
)
560 if (ntohl (a
->router_id
) > ntohl (b
->router_id
))
562 if (ntohl (a
->router_id
) < ntohl (b
->router_id
))
565 zlog_warn ("Router-ID duplicate ?");
569 static struct ospf6_neighbor
*
570 better_drouter (struct ospf6_neighbor
*a
, struct ospf6_neighbor
*b
)
572 if ((a
== NULL
|| ! IS_ELIGIBLE (a
) || a
->drouter
!= a
->router_id
) &&
573 (b
== NULL
|| ! IS_ELIGIBLE (b
) || b
->drouter
!= b
->router_id
))
575 else if (a
== NULL
|| ! IS_ELIGIBLE (a
) || a
->drouter
!= a
->router_id
)
577 else if (b
== NULL
|| ! IS_ELIGIBLE (b
) || b
->drouter
!= b
->router_id
)
580 if (a
->drouter
== a
->router_id
&& b
->drouter
!= b
->router_id
)
582 if (a
->drouter
!= a
->router_id
&& b
->drouter
== b
->router_id
)
585 if (a
->priority
> b
->priority
)
587 if (a
->priority
< b
->priority
)
590 if (ntohl (a
->router_id
) > ntohl (b
->router_id
))
592 if (ntohl (a
->router_id
) < ntohl (b
->router_id
))
595 zlog_warn ("Router-ID duplicate ?");
600 dr_election (struct ospf6_interface
*oi
)
602 struct listnode
*node
, *nnode
;
603 struct ospf6_neighbor
*on
, *drouter
, *bdrouter
, myself
;
604 struct ospf6_neighbor
*best_drouter
, *best_bdrouter
;
605 u_char next_state
= 0;
607 drouter
= bdrouter
= NULL
;
608 best_drouter
= best_bdrouter
= NULL
;
610 /* pseudo neighbor myself, including noting current DR/BDR (1) */
611 memset (&myself
, 0, sizeof (myself
));
612 inet_ntop (AF_INET
, &oi
->area
->ospf6
->router_id
, myself
.name
,
613 sizeof (myself
.name
));
614 myself
.state
= OSPF6_NEIGHBOR_TWOWAY
;
615 myself
.drouter
= oi
->drouter
;
616 myself
.bdrouter
= oi
->bdrouter
;
617 myself
.priority
= oi
->priority
;
618 myself
.router_id
= oi
->area
->ospf6
->router_id
;
620 /* Electing BDR (2) */
621 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
622 bdrouter
= better_bdrouter (bdrouter
, on
);
624 best_bdrouter
= bdrouter
;
625 bdrouter
= better_bdrouter (best_bdrouter
, &myself
);
627 /* Electing DR (3) */
628 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
629 drouter
= better_drouter (drouter
, on
);
631 best_drouter
= drouter
;
632 drouter
= better_drouter (best_drouter
, &myself
);
636 /* the router itself is newly/no longer DR/BDR (4) */
637 if ((drouter
== &myself
&& myself
.drouter
!= myself
.router_id
) ||
638 (drouter
!= &myself
&& myself
.drouter
== myself
.router_id
) ||
639 (bdrouter
== &myself
&& myself
.bdrouter
!= myself
.router_id
) ||
640 (bdrouter
!= &myself
&& myself
.bdrouter
== myself
.router_id
))
642 myself
.drouter
= (drouter
? drouter
->router_id
: htonl (0));
643 myself
.bdrouter
= (bdrouter
? bdrouter
->router_id
: htonl (0));
645 /* compatible to Electing BDR (2) */
646 bdrouter
= better_bdrouter (best_bdrouter
, &myself
);
648 /* compatible to Electing DR (3) */
649 drouter
= better_drouter (best_drouter
, &myself
);
654 /* Set interface state accordingly (5) */
655 if (drouter
&& drouter
== &myself
)
656 next_state
= OSPF6_INTERFACE_DR
;
657 else if (bdrouter
&& bdrouter
== &myself
)
658 next_state
= OSPF6_INTERFACE_BDR
;
660 next_state
= OSPF6_INTERFACE_DROTHER
;
662 /* If NBMA, schedule Start for each neighbor having priority of 0 (6) */
665 /* If DR or BDR change, invoke AdjOK? for each neighbor (7) */
666 /* RFC 2328 section 12.4. Originating LSAs (3) will be handled
667 accordingly after AdjOK */
668 if (oi
->drouter
!= (drouter
? drouter
->router_id
: htonl (0)) ||
669 oi
->bdrouter
!= (bdrouter
? bdrouter
->router_id
: htonl (0)))
671 if (IS_OSPF6_DEBUG_INTERFACE
)
672 zlog_debug ("DR Election on %s: DR: %s BDR: %s", oi
->interface
->name
,
673 (drouter
? drouter
->name
: "0.0.0.0"),
674 (bdrouter
? bdrouter
->name
: "0.0.0.0"));
676 for (ALL_LIST_ELEMENTS_RO (oi
->neighbor_list
, node
, on
))
678 if (on
->state
< OSPF6_NEIGHBOR_TWOWAY
)
680 /* Schedule AdjOK. */
681 thread_add_event (master
, adj_ok
, on
, 0);
685 oi
->drouter
= (drouter
? drouter
->router_id
: htonl (0));
686 oi
->bdrouter
= (bdrouter
? bdrouter
->router_id
: htonl (0));
691 /* Interface State Machine */
693 interface_up (struct thread
*thread
)
695 struct ospf6_interface
*oi
;
697 oi
= (struct ospf6_interface
*) THREAD_ARG (thread
);
698 assert (oi
&& oi
->interface
);
700 if (IS_OSPF6_DEBUG_INTERFACE
)
701 zlog_debug ("Interface Event %s: [InterfaceUp]",
702 oi
->interface
->name
);
704 /* check physical interface is up */
705 if (! if_is_operative (oi
->interface
))
707 if (IS_OSPF6_DEBUG_INTERFACE
)
708 zlog_debug ("Interface %s is down, can't execute [InterfaceUp]",
709 oi
->interface
->name
);
713 /* check interface has a link-local address */
714 if (! (ospf6_interface_get_linklocal_address(oi
->interface
)
715 || if_is_loopback(oi
->interface
)))
717 if (IS_OSPF6_DEBUG_INTERFACE
)
718 zlog_debug ("Interface %s has no link local address, can't execute [InterfaceUp]",
719 oi
->interface
->name
);
724 ospf6_interface_recalculate_cost (oi
);
726 /* if already enabled, do nothing */
727 if (oi
->state
> OSPF6_INTERFACE_DOWN
)
729 if (IS_OSPF6_DEBUG_INTERFACE
)
730 zlog_debug ("Interface %s already enabled",
731 oi
->interface
->name
);
735 /* If no area assigned, return */
736 if (oi
->area
== NULL
)
738 zlog_debug ("%s: Not scheduleing Hello for %s as there is no area assigned yet", __func__
,
739 oi
->interface
->name
);
743 /* Join AllSPFRouters */
744 if (ospf6_sso (oi
->interface
->ifindex
, &allspfrouters6
, IPV6_JOIN_GROUP
) < 0)
746 if (oi
->sso_try_cnt
++ < OSPF6_INTERFACE_SSO_RETRY_MAX
)
748 zlog_info("Scheduling %s for sso retry, trial count: %d",
749 oi
->interface
->name
, oi
->sso_try_cnt
);
750 thread_add_timer (master
, interface_up
, oi
,
751 OSPF6_INTERFACE_SSO_RETRY_INT
);
755 oi
->sso_try_cnt
= 0; /* Reset on success */
757 /* Update interface route */
758 ospf6_interface_connected_route_update (oi
->interface
);
761 if (! CHECK_FLAG (oi
->flag
, OSPF6_INTERFACE_PASSIVE
) &&
762 !if_is_loopback (oi
->interface
))
763 oi
->thread_send_hello
= thread_add_event (master
, ospf6_hello_send
, oi
, 0);
765 /* decide next interface state */
766 if ((if_is_pointopoint (oi
->interface
)) ||
767 (oi
->type
== OSPF_IFTYPE_POINTOPOINT
)) {
768 ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT
, oi
);
770 else if (oi
->priority
== 0)
771 ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER
, oi
);
774 ospf6_interface_state_change (OSPF6_INTERFACE_WAITING
, oi
);
775 thread_add_timer (master
, wait_timer
, oi
, oi
->dead_interval
);
782 wait_timer (struct thread
*thread
)
784 struct ospf6_interface
*oi
;
786 oi
= (struct ospf6_interface
*) THREAD_ARG (thread
);
787 assert (oi
&& oi
->interface
);
789 if (IS_OSPF6_DEBUG_INTERFACE
)
790 zlog_debug ("Interface Event %s: [WaitTimer]",
791 oi
->interface
->name
);
793 if (oi
->state
== OSPF6_INTERFACE_WAITING
)
794 ospf6_interface_state_change (dr_election (oi
), oi
);
800 backup_seen (struct thread
*thread
)
802 struct ospf6_interface
*oi
;
804 oi
= (struct ospf6_interface
*) THREAD_ARG (thread
);
805 assert (oi
&& oi
->interface
);
807 if (IS_OSPF6_DEBUG_INTERFACE
)
808 zlog_debug ("Interface Event %s: [BackupSeen]",
809 oi
->interface
->name
);
811 if (oi
->state
== OSPF6_INTERFACE_WAITING
)
812 ospf6_interface_state_change (dr_election (oi
), oi
);
818 neighbor_change (struct thread
*thread
)
820 struct ospf6_interface
*oi
;
822 oi
= (struct ospf6_interface
*) THREAD_ARG (thread
);
823 assert (oi
&& oi
->interface
);
825 if (IS_OSPF6_DEBUG_INTERFACE
)
826 zlog_debug ("Interface Event %s: [NeighborChange]",
827 oi
->interface
->name
);
829 if (oi
->state
== OSPF6_INTERFACE_DROTHER
||
830 oi
->state
== OSPF6_INTERFACE_BDR
||
831 oi
->state
== OSPF6_INTERFACE_DR
)
832 ospf6_interface_state_change (dr_election (oi
), oi
);
838 interface_down (struct thread
*thread
)
840 struct ospf6_interface
*oi
;
841 struct listnode
*node
, *nnode
;
842 struct ospf6_neighbor
*on
;
844 oi
= (struct ospf6_interface
*) THREAD_ARG (thread
);
845 assert (oi
&& oi
->interface
);
847 if (IS_OSPF6_DEBUG_INTERFACE
)
848 zlog_debug ("Interface Event %s: [InterfaceDown]",
849 oi
->interface
->name
);
852 THREAD_OFF (oi
->thread_send_hello
);
854 /* Leave AllSPFRouters */
855 if (oi
->state
> OSPF6_INTERFACE_DOWN
)
856 ospf6_sso (oi
->interface
->ifindex
, &allspfrouters6
, IPV6_LEAVE_GROUP
);
858 ospf6_interface_state_change (OSPF6_INTERFACE_DOWN
, oi
);
860 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
861 ospf6_neighbor_delete (on
);
863 list_delete_all_node (oi
->neighbor_list
);
865 /* When interface state is reset, also reset information about
866 * DR election, as it is no longer valid. */
867 oi
->drouter
= oi
->prev_drouter
= htonl(0);
868 oi
->bdrouter
= oi
->prev_bdrouter
= htonl(0);
873 /* show specified interface structure */
875 ospf6_interface_show (struct vty
*vty
, struct interface
*ifp
)
877 struct ospf6_interface
*oi
;
881 char strbuf
[PREFIX2STR_BUFFER
], drouter
[32], bdrouter
[32];
882 const char *updown
[3] = {"down", "up", NULL
};
884 struct timeval res
, now
;
886 struct ospf6_lsa
*lsa
;
888 /* check physical interface type */
889 if (if_is_loopback (ifp
))
891 else if (if_is_broadcast (ifp
))
893 else if (if_is_pointopoint (ifp
))
894 type
= "POINTOPOINT";
898 vty_out (vty
, "%s is %s, type %s%s",
899 ifp
->name
, updown
[if_is_operative (ifp
)], type
,
901 vty_out (vty
, " Interface ID: %d%s", ifp
->ifindex
, VNL
);
903 if (ifp
->info
== NULL
)
905 vty_out (vty
, " OSPF not enabled on this interface%s", VNL
);
909 oi
= (struct ospf6_interface
*) ifp
->info
;
911 vty_out (vty
, " Internet Address:%s", VNL
);
913 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, i
, c
))
916 prefix2str (p
, strbuf
, sizeof (strbuf
));
920 vty_out (vty
, " inet : %s%s", strbuf
,
924 vty_out (vty
, " inet6: %s%s", strbuf
,
928 vty_out (vty
, " ??? : %s%s", strbuf
,
936 vty_out (vty
, " Instance ID %d, Interface MTU %d (autodetect: %d)%s",
937 oi
->instance_id
, oi
->ifmtu
, ifp
->mtu6
, VNL
);
938 vty_out (vty
, " MTU mismatch detection: %s%s", oi
->mtu_ignore
?
939 "disabled" : "enabled", VNL
);
940 inet_ntop (AF_INET
, &oi
->area
->area_id
,
941 strbuf
, sizeof (strbuf
));
942 vty_out (vty
, " Area ID %s, Cost %u%s", strbuf
, oi
->cost
,
946 vty_out (vty
, " Not Attached to Area%s", VNL
);
948 vty_out (vty
, " State %s, Transmit Delay %d sec, Priority %d%s",
949 ospf6_interface_state_str
[oi
->state
],
950 oi
->transdelay
, oi
->priority
,
952 vty_out (vty
, " Timer intervals configured:%s", VNL
);
953 vty_out (vty
, " Hello %d, Dead %d, Retransmit %d%s",
954 oi
->hello_interval
, oi
->dead_interval
, oi
->rxmt_interval
,
957 inet_ntop (AF_INET
, &oi
->drouter
, drouter
, sizeof (drouter
));
958 inet_ntop (AF_INET
, &oi
->bdrouter
, bdrouter
, sizeof (bdrouter
));
959 vty_out (vty
, " DR: %s BDR: %s%s", drouter
, bdrouter
, VNL
);
961 vty_out (vty
, " Number of I/F scoped LSAs is %u%s",
962 oi
->lsdb
->count
, VNL
);
967 if (oi
->thread_send_lsupdate
)
968 timersub (&oi
->thread_send_lsupdate
->u
.sands
, &now
, &res
);
969 timerstring (&res
, duration
, sizeof (duration
));
970 vty_out (vty
, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
971 oi
->lsupdate_list
->count
, duration
,
972 (oi
->thread_send_lsupdate
? "on" : "off"),
974 for (lsa
= ospf6_lsdb_head (oi
->lsupdate_list
); lsa
;
975 lsa
= ospf6_lsdb_next (lsa
))
976 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
979 if (oi
->thread_send_lsack
)
980 timersub (&oi
->thread_send_lsack
->u
.sands
, &now
, &res
);
981 timerstring (&res
, duration
, sizeof (duration
));
982 vty_out (vty
, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
983 oi
->lsack_list
->count
, duration
,
984 (oi
->thread_send_lsack
? "on" : "off"),
986 for (lsa
= ospf6_lsdb_head (oi
->lsack_list
); lsa
;
987 lsa
= ospf6_lsdb_next (lsa
))
988 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
989 ospf6_bfd_show_info(vty
, oi
->bfd_info
, 1);
994 DEFUN (show_ipv6_ospf6_interface
,
995 show_ipv6_ospf6_interface_ifname_cmd
,
996 "show ipv6 ospf6 interface [IFNAME]",
1004 struct interface
*ifp
;
1009 ifp
= if_lookup_by_name (argv
[idx_ifname
]->arg
);
1012 vty_out (vty
, "No such Interface: %s%s", argv
[idx_ifname
]->arg
,
1016 ospf6_interface_show (vty
, ifp
);
1020 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), i
, ifp
))
1021 ospf6_interface_show (vty
, ifp
);
1027 DEFUN (show_ipv6_ospf6_interface_ifname_prefix
,
1028 show_ipv6_ospf6_interface_ifname_prefix_cmd
,
1029 "show ipv6 ospf6 interface IFNAME prefix [<X:X::X:X|X:X::X:X/M>] [<match|detail>]",
1035 "Display connected prefixes to advertise\n"
1036 OSPF6_ROUTE_ADDRESS_STR
1037 OSPF6_ROUTE_PREFIX_STR
1038 OSPF6_ROUTE_MATCH_STR
1039 "Display details of the prefixes\n")
1043 struct interface
*ifp
;
1044 struct ospf6_interface
*oi
;
1046 ifp
= if_lookup_by_name (argv
[idx_ifname
]->arg
);
1049 vty_out (vty
, "No such Interface: %s%s", argv
[idx_ifname
]->arg
, VNL
);
1056 vty_out (vty
, "OSPFv3 is not enabled on %s%s", argv
[idx_ifname
]->arg
, VNL
);
1060 ospf6_route_table_show (vty
, idx_prefix
, argc
, argv
, oi
->route_connected
);
1065 DEFUN (show_ipv6_ospf6_interface_prefix
,
1066 show_ipv6_ospf6_interface_prefix_cmd
,
1067 "show ipv6 ospf6 interface prefix [<X:X::X:X|X:X::X:X/M>] [<match|detail>]",
1072 "Display connected prefixes to advertise\n"
1073 OSPF6_ROUTE_ADDRESS_STR
1074 OSPF6_ROUTE_PREFIX_STR
1075 OSPF6_ROUTE_MATCH_STR
1076 "Display details of the prefixes\n")
1080 struct ospf6_interface
*oi
;
1081 struct interface
*ifp
;
1083 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), i
, ifp
))
1085 oi
= (struct ospf6_interface
*) ifp
->info
;
1089 ospf6_route_table_show (vty
, idx_prefix
, argc
, argv
, oi
->route_connected
);
1095 /* interface variable set command */
1096 DEFUN (ipv6_ospf6_ifmtu
,
1097 ipv6_ospf6_ifmtu_cmd
,
1098 "ipv6 ospf6 ifmtu (1-65535)",
1102 "OSPFv3 Interface MTU\n"
1105 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1107 struct ospf6_interface
*oi
;
1108 unsigned int ifmtu
, iobuflen
;
1109 struct listnode
*node
, *nnode
;
1110 struct ospf6_neighbor
*on
;
1114 oi
= (struct ospf6_interface
*) ifp
->info
;
1116 oi
= ospf6_interface_create (ifp
);
1119 ifmtu
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
1121 if (oi
->ifmtu
== ifmtu
)
1124 if (ifp
->mtu6
!= 0 && ifp
->mtu6
< ifmtu
)
1126 vty_out (vty
, "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)%s",
1127 ifp
->name
, ifp
->mtu6
, VNL
);
1131 if (oi
->ifmtu
< ifmtu
)
1133 iobuflen
= ospf6_iobuf_size (ifmtu
);
1134 if (iobuflen
< ifmtu
)
1136 vty_out (vty
, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
1137 ifp
->name
, iobuflen
, VNL
);
1138 oi
->ifmtu
= iobuflen
;
1146 /* re-establish adjacencies */
1147 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
1149 THREAD_OFF (on
->inactivity_timer
);
1150 thread_add_event (master
, inactivity_timer
, on
, 0);
1156 DEFUN (no_ipv6_ospf6_ifmtu
,
1157 no_ipv6_ospf6_ifmtu_cmd
,
1158 "no ipv6 ospf6 ifmtu",
1165 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1166 struct ospf6_interface
*oi
;
1167 unsigned int iobuflen
;
1168 struct listnode
*node
, *nnode
;
1169 struct ospf6_neighbor
*on
;
1173 oi
= (struct ospf6_interface
*) ifp
->info
;
1175 oi
= ospf6_interface_create (ifp
);
1178 if (oi
->ifmtu
< ifp
->mtu
)
1180 iobuflen
= ospf6_iobuf_size (ifp
->mtu
);
1181 if (iobuflen
< ifp
->mtu
)
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
;
1188 oi
->ifmtu
= ifp
->mtu
;
1191 oi
->ifmtu
= ifp
->mtu
;
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 (ipv6_ospf6_cost
,
1204 ipv6_ospf6_cost_cmd
,
1205 "ipv6 ospf6 cost (1-65535)",
1209 "Outgoing metric of this interface\n"
1212 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1214 struct ospf6_interface
*oi
;
1215 unsigned long int lcost
;
1219 oi
= (struct ospf6_interface
*) ifp
->info
;
1221 oi
= ospf6_interface_create (ifp
);
1224 lcost
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
1226 if (lcost
> UINT32_MAX
)
1228 vty_out (vty
, "Cost %ld is out of range%s", lcost
, VNL
);
1232 if (oi
->cost
== lcost
)
1236 SET_FLAG (oi
->flag
, OSPF6_INTERFACE_NOAUTOCOST
);
1238 ospf6_interface_recalculate_cost(oi
);
1243 DEFUN (no_ipv6_ospf6_cost
,
1244 no_ipv6_ospf6_cost_cmd
,
1245 "no ipv6 ospf6 cost",
1249 "Calculate interface cost from bandwidth\n"
1252 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1253 struct ospf6_interface
*oi
;
1256 oi
= (struct ospf6_interface
*) ifp
->info
;
1258 oi
= ospf6_interface_create (ifp
);
1261 UNSET_FLAG (oi
->flag
, OSPF6_INTERFACE_NOAUTOCOST
);
1263 ospf6_interface_recalculate_cost(oi
);
1268 DEFUN (auto_cost_reference_bandwidth
,
1269 auto_cost_reference_bandwidth_cmd
,
1270 "auto-cost reference-bandwidth (1-4294967)",
1271 "Calculate OSPF interface cost according to bandwidth\n"
1272 "Use reference bandwidth method to assign OSPF cost\n"
1273 "The reference bandwidth in terms of Mbits per second\n")
1275 VTY_DECLVAR_CONTEXT(ospf6
, o
);
1277 struct ospf6_area
*oa
;
1278 struct ospf6_interface
*oi
;
1279 struct listnode
*i
, *j
;
1282 refbw
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
1283 if (refbw
< 1 || refbw
> 4294967)
1285 vty_out (vty
, "reference-bandwidth value is invalid%s", VTY_NEWLINE
);
1289 /* If reference bandwidth is changed. */
1290 if ((refbw
) == o
->ref_bandwidth
)
1293 o
->ref_bandwidth
= refbw
;
1294 for (ALL_LIST_ELEMENTS_RO (o
->area_list
, i
, oa
))
1295 for (ALL_LIST_ELEMENTS_RO (oa
->if_list
, j
, oi
))
1296 ospf6_interface_recalculate_cost (oi
);
1301 DEFUN (no_auto_cost_reference_bandwidth
,
1302 no_auto_cost_reference_bandwidth_cmd
,
1303 "no auto-cost reference-bandwidth [(1-4294967)]",
1305 "Calculate OSPF interface cost according to bandwidth\n"
1306 "Use reference bandwidth method to assign OSPF cost\n"
1307 "The reference bandwidth in terms of Mbits per second\n")
1309 VTY_DECLVAR_CONTEXT(ospf6
, o
);
1310 struct ospf6_area
*oa
;
1311 struct ospf6_interface
*oi
;
1312 struct listnode
*i
, *j
;
1314 if (o
->ref_bandwidth
== OSPF6_REFERENCE_BANDWIDTH
)
1317 o
->ref_bandwidth
= OSPF6_REFERENCE_BANDWIDTH
;
1318 for (ALL_LIST_ELEMENTS_RO (o
->area_list
, i
, oa
))
1319 for (ALL_LIST_ELEMENTS_RO (oa
->if_list
, j
, oi
))
1320 ospf6_interface_recalculate_cost (oi
);
1326 DEFUN (ipv6_ospf6_hellointerval
,
1327 ipv6_ospf6_hellointerval_cmd
,
1328 "ipv6 ospf6 hello-interval (1-65535)",
1331 "Time between HELLO packets\n"
1335 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1337 struct ospf6_interface
*oi
;
1340 oi
= (struct ospf6_interface
*) ifp
->info
;
1342 oi
= ospf6_interface_create (ifp
);
1345 oi
->hello_interval
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
1349 /* interface variable set command */
1350 DEFUN (ipv6_ospf6_deadinterval
,
1351 ipv6_ospf6_deadinterval_cmd
,
1352 "ipv6 ospf6 dead-interval (1-65535)",
1355 "Interval time after which a neighbor is declared down\n"
1359 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1361 struct ospf6_interface
*oi
;
1364 oi
= (struct ospf6_interface
*) ifp
->info
;
1366 oi
= ospf6_interface_create (ifp
);
1369 oi
->dead_interval
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
1373 /* interface variable set command */
1374 DEFUN (ipv6_ospf6_transmitdelay
,
1375 ipv6_ospf6_transmitdelay_cmd
,
1376 "ipv6 ospf6 transmit-delay (1-3600)",
1379 "Link state transmit delay\n"
1382 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1384 struct ospf6_interface
*oi
;
1387 oi
= (struct ospf6_interface
*) ifp
->info
;
1389 oi
= ospf6_interface_create (ifp
);
1392 oi
->transdelay
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
1396 /* interface variable set command */
1397 DEFUN (ipv6_ospf6_retransmitinterval
,
1398 ipv6_ospf6_retransmitinterval_cmd
,
1399 "ipv6 ospf6 retransmit-interval (1-65535)",
1402 "Time between retransmitting lost link state advertisements\n"
1406 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1408 struct ospf6_interface
*oi
;
1411 oi
= (struct ospf6_interface
*) ifp
->info
;
1413 oi
= ospf6_interface_create (ifp
);
1416 oi
->rxmt_interval
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
1420 /* interface variable set command */
1421 DEFUN (ipv6_ospf6_priority
,
1422 ipv6_ospf6_priority_cmd
,
1423 "ipv6 ospf6 priority (0-255)",
1430 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1432 struct ospf6_interface
*oi
;
1435 oi
= (struct ospf6_interface
*) ifp
->info
;
1437 oi
= ospf6_interface_create (ifp
);
1440 oi
->priority
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
1443 (oi
->state
== OSPF6_INTERFACE_DROTHER
||
1444 oi
->state
== OSPF6_INTERFACE_BDR
||
1445 oi
->state
== OSPF6_INTERFACE_DR
))
1446 ospf6_interface_state_change (dr_election (oi
), oi
);
1451 DEFUN (ipv6_ospf6_instance
,
1452 ipv6_ospf6_instance_cmd
,
1453 "ipv6 ospf6 instance-id (0-255)",
1456 "Instance ID for this interface\n"
1457 "Instance ID value\n"
1460 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1462 struct ospf6_interface
*oi
;
1465 oi
= (struct ospf6_interface
*)ifp
->info
;
1467 oi
= ospf6_interface_create (ifp
);
1470 oi
->instance_id
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
1474 DEFUN (ipv6_ospf6_passive
,
1475 ipv6_ospf6_passive_cmd
,
1476 "ipv6 ospf6 passive",
1479 "Passive interface; no adjacency will be formed on this interface\n"
1482 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1483 struct ospf6_interface
*oi
;
1484 struct listnode
*node
, *nnode
;
1485 struct ospf6_neighbor
*on
;
1489 oi
= (struct ospf6_interface
*) ifp
->info
;
1491 oi
= ospf6_interface_create (ifp
);
1494 SET_FLAG (oi
->flag
, OSPF6_INTERFACE_PASSIVE
);
1495 THREAD_OFF (oi
->thread_send_hello
);
1497 for (ALL_LIST_ELEMENTS (oi
->neighbor_list
, node
, nnode
, on
))
1499 THREAD_OFF (on
->inactivity_timer
);
1500 thread_add_event (master
, inactivity_timer
, on
, 0);
1506 DEFUN (no_ipv6_ospf6_passive
,
1507 no_ipv6_ospf6_passive_cmd
,
1508 "no ipv6 ospf6 passive",
1512 "passive interface: No Adjacency will be formed on this I/F\n"
1515 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1516 struct ospf6_interface
*oi
;
1519 oi
= (struct ospf6_interface
*) ifp
->info
;
1521 oi
= ospf6_interface_create (ifp
);
1524 UNSET_FLAG (oi
->flag
, OSPF6_INTERFACE_PASSIVE
);
1525 THREAD_OFF (oi
->thread_send_hello
);
1526 oi
->thread_send_hello
=
1527 thread_add_event (master
, ospf6_hello_send
, oi
, 0);
1532 DEFUN (ipv6_ospf6_mtu_ignore
,
1533 ipv6_ospf6_mtu_ignore_cmd
,
1534 "ipv6 ospf6 mtu-ignore",
1537 "Disable MTU mismatch detection on this interface\n"
1540 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1541 struct ospf6_interface
*oi
;
1544 oi
= (struct ospf6_interface
*) ifp
->info
;
1546 oi
= ospf6_interface_create (ifp
);
1554 DEFUN (no_ipv6_ospf6_mtu_ignore
,
1555 no_ipv6_ospf6_mtu_ignore_cmd
,
1556 "no ipv6 ospf6 mtu-ignore",
1560 "Disable MTU mismatch detection on this interface\n"
1563 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1564 struct ospf6_interface
*oi
;
1567 oi
= (struct ospf6_interface
*) ifp
->info
;
1569 oi
= ospf6_interface_create (ifp
);
1577 DEFUN (ipv6_ospf6_advertise_prefix_list
,
1578 ipv6_ospf6_advertise_prefix_list_cmd
,
1579 "ipv6 ospf6 advertise prefix-list WORD",
1582 "Advertising options\n"
1583 "Filter prefix using prefix-list\n"
1584 "Prefix list name\n"
1587 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1589 struct ospf6_interface
*oi
;
1592 oi
= (struct ospf6_interface
*) ifp
->info
;
1594 oi
= ospf6_interface_create (ifp
);
1598 XFREE (MTYPE_CFG_PLIST_NAME
, oi
->plist_name
);
1599 oi
->plist_name
= XSTRDUP (MTYPE_CFG_PLIST_NAME
, argv
[idx_word
]->arg
);
1601 ospf6_interface_connected_route_update (oi
->interface
);
1605 OSPF6_LINK_LSA_SCHEDULE (oi
);
1606 if (oi
->state
== OSPF6_INTERFACE_DR
)
1608 OSPF6_NETWORK_LSA_SCHEDULE (oi
);
1609 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi
);
1611 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi
->area
);
1617 DEFUN (no_ipv6_ospf6_advertise_prefix_list
,
1618 no_ipv6_ospf6_advertise_prefix_list_cmd
,
1619 "no ipv6 ospf6 advertise prefix-list",
1623 "Advertising options\n"
1624 "Filter prefix using prefix-list\n"
1627 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1628 struct ospf6_interface
*oi
;
1631 oi
= (struct ospf6_interface
*) ifp
->info
;
1633 oi
= ospf6_interface_create (ifp
);
1638 XFREE (MTYPE_CFG_PLIST_NAME
, oi
->plist_name
);
1639 oi
->plist_name
= NULL
;
1642 ospf6_interface_connected_route_update (oi
->interface
);
1646 OSPF6_LINK_LSA_SCHEDULE (oi
);
1647 if (oi
->state
== OSPF6_INTERFACE_DR
)
1649 OSPF6_NETWORK_LSA_SCHEDULE (oi
);
1650 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi
);
1652 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi
->area
);
1658 DEFUN (ipv6_ospf6_network
,
1659 ipv6_ospf6_network_cmd
,
1660 "ipv6 ospf6 network <broadcast|point-to-point>",
1664 "Specify OSPF6 broadcast network\n"
1665 "Specify OSPF6 point-to-point network\n"
1668 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1669 int idx_network
= 3;
1670 struct ospf6_interface
*oi
;
1673 oi
= (struct ospf6_interface
*) ifp
->info
;
1675 oi
= ospf6_interface_create (ifp
);
1679 if (strncmp (argv
[idx_network
]->arg
, "b", 1) == 0)
1681 if (oi
->type
== OSPF_IFTYPE_BROADCAST
)
1684 oi
->type
= OSPF_IFTYPE_BROADCAST
;
1686 else if (strncmp (argv
[idx_network
]->arg
, "point-to-p", 10) == 0)
1688 if (oi
->type
== OSPF_IFTYPE_POINTOPOINT
) {
1691 oi
->type
= OSPF_IFTYPE_POINTOPOINT
;
1694 /* Reset the interface */
1695 thread_add_event (master
, interface_down
, oi
, 0);
1696 thread_add_event (master
, interface_up
, oi
, 0);
1701 DEFUN (no_ipv6_ospf6_network
,
1702 no_ipv6_ospf6_network_cmd
,
1703 "no ipv6 ospf6 network",
1708 "Default to whatever interface type system specifies"
1711 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1712 struct ospf6_interface
*oi
;
1717 oi
= (struct ospf6_interface
*) ifp
->info
;
1722 type
= ospf6_default_iftype (ifp
);
1723 if (oi
->type
== type
)
1729 /* Reset the interface */
1730 thread_add_event (master
, interface_down
, oi
, 0);
1731 thread_add_event (master
, interface_up
, oi
, 0);
1737 config_write_ospf6_interface (struct vty
*vty
)
1740 struct ospf6_interface
*oi
;
1741 struct interface
*ifp
;
1743 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), i
, ifp
))
1745 oi
= (struct ospf6_interface
*) ifp
->info
;
1749 vty_out (vty
, "interface %s%s",
1750 oi
->interface
->name
, VNL
);
1753 vty_out (vty
, " description %s%s", ifp
->desc
, VNL
);
1754 if (ifp
->mtu6
!= oi
->ifmtu
)
1755 vty_out (vty
, " ipv6 ospf6 ifmtu %d%s", oi
->ifmtu
, VNL
);
1757 if (CHECK_FLAG (oi
->flag
, OSPF6_INTERFACE_NOAUTOCOST
))
1758 vty_out (vty
, " ipv6 ospf6 cost %d%s",
1761 if (oi
->hello_interval
!= OSPF6_INTERFACE_HELLO_INTERVAL
)
1762 vty_out (vty
, " ipv6 ospf6 hello-interval %d%s",
1763 oi
->hello_interval
, VNL
);
1765 if (oi
->dead_interval
!= OSPF6_INTERFACE_DEAD_INTERVAL
)
1766 vty_out (vty
, " ipv6 ospf6 dead-interval %d%s",
1767 oi
->dead_interval
, VNL
);
1769 if (oi
->rxmt_interval
!= OSPF6_INTERFACE_RXMT_INTERVAL
)
1770 vty_out (vty
, " ipv6 ospf6 retransmit-interval %d%s",
1771 oi
->rxmt_interval
, VNL
);
1773 if (oi
->priority
!= OSPF6_INTERFACE_PRIORITY
)
1774 vty_out (vty
, " ipv6 ospf6 priority %d%s",
1777 if (oi
->transdelay
!= OSPF6_INTERFACE_TRANSDELAY
)
1778 vty_out (vty
, " ipv6 ospf6 transmit-delay %d%s",
1779 oi
->transdelay
, VNL
);
1781 if (oi
->instance_id
!= OSPF6_INTERFACE_INSTANCE_ID
)
1782 vty_out (vty
, " ipv6 ospf6 instance-id %d%s",
1783 oi
->instance_id
, VNL
);
1786 vty_out (vty
, " ipv6 ospf6 advertise prefix-list %s%s",
1787 oi
->plist_name
, VNL
);
1789 if (CHECK_FLAG (oi
->flag
, OSPF6_INTERFACE_PASSIVE
))
1790 vty_out (vty
, " ipv6 ospf6 passive%s", VNL
);
1793 vty_out (vty
, " ipv6 ospf6 mtu-ignore%s", VNL
);
1795 if (oi
->type
!= ospf6_default_iftype(ifp
))
1797 if (oi
->type
== OSPF_IFTYPE_POINTOPOINT
)
1798 vty_out (vty
, " ipv6 ospf6 network point-to-point%s", VNL
);
1799 else if (oi
->type
== OSPF_IFTYPE_BROADCAST
)
1800 vty_out (vty
, " ipv6 ospf6 network broadcast%s", VNL
);
1803 ospf6_bfd_write_config(vty
, oi
);
1805 vty_out (vty
, "!%s", VNL
);
1810 static struct cmd_node interface_node
=
1818 ospf6_interface_init (void)
1820 /* Install interface node. */
1821 install_node (&interface_node
, config_write_ospf6_interface
);
1824 install_element (VIEW_NODE
, &show_ipv6_ospf6_interface_prefix_cmd
);
1825 install_element (VIEW_NODE
, &show_ipv6_ospf6_interface_ifname_cmd
);
1826 install_element (VIEW_NODE
, &show_ipv6_ospf6_interface_ifname_prefix_cmd
);
1828 install_element (INTERFACE_NODE
, &ipv6_ospf6_cost_cmd
);
1829 install_element (INTERFACE_NODE
, &no_ipv6_ospf6_cost_cmd
);
1830 install_element (INTERFACE_NODE
, &ipv6_ospf6_ifmtu_cmd
);
1831 install_element (INTERFACE_NODE
, &no_ipv6_ospf6_ifmtu_cmd
);
1832 install_element (INTERFACE_NODE
, &ipv6_ospf6_deadinterval_cmd
);
1833 install_element (INTERFACE_NODE
, &ipv6_ospf6_hellointerval_cmd
);
1834 install_element (INTERFACE_NODE
, &ipv6_ospf6_priority_cmd
);
1835 install_element (INTERFACE_NODE
, &ipv6_ospf6_retransmitinterval_cmd
);
1836 install_element (INTERFACE_NODE
, &ipv6_ospf6_transmitdelay_cmd
);
1837 install_element (INTERFACE_NODE
, &ipv6_ospf6_instance_cmd
);
1839 install_element (INTERFACE_NODE
, &ipv6_ospf6_passive_cmd
);
1840 install_element (INTERFACE_NODE
, &no_ipv6_ospf6_passive_cmd
);
1842 install_element (INTERFACE_NODE
, &ipv6_ospf6_mtu_ignore_cmd
);
1843 install_element (INTERFACE_NODE
, &no_ipv6_ospf6_mtu_ignore_cmd
);
1845 install_element (INTERFACE_NODE
, &ipv6_ospf6_advertise_prefix_list_cmd
);
1846 install_element (INTERFACE_NODE
, &no_ipv6_ospf6_advertise_prefix_list_cmd
);
1848 install_element (INTERFACE_NODE
, &ipv6_ospf6_network_cmd
);
1849 install_element (INTERFACE_NODE
, &no_ipv6_ospf6_network_cmd
);
1851 /* reference bandwidth commands */
1852 install_element (OSPF6_NODE
, &auto_cost_reference_bandwidth_cmd
);
1853 install_element (OSPF6_NODE
, &no_auto_cost_reference_bandwidth_cmd
);
1856 /* Clear the specified interface structure */
1858 ospf6_interface_clear (struct vty
*vty
, struct interface
*ifp
)
1860 struct ospf6_interface
*oi
;
1862 if (!if_is_operative (ifp
))
1865 if (ifp
->info
== NULL
)
1868 oi
= (struct ospf6_interface
*) ifp
->info
;
1870 if (IS_OSPF6_DEBUG_INTERFACE
)
1871 zlog_debug ("Interface %s: clear by reset", ifp
->name
);
1873 /* Reset the interface */
1874 thread_add_event (master
, interface_down
, oi
, 0);
1875 thread_add_event (master
, interface_up
, oi
, 0);
1878 /* Clear interface */
1879 DEFUN (clear_ipv6_ospf6_interface
,
1880 clear_ipv6_ospf6_interface_cmd
,
1881 "clear ipv6 ospf6 interface [IFNAME]",
1890 struct interface
*ifp
;
1891 struct listnode
*node
;
1893 if (argc
== 4) /* Clear all the ospfv3 interfaces. */
1895 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
1896 ospf6_interface_clear (vty
, ifp
);
1898 else /* Interface name is specified. */
1900 if ((ifp
= if_lookup_by_name (argv
[idx_ifname
]->arg
)) == NULL
)
1902 vty_out (vty
, "No such Interface: %s%s", argv
[idx_ifname
]->arg
, VNL
);
1905 ospf6_interface_clear (vty
, ifp
);
1912 install_element_ospf6_clear_interface (void)
1914 install_element (ENABLE_NODE
, &clear_ipv6_ospf6_interface_cmd
);
1917 DEFUN (debug_ospf6_interface
,
1918 debug_ospf6_interface_cmd
,
1919 "debug ospf6 interface",
1922 "Debug OSPFv3 Interface\n"
1925 OSPF6_DEBUG_INTERFACE_ON ();
1929 DEFUN (no_debug_ospf6_interface
,
1930 no_debug_ospf6_interface_cmd
,
1931 "no debug ospf6 interface",
1935 "Debug OSPFv3 Interface\n"
1938 OSPF6_DEBUG_INTERFACE_OFF ();
1943 config_write_ospf6_debug_interface (struct vty
*vty
)
1945 if (IS_OSPF6_DEBUG_INTERFACE
)
1946 vty_out (vty
, "debug ospf6 interface%s", VNL
);
1951 install_element_ospf6_debug_interface (void)
1953 install_element (ENABLE_NODE
, &debug_ospf6_interface_cmd
);
1954 install_element (ENABLE_NODE
, &no_debug_ospf6_interface_cmd
);
1955 install_element (CONFIG_NODE
, &debug_ospf6_interface_cmd
);
1956 install_element (CONFIG_NODE
, &no_debug_ospf6_interface_cmd
);