]> git.proxmox.com Git - mirror_frr.git/commitdiff
isisd: Add debugging for BFD
authorChristian Franke <chris@opensourcerouting.org>
Fri, 28 Sep 2018 17:35:10 +0000 (19:35 +0200)
committerChristian Franke <chris@opensourcerouting.org>
Fri, 5 Oct 2018 12:08:23 +0000 (14:08 +0200)
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
isisd/isis_bfd.c
isisd/isisd.c
isisd/isisd.h

index 8b85811fdcf51b8ee8b45bb43a70a176f890779b..6f89d9873592b7329c4219ab47657ebc56c46ff6 100644 (file)
@@ -63,6 +63,23 @@ static void bfd_session_free(struct bfd_session **session)
 static int isis_bfd_interface_dest_update(int command, struct zclient *zclient,
                                          zebra_size_t length, vrf_id_t vrf_id)
 {
+       struct interface *ifp;
+       struct prefix dst_ip;
+       int status;
+
+       ifp = bfd_get_peer_info(zclient->ibuf, &dst_ip, NULL, &status, vrf_id);
+       if (!ifp || dst_ip.family != AF_INET)
+               return 0;
+
+       if (isis->debugs & DEBUG_BFD) {
+               char dst_buf[INET6_ADDRSTRLEN];
+               inet_ntop(AF_INET, &dst_ip.u.prefix4,
+                         dst_buf, sizeof(dst_buf));
+
+               zlog_debug("ISIS-BFD: Received update for %s on %s: Changed state to %s",
+                          dst_buf, ifp->name, bfd_get_status_str(status));
+       }
+
        return 0;
 }
 
@@ -74,6 +91,9 @@ static int isis_bfd_nbr_replay(int command, struct zclient *zclient,
        struct listnode *anode;
        struct isis_area *area;
 
+       if (isis->debugs & DEBUG_BFD)
+               zlog_debug("ISIS-BFD: Got neighbor replay request, resending neighbors.");
+
        for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) {
                struct listnode *cnode;
                struct isis_circuit *circuit;
@@ -82,6 +102,9 @@ static int isis_bfd_nbr_replay(int command, struct zclient *zclient,
                        isis_bfd_circuit_cmd(circuit, ZEBRA_BFD_DEST_UPDATE);
        }
 
+       if (isis->debugs & DEBUG_BFD)
+               zlog_debug("ISIS-BFD: Done with replay.");
+
        return 0;
 }
 
@@ -94,11 +117,47 @@ static void isis_bfd_zebra_connected(struct zclient *zclient)
        bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER);
 }
 
