]> git.puffer.fish Git - mirror/frr.git/commitdiff
ospfd: add debug option for BFD
authorRafael Zalamena <rzalamena@opensourcerouting.org>
Thu, 4 Mar 2021 18:15:00 +0000 (15:15 -0300)
committerRafael Zalamena <rzalamena@opensourcerouting.org>
Tue, 23 Mar 2021 13:18:42 +0000 (10:18 -0300)
Add specialized debug option for BFD which also enables library debugging.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
ospfd/ospf_bfd.c
ospfd/ospf_dump.c
ospfd/ospf_dump.h

index f4470ad833b19f816ee98a05e017ed17d3a9bbda..123515e0392ff08f53b055fb12cdddffb5e49879 100644 (file)
@@ -70,18 +70,18 @@ static void ospf_bfd_session_change(struct bfd_session_params *bsp,
        /* BFD peer went down. */
        if (bss->state == BFD_STATUS_DOWN
            && bss->previous_state == BFD_STATUS_UP) {
-               if (IS_DEBUG_OSPF(nsm, NSM_EVENTS))
-                       zlog_debug("NSM[%s:%pI4]: BFD Down", IF_NAME(nbr->oi),
-                                  &nbr->address.u.prefix4);
+               if (IS_DEBUG_OSPF(bfd, BFD_LIB))
+                       zlog_debug("%s: NSM[%s:%pI4]: BFD Down", __func__,
+                                  IF_NAME(nbr->oi), &nbr->address.u.prefix4);
 
                OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_InactivityTimer);
        }
 
        /* BFD peer went up. */
        if (bss->state == BSS_UP && bss->previous_state == BSS_DOWN)
-               if (IS_DEBUG_OSPF(nsm, NSM_EVENTS))
-                       zlog_debug("NSM[%s:%pI4]: BFD Up", IF_NAME(nbr->oi),
-                                  &nbr->address.u.prefix4);
+               if (IS_DEBUG_OSPF(bfd, BFD_LIB))
+                       zlog_debug("%s: NSM[%s:%pI4]: BFD Up", __func__,
+                                  IF_NAME(nbr->oi), &nbr->address.u.prefix4);
 }
 
 void ospf_neighbor_bfd_apply(struct ospf_neighbor *nbr)
index 19829d4546f0af66533db1941ebfa712a09f6e5a..cd4fbc6dcd395a2623988fcf1d508e3f1ee3c917 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <zebra.h>
 
+#include "lib/bfd.h"
 #include "monotime.h"
 #include "linklist.h"
 #include "thread.h"
@@ -60,6 +61,7 @@ unsigned long conf_debug_ospf_ti_lfa = 0;
 unsigned long conf_debug_ospf_defaultinfo = 0;
 unsigned long conf_debug_ospf_ldp_sync = 0;
 unsigned long conf_debug_ospf_gr = 0;
+unsigned long conf_debug_ospf_bfd = 0;
 
 /* Enable debug option variables -- valid only session. */
 unsigned long term_debug_ospf_packet[5] = {0, 0, 0, 0, 0};
@@ -76,6 +78,7 @@ unsigned long term_debug_ospf_ti_lfa = 0;
 unsigned long term_debug_ospf_defaultinfo;
 unsigned long term_debug_ospf_ldp_sync;
 unsigned long term_debug_ospf_gr = 0;
