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 void 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
);
295 void twoway_received(struct thread
*thread
)
297 struct ospf6_neighbor
*on
;
299 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
302 if (on
->state
> OSPF6_NEIGHBOR_INIT
)
305 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
306 zlog_debug("Neighbor Event %s: *2Way-Received*", on
->name
);
308 thread_add_event(master
, neighbor_change
, on
->ospf6_if
, 0, NULL
);
310 if (!need_adjacency(on
)) {
311 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_TWOWAY
, on
,
312 OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD
);
316 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART
, on
,
317 OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD
);
318 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
319 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
320 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
322 THREAD_OFF(on
->thread_send_dbdesc
);
323 thread_add_event(master
, ospf6_dbdesc_send
, on
, 0,
324 &on
->thread_send_dbdesc
);
327 void negotiation_done(struct thread
*thread
)
329 struct ospf6_neighbor
*on
;
330 struct ospf6_lsa
*lsa
, *lsanext
;
332 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
335 if (on
->state
!= OSPF6_NEIGHBOR_EXSTART
)
338 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
339 zlog_debug("Neighbor Event %s: *NegotiationDone*", on
->name
);
342 ospf6_lsdb_remove_all(on
->summary_list
);
343 ospf6_lsdb_remove_all(on
->request_list
);
344 for (ALL_LSDB(on
->retrans_list
, lsa
, lsanext
)) {
345 ospf6_decrement_retrans_count(lsa
);
346 ospf6_lsdb_remove(lsa
, on
->retrans_list
);
349 /* Interface scoped LSAs */
350 for (ALL_LSDB(on
->ospf6_if
->lsdb
, lsa
, lsanext
)) {
351 if (OSPF6_LSA_IS_MAXAGE(lsa
)) {
352 ospf6_increment_retrans_count(lsa
);
353 ospf6_lsdb_add(ospf6_lsa_copy(lsa
), on
->retrans_list
);
355 ospf6_lsdb_add(ospf6_lsa_copy(lsa
), on
->summary_list
);
358 /* Area scoped LSAs */
359 for (ALL_LSDB(on
->ospf6_if
->area
->lsdb
, lsa
, lsanext
)) {
360 if (OSPF6_LSA_IS_MAXAGE(lsa
)) {
361 ospf6_increment_retrans_count(lsa
);
362 ospf6_lsdb_add(ospf6_lsa_copy(lsa
), on
->retrans_list
);
364 ospf6_lsdb_add(ospf6_lsa_copy(lsa
), on
->summary_list
);
368 for (ALL_LSDB(on
->ospf6_if
->area
->ospf6
->lsdb
, lsa
, lsanext
)) {
369 if (OSPF6_LSA_IS_MAXAGE(lsa
)) {
370 ospf6_increment_retrans_count(lsa
);
371 ospf6_lsdb_add(ospf6_lsa_copy(lsa
), on
->retrans_list
);
373 ospf6_lsdb_add(ospf6_lsa_copy(lsa
), on
->summary_list
);
376 UNSET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
377 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXCHANGE
, on
,
378 OSPF6_NEIGHBOR_EVENT_NEGOTIATION_DONE
);
381 static void ospf6_neighbor_last_dbdesc_release(struct thread
*thread
)
383 struct ospf6_neighbor
*on
= THREAD_ARG(thread
);
386 memset(&on
->dbdesc_last
, 0, sizeof(struct ospf6_dbdesc
));
389 void exchange_done(struct thread
*thread
)
391 struct ospf6_neighbor
*on
;
393 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
396 if (on
->state
!= OSPF6_NEIGHBOR_EXCHANGE
)
399 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
400 zlog_debug("Neighbor Event %s: *ExchangeDone*", on
->name
);
402 THREAD_OFF(on
->thread_send_dbdesc
);
403 ospf6_lsdb_remove_all(on
->dbdesc_list
);
405 /* RFC 2328 (10.8): Release the last dbdesc after dead_interval */
406 if (!CHECK_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
)) {
407 THREAD_OFF(on
->last_dbdesc_release_timer
);
408 thread_add_timer(master
, ospf6_neighbor_last_dbdesc_release
, on
,
409 on
->ospf6_if
->dead_interval
,
410 &on
->last_dbdesc_release_timer
);
413 if (on
->request_list
->count
== 0)
414 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_FULL
, on
,
415 OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE
);
417 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_LOADING
, on
,
418 OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE
);
420 thread_add_event(master
, ospf6_lsreq_send
, on
, 0,
421 &on
->thread_send_lsreq
);
425 /* Check loading state. */
426 void ospf6_check_nbr_loading(struct ospf6_neighbor
*on
)
429 /* RFC2328 Section 10.9: When the neighbor responds to these requests
430 with the proper Link State Update packet(s), the Link state request
431 list is truncated and a new Link State Request packet is sent.
433 if ((on
->state
== OSPF6_NEIGHBOR_LOADING
)
434 || (on
->state
== OSPF6_NEIGHBOR_EXCHANGE
)) {
435 if (on
->request_list
->count
== 0)
436 thread_add_event(master
, loading_done
, on
, 0, NULL
);
437 else if (on
->last_ls_req
== NULL
) {
438 THREAD_OFF(on
->thread_send_lsreq
);
439 thread_add_event(master
, ospf6_lsreq_send
, on
, 0,
440 &on
->thread_send_lsreq
);
445 void loading_done(struct thread
*thread
)
447 struct ospf6_neighbor
*on
;
449 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
452 if (on
->state
!= OSPF6_NEIGHBOR_LOADING
)
455 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
456 zlog_debug("Neighbor Event %s: *LoadingDone*", on
->name
);
458 assert(on
->request_list
->count
== 0);
460 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_FULL
, on
,
461 OSPF6_NEIGHBOR_EVENT_LOADING_DONE
);
464 void adj_ok(struct thread
*thread
)
466 struct ospf6_neighbor
*on
;
467 struct ospf6_lsa
*lsa
, *lsanext
;
469 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
472 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
473 zlog_debug("Neighbor Event %s: *AdjOK?*", on
->name
);
475 if (on
->state
== OSPF6_NEIGHBOR_TWOWAY
&& need_adjacency(on
)) {
476 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART
, on
,
477 OSPF6_NEIGHBOR_EVENT_ADJ_OK
);
478 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
479 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
480 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
482 THREAD_OFF(on
->thread_send_dbdesc
);
483 thread_add_event(master
, ospf6_dbdesc_send
, on
, 0,
484 &on
->thread_send_dbdesc
);
486 } else if (on
->state
>= OSPF6_NEIGHBOR_EXSTART
&& !need_adjacency(on
)) {
487 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_TWOWAY
, on
,
488 OSPF6_NEIGHBOR_EVENT_ADJ_OK
);
489 ospf6_lsdb_remove_all(on
->summary_list
);
490 ospf6_lsdb_remove_all(on
->request_list
);
491 for (ALL_LSDB(on
->retrans_list
, lsa
, lsanext
)) {
492 ospf6_decrement_retrans_count(lsa
);
493 ospf6_lsdb_remove(lsa
, on
->retrans_list
);
498 void seqnumber_mismatch(struct thread
*thread
)
500 struct ospf6_neighbor
*on
;
501 struct ospf6_lsa
*lsa
, *lsanext
;
503 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
506 if (on
->state
< OSPF6_NEIGHBOR_EXCHANGE
)
509 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
510 zlog_debug("Neighbor Event %s: *SeqNumberMismatch*", on
->name
);
512 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART
, on
,
513 OSPF6_NEIGHBOR_EVENT_SEQNUMBER_MISMATCH
);
514 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
515 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
516 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
518 ospf6_lsdb_remove_all(on
->summary_list
);
519 ospf6_lsdb_remove_all(on
->request_list
);
520 for (ALL_LSDB(on
->retrans_list
, lsa
, lsanext
)) {
521 ospf6_decrement_retrans_count(lsa
);
522 ospf6_lsdb_remove(lsa
, on
->retrans_list
);
525 THREAD_OFF(on
->thread_send_dbdesc
);
526 on
->dbdesc_seqnum
++; /* Incr seqnum as per RFC2328, sec 10.3 */
528 thread_add_event(master
, ospf6_dbdesc_send
, on
, 0,
529 &on
->thread_send_dbdesc
);
532 void bad_lsreq(struct thread
*thread
)
534 struct ospf6_neighbor
*on
;
535 struct ospf6_lsa
*lsa
, *lsanext
;
537 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
540 if (on
->state
< OSPF6_NEIGHBOR_EXCHANGE
)
543 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
544 zlog_debug("Neighbor Event %s: *BadLSReq*", on
->name
);
546 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART
, on
,
547 OSPF6_NEIGHBOR_EVENT_BAD_LSREQ
);
548 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
549 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
550 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
552 ospf6_lsdb_remove_all(on
->summary_list
);
553 ospf6_lsdb_remove_all(on
->request_list
);
554 for (ALL_LSDB(on
->retrans_list
, lsa
, lsanext
)) {
555 ospf6_decrement_retrans_count(lsa
);
556 ospf6_lsdb_remove(lsa
, on
->retrans_list
);
559 THREAD_OFF(on
->thread_send_dbdesc
);
560 on
->dbdesc_seqnum
++; /* Incr seqnum as per RFC2328, sec 10.3 */
562 thread_add_event(master
, ospf6_dbdesc_send
, on
, 0,
563 &on
->thread_send_dbdesc
);
567 void oneway_received(struct thread
*thread
)
569 struct ospf6_neighbor
*on
;
570 struct ospf6_lsa
*lsa
, *lsanext
;
572 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
575 if (on
->state
< OSPF6_NEIGHBOR_TWOWAY
)
578 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
579 zlog_debug("Neighbor Event %s: *1Way-Received*", on
->name
);
581 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_INIT
, on
,
582 OSPF6_NEIGHBOR_EVENT_ONEWAY_RCVD
);
583 thread_add_event(master
, neighbor_change
, on
->ospf6_if
, 0, NULL
);
585 ospf6_lsdb_remove_all(on
->summary_list
);
586 ospf6_lsdb_remove_all(on
->request_list
);
587 for (ALL_LSDB(on
->retrans_list
, lsa
, lsanext
)) {
588 ospf6_decrement_retrans_count(lsa
);
589 ospf6_lsdb_remove(lsa
, on
->retrans_list
);
592 THREAD_OFF(on
->thread_send_dbdesc
);
593 THREAD_OFF(on
->thread_send_lsreq
);
594 THREAD_OFF(on
->thread_send_lsupdate
);
595 THREAD_OFF(on
->thread_send_lsack
);
596 THREAD_OFF(on
->thread_exchange_done
);
597 THREAD_OFF(on
->thread_adj_ok
);
600 void inactivity_timer(struct thread
*thread
)
602 struct ospf6_neighbor
*on
;
604 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
607 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
608 zlog_debug("Neighbor Event %s: *InactivityTimer*", on
->name
);
610 on
->drouter
= on
->prev_drouter
= 0;
611 on
->bdrouter
= on
->prev_bdrouter
= 0;
613 if (!OSPF6_GR_IS_ACTIVE_HELPER(on
)) {
614 on
->drouter
= on
->prev_drouter
= 0;
615 on
->bdrouter
= on
->prev_bdrouter
= 0;
617 ospf6_neighbor_state_change(
618 OSPF6_NEIGHBOR_DOWN
, on
,
619 OSPF6_NEIGHBOR_EVENT_INACTIVITY_TIMER
);
620 thread_add_event(master
, neighbor_change
, on
->ospf6_if
, 0,
623 listnode_delete(on
->ospf6_if
->neighbor_list
, on
);
624 ospf6_neighbor_delete(on
);
627 if (IS_DEBUG_OSPF6_GR
)
629 "%s, Acting as HELPER for this neighbour, So restart the dead timer.",
630 __PRETTY_FUNCTION__
);
632 thread_add_timer(master
, inactivity_timer
, on
,
633 on
->ospf6_if
->dead_interval
,
634 &on
->inactivity_timer
);
640 /* show neighbor structure */
641 static void ospf6_neighbor_show(struct vty
*vty
, struct ospf6_neighbor
*on
,
642 json_object
*json_array
, bool use_json
)
650 json_object
*json_route
;
652 /* Router-ID (Name) */
653 inet_ntop(AF_INET
, &on
->router_id
, router_id
, sizeof(router_id
));
654 #ifdef HAVE_GETNAMEINFO
657 #endif /*HAVE_GETNAMEINFO*/
661 if (on
->inactivity_timer
) {
662 s
= monotime_until(&on
->inactivity_timer
->u
.sands
, NULL
)
669 snprintf(deadtime
, sizeof(deadtime
), "%02ld:%02ld:%02ld", h
, m
, s
);
672 if (on
->ospf6_if
->type
== OSPF_IFTYPE_POINTOPOINT
)
673 snprintf(nstate
, sizeof(nstate
), "PointToPoint");
675 if (on
->router_id
== on
->drouter
)
676 snprintf(nstate
, sizeof(nstate
), "DR");
677 else if (on
->router_id
== on
->bdrouter
)
678 snprintf(nstate
, sizeof(nstate
), "BDR");
680 snprintf(nstate
, sizeof(nstate
), "DROther");
684 monotime_since(&on
->last_changed
, &res
);
685 timerstring(&res
, duration
, sizeof(duration
));
688 vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]\n",
689 "Neighbor ID", "Pri", "DeadTime", "State", "IfState",
690 "Duration", "I/F", "State");
693 json_route
= json_object_new_object();
695 json_object_string_add(json_route
, "neighborId", router_id
);
696 json_object_int_add(json_route
, "priority", on
->priority
);
697 json_object_string_add(json_route
, "deadTime", deadtime
);
698 json_object_string_add(json_route
, "state",
699 ospf6_neighbor_state_str
[on
->state
]);
700 json_object_string_add(json_route
, "ifState", nstate
);
701 json_object_string_add(json_route
, "duration", duration
);
702 json_object_string_add(json_route
, "interfaceName",
703 on
->ospf6_if
->interface
->name
);
704 json_object_string_add(
705 json_route
, "interfaceState",
706 ospf6_interface_state_str
[on
->ospf6_if
->state
]);
708 json_object_array_add(json_array
, json_route
);
710 vty_out(vty
, "%-15s %3d %11s %8s/%-12s %11s %s[%s]\n",
711 router_id
, on
->priority
, deadtime
,
712 ospf6_neighbor_state_str
[on
->state
], nstate
, duration
,
713 on
->ospf6_if
->interface
->name
,
714 ospf6_interface_state_str
[on
->ospf6_if
->state
]);
717 static void ospf6_neighbor_show_drchoice(struct vty
*vty
,
718 struct ospf6_neighbor
*on
,
719 json_object
*json_array
, bool use_json
)
722 char drouter
[16], bdrouter
[16];
724 struct timeval now
, res
;
725 json_object
*json_route
;
728 vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]\n",
729 "RouterID", "State", "Duration", "DR", "BDR", "I/F",
733 inet_ntop(AF_INET
, &on
->router_id
, router_id
, sizeof(router_id
));
734 inet_ntop(AF_INET
, &on
->drouter
, drouter
, sizeof(drouter
));
735 inet_ntop(AF_INET
, &on
->bdrouter
, bdrouter
, sizeof(bdrouter
));
738 timersub(&now
, &on
->last_changed
, &res
);
739 timerstring(&res
, duration
, sizeof(duration
));
742 json_route
= json_object_new_object();
743 json_object_string_add(json_route
, "routerId", router_id
);
744 json_object_string_add(json_route
, "state",
745 ospf6_neighbor_state_str
[on
->state
]);
746 json_object_string_add(json_route
, "duration", duration
);
747 json_object_string_add(json_route
, "dRouter", drouter
);
748 json_object_string_add(json_route
, "bdRouter", bdrouter
);
749 json_object_string_add(json_route
, "interfaceName",
750 on
->ospf6_if
->interface
->name
);
751 json_object_string_add(
752 json_route
, "interfaceState",
753 ospf6_interface_state_str
[on
->ospf6_if
->state
]);
755 json_object_array_add(json_array
, json_route
);
757 vty_out(vty
, "%-15s %8s/%-11s %-15s %-15s %s[%s]\n", router_id
,
758 ospf6_neighbor_state_str
[on
->state
], duration
, drouter
,
759 bdrouter
, on
->ospf6_if
->interface
->name
,
760 ospf6_interface_state_str
[on
->ospf6_if
->state
]);
763 static void ospf6_neighbor_show_detail(struct vty
*vty
,
764 struct ospf6_neighbor
*on
,
765 json_object
*json
, bool use_json
)
767 char drouter
[16], bdrouter
[16];
768 char linklocal_addr
[64], duration
[32];
769 struct timeval now
, res
;
770 struct ospf6_lsa
*lsa
, *lsanext
;
771 json_object
*json_neighbor
;
772 json_object
*json_array
;
773 char db_desc_str
[20];
775 inet_ntop(AF_INET6
, &on
->linklocal_addr
, linklocal_addr
,
776 sizeof(linklocal_addr
));
777 inet_ntop(AF_INET
, &on
->drouter
, drouter
, sizeof(drouter
));
778 inet_ntop(AF_INET
, &on
->bdrouter
, bdrouter
, sizeof(bdrouter
));
781 timersub(&now
, &on
->last_changed
, &res
);
782 timerstring(&res
, duration
, sizeof(duration
));
785 json_neighbor
= json_object_new_object();
786 json_object_string_add(json_neighbor
, "area",
787 on
->ospf6_if
->area
->name
);
788 json_object_string_add(json_neighbor
, "interface",
789 on
->ospf6_if
->interface
->name
);
790 json_object_int_add(json_neighbor
, "interfaceIndex",
791 on
->ospf6_if
->interface
->ifindex
);
792 json_object_int_add(json_neighbor
, "neighborInterfaceIndex",
794 json_object_string_add(json_neighbor
, "linkLocalAddress",
796 json_object_string_add(json_neighbor
, "neighborState",
797 ospf6_neighbor_state_str
[on
->state
]);
798 json_object_string_add(json_neighbor
, "neighborStateDuration",
800 json_object_string_add(json_neighbor
, "neighborDRouter",
802 json_object_string_add(json_neighbor
, "neighborBdRouter",
804 snprintf(db_desc_str
, sizeof(db_desc_str
), "%s%s%s",
805 (CHECK_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
)
808 (CHECK_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
)
811 (CHECK_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
)
814 json_object_string_add(json_neighbor
, "dbDescStatus",
817 json_object_int_add(json_neighbor
, "dbDescSeqNumber",
818 (unsigned long)ntohl(on
->dbdesc_seqnum
));
820 json_array
= json_object_new_array();
821 json_object_int_add(json_neighbor
, "summaryListCount",
822 on
->summary_list
->count
);
823 for (ALL_LSDB(on
->summary_list
, lsa
, lsanext
))
824 json_object_array_add(
825 json_array
, json_object_new_string(lsa
->name
));
826 json_object_object_add(json_neighbor
, "summaryListLsa",
829 json_array
= json_object_new_array();
830 json_object_int_add(json_neighbor
, "requestListCount",
831 on
->request_list
->count
);
832 for (ALL_LSDB(on
->request_list
, lsa
, lsanext
))
833 json_object_array_add(
834 json_array
, json_object_new_string(lsa
->name
));
835 json_object_object_add(json_neighbor
, "requestListLsa",
838 json_array
= json_object_new_array();
839 json_object_int_add(json_neighbor
, "reTransListCount",
840 on
->retrans_list
->count
);
841 for (ALL_LSDB(on
->retrans_list
, lsa
, lsanext
))
842 json_object_array_add(
843 json_array
, json_object_new_string(lsa
->name
));
844 json_object_object_add(json_neighbor
, "reTransListLsa",
849 if (thread_is_scheduled(on
->thread_send_dbdesc
))
850 timersub(&on
->thread_send_dbdesc
->u
.sands
, &now
, &res
);
851 timerstring(&res
, duration
, sizeof(duration
));
852 json_object_int_add(json_neighbor
, "pendingLsaDbDescCount",
853 on
->dbdesc_list
->count
);
854 json_object_string_add(json_neighbor
, "pendingLsaDbDescTime",
856 json_object_string_add(
857 json_neighbor
, "dbDescSendThread",
858 (thread_is_scheduled(on
->thread_send_dbdesc
) ? "on"
860 json_array
= json_object_new_array();
861 for (ALL_LSDB(on
->dbdesc_list
, lsa
, lsanext
))
862 json_object_array_add(
863 json_array
, json_object_new_string(lsa
->name
));
864 json_object_object_add(json_neighbor
, "pendingLsaDbDesc",
868 if (thread_is_scheduled(on
->thread_send_lsreq
))
869 timersub(&on
->thread_send_lsreq
->u
.sands
, &now
, &res
);
870 timerstring(&res
, duration
, sizeof(duration
));
871 json_object_int_add(json_neighbor
, "pendingLsaLsReqCount",
872 on
->request_list
->count
);
873 json_object_string_add(json_neighbor
, "pendingLsaLsReqTime",
875 json_object_string_add(
876 json_neighbor
, "lsReqSendThread",
877 (thread_is_scheduled(on
->thread_send_lsreq
) ? "on"
879 json_array
= json_object_new_array();
880 for (ALL_LSDB(on
->request_list
, lsa
, lsanext
))
881 json_object_array_add(
882 json_array
, json_object_new_string(lsa
->name
));
883 json_object_object_add(json_neighbor
, "pendingLsaLsReq",
888 if (thread_is_scheduled(on
->thread_send_lsupdate
))
889 timersub(&on
->thread_send_lsupdate
->u
.sands
, &now
,
891 timerstring(&res
, duration
, sizeof(duration
));
892 json_object_int_add(json_neighbor
, "pendingLsaLsUpdateCount",
893 on
->lsupdate_list
->count
);
894 json_object_string_add(json_neighbor
, "pendingLsaLsUpdateTime",
896 json_object_string_add(
897 json_neighbor
, "lsUpdateSendThread",
898 (thread_is_scheduled(on
->thread_send_lsupdate
)
901 json_array
= json_object_new_array();
902 for (ALL_LSDB(on
->lsupdate_list
, lsa
, lsanext
))
903 json_object_array_add(
904 json_array
, json_object_new_string(lsa
->name
));
905 json_object_object_add(json_neighbor
, "pendingLsaLsUpdate",
909 if (thread_is_scheduled(on
->thread_send_lsack
))
910 timersub(&on
->thread_send_lsack
->u
.sands
, &now
, &res
);
911 timerstring(&res
, duration
, sizeof(duration
));
912 json_object_int_add(json_neighbor
, "pendingLsaLsAckCount",
913 on
->lsack_list
->count
);
914 json_object_string_add(json_neighbor
, "pendingLsaLsAckTime",
916 json_object_string_add(
917 json_neighbor
, "lsAckSendThread",
918 (thread_is_scheduled(on
->thread_send_lsack
) ? "on"
920 json_array
= json_object_new_array();
921 for (ALL_LSDB(on
->lsack_list
, lsa
, lsanext
))
922 json_object_array_add(
923 json_array
, json_object_new_string(lsa
->name
));
924 json_object_object_add(json_neighbor
, "pendingLsaLsAck",
927 bfd_sess_show(vty
, json_neighbor
, on
->bfd_session
);
929 if (on
->auth_present
== true) {
930 json_object_string_add(json_neighbor
, "authStatus",
933 json_neighbor
, "recvdHelloHigherSeqNo",
934 on
->seqnum_h
[OSPF6_MESSAGE_TYPE_HELLO
]);
936 json_neighbor
, "recvdHelloLowerSeqNo",
937 on
->seqnum_l
[OSPF6_MESSAGE_TYPE_HELLO
]);
939 json_neighbor
, "recvdDBDescHigherSeqNo",
940 on
->seqnum_h
[OSPF6_MESSAGE_TYPE_DBDESC
]);
942 json_neighbor
, "recvdDBDescLowerSeqNo",
943 on
->seqnum_l
[OSPF6_MESSAGE_TYPE_DBDESC
]);
945 json_neighbor
, "recvdLSReqHigherSeqNo",
946 on
->seqnum_h
[OSPF6_MESSAGE_TYPE_LSREQ
]);
948 json_neighbor
, "recvdLSReqLowerSeqNo",
949 on
->seqnum_l
[OSPF6_MESSAGE_TYPE_LSREQ
]);
951 json_neighbor
, "recvdLSUpdHigherSeqNo",
952 on
->seqnum_h
[OSPF6_MESSAGE_TYPE_LSUPDATE
]);
954 json_neighbor
, "recvdLSUpdLowerSeqNo",
955 on
->seqnum_l
[OSPF6_MESSAGE_TYPE_LSUPDATE
]);
957 json_neighbor
, "recvdLSAckHigherSeqNo",
958 on
->seqnum_h
[OSPF6_MESSAGE_TYPE_LSACK
]);
960 json_neighbor
, "recvdLSAckLowerSeqNo",
961 on
->seqnum_l
[OSPF6_MESSAGE_TYPE_LSACK
]);
963 json_object_string_add(json_neighbor
, "authStatus",
966 json_object_object_add(json
, on
->name
, json_neighbor
);
969 vty_out(vty
, " Neighbor %s\n", on
->name
);
970 vty_out(vty
, " Area %s via interface %s (ifindex %d)\n",
971 on
->ospf6_if
->area
->name
, on
->ospf6_if
->interface
->name
,
972 on
->ospf6_if
->interface
->ifindex
);
973 vty_out(vty
, " His IfIndex: %d Link-local address: %s\n",
974 on
->ifindex
, linklocal_addr
);
975 vty_out(vty
, " State %s for a duration of %s\n",
976 ospf6_neighbor_state_str
[on
->state
], duration
);
977 vty_out(vty
, " His choice of DR/BDR %s/%s, Priority %d\n",
978 drouter
, bdrouter
, on
->priority
);
979 vty_out(vty
, " DbDesc status: %s%s%s SeqNum: %#lx\n",
980 (CHECK_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
)
983 (CHECK_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
)
986 (CHECK_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
)
989 (unsigned long)ntohl(on
->dbdesc_seqnum
));
991 vty_out(vty
, " Summary-List: %d LSAs\n",
992 on
->summary_list
->count
);
993 for (ALL_LSDB(on
->summary_list
, lsa
, lsanext
))
994 vty_out(vty
, " %s\n", lsa
->name
);
996 vty_out(vty
, " Request-List: %d LSAs\n",
997 on
->request_list
->count
);
998 for (ALL_LSDB(on
->request_list
, lsa
, lsanext
))
999 vty_out(vty
, " %s\n", lsa
->name
);
1001 vty_out(vty
, " Retrans-List: %d LSAs\n",
1002 on
->retrans_list
->count
);
1003 for (ALL_LSDB(on
->retrans_list
, lsa
, lsanext
))
1004 vty_out(vty
, " %s\n", lsa
->name
);
1007 if (thread_is_scheduled(on
->thread_send_dbdesc
))
1008 timersub(&on
->thread_send_dbdesc
->u
.sands
, &now
, &res
);
1009 timerstring(&res
, duration
, sizeof(duration
));
1011 " %d Pending LSAs for DbDesc in Time %s [thread %s]\n",
1012 on
->dbdesc_list
->count
, duration
,
1013 (thread_is_scheduled(on
->thread_send_dbdesc
) ? "on"
1015 for (ALL_LSDB(on
->dbdesc_list
, lsa
, lsanext
))
1016 vty_out(vty
, " %s\n", lsa
->name
);
1019 if (thread_is_scheduled(on
->thread_send_lsreq
))
1020 timersub(&on
->thread_send_lsreq
->u
.sands
, &now
, &res
);
1021 timerstring(&res
, duration
, sizeof(duration
));
1023 " %d Pending LSAs for LSReq in Time %s [thread %s]\n",
1024 on
->request_list
->count
, duration
,
1025 (thread_is_scheduled(on
->thread_send_lsreq
) ? "on"
1027 for (ALL_LSDB(on
->request_list
, lsa
, lsanext
))
1028 vty_out(vty
, " %s\n", lsa
->name
);
1031 if (thread_is_scheduled(on
->thread_send_lsupdate
))
1032 timersub(&on
->thread_send_lsupdate
->u
.sands
, &now
,
1034 timerstring(&res
, duration
, sizeof(duration
));
1036 " %d Pending LSAs for LSUpdate in Time %s [thread %s]\n",
1037 on
->lsupdate_list
->count
, duration
,
1038 (thread_is_scheduled(on
->thread_send_lsupdate
)
1041 for (ALL_LSDB(on
->lsupdate_list
, lsa
, lsanext
))
1042 vty_out(vty
, " %s\n", lsa
->name
);
1045 if (thread_is_scheduled(on
->thread_send_lsack
))
1046 timersub(&on
->thread_send_lsack
->u
.sands
, &now
, &res
);
1047 timerstring(&res
, duration
, sizeof(duration
));
1049 " %d Pending LSAs for LSAck in Time %s [thread %s]\n",
1050 on
->lsack_list
->count
, duration
,
1051 (thread_is_scheduled(on
->thread_send_lsack
) ? "on"
1053 for (ALL_LSDB(on
->lsack_list
, lsa
, lsanext
))
1054 vty_out(vty
, " %s\n", lsa
->name
);
1056 bfd_sess_show(vty
, NULL
, on
->bfd_session
);
1058 if (on
->auth_present
== true) {
1059 vty_out(vty
, " Authentication header present\n");
1061 "\t\t\t hello DBDesc LSReq LSUpd LSAck\n");
1063 " Higher sequence no 0x%-10X 0x%-10X 0x%-10X 0x%-10X 0x%-10X\n",
1064 on
->seqnum_h
[OSPF6_MESSAGE_TYPE_HELLO
],
1065 on
->seqnum_h
[OSPF6_MESSAGE_TYPE_DBDESC
],
1066 on
->seqnum_h
[OSPF6_MESSAGE_TYPE_LSREQ
],
1067 on
->seqnum_h
[OSPF6_MESSAGE_TYPE_LSUPDATE
],
1068 on
->seqnum_h
[OSPF6_MESSAGE_TYPE_LSACK
]);
1070 " Lower sequence no 0x%-10X 0x%-10X 0x%-10X 0x%-10X 0x%-10X\n",
1071 on
->seqnum_l
[OSPF6_MESSAGE_TYPE_HELLO
],
1072 on
->seqnum_l
[OSPF6_MESSAGE_TYPE_DBDESC
],
1073 on
->seqnum_l
[OSPF6_MESSAGE_TYPE_LSREQ
],
1074 on
->seqnum_l
[OSPF6_MESSAGE_TYPE_LSUPDATE
],
1075 on
->seqnum_l
[OSPF6_MESSAGE_TYPE_LSACK
]);
1077 vty_out(vty
, " Authentication header not present\n");
1081 static void ospf6_neighbor_show_detail_common(struct vty
*vty
,
1082 struct ospf6
*ospf6
, bool uj
,
1083 bool detail
, bool drchoice
)
1085 struct ospf6_neighbor
*on
;
1086 struct ospf6_interface
*oi
;
1087 struct ospf6_area
*oa
;
1088 struct listnode
*i
, *j
, *k
;
1089 json_object
*json
= NULL
;
1090 json_object
*json_array
= NULL
;
1091 void (*showfunc
)(struct vty
*, struct ospf6_neighbor
*,
1092 json_object
*json
, bool use_json
);
1095 showfunc
= ospf6_neighbor_show_detail
;
1097 showfunc
= ospf6_neighbor_show_drchoice
;
1099 showfunc
= ospf6_neighbor_show
;
1102 json
= json_object_new_object();
1103 json_array
= json_object_new_array();
1105 if (showfunc
== ospf6_neighbor_show
)
1106 vty_out(vty
, "%-15s %3s %11s %8s/%-12s %11s %s[%s]\n",
1107 "Neighbor ID", "Pri", "DeadTime", "State",
1108 "IfState", "Duration", "I/F", "State");
1109 else if (showfunc
== ospf6_neighbor_show_drchoice
)
1110 vty_out(vty
, "%-15s %8s/%-11s %-15s %-15s %s[%s]\n",
1111 "RouterID", "State", "Duration", "DR", "BDR",
1115 for (ALL_LIST_ELEMENTS_RO(ospf6
->area_list
, i
, oa
))
1116 for (ALL_LIST_ELEMENTS_RO(oa
->if_list
, j
, oi
))
1117 for (ALL_LIST_ELEMENTS_RO(oi
->neighbor_list
, k
, on
)) {
1118 if (showfunc
== ospf6_neighbor_show_detail
)
1119 (*showfunc
)(vty
, on
, json
, uj
);
1121 (*showfunc
)(vty
, on
, json_array
, uj
);
1125 if (showfunc
!= ospf6_neighbor_show_detail
)
1126 json_object_object_add(json
, "neighbors", json_array
);
1128 json_object_free(json_array
);
1129 vty_json(vty
, json
);
1133 DEFUN(show_ipv6_ospf6_neighbor
, show_ipv6_ospf6_neighbor_cmd
,
1134 "show ipv6 ospf6 [vrf <NAME|all>] neighbor [<detail|drchoice>] [json]",
1135 SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1139 "Display DR choices\n" JSON_STR
)
1141 struct ospf6
*ospf6
;
1142 struct listnode
*node
;
1143 const char *vrf_name
= NULL
;
1144 bool all_vrf
= false;
1147 bool uj
= use_json(argc
, argv
);
1148 bool detail
= false;
1149 bool drchoice
= false;
1151 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1153 if (argv_find(argv
, argc
, "detail", &idx_type
))
1155 else if (argv_find(argv
, argc
, "drchoice", &idx_type
))
1158 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1159 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1160 ospf6_neighbor_show_detail_common(vty
, ospf6
, uj
,
1167 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
1172 static int ospf6_neighbor_show_common(struct vty
*vty
, int argc
,
1173 struct cmd_token
**argv
,
1174 struct ospf6
*ospf6
, int idx_ipv4
,
1177 struct ospf6_neighbor
*on
;
1178 struct ospf6_interface
*oi
;
1179 struct ospf6_area
*oa
;
1180 struct listnode
*i
, *j
, *k
;
1181 void (*showfunc
)(struct vty
*, struct ospf6_neighbor
*,
1182 json_object
*json
, bool use_json
);
1184 json_object
*json
= NULL
;
1186 showfunc
= ospf6_neighbor_show_detail
;
1188 json
= json_object_new_object();
1190 if ((inet_pton(AF_INET
, argv
[idx_ipv4
]->arg
, &router_id
)) != 1) {
1191 vty_out(vty
, "Router-ID is not parsable: %s\n",
1192 argv
[idx_ipv4
]->arg
);
1196 for (ALL_LIST_ELEMENTS_RO(ospf6
->area_list
, i
, oa
))
1197 for (ALL_LIST_ELEMENTS_RO(oa
->if_list
, j
, oi
))
1198 for (ALL_LIST_ELEMENTS_RO(oi
->neighbor_list
, k
, on
)) {
1199 if (router_id
== on
->router_id
)
1200 (*showfunc
)(vty
, on
, json
, uj
);
1204 vty_json(vty
, json
);
1209 DEFUN(show_ipv6_ospf6_neighbor_one
, show_ipv6_ospf6_neighbor_one_cmd
,
1210 "show ipv6 ospf6 [vrf <NAME|all>] neighbor A.B.C.D [json]",
1211 SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1214 "Specify Router-ID as IPv4 address notation\n" JSON_STR
)
1217 struct ospf6
*ospf6
;
1218 struct listnode
*node
;
1219 const char *vrf_name
= NULL
;
1220 bool all_vrf
= false;
1222 bool uj
= use_json(argc
, argv
);
1224 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1228 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1229 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1230 ospf6_neighbor_show_common(vty
, argc
, argv
, ospf6
,
1238 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
1243 void ospf6_neighbor_init(void)
1245 install_element(VIEW_NODE
, &show_ipv6_ospf6_neighbor_cmd
);
1246 install_element(VIEW_NODE
, &show_ipv6_ospf6_neighbor_one_cmd
);
1249 DEFUN (debug_ospf6_neighbor
,
1250 debug_ospf6_neighbor_cmd
,
1251 "debug ospf6 neighbor [<state|event>]",
1254 "Debug OSPFv3 Neighbor\n"
1255 "Debug OSPFv3 Neighbor State Change\n"
1256 "Debug OSPFv3 Neighbor Event\n")
1259 unsigned char level
= 0;
1262 if (!strncmp(argv
[idx_type
]->arg
, "s", 1))
1263 level
= OSPF6_DEBUG_NEIGHBOR_STATE
;
1264 else if (!strncmp(argv
[idx_type
]->arg
, "e", 1))
1265 level
= OSPF6_DEBUG_NEIGHBOR_EVENT
;
1267 level
= OSPF6_DEBUG_NEIGHBOR_STATE
| OSPF6_DEBUG_NEIGHBOR_EVENT
;
1269 OSPF6_DEBUG_NEIGHBOR_ON(level
);
1274 DEFUN (no_debug_ospf6_neighbor
,
1275 no_debug_ospf6_neighbor_cmd
,
1276 "no debug ospf6 neighbor [<state|event>]",
1280 "Debug OSPFv3 Neighbor\n"
1281 "Debug OSPFv3 Neighbor State Change\n"
1282 "Debug OSPFv3 Neighbor Event\n")
1285 unsigned char level
= 0;
1288 if (!strncmp(argv
[idx_type
]->arg
, "s", 1))
1289 level
= OSPF6_DEBUG_NEIGHBOR_STATE
;
1290 if (!strncmp(argv
[idx_type
]->arg
, "e", 1))
1291 level
= OSPF6_DEBUG_NEIGHBOR_EVENT
;
1293 level
= OSPF6_DEBUG_NEIGHBOR_STATE
| OSPF6_DEBUG_NEIGHBOR_EVENT
;
1295 OSPF6_DEBUG_NEIGHBOR_OFF(level
);
1300 DEFUN (no_debug_ospf6
,
1309 OSPF6_DEBUG_ABR_OFF();
1310 OSPF6_DEBUG_ASBR_OFF();
1311 OSPF6_DEBUG_BROUTER_OFF();
1312 OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_OFF();
1313 OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_OFF();
1314 OSPF6_DEBUG_FLOODING_OFF();
1315 OSPF6_DEBUG_INTERFACE_OFF();
1317 ospf6_lsa_debug_set_all(false);
1319 for (i
= 0; i
< 6; i
++)
1320 OSPF6_DEBUG_MESSAGE_OFF(i
,
1321 OSPF6_DEBUG_NEIGHBOR_STATE
1322 | OSPF6_DEBUG_NEIGHBOR_EVENT
);
1324 OSPF6_DEBUG_NEIGHBOR_OFF(OSPF6_DEBUG_NEIGHBOR_STATE
1325 | OSPF6_DEBUG_NEIGHBOR_EVENT
);
1326 OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_TABLE
);
1327 OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_INTRA
);
1328 OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_INTER
);
1329 OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_MEMORY
);
1330 OSPF6_DEBUG_SPF_OFF(OSPF6_DEBUG_SPF_PROCESS
);
1331 OSPF6_DEBUG_SPF_OFF(OSPF6_DEBUG_SPF_TIME
);
1332 OSPF6_DEBUG_SPF_OFF(OSPF6_DEBUG_SPF_DATABASE
);
1333 OSPF6_DEBUG_ZEBRA_OFF(OSPF6_DEBUG_ZEBRA_SEND
| OSPF6_DEBUG_ZEBRA_RECV
);
1338 int config_write_ospf6_debug_neighbor(struct vty
*vty
)
1340 if (IS_OSPF6_DEBUG_NEIGHBOR(STATE
) && IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
1341 vty_out(vty
, "debug ospf6 neighbor\n");
1342 else if (IS_OSPF6_DEBUG_NEIGHBOR(STATE
))
1343 vty_out(vty
, "debug ospf6 neighbor state\n");
1344 else if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
1345 vty_out(vty
, "debug ospf6 neighbor event\n");
1349 void install_element_ospf6_debug_neighbor(void)
1351 install_element(ENABLE_NODE
, &debug_ospf6_neighbor_cmd
);
1352 install_element(ENABLE_NODE
, &no_debug_ospf6_neighbor_cmd
);
1353 install_element(ENABLE_NODE
, &no_debug_ospf6_cmd
);
1354 install_element(CONFIG_NODE
, &debug_ospf6_neighbor_cmd
);
1355 install_element(CONFIG_NODE
, &no_debug_ospf6_neighbor_cmd
);
1356 install_element(CONFIG_NODE
, &no_debug_ospf6_cmd
);