]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_debug.c
bgpd: fix the IGP metric for best path selection on VPN import
[mirror_frr.git] / bgpd / bgp_debug.c
index 8976b3b674eb00960d4e4fbaf1235920fba3a8f5..bfde1c127e1ec09aae6d34f74284c20f329b62f1 100644 (file)
@@ -70,6 +70,8 @@ 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 conf_bgp_debug_cond_adv;
+unsigned long conf_bgp_debug_optimal_route_reflection;
 
 unsigned long term_bgp_debug_as4;
 unsigned long term_bgp_debug_neighbor_events;
@@ -90,6 +92,8 @@ 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;
+unsigned long term_bgp_debug_cond_adv;
+unsigned long term_bgp_debug_optimal_route_reflection;
 
 struct list *bgp_debug_neighbor_events_peers = NULL;
 struct list *bgp_debug_keepalive_peers = NULL;
@@ -141,6 +145,7 @@ static const struct message bgp_notify_open_msg[] = {
        {BGP_NOTIFY_OPEN_AUTH_FAILURE, "/Authentication Failure"},
        {BGP_NOTIFY_OPEN_UNACEP_HOLDTIME, "/Unacceptable Hold Time"},
        {BGP_NOTIFY_OPEN_UNSUP_CAPBL, "/Unsupported Capability"},
+       {BGP_NOTIFY_OPEN_ROLE_MISMATCH, "/Role Mismatch"},
        {0}};
 
 static const struct message bgp_notify_update_msg[] = {
@@ -373,8 +378,6 @@ bool bgp_debug_peer_updout_enabled(char *host)
 /* Dump attribute. */
 bool bgp_dump_attr(struct attr *attr, char *buf, size_t size)
 {
-       char addrbuf[BUFSIZ];
-
        if (!attr)
                return false;
 
@@ -390,15 +393,12 @@ bool bgp_dump_attr(struct attr *attr, char *buf, size_t size)
        /* Add MP case. */
        if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL
            || attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL)
-               snprintf(buf + strlen(buf), size - strlen(buf),
-                        ", mp_nexthop %s",
-                        inet_ntop(AF_INET6, &attr->mp_nexthop_global, addrbuf,
-                                  BUFSIZ));
+               snprintfrr(buf + strlen(buf), size - strlen(buf),
+                          ", mp_nexthop %pI6", &attr->mp_nexthop_global);
 
        if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL)
-               snprintf(buf + strlen(buf), size - strlen(buf), "(%s)",
-                        inet_ntop(AF_INET6, &attr->mp_nexthop_local, addrbuf,
-                                  BUFSIZ));
+               snprintfrr(buf + strlen(buf), size - strlen(buf), "(%pI6)",
+                          &attr->mp_nexthop_local);
 
        if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV4)
                snprintfrr(buf, size, "nexthop %pI4", &attr->nexthop);
@@ -407,6 +407,11 @@ bool bgp_dump_attr(struct attr *attr, char *buf, size_t size)
                snprintf(buf + strlen(buf), size - strlen(buf),
                         ", localpref %u", attr->local_pref);
 
+       if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_AIGP)))
+               snprintf(buf + strlen(buf), size - strlen(buf),
+                        ", aigp-metric %" PRIu64,
+                        (unsigned long long)bgp_attr_get_aigp_metric(attr));
+
        if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)))
                snprintf(buf + strlen(buf), size - strlen(buf), ", metric %u",
                         attr->med);
@@ -1405,9 +1410,7 @@ DEFUN (no_debug_bgp_update_direct_peer,
        return CMD_SUCCESS;
 }
 
-#ifndef VTYSH_EXTRACT_PL
 #include "bgpd/bgp_debug_clippy.c"
