1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * EIGRP Dump Functions and Debugging.
4 * Copyright (C) 2013-2014
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"
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;
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;
51 static int config_write_debug(struct vty
*vty
)
56 const char *type_str
[] = {"update", "request", "query", "reply",
57 "hello", "", "probe", "ack",
58 "", "SIA query", "SIA reply", "stub",
60 const char *detail_str
[] = {
61 "", " send", " recv", "",
62 " detail", " send detail", " recv detail", " detail"};
65 /* debug eigrp event. */
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)
73 vty_out(vty
, "debug eigrp packet %s%s\n", type_str
[i
],
74 detail_str
[conf_debug_eigrp_packet
[i
]]);
81 static int eigrp_neighbor_packet_queue_sum(struct eigrp_interface
*ei
)
83 struct eigrp_neighbor
*nbr
;
84 struct listnode
*node
, *nnode
;
88 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node
, nnode
, nbr
)) {
89 sum
+= nbr
->retrans_queue
->count
;
96 * Expects header to be in host order
98 void eigrp_ip_header_dump(struct ip
*iph
)
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
);
115 * Expects header to be in host order
117 void eigrp_header_dump(struct eigrp_header
*eigrph
)
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
));
130 const char *eigrp_if_name_string(struct eigrp_interface
*ei
)
135 return ei
->ifp
->name
;
138 void show_ip_eigrp_interface_header(struct vty
*vty
, struct eigrp
*eigrp
)
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");
149 void show_ip_eigrp_interface_sub(struct vty
*vty
, struct eigrp
*eigrp
,
150 struct eigrp_interface
*ei
)
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
);
162 void show_ip_eigrp_interface_detail(struct vty
*vty
, struct eigrp
*eigrp
,
163 struct eigrp_interface
*ei
)
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,
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",
176 vty_out(vty
, "%-2s %s \n", "", "Use multicast");
179 void show_ip_eigrp_neighbor_header(struct vty
*vty
, struct eigrp
*eigrp
)
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",
188 void show_ip_eigrp_neighbor_sub(struct vty
*vty
, struct eigrp_neighbor
*nbr
,
192 vty_out(vty
, "%-3u %-17pI4 %-21s", 0, &nbr
->src
, IF_NAME(nbr
->ei
));
194 vty_out(vty
, "%-7lu",
195 thread_timer_remain_second(nbr
->t_holddown
));
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
);
204 vty_out(vty
, " Version %u.%u/%u.%u", nbr
->os_rel_major
,
205 nbr
->os_rel_minor
, nbr
->tlv_rel_major
,
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
));
214 * Print standard header for show EIGRP topology output
216 void show_ip_eigrp_topology_header(struct vty
*vty
, struct eigrp
*eigrp
)
218 vty_out(vty
, "\nEIGRP Topology Table for AS(%d)/ID(%pI4)\n\n",
219 eigrp
->AS
, &eigrp
->router_id
);
221 "Codes: P - Passive, A - Active, U - Update, Q - Query, R - Reply\n r - reply Status, s - sia Status\n\n");
224 void show_ip_eigrp_prefix_descriptor(struct vty
*vty
,
225 struct eigrp_prefix_descriptor
*tn
)
227 struct list
*successors
= eigrp_topology_get_successor(tn
);
229 vty_out(vty
, "%-3c", (tn
->state
> 0) ? 'A' : 'P');
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
,
237 list_delete(&successors
);
240 void show_ip_eigrp_route_descriptor(struct vty
*vty
, struct eigrp
*eigrp
,
241 struct eigrp_route_descriptor
*te
,
244 if (te
->reported_distance
== EIGRP_MAX_METRIC
)
248 show_ip_eigrp_prefix_descriptor(vty
, te
->prefix
);
252 if (te
->adv_router
== eigrp
->neighbor_self
)
253 vty_out(vty
, "%-7s%s, %s\n", " ", "via Connected",
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
));
263 DEFUN_NOSH (show_debugging_eigrp
,
264 show_debugging_eigrp_cmd
,
265 "show debugging [eigrp]",
272 vty_out(vty
, "EIGRP debugging status:\n");
274 /* Show debug status for events. */
275 if (IS_DEBUG_EIGRP(event
, EVENT
))
276 vty_out(vty
, " EIGRP event debugging is on\n");
278 /* Show debug status for EIGRP Packets. */
279 for (i
= 0; i
< 11; i
++) {
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
)
291 if (IS_DEBUG_EIGRP_PACKET(i
, SEND
))
293 " EIGRP packet %s send%s debugging is on\n",
294 lookup_msg(eigrp_packet_type_str
, i
+ 1,
296 IS_DEBUG_EIGRP_PACKET(i
, PACKET_DETAIL
)
299 if (IS_DEBUG_EIGRP_PACKET(i
, RECV
))
301 " EIGRP packet %s receive%s debugging is on\n",
302 lookup_msg(eigrp_packet_type_str
, i
+ 1,
304 IS_DEBUG_EIGRP_PACKET(i
, PACKET_DETAIL
)
310 cmd_show_lib_debugs(vty
);
316 [no] debug eigrp packet (hello|dd|ls-request|ls-update|ls-ack|all)
320 DEFUN (debug_eigrp_transmit
,
321 debug_eigrp_transmit_cmd
,
322 "debug eigrp transmit <send|recv|all> [detail]",
325 "EIGRP transmission events\n"
329 "Detailed Information\n")
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
;
343 if (argv_find(argv
, argc
, "detail", &idx
))
344 flag
= EIGRP_DEBUG_PACKET_DETAIL
;
346 if (vty
->node
== CONFIG_NODE
)
347 DEBUG_TRANSMIT_ON(0, flag
);
349 TERM_DEBUG_TRANSMIT_ON(0, flag
);
354 DEFUN (no_debug_eigrp_transmit
,
355 no_debug_eigrp_transmit_cmd
,
356 "no debug eigrp transmit <send|recv|all> [detail]",
360 "EIGRP transmission events\n"
364 "Detailed Information\n")
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
;
378 if (argv_find(argv
, argc
, "detail", &idx
))
379 flag
= EIGRP_DEBUG_PACKET_DETAIL
;
381 if (vty
->node
== CONFIG_NODE
)
382 DEBUG_TRANSMIT_OFF(0, flag
);
384 TERM_DEBUG_TRANSMIT_OFF(0, flag
);
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]",
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"
410 "Detail Information\n")
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
;
442 /* All packet types, both send and recv. */
443 flag
= EIGRP_DEBUG_SEND_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
;
452 if (argv_find(argv
, argc
, "detail", &idx
))
453 flag
|= EIGRP_DEBUG_PACKET_DETAIL
;
455 for (i
= 0; i
< 11; i
++)
456 if (type
& (0x01 << i
)) {
457 if (vty
->node
== CONFIG_NODE
)
458 DEBUG_PACKET_ON(i
, flag
);
460 TERM_DEBUG_PACKET_ON(i
, flag
);
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]",
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"
488 "Detailed Information\n")
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
;
517 /* Default, both send and recv. */
518 flag
= EIGRP_DEBUG_SEND_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
;
527 if (argv_find(argv
, argc
, "detail", &idx
))
528 flag
|= EIGRP_DEBUG_PACKET_DETAIL
;
530 for (i
= 0; i
< 11; i
++)
531 if (type
& (0x01 << i
)) {
532 if (vty
->node
== CONFIG_NODE
)
533 DEBUG_PACKET_OFF(i
, flag
);
535 TERM_DEBUG_PACKET_OFF(i
, flag
);
542 static int config_write_debug(struct vty
*vty
);
543 static struct cmd_node eigrp_debug_node
= {
547 .config_write
= config_write_debug
,
550 /* Initialize debug commands. */
551 void eigrp_debug_init(void)
553 install_node(&eigrp_debug_node
);
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
);
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
);