]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: remove bgp_attr_undup
authorIgor Ryzhov <iryzhov@nfware.com>
Wed, 9 Feb 2022 22:43:37 +0000 (01:43 +0300)
committerIgor Ryzhov <iryzhov@nfware.com>
Wed, 9 Feb 2022 22:43:37 +0000 (01:43 +0300)
bgp_attr_undup does the same thing as bgp_attr_flush – frees the
temporary data that might be allocated when applying a route-map. There
is no need to have two separate functions for that.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
bgpd/bgp_attr.c
bgpd/bgp_attr.h
bgpd/bgp_route.c
bgpd/bgp_updgrp_adv.c

index 3c3fd174f66b5892a5e0880a6f51ccfaa70d95e0..97ff4caca55a3b331ae167385407c0c264ea0530 100644 (file)
@@ -1149,43 +1149,6 @@ void bgp_attr_unintern_sub(struct attr *attr)
                srv6_vpn_unintern(&attr->srv6_vpn);
 }
 
-/*
- * We have some show commands that let you experimentally
- * apply a route-map.  When we apply the route-map
- * we are reseting values but not saving them for
- * posterity via intern'ing( because route-maps don't
- * do that) but at this point in time we need
- * to compare the new attr to the old and if the
- * routemap has changed it we need to, as Snoop Dog says,
- * Drop it like it's hot
- */
-void bgp_attr_undup(struct attr *new, struct attr *old)
-{
-       struct ecommunity *ecomm = bgp_attr_get_ecommunity(new);
-
-       if (new->aspath != old->aspath)
-               aspath_free(new->aspath);
-
-       if (new->community != old->community)
-               community_free(&new->community);
-
-       if (ecomm != bgp_attr_get_ecommunity(old))
-               ecommunity_free(&ecomm);
-
-       if (new->lcommunity != old->lcommunity)
-               lcommunity_free(&new->lcommunity);
-
-       if (new->srv6_l3vpn != old->srv6_l3vpn) {
-               srv6_l3vpn_free(new->srv6_l3vpn);
-               new->srv6_l3vpn = NULL;
-       }
-
-       if (new->srv6_vpn != old->srv6_vpn) {
-               srv6_vpn_free(new->srv6_vpn);
-               new->srv6_vpn = NULL;
-       }
-}
-
 /* Free bgp attribute and aspath. */
 void bgp_attr_unintern(struct attr **pattr)
 {
index 2cf332574b49b444d049c983d37aa976e23c9635..b38cbf8ef8eff136ae3ec99a59cd7543a9d4edac 100644 (file)
@@ -394,7 +394,6 @@ extern void bgp_attr_finish(void);
 extern bgp_attr_parse_ret_t bgp_attr_parse(struct peer *, struct attr *,
                                           bgp_size_t, struct bgp_nlri *,
                                           struct bgp_nlri *);
-extern void bgp_attr_undup(struct attr *new, struct attr *old);
 extern struct attr *bgp_attr_intern(struct attr *attr);
 extern void bgp_attr_unintern_sub(struct attr *);
 extern void bgp_attr_unintern(struct attr **);
index 5bc2b8737edfe40a9ce5fed603f836417133d951..5ca4cee159c4a0f1a78123c2979a8d9b888ad0dc 100644 (file)
@@ -3386,7 +3386,7 @@ static uint32_t bgp_filtered_routes_count(struct peer *peer, afi_t afi,
                        if (filtered)
                                count++;
 
-                       bgp_attr_undup(&attr, ain->attr);
+                       bgp_attr_flush(&attr);
                }
        }
 
@@ -13590,7 +13590,7 @@ show_adj_route(struct vty *vty, struct peer *peer, struct bgp_table *table,
 
                                if (type == bgp_show_adj_route_filtered &&
                                        !route_filtered && ret != RMAP_DENY) {
-                                       bgp_attr_undup(&attr, ain->attr);
+                                       bgp_attr_flush(&attr);
                                        continue;
                                }
 
@@ -13600,7 +13600,7 @@ show_adj_route(struct vty *vty, struct peer *peer, struct bgp_table *table,
 
                                route_vty_out_tmp(vty, dest, rn_p, &attr, safi,
                                                  use_json, json_ar, wide);
-                               bgp_attr_undup(&attr, ain->attr);
+                               bgp_attr_flush(&attr);
                                (*output_count)++;
                        }
                } else if (type == bgp_show_adj_route_advertised) {
@@ -13648,7 +13648,7 @@ show_adj_route(struct vty *vty, struct peer *peer, struct bgp_table *table,
                                                (*filtered_count)++;
                                        }
 
-                                       bgp_attr_undup(&attr, adj->attr);
+                                       bgp_attr_flush(&attr);
                                }
                } else if (type == bgp_show_adj_route_bestpath) {
                        struct bgp_path_info *pi;
index 2110dcb8bc40eb4c3bc22bbe6742e1604dc35725..dd140e48afef3d230f8243bbb984601b88e0db18 100644 (file)
@@ -859,7 +859,7 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
                                        bgp_dest_get_prefix(dest), pi, &tmp_pi);
 
                                if (ret == RMAP_DENYMATCH) {
-                                       bgp_attr_undup(&tmp_attr, &attr);
+                                       bgp_attr_flush(&tmp_attr);
                                        continue;
                                } else {
                                        new_attr = bgp_attr_intern(&tmp_attr);