]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Optimize the path for suppressed announcements 15618/head
authorDonatas Abraitis <donatas@opensourcerouting.org>
Tue, 26 Mar 2024 11:19:17 +0000 (13:19 +0200)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Tue, 26 Mar 2024 11:26:17 +0000 (13:26 +0200)
If supress-duplicates is turned of (which is turned on by default), do not
calculate attribute hash key, that consumes CPU quite a lot.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
bgpd/bgp_updgrp_adv.c

index 989dbe43a3d1dff8613f006baee1676ff4886005..5d7a8b2ba1ade2f93f5a3aba541f30f8918b836f 100644 (file)
@@ -532,7 +532,7 @@ bool bgp_adj_out_set_subgroup(struct bgp_dest *dest,
        struct peer *adv_peer;
        struct peer_af *paf;
        struct bgp *bgp;
-       uint32_t attr_hash = attrhash_key_make(attr);
+       uint32_t attr_hash = 0;
 
        peer = SUBGRP_PEER(subgrp);
        afi = SUBGRP_AFI(subgrp);
@@ -567,9 +567,11 @@ bool bgp_adj_out_set_subgroup(struct bgp_dest *dest,
         * the route wasn't changed actually.
         * Do not suppress BGP UPDATES for route-refresh.
         */
-       if (CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES)
-           && !CHECK_FLAG(subgrp->sflags, SUBGRP_STATUS_FORCE_UPDATES)
-           && adj->attr_hash == attr_hash) {
+       if (likely(CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES)))
+               attr_hash = attrhash_key_make(attr);
+
+       if (!CHECK_FLAG(subgrp->sflags, SUBGRP_STATUS_FORCE_UPDATES) &&
+           attr_hash && adj->attr_hash == attr_hash) {
                if (BGP_DEBUG(update, UPDATE_OUT)) {
                        char attr_str[BUFSIZ] = {0};