]> 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 df7262be6412e590747bf6daae4ad8bd208f167e..bfde1c127e1ec09aae6d34f74284c20f329b62f1 100644 (file)
@@ -71,6 +71,7 @@ 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;
@@ -92,6 +93,7 @@ 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;
@@ -376,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;
 
@@ -393,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);
@@ -410,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);
@@ -1408,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,
@@ -2044,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",
@@ -2182,6 +2209,7 @@ DEFUN (no_debug_bgp,
        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");
 
@@ -2278,6 +2306,12 @@ DEFUN_NOSH (show_debugging_bgp,
                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;
 }
 
@@ -2412,6 +2446,11 @@ static int bgp_config_write_debug(struct vty *vty)
                write++;
        }
 
+       if (CONF_BGP_DEBUG(optimal_route_reflection, ORR)) {
+               vty_out(vty, "debug bgp optimal-route-reflection\n");
+               write++;
+       }
+
        return write;
 }
 
@@ -2544,6 +2583,10 @@ void bgp_debug_init(void)
        /* 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