]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_nexthop.c
Revert "bgpd: Free only subattributes, not the whole attr_extra pointer"
[mirror_frr.git] / bgpd / bgp_nexthop.c
index 1a9f59db6441c7ee404f9006e3eaf3560c3734ee..e7bad42f9741a345f2dfe13470f6fb6626f4a8fd 100644 (file)
@@ -33,6 +33,7 @@
 #include "nexthop.h"
 #include "queue.h"
 #include "filter.h"
+#include "printfrr.h"
 
 #include "bgpd/bgpd.h"
 #include "bgpd/bgp_route.h"
@@ -413,7 +414,7 @@ void bgp_connected_add(struct bgp *bgp, struct connected *ifc)
                for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
                        if (peer->conf_if
                            && (strcmp(peer->conf_if, ifc->ifp->name) == 0)
-                           && peer->status != Established
+                           && !peer_established(peer)
                            && !CHECK_FLAG(peer->flags,
                                           PEER_FLAG_IFPEER_V6ONLY)) {
                                if (peer_active(peer))
@@ -782,7 +783,9 @@ static void bgp_show_nexthops_detail(struct vty *vty, struct bgp *bgp,
                        vty_out(vty, "  gate %s, if %s\n",
                                inet_ntop(AF_INET6, &nexthop->gate.ipv6, buf,
                                          sizeof(buf)),
-                               ifindex2ifname(nexthop->ifindex, bgp->vrf_id));
+                               ifindex2ifname(bnc->ifindex ? bnc->ifindex
+                                                           : nexthop->ifindex,
+                                              bgp->vrf_id));
                        break;
                case NEXTHOP_TYPE_IPV4:
                        vty_out(vty, "  gate %s\n",
@@ -791,13 +794,17 @@ static void bgp_show_nexthops_detail(struct vty *vty, struct bgp *bgp,
                        break;
                case NEXTHOP_TYPE_IFINDEX:
                        vty_out(vty, "  if %s\n",
-                               ifindex2ifname(nexthop->ifindex, bgp->vrf_id));
+                               ifindex2ifname(bnc->ifindex ? bnc->ifindex
+                                                           : nexthop->ifindex,
+                                              bgp->vrf_id));
                        break;
                case NEXTHOP_TYPE_IPV4_IFINDEX:
                        vty_out(vty, "  gate %s, if %s\n",
                                inet_ntop(AF_INET, &nexthop->gate.ipv4, buf,
                                          sizeof(buf)),
-                               ifindex2ifname(nexthop->ifindex, bgp->vrf_id));
+                               ifindex2ifname(bnc->ifindex ? bnc->ifindex
+                                                           : nexthop->ifindex,
+                                              bgp->vrf_id));
                        break;
                case NEXTHOP_TYPE_BLACKHOLE:
                        vty_out(vty, "  blackhole\n");
@@ -828,6 +835,18 @@ static void bgp_show_nexthop(struct vty *vty, struct bgp *bgp,
                        bnc->metric, bnc->path_count);
                if (peer)
                        vty_out(vty, ", peer %s", peer->host);
+               if (bnc->is_evpn_gwip_nexthop)
+                       vty_out(vty, " EVPN Gateway IP");
+               vty_out(vty, "\n");
+               bgp_show_nexthops_detail(vty, bgp, bnc);
+       } else if (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_EVPN_INCOMPLETE)) {
+               vty_out(vty,
+                       " %s overlay index unresolved [IGP metric %d], #paths %d",
+                       inet_ntop(bnc->prefix.family, &bnc->prefix.u.prefix,
+                                 buf, sizeof(buf)),
+                       bnc->metric, bnc->path_count);
+               if (bnc->is_evpn_gwip_nexthop)
+                       vty_out(vty, " EVPN Gateway IP");
                vty_out(vty, "\n");
                bgp_show_nexthops_detail(vty, bgp, bnc);
        } else {
@@ -837,6 +856,8 @@ static void bgp_show_nexthop(struct vty *vty, struct bgp *bgp,
                        bnc->path_count);
                if (peer)
                        vty_out(vty, ", peer %s", peer->host);
+               if (bnc->is_evpn_gwip_nexthop)
+                       vty_out(vty, " EVPN Gateway IP");
                vty_out(vty, "\n");
                if (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_CONNECTED))
                        vty_out(vty, "  Must be Connected\n");
@@ -1020,3 +1041,50 @@ void bgp_scan_finish(struct bgp *bgp)
                bgp->connected_table[afi] = NULL;
        }
 }
+
+char *bgp_nexthop_dump_bnc_flags(struct bgp_nexthop_cache *bnc, char *buf,
+                                size_t len)
+{
+       if (bnc->flags == 0) {
+               snprintfrr(buf, len, "None ");
+               return buf;
+       }
+
+       snprintfrr(buf, len, "%s%s%s%s%s%s%s",
+                  CHECK_FLAG(bnc->flags, BGP_NEXTHOP_VALID) ? "Valid " : "",
+                  CHECK_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED) ? "Reg " : "",
+                  CHECK_FLAG(bnc->flags, BGP_NEXTHOP_CONNECTED) ? "Conn " : "",
+                  CHECK_FLAG(bnc->flags, BGP_NEXTHOP_PEER_NOTIFIED) ? "Notify "
+                                                                    : "",
+                  CHECK_FLAG(bnc->flags, BGP_STATIC_ROUTE) ? "Static " : "",
+                  CHECK_FLAG(bnc->flags, BGP_STATIC_ROUTE_EXACT_MATCH)
+                          ? "Static Exact "
+                          : "",
+                  CHECK_FLAG(bnc->flags, BGP_NEXTHOP_LABELED_VALID)
+                          ? "Label Valid "
+                          : "");
+
+       return buf;
+}
+
+char *bgp_nexthop_dump_bnc_change_flags(struct bgp_nexthop_cache *bnc,
+                                       char *buf, size_t len)
+{
+       if (bnc->flags == 0) {
+               snprintfrr(buf, len, "None ");
+               return buf;
+       }
+
+       snprintfrr(buf, len, "%s%s%s",
+                  CHECK_FLAG(bnc->change_flags, BGP_NEXTHOP_CHANGED)
+                          ? "Changed "
+                          : "",
+                  CHECK_FLAG(bnc->change_flags, BGP_NEXTHOP_METRIC_CHANGED)
+                          ? "Metric "
+                          : "",
+                  CHECK_FLAG(bnc->change_flags, BGP_NEXTHOP_CONNECTED_CHANGED)
+                          ? "Connected "
+                          : "");
+
+       return buf;
+}