-#endif
 
 DEFPY (debug_bgp_update_prefix_afi_safi,
        debug_bgp_update_prefix_afi_safi_cmd,
@@ -1809,40 +1812,6 @@ DEFUN (no_debug_bgp_zebra_prefix,
        return CMD_SUCCESS;
 }
 
-DEFUN (debug_bgp_allow_martians,
-       debug_bgp_allow_martians_cmd,
-       "debug bgp allow-martians",
-       DEBUG_STR
-       BGP_STR
-       "BGP allow martian next hops\n")
-{
-       if (vty->node == CONFIG_NODE)
-               DEBUG_ON(allow_martians, ALLOW_MARTIANS);
-       else {
-               TERM_DEBUG_ON(allow_martians, ALLOW_MARTIANS);
-               vty_out(vty, "BGP allow_martian next hop debugging is on\n");
-       }
-       return CMD_SUCCESS;
-}
-
-DEFUN (no_debug_bgp_allow_martians,
-       no_debug_bgp_allow_martians_cmd,
-       "no debug bgp allow-martians",
-       NO_STR
-       DEBUG_STR
-       BGP_STR
-       "BGP allow martian next hops\n")
-{
-       if (vty->node == CONFIG_NODE)
-               DEBUG_OFF(allow_martians, ALLOW_MARTIANS);
-       else {
-               TERM_DEBUG_OFF(allow_martians, ALLOW_MARTIANS);
-               vty_out(vty, "BGP allow martian next hop debugging is off\n");
-       }
-       return CMD_SUCCESS;
-}
-
-
 /* debug bgp update-groups */
 DEFUN (debug_bgp_update_groups,
        debug_bgp_update_groups_cmd,
@@ -2075,6 +2044,33 @@ DEFPY (debug_bgp_evpn_mh,
        return CMD_SUCCESS;
 }
 
+DEFPY (debug_bgp_optimal_route_reflection,
+       debug_bgp_optimal_route_reflection_cmd,
+       "[no$no] debug bgp optimal-route-reflection",
+       NO_STR
+       DEBUG_STR
+       BGP_STR
+       BGP_ORR_DEBUG)
+{
+       if (vty->node == CONFIG_NODE) {
+               if (no)
+                       DEBUG_OFF(optimal_route_reflection, ORR);
+               else
+                       DEBUG_ON(optimal_route_reflection, ORR);
+       } else {
+               if (no) {
+                       TERM_DEBUG_OFF(optimal_route_reflection, ORR);
+                       vty_out(vty,
+                               "BGP Optimal Route Reflection debugging is off\n");
+               } else {
+                       TERM_DEBUG_ON(optimal_route_reflection, ORR);
+                       vty_out(vty,
+                               "BGP Optimal Route Reflection debugging is on\n");
+               }
+       }
+       return CMD_SUCCESS;
+}
+
 DEFUN (debug_bgp_labelpool,
        debug_bgp_labelpool_cmd,
        "debug bgp labelpool",
@@ -2141,6 +2137,33 @@ DEFPY(debug_bgp_bfd, debug_bgp_bfd_cmd,
        return CMD_SUCCESS;
 }
 
+DEFPY (debug_bgp_cond_adv,
+       debug_bgp_cond_adv_cmd,
+       "[no$no] debug bgp conditional-advertisement",
+       NO_STR
+       DEBUG_STR
+       BGP_STR
+       "BGP conditional advertisement\n")
+{
+       if (vty->node == CONFIG_NODE) {
+               if (no)
+                       DEBUG_OFF(cond_adv, COND_ADV);
+               else
+                       DEBUG_ON(cond_adv, COND_ADV);
+       } else {
+               if (no) {
+                       TERM_DEBUG_OFF(cond_adv, COND_ADV);
+                       vty_out(vty,
+                               "BGP conditional advertisement debugging is off\n");
+               } else {
+                       TERM_DEBUG_ON(cond_adv, COND_ADV);
+                       vty_out(vty,
+                               "BGP conditional advertisement debugging is on\n");
+               }
+       }
+       return CMD_SUCCESS;
+}
+
 DEFUN (no_debug_bgp,
        no_debug_bgp_cmd,
        "no debug bgp",
@@ -2185,6 +2208,8 @@ DEFUN (no_debug_bgp,
        TERM_DEBUG_OFF(evpn_mh, EVPN_MH_ES);
        TERM_DEBUG_OFF(evpn_mh, EVPN_MH_RT);
        TERM_DEBUG_OFF(bfd, BFD_LIB);
+       TERM_DEBUG_OFF(cond_adv, COND_ADV);
+       TERM_DEBUG_OFF(optimal_route_reflection, ORR);
 
        vty_out(vty, "All possible debugging has been turned off\n");
 
@@ -2277,6 +2302,16 @@ DEFUN_NOSH (show_debugging_bgp,
        if (BGP_DEBUG(bfd, BFD_LIB))
                vty_out(vty, "  BGP BFD library debugging is on\n");
 
+       if (BGP_DEBUG(cond_adv, COND_ADV))
+               vty_out(vty,
+                       "  BGP conditional advertisement debugging is on\n");
+
+       if (BGP_DEBUG(optimal_route_reflection, ORR))
+               vty_out(vty,
+                       "  BGP Optimal Route Reflection debugging is on\n");
+
+       cmd_show_lib_debugs(vty);
+
        return CMD_SUCCESS;
 }
 
@@ -2406,6 +2441,16 @@ static int bgp_config_write_debug(struct vty *vty)
                write++;
        }
 
+       if (CONF_BGP_DEBUG(cond_adv, COND_ADV)) {
+               vty_out(vty, "debug bgp conditional-advertisement\n");
+               write++;
+       }
+
+       if (CONF_BGP_DEBUG(optimal_route_reflection, ORR)) {
+               vty_out(vty, "debug bgp optimal-route-reflection\n");
+               write++;
+       }
+
        return write;
 }
 
@@ -2438,8 +2483,6 @@ void bgp_debug_init(void)
        install_element(CONFIG_NODE, &debug_bgp_update_cmd);
        install_element(ENABLE_NODE, &debug_bgp_zebra_cmd);
        install_element(CONFIG_NODE, &debug_bgp_zebra_cmd);
-       install_element(ENABLE_NODE, &debug_bgp_allow_martians_cmd);
-       install_element(CONFIG_NODE, &debug_bgp_allow_martians_cmd);
        install_element(ENABLE_NODE, &debug_bgp_update_groups_cmd);
        install_element(CONFIG_NODE, &debug_bgp_update_groups_cmd);
        install_element(ENABLE_NODE, &debug_bgp_bestpath_prefix_cmd);
@@ -2503,8 +2546,6 @@ void bgp_debug_init(void)
        install_element(CONFIG_NODE, &no_debug_bgp_update_cmd);
        install_element(ENABLE_NODE, &no_debug_bgp_zebra_cmd);
        install_element(CONFIG_NODE, &no_debug_bgp_zebra_cmd);
-       install_element(ENABLE_NODE, &no_debug_bgp_allow_martians_cmd);
-       install_element(CONFIG_NODE, &no_debug_bgp_allow_martians_cmd);
        install_element(ENABLE_NODE, &no_debug_bgp_update_groups_cmd);
        install_element(CONFIG_NODE, &no_debug_bgp_update_groups_cmd);
        install_element(ENABLE_NODE, &no_debug_bgp_cmd);
@@ -2538,6 +2579,14 @@ void bgp_debug_init(void)
        /* debug bgp bfd */
        install_element(ENABLE_NODE, &debug_bgp_bfd_cmd);
        install_element(CONFIG_NODE, &debug_bgp_bfd_cmd);
+
+       /* debug bgp conditional advertisement */
+       install_element(ENABLE_NODE, &debug_bgp_cond_adv_cmd);
+       install_element(CONFIG_NODE, &debug_bgp_cond_adv_cmd);
+
+       /* debug bgp optimal route reflection */
+       install_element(ENABLE_NODE, &debug_bgp_optimal_route_reflection_cmd);
+       install_element(CONFIG_NODE, &debug_bgp_optimal_route_reflection_cmd);
 }
 
 /* Return true if this prefix is on the per_prefix_list of prefixes to debug
@@ -2699,7 +2748,6 @@ const char *bgp_debug_rdpfxpath2str(afi_t afi, safi_t safi,
                                    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;
@@ -2757,8 +2805,7 @@ const char *bgp_debug_rdpfxpath2str(afi_t afi, safi_t safi,
        }
 
        if (prd)
-               snprintfrr(str, size, "RD %s %pFX%s%s%s %s %s",
-                          prefix_rd2str(prd, rd_buf, sizeof(rd_buf)), pu.p,
+               snprintfrr(str, size, "RD %pRD %pFX%s%s%s %s %s", prd, pu.p,
                           overlay_index_buf, tag_buf, pathid_buf, afi2str(afi),
                           safi2str(safi));
        else if (safi == SAFI_FLOWSPEC) {