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 along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 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"
44 #include "ospf6_bfd.h"
46 DEFINE_MTYPE_STATIC(OSPF6D
, CFG_PLIST_NAME
, "configured prefix list names")
47 DEFINE_QOBJ_TYPE(ospf6_interface
)
48 DEFINE_HOOK(ospf6_interface_change
,
49 (struct ospf6_interface
* oi
, int state
, int old_state
),
50 (oi
, state
, old_state
))
52 unsigned char conf_debug_ospf6_interface
= 0;
54 const char *ospf6_interface_state_str
[] = {
55 "None", "Down", "Loopback", "Waiting", "PointToPoint",
56 "DROther", "BDR", "DR", NULL
};
58 struct ospf6_interface
*ospf6_interface_lookup_by_ifindex(ifindex_t ifindex
)
60 struct ospf6_interface
*oi
;
61 struct interface
*ifp
;
63 ifp
= if_lookup_by_index(ifindex
, VRF_DEFAULT
);
65 return (struct ospf6_interface
*)NULL
;
67 oi
= (struct ospf6_interface
*)ifp
->info
;
71 /* schedule routing table recalculation */
72 static void ospf6_interface_lsdb_hook(struct ospf6_lsa
*lsa
,
75 struct ospf6_interface
*oi
;
81 switch (ntohs(lsa
->header
->type
)) {
82 case OSPF6_LSTYPE_LINK
:
83 if (oi
->state
== OSPF6_INTERFACE_DR
)
84 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(oi
);
86 ospf6_spf_schedule(oi
->area
->ospf6
, reason
);
94 static void ospf6_interface_lsdb_hook_add(struct ospf6_lsa
*lsa
)
96 ospf6_interface_lsdb_hook(lsa
, ospf6_lsadd_to_spf_reason(lsa
));
99 static void ospf6_interface_lsdb_hook_remove(struct ospf6_lsa
*lsa
)
101 ospf6_interface_lsdb_hook(lsa
, ospf6_lsremove_to_spf_reason(lsa
));
104 static uint8_t ospf6_default_iftype(struct interface
*ifp
)
106 if (if_is_pointopoint(ifp
))
107 return OSPF_IFTYPE_POINTOPOINT
;
108 else if (if_is_loopback(ifp
))
109 return OSPF_IFTYPE_LOOPBACK
;
111 return OSPF_IFTYPE_BROADCAST
;
114 static uint32_t ospf6_interface_get_cost(struct ospf6_interface
*oi
)
116 /* If all else fails, use default OSPF cost */
120 /* interface speed and bw can be 0 in some platforms,
121 * use ospf default bw. If bw is configured then it would
124 if (!oi
->interface
->bandwidth
&& oi
->interface
->speed
) {
125 bw
= oi
->interface
->speed
;
127 bw
= oi
->interface
->bandwidth
? oi
->interface
->bandwidth
128 : OSPF6_INTERFACE_BANDWIDTH
;
131 refbw
= ospf6
? ospf6
->ref_bandwidth
: OSPF6_REFERENCE_BANDWIDTH
;
133 /* A specifed ip ospf cost overrides a calculated one. */
134 if (CHECK_FLAG(oi
->flag
, OSPF6_INTERFACE_NOAUTOCOST
))
137 cost
= (uint32_t)((double)refbw
/ (double)bw
+ (double)0.5);
140 else if (cost
> UINT32_MAX
)
147 static void ospf6_interface_force_recalculate_cost(struct ospf6_interface
*oi
)
149 /* update cost held in route_connected list in ospf6_interface */
150 ospf6_interface_connected_route_update(oi
->interface
);
152 /* execute LSA hooks */
154 OSPF6_LINK_LSA_SCHEDULE(oi
);
155 OSPF6_ROUTER_LSA_SCHEDULE(oi
->area
);
156 OSPF6_NETWORK_LSA_SCHEDULE(oi
);
157 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(oi
);
158 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(oi
->area
);
162 static void ospf6_interface_recalculate_cost(struct ospf6_interface
*oi
)
166 newcost
= ospf6_interface_get_cost(oi
);
167 if (newcost
== oi
->cost
)
171 ospf6_interface_force_recalculate_cost(oi
);
174 /* Create new ospf6 interface structure */
175 struct ospf6_interface
*ospf6_interface_create(struct interface
*ifp
)
177 struct ospf6_interface
*oi
;
178 unsigned int iobuflen
;
180 oi
= (struct ospf6_interface
*)XCALLOC(MTYPE_OSPF6_IF
,
181 sizeof(struct ospf6_interface
));
183 oi
->area
= (struct ospf6_area
*)NULL
;
184 oi
->neighbor_list
= list_new();
185 oi
->neighbor_list
->cmp
= ospf6_neighbor_cmp
;
186 oi
->linklocal_addr
= (struct in6_addr
*)NULL
;
187 oi
->instance_id
= OSPF6_INTERFACE_INSTANCE_ID
;
188 oi
->transdelay
= OSPF6_INTERFACE_TRANSDELAY
;
189 oi
->priority
= OSPF6_INTERFACE_PRIORITY
;
191 oi
->hello_interval
= OSPF_HELLO_INTERVAL_DEFAULT
;
192 oi
->dead_interval
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
193 oi
->rxmt_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
194 oi
->type
= ospf6_default_iftype(ifp
);
195 oi
->state
= OSPF6_INTERFACE_DOWN
;
200 /* Try to adjust I/O buffer size with IfMtu */
201 oi
->ifmtu
= ifp
->mtu6
;
202 iobuflen
= ospf6_iobuf_size(ifp
->mtu6
);
203 if (oi
->ifmtu
> iobuflen
) {
204 if (IS_OSPF6_DEBUG_INTERFACE
)
206 "Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
207 ifp
->name
, iobuflen
);
208 oi
->ifmtu
= iobuflen
;
211 QOBJ_REG(oi
, ospf6_interface
);
213 oi
->lsupdate_list
= ospf6_lsdb_create(oi
);
214 oi
->lsack_list
= ospf6_lsdb_create(oi
);
215 oi
->lsdb
= ospf6_lsdb_create(oi
);
216 oi
->lsdb
->hook_add
= ospf6_interface_lsdb_hook_add
;
217 oi
->lsdb
->hook_remove
= ospf6_interface_lsdb_hook_remove
;
218 oi
->lsdb_self
= ospf6_lsdb_create(oi
);
220 oi
->route_connected
=
221 OSPF6_ROUTE_TABLE_CREATE(INTERFACE
, CONNECTED_ROUTES
);
222 oi
->route_connected
->scope
= oi
;
229 oi
->cost
= ospf6_interface_get_cost(oi
);
234 void ospf6_interface_delete(struct ospf6_interface
*oi
)
236 struct listnode
*node
, *nnode
;
237 struct ospf6_neighbor
*on
;
241 for (ALL_LIST_ELEMENTS(oi
->neighbor_list
, node
, nnode
, on
))
242 ospf6_neighbor_delete(on
);
244 list_delete(&oi
->neighbor_list
);
246 THREAD_OFF(oi
->thread_send_hello
);
247 THREAD_OFF(oi
->thread_send_lsupdate
);
248 THREAD_OFF(oi
->thread_send_lsack
);
250 ospf6_lsdb_remove_all(oi
->lsdb
);
251 ospf6_lsdb_remove_all(oi
->lsupdate_list
);
252 ospf6_lsdb_remove_all(oi
->lsack_list
);
254 ospf6_lsdb_delete(oi
->lsdb
);
255 ospf6_lsdb_delete(oi
->lsdb_self
);
257 ospf6_lsdb_delete(oi
->lsupdate_list
);
258 ospf6_lsdb_delete(oi
->lsack_list
);
260 ospf6_route_table_delete(oi
->route_connected
);
263 oi
->interface
->info
= NULL
;
267 XFREE(MTYPE_CFG_PLIST_NAME
, oi
->plist_name
);
269 ospf6_bfd_info_free(&(oi
->bfd_info
));
271 XFREE(MTYPE_OSPF6_IF
, oi
);
274 void ospf6_interface_enable(struct ospf6_interface
*oi
)
276 UNSET_FLAG(oi
->flag
, OSPF6_INTERFACE_DISABLE
);
277 ospf6_interface_state_update(oi
->interface
);
280 void ospf6_interface_disable(struct ospf6_interface
*oi
)
282 SET_FLAG(oi
->flag
, OSPF6_INTERFACE_DISABLE
);
284 thread_execute(master
, interface_down
, oi
, 0);
286 ospf6_lsdb_remove_all(oi
->lsdb
);
287 ospf6_lsdb_remove_all(oi
->lsdb_self
);
288 ospf6_lsdb_remove_all(oi
->lsupdate_list
);
289 ospf6_lsdb_remove_all(oi
->lsack_list
);
291 THREAD_OFF(oi
->thread_send_hello
);
292 THREAD_OFF(oi
->thread_send_lsupdate
);
293 THREAD_OFF(oi
->thread_send_lsack
);
295 THREAD_OFF(oi
->thread_network_lsa
);
296 THREAD_OFF(oi
->thread_link_lsa
);
297 THREAD_OFF(oi
->thread_intra_prefix_lsa
);
298 THREAD_OFF(oi
->thread_as_extern_lsa
);
301 static struct in6_addr
*
302 ospf6_interface_get_linklocal_address(struct interface
*ifp
)
306 struct in6_addr
*l
= (struct in6_addr
*)NULL
;
308 /* for each connected address */
309 for (ALL_LIST_ELEMENTS_RO(ifp
->connected
, n
, c
)) {
310 /* if family not AF_INET6, ignore */
311 if (c
->address
->family
!= AF_INET6
)
314 /* linklocal scope check */
315 if (IN6_IS_ADDR_LINKLOCAL(&c
->address
->u
.prefix6
))
316 l
= &c
->address
->u
.prefix6
;
321 void ospf6_interface_if_add(struct interface
*ifp
)
323 struct ospf6_interface
*oi
;
324 unsigned int iobuflen
;
326 oi
= (struct ospf6_interface
*)ifp
->info
;
330 /* Try to adjust I/O buffer size with IfMtu */
332 oi
->ifmtu
= ifp
->mtu6
;
333 iobuflen
= ospf6_iobuf_size(ifp
->mtu6
);
334 if (oi
->ifmtu
> iobuflen
) {
335 if (IS_OSPF6_DEBUG_INTERFACE
)
337 "Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
338 ifp
->name
, iobuflen
);
339 oi
->ifmtu
= iobuflen
;
342 /* interface start */
343 ospf6_interface_state_update(oi
->interface
);
346 void ospf6_interface_state_update(struct interface
*ifp
)
348 struct ospf6_interface
*oi
;
349 unsigned int iobuflen
;
351 oi
= (struct ospf6_interface
*)ifp
->info
;
354 if (oi
->area
== NULL
)
356 if (CHECK_FLAG(oi
->flag
, OSPF6_INTERFACE_DISABLE
))
359 /* Adjust the mtu values if the kernel told us something new */
360 if (ifp
->mtu6
!= oi
->ifmtu
) {
361 /* If nothing configured, accept it and check for buffer size */
363 oi
->ifmtu
= ifp
->mtu6
;
364 iobuflen
= ospf6_iobuf_size(ifp
->mtu6
);
365 if (oi
->ifmtu
> iobuflen
) {
366 if (IS_OSPF6_DEBUG_INTERFACE
)
368 "Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
369 ifp
->name
, iobuflen
);
370 oi
->ifmtu
= iobuflen
;
372 } else if (oi
->c_ifmtu
> ifp
->mtu6
) {
373 oi
->ifmtu
= ifp
->mtu6
;
375 "Configured mtu %u on %s overridden by kernel %u",
376 oi
->c_ifmtu
, ifp
->name
, ifp
->mtu6
);
378 oi
->ifmtu
= oi
->c_ifmtu
;
381 if (if_is_operative(ifp
)
382 && (ospf6_interface_get_linklocal_address(oi
->interface
)
383 || if_is_loopback(oi
->interface
)))
384 thread_execute(master
, interface_up
, oi
, 0);
386 thread_execute(master
, interface_down
, oi
, 0);
391 void ospf6_interface_connected_route_update(struct interface
*ifp
)
393 struct ospf6_interface
*oi
;
394 struct ospf6_route
*route
;
396 struct listnode
*node
, *nnode
;
397 struct in6_addr nh_addr
;
399 oi
= (struct ospf6_interface
*)ifp
->info
;
403 /* reset linklocal pointer */
404 oi
->linklocal_addr
= ospf6_interface_get_linklocal_address(ifp
);
406 /* if area is null, do not make connected-route list */
407 if (oi
->area
== NULL
)
410 if (CHECK_FLAG(oi
->flag
, OSPF6_INTERFACE_DISABLE
))
413 /* update "route to advertise" interface route table */
414 ospf6_route_remove_all(oi
->route_connected
);
416 for (ALL_LIST_ELEMENTS(oi
->interface
->connected
, node
, nnode
, c
)) {
417 if (c
->address
->family
!= AF_INET6
)
420 CONTINUE_IF_ADDRESS_LINKLOCAL(IS_OSPF6_DEBUG_INTERFACE
,
422 CONTINUE_IF_ADDRESS_UNSPECIFIED(IS_OSPF6_DEBUG_INTERFACE
,
424 CONTINUE_IF_ADDRESS_LOOPBACK(IS_OSPF6_DEBUG_INTERFACE
,
426 CONTINUE_IF_ADDRESS_V4COMPAT(IS_OSPF6_DEBUG_INTERFACE
,
428 CONTINUE_IF_ADDRESS_V4MAPPED(IS_OSPF6_DEBUG_INTERFACE
,
432 if (oi
->plist_name
) {
433 struct prefix_list
*plist
;
434 enum prefix_list_type ret
;
435 char buf
[PREFIX2STR_BUFFER
];
437 prefix2str(c
->address
, buf
, sizeof(buf
));
438 plist
= prefix_list_lookup(AFI_IP6
, oi
->plist_name
);
439 ret
= prefix_list_apply(plist
, (void *)c
->address
);
440 if (ret
== PREFIX_DENY
) {
441 if (IS_OSPF6_DEBUG_INTERFACE
)
443 "%s on %s filtered by prefix-list %s ",
444 buf
, oi
->interface
->name
,
450 route
= ospf6_route_create();
451 memcpy(&route
->prefix
, c
->address
, sizeof(struct prefix
));
452 apply_mask(&route
->prefix
);
453 route
->type
= OSPF6_DEST_TYPE_NETWORK
;
454 route
->path
.area_id
= oi
->area
->area_id
;
455 route
->path
.type
= OSPF6_PATH_TYPE_INTRA
;
456 route
->path
.cost
= oi
->cost
;
457 inet_pton(AF_INET6
, "::1", &nh_addr
);
458 ospf6_route_add_nexthop(route
, oi
->interface
->ifindex
,
460 ospf6_route_add(route
, oi
->route_connected
);
463 /* create new Link-LSA */
464 OSPF6_LINK_LSA_SCHEDULE(oi
);
465 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(oi
);
466 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(oi
->area
);
469 static void ospf6_interface_state_change(uint8_t next_state
,
470 struct ospf6_interface
*oi
)
474 prev_state
= oi
->state
;
475 oi
->state
= next_state
;
477 if (prev_state
== next_state
)
481 if (IS_OSPF6_DEBUG_INTERFACE
) {
482 zlog_debug("Interface state change %s: %s -> %s",
484 ospf6_interface_state_str
[prev_state
],
485 ospf6_interface_state_str
[next_state
]);
489 if ((prev_state
== OSPF6_INTERFACE_DR
490 || prev_state
== OSPF6_INTERFACE_BDR
)
491 && (next_state
!= OSPF6_INTERFACE_DR
492 && next_state
!= OSPF6_INTERFACE_BDR
))
493 ospf6_sso(oi
->interface
->ifindex
, &alldrouters6
,
496 if ((prev_state
!= OSPF6_INTERFACE_DR
497 && prev_state
!= OSPF6_INTERFACE_BDR
)
498 && (next_state
== OSPF6_INTERFACE_DR
499 || next_state
== OSPF6_INTERFACE_BDR
))
500 ospf6_sso(oi
->interface
->ifindex
, &alldrouters6
,
503 OSPF6_ROUTER_LSA_SCHEDULE(oi
->area
);
504 if (next_state
== OSPF6_INTERFACE_DOWN
) {
505 OSPF6_NETWORK_LSA_EXECUTE(oi
);
506 OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT(oi
);
507 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(oi
->area
);
508 OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT(oi
);
509 } else if (prev_state
== OSPF6_INTERFACE_DR
510 || next_state
== OSPF6_INTERFACE_DR
) {
511 OSPF6_NETWORK_LSA_SCHEDULE(oi
);
512 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(oi
);
513 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(oi
->area
);
516 hook_call(ospf6_interface_change
, oi
, next_state
, prev_state
);
520 /* DR Election, RFC2328 section 9.4 */
522 #define IS_ELIGIBLE(n) \
523 ((n)->state >= OSPF6_NEIGHBOR_TWOWAY && (n)->priority != 0)
525 static struct ospf6_neighbor
*better_bdrouter(struct ospf6_neighbor
*a
,
526 struct ospf6_neighbor
*b
)
528 if ((a
== NULL
|| !IS_ELIGIBLE(a
) || a
->drouter
== a
->router_id
)
529 && (b
== NULL
|| !IS_ELIGIBLE(b
) || b
->drouter
== b
->router_id
))
531 else if (a
== NULL
|| !IS_ELIGIBLE(a
) || a
->drouter
== a
->router_id
)
533 else if (b
== NULL
|| !IS_ELIGIBLE(b
) || b
->drouter
== b
->router_id
)
536 if (a
->bdrouter
== a
->router_id
&& b
->bdrouter
!= b
->router_id
)
538 if (a
->bdrouter
!= a
->router_id
&& b
->bdrouter
== b
->router_id
)
541 if (a
->priority
> b
->priority
)
543 if (a
->priority
< b
->priority
)
546 if (ntohl(a
->router_id
) > ntohl(b
->router_id
))
548 if (ntohl(a
->router_id
) < ntohl(b
->router_id
))
551 zlog_warn("Router-ID duplicate ?");
555 static struct ospf6_neighbor
*better_drouter(struct ospf6_neighbor
*a
,
556 struct ospf6_neighbor
*b
)
558 if ((a
== NULL
|| !IS_ELIGIBLE(a
) || a
->drouter
!= a
->router_id
)
559 && (b
== NULL
|| !IS_ELIGIBLE(b
) || b
->drouter
!= b
->router_id
))
561 else if (a
== NULL
|| !IS_ELIGIBLE(a
) || a
->drouter
!= a
->router_id
)
563 else if (b
== NULL
|| !IS_ELIGIBLE(b
) || b
->drouter
!= b
->router_id
)
566 if (a
->drouter
== a
->router_id
&& b
->drouter
!= b
->router_id
)
568 if (a
->drouter
!= a
->router_id
&& b
->drouter
== b
->router_id
)
571 if (a
->priority
> b
->priority
)
573 if (a
->priority
< b
->priority
)
576 if (ntohl(a
->router_id
) > ntohl(b
->router_id
))
578 if (ntohl(a
->router_id
) < ntohl(b
->router_id
))
581 zlog_warn("Router-ID duplicate ?");
585 static uint8_t dr_election(struct ospf6_interface
*oi
)
587 struct listnode
*node
, *nnode
;
588 struct ospf6_neighbor
*on
, *drouter
, *bdrouter
, myself
;
589 struct ospf6_neighbor
*best_drouter
, *best_bdrouter
;
590 uint8_t next_state
= 0;
592 drouter
= bdrouter
= NULL
;
593 best_drouter
= best_bdrouter
= NULL
;
595 /* pseudo neighbor myself, including noting current DR/BDR (1) */
596 memset(&myself
, 0, sizeof(myself
));
597 inet_ntop(AF_INET
, &oi
->area
->ospf6
->router_id
, myself
.name
,
598 sizeof(myself
.name
));
599 myself
.state
= OSPF6_NEIGHBOR_TWOWAY
;
600 myself
.drouter
= oi
->drouter
;
601 myself
.bdrouter
= oi
->bdrouter
;
602 myself
.priority
= oi
->priority
;
603 myself
.router_id
= oi
->area
->ospf6
->router_id
;
605 /* Electing BDR (2) */
606 for (ALL_LIST_ELEMENTS(oi
->neighbor_list
, node
, nnode
, on
))
607 bdrouter
= better_bdrouter(bdrouter
, on
);
609 best_bdrouter
= bdrouter
;
610 bdrouter
= better_bdrouter(best_bdrouter
, &myself
);
612 /* Electing DR (3) */
613 for (ALL_LIST_ELEMENTS(oi
->neighbor_list
, node
, nnode
, on
))
614 drouter
= better_drouter(drouter
, on
);
616 best_drouter
= drouter
;
617 drouter
= better_drouter(best_drouter
, &myself
);
621 /* the router itself is newly/no longer DR/BDR (4) */
622 if ((drouter
== &myself
&& myself
.drouter
!= myself
.router_id
)
623 || (drouter
!= &myself
&& myself
.drouter
== myself
.router_id
)
624 || (bdrouter
== &myself
&& myself
.bdrouter
!= myself
.router_id
)
625 || (bdrouter
!= &myself
&& myself
.bdrouter
== myself
.router_id
)) {
626 myself
.drouter
= (drouter
? drouter
->router_id
: htonl(0));
627 myself
.bdrouter
= (bdrouter
? bdrouter
->router_id
: htonl(0));
629 /* compatible to Electing BDR (2) */
630 bdrouter
= better_bdrouter(best_bdrouter
, &myself
);
632 /* compatible to Electing DR (3) */
633 drouter
= better_drouter(best_drouter
, &myself
);
638 /* Set interface state accordingly (5) */
639 if (drouter
&& drouter
== &myself
)
640 next_state
= OSPF6_INTERFACE_DR
;
641 else if (bdrouter
&& bdrouter
== &myself
)
642 next_state
= OSPF6_INTERFACE_BDR
;
644 next_state
= OSPF6_INTERFACE_DROTHER
;
646 /* If NBMA, schedule Start for each neighbor having priority of 0 (6) */
649 /* If DR or BDR change, invoke AdjOK? for each neighbor (7) */
650 /* RFC 2328 section 12.4. Originating LSAs (3) will be handled
651 accordingly after AdjOK */
652 if (oi
->drouter
!= (drouter
? drouter
->router_id
: htonl(0))
653 || oi
->bdrouter
!= (bdrouter
? bdrouter
->router_id
: htonl(0))) {
654 if (IS_OSPF6_DEBUG_INTERFACE
)
655 zlog_debug("DR Election on %s: DR: %s BDR: %s",
657 (drouter
? drouter
->name
: "0.0.0.0"),
658 (bdrouter
? bdrouter
->name
: "0.0.0.0"));
660 for (ALL_LIST_ELEMENTS_RO(oi
->neighbor_list
, node
, on
)) {
661 if (on
->state
< OSPF6_NEIGHBOR_TWOWAY
)
663 /* Schedule AdjOK. */
664 thread_add_event(master
, adj_ok
, on
, 0, NULL
);
668 oi
->drouter
= (drouter
? drouter
->router_id
: htonl(0));
669 oi
->bdrouter
= (bdrouter
? bdrouter
->router_id
: htonl(0));
674 /* Interface State Machine */
675 int interface_up(struct thread
*thread
)
677 struct ospf6_interface
*oi
;
679 oi
= (struct ospf6_interface
*)THREAD_ARG(thread
);
680 assert(oi
&& oi
->interface
);
682 if (IS_OSPF6_DEBUG_INTERFACE
)
683 zlog_debug("Interface Event %s: [InterfaceUp]",
684 oi
->interface
->name
);
686 /* check physical interface is up */
687 if (!if_is_operative(oi
->interface
)) {
688 if (IS_OSPF6_DEBUG_INTERFACE
)
690 "Interface %s is down, can't execute [InterfaceUp]",
691 oi
->interface
->name
);
695 /* check interface has a link-local address */
696 if (!(ospf6_interface_get_linklocal_address(oi
->interface
)
697 || if_is_loopback(oi
->interface
))) {
698 if (IS_OSPF6_DEBUG_INTERFACE
)
700 "Interface %s has no link local address, can't execute [InterfaceUp]",
701 oi
->interface
->name
);
706 ospf6_interface_recalculate_cost(oi
);
708 /* if already enabled, do nothing */
709 if (oi
->state
> OSPF6_INTERFACE_DOWN
) {
710 if (IS_OSPF6_DEBUG_INTERFACE
)
711 zlog_debug("Interface %s already enabled",
712 oi
->interface
->name
);
716 /* If no area assigned, return */
717 if (oi
->area
== NULL
) {
719 "%s: Not scheduleing Hello for %s as there is no area assigned yet",
720 __func__
, oi
->interface
->name
);
724 /* Join AllSPFRouters */
725 if (ospf6_sso(oi
->interface
->ifindex
, &allspfrouters6
, IPV6_JOIN_GROUP
)
727 if (oi
->sso_try_cnt
++ < OSPF6_INTERFACE_SSO_RETRY_MAX
) {
729 "Scheduling %s for sso retry, trial count: %d",
730 oi
->interface
->name
, oi
->sso_try_cnt
);
731 thread_add_timer(master
, interface_up
, oi
,
732 OSPF6_INTERFACE_SSO_RETRY_INT
, NULL
);
736 oi
->sso_try_cnt
= 0; /* Reset on success */
738 /* Update interface route */
739 ospf6_interface_connected_route_update(oi
->interface
);
742 if (!CHECK_FLAG(oi
->flag
, OSPF6_INTERFACE_PASSIVE
)
743 && !if_is_loopback(oi
->interface
)) {
744 oi
->thread_send_hello
= NULL
;
745 thread_add_event(master
, ospf6_hello_send
, oi
, 0,
746 &oi
->thread_send_hello
);
749 /* decide next interface state */
750 if ((if_is_pointopoint(oi
->interface
))
751 || (oi
->type
== OSPF_IFTYPE_POINTOPOINT
)) {
752 ospf6_interface_state_change(OSPF6_INTERFACE_POINTTOPOINT
, oi
);
753 } else if (oi
->priority
== 0)
754 ospf6_interface_state_change(OSPF6_INTERFACE_DROTHER
, oi
);
756 ospf6_interface_state_change(OSPF6_INTERFACE_WAITING
, oi
);
757 thread_add_timer(master
, wait_timer
, oi
, oi
->dead_interval
,
764 int wait_timer(struct thread
*thread
)
766 struct ospf6_interface
*oi
;
768 oi
= (struct ospf6_interface
*)THREAD_ARG(thread
);
769 assert(oi
&& oi
->interface
);
771 if (IS_OSPF6_DEBUG_INTERFACE
)
772 zlog_debug("Interface Event %s: [WaitTimer]",
773 oi
->interface
->name
);
775 if (oi
->state
== OSPF6_INTERFACE_WAITING
)
776 ospf6_interface_state_change(dr_election(oi
), oi
);
781 int backup_seen(struct thread
*thread
)
783 struct ospf6_interface
*oi
;
785 oi
= (struct ospf6_interface
*)THREAD_ARG(thread
);
786 assert(oi
&& oi
->interface
);
788 if (IS_OSPF6_DEBUG_INTERFACE
)
789 zlog_debug("Interface Event %s: [BackupSeen]",
790 oi
->interface
->name
);
792 if (oi
->state
== OSPF6_INTERFACE_WAITING
)
793 ospf6_interface_state_change(dr_election(oi
), oi
);
798 int neighbor_change(struct thread
*thread
)
800 struct ospf6_interface
*oi
;
802 oi
= (struct ospf6_interface
*)THREAD_ARG(thread
);
803 assert(oi
&& oi
->interface
);
805 if (IS_OSPF6_DEBUG_INTERFACE
)
806 zlog_debug("Interface Event %s: [NeighborChange]",
807 oi
->interface
->name
);
809 if (oi
->state
== OSPF6_INTERFACE_DROTHER
810 || oi
->state
== OSPF6_INTERFACE_BDR
811 || oi
->state
== OSPF6_INTERFACE_DR
)
812 ospf6_interface_state_change(dr_election(oi
), oi
);
817 int interface_down(struct thread
*thread
)
819 struct ospf6_interface
*oi
;
820 struct listnode
*node
, *nnode
;
821 struct ospf6_neighbor
*on
;
823 oi
= (struct ospf6_interface
*)THREAD_ARG(thread
);
824 assert(oi
&& oi
->interface
);
826 if (IS_OSPF6_DEBUG_INTERFACE
)
827 zlog_debug("Interface Event %s: [InterfaceDown]",
828 oi
->interface
->name
);
831 THREAD_OFF(oi
->thread_send_hello
);
833 /* Leave AllSPFRouters */
834 if (oi
->state
> OSPF6_INTERFACE_DOWN
)
835 ospf6_sso(oi
->interface
->ifindex
, &allspfrouters6
,
838 ospf6_interface_state_change(OSPF6_INTERFACE_DOWN
, oi
);
840 for (ALL_LIST_ELEMENTS(oi
->neighbor_list
, node
, nnode
, on
))
841 ospf6_neighbor_delete(on
);
843 list_delete_all_node(oi
->neighbor_list
);
845 /* When interface state is reset, also reset information about
846 * DR election, as it is no longer valid. */
847 oi
->drouter
= oi
->prev_drouter
= htonl(0);
848 oi
->bdrouter
= oi
->prev_bdrouter
= htonl(0);
853 /* show specified interface structure */
854 static int ospf6_interface_show(struct vty
*vty
, struct interface
*ifp
)
856 struct ospf6_interface
*oi
;
860 char strbuf
[PREFIX2STR_BUFFER
], drouter
[32], bdrouter
[32];
862 struct timeval res
, now
;
864 struct ospf6_lsa
*lsa
;
866 /* check physical interface type */
867 if (if_is_loopback(ifp
))
869 else if (if_is_broadcast(ifp
))
871 else if (if_is_pointopoint(ifp
))
872 type
= "POINTOPOINT";
876 vty_out(vty
, "%s is %s, type %s\n", ifp
->name
,
877 (if_is_operative(ifp
) ? "up" : "down"), type
);
878 vty_out(vty
, " Interface ID: %d\n", ifp
->ifindex
);
880 if (ifp
->info
== NULL
) {
881 vty_out(vty
, " OSPF not enabled on this interface\n");
884 oi
= (struct ospf6_interface
*)ifp
->info
;
886 vty_out(vty
, " Internet Address:\n");
888 for (ALL_LIST_ELEMENTS_RO(ifp
->connected
, i
, c
)) {
890 prefix2str(p
, strbuf
, sizeof(strbuf
));
893 vty_out(vty
, " inet : %s\n", strbuf
);
896 vty_out(vty
, " inet6: %s\n", strbuf
);
899 vty_out(vty
, " ??? : %s\n", strbuf
);
906 " Instance ID %d, Interface MTU %d (autodetect: %d)\n",
907 oi
->instance_id
, oi
->ifmtu
, ifp
->mtu6
);
908 vty_out(vty
, " MTU mismatch detection: %s\n",
909 oi
->mtu_ignore
? "disabled" : "enabled");
910 inet_ntop(AF_INET
, &oi
->area
->area_id
, strbuf
, sizeof(strbuf
));
911 vty_out(vty
, " Area ID %s, Cost %u\n", strbuf
, oi
->cost
);
913 vty_out(vty
, " Not Attached to Area\n");
915 vty_out(vty
, " State %s, Transmit Delay %d sec, Priority %d\n",
916 ospf6_interface_state_str
[oi
->state
], oi
->transdelay
,
918 vty_out(vty
, " Timer intervals configured:\n");
919 vty_out(vty
, " Hello %d, Dead %d, Retransmit %d\n",
920 oi
->hello_interval
, oi
->dead_interval
, oi
->rxmt_interval
);
922 inet_ntop(AF_INET
, &oi
->drouter
, drouter
, sizeof(drouter
));
923 inet_ntop(AF_INET
, &oi
->bdrouter
, bdrouter
, sizeof(bdrouter
));
924 vty_out(vty
, " DR: %s BDR: %s\n", drouter
, bdrouter
);
926 vty_out(vty
, " Number of I/F scoped LSAs is %u\n", oi
->lsdb
->count
);
931 if (oi
->thread_send_lsupdate
)
932 timersub(&oi
->thread_send_lsupdate
->u
.sands
, &now
, &res
);
933 timerstring(&res
, duration
, sizeof(duration
));
935 " %d Pending LSAs for LSUpdate in Time %s [thread %s]\n",
936 oi
->lsupdate_list
->count
, duration
,
937 (oi
->thread_send_lsupdate
? "on" : "off"));
938 for (ALL_LSDB(oi
->lsupdate_list
, lsa
))
939 vty_out(vty
, " %s\n", lsa
->name
);
942 if (oi
->thread_send_lsack
)
943 timersub(&oi
->thread_send_lsack
->u
.sands
, &now
, &res
);
944 timerstring(&res
, duration
, sizeof(duration
));
945 vty_out(vty
, " %d Pending LSAs for LSAck in Time %s [thread %s]\n",
946 oi
->lsack_list
->count
, duration
,
947 (oi
->thread_send_lsack
? "on" : "off"));
948 for (ALL_LSDB(oi
->lsack_list
, lsa
))
949 vty_out(vty
, " %s\n", lsa
->name
);
950 ospf6_bfd_show_info(vty
, oi
->bfd_info
, 1);
955 DEFUN (show_ipv6_ospf6_interface
,
956 show_ipv6_ospf6_interface_ifname_cmd
,
957 "show ipv6 ospf6 interface [IFNAME]",
964 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
966 struct interface
*ifp
;
969 ifp
= if_lookup_by_name(argv
[idx_ifname
]->arg
, VRF_DEFAULT
);
971 vty_out(vty
, "No such Interface: %s\n",
972 argv
[idx_ifname
]->arg
);
975 ospf6_interface_show(vty
, ifp
);
977 FOR_ALL_INTERFACES (vrf
, ifp
)
978 ospf6_interface_show(vty
, ifp
);
984 static int ospf6_interface_show_traffic(struct vty
*vty
, uint32_t vrf_id
,
985 struct interface
*intf_ifp
,
988 struct interface
*ifp
;
989 struct vrf
*vrf
= NULL
;
990 struct ospf6_interface
*oi
= NULL
;
992 vrf
= vrf_lookup_by_id(vrf_id
);
996 vty_out(vty
, "%-12s%-17s%-17s%-17s%-17s%-17s\n", "Interface",
997 " HELLO", " DB-Desc", " LS-Req", " LS-Update",
999 vty_out(vty
, "%-10s%-18s%-18s%-17s%-17s%-17s\n", "",
1000 " Rx/Tx", " Rx/Tx", " Rx/Tx", " Rx/Tx",
1003 "--------------------------------------------------------------------------------------------\n");
1006 if (intf_ifp
== NULL
) {
1007 FOR_ALL_INTERFACES (vrf
, ifp
) {
1009 oi
= (struct ospf6_interface
*)ifp
->info
;
1014 "%-10s %8u/%-8u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u\n",
1015 oi
->interface
->name
, oi
->hello_in
,
1016 oi
->hello_out
, oi
->db_desc_in
, oi
->db_desc_out
,
1017 oi
->ls_req_in
, oi
->ls_req_out
, oi
->ls_upd_in
,
1018 oi
->ls_upd_out
, oi
->ls_ack_in
, oi
->ls_ack_out
);
1021 oi
= intf_ifp
->info
;
1026 "%-10s %8u/%-8u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u\n",
1027 oi
->interface
->name
, oi
->hello_in
, oi
->hello_out
,
1028 oi
->db_desc_in
, oi
->db_desc_out
, oi
->ls_req_in
,
1029 oi
->ls_req_out
, oi
->ls_upd_in
, oi
->ls_upd_out
,
1030 oi
->ls_ack_in
, oi
->ls_ack_out
);
1036 /* show interface */
1037 DEFUN (show_ipv6_ospf6_interface_traffic
,
1038 show_ipv6_ospf6_interface_traffic_cmd
,
1039 "show ipv6 ospf6 interface traffic [IFNAME]",
1044 "Protocol Packet counters\n"
1048 int display_once
= 0;
1049 char *intf_name
= NULL
;
1050 struct interface
*ifp
= NULL
;
1052 if (argv_find(argv
, argc
, "IFNAME", &idx_ifname
)) {
1053 intf_name
= argv
[idx_ifname
]->arg
;
1054 ifp
= if_lookup_by_name(intf_name
, VRF_DEFAULT
);
1056 vty_out(vty
, "No such Interface: %s\n", intf_name
);
1059 if (ifp
->info
== NULL
) {
1061 " OSPF not enabled on this interface %s\n",
1067 ospf6_interface_show_traffic(vty
, VRF_DEFAULT
, ifp
, display_once
);
1074 DEFUN (show_ipv6_ospf6_interface_ifname_prefix
,
1075 show_ipv6_ospf6_interface_ifname_prefix_cmd
,
1076 "show ipv6 ospf6 interface IFNAME prefix\
1079 |<X:X::X:X|X:X::X:X/M> [<match|detail>]\
1086 "Display connected prefixes to advertise\n"
1087 "Display details of the prefixes\n"
1088 OSPF6_ROUTE_ADDRESS_STR
1089 OSPF6_ROUTE_PREFIX_STR
1090 OSPF6_ROUTE_MATCH_STR
1091 "Display details of the prefixes\n")
1095 struct interface
*ifp
;
1096 struct ospf6_interface
*oi
;
1098 ifp
= if_lookup_by_name(argv
[idx_ifname
]->arg
, VRF_DEFAULT
);
1100 vty_out(vty
, "No such Interface: %s\n", argv
[idx_ifname
]->arg
);
1106 vty_out(vty
, "OSPFv3 is not enabled on %s\n",
1107 argv
[idx_ifname
]->arg
);
1111 ospf6_route_table_show(vty
, idx_prefix
, argc
, argv
,
1112 oi
->route_connected
);
1117 DEFUN (show_ipv6_ospf6_interface_prefix
,
1118 show_ipv6_ospf6_interface_prefix_cmd
,
1119 "show ipv6 ospf6 interface prefix\
1122 |<X:X::X:X|X:X::X:X/M> [<match|detail>]\
1128 "Display connected prefixes to advertise\n"
1129 "Display details of the prefixes\n"
1130 OSPF6_ROUTE_ADDRESS_STR
1131 OSPF6_ROUTE_PREFIX_STR
1132 OSPF6_ROUTE_MATCH_STR
1133 "Display details of the prefixes\n")
1135 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
1137 struct ospf6_interface
*oi
;
1138 struct interface
*ifp
;
1140 FOR_ALL_INTERFACES (vrf
, ifp
) {
1141 oi
= (struct ospf6_interface
*)ifp
->info
;
1145 ospf6_route_table_show(vty
, idx_prefix
, argc
, argv
,
1146 oi
->route_connected
);
1152 /* interface variable set command */
1153 DEFUN (ipv6_ospf6_ifmtu
,
1154 ipv6_ospf6_ifmtu_cmd
,
1155 "ipv6 ospf6 ifmtu (1-65535)",
1159 "OSPFv3 Interface MTU\n"
1162 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1164 struct ospf6_interface
*oi
;
1165 unsigned int ifmtu
, iobuflen
;
1166 struct listnode
*node
, *nnode
;
1167 struct ospf6_neighbor
*on
;
1171 oi
= (struct ospf6_interface
*)ifp
->info
;
1173 oi
= ospf6_interface_create(ifp
);
1176 ifmtu
= strtol(argv
[idx_number
]->arg
, NULL
, 10);
1178 if (oi
->c_ifmtu
== ifmtu
)
1181 if (ifp
->mtu6
!= 0 && ifp
->mtu6
< ifmtu
) {
1183 "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)\n",
1184 ifp
->name
, ifp
->mtu6
);
1185 return CMD_WARNING_CONFIG_FAILED
;
1188 if (oi
->ifmtu
< ifmtu
) {
1189 iobuflen
= ospf6_iobuf_size(ifmtu
);
1190 if (iobuflen
< ifmtu
) {
1192 "%s's ifmtu is adjusted to I/O buffer size (%d).\n",
1193 ifp
->name
, iobuflen
);
1194 oi
->ifmtu
= oi
->c_ifmtu
= iobuflen
;
1196 oi
->ifmtu
= oi
->c_ifmtu
= ifmtu
;
1198 oi
->ifmtu
= oi
->c_ifmtu
= ifmtu
;
1200 /* re-establish adjacencies */
1201 for (ALL_LIST_ELEMENTS(oi
->neighbor_list
, node
, nnode
, on
)) {
1202 THREAD_OFF(on
->inactivity_timer
);
1203 thread_add_event(master
, inactivity_timer
, on
, 0, NULL
);
1209 DEFUN (no_ipv6_ospf6_ifmtu
,
1210 no_ipv6_ospf6_ifmtu_cmd
,
1211 "no ipv6 ospf6 ifmtu [(1-65535)]",
1216 "OSPFv3 Interface MTU\n"
1219 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1220 struct ospf6_interface
*oi
;
1221 unsigned int iobuflen
;
1222 struct listnode
*node
, *nnode
;
1223 struct ospf6_neighbor
*on
;
1227 oi
= (struct ospf6_interface
*)ifp
->info
;
1229 oi
= ospf6_interface_create(ifp
);
1232 if (oi
->ifmtu
< ifp
->mtu
) {
1233 iobuflen
= ospf6_iobuf_size(ifp
->mtu
);
1234 if (iobuflen
< ifp
->mtu
) {
1236 "%s's ifmtu is adjusted to I/O buffer size (%d).\n",
1237 ifp
->name
, iobuflen
);
1238 oi
->ifmtu
= iobuflen
;
1240 oi
->ifmtu
= ifp
->mtu
;
1242 oi
->ifmtu
= ifp
->mtu
;
1246 /* re-establish adjacencies */
1247 for (ALL_LIST_ELEMENTS(oi
->neighbor_list
, node
, nnode
, on
)) {
1248 THREAD_OFF(on
->inactivity_timer
);
1249 thread_add_event(master
, inactivity_timer
, on
, 0, NULL
);
1255 DEFUN (ipv6_ospf6_cost
,
1256 ipv6_ospf6_cost_cmd
,
1257 "ipv6 ospf6 cost (1-65535)",
1261 "Outgoing metric of this interface\n")
1263 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1265 struct ospf6_interface
*oi
;
1266 unsigned long int lcost
;
1270 oi
= (struct ospf6_interface
*)ifp
->info
;
1272 oi
= ospf6_interface_create(ifp
);
1275 lcost
= strtol(argv
[idx_number
]->arg
, NULL
, 10);
1277 if (lcost
> UINT32_MAX
) {
1278 vty_out(vty
, "Cost %ld is out of range\n", lcost
);
1279 return CMD_WARNING_CONFIG_FAILED
;
1282 if (oi
->cost
== lcost
)
1286 SET_FLAG(oi
->flag
, OSPF6_INTERFACE_NOAUTOCOST
);
1288 ospf6_interface_force_recalculate_cost(oi
);
1293 DEFUN (no_ipv6_ospf6_cost
,
1294 no_ipv6_ospf6_cost_cmd
,
1295 "no ipv6 ospf6 cost [(1-65535)]",
1299 "Calculate interface cost from bandwidth\n"
1300 "Outgoing metric of this interface\n")
1302 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1303 struct ospf6_interface
*oi
;
1306 oi
= (struct ospf6_interface
*)ifp
->info
;
1308 oi
= ospf6_interface_create(ifp
);
1311 UNSET_FLAG(oi
->flag
, OSPF6_INTERFACE_NOAUTOCOST
);
1313 ospf6_interface_recalculate_cost(oi
);
1318 DEFUN (auto_cost_reference_bandwidth
,
1319 auto_cost_reference_bandwidth_cmd
,
1320 "auto-cost reference-bandwidth (1-4294967)",
1321 "Calculate OSPF interface cost according to bandwidth\n"
1322 "Use reference bandwidth method to assign OSPF cost\n"
1323 "The reference bandwidth in terms of Mbits per second\n")
1325 VTY_DECLVAR_CONTEXT(ospf6
, o
);
1327 struct ospf6_area
*oa
;
1328 struct ospf6_interface
*oi
;
1329 struct listnode
*i
, *j
;
1332 refbw
= strtol(argv
[idx_number
]->arg
, NULL
, 10);
1333 if (refbw
< 1 || refbw
> 4294967) {
1334 vty_out(vty
, "reference-bandwidth value is invalid\n");
1335 return CMD_WARNING_CONFIG_FAILED
;
1338 /* If reference bandwidth is changed. */
1339 if ((refbw
) == o
->ref_bandwidth
)
1342 o
->ref_bandwidth
= refbw
;
1343 for (ALL_LIST_ELEMENTS_RO(o
->area_list
, i
, oa
))
1344 for (ALL_LIST_ELEMENTS_RO(oa
->if_list
, j
, oi
))
1345 ospf6_interface_recalculate_cost(oi
);
1350 DEFUN (no_auto_cost_reference_bandwidth
,
1351 no_auto_cost_reference_bandwidth_cmd
,
1352 "no auto-cost reference-bandwidth [(1-4294967)]",
1354 "Calculate OSPF interface cost according to bandwidth\n"
1355 "Use reference bandwidth method to assign OSPF cost\n"
1356 "The reference bandwidth in terms of Mbits per second\n")
1358 VTY_DECLVAR_CONTEXT(ospf6
, o
);
1359 struct ospf6_area
*oa
;
1360 struct ospf6_interface
*oi
;
1361 struct listnode
*i
, *j
;
1363 if (o
->ref_bandwidth
== OSPF6_REFERENCE_BANDWIDTH
)
1366 o
->ref_bandwidth
= OSPF6_REFERENCE_BANDWIDTH
;
1367 for (ALL_LIST_ELEMENTS_RO(o
->area_list
, i
, oa
))
1368 for (ALL_LIST_ELEMENTS_RO(oa
->if_list
, j
, oi
))
1369 ospf6_interface_recalculate_cost(oi
);
1375 DEFUN (ipv6_ospf6_hellointerval
,
1376 ipv6_ospf6_hellointerval_cmd
,
1377 "ipv6 ospf6 hello-interval (1-65535)",
1380 "Time between HELLO packets\n"
1383 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1385 struct ospf6_interface
*oi
;
1388 oi
= (struct ospf6_interface
*)ifp
->info
;
1390 oi
= ospf6_interface_create(ifp
);
1393 oi
->hello_interval
= strmatch(argv
[0]->text
, "no")
1394 ? OSPF_HELLO_INTERVAL_DEFAULT
1395 : strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1399 ALIAS (ipv6_ospf6_hellointerval
,
1400 no_ipv6_ospf6_hellointerval_cmd
,
1401 "no ipv6 ospf6 hello-interval [(1-65535)]",
1405 "Time between HELLO packets\n"
1408 /* interface variable set command */
1409 DEFUN (ipv6_ospf6_deadinterval
,
1410 ipv6_ospf6_deadinterval_cmd
,
1411 "ipv6 ospf6 dead-interval (1-65535)",
1414 "Interval time after which a neighbor is declared down\n"
1417 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1419 struct ospf6_interface
*oi
;
1422 oi
= (struct ospf6_interface
*)ifp
->info
;
1424 oi
= ospf6_interface_create(ifp
);
1427 oi
->dead_interval
= strmatch(argv
[0]->arg
, "no")
1428 ? OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
1429 : strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1433 ALIAS (ipv6_ospf6_deadinterval
,
1434 no_ipv6_ospf6_deadinterval_cmd
,
1435 "no ipv6 ospf6 dead-interval [(1-65535)]",
1439 "Interval time after which a neighbor is declared down\n"
1442 /* interface variable set command */
1443 DEFUN (ipv6_ospf6_transmitdelay
,
1444 ipv6_ospf6_transmitdelay_cmd
,
1445 "ipv6 ospf6 transmit-delay (1-3600)",
1448 "Link state transmit delay\n"
1451 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1453 struct ospf6_interface
*oi
;
1456 oi
= (struct ospf6_interface
*)ifp
->info
;
1458 oi
= ospf6_interface_create(ifp
);
1461 oi
->transdelay
= strmatch(argv
[0]->text
, "no")
1462 ? OSPF6_INTERFACE_TRANSDELAY
1463 : strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1467 ALIAS (ipv6_ospf6_transmitdelay
,
1468 no_ipv6_ospf6_transmitdelay_cmd
,
1469 "no ipv6 ospf6 transmit-delay [(1-3600)]",
1473 "Link state transmit delay\n"
1476 /* interface variable set command */
1477 DEFUN (ipv6_ospf6_retransmitinterval
,
1478 ipv6_ospf6_retransmitinterval_cmd
,
1479 "ipv6 ospf6 retransmit-interval (1-65535)",
1482 "Time between retransmitting lost link state advertisements\n"
1485 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1487 struct ospf6_interface
*oi
;
1490 oi
= (struct ospf6_interface
*)ifp
->info
;
1492 oi
= ospf6_interface_create(ifp
);
1495 oi
->rxmt_interval
= strmatch(argv
[0]->text
, "no")
1496 ? OSPF_RETRANSMIT_INTERVAL_DEFAULT
1497 : strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1501 ALIAS (ipv6_ospf6_retransmitinterval
,
1502 no_ipv6_ospf6_retransmitinterval_cmd
,
1503 "no ipv6 ospf6 retransmit-interval [(1-65535)]",
1507 "Time between retransmitting lost link state advertisements\n"
1510 /* interface variable set command */
1511 DEFUN (ipv6_ospf6_priority
,
1512 ipv6_ospf6_priority_cmd
,
1513 "ipv6 ospf6 priority (0-255)",
1519 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1521 struct ospf6_interface
*oi
;
1524 oi
= (struct ospf6_interface
*)ifp
->info
;
1526 oi
= ospf6_interface_create(ifp
);
1529 oi
->priority
= strmatch(argv
[0]->text
, "no")
1530 ? OSPF6_INTERFACE_PRIORITY
1531 : strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1533 if (oi
->area
&& (oi
->state
== OSPF6_INTERFACE_DROTHER
1534 || oi
->state
== OSPF6_INTERFACE_BDR
1535 || oi
->state
== OSPF6_INTERFACE_DR
))
1536 ospf6_interface_state_change(dr_election(oi
), oi
);
1541 ALIAS (ipv6_ospf6_priority
,
1542 no_ipv6_ospf6_priority_cmd
,
1543 "no ipv6 ospf6 priority [(0-255)]",
1550 DEFUN (ipv6_ospf6_instance
,
1551 ipv6_ospf6_instance_cmd
,
1552 "ipv6 ospf6 instance-id (0-255)",
1555 "Instance ID for this interface\n"
1556 "Instance ID value\n")
1558 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1560 struct ospf6_interface
*oi
;
1563 oi
= (struct ospf6_interface
*)ifp
->info
;
1565 oi
= ospf6_interface_create(ifp
);
1568 oi
->instance_id
= strmatch(argv
[0]->text
, "no")
1569 ? OSPF6_INTERFACE_INSTANCE_ID
1570 : strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1574 ALIAS (ipv6_ospf6_instance
,
1575 no_ipv6_ospf6_instance_cmd
,
1576 "no ipv6 ospf6 instance-id [(0-255)]",
1580 "Instance ID for this interface\n"
1581 "Instance ID value\n")
1583 DEFUN (ipv6_ospf6_passive
,
1584 ipv6_ospf6_passive_cmd
,
1585 "ipv6 ospf6 passive",
1588 "Passive interface; no adjacency will be formed on this interface\n"
1591 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1592 struct ospf6_interface
*oi
;
1593 struct listnode
*node
, *nnode
;
1594 struct ospf6_neighbor
*on
;
1598 oi
= (struct ospf6_interface
*)ifp
->info
;
1600 oi
= ospf6_interface_create(ifp
);
1603 SET_FLAG(oi
->flag
, OSPF6_INTERFACE_PASSIVE
);
1604 THREAD_OFF(oi
->thread_send_hello
);
1606 for (ALL_LIST_ELEMENTS(oi
->neighbor_list
, node
, nnode
, on
)) {
1607 THREAD_OFF(on
->inactivity_timer
);
1608 thread_add_event(master
, inactivity_timer
, on
, 0, NULL
);
1614 DEFUN (no_ipv6_ospf6_passive
,
1615 no_ipv6_ospf6_passive_cmd
,
1616 "no ipv6 ospf6 passive",
1620 "passive interface: No Adjacency will be formed on this I/F\n"
1623 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1624 struct ospf6_interface
*oi
;
1627 oi
= (struct ospf6_interface
*)ifp
->info
;
1629 oi
= ospf6_interface_create(ifp
);
1632 UNSET_FLAG(oi
->flag
, OSPF6_INTERFACE_PASSIVE
);
1633 THREAD_OFF(oi
->thread_send_hello
);
1634 oi
->thread_send_hello
= NULL
;
1635 thread_add_event(master
, ospf6_hello_send
, oi
, 0,
1636 &oi
->thread_send_hello
);
1641 DEFUN (ipv6_ospf6_mtu_ignore
,
1642 ipv6_ospf6_mtu_ignore_cmd
,
1643 "ipv6 ospf6 mtu-ignore",
1646 "Disable MTU mismatch detection on this interface\n"
1649 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1650 struct ospf6_interface
*oi
;
1653 oi
= (struct ospf6_interface
*)ifp
->info
;
1655 oi
= ospf6_interface_create(ifp
);
1663 DEFUN (no_ipv6_ospf6_mtu_ignore
,
1664 no_ipv6_ospf6_mtu_ignore_cmd
,
1665 "no ipv6 ospf6 mtu-ignore",
1669 "Disable MTU mismatch detection on this interface\n"
1672 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1673 struct ospf6_interface
*oi
;
1676 oi
= (struct ospf6_interface
*)ifp
->info
;
1678 oi
= ospf6_interface_create(ifp
);
1686 DEFUN (ipv6_ospf6_advertise_prefix_list
,
1687 ipv6_ospf6_advertise_prefix_list_cmd
,
1688 "ipv6 ospf6 advertise prefix-list WORD",
1691 "Advertising options\n"
1692 "Filter prefix using prefix-list\n"
1693 "Prefix list name\n"
1696 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1698 struct ospf6_interface
*oi
;
1701 oi
= (struct ospf6_interface
*)ifp
->info
;
1703 oi
= ospf6_interface_create(ifp
);
1707 XFREE(MTYPE_CFG_PLIST_NAME
, oi
->plist_name
);
1708 oi
->plist_name
= XSTRDUP(MTYPE_CFG_PLIST_NAME
, argv
[idx_word
]->arg
);
1710 ospf6_interface_connected_route_update(oi
->interface
);
1713 OSPF6_LINK_LSA_SCHEDULE(oi
);
1714 if (oi
->state
== OSPF6_INTERFACE_DR
) {
1715 OSPF6_NETWORK_LSA_SCHEDULE(oi
);
1716 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(oi
);
1718 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(oi
->area
);
1724 DEFUN (no_ipv6_ospf6_advertise_prefix_list
,
1725 no_ipv6_ospf6_advertise_prefix_list_cmd
,
1726 "no ipv6 ospf6 advertise prefix-list [WORD]",
1730 "Advertising options\n"
1731 "Filter prefix using prefix-list\n"
1732 "Prefix list name\n")
1734 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1735 struct ospf6_interface
*oi
;
1738 oi
= (struct ospf6_interface
*)ifp
->info
;
1740 oi
= ospf6_interface_create(ifp
);
1744 XFREE(MTYPE_CFG_PLIST_NAME
, oi
->plist_name
);
1746 ospf6_interface_connected_route_update(oi
->interface
);
1749 OSPF6_LINK_LSA_SCHEDULE(oi
);
1750 if (oi
->state
== OSPF6_INTERFACE_DR
) {
1751 OSPF6_NETWORK_LSA_SCHEDULE(oi
);
1752 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(oi
);
1754 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(oi
->area
);
1760 DEFUN (ipv6_ospf6_network
,
1761 ipv6_ospf6_network_cmd
,
1762 "ipv6 ospf6 network <broadcast|point-to-point>",
1766 "Specify OSPF6 broadcast network\n"
1767 "Specify OSPF6 point-to-point network\n"
1770 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1771 int idx_network
= 3;
1772 struct ospf6_interface
*oi
;
1775 oi
= (struct ospf6_interface
*)ifp
->info
;
1777 oi
= ospf6_interface_create(ifp
);
1781 if (strncmp(argv
[idx_network
]->arg
, "b", 1) == 0) {
1782 if (oi
->type
== OSPF_IFTYPE_BROADCAST
)
1785 oi
->type
= OSPF_IFTYPE_BROADCAST
;
1786 } else if (strncmp(argv
[idx_network
]->arg
, "point-to-p", 10) == 0) {
1787 if (oi
->type
== OSPF_IFTYPE_POINTOPOINT
) {
1790 oi
->type
= OSPF_IFTYPE_POINTOPOINT
;
1793 /* Reset the interface */
1794 thread_execute(master
, interface_down
, oi
, 0);
1795 thread_execute(master
, interface_up
, oi
, 0);
1800 DEFUN (no_ipv6_ospf6_network
,
1801 no_ipv6_ospf6_network_cmd
,
1802 "no ipv6 ospf6 network [<broadcast|point-to-point>]",
1806 "Set default network type\n"
1807 "Specify OSPF6 broadcast network\n"
1808 "Specify OSPF6 point-to-point network\n")
1810 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1811 struct ospf6_interface
*oi
;
1816 oi
= (struct ospf6_interface
*)ifp
->info
;
1821 type
= ospf6_default_iftype(ifp
);
1822 if (oi
->type
== type
) {
1827 /* Reset the interface */
1828 thread_execute(master
, interface_down
, oi
, 0);
1829 thread_execute(master
, interface_up
, oi
, 0);
1834 static int config_write_ospf6_interface(struct vty
*vty
)
1836 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
1837 struct ospf6_interface
*oi
;
1838 struct interface
*ifp
;
1840 FOR_ALL_INTERFACES (vrf
, ifp
) {
1841 oi
= (struct ospf6_interface
*)ifp
->info
;
1845 vty_frame(vty
, "interface %s\n", oi
->interface
->name
);
1848 vty_out(vty
, " description %s\n", ifp
->desc
);
1850 vty_out(vty
, " ipv6 ospf6 ifmtu %d\n", oi
->c_ifmtu
);
1852 if (CHECK_FLAG(oi
->flag
, OSPF6_INTERFACE_NOAUTOCOST
))
1853 vty_out(vty
, " ipv6 ospf6 cost %d\n", oi
->cost
);
1855 if (oi
->hello_interval
!= OSPF6_INTERFACE_HELLO_INTERVAL
)
1856 vty_out(vty
, " ipv6 ospf6 hello-interval %d\n",
1857 oi
->hello_interval
);
1859 if (oi
->dead_interval
!= OSPF6_INTERFACE_DEAD_INTERVAL
)
1860 vty_out(vty
, " ipv6 ospf6 dead-interval %d\n",
1863 if (oi
->rxmt_interval
!= OSPF6_INTERFACE_RXMT_INTERVAL
)
1864 vty_out(vty
, " ipv6 ospf6 retransmit-interval %d\n",
1867 if (oi
->priority
!= OSPF6_INTERFACE_PRIORITY
)
1868 vty_out(vty
, " ipv6 ospf6 priority %d\n", oi
->priority
);
1870 if (oi
->transdelay
!= OSPF6_INTERFACE_TRANSDELAY
)
1871 vty_out(vty
, " ipv6 ospf6 transmit-delay %d\n",
1874 if (oi
->instance_id
!= OSPF6_INTERFACE_INSTANCE_ID
)
1875 vty_out(vty
, " ipv6 ospf6 instance-id %d\n",
1879 vty_out(vty
, " ipv6 ospf6 advertise prefix-list %s\n",
1882 if (CHECK_FLAG(oi
->flag
, OSPF6_INTERFACE_PASSIVE
))
1883 vty_out(vty
, " ipv6 ospf6 passive\n");
1886 vty_out(vty
, " ipv6 ospf6 mtu-ignore\n");
1888 if (oi
->type
!= ospf6_default_iftype(ifp
)) {
1889 if (oi
->type
== OSPF_IFTYPE_POINTOPOINT
)
1891 " ipv6 ospf6 network point-to-point\n");
1892 else if (oi
->type
== OSPF_IFTYPE_BROADCAST
)
1893 vty_out(vty
, " ipv6 ospf6 network broadcast\n");
1896 ospf6_bfd_write_config(vty
, oi
);
1898 vty_endframe(vty
, "!\n");
1903 static struct cmd_node interface_node
= {
1904 INTERFACE_NODE
, "%s(config-if)# ", 1 /* VTYSH */
1907 void ospf6_interface_init(void)
1909 /* Install interface node. */
1910 install_node(&interface_node
, config_write_ospf6_interface
);
1913 install_element(VIEW_NODE
, &show_ipv6_ospf6_interface_prefix_cmd
);
1914 install_element(VIEW_NODE
, &show_ipv6_ospf6_interface_ifname_cmd
);
1915 install_element(VIEW_NODE
,
1916 &show_ipv6_ospf6_interface_ifname_prefix_cmd
);
1917 install_element(VIEW_NODE
, &show_ipv6_ospf6_interface_traffic_cmd
);
1919 install_element(INTERFACE_NODE
, &ipv6_ospf6_cost_cmd
);
1920 install_element(INTERFACE_NODE
, &no_ipv6_ospf6_cost_cmd
);
1921 install_element(INTERFACE_NODE
, &ipv6_ospf6_ifmtu_cmd
);
1922 install_element(INTERFACE_NODE
, &no_ipv6_ospf6_ifmtu_cmd
);
1924 install_element(INTERFACE_NODE
, &ipv6_ospf6_deadinterval_cmd
);
1925 install_element(INTERFACE_NODE
, &ipv6_ospf6_hellointerval_cmd
);
1926 install_element(INTERFACE_NODE
, &ipv6_ospf6_priority_cmd
);
1927 install_element(INTERFACE_NODE
, &ipv6_ospf6_retransmitinterval_cmd
);
1928 install_element(INTERFACE_NODE
, &ipv6_ospf6_transmitdelay_cmd
);
1929 install_element(INTERFACE_NODE
, &ipv6_ospf6_instance_cmd
);
1930 install_element(INTERFACE_NODE
, &no_ipv6_ospf6_deadinterval_cmd
);
1931 install_element(INTERFACE_NODE
, &no_ipv6_ospf6_hellointerval_cmd
);
1932 install_element(INTERFACE_NODE
, &no_ipv6_ospf6_priority_cmd
);
1933 install_element(INTERFACE_NODE
, &no_ipv6_ospf6_retransmitinterval_cmd
);
1934 install_element(INTERFACE_NODE
, &no_ipv6_ospf6_transmitdelay_cmd
);
1935 install_element(INTERFACE_NODE
, &no_ipv6_ospf6_instance_cmd
);
1937 install_element(INTERFACE_NODE
, &ipv6_ospf6_passive_cmd
);
1938 install_element(INTERFACE_NODE
, &no_ipv6_ospf6_passive_cmd
);
1940 install_element(INTERFACE_NODE
, &ipv6_ospf6_mtu_ignore_cmd
);
1941 install_element(INTERFACE_NODE
, &no_ipv6_ospf6_mtu_ignore_cmd
);
1943 install_element(INTERFACE_NODE
, &ipv6_ospf6_advertise_prefix_list_cmd
);
1944 install_element(INTERFACE_NODE
,
1945 &no_ipv6_ospf6_advertise_prefix_list_cmd
);
1947 install_element(INTERFACE_NODE
, &ipv6_ospf6_network_cmd
);
1948 install_element(INTERFACE_NODE
, &no_ipv6_ospf6_network_cmd
);
1950 /* reference bandwidth commands */
1951 install_element(OSPF6_NODE
, &auto_cost_reference_bandwidth_cmd
);
1952 install_element(OSPF6_NODE
, &no_auto_cost_reference_bandwidth_cmd
);
1955 /* Clear the specified interface structure */
1956 static void ospf6_interface_clear(struct vty
*vty
, struct interface
*ifp
)
1958 struct ospf6_interface
*oi
;
1960 if (!if_is_operative(ifp
))
1963 if (ifp
->info
== NULL
)
1966 oi
= (struct ospf6_interface
*)ifp
->info
;
1968 if (IS_OSPF6_DEBUG_INTERFACE
)
1969 zlog_debug("Interface %s: clear by reset", ifp
->name
);
1971 /* Reset the interface */
1972 thread_execute(master
, interface_down
, oi
, 0);
1973 thread_execute(master
, interface_up
, oi
, 0);
1976 /* Clear interface */
1977 DEFUN (clear_ipv6_ospf6_interface
,
1978 clear_ipv6_ospf6_interface_cmd
,
1979 "clear ipv6 ospf6 interface [IFNAME]",
1987 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
1989 struct interface
*ifp
;
1991 if (argc
== 4) /* Clear all the ospfv3 interfaces. */
1993 FOR_ALL_INTERFACES (vrf
, ifp
)
1994 ospf6_interface_clear(vty
, ifp
);
1995 } else /* Interface name is specified. */
1997 if ((ifp
= if_lookup_by_name(argv
[idx_ifname
]->arg
,
2000 vty_out(vty
, "No such Interface: %s\n",
2001 argv
[idx_ifname
]->arg
);
2004 ospf6_interface_clear(vty
, ifp
);
2010 void install_element_ospf6_clear_interface(void)
2012 install_element(ENABLE_NODE
, &clear_ipv6_ospf6_interface_cmd
);
2015 DEFUN (debug_ospf6_interface
,
2016 debug_ospf6_interface_cmd
,
2017 "debug ospf6 interface",
2020 "Debug OSPFv3 Interface\n"
2023 OSPF6_DEBUG_INTERFACE_ON();
2027 DEFUN (no_debug_ospf6_interface
,
2028 no_debug_ospf6_interface_cmd
,
2029 "no debug ospf6 interface",
2033 "Debug OSPFv3 Interface\n"
2036 OSPF6_DEBUG_INTERFACE_OFF();
2040 int config_write_ospf6_debug_interface(struct vty
*vty
)
2042 if (IS_OSPF6_DEBUG_INTERFACE
)
2043 vty_out(vty
, "debug ospf6 interface\n");
2047 void install_element_ospf6_debug_interface(void)
2049 install_element(ENABLE_NODE
, &debug_ospf6_interface_cmd
);
2050 install_element(ENABLE_NODE
, &no_debug_ospf6_interface_cmd
);
2051 install_element(CONFIG_NODE
, &debug_ospf6_interface_cmd
);
2052 install_element(CONFIG_NODE
, &no_debug_ospf6_interface_cmd
);