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
31 #include "ospf6_proto.h"
32 #include "ospf6_lsa.h"
33 #include "ospf6_lsdb.h"
34 #include "ospf6_message.h"
35 #include "ospf6_top.h"
36 #include "ospf6_area.h"
37 #include "ospf6_interface.h"
38 #include "ospf6_neighbor.h"
39 #include "ospf6_intra.h"
40 #include "ospf6_flood.h"
42 #include "ospf6_bfd.h"
43 #include "ospf6_abr.h"
44 #include "ospf6_asbr.h"
45 #include "ospf6_lsa.h"
46 #include "ospf6_spf.h"
47 #include "ospf6_zebra.h"
51 DEFINE_MTYPE_STATIC(OSPF6D
, OSPF6_NEIGHBOR
, "OSPF6 neighbor");
53 DEFINE_HOOK(ospf6_neighbor_change
,
54 (struct ospf6_neighbor
* on
, int state
, int next_state
),
55 (on
, state
, next_state
));
57 unsigned char conf_debug_ospf6_neighbor
= 0;
59 const char *const ospf6_neighbor_state_str
[] = {
60 "None", "Down", "Attempt", "Init", "Twoway",
61 "ExStart", "ExChange", "Loading", "Full", NULL
};
63 const char *const ospf6_neighbor_event_str
[] = {
64 "NoEvent", "HelloReceived", "2-WayReceived", "NegotiationDone",
65 "ExchangeDone", "LoadingDone", "AdjOK?", "SeqNumberMismatch",
66 "BadLSReq", "1-WayReceived", "InactivityTimer",
69 int ospf6_neighbor_cmp(void *va
, void *vb
)
71 struct ospf6_neighbor
*ona
= (struct ospf6_neighbor
*)va
;
72 struct ospf6_neighbor
*onb
= (struct ospf6_neighbor
*)vb
;
74 if (ona
->router_id
== onb
->router_id
)
77 return (ntohl(ona
->router_id
) < ntohl(onb
->router_id
)) ? -1 : 1;
80 struct ospf6_neighbor
*ospf6_neighbor_lookup(uint32_t router_id
,
81 struct ospf6_interface
*oi
)
84 struct ospf6_neighbor
*on
;
86 for (ALL_LIST_ELEMENTS_RO(oi
->neighbor_list
, n
, on
))
87 if (on
->router_id
== router_id
)
90 return (struct ospf6_neighbor
*)NULL
;
93 struct ospf6_neighbor
*ospf6_area_neighbor_lookup(struct ospf6_area
*area
,
96 struct ospf6_interface
*oi
;
97 struct ospf6_neighbor
*nbr
;
98 struct listnode
*node
;
100 for (ALL_LIST_ELEMENTS_RO(area
->if_list
, node
, oi
)) {
101 nbr
= ospf6_neighbor_lookup(router_id
, oi
);
109 /* create ospf6_neighbor */
110 struct ospf6_neighbor
*ospf6_neighbor_create(uint32_t router_id
,
111 struct ospf6_interface
*oi
)
113 struct ospf6_neighbor
*on
;
117 on
= XCALLOC(MTYPE_OSPF6_NEIGHBOR
, sizeof(struct ospf6_neighbor
));
118 inet_ntop(AF_INET
, &router_id
, buf
, sizeof(buf
));
119 snprintf(on
->name
, sizeof(on
->name
), "%s%%%s", buf
,
120 oi
->interface
->name
);
122 on
->state
= OSPF6_NEIGHBOR_DOWN
;
123 on
->state_change
= 0;
124 monotime(&on
->last_changed
);
125 on
->router_id
= router_id
;
127 on
->summary_list
= ospf6_lsdb_create(on
);
128 on
->request_list
= ospf6_lsdb_create(on
);
129 on
->retrans_list
= ospf6_lsdb_create(on
);
131 on
->dbdesc_list
= ospf6_lsdb_create(on
);
132 on
->lsupdate_list
= ospf6_lsdb_create(on
);
133 on
->lsack_list
= ospf6_lsdb_create(on
);
135 for (type
= 0; type
< OSPF6_MESSAGE_TYPE_MAX
; type
++) {
136 on
->seqnum_l
[type
] = 0;
137 on
->seqnum_h
[type
] = 0;
140 on
->auth_present
= false;
142 listnode_add_sort(oi
->neighbor_list
, on
);
144 ospf6_bfd_info_nbr_create(oi
, on
);
148 void ospf6_neighbor_delete(struct ospf6_neighbor
*on
)
150 struct ospf6_lsa
*lsa
, *lsanext
;
152 ospf6_lsdb_remove_all(on
->summary_list
);
153 ospf6_lsdb_remove_all(on
->request_list
);
154 for (ALL_LSDB(on
->retrans_list
, lsa
, lsanext
)) {
155 ospf6_decrement_retrans_count(lsa
);
156 ospf6_lsdb_remove(lsa
, on
->retrans_list
);
159 ospf6_lsdb_remove_all(on
->dbdesc_list
);
160 ospf6_lsdb_remove_all(on
->lsupdate_list
);
161 ospf6_lsdb_remove_all(on
->lsack_list
);
163 ospf6_lsdb_delete(on
->summary_list
);
164 ospf6_lsdb_delete(on
->request_list
);
165 ospf6_lsdb_delete(on
->retrans_list
);
167 ospf6_lsdb_delete(on
->dbdesc_list
);
168 ospf6_lsdb_delete(on
->lsupdate_list
);
169 ospf6_lsdb_delete(on
->lsack_list
);
171 THREAD_OFF(on
->inactivity_timer
);
173 THREAD_OFF(on
->last_dbdesc_release_timer
);
175 THREAD_OFF(on
->thread_send_dbdesc
);
176 THREAD_OFF(on
->thread_send_lsreq
);
177 THREAD_OFF(on
->thread_send_lsupdate
);
178 THREAD_OFF(on
->thread_send_lsack
);
179 THREAD_OFF(on
->thread_exchange_done
);
180 THREAD_OFF(on
->thread_adj_ok
);
182 THREAD_OFF(on
->gr_helper_info
.t_grace_timer
);
184 bfd_sess_free(&on
->bfd_session
);
185 XFREE(MTYPE_OSPF6_NEIGHBOR
, on
);
188 static void ospf6_neighbor_state_change(uint8_t next_state
,
189 struct ospf6_neighbor
*on
, int event
)
193 prev_state
= on
->state
;
194 on
->state
= next_state
;
196 if (prev_state
== next_state
)
200 monotime(&on
->last_changed
);
203 if (IS_OSPF6_DEBUG_NEIGHBOR(STATE
)) {
204 zlog_debug("Neighbor state change %s: [%s]->[%s] (%s)",
205 on
->name
, ospf6_neighbor_state_str
[prev_state
],
206 ospf6_neighbor_state_str
[next_state
],
207 ospf6_neighbor_event_string(event
));
210 /* Optionally notify about adjacency changes */
211 if (CHECK_FLAG(on
->ospf6_if
->area
->ospf6
->config_flags
,
212 OSPF6_LOG_ADJACENCY_CHANGES
)
213 && (CHECK_FLAG(on
->ospf6_if
->area
->ospf6
->config_flags
,
214 OSPF6_LOG_ADJACENCY_DETAIL
)
215 || (next_state
== OSPF6_NEIGHBOR_FULL
)
216 || (next_state
< prev_state
)))
217 zlog_notice("AdjChg: Nbr %s: %s -> %s (%s)", on
->name
,
218 ospf6_neighbor_state_str
[prev_state
],
219 ospf6_neighbor_state_str
[next_state
],
220 ospf6_neighbor_event_string(event
));
222 if (prev_state
== OSPF6_NEIGHBOR_FULL
223 || next_state
== OSPF6_NEIGHBOR_FULL
) {
224 if (!OSPF6_GR_IS_ACTIVE_HELPER(on
)) {
225 OSPF6_ROUTER_LSA_SCHEDULE(on
->ospf6_if
->area
);
226 if (on
->ospf6_if
->state
== OSPF6_INTERFACE_DR
) {
227 OSPF6_NETWORK_LSA_SCHEDULE(on
->ospf6_if
);
228 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(
232 if (next_state
== OSPF6_NEIGHBOR_FULL
)
233 on
->ospf6_if
->area
->intra_prefix_originate
= 1;
235 if (!OSPF6_GR_IS_ACTIVE_HELPER(on
))
236 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(
239 if ((prev_state
== OSPF6_NEIGHBOR_LOADING
240 || prev_state
== OSPF6_NEIGHBOR_EXCHANGE
)
241 && next_state
== OSPF6_NEIGHBOR_FULL
) {
242 OSPF6_AS_EXTERN_LSA_SCHEDULE(on
->ospf6_if
);
243 on
->ospf6_if
->area
->full_nbrs
++;
246 if (prev_state
== OSPF6_NEIGHBOR_FULL
)
247 on
->ospf6_if
->area
->full_nbrs
--;
250 if ((prev_state
== OSPF6_NEIGHBOR_EXCHANGE
251 || prev_state
== OSPF6_NEIGHBOR_LOADING
)
252 && (next_state
!= OSPF6_NEIGHBOR_EXCHANGE
253 && next_state
!= OSPF6_NEIGHBOR_LOADING
))
254 ospf6_maxage_remove(on
->ospf6_if
->area
->ospf6
);
256 hook_call(ospf6_neighbor_change
, on
, next_state
, prev_state
);
257 ospf6_bfd_trigger_event(on
, prev_state
, next_state
);
260 /* RFC2328 section 10.4 */
261 static int need_adjacency(struct ospf6_neighbor
*on
)
263 if (on
->ospf6_if
->state
== OSPF6_INTERFACE_POINTTOPOINT
264 || on
->ospf6_if
->state
== OSPF6_INTERFACE_DR
265 || on
->ospf6_if
->state
== OSPF6_INTERFACE_BDR
)
268 if (on
->ospf6_if
->drouter
== on
->router_id
269 || on
->ospf6_if
->bdrouter
== on
->router_id
)
275 int hello_received(struct thread
*thread
)
277 struct ospf6_neighbor
*on
;
279 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
282 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
283 zlog_debug("Neighbor Event %s: *HelloReceived*", on
->name
);
285 /* reset Inactivity Timer */
286 THREAD_OFF(on
->inactivity_timer
);
287 thread_add_timer(master
, inactivity_timer
, on
,
288 on
->ospf6_if
->dead_interval
, &on
->inactivity_timer
);
290 if (on
->state
<= OSPF6_NEIGHBOR_DOWN
)
291 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_INIT
, on
,
292 OSPF6_NEIGHBOR_EVENT_HELLO_RCVD
);
297 int twoway_received(struct thread
*thread
)
299 struct ospf6_neighbor
*on
;
301 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
304 if (on
->state
> OSPF6_NEIGHBOR_INIT
)
307 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
308 zlog_debug("Neighbor Event %s: *2Way-Received*", on
->name
);
310 thread_add_event(master
, neighbor_change
, on
->ospf6_if
, 0, NULL
);
312 if (!need_adjacency(on
)) {
313 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_TWOWAY
, on
,
314 OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD
);
318 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART
, on
,
319 OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD
);
320 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
321 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
322 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
324 THREAD_OFF(on
->thread_send_dbdesc
);
325 thread_add_event(master
, ospf6_dbdesc_send
, on
, 0,
326 &on
->thread_send_dbdesc
);
331 int negotiation_done(struct thread
*thread
)
333 struct ospf6_neighbor
*on
;
334 struct ospf6_lsa
*lsa
, *lsanext
;
336 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
339 if (on
->state
!= OSPF6_NEIGHBOR_EXSTART
)
342 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
343 zlog_debug("Neighbor Event %s: *NegotiationDone*", on
->name
);
346 ospf6_lsdb_remove_all(on
->summary_list
);
347 ospf6_lsdb_remove_all(on
->request_list
);
348 for (ALL_LSDB(on
->retrans_list
, lsa
, lsanext
)) {
349 ospf6_decrement_retrans_count(lsa
);
350 ospf6_lsdb_remove(lsa
, on
->retrans_list
);
353 /* Interface scoped LSAs */
354 for (ALL_LSDB(on
->ospf6_if
->lsdb
, lsa
, lsanext
)) {
355 if (OSPF6_LSA_IS_MAXAGE(lsa
)) {
356 ospf6_increment_retrans_count(lsa
);
357 ospf6_lsdb_add(ospf6_lsa_copy(lsa
), on
->retrans_list
);
359 ospf6_lsdb_add(ospf6_lsa_copy(lsa
), on
->summary_list
);
362 /* Area scoped LSAs */
363 for (ALL_LSDB(on
->ospf6_if
->area
->lsdb
, lsa
, lsanext
)) {
364 if (OSPF6_LSA_IS_MAXAGE(lsa
)) {
365 ospf6_increment_retrans_count(lsa
);
366 ospf6_lsdb_add(ospf6_lsa_copy(lsa
), on
->retrans_list
);
368 ospf6_lsdb_add(ospf6_lsa_copy(lsa
), on
->summary_list
);
372 for (ALL_LSDB(on
->ospf6_if
->area
->ospf6
->lsdb
, lsa
, lsanext
)) {
373 if (OSPF6_LSA_IS_MAXAGE(lsa
)) {
374 ospf6_increment_retrans_count(lsa
);
375 ospf6_lsdb_add(ospf6_lsa_copy(lsa
), on
->retrans_list
);
377 ospf6_lsdb_add(ospf6_lsa_copy(lsa
), on
->summary_list
);
380 UNSET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
381 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXCHANGE
, on
,
382 OSPF6_NEIGHBOR_EVENT_NEGOTIATION_DONE
);
387 static int ospf6_neighbor_last_dbdesc_release(struct thread
*thread
)
389 struct ospf6_neighbor
*on
= THREAD_ARG(thread
);
392 memset(&on
->dbdesc_last
, 0, sizeof(struct ospf6_dbdesc
));
397 int exchange_done(struct thread
*thread
)
399 struct ospf6_neighbor
*on
;
401 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
404 if (on
->state
!= OSPF6_NEIGHBOR_EXCHANGE
)
407 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
408 zlog_debug("Neighbor Event %s: *ExchangeDone*", on
->name
);
410 THREAD_OFF(on
->thread_send_dbdesc
);
411 ospf6_lsdb_remove_all(on
->dbdesc_list
);
413 /* RFC 2328 (10.8): Release the last dbdesc after dead_interval */
414 if (!CHECK_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
)) {
415 THREAD_OFF(on
->last_dbdesc_release_timer
);
416 thread_add_timer(master
, ospf6_neighbor_last_dbdesc_release
, on
,
417 on
->ospf6_if
->dead_interval
,
418 &on
->last_dbdesc_release_timer
);
421 if (on
->request_list
->count
== 0)
422 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_FULL
, on
,
423 OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE
);
425 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_LOADING
, on
,
426 OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE
);
428 thread_add_event(master
, ospf6_lsreq_send
, on
, 0,
429 &on
->thread_send_lsreq
);
435 /* Check loading state. */
436 void ospf6_check_nbr_loading(struct ospf6_neighbor
*on
)
439 /* RFC2328 Section 10.9: When the neighbor responds to these requests
440 with the proper Link State Update packet(s), the Link state request
441 list is truncated and a new Link State Request packet is sent.
443 if ((on
->state
== OSPF6_NEIGHBOR_LOADING
)
444 || (on
->state
== OSPF6_NEIGHBOR_EXCHANGE
)) {
445 if (on
->request_list
->count
== 0)
446 thread_add_event(master
, loading_done
, on
, 0, NULL
);
447 else if (on
->last_ls_req
== NULL
) {
448 if (on
->thread_send_lsreq
!= NULL
)
449 THREAD_OFF(on
->thread_send_lsreq
);
450 thread_add_event(master
, ospf6_lsreq_send
, on
, 0,
451 &on
->thread_send_lsreq
);
456 int loading_done(struct thread
*thread
)
458 struct ospf6_neighbor
*on
;
460 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
463 if (on
->state
!= OSPF6_NEIGHBOR_LOADING
)
466 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
467 zlog_debug("Neighbor Event %s: *LoadingDone*", on
->name
);
469 assert(on
->request_list
->count
== 0);
471 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_FULL
, on
,
472 OSPF6_NEIGHBOR_EVENT_LOADING_DONE
);
477 int adj_ok(struct thread
*thread
)
479 struct ospf6_neighbor
*on
;
480 struct ospf6_lsa
*lsa
, *lsanext
;
482 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
485 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
486 zlog_debug("Neighbor Event %s: *AdjOK?*", on
->name
);
488 if (on
->state
== OSPF6_NEIGHBOR_TWOWAY
&& need_adjacency(on
)) {
489 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART
, on
,
490 OSPF6_NEIGHBOR_EVENT_ADJ_OK
);
491 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
492 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
493 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
495 THREAD_OFF(on
->thread_send_dbdesc
);
496 on
->thread_send_dbdesc
= NULL
;
497 thread_add_event(master
, ospf6_dbdesc_send
, on
, 0,
498 &on
->thread_send_dbdesc
);
500 } else if (on
->state
>= OSPF6_NEIGHBOR_EXSTART
&& !need_adjacency(on
)) {
501 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_TWOWAY
, on
,
502 OSPF6_NEIGHBOR_EVENT_ADJ_OK
);
503 ospf6_lsdb_remove_all(on
->summary_list
);
504 ospf6_lsdb_remove_all(on
->request_list
);
505 for (ALL_LSDB(on
->retrans_list
, lsa
, lsanext
)) {
506 ospf6_decrement_retrans_count(lsa
);
507 ospf6_lsdb_remove(lsa
, on
->retrans_list
);
514 int seqnumber_mismatch(struct thread
*thread
)
516 struct ospf6_neighbor
*on
;
517 struct ospf6_lsa
*lsa
, *lsanext
;
519 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
522 if (on
->state
< OSPF6_NEIGHBOR_EXCHANGE
)
525 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
526 zlog_debug("Neighbor Event %s: *SeqNumberMismatch*", on
->name
);
528 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART
, on
,
529 OSPF6_NEIGHBOR_EVENT_SEQNUMBER_MISMATCH
);
530 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
531 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
532 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
534 ospf6_lsdb_remove_all(on
->summary_list
);
535 ospf6_lsdb_remove_all(on
->request_list
);
536 for (ALL_LSDB(on
->retrans_list
, lsa
, lsanext
)) {
537 ospf6_decrement_retrans_count(lsa
);
538 ospf6_lsdb_remove(lsa
, on
->retrans_list
);
541 THREAD_OFF(on
->thread_send_dbdesc
);
542 on
->dbdesc_seqnum
++; /* Incr seqnum as per RFC2328, sec 10.3 */
544 on
->thread_send_dbdesc
= NULL
;
545 thread_add_event(master
, ospf6_dbdesc_send
, on
, 0,
546 &on
->thread_send_dbdesc
);
551 int bad_lsreq(struct thread
*thread
)
553 struct ospf6_neighbor
*on
;
554 struct ospf6_lsa
*lsa
, *lsanext
;
556 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
559 if (on
->state
< OSPF6_NEIGHBOR_EXCHANGE
)
562 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
563 zlog_debug("Neighbor Event %s: *BadLSReq*", on
->name
);
565 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART
, on
,
566 OSPF6_NEIGHBOR_EVENT_BAD_LSREQ
);
567 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
568 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
569 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
571 ospf6_lsdb_remove_all(on
->summary_list
);
572 ospf6_lsdb_remove_all(on
->request_list
);
573 for (ALL_LSDB(on
->retrans_list
, lsa
, lsanext
)) {
574 ospf6_decrement_retrans_count(lsa
);
575 ospf6_lsdb_remove(lsa
, on
->retrans_list
);
578 THREAD_OFF(on
->thread_send_dbdesc
);
579 on
->dbdesc_seqnum
++; /* Incr seqnum as per RFC2328, sec 10.3 */
581 on
->thread_send_dbdesc
= NULL
;
582 thread_add_event(master
, ospf6_dbdesc_send
, on
, 0,
583 &on
->thread_send_dbdesc
);
588 int oneway_received(struct thread
*thread
)
590 struct ospf6_neighbor
*on
;
591 struct ospf6_lsa
*lsa
, *lsanext
;
593 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
596 if (on
->state
< OSPF6_NEIGHBOR_TWOWAY
)
599 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
600 zlog_debug("Neighbor Event %s: *1Way-Received*", on
->name
);
602 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_INIT
, on
,
603 OSPF6_NEIGHBOR_EVENT_ONEWAY_RCVD
);
604 thread_add_event(master
, neighbor_change
, on
->ospf6_if
, 0, NULL
);
606 ospf6_lsdb_remove_all(on
->summary_list
);
607 ospf6_lsdb_remove_all(on
->request_list
);
608 for (ALL_LSDB(on
->retrans_list
, lsa
, lsanext
)) {
609 ospf6_decrement_retrans_count(lsa
);
610 ospf6_lsdb_remove(lsa
, on
->retrans_list
);
613 THREAD_OFF(on
->thread_send_dbdesc
);
614 THREAD_OFF(on
->thread_send_lsreq
);
615 THREAD_OFF(on
->thread_send_lsupdate
);
616 THREAD_OFF(on
->thread_send_lsack
);
617 THREAD_OFF(on
->thread_exchange_done
);
618 THREAD_OFF(on
->thread_adj_ok
);
623 int inactivity_timer(struct thread
*thread
)
625 struct ospf6_neighbor
*on
;
627 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
630 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
631 zlog_debug("Neighbor Event %s: *InactivityTimer*", on
->name
);
633 on
->drouter
= on
->prev_drouter
= 0;
634 on
->bdrouter
= on
->prev_bdrouter
= 0;
636 if (!OSPF6_GR_IS_ACTIVE_HELPER(on
)) {
637 on
->drouter
= on
->prev_drouter
= 0;
638 on
->bdrouter
= on
->prev_bdrouter
= 0;
640 ospf6_neighbor_state_change(
641 OSPF6_NEIGHBOR_DOWN
, on
,
642 OSPF6_NEIGHBOR_EVENT_INACTIVITY_TIMER
);
643 thread_add_event(master
, neighbor_change
, on
->ospf6_if
, 0,
646 listnode_delete(on
->ospf6_if
->neighbor_list
, on
);
647 ospf6_neighbor_delete(on
);
650 if (IS_DEBUG_OSPF6_GR
)
652 "%s, Acting as HELPER for this neighbour, So restart the dead timer.",
653 __PRETTY_FUNCTION__
);
655 thread_add_timer(master
, inactivity_timer
, on
,
656 on
->ospf6_if
->dead_interval
,
657 &on
->inactivity_timer
);
665 /* show neighbor structure */
666 static void ospf6_neighbor_show(struct vty
*vty
, struct ospf6_neighbor
*on
,
667 json_object
*json_array
, bool use_json
)
675 json_object
*json_route
;
677 /* Router-ID (Name) */
678 inet_ntop(AF_INET
, &on
->router_id
, router_id
, sizeof(router_id
));
679 #ifdef HAVE_GETNAMEINFO
682 #endif /*HAVE_GETNAMEINFO*/
686 if (on
->inactivity_timer
) {
687 s
= monotime_until(&on
->inactivity_timer
->u
.sands
, NULL
)
694 snprintf(deadtime
, sizeof(deadtime
), "%02ld:%02ld:%02ld", h
, m
, s
);
697 if (on
->ospf6_if
->type
== OSPF_IFTYPE_POINTOPOINT
)
698 snprintf(nstate
, sizeof(nstate
), "PointToPoint");
700 if (on
->router_id
== on
->drouter
)
701 snprintf(nstate
, sizeof(nstate
), "DR");
702 else if (on
->router_id
== on
->bdrouter
)
703 snprintf(nstate
, sizeof(nstate
), "BDR");
705 snprintf(nstate
, sizeof(nstate
), "DROther");
709 monotime_since(&on
->last_changed
, &res
);
710 timerstring(&res
, duration
, sizeof(duration
));
713 vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]\n",
714 "Neighbor ID", "Pri", "DeadTime", "State", "IfState",
715 "Duration", "I/F", "State");
718 json_route
= json_object_new_object();
720 json_object_string_add(json_route
, "neighborId", router_id
);
721 json_object_int_add(json_route
, "priority", on
->priority
);
722 json_object_string_add(json_route
, "deadTime", deadtime
);
723 json_object_string_add(json_route
, "state",
724 ospf6_neighbor_state_str
[on
->state
]);
725 json_object_string_add(json_route
, "ifState", nstate
);
726 json_object_string_add(json_route
, "duration", duration
);
727 json_object_string_add(json_route
, "interfaceName",
728 on
->ospf6_if
->interface
->name
);
729 json_object_string_add(
730 json_route
, "interfaceState",
731 ospf6_interface_state_str
[on
->ospf6_if
->state
]);
733 json_object_array_add(json_array
, json_route
);
735 vty_out(vty
, "%-15s %3d %11s %8s/%-12s %11s %s[%s]\n",
736 router_id
, on
->priority
, deadtime
,
737 ospf6_neighbor_state_str
[on
->state
], nstate
, duration
,
738 on
->ospf6_if
->interface
->name
,
739 ospf6_interface_state_str
[on
->ospf6_if
->state
]);
742 static void ospf6_neighbor_show_drchoice(struct vty
*vty
,
743 struct ospf6_neighbor
*on
,
744 json_object
*json_array
, bool use_json
)
747 char drouter
[16], bdrouter
[16];
749 struct timeval now
, res
;
750 json_object
*json_route
;
753 vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]\n",
754 "RouterID", "State", "Duration", "DR", "BDR", "I/F",
758 inet_ntop(AF_INET
, &on
->router_id
, router_id
, sizeof(router_id
));
759 inet_ntop(AF_INET
, &on
->drouter
, drouter
, sizeof(drouter
));
760 inet_ntop(AF_INET
, &on
->bdrouter
, bdrouter
, sizeof(bdrouter
));
763 timersub(&now
, &on
->last_changed
, &res
);
764 timerstring(&res
, duration
, sizeof(duration
));
767 json_route
= json_object_new_object();
768 json_object_string_add(json_route
, "routerId", router_id
);
769 json_object_string_add(json_route
, "state",
770 ospf6_neighbor_state_str
[on
->state
]);
771 json_object_string_add(json_route
, "duration", duration
);
772 json_object_string_add(json_route
, "dRouter", drouter
);
773 json_object_string_add(json_route
, "bdRouter", bdrouter
);
774 json_object_string_add(json_route
, "interfaceName",
775 on
->ospf6_if
->interface
->name
);
776 json_object_string_add(
777 json_route
, "interfaceState",
778 ospf6_interface_state_str
[on
->ospf6_if
->state
]);
780 json_object_array_add(json_array
, json_route
);
782 vty_out(vty
, "%-15s %8s/%-11s %-15s %-15s %s[%s]\n", router_id
,
783 ospf6_neighbor_state_str
[on
->state
], duration
, drouter
,
784 bdrouter
, on
->ospf6_if
->interface
->name
,
785 ospf6_interface_state_str
[on
->ospf6_if
->state
]);
788 static void ospf6_neighbor_show_detail(struct vty
*vty
,
789 struct ospf6_neighbor
*on
,
790 json_object
*json
, bool use_json
)
792 char drouter
[16], bdrouter
[16];
793 char linklocal_addr
[64], duration
[32];
794 struct timeval now
, res
;
795 struct ospf6_lsa
*lsa
, *lsanext
;
796 json_object
*json_neighbor
;
797 json_object
*json_array
;
798 char db_desc_str
[20];
800 inet_ntop(AF_INET6
, &on
->linklocal_addr
, linklocal_addr
,
801 sizeof(linklocal_addr
));
802 inet_ntop(AF_INET
, &on
->drouter
, drouter
, sizeof(drouter
));
803 inet_ntop(AF_INET
, &on
->bdrouter
, bdrouter
, sizeof(bdrouter
));
806 timersub(&now
, &on
->last_changed
, &res
);
807 timerstring(&res
, duration
, sizeof(duration
));
810 json_neighbor
= json_object_new_object();
811 json_object_string_add(json_neighbor
, "area",
812 on
->ospf6_if
->area
->name
);
813 json_object_string_add(json_neighbor
, "interface",
814 on
->ospf6_if
->interface
->name
);
815 json_object_int_add(json_neighbor
, "interfaceIndex",
816 on
->ospf6_if
->interface
->ifindex
);
817 json_object_int_add(json_neighbor
, "neighborInterfaceIndex",
819 json_object_string_add(json_neighbor
, "linkLocalAddress",
821 json_object_string_add(json_neighbor
, "neighborState",
822 ospf6_neighbor_state_str
[on
->state
]);
823 json_object_string_add(json_neighbor
, "neighborStateDuration",
825 json_object_string_add(json_neighbor
, "neighborDRouter",
827 json_object_string_add(json_neighbor
, "neighborBdRouter",
829 snprintf(db_desc_str
, sizeof(db_desc_str
), "%s%s%s",
830 (CHECK_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
)
833 (CHECK_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
)
836 (CHECK_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
)
839 json_object_string_add(json_neighbor
, "dbDescStatus",
842 json_object_int_add(json_neighbor
, "dbDescSeqNumber",
843 (unsigned long)ntohl(on
->dbdesc_seqnum
));
845 json_array
= json_object_new_array();
846 json_object_int_add(json_neighbor
, "summaryListCount",
847 on
->summary_list
->count
);
848 for (ALL_LSDB(on
->summary_list
, lsa
, lsanext
))
849 json_object_array_add(
850 json_array
, json_object_new_string(lsa
->name
));
851 json_object_object_add(json_neighbor
, "summaryListLsa",
854 json_array
= json_object_new_array();
855 json_object_int_add(json_neighbor
, "requestListCount",
856 on
->request_list
->count
);
857 for (ALL_LSDB(on
->request_list
, lsa
, lsanext
))
858 json_object_array_add(
859 json_array
, json_object_new_string(lsa
->name
));
860 json_object_object_add(json_neighbor
, "requestListLsa",
863 json_array
= json_object_new_array();
864 json_object_int_add(json_neighbor
, "reTransListCount",
865 on
->retrans_list
->count
);
866 for (ALL_LSDB(on
->retrans_list
, lsa
, lsanext
))
867 json_object_array_add(
868 json_array
, json_object_new_string(lsa
->name
));
869 json_object_object_add(json_neighbor
, "reTransListLsa",
874 if (on
->thread_send_dbdesc
)
875 timersub(&on
->thread_send_dbdesc
->u
.sands
, &now
, &res
);
876 timerstring(&res
, duration
, sizeof(duration
));
877 json_object_int_add(json_neighbor
, "pendingLsaDbDescCount",
878 on
->dbdesc_list
->count
);
879 json_object_string_add(json_neighbor
, "pendingLsaDbDescTime",
881 json_object_string_add(json_neighbor
, "dbDescSendThread",
882 (on
->thread_send_dbdesc
? "on" : "off"));
883 json_array
= json_object_new_array();
884 for (ALL_LSDB(on
->dbdesc_list
, lsa
, lsanext
))
885 json_object_array_add(
886 json_array
, json_object_new_string(lsa
->name
));
887 json_object_object_add(json_neighbor
, "pendingLsaDbDesc",
891 if (on
->thread_send_lsreq
)
892 timersub(&on
->thread_send_lsreq
->u
.sands
, &now
, &res
);
893 timerstring(&res
, duration
, sizeof(duration
));
894 json_object_int_add(json_neighbor
, "pendingLsaLsReqCount",
895 on
->request_list
->count
);
896 json_object_string_add(json_neighbor
, "pendingLsaLsReqTime",
898 json_object_string_add(json_neighbor
, "lsReqSendThread",
899 (on
->thread_send_lsreq
? "on" : "off"));
900 json_array
= json_object_new_array();
901 for (ALL_LSDB(on
->request_list
, lsa
, lsanext
))
902 json_object_array_add(
903 json_array
, json_object_new_string(lsa
->name
));
904 json_object_object_add(json_neighbor
, "pendingLsaLsReq",
909 if (on
->thread_send_lsupdate
)
910 timersub(&on
->thread_send_lsupdate
->u
.sands
, &now
,
912 timerstring(&res
, duration
, sizeof(duration
));
913 json_object_int_add(json_neighbor
, "pendingLsaLsUpdateCount",
914 on
->lsupdate_list
->count
);
915 json_object_string_add(json_neighbor
, "pendingLsaLsUpdateTime",
917 json_object_string_add(
918 json_neighbor
, "lsUpdateSendThread",
919 (on
->thread_send_lsupdate
? "on" : "off"));
920 json_array
= json_object_new_array();
921 for (ALL_LSDB(on
->lsupdate_list
, lsa
, lsanext
))
922 json_object_array_add(
923 json_array
, json_object_new_string(lsa
->name
));
924 json_object_object_add(json_neighbor
, "pendingLsaLsUpdate",
928 if (on
->thread_send_lsack
)
929 timersub(&on
->thread_send_lsack
->u
.sands
, &now
, &res
);
930 timerstring(&res
, duration
, sizeof(duration
));
931 json_object_int_add(json_neighbor
, "pendingLsaLsAckCount",
932 on
->lsack_list
->count
);
933 json_object_string_add(json_neighbor
, "pendingLsaLsAckTime",
935 json_object_string_add(json_neighbor
, "lsAckSendThread",
936 (on
->thread_send_lsack
? "on" : "off"));
937 json_array
= json_object_new_array();
938 for (ALL_LSDB(on
->lsack_list
, lsa
, lsanext
))
939 json_object_array_add(
940 json_array
, json_object_new_string(lsa
->name
));
941 json_object_object_add(json_neighbor
, "pendingLsaLsAck",
944 bfd_sess_show(vty
, json_neighbor
, on
->bfd_session
);
946 if (on
->auth_present
== true) {
947 json_object_string_add(json_neighbor
, "authStatus",
950 json_neighbor
, "recvdHelloHigherSeqNo",
951 on
->seqnum_h
[OSPF6_MESSAGE_TYPE_HELLO
]);
953 json_neighbor
, "recvdHelloLowerSeqNo",
954 on
->seqnum_l
[OSPF6_MESSAGE_TYPE_HELLO
]);
956 json_neighbor
, "recvdDBDescHigherSeqNo",
957 on
->seqnum_h
[OSPF6_MESSAGE_TYPE_DBDESC
]);
959 json_neighbor
, "recvdDBDescLowerSeqNo",
960 on
->seqnum_l
[OSPF6_MESSAGE_TYPE_DBDESC
]);
962 json_neighbor
, "recvdLSReqHigherSeqNo",
963 on
->seqnum_h
[OSPF6_MESSAGE_TYPE_LSREQ
]);
965 json_neighbor
, "recvdLSReqLowerSeqNo",
966 on
->seqnum_l
[OSPF6_MESSAGE_TYPE_LSREQ
]);
968 json_neighbor
, "recvdLSUpdHigherSeqNo",
969 on
->seqnum_h
[OSPF6_MESSAGE_TYPE_LSUPDATE
]);
971 json_neighbor
, "recvdLSUpdLowerSeqNo",
972 on
->seqnum_l
[OSPF6_MESSAGE_TYPE_LSUPDATE
]);
974 json_neighbor
, "recvdLSAckHigherSeqNo",
975 on
->seqnum_h
[OSPF6_MESSAGE_TYPE_LSACK
]);
977 json_neighbor
, "recvdLSAckLowerSeqNo",
978 on
->seqnum_l
[OSPF6_MESSAGE_TYPE_LSACK
]);
980 json_object_string_add(json_neighbor
, "authStatus",
983 json_object_object_add(json
, on
->name
, json_neighbor
);
986 vty_out(vty
, " Neighbor %s\n", on
->name
);
987 vty_out(vty
, " Area %s via interface %s (ifindex %d)\n",
988 on
->ospf6_if
->area
->name
, on
->ospf6_if
->interface
->name
,
989 on
->ospf6_if
->interface
->ifindex
);
990 vty_out(vty
, " His IfIndex: %d Link-local address: %s\n",
991 on
->ifindex
, linklocal_addr
);
992 vty_out(vty
, " State %s for a duration of %s\n",
993 ospf6_neighbor_state_str
[on
->state
], duration
);
994 vty_out(vty
, " His choice of DR/BDR %s/%s, Priority %d\n",
995 drouter
, bdrouter
, on
->priority
);
996 vty_out(vty
, " DbDesc status: %s%s%s SeqNum: %#lx\n",
997 (CHECK_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
)
1000 (CHECK_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
)
1003 (CHECK_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
)
1006 (unsigned long)ntohl(on
->dbdesc_seqnum
));
1008 vty_out(vty
, " Summary-List: %d LSAs\n",
1009 on
->summary_list
->count
);
1010 for (ALL_LSDB(on
->summary_list
, lsa
, lsanext
))
1011 vty_out(vty
, " %s\n", lsa
->name
);
1013 vty_out(vty
, " Request-List: %d LSAs\n",
1014 on
->request_list
->count
);
1015 for (ALL_LSDB(on
->request_list
, lsa
, lsanext
))
1016 vty_out(vty
, " %s\n", lsa
->name
);
1018 vty_out(vty
, " Retrans-List: %d LSAs\n",
1019 on
->retrans_list
->count
);
1020 for (ALL_LSDB(on
->retrans_list
, lsa
, lsanext
))
1021 vty_out(vty
, " %s\n", lsa
->name
);
1024 if (on
->thread_send_dbdesc
)
1025 timersub(&on
->thread_send_dbdesc
->u
.sands
, &now
, &res
);
1026 timerstring(&res
, duration
, sizeof(duration
));
1028 " %d Pending LSAs for DbDesc in Time %s [thread %s]\n",
1029 on
->dbdesc_list
->count
, duration
,
1030 (on
->thread_send_dbdesc
? "on" : "off"));
1031 for (ALL_LSDB(on
->dbdesc_list
, lsa
, lsanext
))
1032 vty_out(vty
, " %s\n", lsa
->name
);
1035 if (on
->thread_send_lsreq
)
1036 timersub(&on
->thread_send_lsreq
->u
.sands
, &now
, &res
);
1037 timerstring(&res
, duration
, sizeof(duration
));
1039 " %d Pending LSAs for LSReq in Time %s [thread %s]\n",
1040 on
->request_list
->count
, duration
,
1041 (on
->thread_send_lsreq
? "on" : "off"));
1042 for (ALL_LSDB(on
->request_list
, lsa
, lsanext
))
1043 vty_out(vty
, " %s\n", lsa
->name
);
1046 if (on
->thread_send_lsupdate
)
1047 timersub(&on
->thread_send_lsupdate
->u
.sands
, &now
,
1049 timerstring(&res
, duration
, sizeof(duration
));
1051 " %d Pending LSAs for LSUpdate in Time %s [thread %s]\n",
1052 on
->lsupdate_list
->count
, duration
,
1053 (on
->thread_send_lsupdate
? "on" : "off"));
1054 for (ALL_LSDB(on
->lsupdate_list
, lsa
, lsanext
))
1055 vty_out(vty
, " %s\n", lsa
->name
);
1058 if (on
->thread_send_lsack
)
1059 timersub(&on
->thread_send_lsack
->u
.sands
, &now
, &res
);
1060 timerstring(&res
, duration
, sizeof(duration
));
1062 " %d Pending LSAs for LSAck in Time %s [thread %s]\n",
1063 on
->lsack_list
->count
, duration
,
1064 (on
->thread_send_lsack
? "on" : "off"));
1065 for (ALL_LSDB(on
->lsack_list
, lsa
, lsanext
))
1066 vty_out(vty
, " %s\n", lsa
->name
);
1068 bfd_sess_show(vty
, NULL
, on
->bfd_session
);
1070 if (on
->auth_present
== true) {
1071 vty_out(vty
, " Authentication header present\n");
1073 "\t\t\t hello DBDesc LSReq LSUpd LSAck\n");
1075 " Higher sequence no 0x%-10X 0x%-10X 0x%-10X 0x%-10X 0x%-10X\n",
1076 on
->seqnum_h
[OSPF6_MESSAGE_TYPE_HELLO
],
1077 on
->seqnum_h
[OSPF6_MESSAGE_TYPE_DBDESC
],
1078 on
->seqnum_h
[OSPF6_MESSAGE_TYPE_LSREQ
],
1079 on
->seqnum_h
[OSPF6_MESSAGE_TYPE_LSUPDATE
],
1080 on
->seqnum_h
[OSPF6_MESSAGE_TYPE_LSACK
]);
1082 " Lower sequence no 0x%-10X 0x%-10X 0x%-10X 0x%-10X 0x%-10X\n",
1083 on
->seqnum_l
[OSPF6_MESSAGE_TYPE_HELLO
],
1084 on
->seqnum_l
[OSPF6_MESSAGE_TYPE_DBDESC
],
1085 on
->seqnum_l
[OSPF6_MESSAGE_TYPE_LSREQ
],
1086 on
->seqnum_l
[OSPF6_MESSAGE_TYPE_LSUPDATE
],
1087 on
->seqnum_l
[OSPF6_MESSAGE_TYPE_LSACK
]);
1089 vty_out(vty
, " Authentication header not present\n");
1093 static void ospf6_neighbor_show_detail_common(struct vty
*vty
,
1094 struct ospf6
*ospf6
, bool uj
,
1095 bool detail
, bool drchoice
)
1097 struct ospf6_neighbor
*on
;
1098 struct ospf6_interface
*oi
;
1099 struct ospf6_area
*oa
;
1100 struct listnode
*i
, *j
, *k
;
1101 json_object
*json
= NULL
;
1102 json_object
*json_array
= NULL
;
1103 void (*showfunc
)(struct vty
*, struct ospf6_neighbor
*,
1104 json_object
*json
, bool use_json
);
1107 showfunc
= ospf6_neighbor_show_detail
;
1109 showfunc
= ospf6_neighbor_show_drchoice
;
1111 showfunc
= ospf6_neighbor_show
;
1114 json
= json_object_new_object();
1115 json_array
= json_object_new_array();
1117 if (showfunc
== ospf6_neighbor_show
)
1118 vty_out(vty
, "%-15s %3s %11s %8s/%-12s %11s %s[%s]\n",
1119 "Neighbor ID", "Pri", "DeadTime", "State",
1120 "IfState", "Duration", "I/F", "State");
1121 else if (showfunc
== ospf6_neighbor_show_drchoice
)
1122 vty_out(vty
, "%-15s %8s/%-11s %-15s %-15s %s[%s]\n",
1123 "RouterID", "State", "Duration", "DR", "BDR",
1127 for (ALL_LIST_ELEMENTS_RO(ospf6
->area_list
, i
, oa
))
1128 for (ALL_LIST_ELEMENTS_RO(oa
->if_list
, j
, oi
))
1129 for (ALL_LIST_ELEMENTS_RO(oi
->neighbor_list
, k
, on
)) {
1130 if (showfunc
== ospf6_neighbor_show_detail
)
1131 (*showfunc
)(vty
, on
, json
, uj
);
1133 (*showfunc
)(vty
, on
, json_array
, uj
);
1137 if (showfunc
!= ospf6_neighbor_show_detail
)
1138 json_object_object_add(json
, "neighbors", json_array
);
1140 json_object_free(json_array
);
1141 vty_json(vty
, json
);
1145 DEFUN(show_ipv6_ospf6_neighbor
, show_ipv6_ospf6_neighbor_cmd
,
1146 "show ipv6 ospf6 [vrf <NAME|all>] neighbor [<detail|drchoice>] [json]",
1147 SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1151 "Display DR choices\n" JSON_STR
)
1153 struct ospf6
*ospf6
;
1154 struct listnode
*node
;
1155 const char *vrf_name
= NULL
;
1156 bool all_vrf
= false;
1159 bool uj
= use_json(argc
, argv
);
1160 bool detail
= false;
1161 bool drchoice
= false;
1163 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1165 if (argv_find(argv
, argc
, "detail", &idx_type
))
1167 else if (argv_find(argv
, argc
, "drchoice", &idx_type
))
1170 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1171 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1172 ospf6_neighbor_show_detail_common(vty
, ospf6
, uj
,
1179 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
1184 static int ospf6_neighbor_show_common(struct vty
*vty
, int argc
,
1185 struct cmd_token
**argv
,
1186 struct ospf6
*ospf6
, int idx_ipv4
,
1189 struct ospf6_neighbor
*on
;
1190 struct ospf6_interface
*oi
;
1191 struct ospf6_area
*oa
;
1192 struct listnode
*i
, *j
, *k
;
1193 void (*showfunc
)(struct vty
*, struct ospf6_neighbor
*,
1194 json_object
*json
, bool use_json
);
1196 json_object
*json
= NULL
;
1198 showfunc
= ospf6_neighbor_show_detail
;
1200 json
= json_object_new_object();
1202 if ((inet_pton(AF_INET
, argv
[idx_ipv4
]->arg
, &router_id
)) != 1) {
1203 vty_out(vty
, "Router-ID is not parsable: %s\n",
1204 argv
[idx_ipv4
]->arg
);
1208 for (ALL_LIST_ELEMENTS_RO(ospf6
->area_list
, i
, oa
))
1209 for (ALL_LIST_ELEMENTS_RO(oa
->if_list
, j
, oi
))
1210 for (ALL_LIST_ELEMENTS_RO(oi
->neighbor_list
, k
, on
)) {
1211 if (router_id
== on
->router_id
)
1212 (*showfunc
)(vty
, on
, json
, uj
);
1216 vty_json(vty
, json
);
1221 DEFUN(show_ipv6_ospf6_neighbor_one
, show_ipv6_ospf6_neighbor_one_cmd
,
1222 "show ipv6 ospf6 [vrf <NAME|all>] neighbor A.B.C.D [json]",
1223 SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1226 "Specify Router-ID as IPv4 address notation\n" JSON_STR
)
1229 struct ospf6
*ospf6
;
1230 struct listnode
*node
;
1231 const char *vrf_name
= NULL
;
1232 bool all_vrf
= false;
1234 bool uj
= use_json(argc
, argv
);
1236 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1240 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1241 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1242 ospf6_neighbor_show_common(vty
, argc
, argv
, ospf6
,
1250 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
1255 void ospf6_neighbor_init(void)
1257 install_element(VIEW_NODE
, &show_ipv6_ospf6_neighbor_cmd
);
1258 install_element(VIEW_NODE
, &show_ipv6_ospf6_neighbor_one_cmd
);
1261 DEFUN (debug_ospf6_neighbor
,
1262 debug_ospf6_neighbor_cmd
,
1263 "debug ospf6 neighbor [<state|event>]",
1266 "Debug OSPFv3 Neighbor\n"
1267 "Debug OSPFv3 Neighbor State Change\n"
1268 "Debug OSPFv3 Neighbor Event\n")
1271 unsigned char level
= 0;
1274 if (!strncmp(argv
[idx_type
]->arg
, "s", 1))
1275 level
= OSPF6_DEBUG_NEIGHBOR_STATE
;
1276 else if (!strncmp(argv
[idx_type
]->arg
, "e", 1))
1277 level
= OSPF6_DEBUG_NEIGHBOR_EVENT
;
1279 level
= OSPF6_DEBUG_NEIGHBOR_STATE
| OSPF6_DEBUG_NEIGHBOR_EVENT
;
1281 OSPF6_DEBUG_NEIGHBOR_ON(level
);
1286 DEFUN (no_debug_ospf6_neighbor
,
1287 no_debug_ospf6_neighbor_cmd
,
1288 "no debug ospf6 neighbor [<state|event>]",
1292 "Debug OSPFv3 Neighbor\n"
1293 "Debug OSPFv3 Neighbor State Change\n"
1294 "Debug OSPFv3 Neighbor Event\n")
1297 unsigned char level
= 0;
1300 if (!strncmp(argv
[idx_type
]->arg
, "s", 1))
1301 level
= OSPF6_DEBUG_NEIGHBOR_STATE
;
1302 if (!strncmp(argv
[idx_type
]->arg
, "e", 1))
1303 level
= OSPF6_DEBUG_NEIGHBOR_EVENT
;
1305 level
= OSPF6_DEBUG_NEIGHBOR_STATE
| OSPF6_DEBUG_NEIGHBOR_EVENT
;
1307 OSPF6_DEBUG_NEIGHBOR_OFF(level
);
1312 DEFUN (no_debug_ospf6
,
1321 OSPF6_DEBUG_ABR_OFF();
1322 OSPF6_DEBUG_ASBR_OFF();
1323 OSPF6_DEBUG_BROUTER_OFF();
1324 OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_OFF();
1325 OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_OFF();
1326 OSPF6_DEBUG_FLOODING_OFF();
1327 OSPF6_DEBUG_INTERFACE_OFF();
1329 ospf6_lsa_debug_set_all(false);
1331 for (i
= 0; i
< 6; i
++)
1332 OSPF6_DEBUG_MESSAGE_OFF(i
,
1333 OSPF6_DEBUG_NEIGHBOR_STATE
1334 | OSPF6_DEBUG_NEIGHBOR_EVENT
);
1336 OSPF6_DEBUG_NEIGHBOR_OFF(OSPF6_DEBUG_NEIGHBOR_STATE
1337 | OSPF6_DEBUG_NEIGHBOR_EVENT
);
1338 OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_TABLE
);
1339 OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_INTRA
);
1340 OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_INTER
);
1341 OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_MEMORY
);
1342 OSPF6_DEBUG_SPF_OFF(OSPF6_DEBUG_SPF_PROCESS
);
1343 OSPF6_DEBUG_SPF_OFF(OSPF6_DEBUG_SPF_TIME
);
1344 OSPF6_DEBUG_SPF_OFF(OSPF6_DEBUG_SPF_DATABASE
);
1345 OSPF6_DEBUG_ZEBRA_OFF(OSPF6_DEBUG_ZEBRA_SEND
| OSPF6_DEBUG_ZEBRA_RECV
);
1350 int config_write_ospf6_debug_neighbor(struct vty
*vty
)
1352 if (IS_OSPF6_DEBUG_NEIGHBOR(STATE
) && IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
1353 vty_out(vty
, "debug ospf6 neighbor\n");
1354 else if (IS_OSPF6_DEBUG_NEIGHBOR(STATE
))
1355 vty_out(vty
, "debug ospf6 neighbor state\n");
1356 else if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
1357 vty_out(vty
, "debug ospf6 neighbor event\n");
1361 void install_element_ospf6_debug_neighbor(void)
1363 install_element(ENABLE_NODE
, &debug_ospf6_neighbor_cmd
);
1364 install_element(ENABLE_NODE
, &no_debug_ospf6_neighbor_cmd
);
1365 install_element(ENABLE_NODE
, &no_debug_ospf6_cmd
);
1366 install_element(CONFIG_NODE
, &debug_ospf6_neighbor_cmd
);
1367 install_element(CONFIG_NODE
, &no_debug_ospf6_neighbor_cmd
);
1368 install_element(CONFIG_NODE
, &no_debug_ospf6_cmd
);