]> git.proxmox.com Git - mirror_frr.git/blob - ospf6d/ospf6_interface.c
Merge pull request #11813 from anlancs/fix/minor-11
[mirror_frr.git] / ospf6d / ospf6_interface.c
1 /*
2 * Copyright (C) 2003 Yasuhiro Ohara
3 *
4 * This file is part of GNU Zebra.
5 *
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
9 * later version.
10 *
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.
15 *
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
19 */
20
21 #include <zebra.h>
22
23 #include "memory.h"
24 #include "if.h"
25 #include "log.h"
26 #include "command.h"
27 #include "thread.h"
28 #include "prefix.h"
29 #include "plist.h"
30 #include "zclient.h"
31
32 #include "ospf6_lsa.h"
33 #include "ospf6_lsdb.h"
34 #include "ospf6_top.h"
35 #include "ospf6_network.h"
36 #include "ospf6_message.h"
37 #include "ospf6_route.h"
38 #include "ospf6_area.h"
39 #include "ospf6_abr.h"
40 #include "ospf6_interface.h"
41 #include "ospf6_neighbor.h"
42 #include "ospf6_intra.h"
43 #include "ospf6_spf.h"
44 #include "ospf6d.h"
45 #include "ospf6_bfd.h"
46 #include "ospf6_zebra.h"
47 #include "ospf6_gr.h"
48 #include "lib/json.h"
49 #include "ospf6_proto.h"
50 #include "lib/keychain.h"
51 #include "ospf6_auth_trailer.h"
52
53 DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_IF, "OSPF6 interface");
54 DEFINE_MTYPE(OSPF6D, OSPF6_AUTH_KEYCHAIN, "OSPF6 auth keychain");
55 DEFINE_MTYPE(OSPF6D, OSPF6_AUTH_MANUAL_KEY, "OSPF6 auth key");
56 DEFINE_MTYPE_STATIC(OSPF6D, CFG_PLIST_NAME, "configured prefix list names");
57 DEFINE_QOBJ_TYPE(ospf6_interface);
58 DEFINE_HOOK(ospf6_interface_change,
59 (struct ospf6_interface * oi, int state, int old_state),
60 (oi, state, old_state));
61
62 unsigned char conf_debug_ospf6_interface = 0;
63
64 const char *const ospf6_interface_state_str[] = {
65 "None", "Down", "Loopback", "Waiting", "PointToPoint",
66 "DROther", "BDR", "DR", NULL};
67
68 int ospf6_interface_neighbor_count(struct ospf6_interface *oi)
69 {
70 int count = 0;
71 struct ospf6_neighbor *nbr = NULL;
72 struct listnode *node;
73
74 for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, node, nbr)) {
75 /* Down state is not shown. */
76 if (nbr->state == OSPF6_NEIGHBOR_DOWN)
77 continue;
78 count++;
79 }
80
81 return count;
82 }
83
84 struct ospf6_interface *ospf6_interface_lookup_by_ifindex(ifindex_t ifindex,
85 vrf_id_t vrf_id)
86 {
87 struct ospf6_interface *oi;
88 struct interface *ifp;
89
90 ifp = if_lookup_by_index(ifindex, vrf_id);
91 if (ifp == NULL)
92 return (struct ospf6_interface *)NULL;
93
94 oi = (struct ospf6_interface *)ifp->info;
95 return oi;
96 }
97
98 /* schedule routing table recalculation */
99 static void ospf6_interface_lsdb_hook(struct ospf6_lsa *lsa,
100 unsigned int reason)
101 {
102 struct ospf6_interface *oi;
103
104 if (lsa == NULL)
105 return;
106
107 oi = lsa->lsdb->data;
108 switch (ntohs(lsa->header->type)) {
109 case OSPF6_LSTYPE_LINK:
110 if (oi->state == OSPF6_INTERFACE_DR)
111 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(oi);
112 if (oi->area)
113 ospf6_spf_schedule(oi->area->ospf6, reason);
114 break;
115
116 default:
117 break;
118 }
119 }
120
121 static void ospf6_interface_lsdb_hook_add(struct ospf6_lsa *lsa)
122 {
123 ospf6_interface_lsdb_hook(lsa, ospf6_lsadd_to_spf_reason(lsa));
124 }
125
126 static void ospf6_interface_lsdb_hook_remove(struct ospf6_lsa *lsa)
127 {
128 ospf6_interface_lsdb_hook(lsa, ospf6_lsremove_to_spf_reason(lsa));
129 }
130
131 static uint8_t ospf6_default_iftype(struct interface *ifp)
132 {
133 if (if_is_pointopoint(ifp))
134 return OSPF_IFTYPE_POINTOPOINT;
135 else if (if_is_loopback(ifp))
136 return OSPF_IFTYPE_LOOPBACK;
137 else
138 return OSPF_IFTYPE_BROADCAST;
139 }
140
141 static uint32_t ospf6_interface_get_cost(struct ospf6_interface *oi)
142 {
143 /* If all else fails, use default OSPF cost */
144 uint32_t cost;
145 uint32_t bw, refbw;
146 struct ospf6 *ospf6;
147 /* interface speed and bw can be 0 in some platforms,
148 * use ospf default bw. If bw is configured then it would
149 * be used.
150 */
151 if (!oi->interface->bandwidth && oi->interface->speed) {
152 bw = oi->interface->speed;
153 } else {
154 bw = oi->interface->bandwidth ? oi->interface->bandwidth
155 : OSPF6_INTERFACE_BANDWIDTH;
156 }
157
158 ospf6 = oi->interface->vrf->info;
159 refbw = ospf6 ? ospf6->ref_bandwidth : OSPF6_REFERENCE_BANDWIDTH;
160
161 /* A specified ip ospf cost overrides a calculated one. */
162 if (CHECK_FLAG(oi->flag, OSPF6_INTERFACE_NOAUTOCOST))
163 cost = oi->cost;
164 else {
165 cost = (uint32_t)((double)refbw / (double)bw + (double)0.5);
166 if (cost < 1)
167 cost = 1;
168 }
169
170 return cost;
171 }
172
173 static void ospf6_interface_force_recalculate_cost(struct ospf6_interface *oi)
174 {
175 /* update cost held in route_connected list in ospf6_interface */
176 ospf6_interface_connected_route_update(oi->interface);
177
178 /* execute LSA hooks */
179 if (oi->area) {
180 OSPF6_LINK_LSA_SCHEDULE(oi);
181 OSPF6_ROUTER_LSA_SCHEDULE(oi->area);
182 OSPF6_NETWORK_LSA_SCHEDULE(oi);
183 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(oi);
184 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(oi->area);
185 }
186 }
187
188 static void ospf6_interface_recalculate_cost(struct ospf6_interface *oi)
189 {
190 uint32_t newcost;
191
192 newcost = ospf6_interface_get_cost(oi);
193 if (newcost == oi->cost)
194 return;
195 oi->cost = newcost;
196
197 ospf6_interface_force_recalculate_cost(oi);
198 }
199
200 /* Create new ospf6 interface structure */
201 struct ospf6_interface *ospf6_interface_create(struct interface *ifp)
202 {
203 struct ospf6_interface *oi;
204 unsigned int iobuflen;
205
206 oi = XCALLOC(MTYPE_OSPF6_IF, sizeof(struct ospf6_interface));
207
208 oi->obuf = ospf6_fifo_new();
209
210 oi->area = (struct ospf6_area *)NULL;
211 oi->neighbor_list = list_new();
212 oi->neighbor_list->cmp = ospf6_neighbor_cmp;
213 oi->linklocal_addr = (struct in6_addr *)NULL;
214 oi->instance_id = OSPF6_INTERFACE_INSTANCE_ID;
215 oi->transdelay = OSPF6_INTERFACE_TRANSDELAY;
216 oi->priority = OSPF6_INTERFACE_PRIORITY;
217
218 oi->hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
219 oi->dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
220 oi->rxmt_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
221 oi->type = ospf6_default_iftype(ifp);
222 oi->state = OSPF6_INTERFACE_DOWN;
223 oi->flag = 0;
224 oi->mtu_ignore = 0;
225 oi->c_ifmtu = 0;
226
227 /* Try to adjust I/O buffer size with IfMtu */
228 oi->ifmtu = ifp->mtu6;
229 iobuflen = ospf6_iobuf_size(ifp->mtu6);
230 if (oi->ifmtu > iobuflen) {
231 if (IS_OSPF6_DEBUG_INTERFACE)
232 zlog_debug(
233 "Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
234 ifp->name, iobuflen);
235 oi->ifmtu = iobuflen;
236 }
237
238 QOBJ_REG(oi, ospf6_interface);
239
240 oi->lsupdate_list = ospf6_lsdb_create(oi);
241 oi->lsack_list = ospf6_lsdb_create(oi);
242 oi->lsdb = ospf6_lsdb_create(oi);
243 oi->lsdb->hook_add = ospf6_interface_lsdb_hook_add;
244 oi->lsdb->hook_remove = ospf6_interface_lsdb_hook_remove;
245 oi->lsdb_self = ospf6_lsdb_create(oi);
246
247 oi->route_connected =
248 OSPF6_ROUTE_TABLE_CREATE(INTERFACE, CONNECTED_ROUTES);
249 oi->route_connected->scope = oi;
250
251 /* link both */
252 oi->interface = ifp;
253 ifp->info = oi;
254
255 /* Compute cost. */
256 oi->cost = ospf6_interface_get_cost(oi);
257
258 oi->at_data.flags = 0;
259
260 return oi;
261 }
262
263 void ospf6_interface_delete(struct ospf6_interface *oi)
264 {
265 struct listnode *node, *nnode;
266 struct ospf6_neighbor *on;
267
268 QOBJ_UNREG(oi);
269
270 ospf6_fifo_free(oi->obuf);
271
272 for (ALL_LIST_ELEMENTS(oi->neighbor_list, node, nnode, on))
273 ospf6_neighbor_delete(on);
274
275 list_delete(&oi->neighbor_list);
276
277 THREAD_OFF(oi->thread_send_hello);
278 THREAD_OFF(oi->thread_send_lsupdate);
279 THREAD_OFF(oi->thread_send_lsack);
280 THREAD_OFF(oi->thread_sso);
281 THREAD_OFF(oi->thread_wait_timer);
282
283 ospf6_lsdb_remove_all(oi->lsdb);
284 ospf6_lsdb_remove_all(oi->lsupdate_list);
285 ospf6_lsdb_remove_all(oi->lsack_list);
286
287 ospf6_lsdb_delete(oi->lsdb);
288 ospf6_lsdb_delete(oi->lsdb_self);
289
290 ospf6_lsdb_delete(oi->lsupdate_list);
291 ospf6_lsdb_delete(oi->lsack_list);
292
293 ospf6_route_table_delete(oi->route_connected);
294
295 /* cut link */
296 oi->interface->info = NULL;
297
298 /* plist_name */
299 if (oi->plist_name)
300 XFREE(MTYPE_CFG_PLIST_NAME, oi->plist_name);
301
302 /* disable from area list if possible */
303 ospf6_area_interface_delete(oi);
304
305 /* Free BFD allocated data. */
306 XFREE(MTYPE_TMP, oi->bfd_config.profile);
307
308 XFREE(MTYPE_OSPF6_IF, oi);
309 }
310
311 void ospf6_interface_enable(struct ospf6_interface *oi)
312 {
313 UNSET_FLAG(oi->flag, OSPF6_INTERFACE_DISABLE);
314 ospf6_interface_state_update(oi->interface);
315 }
316
317 void ospf6_interface_disable(struct ospf6_interface *oi)
318 {
319 SET_FLAG(oi->flag, OSPF6_INTERFACE_DISABLE);
320
321 thread_execute(master, interface_down, oi, 0);
322
323 ospf6_lsdb_remove_all(oi->lsdb);
324 ospf6_lsdb_remove_all(oi->lsdb_self);
325 ospf6_lsdb_remove_all(oi->lsupdate_list);
326 ospf6_lsdb_remove_all(oi->lsack_list);
327
328 THREAD_OFF(oi->thread_send_hello);
329 THREAD_OFF(oi->thread_send_lsupdate);
330 THREAD_OFF(oi->thread_send_lsack);
331 THREAD_OFF(oi->thread_sso);
332
333 THREAD_OFF(oi->thread_network_lsa);
334 THREAD_OFF(oi->thread_link_lsa);
335 THREAD_OFF(oi->thread_intra_prefix_lsa);
336 THREAD_OFF(oi->thread_as_extern_lsa);
337 THREAD_OFF(oi->thread_wait_timer);
338 }
339
340 static struct in6_addr *
341 ospf6_interface_get_linklocal_address(struct interface *ifp)
342 {
343 struct listnode *n;
344 struct connected *c;
345 struct in6_addr *l = (struct in6_addr *)NULL;
346
347 /* for each connected address */
348 for (ALL_LIST_ELEMENTS_RO(ifp->connected, n, c)) {
349 /* if family not AF_INET6, ignore */
350 if (c->address->family != AF_INET6)
351 continue;
352
353 /* linklocal scope check */
354 if (IN6_IS_ADDR_LINKLOCAL(&c->address->u.prefix6))
355 l = &c->address->u.prefix6;
356 }
357 return l;
358 }
359
360 void ospf6_interface_state_update(struct interface *ifp)
361 {
362 struct ospf6_interface *oi;
363 unsigned int iobuflen;
364
365 oi = (struct ospf6_interface *)ifp->info;
366 if (oi == NULL)
367 return;
368 if (CHECK_FLAG(oi->flag, OSPF6_INTERFACE_DISABLE))
369 return;
370
371 /* Adjust the mtu values if the kernel told us something new */
372 if (ifp->mtu6 != oi->ifmtu) {
373 /* If nothing configured, accept it and check for buffer size */
374 if (!oi->c_ifmtu) {
375 oi->ifmtu = ifp->mtu6;
376 iobuflen = ospf6_iobuf_size(ifp->mtu6);
377 if (oi->ifmtu > iobuflen) {
378 if (IS_OSPF6_DEBUG_INTERFACE)
379 zlog_debug(
380 "Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
381 ifp->name, iobuflen);
382 oi->ifmtu = iobuflen;
383 }
384 } else if (oi->c_ifmtu > ifp->mtu6) {
385 oi->ifmtu = ifp->mtu6;
386 zlog_warn(
387 "Configured mtu %u on %s overridden by kernel %u",
388 oi->c_ifmtu, ifp->name, ifp->mtu6);
389 } else
390 oi->ifmtu = oi->c_ifmtu;
391 }
392
393 if (if_is_operative(ifp)
394 && (ospf6_interface_get_linklocal_address(oi->interface)
395 || if_is_loopback(oi->interface)))
396 thread_execute(master, interface_up, oi, 0);
397 else
398 thread_execute(master, interface_down, oi, 0);
399
400 return;
401 }
402
403 void ospf6_interface_connected_route_update(struct interface *ifp)
404 {
405 struct ospf6_interface *oi;
406 struct ospf6_route *route;
407 struct connected *c;
408 struct listnode *node, *nnode;
409 struct in6_addr nh_addr;
410
411 oi = (struct ospf6_interface *)ifp->info;
412 if (oi == NULL)
413 return;
414
415 /* reset linklocal pointer */
416 oi->linklocal_addr = ospf6_interface_get_linklocal_address(ifp);
417
418 /* if area is null, do not make connected-route list */
419 if (oi->area == NULL)
420 return;
421
422 if (CHECK_FLAG(oi->flag, OSPF6_INTERFACE_DISABLE))
423 return;
424
425 /* update "route to advertise" interface route table */
426 ospf6_route_remove_all(oi->route_connected);
427
428 for (ALL_LIST_ELEMENTS(oi->interface->connected, node, nnode, c)) {
429 if (c->address->family != AF_INET6)
430 continue;
431
432 CONTINUE_IF_ADDRESS_LINKLOCAL(IS_OSPF6_DEBUG_INTERFACE,
433 c->address);
434 CONTINUE_IF_ADDRESS_UNSPECIFIED(IS_OSPF6_DEBUG_INTERFACE,
435 c->address);
436 CONTINUE_IF_ADDRESS_LOOPBACK(IS_OSPF6_DEBUG_INTERFACE,
437 c->address);
438 CONTINUE_IF_ADDRESS_V4COMPAT(IS_OSPF6_DEBUG_INTERFACE,
439 c->address);
440 CONTINUE_IF_ADDRESS_V4MAPPED(IS_OSPF6_DEBUG_INTERFACE,
441 c->address);
442
443 /* apply filter */
444 if (oi->plist_name) {
445 struct prefix_list *plist;
446 enum prefix_list_type ret;
447
448 plist = prefix_list_lookup(AFI_IP6, oi->plist_name);
449 ret = prefix_list_apply(plist, (void *)c->address);
450 if (ret == PREFIX_DENY) {
451 if (IS_OSPF6_DEBUG_INTERFACE)
452 zlog_debug(
453 "%pFX on %s filtered by prefix-list %s ",
454 c->address, oi->interface->name,
455 oi->plist_name);
456 continue;
457 }
458 }
459
460 route = ospf6_route_create(oi->area->ospf6);
461 memcpy(&route->prefix, c->address, sizeof(struct prefix));
462 apply_mask(&route->prefix);
463 route->type = OSPF6_DEST_TYPE_NETWORK;
464 route->path.area_id = oi->area->area_id;
465 route->path.type = OSPF6_PATH_TYPE_INTRA;
466 route->path.cost = oi->cost;
467 inet_pton(AF_INET6, "::1", &nh_addr);
468 ospf6_route_add_nexthop(route, oi->interface->ifindex,
469 &nh_addr);
470 ospf6_route_add(route, oi->route_connected);
471 }
472
473 /* create new Link-LSA */
474 OSPF6_LINK_LSA_SCHEDULE(oi);
475 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(oi);
476 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(oi->area);
477 }
478
479 static int ospf6_interface_state_change(uint8_t next_state,
480 struct ospf6_interface *oi)
481 {
482 uint8_t prev_state;
483 struct ospf6 *ospf6;
484
485 prev_state = oi->state;
486 oi->state = next_state;
487
488 if (prev_state == next_state)
489 return -1;
490
491 if (!oi->area)
492 return -1;
493
494 /* log */
495 if (IS_OSPF6_DEBUG_INTERFACE) {
496 zlog_debug("Interface state change %s: %s -> %s",
497 oi->interface->name,
498 ospf6_interface_state_str[prev_state],
499 ospf6_interface_state_str[next_state]);
500 }
501 oi->state_change++;
502
503 ospf6 = oi->area->ospf6;
504
505 if ((prev_state == OSPF6_INTERFACE_DR
506 || prev_state == OSPF6_INTERFACE_BDR)
507 && (next_state != OSPF6_INTERFACE_DR
508 && next_state != OSPF6_INTERFACE_BDR))
509 ospf6_sso(oi->interface->ifindex, &alldrouters6,
510 IPV6_LEAVE_GROUP, ospf6->fd);
511
512 if ((prev_state != OSPF6_INTERFACE_DR
513 && prev_state != OSPF6_INTERFACE_BDR)
514 && (next_state == OSPF6_INTERFACE_DR
515 || next_state == OSPF6_INTERFACE_BDR))
516 ospf6_sso(oi->interface->ifindex, &alldrouters6,
517 IPV6_JOIN_GROUP, ospf6->fd);
518
519 OSPF6_ROUTER_LSA_SCHEDULE(oi->area);
520 OSPF6_LINK_LSA_SCHEDULE(oi);
521 if (next_state == OSPF6_INTERFACE_DOWN) {
522 OSPF6_NETWORK_LSA_EXECUTE(oi);
523 OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT(oi);
524 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(oi->area);
525 OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT(oi);
526 } else if (prev_state == OSPF6_INTERFACE_DR
527 || next_state == OSPF6_INTERFACE_DR) {
528 OSPF6_NETWORK_LSA_SCHEDULE(oi);
529 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(oi);
530 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(oi->area);
531 }
532
533 hook_call(ospf6_interface_change, oi, next_state, prev_state);
534
535 return 0;
536 }
537
538
539 /* DR Election, RFC2328 section 9.4 */
540
541 #define IS_ELIGIBLE(n) \
542 ((n)->state >= OSPF6_NEIGHBOR_TWOWAY && (n)->priority != 0)
543
544 static struct ospf6_neighbor *better_bdrouter(struct ospf6_neighbor *a,
545 struct ospf6_neighbor *b)
546 {
547 if ((a == NULL || !IS_ELIGIBLE(a) || a->drouter == a->router_id)
548 && (b == NULL || !IS_ELIGIBLE(b) || b->drouter == b->router_id))
549 return NULL;
550 else if (a == NULL || !IS_ELIGIBLE(a) || a->drouter == a->router_id)
551 return b;
552 else if (b == NULL || !IS_ELIGIBLE(b) || b->drouter == b->router_id)
553 return a;
554
555 if (a->bdrouter == a->router_id && b->bdrouter != b->router_id)
556 return a;
557 if (a->bdrouter != a->router_id && b->bdrouter == b->router_id)
558 return b;
559
560 if (a->priority > b->priority)
561 return a;
562 if (a->priority < b->priority)
563 return b;
564
565 if (ntohl(a->router_id) > ntohl(b->router_id))
566 return a;
567 if (ntohl(a->router_id) < ntohl(b->router_id))
568 return b;
569
570 zlog_warn("Router-ID duplicate ?");
571 return a;
572 }
573
574 static struct ospf6_neighbor *better_drouter(struct ospf6_neighbor *a,
575 struct ospf6_neighbor *b)
576 {
577 if ((a == NULL || !IS_ELIGIBLE(a) || a->drouter != a->router_id)
578 && (b == NULL || !IS_ELIGIBLE(b) || b->drouter != b->router_id))
579 return NULL;
580 else if (a == NULL || !IS_ELIGIBLE(a) || a->drouter != a->router_id)
581 return b;
582 else if (b == NULL || !IS_ELIGIBLE(b) || b->drouter != b->router_id)
583 return a;
584
585 if (a->drouter == a->router_id && b->drouter != b->router_id)
586 return a;
587 if (a->drouter != a->router_id && b->drouter == b->router_id)
588 return b;
589
590 if (a->priority > b->priority)
591 return a;
592 if (a->priority < b->priority)
593 return b;
594
595 if (ntohl(a->router_id) > ntohl(b->router_id))
596 return a;
597 if (ntohl(a->router_id) < ntohl(b->router_id))
598 return b;
599
600 zlog_warn("Router-ID duplicate ?");
601 return a;
602 }
603
604 uint8_t dr_election(struct ospf6_interface *oi)
605 {
606 struct listnode *node, *nnode;
607 struct ospf6_neighbor *on, *drouter, *bdrouter, myself;
608 struct ospf6_neighbor *best_drouter, *best_bdrouter;
609 uint8_t next_state = 0;
610
611 drouter = bdrouter = NULL;
612 best_drouter = best_bdrouter = NULL;
613
614 /* pseudo neighbor myself, including noting current DR/BDR (1) */
615 memset(&myself, 0, sizeof(myself));
616 inet_ntop(AF_INET, &oi->area->ospf6->router_id, myself.name,
617 sizeof(myself.name));
618 myself.state = OSPF6_NEIGHBOR_TWOWAY;
619 myself.drouter = oi->drouter;
620 myself.bdrouter = oi->bdrouter;
621 myself.priority = oi->priority;
622 myself.router_id = oi->area->ospf6->router_id;
623
624 /* Electing BDR (2) */
625 for (ALL_LIST_ELEMENTS(oi->neighbor_list, node, nnode, on))
626 bdrouter = better_bdrouter(bdrouter, on);
627
628 best_bdrouter = bdrouter;
629 bdrouter = better_bdrouter(best_bdrouter, &myself);
630
631 /* Electing DR (3) */
632 for (ALL_LIST_ELEMENTS(oi->neighbor_list, node, nnode, on))
633 drouter = better_drouter(drouter, on);
634
635 best_drouter = drouter;
636 drouter = better_drouter(best_drouter, &myself);
637 if (drouter == NULL)
638 drouter = bdrouter;
639
640 /* the router itself is newly/no longer DR/BDR (4) */
641 if ((drouter == &myself && myself.drouter != myself.router_id)
642 || (drouter != &myself && myself.drouter == myself.router_id)
643 || (bdrouter == &myself && myself.bdrouter != myself.router_id)
644 || (bdrouter != &myself && myself.bdrouter == myself.router_id)) {
645 myself.drouter = (drouter ? drouter->router_id : htonl(0));
646 myself.bdrouter = (bdrouter ? bdrouter->router_id : htonl(0));
647
648 /* compatible to Electing BDR (2) */
649 bdrouter = better_bdrouter(best_bdrouter, &myself);
650
651 /* compatible to Electing DR (3) */
652 drouter = better_drouter(best_drouter, &myself);
653 if (drouter == NULL)
654 drouter = bdrouter;
655 }
656
657 /* Set interface state accordingly (5) */
658 if (drouter && drouter == &myself)
659 next_state = OSPF6_INTERFACE_DR;
660 else if (bdrouter && bdrouter == &myself)
661 next_state = OSPF6_INTERFACE_BDR;
662 else
663 next_state = OSPF6_INTERFACE_DROTHER;
664
665 /* If NBMA, schedule Start for each neighbor having priority of 0 (6) */
666 /* XXX */
667
668 /* If DR or BDR change, invoke AdjOK? for each neighbor (7) */
669 /* RFC 2328 section 12.4. Originating LSAs (3) will be handled
670 accordingly after AdjOK */
671 if (oi->drouter != (drouter ? drouter->router_id : htonl(0))
672 || oi->bdrouter != (bdrouter ? bdrouter->router_id : htonl(0))) {
673 if (IS_OSPF6_DEBUG_INTERFACE)
674 zlog_debug("DR Election on %s: DR: %s BDR: %s",
675 oi->interface->name,
676 (drouter ? drouter->name : "0.0.0.0"),
677 (bdrouter ? bdrouter->name : "0.0.0.0"));
678
679 for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, node, on)) {
680 if (on->state < OSPF6_NEIGHBOR_TWOWAY)
681 continue;
682 /* Schedule AdjOK. */
683 thread_add_event(master, adj_ok, on, 0,
684 &on->thread_adj_ok);
685 }
686 }
687
688 oi->drouter = (drouter ? drouter->router_id : htonl(0));
689 oi->bdrouter = (bdrouter ? bdrouter->router_id : htonl(0));
690 return next_state;
691 }
692
693 #ifdef __FreeBSD__
694
695 #include <ifaddrs.h>
696
697 static bool ifmaddr_check(ifindex_t ifindex, struct in6_addr *addr)
698 {
699 struct ifmaddrs *ifmap, *ifma;
700 struct sockaddr_dl *sdl;
701 struct sockaddr_in6 *sin6;
702 bool found = false;
703
704 if (getifmaddrs(&ifmap) != 0)
705 return false;
706
707 for (ifma = ifmap; ifma; ifma = ifma->ifma_next) {
708 if (ifma->ifma_name == NULL || ifma->ifma_addr == NULL)
709 continue;
710 if (ifma->ifma_name->sa_family != AF_LINK)
711 continue;
712 if (ifma->ifma_addr->sa_family != AF_INET6)
713 continue;
714 sdl = (struct sockaddr_dl *)ifma->ifma_name;
715 sin6 = (struct sockaddr_in6 *)ifma->ifma_addr;
716 if (sdl->sdl_index == ifindex
717 && memcmp(&sin6->sin6_addr, addr, IPV6_MAX_BYTELEN) == 0) {
718 found = true;
719 break;
720 }
721 }
722
723 if (ifmap)
724 freeifmaddrs(ifmap);
725
726 return found;
727 }
728
729 #endif /* __FreeBSD__ */
730
731 /* Interface State Machine */
732 void interface_up(struct thread *thread)
733 {
734 struct ospf6_interface *oi;
735 struct ospf6 *ospf6;
736
737 oi = (struct ospf6_interface *)THREAD_ARG(thread);
738 assert(oi && oi->interface);
739
740 if (!oi->type_cfg)
741 oi->type = ospf6_default_iftype(oi->interface);
742
743 thread_cancel(&oi->thread_sso);
744
745 if (IS_OSPF6_DEBUG_INTERFACE)
746 zlog_debug("Interface Event %s: [InterfaceUp]",
747 oi->interface->name);
748
749 /* check physical interface is up */
750 if (!if_is_operative(oi->interface)) {
751 zlog_warn("Interface %s is down, can't execute [InterfaceUp]",
752 oi->interface->name);
753 return;
754 }
755
756 /* check interface has a link-local address */
757 if (!(ospf6_interface_get_linklocal_address(oi->interface)
758 || if_is_loopback(oi->interface))) {
759 zlog_warn(
760 "Interface %s has no link local address, can't execute [InterfaceUp]",
761 oi->interface->name);
762 return;
763 }
764
765 /* Recompute cost */
766 ospf6_interface_recalculate_cost(oi);
767
768 /* if already enabled, do nothing */
769 if (oi->state > OSPF6_INTERFACE_DOWN) {
770 if (IS_OSPF6_DEBUG_INTERFACE)
771 zlog_debug("Interface %s already enabled",
772 oi->interface->name);
773 return;
774 }
775
776 /* If no area assigned, return */
777 if (oi->area == NULL) {
778 zlog_warn(
779 "%s: Not scheduling Hello for %s as there is no area assigned yet",
780 __func__, oi->interface->name);
781 return;
782 }
783
784 #ifdef __FreeBSD__
785 /*
786 * There's a delay in FreeBSD between issuing a command to leave a
787 * multicast group and an actual leave. If we execute "no router ospf6"
788 * and "router ospf6" fast enough, we can end up in a situation when OS
789 * performs the leave later than it performs the join and the interface
790 * remains without a multicast group. We have to do the join only after
791 * the interface actually left the group.
792 */
793 if (ifmaddr_check(oi->interface->ifindex, &allspfrouters6)) {
794 zlog_info(
795 "Interface %s is still in all routers group, rescheduling for SSO",
796 oi->interface->name);
797 thread_add_timer(master, interface_up, oi,
798 OSPF6_INTERFACE_SSO_RETRY_INT,
799 &oi->thread_sso);
800 return;
801 }
802 #endif /* __FreeBSD__ */
803
804 ospf6 = oi->area->ospf6;
805
806 /* Join AllSPFRouters */
807 if (ospf6_sso(oi->interface->ifindex, &allspfrouters6, IPV6_JOIN_GROUP,
808 ospf6->fd)
809 < 0) {
810 if (oi->sso_try_cnt++ < OSPF6_INTERFACE_SSO_RETRY_MAX) {
811 zlog_info(
812 "Scheduling %s for sso retry, trial count: %d",
813 oi->interface->name, oi->sso_try_cnt);
814 thread_add_timer(master, interface_up, oi,
815 OSPF6_INTERFACE_SSO_RETRY_INT,
816 &oi->thread_sso);
817 }
818 return;
819 }
820 oi->sso_try_cnt = 0; /* Reset on success */
821
822 /* Update interface route */
823 ospf6_interface_connected_route_update(oi->interface);
824
825 /* Schedule Hello */
826 if (!CHECK_FLAG(oi->flag, OSPF6_INTERFACE_PASSIVE)
827 && !if_is_loopback(oi->interface)) {
828 thread_add_timer(master, ospf6_hello_send, oi, 0,
829 &oi->thread_send_hello);
830 }
831
832 /* decide next interface state */
833 if (oi->type == OSPF_IFTYPE_LOOPBACK) {
834 ospf6_interface_state_change(OSPF6_INTERFACE_LOOPBACK, oi);
835 } else if (oi->type == OSPF_IFTYPE_POINTOPOINT) {
836 ospf6_interface_state_change(OSPF6_INTERFACE_POINTTOPOINT, oi);
837 } else if (oi->priority == 0)
838 ospf6_interface_state_change(OSPF6_INTERFACE_DROTHER, oi);
839 else {
840 ospf6_interface_state_change(OSPF6_INTERFACE_WAITING, oi);
841 thread_add_timer(master, wait_timer, oi, oi->dead_interval,
842 &oi->thread_wait_timer);
843 }
844 }
845
846 void wait_timer(struct thread *thread)
847 {
848 struct ospf6_interface *oi;
849
850 oi = (struct ospf6_interface *)THREAD_ARG(thread);
851 assert(oi && oi->interface);
852
853 if (IS_OSPF6_DEBUG_INTERFACE)
854 zlog_debug("Interface Event %s: [WaitTimer]",
855 oi->interface->name);
856
857 if (oi->state == OSPF6_INTERFACE_WAITING)
858 ospf6_interface_state_change(dr_election(oi), oi);
859 }
860
861 void backup_seen(struct thread *thread)
862 {
863 struct ospf6_interface *oi;
864
865 oi = (struct ospf6_interface *)THREAD_ARG(thread);
866 assert(oi && oi->interface);
867
868 if (IS_OSPF6_DEBUG_INTERFACE)
869 zlog_debug("Interface Event %s: [BackupSeen]",
870 oi->interface->name);
871
872 if (oi->state == OSPF6_INTERFACE_WAITING)
873 ospf6_interface_state_change(dr_election(oi), oi);
874 }
875
876 void neighbor_change(struct thread *thread)
877 {
878 struct ospf6_interface *oi;
879
880 oi = (struct ospf6_interface *)THREAD_ARG(thread);
881 assert(oi && oi->interface);
882
883 if (IS_OSPF6_DEBUG_INTERFACE)
884 zlog_debug("Interface Event %s: [NeighborChange]",
885 oi->interface->name);
886
887 if (oi->state == OSPF6_INTERFACE_DROTHER
888 || oi->state == OSPF6_INTERFACE_BDR
889 || oi->state == OSPF6_INTERFACE_DR)
890 ospf6_interface_state_change(dr_election(oi), oi);
891 }
892
893 void interface_down(struct thread *thread)
894 {
895 struct ospf6_interface *oi;
896 struct listnode *node, *nnode;
897 struct ospf6_neighbor *on;
898 struct ospf6 *ospf6;
899
900 oi = (struct ospf6_interface *)THREAD_ARG(thread);
901 assert(oi && oi->interface);
902
903 if (IS_OSPF6_DEBUG_INTERFACE)
904 zlog_debug("Interface Event %s: [InterfaceDown]",
905 oi->interface->name);
906
907 /* Stop Hellos */
908 THREAD_OFF(oi->thread_send_hello);
909
910 /* Stop trying to set socket options. */
911 THREAD_OFF(oi->thread_sso);
912
913 /* Cease the HELPER role for all the neighbours
914 * of this interface.
915 */
916 if (ospf6_interface_neighbor_count(oi)) {
917 struct listnode *ln;
918 struct ospf6_neighbor *nbr = NULL;
919
920 for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, ln, nbr))
921 ospf6_gr_helper_exit(nbr, OSPF6_GR_HELPER_TOPO_CHG);
922 }
923
924 for (ALL_LIST_ELEMENTS(oi->neighbor_list, node, nnode, on))
925 ospf6_neighbor_delete(on);
926
927 list_delete_all_node(oi->neighbor_list);
928
929 /* When interface state is reset, also reset information about
930 * DR election, as it is no longer valid. */
931 oi->drouter = oi->prev_drouter = htonl(0);
932 oi->bdrouter = oi->prev_bdrouter = htonl(0);
933
934 if (oi->area == NULL)
935 return;
936
937 ospf6 = oi->area->ospf6;
938 /* Leave AllSPFRouters */
939 if (oi->state > OSPF6_INTERFACE_DOWN)
940 ospf6_sso(oi->interface->ifindex, &allspfrouters6,
941 IPV6_LEAVE_GROUP, ospf6->fd);
942
943 /* deal with write fifo */
944 ospf6_fifo_flush(oi->obuf);
945 if (oi->on_write_q) {
946 listnode_delete(ospf6->oi_write_q, oi);
947 if (list_isempty(ospf6->oi_write_q))
948 thread_cancel(&ospf6->t_write);
949 oi->on_write_q = 0;
950 }
951
952 ospf6_interface_state_change(OSPF6_INTERFACE_DOWN, oi);
953 }
954
955
956 static const char *ospf6_iftype_str(uint8_t iftype)
957 {
958 switch (iftype) {
959 case OSPF_IFTYPE_LOOPBACK:
960 return "LOOPBACK";
961 case OSPF_IFTYPE_BROADCAST:
962 return "BROADCAST";
963 case OSPF_IFTYPE_POINTOPOINT:
964 return "POINTOPOINT";
965 }
966 return "UNKNOWN";
967 }
968
969 /* show specified interface structure */
970 static int ospf6_interface_show(struct vty *vty, struct interface *ifp,
971 json_object *json_obj, bool use_json)
972 {
973 struct ospf6_interface *oi;
974 struct connected *c;
975 struct prefix *p;
976 struct listnode *i;
977 char strbuf[PREFIX2STR_BUFFER], drouter[32], bdrouter[32];
978 uint8_t default_iftype;
979 struct timeval res, now;
980 char duration[32];
981 struct ospf6_lsa *lsa, *lsanext;
982 json_object *json_arr;
983 json_object *json_addr;
984 struct json_object *json_auth = NULL;
985
986 default_iftype = ospf6_default_iftype(ifp);
987
988 if (use_json) {
989 json_object_string_add(json_obj, "status",
990 (if_is_operative(ifp) ? "up" : "down"));
991 json_object_string_add(json_obj, "type",
992 ospf6_iftype_str(default_iftype));
993 json_object_int_add(json_obj, "interfaceId", ifp->ifindex);
994
995 if (ifp->info == NULL)
996 return 0;
997
998 oi = (struct ospf6_interface *)ifp->info;
999
1000 if (if_is_operative(ifp) && oi->type != default_iftype)
1001 json_object_string_add(json_obj, "operatingAsType",
1002 ospf6_iftype_str(oi->type));
1003
1004 } else {
1005 vty_out(vty, "%s is %s, type %s\n", ifp->name,
1006 (if_is_operative(ifp) ? "up" : "down"),
1007 ospf6_iftype_str(default_iftype));
1008 vty_out(vty, " Interface ID: %d\n", ifp->ifindex);
1009
1010 if (ifp->info == NULL) {
1011 vty_out(vty, " OSPF not enabled on this interface\n");
1012 return 0;
1013 }
1014 oi = (struct ospf6_interface *)ifp->info;
1015
1016 if (if_is_operative(ifp) && oi->type != default_iftype)
1017 vty_out(vty, " Operating as type %s\n",
1018 ospf6_iftype_str(oi->type));
1019 }
1020
1021 if (use_json) {
1022 json_arr = json_object_new_array();
1023 for (ALL_LIST_ELEMENTS_RO(ifp->connected, i, c)) {
1024 json_addr = json_object_new_object();
1025 p = c->address;
1026 prefix2str(p, strbuf, sizeof(strbuf));
1027 switch (p->family) {
1028 case AF_INET:
1029 json_object_string_add(json_addr, "type",
1030 "inet");
1031 json_object_string_add(json_addr, "address",
1032 strbuf);
1033 json_object_array_add(json_arr, json_addr);
1034 break;
1035 case AF_INET6:
1036 json_object_string_add(json_addr, "type",
1037 "inet6");
1038 json_object_string_add(json_addr, "address",
1039 strbuf);
1040 json_object_array_add(json_arr, json_addr);
1041 break;
1042 default:
1043 json_object_string_add(json_addr, "type",
1044 "unknown");
1045 json_object_string_add(json_addr, "address",
1046 strbuf);
1047 json_object_array_add(json_arr, json_addr);
1048 break;
1049 }
1050 }
1051 json_object_object_add(json_obj, "internetAddress", json_arr);
1052 } else {
1053 vty_out(vty, " Internet Address:\n");
1054
1055 for (ALL_LIST_ELEMENTS_RO(ifp->connected, i, c)) {
1056 p = c->address;
1057 prefix2str(p, strbuf, sizeof(strbuf));
1058 switch (p->family) {
1059 case AF_INET:
1060 vty_out(vty, " inet : %pFX\n", p);
1061 break;
1062 case AF_INET6:
1063 vty_out(vty, " inet6: %pFX\n", p);
1064 break;
1065 default:
1066 vty_out(vty, " ??? : %pFX\n", p);
1067 break;
1068 }
1069 }
1070 }
1071
1072 if (use_json) {
1073 if (oi->area) {
1074 json_object_boolean_true_add(json_obj,
1075 "attachedToArea");
1076 json_object_int_add(json_obj, "instanceId",
1077 oi->instance_id);
1078 json_object_int_add(json_obj, "interfaceMtu",
1079 oi->ifmtu);
1080 json_object_int_add(json_obj, "autoDetect", ifp->mtu6);
1081 json_object_string_add(json_obj, "mtuMismatchDetection",
1082 oi->mtu_ignore ? "disabled"
1083 : "enabled");
1084 inet_ntop(AF_INET, &oi->area->area_id, strbuf,
1085 sizeof(strbuf));
1086 json_object_string_add(json_obj, "areaId", strbuf);
1087 json_object_int_add(json_obj, "cost", oi->cost);
1088 } else
1089 json_object_boolean_false_add(json_obj,
1090 "attachedToArea");
1091
1092 } else {
1093 if (oi->area) {
1094 vty_out(vty,
1095 " Instance ID %d, Interface MTU %d (autodetect: %d)\n",
1096 oi->instance_id, oi->ifmtu, ifp->mtu6);
1097 vty_out(vty, " MTU mismatch detection: %s\n",
1098 oi->mtu_ignore ? "disabled" : "enabled");
1099 inet_ntop(AF_INET, &oi->area->area_id, strbuf,
1100 sizeof(strbuf));
1101 vty_out(vty, " Area ID %s, Cost %u\n", strbuf,
1102 oi->cost);
1103 } else
1104 vty_out(vty, " Not Attached to Area\n");
1105 }
1106
1107 if (use_json) {
1108 json_object_string_add(json_obj, "ospf6InterfaceState",
1109 ospf6_interface_state_str[oi->state]);
1110 json_object_int_add(json_obj, "transmitDelaySec",
1111 oi->transdelay);
1112 json_object_int_add(json_obj, "priority", oi->priority);
1113 json_object_int_add(json_obj, "timerIntervalsConfigHello",
1114 oi->hello_interval);
1115 json_object_int_add(json_obj, "timerIntervalsConfigDead",
1116 oi->dead_interval);
1117 json_object_int_add(json_obj, "timerIntervalsConfigRetransmit",
1118 oi->rxmt_interval);
1119 } else {
1120 vty_out(vty, " State %s, Transmit Delay %d sec, Priority %d\n",
1121 ospf6_interface_state_str[oi->state], oi->transdelay,
1122 oi->priority);
1123 vty_out(vty, " Timer intervals configured:\n");
1124 vty_out(vty, " Hello %d(%pTHd), Dead %d, Retransmit %d\n",
1125 oi->hello_interval, oi->thread_send_hello,
1126 oi->dead_interval, oi->rxmt_interval);
1127 }
1128
1129 inet_ntop(AF_INET, &oi->drouter, drouter, sizeof(drouter));
1130 inet_ntop(AF_INET, &oi->bdrouter, bdrouter, sizeof(bdrouter));
1131 if (use_json) {
1132 json_object_string_add(json_obj, "dr", drouter);
1133 json_object_string_add(json_obj, "bdr", bdrouter);
1134 json_object_int_add(json_obj, "numberOfInterfaceScopedLsa",
1135 oi->lsdb->count);
1136 } else {
1137 vty_out(vty, " DR: %s BDR: %s\n", drouter, bdrouter);
1138 vty_out(vty, " Number of I/F scoped LSAs is %u\n",
1139 oi->lsdb->count);
1140 }
1141
1142 monotime(&now);
1143
1144 if (use_json) {
1145 timerclear(&res);
1146 if (thread_is_scheduled(oi->thread_send_lsupdate))
1147 timersub(&oi->thread_send_lsupdate->u.sands, &now,
1148 &res);
1149 timerstring(&res, duration, sizeof(duration));
1150 json_object_int_add(json_obj, "pendingLsaLsUpdateCount",
1151 oi->lsupdate_list->count);
1152 json_object_string_add(json_obj, "pendingLsaLsUpdateTime",
1153 duration);
1154 json_object_string_add(
1155 json_obj, "lsUpdateSendThread",
1156 (thread_is_scheduled(oi->thread_send_lsupdate)
1157 ? "on"
1158 : "off"));
1159
1160 json_arr = json_object_new_array();
1161 for (ALL_LSDB(oi->lsupdate_list, lsa, lsanext))
1162 json_object_array_add(
1163 json_arr, json_object_new_string(lsa->name));
1164 json_object_object_add(json_obj, "pendingLsaLsUpdate",
1165 json_arr);
1166
1167 timerclear(&res);
1168 if (thread_is_scheduled(oi->thread_send_lsack))
1169 timersub(&oi->thread_send_lsack->u.sands, &now, &res);
1170 timerstring(&res, duration, sizeof(duration));
1171
1172 json_object_int_add(json_obj, "pendingLsaLsAckCount",
1173 oi->lsack_list->count);
1174 json_object_string_add(json_obj, "pendingLsaLsAckTime",
1175 duration);
1176 json_object_string_add(
1177 json_obj, "lsAckSendThread",
1178 (thread_is_scheduled(oi->thread_send_lsack) ? "on"
1179 : "off"));
1180
1181 json_arr = json_object_new_array();
1182 for (ALL_LSDB(oi->lsack_list, lsa, lsanext))
1183 json_object_array_add(
1184 json_arr, json_object_new_string(lsa->name));
1185 json_object_object_add(json_obj, "pendingLsaLsAck", json_arr);
1186
1187 } else {
1188 timerclear(&res);
1189 if (thread_is_scheduled(oi->thread_send_lsupdate))
1190 timersub(&oi->thread_send_lsupdate->u.sands, &now,
1191 &res);
1192 timerstring(&res, duration, sizeof(duration));
1193 vty_out(vty,
1194 " %d Pending LSAs for LSUpdate in Time %s [thread %s]\n",
1195 oi->lsupdate_list->count, duration,
1196 (thread_is_scheduled(oi->thread_send_lsupdate)
1197 ? "on"
1198 : "off"));
1199 for (ALL_LSDB(oi->lsupdate_list, lsa, lsanext))
1200 vty_out(vty, " %s\n", lsa->name);
1201
1202 timerclear(&res);
1203 if (thread_is_scheduled(oi->thread_send_lsack))
1204 timersub(&oi->thread_send_lsack->u.sands, &now, &res);
1205 timerstring(&res, duration, sizeof(duration));
1206 vty_out(vty,
1207 " %d Pending LSAs for LSAck in Time %s [thread %s]\n",
1208 oi->lsack_list->count, duration,
1209 (thread_is_scheduled(oi->thread_send_lsack) ? "on"
1210 : "off"));
1211 for (ALL_LSDB(oi->lsack_list, lsa, lsanext))
1212 vty_out(vty, " %s\n", lsa->name);
1213 }
1214
1215 /* BFD specific. */
1216 if (oi->bfd_config.enabled) {
1217 if (use_json) {
1218 struct json_object *json_bfd = json_object_new_object();
1219
1220 json_object_int_add(
1221 json_bfd, "detectMultiplier",
1222 oi->bfd_config.detection_multiplier);
1223 json_object_int_add(json_bfd, "rxMinInterval",
1224 oi->bfd_config.min_rx);
1225 json_object_int_add(json_bfd, "txMinInterval",
1226 oi->bfd_config.min_tx);
1227 json_object_object_add(json_obj, "peerBfdInfo",
1228 json_bfd);
1229 } else {
1230 vty_out(vty,
1231 " BFD: Detect Multiplier: %d, Min Rx interval: %d, Min Tx interval: %d\n",
1232 oi->bfd_config.detection_multiplier,
1233 oi->bfd_config.min_rx, oi->bfd_config.min_tx);
1234 }
1235 }
1236
1237 json_auth = json_object_new_object();
1238 if (oi->at_data.flags != 0) {
1239 if (use_json) {
1240 if (CHECK_FLAG(oi->at_data.flags,
1241 OSPF6_AUTH_TRAILER_KEYCHAIN)) {
1242 json_object_string_add(json_auth, "authType",
1243 "keychain");
1244 json_object_string_add(json_auth,
1245 "keychainName",
1246 oi->at_data.keychain);
1247 } else if (CHECK_FLAG(oi->at_data.flags,
1248 OSPF6_AUTH_TRAILER_MANUAL_KEY))
1249 json_object_string_add(json_auth, "authType",
1250 "manualkey");
1251 json_object_int_add(json_auth, "txPktDrop",
1252 oi->at_data.tx_drop);
1253 json_object_int_add(json_auth, "rxPktDrop",
1254 oi->at_data.rx_drop);
1255 } else {
1256 if (CHECK_FLAG(oi->at_data.flags,
1257 OSPF6_AUTH_TRAILER_KEYCHAIN))
1258 vty_out(vty,
1259 " Authentication Trailer is enabled with key-chain %s\n",
1260 oi->at_data.keychain);
1261 else if (CHECK_FLAG(oi->at_data.flags,
1262 OSPF6_AUTH_TRAILER_MANUAL_KEY))
1263 vty_out(vty,
1264 " Authentication trailer is enabled with manual key\n");
1265 vty_out(vty,
1266 " Packet drop Tx %u, Packet drop Rx %u\n",
1267 oi->at_data.tx_drop, oi->at_data.rx_drop);
1268 }
1269 } else {
1270 if (use_json)
1271 json_object_string_add(json_auth, "authType", "NULL");
1272 else
1273 vty_out(vty, " Authentication Trailer is disabled\n");
1274 }
1275
1276 if (use_json)
1277 json_object_object_add(json_obj, "authInfo", json_auth);
1278
1279 return 0;
1280 }
1281
1282 /* Find the global address to be used as a forwarding address in NSSA LSA.*/
1283 struct in6_addr *ospf6_interface_get_global_address(struct interface *ifp)
1284 {
1285 struct listnode *n;
1286 struct connected *c;
1287
1288 /* for each connected address */
1289 for (ALL_LIST_ELEMENTS_RO(ifp->connected, n, c)) {
1290 /* if family not AF_INET6, ignore */
1291 if (c->address->family != AF_INET6)
1292 continue;
1293
1294 if (!IN6_IS_ADDR_LINKLOCAL(&c->address->u.prefix6))
1295 return &c->address->u.prefix6;
1296 }
1297
1298 return NULL;
1299 }
1300
1301
1302 static int show_ospf6_interface_common(struct vty *vty, vrf_id_t vrf_id,
1303 int argc, struct cmd_token **argv,
1304 int idx_ifname, int intf_idx,
1305 int json_idx, bool uj)
1306 {
1307
1308 struct vrf *vrf = vrf_lookup_by_id(vrf_id);
1309 struct interface *ifp;
1310 json_object *json;
1311 json_object *json_int;
1312
1313 if (uj) {
1314 json = json_object_new_object();
1315 if (argc == json_idx) {
1316 ifp = if_lookup_by_name(argv[idx_ifname]->arg, vrf_id);
1317 json_int = json_object_new_object();
1318 if (ifp == NULL) {
1319 json_object_string_add(json, "noSuchInterface",
1320 argv[idx_ifname]->arg);
1321 vty_json(vty, json);
1322 json_object_free(json_int);
1323 return CMD_WARNING;
1324 }
1325 ospf6_interface_show(vty, ifp, json_int, uj);
1326 json_object_object_add(json, ifp->name, json_int);
1327 } else {
1328 FOR_ALL_INTERFACES (vrf, ifp) {
1329 json_int = json_object_new_object();
1330 ospf6_interface_show(vty, ifp, json_int, uj);
1331 json_object_object_add(json, ifp->name,
1332 json_int);
1333 }
1334 }
1335 vty_json(vty, json);
1336 } else {
1337 if (argc == intf_idx) {
1338 ifp = if_lookup_by_name(argv[idx_ifname]->arg, vrf_id);
1339 if (ifp == NULL) {
1340 vty_out(vty, "No such Interface: %s\n",
1341 argv[idx_ifname]->arg);
1342 return CMD_WARNING;
1343 }
1344 ospf6_interface_show(vty, ifp, NULL, uj);
1345 } else {
1346 FOR_ALL_INTERFACES (vrf, ifp)
1347 ospf6_interface_show(vty, ifp, NULL, uj);
1348 }
1349 }
1350 return CMD_SUCCESS;
1351 }
1352
1353 /* show interface */
1354 DEFUN(show_ipv6_ospf6_interface, show_ipv6_ospf6_interface_ifname_cmd,
1355 "show ipv6 ospf6 [vrf <NAME|all>] interface [IFNAME] [json]",
1356 SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1357 "All VRFs\n" INTERFACE_STR IFNAME_STR JSON_STR)
1358 {
1359 int idx_ifname = 4;
1360 int intf_idx = 5;
1361 int json_idx = 6;
1362 struct listnode *node;
1363 struct ospf6 *ospf6;
1364 const char *vrf_name = NULL;
1365 bool all_vrf = false;
1366 int idx_vrf = 0;
1367 bool uj = use_json(argc, argv);
1368
1369 OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
1370 if (idx_vrf > 0) {
1371 idx_ifname += 2;
1372 intf_idx += 2;
1373 json_idx += 2;
1374 }
1375
1376 for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
1377 if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
1378 show_ospf6_interface_common(vty, ospf6->vrf_id, argc,
1379 argv, idx_ifname, intf_idx,
1380 json_idx, uj);
1381
1382 if (!all_vrf)
1383 break;
1384 }
1385 }
1386
1387 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
1388
1389 return CMD_SUCCESS;
1390 }
1391
1392 static int ospf6_interface_show_traffic(struct vty *vty,
1393 struct interface *intf_ifp,
1394 int display_once, json_object *json,
1395 bool use_json, vrf_id_t vrf_id)
1396 {
1397 struct interface *ifp;
1398 struct vrf *vrf = NULL;
1399 struct ospf6_interface *oi = NULL;
1400 json_object *json_interface;
1401
1402 if (!display_once && !use_json) {
1403 vty_out(vty, "\n");
1404 vty_out(vty, "%-12s%-17s%-17s%-17s%-17s%-17s\n", "Interface",
1405 " HELLO", " DB-Desc", " LS-Req", " LS-Update",
1406 " LS-Ack");
1407 vty_out(vty, "%-10s%-18s%-18s%-17s%-17s%-17s\n", "",
1408 " Rx/Tx", " Rx/Tx", " Rx/Tx", " Rx/Tx",
1409 " Rx/Tx");
1410 vty_out(vty,
1411 "--------------------------------------------------------------------------------------------\n");
1412 }
1413
1414 if (intf_ifp == NULL) {
1415 vrf = vrf_lookup_by_id(vrf_id);
1416 FOR_ALL_INTERFACES (vrf, ifp) {
1417 if (ifp->info)
1418 oi = (struct ospf6_interface *)ifp->info;
1419 else
1420 continue;
1421
1422 if (use_json) {
1423 json_interface = json_object_new_object();
1424 json_object_int_add(json_interface, "helloRx",
1425 oi->hello_in);
1426 json_object_int_add(json_interface, "helloTx",
1427 oi->hello_out);
1428 json_object_int_add(json_interface, "dbDescRx",
1429 oi->db_desc_in);
1430 json_object_int_add(json_interface, "dbDescTx",
1431 oi->db_desc_out);
1432 json_object_int_add(json_interface, "lsReqRx",
1433 oi->ls_req_in);
1434 json_object_int_add(json_interface, "lsReqTx",
1435 oi->ls_req_out);
1436 json_object_int_add(json_interface,
1437 "lsUpdateRx",
1438 oi->ls_upd_in);
1439 json_object_int_add(json_interface,
1440 "lsUpdateTx",
1441 oi->ls_upd_out);
1442 json_object_int_add(json_interface, "lsAckRx",
1443 oi->ls_ack_in);
1444 json_object_int_add(json_interface, "lsAckTx",
1445 oi->ls_ack_out);
1446
1447 json_object_object_add(json,
1448 oi->interface->name,
1449 json_interface);
1450 } else
1451 vty_out(vty,
1452 "%-10s %8u/%-8u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u\n",
1453 oi->interface->name, oi->hello_in,
1454 oi->hello_out, oi->db_desc_in,
1455 oi->db_desc_out, oi->ls_req_in,
1456 oi->ls_req_out, oi->ls_upd_in,
1457 oi->ls_upd_out, oi->ls_ack_in,
1458 oi->ls_ack_out);
1459 }
1460 } else {
1461 oi = intf_ifp->info;
1462 if (oi == NULL)
1463 return CMD_WARNING;
1464
1465 if (use_json) {
1466 json_interface = json_object_new_object();
1467 json_object_int_add(json_interface, "helloRx",
1468 oi->hello_in);
1469 json_object_int_add(json_interface, "helloTx",
1470 oi->hello_out);
1471 json_object_int_add(json_interface, "dbDescRx",
1472 oi->db_desc_in);
1473 json_object_int_add(json_interface, "dbDescTx",
1474 oi->db_desc_out);
1475 json_object_int_add(json_interface, "lsReqRx",
1476 oi->ls_req_in);
1477 json_object_int_add(json_interface, "lsReqTx",
1478 oi->ls_req_out);
1479 json_object_int_add(json_interface, "lsUpdateRx",
1480 oi->ls_upd_in);
1481 json_object_int_add(json_interface, "lsUpdateTx",
1482 oi->ls_upd_out);
1483 json_object_int_add(json_interface, "lsAckRx",
1484 oi->ls_ack_in);
1485 json_object_int_add(json_interface, "lsAckTx",
1486 oi->ls_ack_out);
1487
1488 json_object_object_add(json, oi->interface->name,
1489 json_interface);
1490 } else
1491 vty_out(vty,
1492 "%-10s %8u/%-8u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u\n",
1493 oi->interface->name, oi->hello_in,
1494 oi->hello_out, oi->db_desc_in, oi->db_desc_out,
1495 oi->ls_req_in, oi->ls_req_out, oi->ls_upd_in,
1496 oi->ls_upd_out, oi->ls_ack_in, oi->ls_ack_out);
1497 }
1498
1499 return CMD_SUCCESS;
1500 }
1501
1502 static int ospf6_interface_show_traffic_common(struct vty *vty, int argc,
1503 struct cmd_token **argv,
1504 vrf_id_t vrf_id, bool uj)
1505 {
1506 int idx_ifname = 0;
1507 int display_once = 0;
1508 char *intf_name = NULL;
1509 struct interface *ifp = NULL;
1510 json_object *json = NULL;
1511
1512 if (uj)
1513 json = json_object_new_object();
1514
1515 if (argv_find(argv, argc, "IFNAME", &idx_ifname)) {
1516 intf_name = argv[idx_ifname]->arg;
1517 ifp = if_lookup_by_name(intf_name, vrf_id);
1518 if (uj) {
1519 if (ifp == NULL) {
1520 json_object_string_add(json, "status",
1521 "No Such Interface");
1522 json_object_string_add(json, "interface",
1523 intf_name);
1524 vty_json(vty, json);
1525 return CMD_WARNING;
1526 }
1527 if (ifp->info == NULL) {
1528 json_object_string_add(
1529 json, "status",
1530 "OSPF not enabled on this interface");
1531 json_object_string_add(json, "interface",
1532 intf_name);
1533 vty_json(vty, json);
1534 return 0;
1535 }
1536 } else {
1537 if (ifp == NULL) {
1538 vty_out(vty, "No such Interface: %s\n",
1539 intf_name);
1540 return CMD_WARNING;
1541 }
1542 if (ifp->info == NULL) {
1543 vty_out(vty,
1544 " OSPF not enabled on this interface %s\n",
1545 intf_name);
1546 return 0;
1547 }
1548 }
1549 }
1550
1551 ospf6_interface_show_traffic(vty, ifp, display_once, json, uj, vrf_id);
1552
1553 if (uj)
1554 vty_json(vty, json);
1555
1556 return CMD_SUCCESS;
1557 }
1558
1559 /* show interface */
1560 DEFUN(show_ipv6_ospf6_interface_traffic, show_ipv6_ospf6_interface_traffic_cmd,
1561 "show ipv6 ospf6 [vrf <NAME|all>] interface traffic [IFNAME] [json]",
1562 SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1563 "All VRFs\n" INTERFACE_STR
1564 "Protocol Packet counters\n" IFNAME_STR JSON_STR)
1565 {
1566 struct ospf6 *ospf6;
1567 struct listnode *node;
1568 const char *vrf_name = NULL;
1569 bool all_vrf = false;
1570 int idx_vrf = 0;
1571 bool uj = use_json(argc, argv);
1572
1573 OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
1574
1575 for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
1576 if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
1577 ospf6_interface_show_traffic_common(vty, argc, argv,
1578 ospf6->vrf_id, uj);
1579
1580 if (!all_vrf)
1581 break;
1582 }
1583 }
1584
1585 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
1586
1587 return CMD_SUCCESS;
1588 }
1589
1590
1591 DEFUN(show_ipv6_ospf6_interface_ifname_prefix,
1592 show_ipv6_ospf6_interface_ifname_prefix_cmd,
1593 "show ipv6 ospf6 [vrf <NAME|all>] interface IFNAME prefix\
1594 [<\
1595 detail\
1596 |<X:X::X:X|X:X::X:X/M> [<match|detail>]\
1597 >] [json]",
1598 SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1599 "All VRFs\n" INTERFACE_STR IFNAME_STR
1600 "Display connected prefixes to advertise\n"
1601 "Display details of the prefixes\n" OSPF6_ROUTE_ADDRESS_STR
1602 OSPF6_ROUTE_PREFIX_STR OSPF6_ROUTE_MATCH_STR
1603 "Display details of the prefixes\n" JSON_STR)
1604 {
1605 int idx_ifname = 4;
1606 int idx_prefix = 6;
1607 struct ospf6_interface *oi;
1608 bool uj = use_json(argc, argv);
1609
1610 struct ospf6 *ospf6;
1611 struct listnode *node;
1612 struct interface *ifp;
1613 const char *vrf_name = NULL;
1614 bool all_vrf = false;
1615 int idx_vrf = 0;
1616
1617 OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
1618 if (idx_vrf > 0) {
1619 idx_ifname += 2;
1620 idx_prefix += 2;
1621 }
1622
1623 for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
1624 if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
1625 ifp = if_lookup_by_name(argv[idx_ifname]->arg,
1626 ospf6->vrf_id);
1627 if (ifp == NULL) {
1628 vty_out(vty, "No such Interface: %s\n",
1629 argv[idx_ifname]->arg);
1630 return CMD_WARNING;
1631 }
1632
1633 oi = ifp->info;
1634 if (oi == NULL
1635 || CHECK_FLAG(oi->flag, OSPF6_INTERFACE_DISABLE)) {
1636 vty_out(vty,
1637 "Interface %s not attached to area\n",
1638 argv[idx_ifname]->arg);
1639 return CMD_WARNING;
1640 }
1641
1642 ospf6_route_table_show(vty, idx_prefix, argc, argv,
1643 oi->route_connected, uj);
1644
1645 if (!all_vrf)
1646 break;
1647 }
1648 }
1649
1650 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
1651
1652 return CMD_SUCCESS;
1653 }
1654
1655 DEFUN(show_ipv6_ospf6_interface_prefix, show_ipv6_ospf6_interface_prefix_cmd,
1656 "show ipv6 ospf6 [vrf <NAME|all>] interface prefix\
1657 [<\
1658 detail\
1659 |<X:X::X:X|X:X::X:X/M> [<match|detail>]\
1660 >] [json]",
1661 SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1662 "All VRFs\n" INTERFACE_STR
1663 "Display connected prefixes to advertise\n"
1664 "Display details of the prefixes\n" OSPF6_ROUTE_ADDRESS_STR
1665 OSPF6_ROUTE_PREFIX_STR OSPF6_ROUTE_MATCH_STR
1666 "Display details of the prefixes\n" JSON_STR)
1667 {
1668 struct vrf *vrf = NULL;
1669 int idx_prefix = 5;
1670 struct ospf6_interface *oi;
1671 struct interface *ifp;
1672 bool uj = use_json(argc, argv);
1673 struct listnode *node;
1674 struct ospf6 *ospf6;
1675 const char *vrf_name = NULL;
1676 bool all_vrf = false;
1677 int idx_vrf = 0;
1678
1679 OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
1680 if (idx_vrf > 0)
1681 idx_prefix += 2;
1682
1683 for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
1684 if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
1685 vrf = vrf_lookup_by_id(ospf6->vrf_id);
1686 FOR_ALL_INTERFACES (vrf, ifp) {
1687 oi = (struct ospf6_interface *)ifp->info;
1688 if (oi == NULL
1689 || CHECK_FLAG(oi->flag,
1690 OSPF6_INTERFACE_DISABLE))
1691 continue;
1692
1693 ospf6_route_table_show(vty, idx_prefix, argc,
1694 argv,
1695 oi->route_connected, uj);
1696 }
1697 if (!all_vrf)
1698 break;
1699 }
1700 }
1701
1702 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
1703
1704 return CMD_SUCCESS;
1705 }
1706
1707 void ospf6_interface_start(struct ospf6_interface *oi)
1708 {
1709 struct ospf6 *ospf6;
1710 struct ospf6_area *oa;
1711
1712 if (oi->area_id_format == OSPF6_AREA_FMT_UNSET)
1713 return;
1714
1715 if (oi->area) {
1716 /* Recompute cost */
1717 ospf6_interface_recalculate_cost(oi);
1718 return;
1719 }
1720
1721 ospf6 = oi->interface->vrf->info;
1722 if (!ospf6)
1723 return;
1724
1725 oa = ospf6_area_lookup(oi->area_id, ospf6);
1726 if (oa == NULL)
1727 oa = ospf6_area_create(oi->area_id, ospf6, oi->area_id_format);
1728
1729 /* attach interface to area */
1730 listnode_add(oa->if_list, oi);
1731 oi->area = oa;
1732
1733 SET_FLAG(oa->flag, OSPF6_AREA_ENABLE);
1734
1735 /* start up */
1736 ospf6_interface_enable(oi);
1737
1738 /* If the router is ABR, originate summary routes */
1739 if (ospf6_check_and_set_router_abr(ospf6))
1740 ospf6_abr_enable_area(oa);
1741 }
1742
1743 void ospf6_interface_stop(struct ospf6_interface *oi)
1744 {
1745 struct ospf6_area *oa;
1746
1747 oa = oi->area;
1748 if (!oa)
1749 return;
1750
1751 ospf6_interface_disable(oi);
1752
1753 listnode_delete(oa->if_list, oi);
1754 oi->area = NULL;
1755
1756 if (oa->if_list->count == 0) {
1757 UNSET_FLAG(oa->flag, OSPF6_AREA_ENABLE);
1758 ospf6_abr_disable_area(oa);
1759 }
1760 }
1761
1762 /* interface variable set command */
1763 DEFUN (ipv6_ospf6_area,
1764 ipv6_ospf6_area_cmd,
1765 "ipv6 ospf6 area <A.B.C.D|(0-4294967295)>",
1766 IP6_STR
1767 OSPF6_STR
1768 "Specify the OSPF6 area ID\n"
1769 "OSPF6 area ID in IPv4 address notation\n"
1770 "OSPF6 area ID in decimal notation\n")
1771 {
1772 VTY_DECLVAR_CONTEXT(interface, ifp);
1773 struct ospf6_interface *oi;
1774 int idx_ipv4 = 3;
1775 uint32_t area_id;
1776 int format;
1777
1778 assert(ifp);
1779
1780 oi = (struct ospf6_interface *)ifp->info;
1781 if (oi == NULL)
1782 oi = ospf6_interface_create(ifp);
1783 assert(oi);
1784
1785 if (oi->area) {
1786 vty_out(vty, "%s already attached to Area %s\n",
1787 oi->interface->name, oi->area->name);
1788 return CMD_SUCCESS;
1789 }
1790
1791 if (str2area_id(argv[idx_ipv4]->arg, &area_id, &format)) {
1792 vty_out(vty, "Malformed Area-ID: %s\n", argv[idx_ipv4]->arg);
1793 return CMD_WARNING_CONFIG_FAILED;
1794 }
1795
1796 oi->area_id = area_id;
1797 oi->area_id_format = format;
1798
1799 ospf6_interface_start(oi);
1800
1801 return CMD_SUCCESS;
1802 }
1803
1804 DEFUN (no_ipv6_ospf6_area,
1805 no_ipv6_ospf6_area_cmd,
1806 "no ipv6 ospf6 area [<A.B.C.D|(0-4294967295)>]",
1807 NO_STR
1808 IP6_STR
1809 OSPF6_STR
1810 "Specify the OSPF6 area ID\n"
1811 "OSPF6 area ID in IPv4 address notation\n"
1812 "OSPF6 area ID in decimal notation\n")
1813 {
1814 VTY_DECLVAR_CONTEXT(interface, ifp);
1815 struct ospf6_interface *oi;
1816
1817 assert(ifp);
1818
1819 oi = (struct ospf6_interface *)ifp->info;
1820 if (oi == NULL)
1821 oi = ospf6_interface_create(ifp);
1822 assert(oi);
1823
1824 ospf6_interface_stop(oi);
1825
1826 oi->area_id = 0;
1827 oi->area_id_format = OSPF6_AREA_FMT_UNSET;
1828
1829 return CMD_SUCCESS;
1830 }
1831
1832 DEFUN (ipv6_ospf6_ifmtu,
1833 ipv6_ospf6_ifmtu_cmd,
1834 "ipv6 ospf6 ifmtu (1-65535)",
1835 IP6_STR
1836 OSPF6_STR
1837 "Interface MTU\n"
1838 "OSPFv3 Interface MTU\n"
1839 )
1840 {
1841 VTY_DECLVAR_CONTEXT(interface, ifp);
1842 int idx_number = 3;
1843 struct ospf6_interface *oi;
1844 unsigned int ifmtu, iobuflen;
1845 struct listnode *node, *nnode;
1846 struct ospf6_neighbor *on;
1847
1848 assert(ifp);
1849
1850 oi = (struct ospf6_interface *)ifp->info;
1851 if (oi == NULL)
1852 oi = ospf6_interface_create(ifp);
1853 assert(oi);
1854
1855 ifmtu = strtol(argv[idx_number]->arg, NULL, 10);
1856
1857 if (oi->c_ifmtu == ifmtu)
1858 return CMD_SUCCESS;
1859
1860 if (ifp->mtu6 != 0 && ifp->mtu6 < ifmtu) {
1861 vty_out(vty,
1862 "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)\n",
1863 ifp->name, ifp->mtu6);
1864 return CMD_WARNING_CONFIG_FAILED;
1865 }
1866
1867 if (oi->ifmtu < ifmtu) {
1868 iobuflen = ospf6_iobuf_size(ifmtu);
1869 if (iobuflen < ifmtu) {
1870 vty_out(vty,
1871 "%s's ifmtu is adjusted to I/O buffer size (%d).\n",
1872 ifp->name, iobuflen);
1873 oi->ifmtu = oi->c_ifmtu = iobuflen;
1874 } else
1875 oi->ifmtu = oi->c_ifmtu = ifmtu;
1876 } else
1877 oi->ifmtu = oi->c_ifmtu = ifmtu;
1878
1879 /* re-establish adjacencies */
1880 for (ALL_LIST_ELEMENTS(oi->neighbor_list, node, nnode, on)) {
1881 THREAD_OFF(on->inactivity_timer);
1882 thread_add_event(master, inactivity_timer, on, 0, NULL);
1883 }
1884
1885 return CMD_SUCCESS;
1886 }
1887
1888 DEFUN (no_ipv6_ospf6_ifmtu,
1889 no_ipv6_ospf6_ifmtu_cmd,
1890 "no ipv6 ospf6 ifmtu [(1-65535)]",
1891 NO_STR
1892 IP6_STR
1893 OSPF6_STR
1894 "Interface MTU\n"
1895 "OSPFv3 Interface MTU\n"
1896 )
1897 {
1898 VTY_DECLVAR_CONTEXT(interface, ifp);
1899 struct ospf6_interface *oi;
1900 unsigned int iobuflen;
1901 struct listnode *node, *nnode;
1902 struct ospf6_neighbor *on;
1903
1904 assert(ifp);
1905
1906 oi = (struct ospf6_interface *)ifp->info;
1907 if (oi == NULL)
1908 oi = ospf6_interface_create(ifp);
1909 assert(oi);
1910
1911 if (oi->ifmtu < ifp->mtu) {
1912 iobuflen = ospf6_iobuf_size(ifp->mtu);
1913 if (iobuflen < ifp->mtu) {
1914 vty_out(vty,
1915 "%s's ifmtu is adjusted to I/O buffer size (%d).\n",
1916 ifp->name, iobuflen);
1917 oi->ifmtu = iobuflen;
1918 } else
1919 oi->ifmtu = ifp->mtu;
1920 } else
1921 oi->ifmtu = ifp->mtu;
1922
1923 oi->c_ifmtu = 0;
1924
1925 /* re-establish adjacencies */
1926 for (ALL_LIST_ELEMENTS(oi->neighbor_list, node, nnode, on)) {
1927 THREAD_OFF(on->inactivity_timer);
1928 thread_add_event(master, inactivity_timer, on, 0, NULL);
1929 }
1930
1931 return CMD_SUCCESS;
1932 }
1933
1934 DEFUN (ipv6_ospf6_cost,
1935 ipv6_ospf6_cost_cmd,
1936 "ipv6 ospf6 cost (1-65535)",
1937 IP6_STR
1938 OSPF6_STR
1939 "Interface cost\n"
1940 "Outgoing metric of this interface\n")
1941 {
1942 VTY_DECLVAR_CONTEXT(interface, ifp);
1943 int idx_number = 3;
1944 struct ospf6_interface *oi;
1945 unsigned long int lcost;
1946
1947 assert(ifp);
1948
1949 oi = (struct ospf6_interface *)ifp->info;
1950 if (oi == NULL)
1951 oi = ospf6_interface_create(ifp);
1952 assert(oi);
1953
1954 lcost = strtol(argv[idx_number]->arg, NULL, 10);
1955
1956 if (lcost > UINT32_MAX) {
1957 vty_out(vty, "Cost %ld is out of range\n", lcost);
1958 return CMD_WARNING_CONFIG_FAILED;
1959 }
1960
1961 SET_FLAG(oi->flag, OSPF6_INTERFACE_NOAUTOCOST);
1962 if (oi->cost == lcost)
1963 return CMD_SUCCESS;
1964
1965 oi->cost = lcost;
1966 ospf6_interface_force_recalculate_cost(oi);
1967
1968 return CMD_SUCCESS;
1969 }
1970
1971 DEFUN (no_ipv6_ospf6_cost,
1972 no_ipv6_ospf6_cost_cmd,
1973 "no ipv6 ospf6 cost [(1-65535)]",
1974 NO_STR
1975 IP6_STR
1976 OSPF6_STR
1977 "Calculate interface cost from bandwidth\n"
1978 "Outgoing metric of this interface\n")
1979 {
1980 VTY_DECLVAR_CONTEXT(interface, ifp);
1981 struct ospf6_interface *oi;
1982 assert(ifp);
1983
1984 oi = (struct ospf6_interface *)ifp->info;
1985 if (oi == NULL)
1986 oi = ospf6_interface_create(ifp);
1987 assert(oi);
1988
1989 UNSET_FLAG(oi->flag, OSPF6_INTERFACE_NOAUTOCOST);
1990
1991 ospf6_interface_recalculate_cost(oi);
1992
1993 return CMD_SUCCESS;
1994 }
1995
1996 DEFUN (auto_cost_reference_bandwidth,
1997 auto_cost_reference_bandwidth_cmd,
1998 "auto-cost reference-bandwidth (1-4294967)",
1999 "Calculate OSPF interface cost according to bandwidth\n"
2000 "Use reference bandwidth method to assign OSPF cost\n"
2001 "The reference bandwidth in terms of Mbits per second\n")
2002 {
2003 VTY_DECLVAR_CONTEXT(ospf6, o);
2004 int idx_number = 2;
2005 struct ospf6_area *oa;
2006 struct ospf6_interface *oi;
2007 struct listnode *i, *j;
2008 uint32_t refbw;
2009
2010 refbw = strtol(argv[idx_number]->arg, NULL, 10);
2011 if (refbw < 1 || refbw > 4294967) {
2012 vty_out(vty, "reference-bandwidth value is invalid\n");
2013 return CMD_WARNING_CONFIG_FAILED;
2014 }
2015
2016 /* If reference bandwidth is changed. */
2017 if ((refbw) == o->ref_bandwidth)
2018 return CMD_SUCCESS;
2019
2020 o->ref_bandwidth = refbw;
2021 for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa))
2022 for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi))
2023 ospf6_interface_recalculate_cost(oi);
2024
2025 return CMD_SUCCESS;
2026 }
2027
2028 DEFUN (no_auto_cost_reference_bandwidth,
2029 no_auto_cost_reference_bandwidth_cmd,
2030 "no auto-cost reference-bandwidth [(1-4294967)]",
2031 NO_STR
2032 "Calculate OSPF interface cost according to bandwidth\n"
2033 "Use reference bandwidth method to assign OSPF cost\n"
2034 "The reference bandwidth in terms of Mbits per second\n")
2035 {
2036 VTY_DECLVAR_CONTEXT(ospf6, o);
2037 struct ospf6_area *oa;
2038 struct ospf6_interface *oi;
2039 struct listnode *i, *j;
2040
2041 if (o->ref_bandwidth == OSPF6_REFERENCE_BANDWIDTH)
2042 return CMD_SUCCESS;
2043
2044 o->ref_bandwidth = OSPF6_REFERENCE_BANDWIDTH;
2045 for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa))
2046 for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi))
2047 ospf6_interface_recalculate_cost(oi);
2048
2049 return CMD_SUCCESS;
2050 }
2051
2052
2053 DEFUN (ospf6_write_multiplier,
2054 ospf6_write_multiplier_cmd,
2055 "write-multiplier (1-100)",
2056 "Write multiplier\n"
2057 "Maximum number of interface serviced per write\n")
2058 {
2059 VTY_DECLVAR_CONTEXT(ospf6, o);
2060 uint32_t write_oi_count;
2061
2062 write_oi_count = strtol(argv[1]->arg, NULL, 10);
2063 if (write_oi_count < 1 || write_oi_count > 100) {
2064 vty_out(vty, "write-multiplier value is invalid\n");
2065 return CMD_WARNING_CONFIG_FAILED;
2066 }
2067
2068 o->write_oi_count = write_oi_count;
2069 return CMD_SUCCESS;
2070 }
2071
2072 DEFUN (no_ospf6_write_multiplier,
2073 no_ospf6_write_multiplier_cmd,
2074 "no write-multiplier (1-100)",
2075 NO_STR
2076 "Write multiplier\n"
2077 "Maximum number of interface serviced per write\n")
2078 {
2079 VTY_DECLVAR_CONTEXT(ospf6, o);
2080
2081 o->write_oi_count = OSPF6_WRITE_INTERFACE_COUNT_DEFAULT;
2082 return CMD_SUCCESS;
2083 }
2084
2085 DEFUN (ipv6_ospf6_hellointerval,
2086 ipv6_ospf6_hellointerval_cmd,
2087 "ipv6 ospf6 hello-interval (1-65535)",
2088 IP6_STR
2089 OSPF6_STR
2090 "Time between HELLO packets\n"
2091 SECONDS_STR)
2092 {
2093 VTY_DECLVAR_CONTEXT(interface, ifp);
2094 int idx_number = 3;
2095 struct ospf6_interface *oi;
2096 assert(ifp);
2097
2098 oi = (struct ospf6_interface *)ifp->info;
2099 if (oi == NULL)
2100 oi = ospf6_interface_create(ifp);
2101 assert(oi);
2102
2103 oi->hello_interval = strmatch(argv[0]->text, "no")
2104 ? OSPF_HELLO_INTERVAL_DEFAULT
2105 : strtoul(argv[idx_number]->arg, NULL, 10);
2106
2107 /*
2108 * If the thread is scheduled, send the new hello now.
2109 */
2110 if (thread_is_scheduled(oi->thread_send_hello)) {
2111 THREAD_OFF(oi->thread_send_hello);
2112
2113 thread_add_timer(master, ospf6_hello_send, oi, 0,
2114 &oi->thread_send_hello);
2115 }
2116 return CMD_SUCCESS;
2117 }
2118
2119 ALIAS (ipv6_ospf6_hellointerval,
2120 no_ipv6_ospf6_hellointerval_cmd,
2121 "no ipv6 ospf6 hello-interval [(1-65535)]",
2122 NO_STR
2123 IP6_STR
2124 OSPF6_STR
2125 "Time between HELLO packets\n"
2126 SECONDS_STR)
2127
2128 /* interface variable set command */
2129 DEFUN (ipv6_ospf6_deadinterval,
2130 ipv6_ospf6_deadinterval_cmd,
2131 "ipv6 ospf6 dead-interval (1-65535)",
2132 IP6_STR
2133 OSPF6_STR
2134 "Interval time after which a neighbor is declared down\n"
2135 SECONDS_STR)
2136 {
2137 VTY_DECLVAR_CONTEXT(interface, ifp);
2138 int idx_number = 3;
2139 struct ospf6_interface *oi;
2140 assert(ifp);
2141
2142 oi = (struct ospf6_interface *)ifp->info;
2143 if (oi == NULL)
2144 oi = ospf6_interface_create(ifp);
2145 assert(oi);
2146
2147 oi->dead_interval = strmatch(argv[0]->arg, "no")
2148 ? OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
2149 : strtoul(argv[idx_number]->arg, NULL, 10);
2150 return CMD_SUCCESS;
2151 }
2152
2153 ALIAS (ipv6_ospf6_deadinterval,
2154 no_ipv6_ospf6_deadinterval_cmd,
2155 "no ipv6 ospf6 dead-interval [(1-65535)]",
2156 NO_STR
2157 IP6_STR
2158 OSPF6_STR
2159 "Interval time after which a neighbor is declared down\n"
2160 SECONDS_STR)
2161
2162 /* interface variable set command */
2163 DEFUN (ipv6_ospf6_transmitdelay,
2164 ipv6_ospf6_transmitdelay_cmd,
2165 "ipv6 ospf6 transmit-delay (1-3600)",
2166 IP6_STR
2167 OSPF6_STR
2168 "Link state transmit delay\n"
2169 SECONDS_STR)
2170 {
2171 VTY_DECLVAR_CONTEXT(interface, ifp);
2172 int idx_number = 3;
2173 struct ospf6_interface *oi;
2174 assert(ifp);
2175
2176 oi = (struct ospf6_interface *)ifp->info;
2177 if (oi == NULL)
2178 oi = ospf6_interface_create(ifp);
2179 assert(oi);
2180
2181 oi->transdelay = strmatch(argv[0]->text, "no")
2182 ? OSPF6_INTERFACE_TRANSDELAY
2183 : strtoul(argv[idx_number]->arg, NULL, 10);
2184 return CMD_SUCCESS;
2185 }
2186
2187 ALIAS (ipv6_ospf6_transmitdelay,
2188 no_ipv6_ospf6_transmitdelay_cmd,
2189 "no ipv6 ospf6 transmit-delay [(1-3600)]",
2190 NO_STR
2191 IP6_STR
2192 OSPF6_STR
2193 "Link state transmit delay\n"
2194 SECONDS_STR)
2195
2196 /* interface variable set command */
2197 DEFUN (ipv6_ospf6_retransmitinterval,
2198 ipv6_ospf6_retransmitinterval_cmd,
2199 "ipv6 ospf6 retransmit-interval (1-65535)",
2200 IP6_STR
2201 OSPF6_STR
2202 "Time between retransmitting lost link state advertisements\n"
2203 SECONDS_STR)
2204 {
2205 VTY_DECLVAR_CONTEXT(interface, ifp);
2206 int idx_number = 3;
2207 struct ospf6_interface *oi;
2208 assert(ifp);
2209
2210 oi = (struct ospf6_interface *)ifp->info;
2211 if (oi == NULL)
2212 oi = ospf6_interface_create(ifp);
2213 assert(oi);
2214
2215 oi->rxmt_interval = strmatch(argv[0]->text, "no")
2216 ? OSPF_RETRANSMIT_INTERVAL_DEFAULT
2217 : strtoul(argv[idx_number]->arg, NULL, 10);
2218 return CMD_SUCCESS;
2219 }
2220
2221 ALIAS (ipv6_ospf6_retransmitinterval,
2222 no_ipv6_ospf6_retransmitinterval_cmd,
2223 "no ipv6 ospf6 retransmit-interval [(1-65535)]",
2224 NO_STR
2225 IP6_STR
2226 OSPF6_STR
2227 "Time between retransmitting lost link state advertisements\n"
2228 SECONDS_STR)
2229
2230 /* interface variable set command */
2231 DEFUN (ipv6_ospf6_priority,
2232 ipv6_ospf6_priority_cmd,
2233 "ipv6 ospf6 priority (0-255)",
2234 IP6_STR
2235 OSPF6_STR
2236 "Router priority\n"
2237 "Priority value\n")
2238 {
2239 VTY_DECLVAR_CONTEXT(interface, ifp);
2240 int idx_number = 3;
2241 struct ospf6_interface *oi;
2242 assert(ifp);
2243
2244 oi = (struct ospf6_interface *)ifp->info;
2245 if (oi == NULL)
2246 oi = ospf6_interface_create(ifp);
2247 assert(oi);
2248
2249 oi->priority = strmatch(argv[0]->text, "no")
2250 ? OSPF6_INTERFACE_PRIORITY
2251 : strtoul(argv[idx_number]->arg, NULL, 10);
2252
2253 if (oi->area
2254 && (oi->state == OSPF6_INTERFACE_DROTHER
2255 || oi->state == OSPF6_INTERFACE_BDR
2256 || oi->state == OSPF6_INTERFACE_DR)) {
2257 if (ospf6_interface_state_change(dr_election(oi), oi) == -1)
2258 OSPF6_LINK_LSA_SCHEDULE(oi);
2259 }
2260
2261 return CMD_SUCCESS;
2262 }
2263
2264 ALIAS (ipv6_ospf6_priority,
2265 no_ipv6_ospf6_priority_cmd,
2266 "no ipv6 ospf6 priority [(0-255)]",
2267 NO_STR
2268 IP6_STR
2269 OSPF6_STR
2270 "Router priority\n"
2271 "Priority value\n")
2272
2273 DEFUN (ipv6_ospf6_instance,
2274 ipv6_ospf6_instance_cmd,
2275 "ipv6 ospf6 instance-id (0-255)",
2276 IP6_STR
2277 OSPF6_STR
2278 "Instance ID for this interface\n"
2279 "Instance ID value\n")
2280 {
2281 VTY_DECLVAR_CONTEXT(interface, ifp);
2282 int idx_number = 3;
2283 struct ospf6_interface *oi;
2284 assert(ifp);
2285
2286 oi = (struct ospf6_interface *)ifp->info;
2287 if (oi == NULL)
2288 oi = ospf6_interface_create(ifp);
2289 assert(oi);
2290
2291 oi->instance_id = strmatch(argv[0]->text, "no")
2292 ? OSPF6_INTERFACE_INSTANCE_ID
2293 : strtoul(argv[idx_number]->arg, NULL, 10);
2294 return CMD_SUCCESS;
2295 }
2296
2297 ALIAS (ipv6_ospf6_instance,
2298 no_ipv6_ospf6_instance_cmd,
2299 "no ipv6 ospf6 instance-id [(0-255)]",
2300 NO_STR
2301 IP6_STR
2302 OSPF6_STR
2303 "Instance ID for this interface\n"
2304 "Instance ID value\n")
2305
2306 DEFUN (ipv6_ospf6_passive,
2307 ipv6_ospf6_passive_cmd,
2308 "ipv6 ospf6 passive",
2309 IP6_STR
2310 OSPF6_STR
2311 "Passive interface; no adjacency will be formed on this interface\n"
2312 )
2313 {
2314 VTY_DECLVAR_CONTEXT(interface, ifp);
2315 struct ospf6_interface *oi;
2316 struct listnode *node, *nnode;
2317 struct ospf6_neighbor *on;
2318
2319 assert(ifp);
2320
2321 oi = (struct ospf6_interface *)ifp->info;
2322 if (oi == NULL)
2323 oi = ospf6_interface_create(ifp);
2324 assert(oi);
2325
2326 SET_FLAG(oi->flag, OSPF6_INTERFACE_PASSIVE);
2327 THREAD_OFF(oi->thread_send_hello);
2328 THREAD_OFF(oi->thread_sso);
2329
2330 for (ALL_LIST_ELEMENTS(oi->neighbor_list, node, nnode, on)) {
2331 THREAD_OFF(on->inactivity_timer);
2332 thread_add_event(master, inactivity_timer, on, 0, NULL);
2333 }
2334
2335 return CMD_SUCCESS;
2336 }
2337
2338 DEFUN (no_ipv6_ospf6_passive,
2339 no_ipv6_ospf6_passive_cmd,
2340 "no ipv6 ospf6 passive",
2341 NO_STR
2342 IP6_STR
2343 OSPF6_STR
2344 "passive interface: No Adjacency will be formed on this I/F\n"
2345 )
2346 {
2347 VTY_DECLVAR_CONTEXT(interface, ifp);
2348 struct ospf6_interface *oi;
2349 assert(ifp);
2350
2351 oi = (struct ospf6_interface *)ifp->info;
2352 if (oi == NULL)
2353 oi = ospf6_interface_create(ifp);
2354 assert(oi);
2355
2356 UNSET_FLAG(oi->flag, OSPF6_INTERFACE_PASSIVE);
2357 THREAD_OFF(oi->thread_send_hello);
2358 THREAD_OFF(oi->thread_sso);
2359
2360 /* don't send hellos over loopback interface */
2361 if (!if_is_loopback(oi->interface))
2362 thread_add_timer(master, ospf6_hello_send, oi, 0,
2363 &oi->thread_send_hello);
2364
2365 return CMD_SUCCESS;
2366 }
2367
2368 DEFUN (ipv6_ospf6_mtu_ignore,
2369 ipv6_ospf6_mtu_ignore_cmd,
2370 "ipv6 ospf6 mtu-ignore",
2371 IP6_STR
2372 OSPF6_STR
2373 "Disable MTU mismatch detection on this interface\n"
2374 )
2375 {
2376 VTY_DECLVAR_CONTEXT(interface, ifp);
2377 struct ospf6_interface *oi;
2378 assert(ifp);
2379
2380 oi = (struct ospf6_interface *)ifp->info;
2381 if (oi == NULL)
2382 oi = ospf6_interface_create(ifp);
2383 assert(oi);
2384
2385 oi->mtu_ignore = 1;
2386
2387 return CMD_SUCCESS;
2388 }
2389
2390 DEFUN (no_ipv6_ospf6_mtu_ignore,
2391 no_ipv6_ospf6_mtu_ignore_cmd,
2392 "no ipv6 ospf6 mtu-ignore",
2393 NO_STR
2394 IP6_STR
2395 OSPF6_STR
2396 "Disable MTU mismatch detection on this interface\n"
2397 )
2398 {
2399 VTY_DECLVAR_CONTEXT(interface, ifp);
2400 struct ospf6_interface *oi;
2401 assert(ifp);
2402
2403 oi = (struct ospf6_interface *)ifp->info;
2404 if (oi == NULL)
2405 oi = ospf6_interface_create(ifp);
2406 assert(oi);
2407
2408 oi->mtu_ignore = 0;
2409
2410 return CMD_SUCCESS;
2411 }
2412
2413 DEFUN (ipv6_ospf6_advertise_prefix_list,
2414 ipv6_ospf6_advertise_prefix_list_cmd,
2415 "ipv6 ospf6 advertise prefix-list WORD",
2416 IP6_STR
2417 OSPF6_STR
2418 "Advertising options\n"
2419 "Filter prefix using prefix-list\n"
2420 "Prefix list name\n"
2421 )
2422 {
2423 VTY_DECLVAR_CONTEXT(interface, ifp);
2424 int idx_word = 4;
2425 struct ospf6_interface *oi;
2426 assert(ifp);
2427
2428 oi = (struct ospf6_interface *)ifp->info;
2429 if (oi == NULL)
2430 oi = ospf6_interface_create(ifp);
2431 assert(oi);
2432
2433 if (oi->plist_name)
2434 XFREE(MTYPE_CFG_PLIST_NAME, oi->plist_name);
2435 oi->plist_name = XSTRDUP(MTYPE_CFG_PLIST_NAME, argv[idx_word]->arg);
2436
2437 ospf6_interface_connected_route_update(oi->interface);
2438
2439 if (oi->area) {
2440 OSPF6_LINK_LSA_SCHEDULE(oi);
2441 if (oi->state == OSPF6_INTERFACE_DR) {
2442 OSPF6_NETWORK_LSA_SCHEDULE(oi);
2443 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(oi);
2444 }
2445 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(oi->area);
2446 }
2447
2448 return CMD_SUCCESS;
2449 }
2450
2451 DEFUN (no_ipv6_ospf6_advertise_prefix_list,
2452 no_ipv6_ospf6_advertise_prefix_list_cmd,
2453 "no ipv6 ospf6 advertise prefix-list [WORD]",
2454 NO_STR
2455 IP6_STR
2456 OSPF6_STR
2457 "Advertising options\n"
2458 "Filter prefix using prefix-list\n"
2459 "Prefix list name\n")
2460 {
2461 VTY_DECLVAR_CONTEXT(interface, ifp);
2462 struct ospf6_interface *oi;
2463 assert(ifp);
2464
2465 oi = (struct ospf6_interface *)ifp->info;
2466 if (oi == NULL)
2467 oi = ospf6_interface_create(ifp);
2468 assert(oi);
2469
2470 if (oi->plist_name)
2471 XFREE(MTYPE_CFG_PLIST_NAME, oi->plist_name);
2472
2473 ospf6_interface_connected_route_update(oi->interface);
2474
2475 if (oi->area) {
2476 OSPF6_LINK_LSA_SCHEDULE(oi);
2477 if (oi->state == OSPF6_INTERFACE_DR) {
2478 OSPF6_NETWORK_LSA_SCHEDULE(oi);
2479 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(oi);
2480 }
2481 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(oi->area);
2482 }
2483
2484 return CMD_SUCCESS;
2485 }
2486
2487 DEFUN (ipv6_ospf6_network,
2488 ipv6_ospf6_network_cmd,
2489 "ipv6 ospf6 network <broadcast|point-to-point>",
2490 IP6_STR
2491 OSPF6_STR
2492 "Network type\n"
2493 "Specify OSPF6 broadcast network\n"
2494 "Specify OSPF6 point-to-point network\n"
2495 )
2496 {
2497 VTY_DECLVAR_CONTEXT(interface, ifp);
2498 int idx_network = 3;
2499 struct ospf6_interface *oi;
2500 assert(ifp);
2501
2502 oi = (struct ospf6_interface *)ifp->info;
2503 if (oi == NULL) {
2504 oi = ospf6_interface_create(ifp);
2505 }
2506 assert(oi);
2507
2508 oi->type_cfg = true;
2509
2510 if (strncmp(argv[idx_network]->arg, "b", 1) == 0) {
2511 if (oi->type == OSPF_IFTYPE_BROADCAST)
2512 return CMD_SUCCESS;
2513
2514 oi->type = OSPF_IFTYPE_BROADCAST;
2515 } else if (strncmp(argv[idx_network]->arg, "point-to-p", 10) == 0) {
2516 if (oi->type == OSPF_IFTYPE_POINTOPOINT) {
2517 return CMD_SUCCESS;
2518 }
2519 oi->type = OSPF_IFTYPE_POINTOPOINT;
2520 }
2521
2522 /* Reset the interface */
2523 thread_execute(master, interface_down, oi, 0);
2524 thread_execute(master, interface_up, oi, 0);
2525
2526 return CMD_SUCCESS;
2527 }
2528
2529 DEFUN (no_ipv6_ospf6_network,
2530 no_ipv6_ospf6_network_cmd,
2531 "no ipv6 ospf6 network [<broadcast|point-to-point>]",
2532 NO_STR
2533 IP6_STR
2534 OSPF6_STR
2535 "Set default network type\n"
2536 "Specify OSPF6 broadcast network\n"
2537 "Specify OSPF6 point-to-point network\n")
2538 {
2539 VTY_DECLVAR_CONTEXT(interface, ifp);
2540 struct ospf6_interface *oi;
2541 int type;
2542
2543 assert(ifp);
2544
2545 oi = (struct ospf6_interface *)ifp->info;
2546 if (oi == NULL) {
2547 return CMD_SUCCESS;
2548 }
2549
2550 oi->type_cfg = false;
2551
2552 type = ospf6_default_iftype(ifp);
2553 if (oi->type == type) {
2554 return CMD_SUCCESS;
2555 }
2556 oi->type = type;
2557
2558 /* Reset the interface */
2559 thread_execute(master, interface_down, oi, 0);
2560 thread_execute(master, interface_up, oi, 0);
2561
2562 return CMD_SUCCESS;
2563 }
2564
2565 static int config_write_ospf6_interface(struct vty *vty, struct vrf *vrf)
2566 {
2567 struct ospf6_interface *oi;
2568 struct interface *ifp;
2569 char buf[INET_ADDRSTRLEN];
2570
2571 FOR_ALL_INTERFACES (vrf, ifp) {
2572 oi = (struct ospf6_interface *)ifp->info;
2573 if (oi == NULL)
2574 continue;
2575
2576 if_vty_config_start(vty, ifp);
2577
2578 if (ifp->desc)
2579 vty_out(vty, " description %s\n", ifp->desc);
2580 if (oi->area_id_format != OSPF6_AREA_FMT_UNSET) {
2581 area_id2str(buf, sizeof(buf), oi->area_id,
2582 oi->area_id_format);
2583 vty_out(vty, " ipv6 ospf6 area %s\n", buf);
2584 }
2585 if (oi->c_ifmtu)
2586 vty_out(vty, " ipv6 ospf6 ifmtu %d\n", oi->c_ifmtu);
2587
2588 if (CHECK_FLAG(oi->flag, OSPF6_INTERFACE_NOAUTOCOST))
2589 vty_out(vty, " ipv6 ospf6 cost %d\n", oi->cost);
2590
2591 if (oi->hello_interval != OSPF6_INTERFACE_HELLO_INTERVAL)
2592 vty_out(vty, " ipv6 ospf6 hello-interval %d\n",
2593 oi->hello_interval);
2594
2595 if (oi->dead_interval != OSPF6_INTERFACE_DEAD_INTERVAL)
2596 vty_out(vty, " ipv6 ospf6 dead-interval %d\n",
2597 oi->dead_interval);
2598
2599 if (oi->rxmt_interval != OSPF6_INTERFACE_RXMT_INTERVAL)
2600 vty_out(vty, " ipv6 ospf6 retransmit-interval %d\n",
2601 oi->rxmt_interval);
2602
2603 if (oi->priority != OSPF6_INTERFACE_PRIORITY)
2604 vty_out(vty, " ipv6 ospf6 priority %d\n", oi->priority);
2605
2606 if (oi->transdelay != OSPF6_INTERFACE_TRANSDELAY)
2607 vty_out(vty, " ipv6 ospf6 transmit-delay %d\n",
2608 oi->transdelay);
2609
2610 if (oi->instance_id != OSPF6_INTERFACE_INSTANCE_ID)
2611 vty_out(vty, " ipv6 ospf6 instance-id %d\n",
2612 oi->instance_id);
2613
2614 if (oi->plist_name)
2615 vty_out(vty, " ipv6 ospf6 advertise prefix-list %s\n",
2616 oi->plist_name);
2617
2618 if (CHECK_FLAG(oi->flag, OSPF6_INTERFACE_PASSIVE))
2619 vty_out(vty, " ipv6 ospf6 passive\n");
2620
2621 if (oi->mtu_ignore)
2622 vty_out(vty, " ipv6 ospf6 mtu-ignore\n");
2623
2624 if (oi->type_cfg && oi->type == OSPF_IFTYPE_POINTOPOINT)
2625 vty_out(vty, " ipv6 ospf6 network point-to-point\n");
2626 else if (oi->type_cfg && oi->type == OSPF_IFTYPE_BROADCAST)
2627 vty_out(vty, " ipv6 ospf6 network broadcast\n");
2628
2629 ospf6_bfd_write_config(vty, oi);
2630
2631 ospf6_auth_write_config(vty, &oi->at_data);
2632 if_vty_config_end(vty);
2633 }
2634 return 0;
2635 }
2636
2637 /* Configuration write function for ospfd. */
2638 static int config_write_interface(struct vty *vty)
2639 {
2640 int write = 0;
2641 struct vrf *vrf = NULL;
2642
2643 /* Display all VRF aware OSPF interface configuration */
2644 RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
2645 write += config_write_ospf6_interface(vty, vrf);
2646 }
2647
2648 return write;
2649 }
2650
2651 static int ospf6_ifp_create(struct interface *ifp)
2652 {
2653 if (IS_OSPF6_DEBUG_ZEBRA(RECV))
2654 zlog_debug("Zebra Interface add: %s index %d mtu %d", ifp->name,
2655 ifp->ifindex, ifp->mtu6);
2656
2657 if (ifp->info)
2658 ospf6_interface_start(ifp->info);
2659
2660 return 0;
2661 }
2662
2663 static int ospf6_ifp_up(struct interface *ifp)
2664 {
2665 if (IS_OSPF6_DEBUG_ZEBRA(RECV))
2666 zlog_debug(
2667 "Zebra Interface state change: %s index %d flags %llx metric %d mtu %d bandwidth %d",
2668 ifp->name, ifp->ifindex, (unsigned long long)ifp->flags,
2669 ifp->metric, ifp->mtu6, ifp->bandwidth);
2670
2671 ospf6_interface_state_update(ifp);
2672
2673 return 0;
2674 }
2675
2676 static int ospf6_ifp_down(struct interface *ifp)
2677 {
2678 if (IS_OSPF6_DEBUG_ZEBRA(RECV))
2679 zlog_debug(
2680 "Zebra Interface state change: %s index %d flags %llx metric %d mtu %d bandwidth %d",
2681 ifp->name, ifp->ifindex, (unsigned long long)ifp->flags,
2682 ifp->metric, ifp->mtu6, ifp->bandwidth);
2683
2684 ospf6_interface_state_update(ifp);
2685
2686 return 0;
2687 }
2688
2689 static int ospf6_ifp_destroy(struct interface *ifp)
2690 {
2691 if (if_is_up(ifp))
2692 zlog_warn("Zebra: got delete of %s, but interface is still up",
2693 ifp->name);
2694
2695 if (IS_OSPF6_DEBUG_ZEBRA(RECV))
2696 zlog_debug("Zebra Interface delete: %s index %d mtu %d",
2697 ifp->name, ifp->ifindex, ifp->mtu6);
2698
2699 if (ifp->info)
2700 ospf6_interface_stop(ifp->info);
2701
2702 return 0;
2703 }
2704
2705 void ospf6_interface_init(void)
2706 {
2707 /* Install interface node. */
2708 if_cmd_init(config_write_interface);
2709 if_zapi_callbacks(ospf6_ifp_create, ospf6_ifp_up,
2710 ospf6_ifp_down, ospf6_ifp_destroy);
2711
2712 install_element(VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
2713 install_element(VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
2714 install_element(VIEW_NODE,
2715 &show_ipv6_ospf6_interface_ifname_prefix_cmd);
2716 install_element(VIEW_NODE, &show_ipv6_ospf6_interface_traffic_cmd);
2717
2718 install_element(INTERFACE_NODE, &ipv6_ospf6_area_cmd);
2719 install_element(INTERFACE_NODE, &no_ipv6_ospf6_area_cmd);
2720 install_element(INTERFACE_NODE, &ipv6_ospf6_cost_cmd);
2721 install_element(INTERFACE_NODE, &no_ipv6_ospf6_cost_cmd);
2722 install_element(INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd);
2723 install_element(INTERFACE_NODE, &no_ipv6_ospf6_ifmtu_cmd);
2724
2725 install_element(INTERFACE_NODE, &ipv6_ospf6_deadinterval_cmd);
2726 install_element(INTERFACE_NODE, &ipv6_ospf6_hellointerval_cmd);
2727 install_element(INTERFACE_NODE, &ipv6_ospf6_priority_cmd);
2728 install_element(INTERFACE_NODE, &ipv6_ospf6_retransmitinterval_cmd);
2729 install_element(INTERFACE_NODE, &ipv6_ospf6_transmitdelay_cmd);
2730 install_element(INTERFACE_NODE, &ipv6_ospf6_instance_cmd);
2731 install_element(INTERFACE_NODE, &no_ipv6_ospf6_deadinterval_cmd);
2732 install_element(INTERFACE_NODE, &no_ipv6_ospf6_hellointerval_cmd);
2733 install_element(INTERFACE_NODE, &no_ipv6_ospf6_priority_cmd);
2734 install_element(INTERFACE_NODE, &no_ipv6_ospf6_retransmitinterval_cmd);
2735 install_element(INTERFACE_NODE, &no_ipv6_ospf6_transmitdelay_cmd);
2736 install_element(INTERFACE_NODE, &no_ipv6_ospf6_instance_cmd);
2737
2738 install_element(INTERFACE_NODE, &ipv6_ospf6_passive_cmd);
2739 install_element(INTERFACE_NODE, &no_ipv6_ospf6_passive_cmd);
2740
2741 install_element(INTERFACE_NODE, &ipv6_ospf6_mtu_ignore_cmd);
2742 install_element(INTERFACE_NODE, &no_ipv6_ospf6_mtu_ignore_cmd);
2743
2744 install_element(INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd);
2745 install_element(INTERFACE_NODE,
2746 &no_ipv6_ospf6_advertise_prefix_list_cmd);
2747
2748 install_element(INTERFACE_NODE, &ipv6_ospf6_network_cmd);
2749 install_element(INTERFACE_NODE, &no_ipv6_ospf6_network_cmd);
2750
2751 /* reference bandwidth commands */
2752 install_element(OSPF6_NODE, &auto_cost_reference_bandwidth_cmd);
2753 install_element(OSPF6_NODE, &no_auto_cost_reference_bandwidth_cmd);
2754 /* write-multiplier commands */
2755 install_element(OSPF6_NODE, &ospf6_write_multiplier_cmd);
2756 install_element(OSPF6_NODE, &no_ospf6_write_multiplier_cmd);
2757 }
2758
2759 /* Clear the specified interface structure */
2760 void ospf6_interface_clear(struct interface *ifp)
2761 {
2762 struct ospf6_interface *oi;
2763
2764 if (!if_is_operative(ifp))
2765 return;
2766
2767 if (ifp->info == NULL)
2768 return;
2769
2770 oi = (struct ospf6_interface *)ifp->info;
2771
2772 if (IS_OSPF6_DEBUG_INTERFACE)
2773 zlog_debug("Interface %s: clear by reset", ifp->name);
2774
2775 /* Reset the interface */
2776 thread_execute(master, interface_down, oi, 0);
2777 thread_execute(master, interface_up, oi, 0);
2778 }
2779
2780 /* Clear interface */
2781 DEFUN (clear_ipv6_ospf6_interface,
2782 clear_ipv6_ospf6_interface_cmd,
2783 "clear ipv6 ospf6 [vrf NAME] interface [IFNAME]",
2784 CLEAR_STR
2785 IP6_STR
2786 OSPF6_STR
2787 VRF_CMD_HELP_STR
2788 INTERFACE_STR
2789 IFNAME_STR
2790 )
2791 {
2792 struct vrf *vrf;
2793 int idx_vrf = 3;
2794 int idx_ifname = 4;
2795 struct interface *ifp;
2796 const char *vrf_name;
2797
2798 if (argv_find(argv, argc, "vrf", &idx_vrf))
2799 vrf_name = argv[idx_vrf + 1]->arg;
2800 else
2801 vrf_name = VRF_DEFAULT_NAME;
2802 vrf = vrf_lookup_by_name(vrf_name);
2803 if (!vrf) {
2804 vty_out(vty, "%% VRF %s not found\n", vrf_name);
2805 return CMD_WARNING;
2806 }
2807
2808 if (!argv_find(argv, argc, "IFNAME", &idx_ifname)) {
2809 /* Clear all the ospfv3 interfaces. */
2810 FOR_ALL_INTERFACES (vrf, ifp)
2811 ospf6_interface_clear(ifp);
2812 } else {
2813 /* Interface name is specified. */
2814 ifp = if_lookup_by_name_vrf(argv[idx_ifname]->arg, vrf);
2815 if (!ifp) {
2816 vty_out(vty, "No such Interface: %s\n",
2817 argv[idx_ifname]->arg);
2818 return CMD_WARNING;
2819 }
2820 ospf6_interface_clear(ifp);
2821 }
2822
2823 return CMD_SUCCESS;
2824 }
2825
2826 void install_element_ospf6_clear_interface(void)
2827 {
2828 install_element(ENABLE_NODE, &clear_ipv6_ospf6_interface_cmd);
2829 }
2830
2831 DEFUN (debug_ospf6_interface,
2832 debug_ospf6_interface_cmd,
2833 "debug ospf6 interface",
2834 DEBUG_STR
2835 OSPF6_STR
2836 "Debug OSPFv3 Interface\n"
2837 )
2838 {
2839 OSPF6_DEBUG_INTERFACE_ON();
2840 return CMD_SUCCESS;
2841 }
2842
2843 DEFUN (no_debug_ospf6_interface,
2844 no_debug_ospf6_interface_cmd,
2845 "no debug ospf6 interface",
2846 NO_STR
2847 DEBUG_STR
2848 OSPF6_STR
2849 "Debug OSPFv3 Interface\n"
2850 )
2851 {
2852 OSPF6_DEBUG_INTERFACE_OFF();
2853 return CMD_SUCCESS;
2854 }
2855
2856 int config_write_ospf6_debug_interface(struct vty *vty)
2857 {
2858 if (IS_OSPF6_DEBUG_INTERFACE)
2859 vty_out(vty, "debug ospf6 interface\n");
2860 return 0;
2861 }
2862
2863 void install_element_ospf6_debug_interface(void)
2864 {
2865 install_element(ENABLE_NODE, &debug_ospf6_interface_cmd);
2866 install_element(ENABLE_NODE, &no_debug_ospf6_interface_cmd);
2867 install_element(CONFIG_NODE, &debug_ospf6_interface_cmd);
2868 install_element(CONFIG_NODE, &no_debug_ospf6_interface_cmd);
2869 }
2870
2871 void ospf6_auth_write_config(struct vty *vty, struct ospf6_auth_data *at_data)
2872 {
2873 if (CHECK_FLAG(at_data->flags, OSPF6_AUTH_TRAILER_KEYCHAIN))
2874 vty_out(vty, " ipv6 ospf6 authentication keychain %s\n",
2875 at_data->keychain);
2876 else if (CHECK_FLAG(at_data->flags, OSPF6_AUTH_TRAILER_MANUAL_KEY))
2877 vty_out(vty,
2878 " ipv6 ospf6 authentication key-id %d hash-algo %s key %s\n",
2879 at_data->key_id,
2880 keychain_get_algo_name_by_id(at_data->hash_algo),
2881 at_data->auth_key);
2882 }
2883
2884 DEFUN(ipv6_ospf6_intf_auth_trailer_keychain,
2885 ipv6_ospf6_intf_auth_trailer_keychain_cmd,
2886 "ipv6 ospf6 authentication keychain KEYCHAIN_NAME",
2887 IP6_STR OSPF6_STR
2888 "Enable authentication on this interface\n"
2889 "Keychain\n"
2890 "Keychain name\n")
2891 {
2892 VTY_DECLVAR_CONTEXT(interface, ifp);
2893 int keychain_idx = 4;
2894 struct ospf6_interface *oi;
2895
2896 oi = (struct ospf6_interface *)ifp->info;
2897 if (oi == NULL)
2898 oi = ospf6_interface_create(ifp);
2899
2900 assert(oi);
2901 if (CHECK_FLAG(oi->at_data.flags, OSPF6_AUTH_TRAILER_MANUAL_KEY)) {
2902 vty_out(vty,
2903 "Manual key configured, unconfigure it before configuring key chain\n");
2904 return CMD_WARNING_CONFIG_FAILED;
2905 }
2906
2907 SET_FLAG(oi->at_data.flags, OSPF6_AUTH_TRAILER_KEYCHAIN);
2908 if (oi->at_data.keychain)
2909 XFREE(MTYPE_OSPF6_AUTH_KEYCHAIN, oi->at_data.keychain);
2910
2911 oi->at_data.keychain =
2912 XSTRDUP(MTYPE_OSPF6_AUTH_KEYCHAIN, argv[keychain_idx]->arg);
2913
2914 return CMD_SUCCESS;
2915 }
2916
2917 DEFUN(no_ipv6_ospf6_intf_auth_trailer_keychain,
2918 no_ipv6_ospf6_intf_auth_trailer_keychain_cmd,
2919 "no ipv6 ospf6 authentication keychain [KEYCHAIN_NAME]",
2920 NO_STR IP6_STR OSPF6_STR
2921 "Enable authentication on this interface\n"
2922 "Keychain\n"
2923 "Keychain name\n")
2924 {
2925 VTY_DECLVAR_CONTEXT(interface, ifp);
2926 struct ospf6_interface *oi;
2927
2928 oi = (struct ospf6_interface *)ifp->info;
2929 if (oi == NULL)
2930 oi = ospf6_interface_create(ifp);
2931
2932 assert(oi);
2933 if (!CHECK_FLAG(oi->at_data.flags, OSPF6_AUTH_TRAILER_KEYCHAIN))
2934 return CMD_SUCCESS;
2935
2936 if (oi->at_data.keychain) {
2937 oi->at_data.flags = 0;
2938 XFREE(MTYPE_OSPF6_AUTH_KEYCHAIN, oi->at_data.keychain);
2939 oi->at_data.keychain = NULL;
2940 }
2941
2942 return CMD_SUCCESS;
2943 }
2944
2945 DEFUN(ipv6_ospf6_intf_auth_trailer_key, ipv6_ospf6_intf_auth_trailer_key_cmd,
2946 "ipv6 ospf6 authentication key-id (1-65535) hash-algo "
2947 "<md5|hmac-sha-1|hmac-sha-256|hmac-sha-384|hmac-sha-512> "
2948 "key WORD",
2949 IP6_STR OSPF6_STR
2950 "Authentication\n"
2951 "Key ID\n"
2952 "Key ID value\n"
2953 "Cryptographic-algorithm\n"
2954 "Use MD5 algorithm\n"
2955 "Use HMAC-SHA-1 algorithm\n"
2956 "Use HMAC-SHA-256 algorithm\n"
2957 "Use HMAC-SHA-384 algorithm\n"
2958 "Use HMAC-SHA-512 algorithm\n"
2959 "Password\n"
2960 "Password string (key)\n")
2961 {
2962 VTY_DECLVAR_CONTEXT(interface, ifp);
2963 int key_id_idx = 4;
2964 int hash_algo_idx = 6;
2965 int password_idx = 8;
2966 struct ospf6_interface *oi;
2967 uint8_t hash_algo = KEYCHAIN_ALGO_NULL;
2968
2969 oi = (struct ospf6_interface *)ifp->info;
2970 if (oi == NULL)
2971 oi = ospf6_interface_create(ifp);
2972
2973 assert(oi);
2974 if (CHECK_FLAG(oi->at_data.flags, OSPF6_AUTH_TRAILER_KEYCHAIN)) {
2975 vty_out(vty,
2976 "key chain configured, unconfigure it before configuring manual key\n");
2977 return CMD_WARNING_CONFIG_FAILED;
2978 }
2979
2980 hash_algo = keychain_get_algo_id_by_name(argv[hash_algo_idx]->arg);
2981 #ifndef CRYPTO_OPENSSL
2982 if (hash_algo == KEYCHAIN_ALGO_NULL) {
2983 vty_out(vty,
2984 "Hash algorithm not supported, compile with --with-crypto=openssl\n");
2985 return CMD_WARNING_CONFIG_FAILED;
2986 }
2987 #endif /* CRYPTO_OPENSSL */
2988
2989 SET_FLAG(oi->at_data.flags, OSPF6_AUTH_TRAILER_MANUAL_KEY);
2990 oi->at_data.hash_algo = hash_algo;
2991 oi->at_data.key_id = (uint16_t)strtol(argv[key_id_idx]->arg, NULL, 10);
2992 if (oi->at_data.auth_key)
2993 XFREE(MTYPE_OSPF6_AUTH_MANUAL_KEY, oi->at_data.auth_key);
2994 oi->at_data.auth_key =
2995 XSTRDUP(MTYPE_OSPF6_AUTH_MANUAL_KEY, argv[password_idx]->arg);
2996
2997 return CMD_SUCCESS;
2998 }
2999
3000 DEFUN(no_ipv6_ospf6_intf_auth_trailer_key,
3001 no_ipv6_ospf6_intf_auth_trailer_key_cmd,
3002 "no ipv6 ospf6 authentication key-id [(1-65535) hash-algo "
3003 "<md5|hmac-sha-1|hmac-sha-256|hmac-sha-384|hmac-sha-512> "
3004 "key WORD]",
3005 NO_STR IP6_STR OSPF6_STR
3006 "Authentication\n"
3007 "Key ID\n"
3008 "Key ID value\n"
3009 "Cryptographic-algorithm\n"
3010 "Use MD5 algorithm\n"
3011 "Use HMAC-SHA-1 algorithm\n"
3012 "Use HMAC-SHA-256 algorithm\n"
3013 "Use HMAC-SHA-384 algorithm\n"
3014 "Use HMAC-SHA-512 algorithm\n"
3015 "Password\n"
3016 "Password string (key)\n")
3017 {
3018 VTY_DECLVAR_CONTEXT(interface, ifp);
3019 struct ospf6_interface *oi;
3020 #ifndef CRYPTO_OPENSSL
3021 int hash_algo_idx = 7;
3022 uint8_t hash_algo = KEYCHAIN_ALGO_NULL;
3023 #endif /* CRYPTO_OPENSSL */
3024
3025 oi = (struct ospf6_interface *)ifp->info;
3026 if (oi == NULL)
3027 oi = ospf6_interface_create(ifp);
3028
3029 assert(oi);
3030 if (!CHECK_FLAG(oi->at_data.flags, OSPF6_AUTH_TRAILER_MANUAL_KEY))
3031 return CMD_SUCCESS;
3032
3033 #ifndef CRYPTO_OPENSSL
3034 hash_algo = keychain_get_algo_id_by_name(argv[hash_algo_idx]->arg);
3035 if (hash_algo == KEYCHAIN_ALGO_NULL) {
3036 vty_out(vty,
3037 "Hash algorithm not supported, compile with --with-crypto=openssl\n");
3038 return CMD_WARNING_CONFIG_FAILED;
3039 }
3040 #endif /* CRYPTO_OPENSSL */
3041
3042 if (oi->at_data.auth_key) {
3043 oi->at_data.flags = 0;
3044 XFREE(MTYPE_OSPF6_AUTH_MANUAL_KEY, oi->at_data.auth_key);
3045 oi->at_data.auth_key = NULL;
3046 }
3047
3048 return CMD_SUCCESS;
3049 }
3050
3051 void ospf6_interface_auth_trailer_cmd_init(void)
3052 {
3053 /*Install OSPF6 auth trailer commands at interface level */
3054 install_element(INTERFACE_NODE,
3055 &ipv6_ospf6_intf_auth_trailer_keychain_cmd);
3056 install_element(INTERFACE_NODE,
3057 &no_ipv6_ospf6_intf_auth_trailer_keychain_cmd);
3058 install_element(INTERFACE_NODE, &ipv6_ospf6_intf_auth_trailer_key_cmd);
3059 install_element(INTERFACE_NODE,
3060 &no_ipv6_ospf6_intf_auth_trailer_key_cmd);
3061 }