+static void bfd_debug(struct in_addr *dst, struct in_addr *src,
+                     const char *interface, int command)
+{
+       if (!(isis->debugs & DEBUG_BFD))
+               return;
+
+       char dst_str[INET6_ADDRSTRLEN];
+       char src_str[INET6_ADDRSTRLEN];
+
+       inet_ntop(AF_INET, dst, dst_str, sizeof(dst_str));
+       inet_ntop(AF_INET, src, src_str, sizeof(src_str));
+
+       const char *command_str;
+
+       switch (command) {
+       case ZEBRA_BFD_DEST_REGISTER:
+               command_str = "Register";
+               break;
+       case ZEBRA_BFD_DEST_DEREGISTER:
+               command_str = "Deregister";
+               break;
+       case ZEBRA_BFD_DEST_UPDATE:
+               command_str = "Update";
+               break;
+       default:
+               command_str = "Unknown-Cmd";
+               break;
+       }
+
+       zlog_debug("ISIS-BFD: %s peer %s on %s (src %s)",
+                  command_str, dst_str, interface, src_str);
+}
+
 static void bfd_handle_adj_down(struct isis_adjacency *adj)
 {
        if (!adj->bfd_session)
                return;
 
+       bfd_debug(&adj->bfd_session->dst_ip, &adj->bfd_session->src_ip,
+                 adj->circuit->interface->name, ZEBRA_BFD_DEST_DEREGISTER);
+
        bfd_peer_sendmsg(zclient, NULL, AF_INET,
                         &adj->bfd_session->dst_ip,
                         &adj->bfd_session->src_ip,
@@ -137,6 +196,8 @@ static void bfd_handle_adj_up(struct isis_adjacency *adj, int command)
        if (!adj->bfd_session)
                adj->bfd_session = bfd_session_new(dst_ip, src_ip);
 
+       bfd_debug(&adj->bfd_session->dst_ip, &adj->bfd_session->src_ip,
+                 circuit->interface->name, command);
        bfd_peer_sendmsg(zclient, circuit->bfd_info, AF_INET,
                         &adj->bfd_session->dst_ip,
                         &adj->bfd_session->src_ip,
index e5e43c4b7ded8de88fbe7ef3a1da66c1a774173b..94e6a63855b30758d4b6d107efb68f1624a99b5e 100644 (file)
@@ -746,6 +746,8 @@ void print_debug(struct vty *vty, int flags, int onoff)
                vty_out(vty, "IS-IS LSP scheduling debugging is %s\n", onoffs);
        if (flags & DEBUG_FABRICD_FLOODING)
                vty_out(vty, "OpenFabric Flooding debugging is %s\n", onoffs);
+       if (flags & DEBUG_BFD)
+               vty_out(vty, "IS-IS BFD debugging is %s\n", onoffs);
 }
 
 DEFUN_NOSH (show_debugging,
@@ -831,6 +833,10 @@ static int config_write_debug(struct vty *vty)
                vty_out(vty, "debug " PROTO_NAME " flooding\n");
                write++;
        }
+       if (flags & DEBUG_BFD) {
+               vty_out(vty, "debug " PROTO_NAME " bfd\n");
+               write++;
+       }
        write += spf_backoff_write_config(vty);
 
        return write;
@@ -1214,6 +1220,33 @@ DEFUN (no_debug_isis_lsp_sched,
        return CMD_SUCCESS;
 }
 
+DEFUN (debug_isis_bfd,
+       debug_isis_bfd_cmd,
+       "debug " PROTO_NAME " bfd",
+       DEBUG_STR
+       PROTO_HELP
+       PROTO_NAME " interaction with BFD\n")
+{
+       isis->debugs |= DEBUG_BFD;
+       print_debug(vty, DEBUG_BFD, 1);
+
+       return CMD_SUCCESS;
+}
+
+DEFUN (no_debug_isis_bfd,
+       no_debug_isis_bfd_cmd,
+       "no debug " PROTO_NAME " bfd",
+       NO_STR
+       UNDEBUG_STR
+       PROTO_HELP
+       PROTO_NAME " interaction with BFD\n")
+{
+       isis->debugs &= ~DEBUG_BFD;
+       print_debug(vty, DEBUG_BFD, 0);
+
+       return CMD_SUCCESS;
+}
+
 DEFUN (show_hostname,
        show_hostname_cmd,
        "show " PROTO_NAME " hostname",
@@ -2215,6 +2248,8 @@ void isis_init()
        install_element(ENABLE_NODE, &no_debug_isis_lsp_gen_cmd);
        install_element(ENABLE_NODE, &debug_isis_lsp_sched_cmd);
        install_element(ENABLE_NODE, &no_debug_isis_lsp_sched_cmd);
+       install_element(ENABLE_NODE, &debug_isis_bfd_cmd);
+       install_element(ENABLE_NODE, &no_debug_isis_bfd_cmd);
 
        install_element(CONFIG_NODE, &debug_isis_adj_cmd);
        install_element(CONFIG_NODE, &no_debug_isis_adj_cmd);
@@ -2244,6 +2279,8 @@ void isis_init()
        install_element(CONFIG_NODE, &no_debug_isis_lsp_gen_cmd);
        install_element(CONFIG_NODE, &debug_isis_lsp_sched_cmd);
        install_element(CONFIG_NODE, &no_debug_isis_lsp_sched_cmd);
+       install_element(CONFIG_NODE, &debug_isis_bfd_cmd);
+       install_element(CONFIG_NODE, &no_debug_isis_bfd_cmd);
 
        install_element(CONFIG_NODE, &router_isis_cmd);
        install_element(CONFIG_NODE, &no_router_isis_cmd);
index 864021428aa885dfbf07d3eae33e98dec79f4ed7..7572f551743758ffc6f09a95cedf2e360f8cd733 100644 (file)
@@ -211,6 +211,7 @@ extern struct thread_master *master;
 #define DEBUG_LSP_GEN                    (1<<13)
 #define DEBUG_LSP_SCHED                  (1<<14)
 #define DEBUG_FABRICD_FLOODING           (1<<15)
+#define DEBUG_BFD                        (1<<16)
 
 #define lsp_debug(...)                                                         \
        do {                                                                   \