]> git.proxmox.com Git - mirror_frr.git/blob - eigrpd/eigrp_dump.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / eigrpd / eigrp_dump.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * EIGRP Dump Functions and Debugging.
4 * Copyright (C) 2013-2014
5 * Authors:
6 * Donnie Savage
7 * Jan Janovic
8 * Matej Perina
9 * Peter Orsag
10 * Peter Paluch
11 */
12
13 #include <zebra.h>
14
15 #include "linklist.h"
16 #include "thread.h"
17 #include "prefix.h"
18 #include "command.h"
19 #include "stream.h"
20 #include "log.h"
21 #include "sockopt.h"
22 #include "table.h"
23 #include "keychain.h"
24
25 #include "eigrpd/eigrp_structs.h"
26 #include "eigrpd/eigrpd.h"
27 #include "eigrpd/eigrp_interface.h"
28 #include "eigrpd/eigrp_neighbor.h"
29 #include "eigrpd/eigrp_packet.h"
30 #include "eigrpd/eigrp_zebra.h"
31 #include "eigrpd/eigrp_vty.h"
32 #include "eigrpd/eigrp_network.h"
33 #include "eigrpd/eigrp_dump.h"
34 #include "eigrpd/eigrp_topology.h"
35
36 /* Enable debug option variables -- valid only session. */
37 unsigned long term_debug_eigrp = 0;
38 unsigned long term_debug_eigrp_nei = 0;
39 unsigned long term_debug_eigrp_packet[11] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
40 unsigned long term_debug_eigrp_zebra = 6;
41 unsigned long term_debug_eigrp_transmit = 0;
42
43 /* Configuration debug option variables. */
44 unsigned long conf_debug_eigrp = 0;
45 unsigned long conf_debug_eigrp_nei = 0;
46 unsigned long conf_debug_eigrp_packet[11] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
47 unsigned long conf_debug_eigrp_zebra = 0;
48 unsigned long conf_debug_eigrp_transmit = 0;
49
50
51 static int config_write_debug(struct vty *vty)
52 {
53 int write = 0;
54 int i;
55
56 const char *type_str[] = {"update", "request", "query", "reply",
57 "hello", "", "probe", "ack",
58 "", "SIA query", "SIA reply", "stub",
59 "all"};
60 const char *detail_str[] = {
61 "", " send", " recv", "",
62 " detail", " send detail", " recv detail", " detail"};
63
64
65 /* debug eigrp event. */
66
67 /* debug eigrp packet */
68 for (i = 0; i < 10; i++) {
69 if (conf_debug_eigrp_packet[i] == 0
70 && term_debug_eigrp_packet[i] == 0)
71 continue;
72
73 vty_out(vty, "debug eigrp packet %s%s\n", type_str[i],
74 detail_str[conf_debug_eigrp_packet[i]]);
75 write = 1;
76 }
77
78 return write;
79 }
80
81 static int eigrp_neighbor_packet_queue_sum(struct eigrp_interface *ei)
82 {
83 struct eigrp_neighbor *nbr;
84 struct listnode *node, *nnode;
85 int sum;
86 sum = 0;
87
88 for (ALL_LIST_ELEMENTS(ei->nbrs, node, nnode, nbr)) {
89 sum += nbr->retrans_queue->count;
90 }
91
92 return sum;
93 }
94
95 /*
96 * Expects header to be in host order
97 */
98 void eigrp_ip_header_dump(struct ip *iph)
99 {
100 /* IP Header dump. */
101 zlog_debug("ip_v %u", iph->ip_v);
102 zlog_debug("ip_hl %u", iph->ip_hl);
103 zlog_debug("ip_tos %u", iph->ip_tos);
104 zlog_debug("ip_len %u", iph->ip_len);
105 zlog_debug("ip_id %u", (uint32_t)iph->ip_id);
106 zlog_debug("ip_off %u", (uint32_t)iph->ip_off);
107 zlog_debug("ip_ttl %u", iph->ip_ttl);
108 zlog_debug("ip_p %u", iph->ip_p);
109 zlog_debug("ip_sum 0x%x", (uint32_t)iph->ip_sum);
110 zlog_debug("ip_src %pI4", &iph->ip_src);
111 zlog_debug("ip_dst %pI4", &iph->ip_dst);
112 }
113
114 /*
115 * Expects header to be in host order
116 */
117 void eigrp_header_dump(struct eigrp_header *eigrph)
118 {
119 /* EIGRP Header dump. */
120 zlog_debug("eigrp_version %u", eigrph->version);
121 zlog_debug("eigrp_opcode %u", eigrph->opcode);
122 zlog_debug("eigrp_checksum 0x%x", ntohs(eigrph->checksum));
123 zlog_debug("eigrp_flags 0x%x", ntohl(eigrph->flags));
124 zlog_debug("eigrp_sequence %u", ntohl(eigrph->sequence));
125 zlog_debug("eigrp_ack %u", ntohl(eigrph->ack));
126 zlog_debug("eigrp_vrid %u", ntohs(eigrph->vrid));
127 zlog_debug("eigrp_AS %u", ntohs(eigrph->ASNumber));
128 }
129
130 const char *eigrp_if_name_string(struct eigrp_interface *ei)
131 {
132 if (!ei)
133 return "inactive";
134
135 return ei->ifp->name;
136 }
137
138 void show_ip_eigrp_interface_header(struct vty *vty, struct eigrp *eigrp)
139 {
140
141 vty_out(vty,
142 "\nEIGRP interfaces for AS(%d)\n\n%-16s %-10s %-10s %-6s %-12s %-7s %-14s %-12s %-8s %-8s %-8s\n %-44s %-12s %-7s %-14s %-12s %-8s\n",
143 eigrp->AS, "Interface", "Bandwidth", "Delay", "Peers",
144 "Xmit Queue", "Mean", "Pacing Time", "Multicast", "Pending",
145 "Hello", "Holdtime", "", "Un/Reliable", "SRTT", "Un/Reliable",
146 "Flow Timer", "Routes");
147 }
148
149 void show_ip_eigrp_interface_sub(struct vty *vty, struct eigrp *eigrp,
150 struct eigrp_interface *ei)
151 {
152 vty_out(vty, "%-16s ", IF_NAME(ei));
153 vty_out(vty, "%-11u", ei->params.bandwidth);
154 vty_out(vty, "%-11u", ei->params.delay);
155 vty_out(vty, "%-7u", ei->nbrs->count);
156 vty_out(vty, "%u %c %-10u", 0, '/',
157 eigrp_neighbor_packet_queue_sum(ei));
158 vty_out(vty, "%-7u %-14u %-12u %-8u", 0, 0, 0, 0);
159 vty_out(vty, "%-8u %-8u \n", ei->params.v_hello, ei->params.v_wait);
160 }
161
162 void show_ip_eigrp_interface_detail(struct vty *vty, struct eigrp *eigrp,
163 struct eigrp_interface *ei)
164 {
165 vty_out(vty, "%-2s %s %d %-3s \n", "", "Hello interval is ", 0, " sec");
166 vty_out(vty, "%-2s %s %s \n", "", "Next xmit serial", "<none>");
167 vty_out(vty, "%-2s %s %d %s %d %s %d %s %d \n", "",
168 "Un/reliable mcasts: ", 0, "/", 0, "Un/reliable ucasts: ", 0,
169 "/", 0);
170 vty_out(vty, "%-2s %s %d %s %d %s %d \n", "", "Mcast exceptions: ", 0,
171 " CR packets: ", 0, " ACKs suppressed: ", 0);
172 vty_out(vty, "%-2s %s %d %s %d \n", "", "Retransmissions sent: ", 0,
173 "Out-of-sequence rcvd: ", 0);
174 vty_out(vty, "%-2s %s %s %s \n", "", "Authentication mode is ", "not",
175 "set");
176 vty_out(vty, "%-2s %s \n", "", "Use multicast");
177 }
178
179 void show_ip_eigrp_neighbor_header(struct vty *vty, struct eigrp *eigrp)
180 {
181 vty_out(vty,
182 "\nEIGRP neighbors for AS(%d)\n\n%-3s %-17s %-20s %-6s %-8s %-6s %-5s %-5s %-5s\n %-41s %-6s %-8s %-6s %-4s %-6s %-5s \n",
183 eigrp->AS, "H", "Address", "Interface", "Hold", "Uptime",
184 "SRTT", "RTO", "Q", "Seq", "", "(sec)", "", "(ms)", "", "Cnt",
185 "Num");
186 }
187
188 void show_ip_eigrp_neighbor_sub(struct vty *vty, struct eigrp_neighbor *nbr,
189 int detail)
190 {
191
192 vty_out(vty, "%-3u %-17pI4 %-21s", 0, &nbr->src, IF_NAME(nbr->ei));
193 if (nbr->t_holddown)
194 vty_out(vty, "%-7lu",
195 thread_timer_remain_second(nbr->t_holddown));
196 else
197 vty_out(vty, "- ");
198 vty_out(vty, "%-8u %-6u %-5u", 0, 0, EIGRP_PACKET_RETRANS_TIME);
199 vty_out(vty, "%-7lu", nbr->retrans_queue->count);
200 vty_out(vty, "%u\n", nbr->recv_sequence_number);
201
202
203 if (detail) {
204 vty_out(vty, " Version %u.%u/%u.%u", nbr->os_rel_major,
205 nbr->os_rel_minor, nbr->tlv_rel_major,
206 nbr->tlv_rel_minor);
207 vty_out(vty, ", Retrans: %lu, Retries: %lu",
208 nbr->retrans_queue->count, 0UL);
209 vty_out(vty, ", %s\n", eigrp_nbr_state_str(nbr));
210 }
211 }
212
213 /*
214 * Print standard header for show EIGRP topology output
215 */
216 void show_ip_eigrp_topology_header(struct vty *vty, struct eigrp *eigrp)
217 {
218 vty_out(vty, "\nEIGRP Topology Table for AS(%d)/ID(%pI4)\n\n",
219 eigrp->AS, &eigrp->router_id);
220 vty_out(vty,
221 "Codes: P - Passive, A - Active, U - Update, Q - Query, R - Reply\n r - reply Status, s - sia Status\n\n");
222 }
223
224 void show_ip_eigrp_prefix_descriptor(struct vty *vty,
225 struct eigrp_prefix_descriptor *tn)
226 {
227 struct list *successors = eigrp_topology_get_successor(tn);
228
229 vty_out(vty, "%-3c", (tn->state > 0) ? 'A' : 'P');
230
231 vty_out(vty, "%pFX, ", tn->destination);
232 vty_out(vty, "%u successors, ", (successors) ? successors->count : 0);
233 vty_out(vty, "FD is %u, serno: %" PRIu64 " \n", tn->fdistance,
234 tn->serno);
235
236 if (successors)
237 list_delete(&successors);
238 }
239
240 void show_ip_eigrp_route_descriptor(struct vty *vty, struct eigrp *eigrp,
241 struct eigrp_route_descriptor *te,
242 bool *first)
243 {
244 if (te->reported_distance == EIGRP_MAX_METRIC)
245 return;
246
247 if (*first) {
248 show_ip_eigrp_prefix_descriptor(vty, te->prefix);
249 *first = false;
250 }
251
252 if (te->adv_router == eigrp->neighbor_self)
253 vty_out(vty, "%-7s%s, %s\n", " ", "via Connected",
254 IF_NAME(te->ei));
255 else {
256 vty_out(vty, "%-7s%s%pI4 (%u/%u), %s\n", " ", "via ",
257 &te->adv_router->src, te->distance,
258 te->reported_distance, IF_NAME(te->ei));
259 }
260 }
261
262
263 DEFUN_NOSH (show_debugging_eigrp,
264 show_debugging_eigrp_cmd,
265 "show debugging [eigrp]",
266 SHOW_STR
267 DEBUG_STR
268 EIGRP_STR)
269 {
270 int i;
271
272 vty_out(vty, "EIGRP debugging status:\n");
273
274 /* Show debug status for events. */
275 if (IS_DEBUG_EIGRP(event, EVENT))
276 vty_out(vty, " EIGRP event debugging is on\n");
277
278 /* Show debug status for EIGRP Packets. */
279 for (i = 0; i < 11; i++) {
280 if (i == 8)
281 continue;
282
283 if (IS_DEBUG_EIGRP_PACKET(i, SEND)
284 && IS_DEBUG_EIGRP_PACKET(i, RECV)) {
285 vty_out(vty, " EIGRP packet %s%s debugging is on\n",
286 lookup_msg(eigrp_packet_type_str, i + 1, NULL),
287 IS_DEBUG_EIGRP_PACKET(i, PACKET_DETAIL)
288 ? " detail"
289 : "");
290 } else {
291 if (IS_DEBUG_EIGRP_PACKET(i, SEND))
292 vty_out(vty,
293 " EIGRP packet %s send%s debugging is on\n",
294 lookup_msg(eigrp_packet_type_str, i + 1,
295 NULL),
296 IS_DEBUG_EIGRP_PACKET(i, PACKET_DETAIL)
297 ? " detail"
298 : "");
299 if (IS_DEBUG_EIGRP_PACKET(i, RECV))
300 vty_out(vty,
301 " EIGRP packet %s receive%s debugging is on\n",
302 lookup_msg(eigrp_packet_type_str, i + 1,
303 NULL),
304 IS_DEBUG_EIGRP_PACKET(i, PACKET_DETAIL)
305 ? " detail"
306 : "");
307 }
308 }
309
310 cmd_show_lib_debugs(vty);
311 return CMD_SUCCESS;
312 }
313
314
315 /*
316 [no] debug eigrp packet (hello|dd|ls-request|ls-update|ls-ack|all)
317 [send|recv [detail]]
318 */
319
320 DEFUN (debug_eigrp_transmit,
321 debug_eigrp_transmit_cmd,
322 "debug eigrp transmit <send|recv|all> [detail]",
323 DEBUG_STR
324 EIGRP_STR
325 "EIGRP transmission events\n"
326 "packet sent\n"
327 "packet received\n"
328 "all packets\n"
329 "Detailed Information\n")
330 {
331 int flag = 0;
332 int idx = 2;
333
334 /* send or recv. */
335 if (argv_find(argv, argc, "send", &idx))
336 flag = EIGRP_DEBUG_SEND;
337 else if (argv_find(argv, argc, "recv", &idx))
338 flag = EIGRP_DEBUG_RECV;
339 else if (argv_find(argv, argc, "all", &idx))
340 flag = EIGRP_DEBUG_SEND_RECV;
341
342 /* detail option */
343 if (argv_find(argv, argc, "detail", &idx))
344 flag = EIGRP_DEBUG_PACKET_DETAIL;
345
346 if (vty->node == CONFIG_NODE)
347 DEBUG_TRANSMIT_ON(0, flag);
348 else
349 TERM_DEBUG_TRANSMIT_ON(0, flag);
350
351 return CMD_SUCCESS;
352 }
353
354 DEFUN (no_debug_eigrp_transmit,
355 no_debug_eigrp_transmit_cmd,
356 "no debug eigrp transmit <send|recv|all> [detail]",
357 NO_STR
358 UNDEBUG_STR
359 EIGRP_STR
360 "EIGRP transmission events\n"
361 "packet sent\n"
362 "packet received\n"
363 "all packets\n"
364 "Detailed Information\n")
365 {
366 int flag = 0;
367 int idx = 3;
368
369 /* send or recv. */
370 if (argv_find(argv, argc, "send", &idx))
371 flag = EIGRP_DEBUG_SEND;
372 else if (argv_find(argv, argc, "recv", &idx))
373 flag = EIGRP_DEBUG_RECV;
374 else if (argv_find(argv, argc, "all", &idx))
375 flag = EIGRP_DEBUG_SEND_RECV;
376
377 /* detail option */
378 if (argv_find(argv, argc, "detail", &idx))
379 flag = EIGRP_DEBUG_PACKET_DETAIL;
380
381 if (vty->node == CONFIG_NODE)
382 DEBUG_TRANSMIT_OFF(0, flag);
383 else
384 TERM_DEBUG_TRANSMIT_OFF(0, flag);
385
386 return CMD_SUCCESS;
387 }
388
389 DEFUN (debug_eigrp_packets,
390 debug_eigrp_packets_all_cmd,
391 "debug eigrp packets <siaquery|siareply|ack|hello|probe|query|reply|request|retry|stub|terse|update|all> [send|receive] [detail]",
392 DEBUG_STR
393 EIGRP_STR
394 "EIGRP packets\n"
395 "EIGRP SIA-Query packets\n"
396 "EIGRP SIA-Reply packets\n"
397 "EIGRP ack packets\n"
398 "EIGRP hello packets\n"
399 "EIGRP probe packets\n"
400 "EIGRP query packets\n"
401 "EIGRP reply packets\n"
402 "EIGRP request packets\n"
403 "EIGRP retransmissions\n"
404 "EIGRP stub packets\n"
405 "Display all EIGRP packets except Hellos\n"
406 "EIGRP update packets\n"
407 "Display all EIGRP packets\n"
408 "Send Packets\n"
409 "Receive Packets\n"
410 "Detail Information\n")
411 {
412 int type = 0;
413 int flag = 0;
414 int i;
415 int idx = 0;
416
417 /* Check packet type. */
418 if (argv_find(argv, argc, "hello", &idx))
419 type = EIGRP_DEBUG_HELLO;
420 if (argv_find(argv, argc, "update", &idx))
421 type = EIGRP_DEBUG_UPDATE;
422 if (argv_find(argv, argc, "query", &idx))
423 type = EIGRP_DEBUG_QUERY;
424 if (argv_find(argv, argc, "ack", &idx))
425 type = EIGRP_DEBUG_ACK;
426 if (argv_find(argv, argc, "probe", &idx))
427 type = EIGRP_DEBUG_PROBE;
428 if (argv_find(argv, argc, "stub", &idx))
429 type = EIGRP_DEBUG_STUB;
430 if (argv_find(argv, argc, "reply", &idx))
431 type = EIGRP_DEBUG_REPLY;
432 if (argv_find(argv, argc, "request", &idx))
433 type = EIGRP_DEBUG_REQUEST;
434 if (argv_find(argv, argc, "siaquery", &idx))
435 type = EIGRP_DEBUG_SIAQUERY;
436 if (argv_find(argv, argc, "siareply", &idx))
437 type = EIGRP_DEBUG_SIAREPLY;
438 if (argv_find(argv, argc, "all", &idx))
439 type = EIGRP_DEBUG_PACKETS_ALL;
440
441
442 /* All packet types, both send and recv. */
443 flag = EIGRP_DEBUG_SEND_RECV;
444
445 /* send or recv. */
446 if (argv_find(argv, argc, "s", &idx))
447 flag = EIGRP_DEBUG_SEND;
448 else if (argv_find(argv, argc, "r", &idx))
449 flag = EIGRP_DEBUG_RECV;
450
451 /* detail. */
452 if (argv_find(argv, argc, "detail", &idx))
453 flag |= EIGRP_DEBUG_PACKET_DETAIL;
454
455 for (i = 0; i < 11; i++)
456 if (type & (0x01 << i)) {
457 if (vty->node == CONFIG_NODE)
458 DEBUG_PACKET_ON(i, flag);
459 else
460 TERM_DEBUG_PACKET_ON(i, flag);
461 }
462
463 return CMD_SUCCESS;
464 }
465
466 DEFUN (no_debug_eigrp_packets,
467 no_debug_eigrp_packets_all_cmd,
468 "no debug eigrp packets <siaquery|siareply|ack|hello|probe|query|reply|request|retry|stub|terse|update|all> [send|receive] [detail]",
469 NO_STR
470 UNDEBUG_STR
471 EIGRP_STR
472 "EIGRP packets\n"
473 "EIGRP SIA-Query packets\n"
474 "EIGRP SIA-Reply packets\n"
475 "EIGRP ack packets\n"
476 "EIGRP hello packets\n"
477 "EIGRP probe packets\n"
478 "EIGRP query packets\n"
479 "EIGRP reply packets\n"
480 "EIGRP request packets\n"
481 "EIGRP retransmissions\n"
482 "EIGRP stub packets\n"
483 "Display all EIGRP packets except Hellos\n"
484 "EIGRP update packets\n"
485 "Display all EIGRP packets\n"
486 "Send Packets\n"
487 "Receive Packets\n"
488 "Detailed Information\n")
489 {
490 int type = 0;
491 int flag = 0;
492 int i;
493 int idx = 0;
494
495 /* Check packet type. */
496 if (argv_find(argv, argc, "hello", &idx))
497 type = EIGRP_DEBUG_HELLO;
498 if (argv_find(argv, argc, "update", &idx))
499 type = EIGRP_DEBUG_UPDATE;
500 if (argv_find(argv, argc, "query", &idx))
501 type = EIGRP_DEBUG_QUERY;
502 if (argv_find(argv, argc, "ack", &idx))
503 type = EIGRP_DEBUG_ACK;
504 if (argv_find(argv, argc, "probe", &idx))
505 type = EIGRP_DEBUG_PROBE;
506 if (argv_find(argv, argc, "stub", &idx))
507 type = EIGRP_DEBUG_STUB;
508 if (argv_find(argv, argc, "reply", &idx))
509 type = EIGRP_DEBUG_REPLY;
510 if (argv_find(argv, argc, "request", &idx))
511 type = EIGRP_DEBUG_REQUEST;
512 if (argv_find(argv, argc, "siaquery", &idx))
513 type = EIGRP_DEBUG_SIAQUERY;
514 if (argv_find(argv, argc, "siareply", &idx))
515 type = EIGRP_DEBUG_SIAREPLY;
516
517 /* Default, both send and recv. */
518 flag = EIGRP_DEBUG_SEND_RECV;
519
520 /* send or recv. */
521 if (argv_find(argv, argc, "send", &idx))
522 flag = EIGRP_DEBUG_SEND;
523 else if (argv_find(argv, argc, "reply", &idx))
524 flag = EIGRP_DEBUG_RECV;
525
526 /* detail. */
527 if (argv_find(argv, argc, "detail", &idx))
528 flag |= EIGRP_DEBUG_PACKET_DETAIL;
529
530 for (i = 0; i < 11; i++)
531 if (type & (0x01 << i)) {
532 if (vty->node == CONFIG_NODE)
533 DEBUG_PACKET_OFF(i, flag);
534 else
535 TERM_DEBUG_PACKET_OFF(i, flag);
536 }
537
538 return CMD_SUCCESS;
539 }
540
541 /* Debug node. */
542 static int config_write_debug(struct vty *vty);
543 static struct cmd_node eigrp_debug_node = {
544 .name = "debug",
545 .node = DEBUG_NODE,
546 .prompt = "",
547 .config_write = config_write_debug,
548 };
549
550 /* Initialize debug commands. */
551 void eigrp_debug_init(void)
552 {
553 install_node(&eigrp_debug_node);
554
555 install_element(ENABLE_NODE, &show_debugging_eigrp_cmd);
556 install_element(ENABLE_NODE, &debug_eigrp_packets_all_cmd);
557 install_element(ENABLE_NODE, &no_debug_eigrp_packets_all_cmd);
558 install_element(ENABLE_NODE, &debug_eigrp_transmit_cmd);
559 install_element(ENABLE_NODE, &no_debug_eigrp_transmit_cmd);
560
561 install_element(CONFIG_NODE, &show_debugging_eigrp_cmd);
562 install_element(CONFIG_NODE, &debug_eigrp_packets_all_cmd);
563 install_element(CONFIG_NODE, &no_debug_eigrp_packets_all_cmd);
564 install_element(CONFIG_NODE, &debug_eigrp_transmit_cmd);
565 install_element(CONFIG_NODE, &no_debug_eigrp_transmit_cmd);
566 }