2 * EIGRP Dump Functions and Debugging.
3 * Copyright (C) 2013-2014
11 * This file is part of GNU Zebra.
13 * GNU Zebra is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2, or (at your option) any
18 * GNU Zebra is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * General Public License for more details.
23 * You should have received a copy of the GNU General Public License along
24 * with this program; see the file COPYING; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
40 #include "eigrpd/eigrp_structs.h"
41 #include "eigrpd/eigrpd.h"
42 #include "eigrpd/eigrp_interface.h"
43 #include "eigrpd/eigrp_neighbor.h"
44 #include "eigrpd/eigrp_packet.h"
45 #include "eigrpd/eigrp_zebra.h"
46 #include "eigrpd/eigrp_vty.h"
47 #include "eigrpd/eigrp_network.h"
48 #include "eigrpd/eigrp_dump.h"
49 #include "eigrpd/eigrp_topology.h"
51 /* Enable debug option variables -- valid only session. */
52 unsigned long term_debug_eigrp
= 0;
53 unsigned long term_debug_eigrp_nei
= 0;
54 unsigned long term_debug_eigrp_packet
[11] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
55 unsigned long term_debug_eigrp_zebra
= 6;
56 unsigned long term_debug_eigrp_transmit
= 0;
58 /* Configuration debug option variables. */
59 unsigned long conf_debug_eigrp
= 0;
60 unsigned long conf_debug_eigrp_nei
= 0;
61 unsigned long conf_debug_eigrp_packet
[11] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
62 unsigned long conf_debug_eigrp_zebra
= 0;
63 unsigned long conf_debug_eigrp_transmit
= 0;
66 static int config_write_debug(struct vty
*vty
)
71 const char *type_str
[] = {"update", "request", "query", "reply",
72 "hello", "", "probe", "ack",
73 "", "SIA query", "SIA reply", "stub",
75 const char *detail_str
[] = {
76 "", " send", " recv", "",
77 " detail", " send detail", " recv detail", " detail"};
80 /* debug eigrp event. */
82 /* debug eigrp packet */
83 for (i
= 0; i
< 10; i
++) {
84 if (conf_debug_eigrp_packet
[i
] == 0
85 && term_debug_eigrp_packet
[i
] == 0)
88 vty_out(vty
, "debug eigrp packet %s%s\n", type_str
[i
],
89 detail_str
[conf_debug_eigrp_packet
[i
]]);
96 static int eigrp_neighbor_packet_queue_sum(struct eigrp_interface
*ei
)
98 struct eigrp_neighbor
*nbr
;
99 struct listnode
*node
, *nnode
;
103 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node
, nnode
, nbr
)) {
104 sum
+= nbr
->retrans_queue
->count
;
111 * Expects header to be in host order
113 void eigrp_ip_header_dump(struct ip
*iph
)
115 /* IP Header dump. */
116 zlog_debug("ip_v %u", iph
->ip_v
);
117 zlog_debug("ip_hl %u", iph
->ip_hl
);
118 zlog_debug("ip_tos %u", iph
->ip_tos
);
119 zlog_debug("ip_len %u", iph
->ip_len
);
120 zlog_debug("ip_id %u", (u_int32_t
)iph
->ip_id
);
121 zlog_debug("ip_off %u", (u_int32_t
)iph
->ip_off
);
122 zlog_debug("ip_ttl %u", iph
->ip_ttl
);
123 zlog_debug("ip_p %u", iph
->ip_p
);
124 zlog_debug("ip_sum 0x%x", (u_int32_t
)iph
->ip_sum
);
125 zlog_debug("ip_src %s", inet_ntoa(iph
->ip_src
));
126 zlog_debug("ip_dst %s", inet_ntoa(iph
->ip_dst
));
130 * Expects header to be in host order
132 void eigrp_header_dump(struct eigrp_header
*eigrph
)
134 /* EIGRP Header dump. */
135 zlog_debug("eigrp_version %u", eigrph
->version
);
136 zlog_debug("eigrp_opcode %u", eigrph
->opcode
);
137 zlog_debug("eigrp_checksum 0x%x", ntohs(eigrph
->checksum
));
138 zlog_debug("eigrp_flags 0x%x", ntohl(eigrph
->flags
));
139 zlog_debug("eigrp_sequence %u", ntohl(eigrph
->sequence
));
140 zlog_debug("eigrp_ack %u", ntohl(eigrph
->ack
));
141 zlog_debug("eigrp_vrid %u", ntohs(eigrph
->vrid
));
142 zlog_debug("eigrp_AS %u", ntohs(eigrph
->ASNumber
));
145 const char *eigrp_if_name_string(struct eigrp_interface
*ei
)
147 static char buf
[EIGRP_IF_STRING_MAXLEN
] = "";
152 snprintf(buf
, EIGRP_IF_STRING_MAXLEN
, "%s", ei
->ifp
->name
);
156 const char *eigrp_topology_ip_string(struct eigrp_prefix_entry
*tn
)
158 static char buf
[EIGRP_IF_STRING_MAXLEN
] = "";
161 ifaddr
= ntohl(tn
->destination_ipv4
->prefix
.s_addr
);
162 snprintf(buf
, EIGRP_IF_STRING_MAXLEN
, "%u.%u.%u.%u",
163 (ifaddr
>> 24) & 0xff, (ifaddr
>> 16) & 0xff,
164 (ifaddr
>> 8) & 0xff, ifaddr
& 0xff);
169 const char *eigrp_if_ip_string(struct eigrp_interface
*ei
)
171 static char buf
[EIGRP_IF_STRING_MAXLEN
] = "";
177 ifaddr
= ntohl(ei
->address
->u
.prefix4
.s_addr
);
178 snprintf(buf
, EIGRP_IF_STRING_MAXLEN
, "%u.%u.%u.%u",
179 (ifaddr
>> 24) & 0xff, (ifaddr
>> 16) & 0xff,
180 (ifaddr
>> 8) & 0xff, ifaddr
& 0xff);
185 const char *eigrp_neigh_ip_string(struct eigrp_neighbor
*nbr
)
187 static char buf
[EIGRP_IF_STRING_MAXLEN
] = "";
190 ifaddr
= ntohl(nbr
->src
.s_addr
);
191 snprintf(buf
, EIGRP_IF_STRING_MAXLEN
, "%u.%u.%u.%u",
192 (ifaddr
>> 24) & 0xff, (ifaddr
>> 16) & 0xff,
193 (ifaddr
>> 8) & 0xff, ifaddr
& 0xff);
198 void show_ip_eigrp_interface_header(struct vty
*vty
, struct eigrp
*eigrp
)
202 "\nEIGRP interfaces for AS(%d)\n\n %-10s %-10s %-10s %-6s %-12s %-7s %-14s %-12s %-8s %-8s %-8s\n %-39s %-12s %-7s %-14s %-12s %-8s\n",
203 eigrp
->AS
, "Interface", "Bandwidth", "Delay", "Peers",
204 "Xmit Queue", "Mean", "Pacing Time", "Multicast", "Pending",
205 "Hello", "Holdtime", "", "Un/Reliable", "SRTT", "Un/Reliable",
206 "Flow Timer", "Routes");
209 void show_ip_eigrp_interface_sub(struct vty
*vty
, struct eigrp
*eigrp
,
210 struct eigrp_interface
*ei
)
212 vty_out(vty
, "%-11s ", eigrp_if_name_string(ei
));
213 vty_out(vty
, "%-11u", IF_DEF_PARAMS(ei
->ifp
)->bandwidth
);
214 vty_out(vty
, "%-11u", IF_DEF_PARAMS(ei
->ifp
)->delay
);
215 vty_out(vty
, "%-7u", ei
->nbrs
->count
);
216 vty_out(vty
, "%u %c %-10u", 0, '/',
217 eigrp_neighbor_packet_queue_sum(ei
));
218 vty_out(vty
, "%-7u %-14u %-12u %-8u", 0, 0, 0, 0);
219 vty_out(vty
, "%-8u %-8u \n", IF_DEF_PARAMS(ei
->ifp
)->v_hello
,
220 IF_DEF_PARAMS(ei
->ifp
)->v_wait
);
223 void show_ip_eigrp_interface_detail(struct vty
*vty
, struct eigrp
*eigrp
,
224 struct eigrp_interface
*ei
)
226 vty_out(vty
, "%-2s %s %d %-3s \n", "", "Hello interval is ", 0, " sec");
227 vty_out(vty
, "%-2s %s %s \n", "", "Next xmit serial", "<none>");
228 vty_out(vty
, "%-2s %s %d %s %d %s %d %s %d \n", "",
229 "Un/reliable mcasts: ", 0, "/", 0, "Un/reliable ucasts: ", 0,
231 vty_out(vty
, "%-2s %s %d %s %d %s %d \n", "", "Mcast exceptions: ", 0,
232 " CR packets: ", 0, " ACKs supressed: ", 0);
233 vty_out(vty
, "%-2s %s %d %s %d \n", "", "Retransmissions sent: ", 0,
234 "Out-of-sequence rcvd: ", 0);
235 vty_out(vty
, "%-2s %s %s %s \n", "", "Authentication mode is ", "not",
237 vty_out(vty
, "%-2s %s \n", "", "Use multicast");
240 void show_ip_eigrp_neighbor_header(struct vty
*vty
, struct eigrp
*eigrp
)
243 "\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",
244 eigrp
->AS
, "H", "Address", "Interface", "Hold", "Uptime",
245 "SRTT", "RTO", "Q", "Seq", "", "(sec)", "", "(ms)", "", "Cnt",
249 void show_ip_eigrp_neighbor_sub(struct vty
*vty
, struct eigrp_neighbor
*nbr
,
253 vty_out(vty
, "%-3u %-17s %-21s", 0, eigrp_neigh_ip_string(nbr
),
254 eigrp_if_name_string(nbr
->ei
));
255 vty_out(vty
, "%-7lu", thread_timer_remain_second(nbr
->t_holddown
));
256 vty_out(vty
, "%-8u %-6u %-5u", 0, 0, EIGRP_PACKET_RETRANS_TIME
);
257 vty_out(vty
, "%-7lu", nbr
->retrans_queue
->count
);
258 vty_out(vty
, "%u\n", nbr
->recv_sequence_number
);
262 vty_out(vty
, " Version %u.%u/%u.%u", nbr
->os_rel_major
,
263 nbr
->os_rel_minor
, nbr
->tlv_rel_major
,
265 vty_out(vty
, ", Retrans: %lu, Retries: %lu",
266 nbr
->retrans_queue
->count
, 0UL);
267 vty_out(vty
, ", %s\n", eigrp_nbr_state_str(nbr
));
272 * Print standard header for show EIGRP topology output
274 void show_ip_eigrp_topology_header(struct vty
*vty
, struct eigrp
*eigrp
)
276 struct in_addr router_id
;
277 router_id
.s_addr
= eigrp
->router_id
;
279 vty_out(vty
, "\nEIGRP Topology Table for AS(%d)/ID(%s)\n\n", eigrp
->AS
,
280 inet_ntoa(router_id
));
282 "Codes: P - Passive, A - Active, U - Update, Q - Query, "
283 "R - Reply\n r - reply Status, s - sia Status\n\n");
286 void show_ip_eigrp_prefix_entry(struct vty
*vty
, struct eigrp_prefix_entry
*tn
)
288 struct list
*successors
= eigrp_topology_get_successor(tn
);
290 vty_out(vty
, "%-3c", (tn
->state
> 0) ? 'A' : 'P');
292 vty_out(vty
, "%s/%u, ", inet_ntoa(tn
->destination_ipv4
->prefix
),
293 tn
->destination_ipv4
->prefixlen
);
294 vty_out(vty
, "%u successors, ", successors
->count
);
295 vty_out(vty
, "FD is %u, serno: %" PRIu64
" \n", tn
->fdistance
,
298 list_delete(successors
);
301 void show_ip_eigrp_neighbor_entry(struct vty
*vty
, struct eigrp
*eigrp
,
302 struct eigrp_neighbor_entry
*te
, int *first
)
304 if (te
->reported_distance
== EIGRP_MAX_METRIC
)
308 show_ip_eigrp_prefix_entry(vty
, te
->prefix
);
312 if (te
->adv_router
== eigrp
->neighbor_self
)
313 vty_out(vty
, "%-7s%s, %s\n", " ", "via Connected",
314 eigrp_if_name_string(te
->ei
));
316 vty_out(vty
, "%-7s%s%s (%u/%u), %s\n", " ", "via ",
317 inet_ntoa(te
->adv_router
->src
), te
->distance
,
318 te
->reported_distance
, eigrp_if_name_string(te
->ei
));
323 DEFUN (show_debugging_eigrp
,
324 show_debugging_eigrp_cmd
,
325 "show debugging eigrp",
332 vty_out(vty
, "EIGRP debugging status:\n");
334 /* Show debug status for events. */
335 if (IS_DEBUG_EIGRP(event
, EVENT
))
336 vty_out(vty
, " EIGRP event debugging is on\n");
338 /* Show debug status for EIGRP Packets. */
339 for (i
= 0; i
< 11; i
++) {
343 if (IS_DEBUG_EIGRP_PACKET(i
, SEND
)
344 && IS_DEBUG_EIGRP_PACKET(i
, RECV
)) {
345 vty_out(vty
, " EIGRP packet %s%s debugging is on\n",
346 lookup_msg(eigrp_packet_type_str
, i
+ 1, NULL
),
347 IS_DEBUG_EIGRP_PACKET(i
, PACKET_DETAIL
)
351 if (IS_DEBUG_EIGRP_PACKET(i
, SEND
))
353 " EIGRP packet %s send%s debugging is on\n",
354 lookup_msg(eigrp_packet_type_str
, i
+ 1,
356 IS_DEBUG_EIGRP_PACKET(i
, PACKET_DETAIL
)
359 if (IS_DEBUG_EIGRP_PACKET(i
, RECV
))
361 " EIGRP packet %s receive%s debugging is on\n",
362 lookup_msg(eigrp_packet_type_str
, i
+ 1,
364 IS_DEBUG_EIGRP_PACKET(i
, PACKET_DETAIL
)
375 [no] debug eigrp packet (hello|dd|ls-request|ls-update|ls-ack|all)
379 DEFUN (debug_eigrp_transmit
,
380 debug_eigrp_transmit_cmd
,
381 "debug eigrp transmit <send|recv|all> [detail]",
384 "EIGRP transmission events\n"
388 "Detailed Information\n")
394 if (argv_find(argv
, argc
, "send", &idx
))
395 flag
= EIGRP_DEBUG_SEND
;
396 else if (argv_find(argv
, argc
, "recv", &idx
))
397 flag
= EIGRP_DEBUG_RECV
;
398 else if (argv_find(argv
, argc
, "all", &idx
))
399 flag
= EIGRP_DEBUG_SEND_RECV
;
402 if (argv_find(argv
, argc
, "detail", &idx
))
403 flag
= EIGRP_DEBUG_PACKET_DETAIL
;
405 if (vty
->node
== CONFIG_NODE
)
406 DEBUG_TRANSMIT_ON(0, flag
);
408 TERM_DEBUG_TRANSMIT_ON(0, flag
);
413 DEFUN (no_debug_eigrp_transmit
,
414 no_debug_eigrp_transmit_cmd
,
415 "no debug eigrp transmit <send|recv|all> [detail]",
419 "EIGRP transmission events\n"
423 "Detailed Information\n")
429 if (argv_find(argv
, argc
, "send", &idx
))
430 flag
= EIGRP_DEBUG_SEND
;
431 else if (argv_find(argv
, argc
, "recv", &idx
))
432 flag
= EIGRP_DEBUG_RECV
;
433 else if (argv_find(argv
, argc
, "all", &idx
))
434 flag
= EIGRP_DEBUG_SEND_RECV
;
437 if (argv_find(argv
, argc
, "detail", &idx
))
438 flag
= EIGRP_DEBUG_PACKET_DETAIL
;
440 if (vty
->node
== CONFIG_NODE
)
441 DEBUG_TRANSMIT_OFF(0, flag
);
443 TERM_DEBUG_TRANSMIT_OFF(0, flag
);
448 DEFUN (debug_eigrp_packets
,
449 debug_eigrp_packets_all_cmd
,
450 "debug eigrp packets <siaquery|siareply|ack|hello|probe|query|reply|request|retry|stub|terse|update|all> [send|receive] [detail]",
454 "EIGRP SIA-Query packets\n"
455 "EIGRP SIA-Reply packets\n"
456 "EIGRP ack packets\n"
457 "EIGRP hello packets\n"
458 "EIGRP probe packets\n"
459 "EIGRP query packets\n"
460 "EIGRP reply packets\n"
461 "EIGRP request packets\n"
462 "EIGRP retransmissions\n"
463 "EIGRP stub packets\n"
464 "Display all EIGRP packets except Hellos\n"
465 "EIGRP update packets\n"
466 "Display all EIGRP packets\n"
469 "Detail Information\n")
476 /* Check packet type. */
477 if (argv_find(argv
, argc
, "hello", &idx
))
478 type
= EIGRP_DEBUG_HELLO
;
479 if (argv_find(argv
, argc
, "update", &idx
))
480 type
= EIGRP_DEBUG_UPDATE
;
481 if (argv_find(argv
, argc
, "query", &idx
))
482 type
= EIGRP_DEBUG_QUERY
;
483 if (argv_find(argv
, argc
, "ack", &idx
))
484 type
= EIGRP_DEBUG_ACK
;
485 if (argv_find(argv
, argc
, "probe", &idx
))
486 type
= EIGRP_DEBUG_PROBE
;
487 if (argv_find(argv
, argc
, "stub", &idx
))
488 type
= EIGRP_DEBUG_STUB
;
489 if (argv_find(argv
, argc
, "reply", &idx
))
490 type
= EIGRP_DEBUG_REPLY
;
491 if (argv_find(argv
, argc
, "request", &idx
))
492 type
= EIGRP_DEBUG_REQUEST
;
493 if (argv_find(argv
, argc
, "siaquery", &idx
))
494 type
= EIGRP_DEBUG_SIAQUERY
;
495 if (argv_find(argv
, argc
, "siareply", &idx
))
496 type
= EIGRP_DEBUG_SIAREPLY
;
497 if (argv_find(argv
, argc
, "all", &idx
))
498 type
= EIGRP_DEBUG_PACKETS_ALL
;
501 /* All packet types, both send and recv. */
502 flag
= EIGRP_DEBUG_SEND_RECV
;
505 if (argv_find(argv
, argc
, "s", &idx
))
506 flag
= EIGRP_DEBUG_SEND
;
507 else if (argv_find(argv
, argc
, "r", &idx
))
508 flag
= EIGRP_DEBUG_RECV
;
511 if (argv_find(argv
, argc
, "detail", &idx
))
512 flag
|= EIGRP_DEBUG_PACKET_DETAIL
;
514 for (i
= 0; i
< 11; i
++)
515 if (type
& (0x01 << i
)) {
516 if (vty
->node
== CONFIG_NODE
)
517 DEBUG_PACKET_ON(i
, flag
);
519 TERM_DEBUG_PACKET_ON(i
, flag
);
525 DEFUN (no_debug_eigrp_packets
,
526 no_debug_eigrp_packets_all_cmd
,
527 "no debug eigrp packets <siaquery|siareply|ack|hello|probe|query|reply|request|retry|stub|terse|update|all> [send|receive] [detail]",
532 "EIGRP SIA-Query packets\n"
533 "EIGRP SIA-Reply packets\n"
534 "EIGRP ack packets\n"
535 "EIGRP hello packets\n"
536 "EIGRP probe packets\n"
537 "EIGRP query packets\n"
538 "EIGRP reply packets\n"
539 "EIGRP request packets\n"
540 "EIGRP retransmissions\n"
541 "EIGRP stub packets\n"
542 "Display all EIGRP packets except Hellos\n"
543 "EIGRP update packets\n"
544 "Display all EIGRP packets\n"
547 "Detailed Information\n")
554 /* Check packet type. */
555 if (argv_find(argv
, argc
, "hello", &idx
))
556 type
= EIGRP_DEBUG_HELLO
;
557 if (argv_find(argv
, argc
, "update", &idx
))
558 type
= EIGRP_DEBUG_UPDATE
;
559 if (argv_find(argv
, argc
, "query", &idx
))
560 type
= EIGRP_DEBUG_QUERY
;
561 if (argv_find(argv
, argc
, "ack", &idx
))
562 type
= EIGRP_DEBUG_ACK
;
563 if (argv_find(argv
, argc
, "probe", &idx
))
564 type
= EIGRP_DEBUG_PROBE
;
565 if (argv_find(argv
, argc
, "stub", &idx
))
566 type
= EIGRP_DEBUG_STUB
;
567 if (argv_find(argv
, argc
, "reply", &idx
))
568 type
= EIGRP_DEBUG_REPLY
;
569 if (argv_find(argv
, argc
, "request", &idx
))
570 type
= EIGRP_DEBUG_REQUEST
;
571 if (argv_find(argv
, argc
, "siaquery", &idx
))
572 type
= EIGRP_DEBUG_SIAQUERY
;
573 if (argv_find(argv
, argc
, "siareply", &idx
))
574 type
= EIGRP_DEBUG_SIAREPLY
;
576 /* Default, both send and recv. */
577 flag
= EIGRP_DEBUG_SEND_RECV
;
580 if (argv_find(argv
, argc
, "send", &idx
))
581 flag
= EIGRP_DEBUG_SEND
;
582 else if (argv_find(argv
, argc
, "reply", &idx
))
583 flag
= EIGRP_DEBUG_RECV
;
586 if (argv_find(argv
, argc
, "detail", &idx
))
587 flag
|= EIGRP_DEBUG_PACKET_DETAIL
;
589 for (i
= 0; i
< 11; i
++)
590 if (type
& (0x01 << i
)) {
591 if (vty
->node
== CONFIG_NODE
)
592 DEBUG_PACKET_OFF(i
, flag
);
594 TERM_DEBUG_PACKET_OFF(i
, flag
);
601 static struct cmd_node eigrp_debug_node
= {
602 DEBUG_NODE
, "", 1 /* VTYSH */
605 /* Initialize debug commands. */
606 void eigrp_debug_init()
608 install_node(&eigrp_debug_node
, config_write_debug
);
610 install_element(ENABLE_NODE
, &show_debugging_eigrp_cmd
);
611 install_element(ENABLE_NODE
, &debug_eigrp_packets_all_cmd
);
612 install_element(ENABLE_NODE
, &no_debug_eigrp_packets_all_cmd
);
613 install_element(ENABLE_NODE
, &debug_eigrp_transmit_cmd
);
614 install_element(ENABLE_NODE
, &no_debug_eigrp_transmit_cmd
);
616 install_element(CONFIG_NODE
, &show_debugging_eigrp_cmd
);
617 install_element(CONFIG_NODE
, &debug_eigrp_packets_all_cmd
);
618 install_element(CONFIG_NODE
, &no_debug_eigrp_packets_all_cmd
);
619 install_element(CONFIG_NODE
, &no_debug_eigrp_transmit_cmd
);