]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* |
508e53e2 | 2 | * Copyright (C) 2003 Yasuhiro Ohara |
718e3744 | 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 | * | |
896014f4 DL |
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 | |
718e3744 | 19 | */ |
20 | ||
718e3744 | 21 | #include <zebra.h> |
22 | ||
23 | #include "log.h" | |
508e53e2 | 24 | #include "memory.h" |
718e3744 | 25 | #include "thread.h" |
26 | #include "linklist.h" | |
27 | #include "vty.h" | |
28 | #include "command.h" | |
d06cc416 | 29 | #include "lib/bfd.h" |
718e3744 | 30 | |
508e53e2 | 31 | #include "ospf6_proto.h" |
718e3744 | 32 | #include "ospf6_lsa.h" |
508e53e2 | 33 | #include "ospf6_lsdb.h" |
718e3744 | 34 | #include "ospf6_message.h" |
508e53e2 | 35 | #include "ospf6_top.h" |
36 | #include "ospf6_area.h" | |
37 | #include "ospf6_interface.h" | |
718e3744 | 38 | #include "ospf6_neighbor.h" |
508e53e2 | 39 | #include "ospf6_intra.h" |
3b4cd3a9 | 40 | #include "ospf6_flood.h" |
049207c3 | 41 | #include "ospf6d.h" |
7f342629 | 42 | #include "ospf6_bfd.h" |
4dfd8aff DW |
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" | |
0d1753a7 | 48 | #include "ospf6_gr.h" |
6a5bb300 | 49 | #include "lib/json.h" |
718e3744 | 50 | |
a526c055 | 51 | DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_NEIGHBOR, "OSPF6 neighbor"); |
30043e4c | 52 | |
3012671f | 53 | DEFINE_HOOK(ospf6_neighbor_change, |
d62a17ae | 54 | (struct ospf6_neighbor * on, int state, int next_state), |
8451921b | 55 | (on, state, next_state)); |
3012671f | 56 | |
508e53e2 | 57 | unsigned char conf_debug_ospf6_neighbor = 0; |
58 | ||
2b64873d | 59 | const char *const ospf6_neighbor_state_str[] = { |
d62a17ae | 60 | "None", "Down", "Attempt", "Init", "Twoway", |
61 | "ExStart", "ExChange", "Loading", "Full", NULL}; | |
718e3744 | 62 | |
2b64873d DL |
63 | const char *const ospf6_neighbor_event_str[] = { |
64 | "NoEvent", "HelloReceived", "2-WayReceived", "NegotiationDone", | |
65 | "ExchangeDone", "LoadingDone", "AdjOK?", "SeqNumberMismatch", | |
66 | "BadLSReq", "1-WayReceived", "InactivityTimer", | |
67 | }; | |
68 | ||
d62a17ae | 69 | int ospf6_neighbor_cmp(void *va, void *vb) |
718e3744 | 70 | { |
d62a17ae | 71 | struct ospf6_neighbor *ona = (struct ospf6_neighbor *)va; |
72 | struct ospf6_neighbor *onb = (struct ospf6_neighbor *)vb; | |
27fa3398 DS |
73 | |
74 | if (ona->router_id == onb->router_id) | |
75 | return 0; | |
76 | ||
77 | return (ntohl(ona->router_id) < ntohl(onb->router_id)) ? -1 : 1; | |
718e3744 | 78 | } |
79 | ||
d7c0a89a | 80 | struct ospf6_neighbor *ospf6_neighbor_lookup(uint32_t router_id, |
d62a17ae | 81 | struct ospf6_interface *oi) |
718e3744 | 82 | { |
d62a17ae | 83 | struct listnode *n; |
84 | struct ospf6_neighbor *on; | |
85 | ||
86 | for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, n, on)) | |
87 | if (on->router_id == router_id) | |
88 | return on; | |
89 | ||
90 | return (struct ospf6_neighbor *)NULL; | |
718e3744 | 91 | } |
92 | ||
71165098 RW |
93 | struct ospf6_neighbor *ospf6_area_neighbor_lookup(struct ospf6_area *area, |
94 | uint32_t router_id) | |
95 | { | |
96 | struct ospf6_interface *oi; | |
97 | struct ospf6_neighbor *nbr; | |
98 | struct listnode *node; | |
99 | ||
100 | for (ALL_LIST_ELEMENTS_RO(area->if_list, node, oi)) { | |
101 | nbr = ospf6_neighbor_lookup(router_id, oi); | |
102 | if (nbr) | |
103 | return nbr; | |
104 | } | |
105 | ||
106 | return NULL; | |
107 | } | |
108 | ||
508e53e2 | 109 | /* create ospf6_neighbor */ |
d7c0a89a | 110 | struct ospf6_neighbor *ospf6_neighbor_create(uint32_t router_id, |
d62a17ae | 111 | struct ospf6_interface *oi) |
718e3744 | 112 | { |
d62a17ae | 113 | struct ospf6_neighbor *on; |
114 | char buf[16]; | |
6cb85350 | 115 | int type; |
d62a17ae | 116 | |
aa406bbc | 117 | on = XCALLOC(MTYPE_OSPF6_NEIGHBOR, sizeof(struct ospf6_neighbor)); |
d62a17ae | 118 | inet_ntop(AF_INET, &router_id, buf, sizeof(buf)); |
119 | snprintf(on->name, sizeof(on->name), "%s%%%s", buf, | |
120 | oi->interface->name); | |
121 | on->ospf6_if = oi; | |
122 | on->state = OSPF6_NEIGHBOR_DOWN; | |
123 | on->state_change = 0; | |
124 | monotime(&on->last_changed); | |
125 | on->router_id = router_id; | |
126 | ||
127 | on->summary_list = ospf6_lsdb_create(on); | |
128 | on->request_list = ospf6_lsdb_create(on); | |
129 | on->retrans_list = ospf6_lsdb_create(on); | |
130 | ||
131 | on->dbdesc_list = ospf6_lsdb_create(on); | |
132 | on->lsupdate_list = ospf6_lsdb_create(on); | |
133 | on->lsack_list = ospf6_lsdb_create(on); | |
134 | ||
6cb85350 AR |
135 | for (type = 0; type < OSPF6_MESSAGE_TYPE_MAX; type++) { |
136 | on->seqnum_l[type] = 0; | |
137 | on->seqnum_h[type] = 0; | |
138 | } | |
139 | ||
140 | on->auth_present = false; | |
141 | ||
d62a17ae | 142 | listnode_add_sort(oi->neighbor_list, on); |
143 | ||
144 | ospf6_bfd_info_nbr_create(oi, on); | |
145 | return on; | |
718e3744 | 146 | } |
147 | ||
d62a17ae | 148 | void ospf6_neighbor_delete(struct ospf6_neighbor *on) |
718e3744 | 149 | { |
2e37407f | 150 | struct ospf6_lsa *lsa, *lsanext; |
3b4cd3a9 | 151 | |
d62a17ae | 152 | ospf6_lsdb_remove_all(on->summary_list); |
153 | ospf6_lsdb_remove_all(on->request_list); | |
2e37407f | 154 | for (ALL_LSDB(on->retrans_list, lsa, lsanext)) { |
d62a17ae | 155 | ospf6_decrement_retrans_count(lsa); |
156 | ospf6_lsdb_remove(lsa, on->retrans_list); | |
157 | } | |
718e3744 | 158 | |
d62a17ae | 159 | ospf6_lsdb_remove_all(on->dbdesc_list); |
160 | ospf6_lsdb_remove_all(on->lsupdate_list); | |
161 | ospf6_lsdb_remove_all(on->lsack_list); | |
508e53e2 | 162 | |
d62a17ae | 163 | ospf6_lsdb_delete(on->summary_list); |
164 | ospf6_lsdb_delete(on->request_list); | |
165 | ospf6_lsdb_delete(on->retrans_list); | |
718e3744 | 166 | |
d62a17ae | 167 | ospf6_lsdb_delete(on->dbdesc_list); |
168 | ospf6_lsdb_delete(on->lsupdate_list); | |
169 | ospf6_lsdb_delete(on->lsack_list); | |
508e53e2 | 170 | |
d62a17ae | 171 | THREAD_OFF(on->inactivity_timer); |
508e53e2 | 172 | |
bc09f3e6 YR |
173 | THREAD_OFF(on->last_dbdesc_release_timer); |
174 | ||
d62a17ae | 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); | |
9318fc6a | 179 | THREAD_OFF(on->thread_exchange_done); |
81e06dd3 DS |
180 | THREAD_OFF(on->thread_adj_ok); |
181 | ||
0d1753a7 | 182 | THREAD_OFF(on->gr_helper_info.t_grace_timer); |
508e53e2 | 183 | |
d06cc416 | 184 | bfd_sess_free(&on->bfd_session); |
d62a17ae | 185 | XFREE(MTYPE_OSPF6_NEIGHBOR, on); |
718e3744 | 186 | } |
187 | ||
d7c0a89a | 188 | static void ospf6_neighbor_state_change(uint8_t next_state, |
d62a17ae | 189 | struct ospf6_neighbor *on, int event) |
718e3744 | 190 | { |
d7c0a89a | 191 | uint8_t prev_state; |
d62a17ae | 192 | |
193 | prev_state = on->state; | |
194 | on->state = next_state; | |
195 | ||
196 | if (prev_state == next_state) | |
197 | return; | |
198 | ||
199 | on->state_change++; | |
200 | monotime(&on->last_changed); | |
201 | ||
202 | /* log */ | |
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)); | |
208 | } | |
209 | ||
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)); | |
221 | ||
222 | if (prev_state == OSPF6_NEIGHBOR_FULL | |
223 | || next_state == OSPF6_NEIGHBOR_FULL) { | |
0d1753a7 | 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( | |
229 | on->ospf6_if); | |
230 | } | |
d62a17ae | 231 | } |
690df177 CS |
232 | if (next_state == OSPF6_NEIGHBOR_FULL) |
233 | on->ospf6_if->area->intra_prefix_originate = 1; | |
234 | ||
0d1753a7 | 235 | if (!OSPF6_GR_IS_ACTIVE_HELPER(on)) |
236 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB( | |
237 | on->ospf6_if->area); | |
76249532 | 238 | |
0d1753a7 | 239 | if ((prev_state == OSPF6_NEIGHBOR_LOADING |
240 | || prev_state == OSPF6_NEIGHBOR_EXCHANGE) | |
241 | && next_state == OSPF6_NEIGHBOR_FULL) { | |
76249532 | 242 | OSPF6_AS_EXTERN_LSA_SCHEDULE(on->ospf6_if); |
d6927cf3 | 243 | on->ospf6_if->area->full_nbrs++; |
76249532 | 244 | } |
d6927cf3 CS |
245 | |
246 | if (prev_state == OSPF6_NEIGHBOR_FULL) | |
247 | on->ospf6_if->area->full_nbrs--; | |
d62a17ae | 248 | } |
249 | ||
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); | |
255 | ||
256 | hook_call(ospf6_neighbor_change, on, next_state, prev_state); | |
257 | ospf6_bfd_trigger_event(on, prev_state, next_state); | |
718e3744 | 258 | } |
259 | ||
508e53e2 | 260 | /* RFC2328 section 10.4 */ |
d62a17ae | 261 | static int need_adjacency(struct ospf6_neighbor *on) |
718e3744 | 262 | { |
d62a17ae | 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) | |
266 | return 1; | |
718e3744 | 267 | |
d62a17ae | 268 | if (on->ospf6_if->drouter == on->router_id |
269 | || on->ospf6_if->bdrouter == on->router_id) | |
270 | return 1; | |
508e53e2 | 271 | |
d62a17ae | 272 | return 0; |
718e3744 | 273 | } |
274 | ||
d62a17ae | 275 | int hello_received(struct thread *thread) |
718e3744 | 276 | { |
d62a17ae | 277 | struct ospf6_neighbor *on; |
718e3744 | 278 | |
d62a17ae | 279 | on = (struct ospf6_neighbor *)THREAD_ARG(thread); |
280 | assert(on); | |
718e3744 | 281 | |
d62a17ae | 282 | if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) |
283 | zlog_debug("Neighbor Event %s: *HelloReceived*", on->name); | |
508e53e2 | 284 | |
d62a17ae | 285 | /* reset Inactivity Timer */ |
286 | THREAD_OFF(on->inactivity_timer); | |
d62a17ae | 287 | thread_add_timer(master, inactivity_timer, on, |
288 | on->ospf6_if->dead_interval, &on->inactivity_timer); | |
508e53e2 | 289 | |
d62a17ae | 290 | if (on->state <= OSPF6_NEIGHBOR_DOWN) |
291 | ospf6_neighbor_state_change(OSPF6_NEIGHBOR_INIT, on, | |
292 | OSPF6_NEIGHBOR_EVENT_HELLO_RCVD); | |
508e53e2 | 293 | |
d62a17ae | 294 | return 0; |
718e3744 | 295 | } |
296 | ||
d62a17ae | 297 | int twoway_received(struct thread *thread) |
718e3744 | 298 | { |
d62a17ae | 299 | struct ospf6_neighbor *on; |
508e53e2 | 300 | |
d62a17ae | 301 | on = (struct ospf6_neighbor *)THREAD_ARG(thread); |
302 | assert(on); | |
508e53e2 | 303 | |
d62a17ae | 304 | if (on->state > OSPF6_NEIGHBOR_INIT) |
305 | return 0; | |
508e53e2 | 306 | |
d62a17ae | 307 | if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) |
308 | zlog_debug("Neighbor Event %s: *2Way-Received*", on->name); | |
508e53e2 | 309 | |
d62a17ae | 310 | thread_add_event(master, neighbor_change, on->ospf6_if, 0, NULL); |
508e53e2 | 311 | |
d62a17ae | 312 | if (!need_adjacency(on)) { |
313 | ospf6_neighbor_state_change(OSPF6_NEIGHBOR_TWOWAY, on, | |
314 | OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD); | |
315 | return 0; | |
316 | } | |
718e3744 | 317 | |
d62a17ae | 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); | |
508e53e2 | 323 | |
d62a17ae | 324 | THREAD_OFF(on->thread_send_dbdesc); |
d62a17ae | 325 | thread_add_event(master, ospf6_dbdesc_send, on, 0, |
326 | &on->thread_send_dbdesc); | |
508e53e2 | 327 | |
d62a17ae | 328 | return 0; |
718e3744 | 329 | } |
330 | ||
d62a17ae | 331 | int negotiation_done(struct thread *thread) |
718e3744 | 332 | { |
d62a17ae | 333 | struct ospf6_neighbor *on; |
2e37407f | 334 | struct ospf6_lsa *lsa, *lsanext; |
d62a17ae | 335 | |
336 | on = (struct ospf6_neighbor *)THREAD_ARG(thread); | |
337 | assert(on); | |
338 | ||
339 | if (on->state != OSPF6_NEIGHBOR_EXSTART) | |
340 | return 0; | |
341 | ||
342 | if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) | |
343 | zlog_debug("Neighbor Event %s: *NegotiationDone*", on->name); | |
344 | ||
345 | /* clear ls-list */ | |
346 | ospf6_lsdb_remove_all(on->summary_list); | |
347 | ospf6_lsdb_remove_all(on->request_list); | |
2e37407f | 348 | for (ALL_LSDB(on->retrans_list, lsa, lsanext)) { |
d62a17ae | 349 | ospf6_decrement_retrans_count(lsa); |
350 | ospf6_lsdb_remove(lsa, on->retrans_list); | |
351 | } | |
352 | ||
353 | /* Interface scoped LSAs */ | |
2e37407f | 354 | for (ALL_LSDB(on->ospf6_if->lsdb, lsa, lsanext)) { |
d62a17ae | 355 | if (OSPF6_LSA_IS_MAXAGE(lsa)) { |
356 | ospf6_increment_retrans_count(lsa); | |
357 | ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->retrans_list); | |
358 | } else | |
359 | ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->summary_list); | |
360 | } | |
361 | ||
362 | /* Area scoped LSAs */ | |
2e37407f | 363 | for (ALL_LSDB(on->ospf6_if->area->lsdb, lsa, lsanext)) { |
d62a17ae | 364 | if (OSPF6_LSA_IS_MAXAGE(lsa)) { |
365 | ospf6_increment_retrans_count(lsa); | |
366 | ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->retrans_list); | |
367 | } else | |
368 | ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->summary_list); | |
369 | } | |
370 | ||
371 | /* AS scoped LSAs */ | |
2e37407f | 372 | for (ALL_LSDB(on->ospf6_if->area->ospf6->lsdb, lsa, lsanext)) { |
d62a17ae | 373 | if (OSPF6_LSA_IS_MAXAGE(lsa)) { |
374 | ospf6_increment_retrans_count(lsa); | |
375 | ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->retrans_list); | |
376 | } else | |
377 | ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->summary_list); | |
378 | } | |
379 | ||
380 | UNSET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT); | |
381 | ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXCHANGE, on, | |
382 | OSPF6_NEIGHBOR_EVENT_NEGOTIATION_DONE); | |
383 | ||
384 | return 0; | |
718e3744 | 385 | } |
386 | ||
bc09f3e6 YR |
387 | static int ospf6_neighbor_last_dbdesc_release(struct thread *thread) |
388 | { | |
389 | struct ospf6_neighbor *on = THREAD_ARG(thread); | |
390 | ||
391 | assert(on); | |
392 | memset(&on->dbdesc_last, 0, sizeof(struct ospf6_dbdesc)); | |
393 | ||
394 | return 0; | |
395 | } | |
396 | ||
d62a17ae | 397 | int exchange_done(struct thread *thread) |
718e3744 | 398 | { |
d62a17ae | 399 | struct ospf6_neighbor *on; |
718e3744 | 400 | |
d62a17ae | 401 | on = (struct ospf6_neighbor *)THREAD_ARG(thread); |
402 | assert(on); | |
508e53e2 | 403 | |
d62a17ae | 404 | if (on->state != OSPF6_NEIGHBOR_EXCHANGE) |
405 | return 0; | |
508e53e2 | 406 | |
d62a17ae | 407 | if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) |
408 | zlog_debug("Neighbor Event %s: *ExchangeDone*", on->name); | |
508e53e2 | 409 | |
d62a17ae | 410 | THREAD_OFF(on->thread_send_dbdesc); |
411 | ospf6_lsdb_remove_all(on->dbdesc_list); | |
508e53e2 | 412 | |
bc09f3e6 YR |
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); | |
419 | } | |
508e53e2 | 420 | |
d62a17ae | 421 | if (on->request_list->count == 0) |
422 | ospf6_neighbor_state_change(OSPF6_NEIGHBOR_FULL, on, | |
423 | OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE); | |
424 | else { | |
425 | ospf6_neighbor_state_change(OSPF6_NEIGHBOR_LOADING, on, | |
426 | OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE); | |
eb82e9ee | 427 | |
d62a17ae | 428 | thread_add_event(master, ospf6_lsreq_send, on, 0, |
429 | &on->thread_send_lsreq); | |
430 | } | |
508e53e2 | 431 | |
d62a17ae | 432 | return 0; |
508e53e2 | 433 | } |
434 | ||
eb82e9ee | 435 | /* Check loading state. */ |
d62a17ae | 436 | void ospf6_check_nbr_loading(struct ospf6_neighbor *on) |
eb82e9ee DD |
437 | { |
438 | ||
d62a17ae | 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. | |
442 | */ | |
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); | |
d62a17ae | 450 | thread_add_event(master, ospf6_lsreq_send, on, 0, |
451 | &on->thread_send_lsreq); | |
452 | } | |
eb82e9ee | 453 | } |
eb82e9ee DD |
454 | } |
455 | ||
d62a17ae | 456 | int loading_done(struct thread *thread) |
508e53e2 | 457 | { |
d62a17ae | 458 | struct ospf6_neighbor *on; |
508e53e2 | 459 | |
d62a17ae | 460 | on = (struct ospf6_neighbor *)THREAD_ARG(thread); |
461 | assert(on); | |
508e53e2 | 462 | |
d62a17ae | 463 | if (on->state != OSPF6_NEIGHBOR_LOADING) |
464 | return 0; | |
508e53e2 | 465 | |
d62a17ae | 466 | if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) |
467 | zlog_debug("Neighbor Event %s: *LoadingDone*", on->name); | |
508e53e2 | 468 | |
d62a17ae | 469 | assert(on->request_list->count == 0); |
508e53e2 | 470 | |
d62a17ae | 471 | ospf6_neighbor_state_change(OSPF6_NEIGHBOR_FULL, on, |
472 | OSPF6_NEIGHBOR_EVENT_LOADING_DONE); | |
508e53e2 | 473 | |
d62a17ae | 474 | return 0; |
508e53e2 | 475 | } |
476 | ||
d62a17ae | 477 | int adj_ok(struct thread *thread) |
508e53e2 | 478 | { |
d62a17ae | 479 | struct ospf6_neighbor *on; |
2e37407f | 480 | struct ospf6_lsa *lsa, *lsanext; |
d62a17ae | 481 | |
482 | on = (struct ospf6_neighbor *)THREAD_ARG(thread); | |
483 | assert(on); | |
484 | ||
485 | if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) | |
486 | zlog_debug("Neighbor Event %s: *AdjOK?*", on->name); | |
487 | ||
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); | |
494 | ||
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); | |
499 | ||
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); | |
2e37407f | 505 | for (ALL_LSDB(on->retrans_list, lsa, lsanext)) { |
d62a17ae | 506 | ospf6_decrement_retrans_count(lsa); |
507 | ospf6_lsdb_remove(lsa, on->retrans_list); | |
508 | } | |
509 | } | |
510 | ||
511 | return 0; | |
508e53e2 | 512 | } |
718e3744 | 513 | |
d62a17ae | 514 | int seqnumber_mismatch(struct thread *thread) |
508e53e2 | 515 | { |
d62a17ae | 516 | struct ospf6_neighbor *on; |
2e37407f | 517 | struct ospf6_lsa *lsa, *lsanext; |
718e3744 | 518 | |
d62a17ae | 519 | on = (struct ospf6_neighbor *)THREAD_ARG(thread); |
520 | assert(on); | |
718e3744 | 521 | |
d62a17ae | 522 | if (on->state < OSPF6_NEIGHBOR_EXCHANGE) |
523 | return 0; | |
718e3744 | 524 | |
d62a17ae | 525 | if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) |
526 | zlog_debug("Neighbor Event %s: *SeqNumberMismatch*", on->name); | |
718e3744 | 527 | |
d62a17ae | 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); | |
718e3744 | 533 | |
d62a17ae | 534 | ospf6_lsdb_remove_all(on->summary_list); |
535 | ospf6_lsdb_remove_all(on->request_list); | |
2e37407f | 536 | for (ALL_LSDB(on->retrans_list, lsa, lsanext)) { |
d62a17ae | 537 | ospf6_decrement_retrans_count(lsa); |
538 | ospf6_lsdb_remove(lsa, on->retrans_list); | |
539 | } | |
508e53e2 | 540 | |
d62a17ae | 541 | THREAD_OFF(on->thread_send_dbdesc); |
542 | on->dbdesc_seqnum++; /* Incr seqnum as per RFC2328, sec 10.3 */ | |
931b1b8c | 543 | |
d62a17ae | 544 | on->thread_send_dbdesc = NULL; |
545 | thread_add_event(master, ospf6_dbdesc_send, on, 0, | |
546 | &on->thread_send_dbdesc); | |
508e53e2 | 547 | |
d62a17ae | 548 | return 0; |
718e3744 | 549 | } |
550 | ||
d62a17ae | 551 | int bad_lsreq(struct thread *thread) |
718e3744 | 552 | { |
d62a17ae | 553 | struct ospf6_neighbor *on; |
2e37407f | 554 | struct ospf6_lsa *lsa, *lsanext; |
508e53e2 | 555 | |
d62a17ae | 556 | on = (struct ospf6_neighbor *)THREAD_ARG(thread); |
557 | assert(on); | |
508e53e2 | 558 | |
d62a17ae | 559 | if (on->state < OSPF6_NEIGHBOR_EXCHANGE) |
560 | return 0; | |
718e3744 | 561 | |
d62a17ae | 562 | if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) |
563 | zlog_debug("Neighbor Event %s: *BadLSReq*", on->name); | |
718e3744 | 564 | |
d62a17ae | 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); | |
718e3744 | 570 | |
d62a17ae | 571 | ospf6_lsdb_remove_all(on->summary_list); |
572 | ospf6_lsdb_remove_all(on->request_list); | |
2e37407f | 573 | for (ALL_LSDB(on->retrans_list, lsa, lsanext)) { |
d62a17ae | 574 | ospf6_decrement_retrans_count(lsa); |
575 | ospf6_lsdb_remove(lsa, on->retrans_list); | |
576 | } | |
718e3744 | 577 | |
d62a17ae | 578 | THREAD_OFF(on->thread_send_dbdesc); |
579 | on->dbdesc_seqnum++; /* Incr seqnum as per RFC2328, sec 10.3 */ | |
931b1b8c | 580 | |
d62a17ae | 581 | on->thread_send_dbdesc = NULL; |
582 | thread_add_event(master, ospf6_dbdesc_send, on, 0, | |
583 | &on->thread_send_dbdesc); | |
508e53e2 | 584 | |
d62a17ae | 585 | return 0; |
718e3744 | 586 | } |
587 | ||
d62a17ae | 588 | int oneway_received(struct thread *thread) |
718e3744 | 589 | { |
d62a17ae | 590 | struct ospf6_neighbor *on; |
2e37407f | 591 | struct ospf6_lsa *lsa, *lsanext; |
718e3744 | 592 | |
d62a17ae | 593 | on = (struct ospf6_neighbor *)THREAD_ARG(thread); |
594 | assert(on); | |
508e53e2 | 595 | |
d62a17ae | 596 | if (on->state < OSPF6_NEIGHBOR_TWOWAY) |
597 | return 0; | |
508e53e2 | 598 | |
d62a17ae | 599 | if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) |
600 | zlog_debug("Neighbor Event %s: *1Way-Received*", on->name); | |
508e53e2 | 601 | |
d62a17ae | 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); | |
508e53e2 | 605 | |
d62a17ae | 606 | ospf6_lsdb_remove_all(on->summary_list); |
607 | ospf6_lsdb_remove_all(on->request_list); | |
2e37407f | 608 | for (ALL_LSDB(on->retrans_list, lsa, lsanext)) { |
d62a17ae | 609 | ospf6_decrement_retrans_count(lsa); |
610 | ospf6_lsdb_remove(lsa, on->retrans_list); | |
611 | } | |
508e53e2 | 612 | |
d62a17ae | 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); | |
9318fc6a | 617 | THREAD_OFF(on->thread_exchange_done); |
81e06dd3 | 618 | THREAD_OFF(on->thread_adj_ok); |
508e53e2 | 619 | |
d62a17ae | 620 | return 0; |
508e53e2 | 621 | } |
622 | ||
d62a17ae | 623 | int inactivity_timer(struct thread *thread) |
508e53e2 | 624 | { |
d62a17ae | 625 | struct ospf6_neighbor *on; |
508e53e2 | 626 | |
d62a17ae | 627 | on = (struct ospf6_neighbor *)THREAD_ARG(thread); |
628 | assert(on); | |
508e53e2 | 629 | |
d62a17ae | 630 | if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) |
631 | zlog_debug("Neighbor Event %s: *InactivityTimer*", on->name); | |
508e53e2 | 632 | |
d62a17ae | 633 | on->drouter = on->prev_drouter = 0; |
634 | on->bdrouter = on->prev_bdrouter = 0; | |
508e53e2 | 635 | |
0d1753a7 | 636 | if (!OSPF6_GR_IS_ACTIVE_HELPER(on)) { |
637 | on->drouter = on->prev_drouter = 0; | |
638 | on->bdrouter = on->prev_bdrouter = 0; | |
639 | ||
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, | |
644 | NULL); | |
645 | ||
646 | listnode_delete(on->ospf6_if->neighbor_list, on); | |
647 | ospf6_neighbor_delete(on); | |
508e53e2 | 648 | |
0d1753a7 | 649 | } else { |
0fc3e113 | 650 | if (IS_DEBUG_OSPF6_GR) |
0d1753a7 | 651 | zlog_debug( |
652 | "%s, Acting as HELPER for this neighbour, So restart the dead timer.", | |
653 | __PRETTY_FUNCTION__); | |
654 | ||
655 | thread_add_timer(master, inactivity_timer, on, | |
656 | on->ospf6_if->dead_interval, | |
657 | &on->inactivity_timer); | |
658 | } | |
508e53e2 | 659 | |
d62a17ae | 660 | return 0; |
718e3744 | 661 | } |
662 | ||
508e53e2 | 663 | |
718e3744 | 664 | /* vty functions */ |
665 | /* show neighbor structure */ | |
6a5bb300 | 666 | static void ospf6_neighbor_show(struct vty *vty, struct ospf6_neighbor *on, |
667 | json_object *json_array, bool use_json) | |
718e3744 | 668 | { |
d62a17ae | 669 | char router_id[16]; |
68bfcc05 | 670 | char duration[64]; |
d62a17ae | 671 | struct timeval res; |
672 | char nstate[16]; | |
68bfcc05 | 673 | char deadtime[64]; |
d62a17ae | 674 | long h, m, s; |
6a5bb300 | 675 | json_object *json_route; |
d62a17ae | 676 | |
677 | /* Router-ID (Name) */ | |
678 | inet_ntop(AF_INET, &on->router_id, router_id, sizeof(router_id)); | |
508e53e2 | 679 | #ifdef HAVE_GETNAMEINFO |
d62a17ae | 680 | { |
681 | } | |
508e53e2 | 682 | #endif /*HAVE_GETNAMEINFO*/ |
683 | ||
d62a17ae | 684 | /* Dead time */ |
685 | h = m = s = 0; | |
686 | if (on->inactivity_timer) { | |
687 | s = monotime_until(&on->inactivity_timer->u.sands, NULL) | |
688 | / 1000000LL; | |
689 | h = s / 3600; | |
690 | s -= h * 3600; | |
691 | m = s / 60; | |
692 | s -= m * 60; | |
693 | } | |
694 | snprintf(deadtime, sizeof(deadtime), "%02ld:%02ld:%02ld", h, m, s); | |
695 | ||
696 | /* Neighbor State */ | |
e5973353 | 697 | if (on->ospf6_if->type == OSPF_IFTYPE_POINTOPOINT) |
d62a17ae | 698 | snprintf(nstate, sizeof(nstate), "PointToPoint"); |
699 | else { | |
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"); | |
704 | else | |
705 | snprintf(nstate, sizeof(nstate), "DROther"); | |
706 | } | |
707 | ||
708 | /* Duration */ | |
709 | monotime_since(&on->last_changed, &res); | |
710 | timerstring(&res, duration, sizeof(duration)); | |
711 | ||
712 | /* | |
713 | vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]\n", | |
6a5bb300 | 714 | "Neighbor ID", "Pri", "DeadTime", "State", "IfState", |
715 | "Duration", "I/F", "State"); | |
d62a17ae | 716 | */ |
6a5bb300 | 717 | if (use_json) { |
718 | json_route = json_object_new_object(); | |
719 | ||
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]); | |
732 | ||
733 | json_object_array_add(json_array, json_route); | |
734 | } else | |
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]); | |
508e53e2 | 740 | } |
741 | ||
d62a17ae | 742 | static void ospf6_neighbor_show_drchoice(struct vty *vty, |
6a5bb300 | 743 | struct ospf6_neighbor *on, |
744 | json_object *json_array, bool use_json) | |
508e53e2 | 745 | { |
d62a17ae | 746 | char router_id[16]; |
747 | char drouter[16], bdrouter[16]; | |
68bfcc05 | 748 | char duration[64]; |
d62a17ae | 749 | struct timeval now, res; |
6a5bb300 | 750 | json_object *json_route; |
d62a17ae | 751 | |
752 | /* | |
753 | vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]\n", | |
754 | "RouterID", "State", "Duration", "DR", "BDR", "I/F", | |
755 | "State"); | |
756 | */ | |
757 | ||
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)); | |
761 | ||
762 | monotime(&now); | |
763 | timersub(&now, &on->last_changed, &res); | |
764 | timerstring(&res, duration, sizeof(duration)); | |
765 | ||
6a5bb300 | 766 | if (use_json) { |
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]); | |
779 | ||
780 | json_object_array_add(json_array, json_route); | |
781 | } else | |
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]); | |
718e3744 | 786 | } |
787 | ||
d62a17ae | 788 | static void ospf6_neighbor_show_detail(struct vty *vty, |
6a5bb300 | 789 | struct ospf6_neighbor *on, |
790 | json_object *json, bool use_json) | |
718e3744 | 791 | { |
d62a17ae | 792 | char drouter[16], bdrouter[16]; |
793 | char linklocal_addr[64], duration[32]; | |
794 | struct timeval now, res; | |
2e37407f | 795 | struct ospf6_lsa *lsa, *lsanext; |
6a5bb300 | 796 | json_object *json_neighbor; |
797 | json_object *json_array; | |
798 | char db_desc_str[20]; | |
d62a17ae | 799 | |
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)); | |
804 | ||
805 | monotime(&now); | |
806 | timersub(&now, &on->last_changed, &res); | |
807 | timerstring(&res, duration, sizeof(duration)); | |
808 | ||
6a5bb300 | 809 | if (use_json) { |
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", | |
818 | on->ifindex); | |
819 | json_object_string_add(json_neighbor, "linkLocalAddress", | |
820 | linklocal_addr); | |
821 | json_object_string_add(json_neighbor, "neighborState", | |
822 | ospf6_neighbor_state_str[on->state]); | |
823 | json_object_string_add(json_neighbor, "neighborStateDuration", | |
824 | duration); | |
825 | json_object_string_add(json_neighbor, "neighborDRouter", | |
826 | drouter); | |
827 | json_object_string_add(json_neighbor, "neighborBdRouter", | |
828 | bdrouter); | |
829 | snprintf(db_desc_str, sizeof(db_desc_str), "%s%s%s", | |
830 | (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT) | |
831 | ? "Initial " | |
832 | : ""), | |
833 | (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT) | |
834 | ? "More" | |
835 | : ""), | |
836 | (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MSBIT) | |
837 | ? "Master" | |
838 | : "Slave")); | |
839 | json_object_string_add(json_neighbor, "dbDescStatus", | |
840 | db_desc_str); | |
841 | ||
842 | json_object_int_add(json_neighbor, "dbDescSeqNumber", | |
843 | (unsigned long)ntohl(on->dbdesc_seqnum)); | |
844 | ||
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", | |
852 | json_array); | |
853 | ||
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", | |
861 | json_array); | |
862 | ||
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", | |
870 | json_array); | |
871 | ||
872 | ||
873 | timerclear(&res); | |
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", | |
880 | duration); | |
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", | |
888 | json_array); | |
889 | ||
890 | timerclear(&res); | |
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", | |
897 | duration); | |
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", | |
905 | json_array); | |
906 | ||
907 | ||
908 | timerclear(&res); | |
909 | if (on->thread_send_lsupdate) | |
910 | timersub(&on->thread_send_lsupdate->u.sands, &now, | |
911 | &res); | |
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", | |
916 | duration); | |
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", | |
925 | json_array); | |
926 | ||
927 | timerclear(&res); | |
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", | |
934 | duration); | |
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", | |
942 | json_array); | |
943 | ||
d06cc416 | 944 | bfd_sess_show(vty, json_neighbor, on->bfd_session); |
6a5bb300 | 945 | |
6cb85350 AR |
946 | if (on->auth_present == true) { |
947 | json_object_string_add(json_neighbor, "authStatus", | |
948 | "enabled"); | |
949 | json_object_int_add( | |
950 | json_neighbor, "recvdHelloHigherSeqNo", | |
951 | on->seqnum_h[OSPF6_MESSAGE_TYPE_HELLO]); | |
952 | json_object_int_add( | |
953 | json_neighbor, "recvdHelloLowerSeqNo", | |
954 | on->seqnum_l[OSPF6_MESSAGE_TYPE_HELLO]); | |
955 | json_object_int_add( | |
956 | json_neighbor, "recvdDBDescHigherSeqNo", | |
957 | on->seqnum_h[OSPF6_MESSAGE_TYPE_DBDESC]); | |
958 | json_object_int_add( | |
959 | json_neighbor, "recvdDBDescLowerSeqNo", | |
960 | on->seqnum_l[OSPF6_MESSAGE_TYPE_DBDESC]); | |
961 | json_object_int_add( | |
962 | json_neighbor, "recvdLSReqHigherSeqNo", | |
963 | on->seqnum_h[OSPF6_MESSAGE_TYPE_LSREQ]); | |
964 | json_object_int_add( | |
965 | json_neighbor, "recvdLSReqLowerSeqNo", | |
966 | on->seqnum_l[OSPF6_MESSAGE_TYPE_LSREQ]); | |
967 | json_object_int_add( | |
968 | json_neighbor, "recvdLSUpdHigherSeqNo", | |
969 | on->seqnum_h[OSPF6_MESSAGE_TYPE_LSUPDATE]); | |
970 | json_object_int_add( | |
971 | json_neighbor, "recvdLSUpdLowerSeqNo", | |
972 | on->seqnum_l[OSPF6_MESSAGE_TYPE_LSUPDATE]); | |
973 | json_object_int_add( | |
974 | json_neighbor, "recvdLSAckHigherSeqNo", | |
975 | on->seqnum_h[OSPF6_MESSAGE_TYPE_LSACK]); | |
976 | json_object_int_add( | |
977 | json_neighbor, "recvdLSAckLowerSeqNo", | |
978 | on->seqnum_l[OSPF6_MESSAGE_TYPE_LSACK]); | |
979 | } else | |
980 | json_object_string_add(json_neighbor, "authStatus", | |
981 | "disabled"); | |
6a5bb300 | 982 | |
6cb85350 | 983 | json_object_object_add(json, on->name, json_neighbor); |
6a5bb300 | 984 | |
985 | } else { | |
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) | |
998 | ? "Initial " | |
999 | : ""), | |
1000 | (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT) | |
1001 | ? "More " | |
1002 | : ""), | |
1003 | (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MSBIT) | |
1004 | ? "Master" | |
1005 | : "Slave"), | |
1006 | (unsigned long)ntohl(on->dbdesc_seqnum)); | |
1007 | ||
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); | |
1012 | ||
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); | |
1017 | ||
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); | |
1022 | ||
1023 | timerclear(&res); | |
1024 | if (on->thread_send_dbdesc) | |
1025 | timersub(&on->thread_send_dbdesc->u.sands, &now, &res); | |
1026 | timerstring(&res, duration, sizeof(duration)); | |
1027 | vty_out(vty, | |
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); | |
1033 | ||
1034 | timerclear(&res); | |
1035 | if (on->thread_send_lsreq) | |
1036 | timersub(&on->thread_send_lsreq->u.sands, &now, &res); | |
1037 | timerstring(&res, duration, sizeof(duration)); | |
1038 | vty_out(vty, | |
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); | |
1044 | ||
1045 | timerclear(&res); | |
1046 | if (on->thread_send_lsupdate) | |
1047 | timersub(&on->thread_send_lsupdate->u.sands, &now, | |
1048 | &res); | |
1049 | timerstring(&res, duration, sizeof(duration)); | |
1050 | vty_out(vty, | |
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); | |
1056 | ||
1057 | timerclear(&res); | |
1058 | if (on->thread_send_lsack) | |
1059 | timersub(&on->thread_send_lsack->u.sands, &now, &res); | |
1060 | timerstring(&res, duration, sizeof(duration)); | |
1061 | vty_out(vty, | |
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); | |
1067 | ||
d06cc416 | 1068 | bfd_sess_show(vty, NULL, on->bfd_session); |
6cb85350 AR |
1069 | |
1070 | if (on->auth_present == true) { | |
1071 | vty_out(vty, " Authentication header present\n"); | |
1072 | vty_out(vty, | |
1073 | "\t\t\t hello DBDesc LSReq LSUpd LSAck\n"); | |
1074 | vty_out(vty, | |
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]); | |
1081 | vty_out(vty, | |
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]); | |
1088 | } else | |
1089 | vty_out(vty, " Authentication header not present\n"); | |
6a5bb300 | 1090 | } |
718e3744 | 1091 | } |
1092 | ||
ee3e6d7f IR |
1093 | static void ospf6_neighbor_show_detail_common(struct vty *vty, |
1094 | struct ospf6 *ospf6, bool uj, | |
1095 | bool detail, bool drchoice) | |
718e3744 | 1096 | { |
d62a17ae | 1097 | struct ospf6_neighbor *on; |
1098 | struct ospf6_interface *oi; | |
1099 | struct ospf6_area *oa; | |
1100 | struct listnode *i, *j, *k; | |
6a5bb300 | 1101 | json_object *json = NULL; |
1102 | json_object *json_array = NULL; | |
6a5bb300 | 1103 | void (*showfunc)(struct vty *, struct ospf6_neighbor *, |
1104 | json_object *json, bool use_json); | |
d62a17ae | 1105 | |
ee3e6d7f IR |
1106 | if (detail) |
1107 | showfunc = ospf6_neighbor_show_detail; | |
1108 | else if (drchoice) | |
1109 | showfunc = ospf6_neighbor_show_drchoice; | |
1110 | else | |
1111 | showfunc = ospf6_neighbor_show; | |
d62a17ae | 1112 | |
6a5bb300 | 1113 | if (uj) { |
1114 | json = json_object_new_object(); | |
1115 | json_array = json_object_new_array(); | |
1116 | } else { | |
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", | |
1124 | "I/F", "State"); | |
1125 | } | |
d62a17ae | 1126 | |
1127 | for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) | |
1128 | for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi)) | |
6a5bb300 | 1129 | for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, k, on)) { |
1130 | if (showfunc == ospf6_neighbor_show_detail) | |
1131 | (*showfunc)(vty, on, json, uj); | |
1132 | else | |
1133 | (*showfunc)(vty, on, json_array, uj); | |
1134 | } | |
1135 | ||
1136 | if (uj) { | |
1137 | if (showfunc != ospf6_neighbor_show_detail) | |
1138 | json_object_object_add(json, "neighbors", json_array); | |
1139 | else | |
1140 | json_object_free(json_array); | |
5a6c232b | 1141 | vty_json(vty, json); |
6a5bb300 | 1142 | } |
718e3744 | 1143 | } |
1144 | ||
d48ef099 | 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 | |
1148 | "All VRFs\n" | |
1149 | "Neighbor list\n" | |
1150 | "Display details\n" | |
1151 | "Display DR choices\n" JSON_STR) | |
1152 | { | |
d48ef099 | 1153 | struct ospf6 *ospf6; |
1154 | struct listnode *node; | |
1155 | const char *vrf_name = NULL; | |
1156 | bool all_vrf = false; | |
1157 | int idx_vrf = 0; | |
ee3e6d7f IR |
1158 | int idx_type = 4; |
1159 | bool uj = use_json(argc, argv); | |
1160 | bool detail = false; | |
1161 | bool drchoice = false; | |
d48ef099 | 1162 | |
d48ef099 | 1163 | OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); |
ee3e6d7f IR |
1164 | |
1165 | if (argv_find(argv, argc, "detail", &idx_type)) | |
1166 | detail = true; | |
1167 | else if (argv_find(argv, argc, "drchoice", &idx_type)) | |
1168 | drchoice = true; | |
d48ef099 | 1169 | |
1170 | for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) { | |
1171 | if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) { | |
ee3e6d7f IR |
1172 | ospf6_neighbor_show_detail_common(vty, ospf6, uj, |
1173 | detail, drchoice); | |
d48ef099 | 1174 | if (!all_vrf) |
1175 | break; | |
1176 | } | |
1177 | } | |
718e3744 | 1178 | |
d6b901ac | 1179 | OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6); |
1180 | ||
d48ef099 | 1181 | return CMD_SUCCESS; |
1182 | } | |
1183 | ||
1184 | static int ospf6_neighbor_show_common(struct vty *vty, int argc, | |
1185 | struct cmd_token **argv, | |
d6b901ac | 1186 | struct ospf6 *ospf6, int idx_ipv4, |
1187 | bool uj) | |
718e3744 | 1188 | { |
d62a17ae | 1189 | struct ospf6_neighbor *on; |
1190 | struct ospf6_interface *oi; | |
1191 | struct ospf6_area *oa; | |
1192 | struct listnode *i, *j, *k; | |
6a5bb300 | 1193 | void (*showfunc)(struct vty *, struct ospf6_neighbor *, |
1194 | json_object *json, bool use_json); | |
d7c0a89a | 1195 | uint32_t router_id; |
6a5bb300 | 1196 | json_object *json = NULL; |
d62a17ae | 1197 | |
d62a17ae | 1198 | showfunc = ospf6_neighbor_show_detail; |
6a5bb300 | 1199 | if (uj) |
1200 | json = json_object_new_object(); | |
d62a17ae | 1201 | |
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); | |
1205 | return CMD_SUCCESS; | |
1206 | } | |
1207 | ||
1208 | for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) | |
1209 | for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi)) | |
786b76d0 YR |
1210 | for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, k, on)) { |
1211 | if (router_id == on->router_id) | |
1212 | (*showfunc)(vty, on, json, uj); | |
1213 | } | |
d62a17ae | 1214 | |
c48349e3 | 1215 | if (uj) |
5a6c232b | 1216 | vty_json(vty, json); |
d48ef099 | 1217 | |
1218 | return CMD_SUCCESS; | |
1219 | } | |
1220 | ||
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 | |
1224 | "All VRFs\n" | |
1225 | "Neighbor list\n" | |
1226 | "Specify Router-ID as IPv4 address notation\n" JSON_STR) | |
1227 | { | |
1228 | int idx_ipv4 = 4; | |
1229 | struct ospf6 *ospf6; | |
1230 | struct listnode *node; | |
1231 | const char *vrf_name = NULL; | |
1232 | bool all_vrf = false; | |
1233 | int idx_vrf = 0; | |
d6b901ac | 1234 | bool uj = use_json(argc, argv); |
d48ef099 | 1235 | |
d48ef099 | 1236 | OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); |
1237 | if (idx_vrf > 0) | |
1238 | idx_ipv4 += 2; | |
1239 | ||
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, | |
d6b901ac | 1243 | idx_ipv4, uj); |
d48ef099 | 1244 | |
1245 | if (!all_vrf) | |
1246 | break; | |
1247 | } | |
1248 | } | |
1249 | ||
d6b901ac | 1250 | OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6); |
1251 | ||
d62a17ae | 1252 | return CMD_SUCCESS; |
718e3744 | 1253 | } |
1254 | ||
d62a17ae | 1255 | void ospf6_neighbor_init(void) |
718e3744 | 1256 | { |
d62a17ae | 1257 | install_element(VIEW_NODE, &show_ipv6_ospf6_neighbor_cmd); |
1258 | install_element(VIEW_NODE, &show_ipv6_ospf6_neighbor_one_cmd); | |
508e53e2 | 1259 | } |
1260 | ||
1261 | DEFUN (debug_ospf6_neighbor, | |
1262 | debug_ospf6_neighbor_cmd, | |
6de69f83 | 1263 | "debug ospf6 neighbor [<state|event>]", |
508e53e2 | 1264 | DEBUG_STR |
1265 | OSPF6_STR | |
1266 | "Debug OSPFv3 Neighbor\n" | |
1d68dbfe DW |
1267 | "Debug OSPFv3 Neighbor State Change\n" |
1268 | "Debug OSPFv3 Neighbor Event\n") | |
508e53e2 | 1269 | { |
d62a17ae | 1270 | int idx_type = 3; |
1271 | unsigned char level = 0; | |
1272 | ||
1273 | if (argc == 4) { | |
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; | |
1278 | } else | |
1279 | level = OSPF6_DEBUG_NEIGHBOR_STATE | OSPF6_DEBUG_NEIGHBOR_EVENT; | |
1280 | ||
1281 | OSPF6_DEBUG_NEIGHBOR_ON(level); | |
1282 | return CMD_SUCCESS; | |
718e3744 | 1283 | } |
1284 | ||
508e53e2 | 1285 | |
1286 | DEFUN (no_debug_ospf6_neighbor, | |
1287 | no_debug_ospf6_neighbor_cmd, | |
6de69f83 | 1288 | "no debug ospf6 neighbor [<state|event>]", |
508e53e2 | 1289 | NO_STR |
1290 | DEBUG_STR | |
1291 | OSPF6_STR | |
1292 | "Debug OSPFv3 Neighbor\n" | |
1d68dbfe DW |
1293 | "Debug OSPFv3 Neighbor State Change\n" |
1294 | "Debug OSPFv3 Neighbor Event\n") | |
508e53e2 | 1295 | { |
d62a17ae | 1296 | int idx_type = 4; |
1297 | unsigned char level = 0; | |
1298 | ||
1299 | if (argc == 5) { | |
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; | |
1304 | } else | |
1305 | level = OSPF6_DEBUG_NEIGHBOR_STATE | OSPF6_DEBUG_NEIGHBOR_EVENT; | |
1306 | ||
1307 | OSPF6_DEBUG_NEIGHBOR_OFF(level); | |
1308 | return CMD_SUCCESS; | |
508e53e2 | 1309 | } |
1310 | ||
508e53e2 | 1311 | |
4dfd8aff DW |
1312 | DEFUN (no_debug_ospf6, |
1313 | no_debug_ospf6_cmd, | |
1314 | "no debug ospf6", | |
1315 | NO_STR | |
1316 | DEBUG_STR | |
1317 | OSPF6_STR) | |
1318 | { | |
d7c0a89a | 1319 | unsigned int i; |
d62a17ae | 1320 | |
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(); | |
1328 | ||
067967b8 | 1329 | ospf6_lsa_debug_set_all(false); |
d62a17ae | 1330 | |
1331 | for (i = 0; i < 6; i++) | |
1332 | OSPF6_DEBUG_MESSAGE_OFF(i, | |
1333 | OSPF6_DEBUG_NEIGHBOR_STATE | |
1334 | | OSPF6_DEBUG_NEIGHBOR_EVENT); | |
1335 | ||
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); | |
1346 | ||
1347 | return CMD_SUCCESS; | |
4dfd8aff DW |
1348 | } |
1349 | ||
d62a17ae | 1350 | int config_write_ospf6_debug_neighbor(struct vty *vty) |
508e53e2 | 1351 | { |
d62a17ae | 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"); | |
1358 | return 0; | |
508e53e2 | 1359 | } |
1360 | ||
d62a17ae | 1361 | void install_element_ospf6_debug_neighbor(void) |
508e53e2 | 1362 | { |
d62a17ae | 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); | |
508e53e2 | 1369 | } |