]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_debug.c
Merge pull request #9440 from dlqs/dplanehook2
[mirror_frr.git] / bgpd / bgp_debug.c
index 3afa6eaf09ee7a6bad0174bb243baf614531d579..856afb05f84b90d8920762c1b40af308b56b3a72 100644 (file)
@@ -21,6 +21,7 @@
 #include <zebra.h>
 
 #include <lib/version.h>
+#include "lib/bfd.h"
 #include "lib/printfrr.h"
 #include "prefix.h"
 #include "linklist.h"
@@ -67,6 +68,7 @@ unsigned long conf_bgp_debug_labelpool;
 unsigned long conf_bgp_debug_pbr;
 unsigned long conf_bgp_debug_graceful_restart;
 unsigned long conf_bgp_debug_evpn_mh;
+unsigned long conf_bgp_debug_bfd;
 
 unsigned long term_bgp_debug_as4;
 unsigned long term_bgp_debug_neighbor_events;
@@ -86,6 +88,7 @@ unsigned long term_bgp_debug_labelpool;
 unsigned long term_bgp_debug_pbr;
 unsigned long term_bgp_debug_graceful_restart;
 unsigned long term_bgp_debug_evpn_mh;
+unsigned long term_bgp_debug_bfd;
 
 struct list *bgp_debug_neighbor_events_peers = NULL;
 struct list *bgp_debug_keepalive_peers = NULL;
@@ -2093,6 +2096,34 @@ DEFUN (no_debug_bgp_labelpool,
        return CMD_SUCCESS;
 }
 
+DEFPY(debug_bgp_bfd, debug_bgp_bfd_cmd,
+      "[no] debug bgp bfd",
+      NO_STR
+      DEBUG_STR
+      BGP_STR
+      "Bidirection Forwarding Detection\n")
+{
+       if (vty->node == CONFIG_NODE) {
+               if (no) {
+                       DEBUG_OFF(bfd, BFD_LIB);
+                       bfd_protocol_integration_set_debug(false);
+               } else {
+                       DEBUG_ON(bfd, BFD_LIB);
+                       bfd_protocol_integration_set_debug(true);
+               }
+       } else {
+               if (no) {
+                       TERM_DEBUG_OFF(bfd, BFD_LIB);
+                       bfd_protocol_integration_set_debug(false);
+               } else {
+                       TERM_DEBUG_ON(bfd, BFD_LIB);
+                       bfd_protocol_integration_set_debug(true);
+               }
+       }
+
+       return CMD_SUCCESS;
+}
+
 DEFUN (no_debug_bgp,
        no_debug_bgp_cmd,
        "no debug bgp",
@@ -2136,6 +2167,7 @@ DEFUN (no_debug_bgp,
        TERM_DEBUG_OFF(graceful_restart, GRACEFUL_RESTART);
        TERM_DEBUG_OFF(evpn_mh, EVPN_MH_ES);
        TERM_DEBUG_OFF(evpn_mh, EVPN_MH_RT);
+       TERM_DEBUG_OFF(bfd, BFD_LIB);
 
        vty_out(vty, "All possible debugging has been turned off\n");
 
@@ -2225,6 +2257,9 @@ DEFUN_NOSH (show_debugging_bgp,
        if (BGP_DEBUG(evpn_mh, EVPN_MH_RT))
                vty_out(vty, "  BGP EVPN-MH route debugging is on\n");
 
+       if (BGP_DEBUG(bfd, BFD_LIB))
+               vty_out(vty, "  BGP BFD library debugging is on\n");
+
        vty_out(vty, "\n");
        return CMD_SUCCESS;
 }
@@ -2350,6 +2385,11 @@ static int bgp_config_write_debug(struct vty *vty)
                write++;
        }
 
+       if (CONF_BGP_DEBUG(bfd, BFD_LIB)) {
+               vty_out(vty, "debug bgp bfd\n");
+               write++;
+       }
+
        return write;
 }
 
@@ -2478,6 +2518,10 @@ void bgp_debug_init(void)
 
        install_element(ENABLE_NODE, &debug_bgp_evpn_mh_cmd);
        install_element(CONFIG_NODE, &debug_bgp_evpn_mh_cmd);
+
+       /* debug bgp bfd */
+       install_element(ENABLE_NODE, &debug_bgp_bfd_cmd);
+       install_element(CONFIG_NODE, &debug_bgp_bfd_cmd);
 }
 
 /* Return true if this prefix is on the per_prefix_list of prefixes to debug
@@ -2636,10 +2680,14 @@ const char *bgp_debug_rdpfxpath2str(afi_t afi, safi_t safi,
                                    union prefixconstptr pu,
                                    mpls_label_t *label, uint32_t num_labels,
                                    int addpath_valid, uint32_t addpath_id,
+                                   struct bgp_route_evpn *overlay_index,
                                    char *str, int size)
 {
        char rd_buf[RD_ADDRSTRLEN];
        char tag_buf[30];
+       char overlay_index_buf[INET6_ADDRSTRLEN + 14];
+       const struct prefix_evpn *evp;
+
        /* ' with addpath ID '          17
         * max strlen of uint32       + 10
         * +/- (just in case)         +  1
@@ -2657,6 +2705,23 @@ const char *bgp_debug_rdpfxpath2str(afi_t afi, safi_t safi,
                snprintf(pathid_buf, sizeof(pathid_buf), " with addpath ID %u",
                         addpath_id);
 
+       overlay_index_buf[0] = '\0';
+       if (overlay_index && overlay_index->type == OVERLAY_INDEX_GATEWAY_IP) {
+               char obuf[INET6_ADDRSTRLEN];
+
+               obuf[0] = '\0';
+               evp = pu.evp;
+               if (is_evpn_prefix_ipaddr_v4(evp))
+                       inet_ntop(AF_INET, &overlay_index->gw_ip, obuf,
+                                 sizeof(obuf));
+               else if (is_evpn_prefix_ipaddr_v6(evp))
+                       inet_ntop(AF_INET6, &overlay_index->gw_ip, obuf,
+                                 sizeof(obuf));
+
+               snprintf(overlay_index_buf, sizeof(overlay_index_buf),
+                        " gateway IP %s", obuf);
+       }
+
        tag_buf[0] = '\0';
        if (bgp_labeled_safi(safi) && num_labels) {
 
@@ -2676,9 +2741,10 @@ const char *bgp_debug_rdpfxpath2str(afi_t afi, safi_t safi,
        }
 
        if (prd)
-               snprintfrr(str, size, "RD %s %pFX%s%s %s %s",
+               snprintfrr(str, size, "RD %s %pFX%s%s%s %s %s",
                           prefix_rd2str(prd, rd_buf, sizeof(rd_buf)), pu.p,
-                          tag_buf, pathid_buf, afi2str(afi), safi2str(safi));
+                          overlay_index_buf, tag_buf, pathid_buf, afi2str(afi),
+                          safi2str(safi));
        else if (safi == SAFI_FLOWSPEC) {
                char return_string[BGP_FLOWSPEC_NLRI_STRING_MAX];
                const struct prefix_fs *fs = pu.fs;