]>
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 | ||
cc9f21da | 275 | void 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); | |
718e3744 | 293 | } |
294 | ||
cc9f21da | 295 | void twoway_received(struct thread *thread) |
718e3744 | 296 | { |
d62a17ae | 297 | struct ospf6_neighbor *on; |
508e53e2 | 298 | |
d62a17ae | 299 | on = (struct ospf6_neighbor *)THREAD_ARG(thread); |
300 | assert(on); | |
508e53e2 | 301 | |
d62a17ae | 302 | if (on->state > OSPF6_NEIGHBOR_INIT) |
cc9f21da | 303 | return; |
508e53e2 | 304 | |
d62a17ae | 305 | if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) |
306 | zlog_debug("Neighbor Event %s: *2Way-Received*", on->name); | |
508e53e2 | 307 | |
d62a17ae | 308 | thread_add_event(master, neighbor_change, on->ospf6_if, 0, NULL); |
508e53e2 | 309 | |
d62a17ae | 310 | if (!need_adjacency(on)) { |
311 | ospf6_neighbor_state_change(OSPF6_NEIGHBOR_TWOWAY, on, | |
312 | OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD); | |
cc9f21da | 313 | return; |
d62a17ae | 314 | } |
718e3744 | 315 | |
d62a17ae | 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); | |
508e53e2 | 321 | |
d62a17ae | 322 | THREAD_OFF(on->thread_send_dbdesc); |
d62a17ae | 323 | thread_add_event(master, ospf6_dbdesc_send, on, 0, |
324 | &on->thread_send_dbdesc); | |
718e3744 | 325 | } |
326 | ||
cc9f21da | 327 | void negotiation_done(struct thread *thread) |
718e3744 | 328 | { |
d62a17ae | 329 | struct ospf6_neighbor *on; |
2e37407f | 330 | struct ospf6_lsa *lsa, *lsanext; |
d62a17ae | 331 | |
332 | on = (struct ospf6_neighbor *)THREAD_ARG(thread); | |
333 | assert(on); | |
334 | ||
335 | if (on->state != OSPF6_NEIGHBOR_EXSTART) | |
cc9f21da | 336 | return; |
d62a17ae | 337 | |
338 | if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) | |
339 | zlog_debug("Neighbor Event %s: *NegotiationDone*", on->name); | |
340 | ||
341 | /* clear ls-list */ | |
342 | ospf6_lsdb_remove_all(on->summary_list); | |
343 | ospf6_lsdb_remove_all(on->request_list); | |
2e37407f | 344 | for (ALL_LSDB(on->retrans_list, lsa, lsanext)) { |
d62a17ae | 345 | ospf6_decrement_retrans_count(lsa); |
346 | ospf6_lsdb_remove(lsa, on->retrans_list); | |
347 | } | |
348 | ||
349 | /* Interface scoped LSAs */ | |
2e37407f | 350 | for (ALL_LSDB(on->ospf6_if->lsdb, lsa, lsanext)) { |
d62a17ae | 351 | if (OSPF6_LSA_IS_MAXAGE(lsa)) { |
352 | ospf6_increment_retrans_count(lsa); | |
353 | ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->retrans_list); | |
354 | } else | |
355 | ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->summary_list); | |
356 | } | |
357 | ||
358 | /* Area scoped LSAs */ | |
2e37407f | 359 | for (ALL_LSDB(on->ospf6_if->area->lsdb, lsa, lsanext)) { |
d62a17ae | 360 | if (OSPF6_LSA_IS_MAXAGE(lsa)) { |
361 | ospf6_increment_retrans_count(lsa); | |
362 | ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->retrans_list); | |
363 | } else | |
364 | ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->summary_list); | |
365 | } | |
366 | ||
367 | /* AS scoped LSAs */ | |
2e37407f | 368 | for (ALL_LSDB(on->ospf6_if->area->ospf6->lsdb, lsa, lsanext)) { |
d62a17ae | 369 | if (OSPF6_LSA_IS_MAXAGE(lsa)) { |
370 | ospf6_increment_retrans_count(lsa); | |
371 | ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->retrans_list); | |
372 | } else | |
373 | ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->summary_list); | |
374 | } | |
375 | ||
376 | UNSET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT); | |
377 | ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXCHANGE, on, | |
378 | OSPF6_NEIGHBOR_EVENT_NEGOTIATION_DONE); | |
718e3744 | 379 | } |
380 | ||
cc9f21da | 381 | static void ospf6_neighbor_last_dbdesc_release(struct thread *thread) |
bc09f3e6 YR |
382 | { |
383 | struct ospf6_neighbor *on = THREAD_ARG(thread); | |
384 | ||
385 | assert(on); | |
386 | memset(&on->dbdesc_last, 0, sizeof(struct ospf6_dbdesc)); | |
bc09f3e6 YR |
387 | } |
388 | ||
cc9f21da | 389 | void exchange_done(struct thread *thread) |
718e3744 | 390 | { |
d62a17ae | 391 | struct ospf6_neighbor *on; |
718e3744 | 392 | |
d62a17ae | 393 | on = (struct ospf6_neighbor *)THREAD_ARG(thread); |
394 | assert(on); | |
508e53e2 | 395 | |
d62a17ae | 396 | if (on->state != OSPF6_NEIGHBOR_EXCHANGE) |
cc9f21da | 397 | return; |
508e53e2 | 398 | |
d62a17ae | 399 | if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) |
400 | zlog_debug("Neighbor Event %s: *ExchangeDone*", on->name); | |
508e53e2 | 401 | |
d62a17ae | 402 | THREAD_OFF(on->thread_send_dbdesc); |
403 | ospf6_lsdb_remove_all(on->dbdesc_list); | |
508e53e2 | 404 | |
bc09f3e6 YR |
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); | |
411 | } | |
508e53e2 | 412 | |
d62a17ae | 413 | if (on->request_list->count == 0) |
414 | ospf6_neighbor_state_change(OSPF6_NEIGHBOR_FULL, on, | |
415 | OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE); | |
416 | else { | |
417 | ospf6_neighbor_state_change(OSPF6_NEIGHBOR_LOADING, on, | |
418 | OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE); | |
eb82e9ee | 419 | |
d62a17ae | 420 | thread_add_event(master, ospf6_lsreq_send, on, 0, |
421 | &on->thread_send_lsreq); | |
422 | } | |
508e53e2 | 423 | } |
424 | ||
eb82e9ee | 425 | /* Check loading state. */ |
d62a17ae | 426 | void ospf6_check_nbr_loading(struct ospf6_neighbor *on) |
eb82e9ee DD |
427 | { |
428 | ||
d62a17ae | 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. | |
432 | */ | |
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 | if (on->thread_send_lsreq != NULL) | |
439 | THREAD_OFF(on->thread_send_lsreq); | |
d62a17ae | 440 | thread_add_event(master, ospf6_lsreq_send, on, 0, |
441 | &on->thread_send_lsreq); | |
442 | } | |
eb82e9ee | 443 | } |
eb82e9ee DD |
444 | } |
445 | ||
cc9f21da | 446 | void loading_done(struct thread *thread) |
508e53e2 | 447 | { |
d62a17ae | 448 | struct ospf6_neighbor *on; |
508e53e2 | 449 | |
d62a17ae | 450 | on = (struct ospf6_neighbor *)THREAD_ARG(thread); |
451 | assert(on); | |
508e53e2 | 452 | |
d62a17ae | 453 | if (on->state != OSPF6_NEIGHBOR_LOADING) |
cc9f21da | 454 | return; |
508e53e2 | 455 | |
d62a17ae | 456 | if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) |
457 | zlog_debug("Neighbor Event %s: *LoadingDone*", on->name); | |
508e53e2 | 458 | |
d62a17ae | 459 | assert(on->request_list->count == 0); |
508e53e2 | 460 | |
d62a17ae | 461 | ospf6_neighbor_state_change(OSPF6_NEIGHBOR_FULL, on, |
462 | OSPF6_NEIGHBOR_EVENT_LOADING_DONE); | |
508e53e2 | 463 | } |
464 | ||
cc9f21da | 465 | void adj_ok(struct thread *thread) |
508e53e2 | 466 | { |
d62a17ae | 467 | struct ospf6_neighbor *on; |
2e37407f | 468 | struct ospf6_lsa *lsa, *lsanext; |
d62a17ae | 469 | |
470 | on = (struct ospf6_neighbor *)THREAD_ARG(thread); | |
471 | assert(on); | |
472 | ||
473 | if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) | |
474 | zlog_debug("Neighbor Event %s: *AdjOK?*", on->name); | |
475 | ||
476 | if (on->state == OSPF6_NEIGHBOR_TWOWAY && need_adjacency(on)) { | |
477 | ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART, on, | |
478 | OSPF6_NEIGHBOR_EVENT_ADJ_OK); | |
479 | SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MSBIT); | |
480 | SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT); | |
481 | SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT); | |
482 | ||
483 | THREAD_OFF(on->thread_send_dbdesc); | |
484 | on->thread_send_dbdesc = NULL; | |
485 | thread_add_event(master, ospf6_dbdesc_send, on, 0, | |
486 | &on->thread_send_dbdesc); | |
487 | ||
488 | } else if (on->state >= OSPF6_NEIGHBOR_EXSTART && !need_adjacency(on)) { | |
489 | ospf6_neighbor_state_change(OSPF6_NEIGHBOR_TWOWAY, on, | |
490 | OSPF6_NEIGHBOR_EVENT_ADJ_OK); | |
491 | ospf6_lsdb_remove_all(on->summary_list); | |
492 | ospf6_lsdb_remove_all(on->request_list); | |
2e37407f | 493 | for (ALL_LSDB(on->retrans_list, lsa, lsanext)) { |
d62a17ae | 494 | ospf6_decrement_retrans_count(lsa); |
495 | ospf6_lsdb_remove(lsa, on->retrans_list); | |
496 | } | |
497 | } | |
508e53e2 | 498 | } |
718e3744 | 499 | |
cc9f21da | 500 | void seqnumber_mismatch(struct thread *thread) |
508e53e2 | 501 | { |
d62a17ae | 502 | struct ospf6_neighbor *on; |
2e37407f | 503 | struct ospf6_lsa *lsa, *lsanext; |
718e3744 | 504 | |
d62a17ae | 505 | on = (struct ospf6_neighbor *)THREAD_ARG(thread); |
506 | assert(on); | |
718e3744 | 507 | |
d62a17ae | 508 | if (on->state < OSPF6_NEIGHBOR_EXCHANGE) |
cc9f21da | 509 | return; |
718e3744 | 510 | |
d62a17ae | 511 | if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) |
512 | zlog_debug("Neighbor Event %s: *SeqNumberMismatch*", on->name); | |
718e3744 | 513 | |
d62a17ae | 514 | ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART, on, |
515 | OSPF6_NEIGHBOR_EVENT_SEQNUMBER_MISMATCH); | |
516 | SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MSBIT); | |
517 | SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT); | |
518 | SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT); | |
718e3744 | 519 | |
d62a17ae | 520 | ospf6_lsdb_remove_all(on->summary_list); |
521 | ospf6_lsdb_remove_all(on->request_list); | |
2e37407f | 522 | for (ALL_LSDB(on->retrans_list, lsa, lsanext)) { |
d62a17ae | 523 | ospf6_decrement_retrans_count(lsa); |
524 | ospf6_lsdb_remove(lsa, on->retrans_list); | |
525 | } | |
508e53e2 | 526 | |
d62a17ae | 527 | THREAD_OFF(on->thread_send_dbdesc); |
528 | on->dbdesc_seqnum++; /* Incr seqnum as per RFC2328, sec 10.3 */ | |
931b1b8c | 529 | |
d62a17ae | 530 | on->thread_send_dbdesc = NULL; |
531 | thread_add_event(master, ospf6_dbdesc_send, on, 0, | |
532 | &on->thread_send_dbdesc); | |
718e3744 | 533 | } |
534 | ||
cc9f21da | 535 | void bad_lsreq(struct thread *thread) |
718e3744 | 536 | { |
d62a17ae | 537 | struct ospf6_neighbor *on; |
2e37407f | 538 | struct ospf6_lsa *lsa, *lsanext; |
508e53e2 | 539 | |
d62a17ae | 540 | on = (struct ospf6_neighbor *)THREAD_ARG(thread); |
541 | assert(on); | |
508e53e2 | 542 | |
d62a17ae | 543 | if (on->state < OSPF6_NEIGHBOR_EXCHANGE) |
cc9f21da | 544 | return; |
718e3744 | 545 | |
d62a17ae | 546 | if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) |
547 | zlog_debug("Neighbor Event %s: *BadLSReq*", on->name); | |
718e3744 | 548 | |
d62a17ae | 549 | ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART, on, |
550 | OSPF6_NEIGHBOR_EVENT_BAD_LSREQ); | |
551 | SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MSBIT); | |
552 | SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT); | |
553 | SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT); | |
718e3744 | 554 | |
d62a17ae | 555 | ospf6_lsdb_remove_all(on->summary_list); |
556 | ospf6_lsdb_remove_all(on->request_list); | |
2e37407f | 557 | for (ALL_LSDB(on->retrans_list, lsa, lsanext)) { |
d62a17ae | 558 | ospf6_decrement_retrans_count(lsa); |
559 | ospf6_lsdb_remove(lsa, on->retrans_list); | |
560 | } | |
718e3744 | 561 | |
d62a17ae | 562 | THREAD_OFF(on->thread_send_dbdesc); |
563 | on->dbdesc_seqnum++; /* Incr seqnum as per RFC2328, sec 10.3 */ | |
931b1b8c | 564 | |
d62a17ae | 565 | on->thread_send_dbdesc = NULL; |
566 | thread_add_event(master, ospf6_dbdesc_send, on, 0, | |
567 | &on->thread_send_dbdesc); | |
508e53e2 | 568 | |
718e3744 | 569 | } |
570 | ||
cc9f21da | 571 | void oneway_received(struct thread *thread) |
718e3744 | 572 | { |
d62a17ae | 573 | struct ospf6_neighbor *on; |
2e37407f | 574 | struct ospf6_lsa *lsa, *lsanext; |
718e3744 | 575 | |
d62a17ae | 576 | on = (struct ospf6_neighbor *)THREAD_ARG(thread); |
577 | assert(on); | |
508e53e2 | 578 | |
d62a17ae | 579 | if (on->state < OSPF6_NEIGHBOR_TWOWAY) |
cc9f21da | 580 | return; |
508e53e2 | 581 | |
d62a17ae | 582 | if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) |
583 | zlog_debug("Neighbor Event %s: *1Way-Received*", on->name); | |
508e53e2 | 584 | |
d62a17ae | 585 | ospf6_neighbor_state_change(OSPF6_NEIGHBOR_INIT, on, |
586 | OSPF6_NEIGHBOR_EVENT_ONEWAY_RCVD); | |
587 | thread_add_event(master, neighbor_change, on->ospf6_if, 0, NULL); | |
508e53e2 | 588 | |
d62a17ae | 589 | ospf6_lsdb_remove_all(on->summary_list); |
590 | ospf6_lsdb_remove_all(on->request_list); | |
2e37407f | 591 | for (ALL_LSDB(on->retrans_list, lsa, lsanext)) { |
d62a17ae | 592 | ospf6_decrement_retrans_count(lsa); |
593 | ospf6_lsdb_remove(lsa, on->retrans_list); | |
594 | } | |
508e53e2 | 595 | |
d62a17ae | 596 | THREAD_OFF(on->thread_send_dbdesc); |
597 | THREAD_OFF(on->thread_send_lsreq); | |
598 | THREAD_OFF(on->thread_send_lsupdate); | |
599 | THREAD_OFF(on->thread_send_lsack); | |
9318fc6a | 600 | THREAD_OFF(on->thread_exchange_done); |
81e06dd3 | 601 | THREAD_OFF(on->thread_adj_ok); |
508e53e2 | 602 | } |
603 | ||
cc9f21da | 604 | void inactivity_timer(struct thread *thread) |
508e53e2 | 605 | { |
d62a17ae | 606 | struct ospf6_neighbor *on; |
508e53e2 | 607 | |
d62a17ae | 608 | on = (struct ospf6_neighbor *)THREAD_ARG(thread); |
609 | assert(on); | |
508e53e2 | 610 | |
d62a17ae | 611 | if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) |
612 | zlog_debug("Neighbor Event %s: *InactivityTimer*", on->name); | |
508e53e2 | 613 | |
d62a17ae | 614 | on->drouter = on->prev_drouter = 0; |
615 | on->bdrouter = on->prev_bdrouter = 0; | |
508e53e2 | 616 | |
0d1753a7 | 617 | if (!OSPF6_GR_IS_ACTIVE_HELPER(on)) { |
618 | on->drouter = on->prev_drouter = 0; | |
619 | on->bdrouter = on->prev_bdrouter = 0; | |
620 | ||
621 | ospf6_neighbor_state_change( | |
622 | OSPF6_NEIGHBOR_DOWN, on, | |
623 | OSPF6_NEIGHBOR_EVENT_INACTIVITY_TIMER); | |
624 | thread_add_event(master, neighbor_change, on->ospf6_if, 0, | |
625 | NULL); | |
626 | ||
627 | listnode_delete(on->ospf6_if->neighbor_list, on); | |
628 | ospf6_neighbor_delete(on); | |
508e53e2 | 629 | |
0d1753a7 | 630 | } else { |
0fc3e113 | 631 | if (IS_DEBUG_OSPF6_GR) |
0d1753a7 | 632 | zlog_debug( |
633 | "%s, Acting as HELPER for this neighbour, So restart the dead timer.", | |
634 | __PRETTY_FUNCTION__); | |
635 | ||
636 | thread_add_timer(master, inactivity_timer, on, | |
637 | on->ospf6_if->dead_interval, | |
638 | &on->inactivity_timer); | |
639 | } | |
718e3744 | 640 | } |
641 | ||
508e53e2 | 642 | |
718e3744 | 643 | /* vty functions */ |
644 | /* show neighbor structure */ | |
6a5bb300 | 645 | static void ospf6_neighbor_show(struct vty *vty, struct ospf6_neighbor *on, |
646 | json_object *json_array, bool use_json) | |
718e3744 | 647 | { |
d62a17ae | 648 | char router_id[16]; |
68bfcc05 | 649 | char duration[64]; |
d62a17ae | 650 | struct timeval res; |
651 | char nstate[16]; | |
68bfcc05 | 652 | char deadtime[64]; |
d62a17ae | 653 | long h, m, s; |
6a5bb300 | 654 | json_object *json_route; |
d62a17ae | 655 | |
656 | /* Router-ID (Name) */ | |
657 | inet_ntop(AF_INET, &on->router_id, router_id, sizeof(router_id)); | |
508e53e2 | 658 | #ifdef HAVE_GETNAMEINFO |
d62a17ae | 659 | { |
660 | } | |
508e53e2 | 661 | #endif /*HAVE_GETNAMEINFO*/ |
662 | ||
d62a17ae | 663 | /* Dead time */ |
664 | h = m = s = 0; | |
665 | if (on->inactivity_timer) { | |
666 | s = monotime_until(&on->inactivity_timer->u.sands, NULL) | |
667 | / 1000000LL; | |
668 | h = s / 3600; | |
669 | s -= h * 3600; | |
670 | m = s / 60; | |
671 | s -= m * 60; | |
672 | } | |
673 | snprintf(deadtime, sizeof(deadtime), "%02ld:%02ld:%02ld", h, m, s); | |
674 | ||
675 | /* Neighbor State */ | |
e5973353 | 676 | if (on->ospf6_if->type == OSPF_IFTYPE_POINTOPOINT) |
d62a17ae | 677 | snprintf(nstate, sizeof(nstate), "PointToPoint"); |
678 | else { | |
679 | if (on->router_id == on->drouter) | |
680 | snprintf(nstate, sizeof(nstate), "DR"); | |
681 | else if (on->router_id == on->bdrouter) | |
682 | snprintf(nstate, sizeof(nstate), "BDR"); | |
683 | else | |
684 | snprintf(nstate, sizeof(nstate), "DROther"); | |
685 | } | |
686 | ||
687 | /* Duration */ | |
688 | monotime_since(&on->last_changed, &res); | |
689 | timerstring(&res, duration, sizeof(duration)); | |
690 | ||
691 | /* | |
692 | vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]\n", | |
6a5bb300 | 693 | "Neighbor ID", "Pri", "DeadTime", "State", "IfState", |
694 | "Duration", "I/F", "State"); | |
d62a17ae | 695 | */ |
6a5bb300 | 696 | if (use_json) { |
697 | json_route = json_object_new_object(); | |
698 | ||
699 | json_object_string_add(json_route, "neighborId", router_id); | |
700 | json_object_int_add(json_route, "priority", on->priority); | |
701 | json_object_string_add(json_route, "deadTime", deadtime); | |
702 | json_object_string_add(json_route, "state", | |
703 | ospf6_neighbor_state_str[on->state]); | |
704 | json_object_string_add(json_route, "ifState", nstate); | |
705 | json_object_string_add(json_route, "duration", duration); | |
706 | json_object_string_add(json_route, "interfaceName", | |
707 | on->ospf6_if->interface->name); | |
708 | json_object_string_add( | |
709 | json_route, "interfaceState", | |
710 | ospf6_interface_state_str[on->ospf6_if->state]); | |
711 | ||
712 | json_object_array_add(json_array, json_route); | |
713 | } else | |
714 | vty_out(vty, "%-15s %3d %11s %8s/%-12s %11s %s[%s]\n", | |
715 | router_id, on->priority, deadtime, | |
716 | ospf6_neighbor_state_str[on->state], nstate, duration, | |
717 | on->ospf6_if->interface->name, | |
718 | ospf6_interface_state_str[on->ospf6_if->state]); | |
508e53e2 | 719 | } |
720 | ||
d62a17ae | 721 | static void ospf6_neighbor_show_drchoice(struct vty *vty, |
6a5bb300 | 722 | struct ospf6_neighbor *on, |
723 | json_object *json_array, bool use_json) | |
508e53e2 | 724 | { |
d62a17ae | 725 | char router_id[16]; |
726 | char drouter[16], bdrouter[16]; | |
68bfcc05 | 727 | char duration[64]; |
d62a17ae | 728 | struct timeval now, res; |
6a5bb300 | 729 | json_object *json_route; |
d62a17ae | 730 | |
731 | /* | |
732 | vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]\n", | |
733 | "RouterID", "State", "Duration", "DR", "BDR", "I/F", | |
734 | "State"); | |
735 | */ | |
736 | ||
737 | inet_ntop(AF_INET, &on->router_id, router_id, sizeof(router_id)); | |
738 | inet_ntop(AF_INET, &on->drouter, drouter, sizeof(drouter)); | |
739 | inet_ntop(AF_INET, &on->bdrouter, bdrouter, sizeof(bdrouter)); | |
740 | ||
741 | monotime(&now); | |
742 | timersub(&now, &on->last_changed, &res); | |
743 | timerstring(&res, duration, sizeof(duration)); | |
744 | ||
6a5bb300 | 745 | if (use_json) { |
746 | json_route = json_object_new_object(); | |
747 | json_object_string_add(json_route, "routerId", router_id); | |
748 | json_object_string_add(json_route, "state", | |
749 | ospf6_neighbor_state_str[on->state]); | |
750 | json_object_string_add(json_route, "duration", duration); | |
751 | json_object_string_add(json_route, "dRouter", drouter); | |
752 | json_object_string_add(json_route, "bdRouter", bdrouter); | |
753 | json_object_string_add(json_route, "interfaceName", | |
754 | on->ospf6_if->interface->name); | |
755 | json_object_string_add( | |
756 | json_route, "interfaceState", | |
757 | ospf6_interface_state_str[on->ospf6_if->state]); | |
758 | ||
759 | json_object_array_add(json_array, json_route); | |
760 | } else | |
761 | vty_out(vty, "%-15s %8s/%-11s %-15s %-15s %s[%s]\n", router_id, | |
762 | ospf6_neighbor_state_str[on->state], duration, drouter, | |
763 | bdrouter, on->ospf6_if->interface->name, | |
764 | ospf6_interface_state_str[on->ospf6_if->state]); | |
718e3744 | 765 | } |
766 | ||
d62a17ae | 767 | static void ospf6_neighbor_show_detail(struct vty *vty, |
6a5bb300 | 768 | struct ospf6_neighbor *on, |
769 | json_object *json, bool use_json) | |
718e3744 | 770 | { |
d62a17ae | 771 | char drouter[16], bdrouter[16]; |
772 | char linklocal_addr[64], duration[32]; | |
773 | struct timeval now, res; | |
2e37407f | 774 | struct ospf6_lsa *lsa, *lsanext; |
6a5bb300 | 775 | json_object *json_neighbor; |
776 | json_object *json_array; | |
777 | char db_desc_str[20]; | |
d62a17ae | 778 | |
779 | inet_ntop(AF_INET6, &on->linklocal_addr, linklocal_addr, | |
780 | sizeof(linklocal_addr)); | |
781 | inet_ntop(AF_INET, &on->drouter, drouter, sizeof(drouter)); | |
782 | inet_ntop(AF_INET, &on->bdrouter, bdrouter, sizeof(bdrouter)); | |
783 | ||
784 | monotime(&now); | |
785 | timersub(&now, &on->last_changed, &res); | |
786 | timerstring(&res, duration, sizeof(duration)); | |
787 | ||
6a5bb300 | 788 | if (use_json) { |
789 | json_neighbor = json_object_new_object(); | |
790 | json_object_string_add(json_neighbor, "area", | |
791 | on->ospf6_if->area->name); | |
792 | json_object_string_add(json_neighbor, "interface", | |
793 | on->ospf6_if->interface->name); | |
794 | json_object_int_add(json_neighbor, "interfaceIndex", | |
795 | on->ospf6_if->interface->ifindex); | |
796 | json_object_int_add(json_neighbor, "neighborInterfaceIndex", | |
797 | on->ifindex); | |
798 | json_object_string_add(json_neighbor, "linkLocalAddress", | |
799 | linklocal_addr); | |
800 | json_object_string_add(json_neighbor, "neighborState", | |
801 | ospf6_neighbor_state_str[on->state]); | |
802 | json_object_string_add(json_neighbor, "neighborStateDuration", | |
803 | duration); | |
804 | json_object_string_add(json_neighbor, "neighborDRouter", | |
805 | drouter); | |
806 | json_object_string_add(json_neighbor, "neighborBdRouter", | |
807 | bdrouter); | |
808 | snprintf(db_desc_str, sizeof(db_desc_str), "%s%s%s", | |
809 | (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT) | |
810 | ? "Initial " | |
811 | : ""), | |
812 | (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT) | |
813 | ? "More" | |
814 | : ""), | |
815 | (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MSBIT) | |
816 | ? "Master" | |
817 | : "Slave")); | |
818 | json_object_string_add(json_neighbor, "dbDescStatus", | |
819 | db_desc_str); | |
820 | ||
821 | json_object_int_add(json_neighbor, "dbDescSeqNumber", | |
822 | (unsigned long)ntohl(on->dbdesc_seqnum)); | |
823 | ||
824 | json_array = json_object_new_array(); | |
825 | json_object_int_add(json_neighbor, "summaryListCount", | |
826 | on->summary_list->count); | |
827 | for (ALL_LSDB(on->summary_list, lsa, lsanext)) | |
828 | json_object_array_add( | |
829 | json_array, json_object_new_string(lsa->name)); | |
830 | json_object_object_add(json_neighbor, "summaryListLsa", | |
831 | json_array); | |
832 | ||
833 | json_array = json_object_new_array(); | |
834 | json_object_int_add(json_neighbor, "requestListCount", | |
835 | on->request_list->count); | |
836 | for (ALL_LSDB(on->request_list, lsa, lsanext)) | |
837 | json_object_array_add( | |
838 | json_array, json_object_new_string(lsa->name)); | |
839 | json_object_object_add(json_neighbor, "requestListLsa", | |
840 | json_array); | |
841 | ||
842 | json_array = json_object_new_array(); | |
843 | json_object_int_add(json_neighbor, "reTransListCount", | |
844 | on->retrans_list->count); | |
845 | for (ALL_LSDB(on->retrans_list, lsa, lsanext)) | |
846 | json_object_array_add( | |
847 | json_array, json_object_new_string(lsa->name)); | |
848 | json_object_object_add(json_neighbor, "reTransListLsa", | |
849 | json_array); | |
850 | ||
851 | ||
852 | timerclear(&res); | |
853 | if (on->thread_send_dbdesc) | |
854 | timersub(&on->thread_send_dbdesc->u.sands, &now, &res); | |
855 | timerstring(&res, duration, sizeof(duration)); | |
856 | json_object_int_add(json_neighbor, "pendingLsaDbDescCount", | |
857 | on->dbdesc_list->count); | |
858 | json_object_string_add(json_neighbor, "pendingLsaDbDescTime", | |
859 | duration); | |
860 | json_object_string_add(json_neighbor, "dbDescSendThread", | |
861 | (on->thread_send_dbdesc ? "on" : "off")); | |
862 | json_array = json_object_new_array(); | |
863 | for (ALL_LSDB(on->dbdesc_list, lsa, lsanext)) | |
864 | json_object_array_add( | |
865 | json_array, json_object_new_string(lsa->name)); | |
866 | json_object_object_add(json_neighbor, "pendingLsaDbDesc", | |
867 | json_array); | |
868 | ||
869 | timerclear(&res); | |
870 | if (on->thread_send_lsreq) | |
871 | timersub(&on->thread_send_lsreq->u.sands, &now, &res); | |
872 | timerstring(&res, duration, sizeof(duration)); | |
873 | json_object_int_add(json_neighbor, "pendingLsaLsReqCount", | |
874 | on->request_list->count); | |
875 | json_object_string_add(json_neighbor, "pendingLsaLsReqTime", | |
876 | duration); | |
877 | json_object_string_add(json_neighbor, "lsReqSendThread", | |
878 | (on->thread_send_lsreq ? "on" : "off")); | |
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", | |
884 | json_array); | |
885 | ||
886 | ||
887 | timerclear(&res); | |
888 | if (on->thread_send_lsupdate) | |
889 | timersub(&on->thread_send_lsupdate->u.sands, &now, | |
890 | &res); | |
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", | |
895 | duration); | |
896 | json_object_string_add( | |
897 | json_neighbor, "lsUpdateSendThread", | |
898 | (on->thread_send_lsupdate ? "on" : "off")); | |
899 | json_array = json_object_new_array(); | |
900 | for (ALL_LSDB(on->lsupdate_list, lsa, lsanext)) | |
901 | json_object_array_add( | |
902 | json_array, json_object_new_string(lsa->name)); | |
903 | json_object_object_add(json_neighbor, "pendingLsaLsUpdate", | |
904 | json_array); | |
905 | ||
906 | timerclear(&res); | |
907 | if (on->thread_send_lsack) | |
908 | timersub(&on->thread_send_lsack->u.sands, &now, &res); | |
909 | timerstring(&res, duration, sizeof(duration)); | |
910 | json_object_int_add(json_neighbor, "pendingLsaLsAckCount", | |
911 | on->lsack_list->count); | |
912 | json_object_string_add(json_neighbor, "pendingLsaLsAckTime", | |
913 | duration); | |
914 | json_object_string_add(json_neighbor, "lsAckSendThread", | |
915 | (on->thread_send_lsack ? "on" : "off")); | |
916 | json_array = json_object_new_array(); | |
917 | for (ALL_LSDB(on->lsack_list, lsa, lsanext)) | |
918 | json_object_array_add( | |
919 | json_array, json_object_new_string(lsa->name)); | |
920 | json_object_object_add(json_neighbor, "pendingLsaLsAck", | |
921 | json_array); | |
922 | ||
d06cc416 | 923 | bfd_sess_show(vty, json_neighbor, on->bfd_session); |
6a5bb300 | 924 | |
6cb85350 AR |
925 | if (on->auth_present == true) { |
926 | json_object_string_add(json_neighbor, "authStatus", | |
927 | "enabled"); | |
928 | json_object_int_add( | |
929 | json_neighbor, "recvdHelloHigherSeqNo", | |
930 | on->seqnum_h[OSPF6_MESSAGE_TYPE_HELLO]); | |
931 | json_object_int_add( | |
932 | json_neighbor, "recvdHelloLowerSeqNo", | |
933 | on->seqnum_l[OSPF6_MESSAGE_TYPE_HELLO]); | |
934 | json_object_int_add( | |
935 | json_neighbor, "recvdDBDescHigherSeqNo", | |
936 | on->seqnum_h[OSPF6_MESSAGE_TYPE_DBDESC]); | |
937 | json_object_int_add( | |
938 | json_neighbor, "recvdDBDescLowerSeqNo", | |
939 | on->seqnum_l[OSPF6_MESSAGE_TYPE_DBDESC]); | |
940 | json_object_int_add( | |
941 | json_neighbor, "recvdLSReqHigherSeqNo", | |
942 | on->seqnum_h[OSPF6_MESSAGE_TYPE_LSREQ]); | |
943 | json_object_int_add( | |
944 | json_neighbor, "recvdLSReqLowerSeqNo", | |
945 | on->seqnum_l[OSPF6_MESSAGE_TYPE_LSREQ]); | |
946 | json_object_int_add( | |
947 | json_neighbor, "recvdLSUpdHigherSeqNo", | |
948 | on->seqnum_h[OSPF6_MESSAGE_TYPE_LSUPDATE]); | |
949 | json_object_int_add( | |
950 | json_neighbor, "recvdLSUpdLowerSeqNo", | |
951 | on->seqnum_l[OSPF6_MESSAGE_TYPE_LSUPDATE]); | |
952 | json_object_int_add( | |
953 | json_neighbor, "recvdLSAckHigherSeqNo", | |
954 | on->seqnum_h[OSPF6_MESSAGE_TYPE_LSACK]); | |
955 | json_object_int_add( | |
956 | json_neighbor, "recvdLSAckLowerSeqNo", | |
957 | on->seqnum_l[OSPF6_MESSAGE_TYPE_LSACK]); | |
958 | } else | |
959 | json_object_string_add(json_neighbor, "authStatus", | |
960 | "disabled"); | |
6a5bb300 | 961 | |
6cb85350 | 962 | json_object_object_add(json, on->name, json_neighbor); |
6a5bb300 | 963 | |
964 | } else { | |
965 | vty_out(vty, " Neighbor %s\n", on->name); | |
966 | vty_out(vty, " Area %s via interface %s (ifindex %d)\n", | |
967 | on->ospf6_if->area->name, on->ospf6_if->interface->name, | |
968 | on->ospf6_if->interface->ifindex); | |
969 | vty_out(vty, " His IfIndex: %d Link-local address: %s\n", | |
970 | on->ifindex, linklocal_addr); | |
971 | vty_out(vty, " State %s for a duration of %s\n", | |
972 | ospf6_neighbor_state_str[on->state], duration); | |
973 | vty_out(vty, " His choice of DR/BDR %s/%s, Priority %d\n", | |
974 | drouter, bdrouter, on->priority); | |
975 | vty_out(vty, " DbDesc status: %s%s%s SeqNum: %#lx\n", | |
976 | (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT) | |
977 | ? "Initial " | |
978 | : ""), | |
979 | (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT) | |
980 | ? "More " | |
981 | : ""), | |
982 | (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MSBIT) | |
983 | ? "Master" | |
984 | : "Slave"), | |
985 | (unsigned long)ntohl(on->dbdesc_seqnum)); | |
986 | ||
987 | vty_out(vty, " Summary-List: %d LSAs\n", | |
988 | on->summary_list->count); | |
989 | for (ALL_LSDB(on->summary_list, lsa, lsanext)) | |
990 | vty_out(vty, " %s\n", lsa->name); | |
991 | ||
992 | vty_out(vty, " Request-List: %d LSAs\n", | |
993 | on->request_list->count); | |
994 | for (ALL_LSDB(on->request_list, lsa, lsanext)) | |
995 | vty_out(vty, " %s\n", lsa->name); | |
996 | ||
997 | vty_out(vty, " Retrans-List: %d LSAs\n", | |
998 | on->retrans_list->count); | |
999 | for (ALL_LSDB(on->retrans_list, lsa, lsanext)) | |
1000 | vty_out(vty, " %s\n", lsa->name); | |
1001 | ||
1002 | timerclear(&res); | |
1003 | if (on->thread_send_dbdesc) | |
1004 | timersub(&on->thread_send_dbdesc->u.sands, &now, &res); | |
1005 | timerstring(&res, duration, sizeof(duration)); | |
1006 | vty_out(vty, | |
1007 | " %d Pending LSAs for DbDesc in Time %s [thread %s]\n", | |
1008 | on->dbdesc_list->count, duration, | |
1009 | (on->thread_send_dbdesc ? "on" : "off")); | |
1010 | for (ALL_LSDB(on->dbdesc_list, lsa, lsanext)) | |
1011 | vty_out(vty, " %s\n", lsa->name); | |
1012 | ||
1013 | timerclear(&res); | |
1014 | if (on->thread_send_lsreq) | |
1015 | timersub(&on->thread_send_lsreq->u.sands, &now, &res); | |
1016 | timerstring(&res, duration, sizeof(duration)); | |
1017 | vty_out(vty, | |
1018 | " %d Pending LSAs for LSReq in Time %s [thread %s]\n", | |
1019 | on->request_list->count, duration, | |
1020 | (on->thread_send_lsreq ? "on" : "off")); | |
1021 | for (ALL_LSDB(on->request_list, lsa, lsanext)) | |
1022 | vty_out(vty, " %s\n", lsa->name); | |
1023 | ||
1024 | timerclear(&res); | |
1025 | if (on->thread_send_lsupdate) | |
1026 | timersub(&on->thread_send_lsupdate->u.sands, &now, | |
1027 | &res); | |
1028 | timerstring(&res, duration, sizeof(duration)); | |
1029 | vty_out(vty, | |
1030 | " %d Pending LSAs for LSUpdate in Time %s [thread %s]\n", | |
1031 | on->lsupdate_list->count, duration, | |
1032 | (on->thread_send_lsupdate ? "on" : "off")); | |
1033 | for (ALL_LSDB(on->lsupdate_list, lsa, lsanext)) | |
1034 | vty_out(vty, " %s\n", lsa->name); | |
1035 | ||
1036 | timerclear(&res); | |
1037 | if (on->thread_send_lsack) | |
1038 | timersub(&on->thread_send_lsack->u.sands, &now, &res); | |
1039 | timerstring(&res, duration, sizeof(duration)); | |
1040 | vty_out(vty, | |
1041 | " %d Pending LSAs for LSAck in Time %s [thread %s]\n", | |
1042 | on->lsack_list->count, duration, | |
1043 | (on->thread_send_lsack ? "on" : "off")); | |
1044 | for (ALL_LSDB(on->lsack_list, lsa, lsanext)) | |
1045 | vty_out(vty, " %s\n", lsa->name); | |
1046 | ||
d06cc416 | 1047 | bfd_sess_show(vty, NULL, on->bfd_session); |
6cb85350 AR |
1048 | |
1049 | if (on->auth_present == true) { | |
1050 | vty_out(vty, " Authentication header present\n"); | |
1051 | vty_out(vty, | |
1052 | "\t\t\t hello DBDesc LSReq LSUpd LSAck\n"); | |
1053 | vty_out(vty, | |
1054 | " Higher sequence no 0x%-10X 0x%-10X 0x%-10X 0x%-10X 0x%-10X\n", | |
1055 | on->seqnum_h[OSPF6_MESSAGE_TYPE_HELLO], | |
1056 | on->seqnum_h[OSPF6_MESSAGE_TYPE_DBDESC], | |
1057 | on->seqnum_h[OSPF6_MESSAGE_TYPE_LSREQ], | |
1058 | on->seqnum_h[OSPF6_MESSAGE_TYPE_LSUPDATE], | |
1059 | on->seqnum_h[OSPF6_MESSAGE_TYPE_LSACK]); | |
1060 | vty_out(vty, | |
1061 | " Lower sequence no 0x%-10X 0x%-10X 0x%-10X 0x%-10X 0x%-10X\n", | |
1062 | on->seqnum_l[OSPF6_MESSAGE_TYPE_HELLO], | |
1063 | on->seqnum_l[OSPF6_MESSAGE_TYPE_DBDESC], | |
1064 | on->seqnum_l[OSPF6_MESSAGE_TYPE_LSREQ], | |
1065 | on->seqnum_l[OSPF6_MESSAGE_TYPE_LSUPDATE], | |
1066 | on->seqnum_l[OSPF6_MESSAGE_TYPE_LSACK]); | |
1067 | } else | |
1068 | vty_out(vty, " Authentication header not present\n"); | |
6a5bb300 | 1069 | } |
718e3744 | 1070 | } |
1071 | ||
ee3e6d7f IR |
1072 | static void ospf6_neighbor_show_detail_common(struct vty *vty, |
1073 | struct ospf6 *ospf6, bool uj, | |
1074 | bool detail, bool drchoice) | |
718e3744 | 1075 | { |
d62a17ae | 1076 | struct ospf6_neighbor *on; |
1077 | struct ospf6_interface *oi; | |
1078 | struct ospf6_area *oa; | |
1079 | struct listnode *i, *j, *k; | |
6a5bb300 | 1080 | json_object *json = NULL; |
1081 | json_object *json_array = NULL; | |
6a5bb300 | 1082 | void (*showfunc)(struct vty *, struct ospf6_neighbor *, |
1083 | json_object *json, bool use_json); | |
d62a17ae | 1084 | |
ee3e6d7f IR |
1085 | if (detail) |
1086 | showfunc = ospf6_neighbor_show_detail; | |
1087 | else if (drchoice) | |
1088 | showfunc = ospf6_neighbor_show_drchoice; | |
1089 | else | |
1090 | showfunc = ospf6_neighbor_show; | |
d62a17ae | 1091 | |
6a5bb300 | 1092 | if (uj) { |
1093 | json = json_object_new_object(); | |
1094 | json_array = json_object_new_array(); | |
1095 | } else { | |
1096 | if (showfunc == ospf6_neighbor_show) | |
1097 | vty_out(vty, "%-15s %3s %11s %8s/%-12s %11s %s[%s]\n", | |
1098 | "Neighbor ID", "Pri", "DeadTime", "State", | |
1099 | "IfState", "Duration", "I/F", "State"); | |
1100 | else if (showfunc == ospf6_neighbor_show_drchoice) | |
1101 | vty_out(vty, "%-15s %8s/%-11s %-15s %-15s %s[%s]\n", | |
1102 | "RouterID", "State", "Duration", "DR", "BDR", | |
1103 | "I/F", "State"); | |
1104 | } | |
d62a17ae | 1105 | |
1106 | for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) | |
1107 | for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi)) | |
6a5bb300 | 1108 | for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, k, on)) { |
1109 | if (showfunc == ospf6_neighbor_show_detail) | |
1110 | (*showfunc)(vty, on, json, uj); | |
1111 | else | |
1112 | (*showfunc)(vty, on, json_array, uj); | |
1113 | } | |
1114 | ||
1115 | if (uj) { | |
1116 | if (showfunc != ospf6_neighbor_show_detail) | |
1117 | json_object_object_add(json, "neighbors", json_array); | |
1118 | else | |
1119 | json_object_free(json_array); | |
5a6c232b | 1120 | vty_json(vty, json); |
6a5bb300 | 1121 | } |
718e3744 | 1122 | } |
1123 | ||
d48ef099 | 1124 | DEFUN(show_ipv6_ospf6_neighbor, show_ipv6_ospf6_neighbor_cmd, |
1125 | "show ipv6 ospf6 [vrf <NAME|all>] neighbor [<detail|drchoice>] [json]", | |
1126 | SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR | |
1127 | "All VRFs\n" | |
1128 | "Neighbor list\n" | |
1129 | "Display details\n" | |
1130 | "Display DR choices\n" JSON_STR) | |
1131 | { | |
d48ef099 | 1132 | struct ospf6 *ospf6; |
1133 | struct listnode *node; | |
1134 | const char *vrf_name = NULL; | |
1135 | bool all_vrf = false; | |
1136 | int idx_vrf = 0; | |
ee3e6d7f IR |
1137 | int idx_type = 4; |
1138 | bool uj = use_json(argc, argv); | |
1139 | bool detail = false; | |
1140 | bool drchoice = false; | |
d48ef099 | 1141 | |
d48ef099 | 1142 | OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); |
ee3e6d7f IR |
1143 | |
1144 | if (argv_find(argv, argc, "detail", &idx_type)) | |
1145 | detail = true; | |
1146 | else if (argv_find(argv, argc, "drchoice", &idx_type)) | |
1147 | drchoice = true; | |
d48ef099 | 1148 | |
1149 | for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) { | |
1150 | if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) { | |
ee3e6d7f IR |
1151 | ospf6_neighbor_show_detail_common(vty, ospf6, uj, |
1152 | detail, drchoice); | |
d48ef099 | 1153 | if (!all_vrf) |
1154 | break; | |
1155 | } | |
1156 | } | |
718e3744 | 1157 | |
d6b901ac | 1158 | OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6); |
1159 | ||
d48ef099 | 1160 | return CMD_SUCCESS; |
1161 | } | |
1162 | ||
1163 | static int ospf6_neighbor_show_common(struct vty *vty, int argc, | |
1164 | struct cmd_token **argv, | |
d6b901ac | 1165 | struct ospf6 *ospf6, int idx_ipv4, |
1166 | bool uj) | |
718e3744 | 1167 | { |
d62a17ae | 1168 | struct ospf6_neighbor *on; |
1169 | struct ospf6_interface *oi; | |
1170 | struct ospf6_area *oa; | |
1171 | struct listnode *i, *j, *k; | |
6a5bb300 | 1172 | void (*showfunc)(struct vty *, struct ospf6_neighbor *, |
1173 | json_object *json, bool use_json); | |
d7c0a89a | 1174 | uint32_t router_id; |
6a5bb300 | 1175 | json_object *json = NULL; |
d62a17ae | 1176 | |
d62a17ae | 1177 | showfunc = ospf6_neighbor_show_detail; |
6a5bb300 | 1178 | if (uj) |
1179 | json = json_object_new_object(); | |
d62a17ae | 1180 | |
1181 | if ((inet_pton(AF_INET, argv[idx_ipv4]->arg, &router_id)) != 1) { | |
1182 | vty_out(vty, "Router-ID is not parsable: %s\n", | |
1183 | argv[idx_ipv4]->arg); | |
1184 | return CMD_SUCCESS; | |
1185 | } | |
1186 | ||
1187 | for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) | |
1188 | for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi)) | |
786b76d0 YR |
1189 | for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, k, on)) { |
1190 | if (router_id == on->router_id) | |
1191 | (*showfunc)(vty, on, json, uj); | |
1192 | } | |
d62a17ae | 1193 | |
c48349e3 | 1194 | if (uj) |
5a6c232b | 1195 | vty_json(vty, json); |
d48ef099 | 1196 | |
1197 | return CMD_SUCCESS; | |
1198 | } | |
1199 | ||
1200 | DEFUN(show_ipv6_ospf6_neighbor_one, show_ipv6_ospf6_neighbor_one_cmd, | |
1201 | "show ipv6 ospf6 [vrf <NAME|all>] neighbor A.B.C.D [json]", | |
1202 | SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR | |
1203 | "All VRFs\n" | |
1204 | "Neighbor list\n" | |
1205 | "Specify Router-ID as IPv4 address notation\n" JSON_STR) | |
1206 | { | |
1207 | int idx_ipv4 = 4; | |
1208 | struct ospf6 *ospf6; | |
1209 | struct listnode *node; | |
1210 | const char *vrf_name = NULL; | |
1211 | bool all_vrf = false; | |
1212 | int idx_vrf = 0; | |
d6b901ac | 1213 | bool uj = use_json(argc, argv); |
d48ef099 | 1214 | |
d48ef099 | 1215 | OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); |
1216 | if (idx_vrf > 0) | |
1217 | idx_ipv4 += 2; | |
1218 | ||
1219 | for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) { | |
1220 | if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) { | |
1221 | ospf6_neighbor_show_common(vty, argc, argv, ospf6, | |
d6b901ac | 1222 | idx_ipv4, uj); |
d48ef099 | 1223 | |
1224 | if (!all_vrf) | |
1225 | break; | |
1226 | } | |
1227 | } | |
1228 | ||
d6b901ac | 1229 | OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6); |
1230 | ||
d62a17ae | 1231 | return CMD_SUCCESS; |
718e3744 | 1232 | } |
1233 | ||
d62a17ae | 1234 | void ospf6_neighbor_init(void) |
718e3744 | 1235 | { |
d62a17ae | 1236 | install_element(VIEW_NODE, &show_ipv6_ospf6_neighbor_cmd); |
1237 | install_element(VIEW_NODE, &show_ipv6_ospf6_neighbor_one_cmd); | |
508e53e2 | 1238 | } |
1239 | ||
1240 | DEFUN (debug_ospf6_neighbor, | |
1241 | debug_ospf6_neighbor_cmd, | |
6de69f83 | 1242 | "debug ospf6 neighbor [<state|event>]", |
508e53e2 | 1243 | DEBUG_STR |
1244 | OSPF6_STR | |
1245 | "Debug OSPFv3 Neighbor\n" | |
1d68dbfe DW |
1246 | "Debug OSPFv3 Neighbor State Change\n" |
1247 | "Debug OSPFv3 Neighbor Event\n") | |
508e53e2 | 1248 | { |
d62a17ae | 1249 | int idx_type = 3; |
1250 | unsigned char level = 0; | |
1251 | ||
1252 | if (argc == 4) { | |
1253 | if (!strncmp(argv[idx_type]->arg, "s", 1)) | |
1254 | level = OSPF6_DEBUG_NEIGHBOR_STATE; | |
1255 | else if (!strncmp(argv[idx_type]->arg, "e", 1)) | |
1256 | level = OSPF6_DEBUG_NEIGHBOR_EVENT; | |
1257 | } else | |
1258 | level = OSPF6_DEBUG_NEIGHBOR_STATE | OSPF6_DEBUG_NEIGHBOR_EVENT; | |
1259 | ||
1260 | OSPF6_DEBUG_NEIGHBOR_ON(level); | |
1261 | return CMD_SUCCESS; | |
718e3744 | 1262 | } |
1263 | ||
508e53e2 | 1264 | |
1265 | DEFUN (no_debug_ospf6_neighbor, | |
1266 | no_debug_ospf6_neighbor_cmd, | |
6de69f83 | 1267 | "no debug ospf6 neighbor [<state|event>]", |
508e53e2 | 1268 | NO_STR |
1269 | DEBUG_STR | |
1270 | OSPF6_STR | |
1271 | "Debug OSPFv3 Neighbor\n" | |
1d68dbfe DW |
1272 | "Debug OSPFv3 Neighbor State Change\n" |
1273 | "Debug OSPFv3 Neighbor Event\n") | |
508e53e2 | 1274 | { |
d62a17ae | 1275 | int idx_type = 4; |
1276 | unsigned char level = 0; | |
1277 | ||
1278 | if (argc == 5) { | |
1279 | if (!strncmp(argv[idx_type]->arg, "s", 1)) | |
1280 | level = OSPF6_DEBUG_NEIGHBOR_STATE; | |
1281 | if (!strncmp(argv[idx_type]->arg, "e", 1)) | |
1282 | level = OSPF6_DEBUG_NEIGHBOR_EVENT; | |
1283 | } else | |
1284 | level = OSPF6_DEBUG_NEIGHBOR_STATE | OSPF6_DEBUG_NEIGHBOR_EVENT; | |
1285 | ||
1286 | OSPF6_DEBUG_NEIGHBOR_OFF(level); | |
1287 | return CMD_SUCCESS; | |
508e53e2 | 1288 | } |
1289 | ||
508e53e2 | 1290 | |
4dfd8aff DW |
1291 | DEFUN (no_debug_ospf6, |
1292 | no_debug_ospf6_cmd, | |
1293 | "no debug ospf6", | |
1294 | NO_STR | |
1295 | DEBUG_STR | |
1296 | OSPF6_STR) | |
1297 | { | |
d7c0a89a | 1298 | unsigned int i; |
d62a17ae | 1299 | |
1300 | OSPF6_DEBUG_ABR_OFF(); | |
1301 | OSPF6_DEBUG_ASBR_OFF(); | |
1302 | OSPF6_DEBUG_BROUTER_OFF(); | |
1303 | OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_OFF(); | |
1304 | OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_OFF(); | |
1305 | OSPF6_DEBUG_FLOODING_OFF(); | |
1306 | OSPF6_DEBUG_INTERFACE_OFF(); | |
1307 | ||
067967b8 | 1308 | ospf6_lsa_debug_set_all(false); |
d62a17ae | 1309 | |
1310 | for (i = 0; i < 6; i++) | |
1311 | OSPF6_DEBUG_MESSAGE_OFF(i, | |
1312 | OSPF6_DEBUG_NEIGHBOR_STATE | |
1313 | | OSPF6_DEBUG_NEIGHBOR_EVENT); | |
1314 | ||
1315 | OSPF6_DEBUG_NEIGHBOR_OFF(OSPF6_DEBUG_NEIGHBOR_STATE | |
1316 | | OSPF6_DEBUG_NEIGHBOR_EVENT); | |
1317 | OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_TABLE); | |
1318 | OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_INTRA); | |
1319 | OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_INTER); | |
1320 | OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_MEMORY); | |
1321 | OSPF6_DEBUG_SPF_OFF(OSPF6_DEBUG_SPF_PROCESS); | |
1322 | OSPF6_DEBUG_SPF_OFF(OSPF6_DEBUG_SPF_TIME); | |
1323 | OSPF6_DEBUG_SPF_OFF(OSPF6_DEBUG_SPF_DATABASE); | |
1324 | OSPF6_DEBUG_ZEBRA_OFF(OSPF6_DEBUG_ZEBRA_SEND | OSPF6_DEBUG_ZEBRA_RECV); | |
1325 | ||
1326 | return CMD_SUCCESS; | |
4dfd8aff DW |
1327 | } |
1328 | ||
d62a17ae | 1329 | int config_write_ospf6_debug_neighbor(struct vty *vty) |
508e53e2 | 1330 | { |
d62a17ae | 1331 | if (IS_OSPF6_DEBUG_NEIGHBOR(STATE) && IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) |
1332 | vty_out(vty, "debug ospf6 neighbor\n"); | |
1333 | else if (IS_OSPF6_DEBUG_NEIGHBOR(STATE)) | |
1334 | vty_out(vty, "debug ospf6 neighbor state\n"); | |
1335 | else if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) | |
1336 | vty_out(vty, "debug ospf6 neighbor event\n"); | |
1337 | return 0; | |
508e53e2 | 1338 | } |
1339 | ||
d62a17ae | 1340 | void install_element_ospf6_debug_neighbor(void) |
508e53e2 | 1341 | { |
d62a17ae | 1342 | install_element(ENABLE_NODE, &debug_ospf6_neighbor_cmd); |
1343 | install_element(ENABLE_NODE, &no_debug_ospf6_neighbor_cmd); | |
1344 | install_element(ENABLE_NODE, &no_debug_ospf6_cmd); | |
1345 | install_element(CONFIG_NODE, &debug_ospf6_neighbor_cmd); | |
1346 | install_element(CONFIG_NODE, &no_debug_ospf6_neighbor_cmd); | |
1347 | install_element(CONFIG_NODE, &no_debug_ospf6_cmd); | |
508e53e2 | 1348 | } |