]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: When we don't have a route-map to apply don't apply the original
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 25 Oct 2017 00:23:06 +0000 (20:23 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 27 Nov 2017 13:21:56 +0000 (08:21 -0500)
When we display the advertised-routes and we don't have a route-map
to apply do not re-apply the route-map.  This does two things:

1) Fixes a display issue with the show command.
2) More importantly stops leaking memory like a sieve for when
   you have a full bgp table.

Fixes: #1345
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
bgpd/bgp_route.c

index cc7b80df8271fe166cfac6bd37188aa90dc6c8f4..3a7cfc4f2cfabe87c9e1829d8f6abeab48f11b05 100644 (file)
@@ -1157,49 +1157,50 @@ static int bgp_output_modifier(struct peer *peer, struct prefix *p,
                               struct attr *attr, afi_t afi, safi_t safi,
                               const char *rmap_name)
 {
-       struct bgp_filter *filter;
        struct bgp_info info;
        route_map_result_t ret;
        struct route_map *rmap = NULL;
 
-       filter = &peer->filter[afi][safi];
+       /*
+        * So if we get to this point and have no rmap_name
+        * we want to just show the output as it currently
+        * exists.
+        */
+       if (!rmap_name)
+               return RMAP_PERMIT;
 
        /* Apply default weight value. */
        if (peer->weight[afi][safi])
                attr->weight = peer->weight[afi][safi];
 
-       if (rmap_name) {
-               rmap = route_map_lookup_by_name(rmap_name);
+       rmap = route_map_lookup_by_name(rmap_name);
 
-               if (rmap == NULL)
-                       return RMAP_DENY;
-       } else {
-               if (ROUTE_MAP_OUT_NAME(filter)) {
-                       rmap = ROUTE_MAP_OUT(filter);
-
-                       if (rmap == NULL)
-                               return RMAP_DENY;
-               }
-       }
+       /*
+        * If we have a route map name and we do not find
+        * the routemap that means we have an implicit
+        * deny.
+        */
+       if (rmap == NULL)
+               return RMAP_DENY;
 
        /* Route map apply. */
-       if (rmap) {
-               /* Duplicate current value to new strucutre for modification. */
-               info.peer = peer;
-               info.attr = attr;
+       /* Duplicate current value to new strucutre for modification. */
+       info.peer = peer;
+       info.attr = attr;
 
-               SET_FLAG(peer->rmap_type, PEER_RMAP_TYPE_OUT);
+       SET_FLAG(peer->rmap_type, PEER_RMAP_TYPE_OUT);
 
-               /* Apply BGP route map to the attribute. */
-               ret = route_map_apply(rmap, p, RMAP_BGP, &info);
+       /* Apply BGP route map to the attribute. */
+       ret = route_map_apply(rmap, p, RMAP_BGP, &info);
 
-               peer->rmap_type = 0;
+       peer->rmap_type = 0;
+
+       if (ret == RMAP_DENYMATCH)
+               /*
+                * caller has multiple error paths with bgp_attr_flush()
+                */
+               return RMAP_DENY;
 
-               if (ret == RMAP_DENYMATCH)
-                       /* caller has multiple error paths with bgp_attr_flush()
-                        */
-                       return RMAP_DENY;
-       }
        return RMAP_PERMIT;
 }