]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_route.c
bgpd: Add peer action for PEER_FLAG_IFPEER_V6ONLY flag
[mirror_frr.git] / bgpd / bgp_route.c
index 862665814922842cb27d7c4eb2d585f2207b1b73..9fa0aaa4fd7cbfd5ad4600fe56934411006baee4 100644 (file)
@@ -38,6 +38,7 @@
 #include "queue.h"
 #include "memory.h"
 #include "lib/json.h"
+#include "lib_errors.h"
 
 #include "bgpd/bgpd.h"
 #include "bgpd/bgp_table.h"
@@ -353,12 +354,9 @@ static void bgp_pcount_adjust(struct bgp_node *rn, struct bgp_info *ri)
                /* slight hack, but more robust against errors. */
                if (ri->peer->pcount[table->afi][table->safi])
                        ri->peer->pcount[table->afi][table->safi]--;
-               else {
-                       zlog_warn(
-                               "%s: Asked to decrement 0 prefix count for peer %s",
-                               __func__, ri->peer->host);
-                       zlog_backtrace(LOG_WARNING);
-               }
+               else
+                       flog_err(LIB_ERR_DEVELOPMENT,
+                                "Asked to decrement 0 prefix count for peer");
        } else if (BGP_INFO_COUNTABLE(ri)
                   && !CHECK_FLAG(ri->flags, BGP_INFO_COUNTED)) {
                SET_FLAG(ri->flags, BGP_INFO_COUNTED);
@@ -1052,8 +1050,8 @@ static enum filter_type bgp_input_filter(struct peer *peer, struct prefix *p,
 
 #define FILTER_EXIST_WARN(F, f, filter)                                        \
        if (BGP_DEBUG(update, UPDATE_IN) && !(F##_IN(filter)))                 \
-               zlog_warn("%s: Could not find configured input %s-list %s!",   \
-                         peer->host, #f, F##_IN_NAME(filter));
+               zlog_debug("%s: Could not find configured input %s-list %s!",  \
+                          peer->host, #f, F##_IN_NAME(filter));
 
        if (DISTRIBUTE_IN_NAME(filter)) {
                FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter);
@@ -1091,8 +1089,8 @@ static enum filter_type bgp_output_filter(struct peer *peer, struct prefix *p,
 
 #define FILTER_EXIST_WARN(F, f, filter)                                        \
        if (BGP_DEBUG(update, UPDATE_OUT) && !(F##_OUT(filter)))               \
-               zlog_warn("%s: Could not find configured output %s-list %s!",  \
-                         peer->host, #f, F##_OUT_NAME(filter));
+               zlog_debug("%s: Could not find configured output %s-list %s!", \
+                          peer->host, #f, F##_OUT_NAME(filter));
 
        if (DISTRIBUTE_OUT_NAME(filter)) {
                FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter);
@@ -5458,7 +5456,8 @@ static void bgp_aggregate_free(struct bgp_aggregate *aggregate)
        XFREE(MTYPE_BGP_AGGREGATE, aggregate);
 }
 
-static int bgp_aggregate_info_same(struct bgp_info *ri, struct aspath *aspath,
+static int bgp_aggregate_info_same(struct bgp_info *ri, uint8_t origin,
+                                  struct aspath *aspath,
                                   struct community *comm)
 {
        static struct aspath *ae = NULL;
@@ -5469,6 +5468,9 @@ static int bgp_aggregate_info_same(struct bgp_info *ri, struct aspath *aspath,
        if (!ri)
                return 0;
 
+       if (origin != ri->attr->origin)
+               return 0;
+
        if (!aspath_cmp(ri->attr->aspath, (aspath) ? aspath : ae))
                return 0;
 
@@ -5503,7 +5505,8 @@ static void bgp_aggregate_install(struct bgp *bgp, afi_t afi, safi_t safi,
                 * If the aggregate information has not changed
                 * no need to re-install it again.
                 */
-               if (bgp_aggregate_info_same(rn->info, aspath, community)) {
+               if (bgp_aggregate_info_same(rn->info, origin, aspath,
+                                           community)) {
                        bgp_unlock_node(rn);
 
                        if (aspath)
@@ -8583,9 +8586,19 @@ void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp,
        int count = 0;
        int best = 0;
        int suppress = 0;
+       int accept_own = 0;
+       int route_filter_translated_v4 = 0;
+       int route_filter_v4 = 0;
+       int route_filter_translated_v6 = 0;
+       int route_filter_v6 = 0;
+       int llgr_stale = 0;
+       int no_llgr = 0;
+       int accept_own_nexthop = 0;
+       int blackhole = 0;
        int no_export = 0;
        int no_advertise = 0;
        int local_as = 0;
+       int no_peer = 0;
        int first = 1;
        int has_valid_label = 0;
        mpls_label_t label = 0;
@@ -8662,12 +8675,41 @@ void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp,
                } else
                        vty_out(vty, ", no best path");
 
-               if (no_advertise)
-                       vty_out(vty, ", not advertised to any peer");
+               if (accept_own)
+                       vty_out(vty,
+                       ", accept own local route exported and imported in different VRF");
+               else if (route_filter_translated_v4)
+                       vty_out(vty,
+                       ", mark translated RTs for VPNv4 route filtering");
+               else if (route_filter_v4)
+                       vty_out(vty,
+                       ", attach RT as-is for VPNv4 route filtering");
+               else if (route_filter_translated_v6)
+                       vty_out(vty,
+                       ", mark translated RTs for VPNv6 route filtering");
+               else if (route_filter_v6)
+                       vty_out(vty,
+                       ", attach RT as-is for VPNv6 route filtering");
+               else if (llgr_stale)
+                       vty_out(vty,
+                       ", mark routes to be retained for a longer time. Requeres support for Long-lived BGP Graceful Restart");
+               else if (no_llgr)
+                       vty_out(vty,
+                       ", mark routes to not be treated according to Long-lived BGP Graceful Restart operations");
+               else if (accept_own_nexthop)
+                       vty_out(vty,
+                       ", accept local nexthop");
+               else if (blackhole)
+                       vty_out(vty, ", inform peer to blackhole prefix");
                else if (no_export)
                        vty_out(vty, ", not advertised to EBGP peer");
+               else if (no_advertise)
+                       vty_out(vty, ", not advertised to any peer");
                else if (local_as)
                        vty_out(vty, ", not advertised outside local AS");
+               else if (no_peer)
+                       vty_out(vty,
+                       ", inform EBGP peer not to advertise to their EBGP peers");
 
                if (suppress)
                        vty_out(vty,
@@ -9028,6 +9070,10 @@ DEFUN (show_ip_bgp,
            |prefix-list WORD\
            |filter-list WORD\
            |statistics\
+           |community <AA:NN|local-AS|no-advertise|no-export|graceful-shutdown\
+           no-peer|blackhole|llgr-stale|no-llgr|accept-own|accept-own-nexthop\
+           route-filter-v6|route-filter-v4|route-filter-translated-v6|\
+           route-filter-translated-v4> [exact-match]\
            |community-list <(1-500)|WORD> [exact-match]\
            |A.B.C.D/M longer-prefixes\
            |X:X::X:X/M longer-prefixes\
@@ -9047,6 +9093,23 @@ DEFUN (show_ip_bgp,
        "Display routes conforming to the filter-list\n"
        "Regular expression access list name\n"
        "BGP RIB advertisement statistics\n"
+       "Display routes matching the communities\n"
+       COMMUNITY_AANN_STR
+       "Do not send outside local AS (well-known community)\n"
+       "Do not advertise to any peer (well-known community)\n"
+       "Do not export to next AS (well-known community)\n"
+       "Graceful shutdown (well-known community)\n"
+       "Do not export to any peer (well-known community)\n"
+       "Inform EBGP peers to blackhole traffic to prefix (well-known community)\n"
+       "Staled Long-lived Graceful Restart VPN route (well-known community)\n"
+       "Removed because Long-lived Graceful Restart was not enabled for VPN route (well-known community)\n"
+       "Should accept local VPN route if exported and imported into different VRF (well-known community)\n"
+       "Should accept VPN route with local nexthop (well-known community)\n"
+       "RT VPNv6 route filtering (well-known community)\n"
+       "RT VPNv4 route filtering (well-known community)\n"
+       "RT translated VPNv6 route filtering (well-known community)\n"
+       "RT translated VPNv4 route filtering (well-known community)\n"
+       "Exact match of the communities\n"
        "Display routes matching the community-list\n"
        "community-list number\n"
        "community-list name\n"
@@ -9807,8 +9870,6 @@ static int bgp_peer_count_walker(struct thread *t)
                                pc->count[PCOUNT_ADJ_IN]++;
 
                for (ri = rn->info; ri; ri = ri->next) {
-                       char buf[SU_ADDRSTRLEN];
-
                        if (ri->peer != peer)
                                continue;
 
@@ -9830,22 +9891,12 @@ static int bgp_peer_count_walker(struct thread *t)
                        if (CHECK_FLAG(ri->flags, BGP_INFO_COUNTED)) {
                                pc->count[PCOUNT_COUNTED]++;
                                if (CHECK_FLAG(ri->flags, BGP_INFO_UNUSEABLE))
-                                       zlog_warn(
-                                               "%s [pcount] %s/%d is counted but flags 0x%x",
-                                               peer->host,
-                                               inet_ntop(rn->p.family,
-                                                         &rn->p.u.prefix, buf,
-                                                         SU_ADDRSTRLEN),
-                                               rn->p.prefixlen, ri->flags);
+                                       flog_err(LIB_ERR_DEVELOPMENT,
+                                                "Attempting to count but flags say it is unusable");
                        } else {
                                if (!CHECK_FLAG(ri->flags, BGP_INFO_UNUSEABLE))
-                                       zlog_warn(
-                                               "%s [pcount] %s/%d not counted but flags 0x%x",
-                                               peer->host,
-                                               inet_ntop(rn->p.family,
-                                                         &rn->p.u.prefix, buf,
-                                                         SU_ADDRSTRLEN),
-                                               rn->p.prefixlen, ri->flags);
+                                       flog_err(LIB_ERR_DEVELOPMENT,
+                                                "Not counted but flags say we should");
                        }
                }
        }