]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: fix missing bgp_attr_flush on errors in bgp_update
authorIgor Ryzhov <iryzhov@nfware.com>
Wed, 9 Feb 2022 22:15:57 +0000 (01:15 +0300)
committermergify-bot <noreply@mergify.com>
Thu, 10 Feb 2022 06:54:07 +0000 (06:54 +0000)
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
(cherry picked from commit 4dbf2038ea76f8ee697f9ec0d8f9aa5e7e5e69d9)

bgpd/bgp_route.c

index 0044292433b01bdfb1773276fd28da70fab399bc..766f026085ea02780c5f74bcb86926abec852636 100644 (file)
@@ -3812,6 +3812,7 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
        if (bgp_mac_entry_exists(p) || bgp_mac_exist(&attr->rmac)) {
                peer->stat_pfx_nh_invalid++;
                reason = "self mac;";
+               bgp_attr_flush(&new_attr);
                goto filtered;
        }
 
@@ -3828,13 +3829,15 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
            && (!CHECK_FLAG(dest->flags, BGP_NODE_FIB_INSTALLED)))
                SET_FLAG(dest->flags, BGP_NODE_FIB_INSTALL_PENDING);
 
-       attr_new = bgp_attr_intern(&new_attr);
-
        /* If maximum prefix count is configured and current prefix
         * count exeed it.
         */
-       if (bgp_maximum_prefix_overflow(peer, afi, safi, 0))
+       if (bgp_maximum_prefix_overflow(peer, afi, safi, 0)) {
+               bgp_attr_flush(&new_attr);
                return -1;
+       }
+
+       attr_new = bgp_attr_intern(&new_attr);
 
        /* If the update is implicit withdraw. */
        if (pi) {