+unsigned long term_debug_ospf_bfd = 0;
 
 const char *ospf_redist_string(unsigned int route_type)
 {
@@ -1563,6 +1566,31 @@ DEFPY (debug_ospf_gr,
        return CMD_SUCCESS;
 }
 
+DEFPY(debug_ospf_bfd, debug_ospf_bfd_cmd,
+      "[no] debug ospf bfd",
+      NO_STR
+      DEBUG_STR
+      OSPF_STR
+      "Bidirection Forwarding Detection\n")
+{
+       if (vty->node == CONFIG_NODE) {
+               if (no) {
+                       bfd_protocol_integration_set_debug(false);
+                       CONF_DEBUG_OFF(bfd, BFD_LIB);
+               } else {
+                       bfd_protocol_integration_set_debug(true);
+                       CONF_DEBUG_ON(bfd, BFD_LIB);
+               }
+       }
+
+       if (no)
+               TERM_DEBUG_OFF(bfd, BFD_LIB);
+       else
+               TERM_DEBUG_ON(bfd, BFD_LIB);
+
+       return CMD_SUCCESS;
+}
+
 DEFUN (no_debug_ospf,
        no_debug_ospf_cmd,
        "no debug ospf",
@@ -1594,6 +1622,10 @@ DEFUN (no_debug_ospf,
                DEBUG_OFF(defaultinfo, DEFAULTINFO);
                DEBUG_OFF(ldp_sync, LDP_SYNC);
 
+               /* BFD debugging is two parts: OSPF and library. */
+               DEBUG_OFF(bfd, BFD_LIB);
+               bfd_protocol_integration_set_debug(false);
+
                for (i = 0; i < 5; i++)
                        DEBUG_PACKET_OFF(i, flag);
        }
@@ -1621,6 +1653,7 @@ DEFUN (no_debug_ospf,
        TERM_DEBUG_OFF(zebra, ZEBRA_REDISTRIBUTE);
        TERM_DEBUG_OFF(defaultinfo, DEFAULTINFO);
        TERM_DEBUG_OFF(ldp_sync, LDP_SYNC);
+       TERM_DEBUG_OFF(bfd, BFD_LIB);
 
        return CMD_SUCCESS;
 }
@@ -1730,6 +1763,10 @@ static int show_debugging_ospf_common(struct vty *vty)
        if (IS_DEBUG_OSPF(gr, GR_HELPER) == OSPF_DEBUG_GR_HELPER)
                vty_out(vty, "  OSPF Graceful Restart Helper debugging is on\n");
 
+       if (IS_DEBUG_OSPF(bfd, BFD_LIB) == OSPF_DEBUG_BFD_LIB)
+               vty_out(vty,
+                       "  OSPF BFD integration library debugging is on\n");
+
        vty_out(vty, "\n");
 
        return CMD_SUCCESS;
@@ -1917,6 +1954,11 @@ static int config_write_debug(struct vty *vty)
                write = 1;
        }
 
+       if (IS_CONF_DEBUG_OSPF(bfd, BFD_LIB) == OSPF_DEBUG_BFD_LIB) {
+               vty_out(vty, "debug ospf%s bfd\n", str);
+               write = 1;
+       }
+
        return write;
 }
 
@@ -1949,6 +1991,7 @@ void ospf_debug_init(void)
        install_element(ENABLE_NODE, &no_debug_ospf_default_info_cmd);
        install_element(ENABLE_NODE, &no_debug_ospf_ldp_sync_cmd);
        install_element(ENABLE_NODE, &debug_ospf_gr_cmd);
+       install_element(ENABLE_NODE, &debug_ospf_bfd_cmd);
 
        install_element(ENABLE_NODE, &show_debugging_ospf_instance_cmd);
        install_element(ENABLE_NODE, &debug_ospf_packet_cmd);
@@ -1992,6 +2035,7 @@ void ospf_debug_init(void)
        install_element(CONFIG_NODE, &no_debug_ospf_default_info_cmd);
        install_element(CONFIG_NODE, &no_debug_ospf_ldp_sync_cmd);
        install_element(CONFIG_NODE, &debug_ospf_gr_cmd);
+       install_element(CONFIG_NODE, &debug_ospf_bfd_cmd);
 
        install_element(CONFIG_NODE, &debug_ospf_instance_nsm_cmd);
        install_element(CONFIG_NODE, &debug_ospf_instance_lsa_cmd);
index c4c560666367d6b3db9ae5d931c89bd9eda523c8..b1c1d02a5115472766c906e281a5af92932c2456 100644 (file)
@@ -67,6 +67,8 @@
 #define OSPF_DEBUG_GR_HELPER 0x01
 #define OSPF_DEBUG_GR 0x03
 
+#define OSPF_DEBUG_BFD_LIB 0x01
+
 /* Macro for setting debug option. */
 #define CONF_DEBUG_PACKET_ON(a, b)         conf_debug_ospf_packet[a] |= (b)
 #define CONF_DEBUG_PACKET_OFF(a, b)        conf_debug_ospf_packet[a] &= ~(b)
@@ -140,6 +142,7 @@ extern unsigned long term_debug_ospf_ti_lfa;
 extern unsigned long term_debug_ospf_defaultinfo;
 extern unsigned long term_debug_ospf_ldp_sync;
 extern unsigned long term_debug_ospf_gr;
+extern unsigned long term_debug_ospf_bfd;
 
 /* Message Strings. */
 extern char *ospf_lsa_type_str[];