]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Avoid memset when tip hash is empty
authorDonald Sharp <sharpd@nvidia.com>
Wed, 16 Sep 2020 21:48:15 +0000 (17:48 -0400)
committerIgor Ryzhov <iryzhov@nfware.com>
Tue, 6 Oct 2020 12:54:24 +0000 (15:54 +0300)
The tip hash is only used when we are dealing with
evpn.  In bgp_nexthop_self we are doing a memset
irrelevant of whether we will ever find data.  Yes
hash_lookup will return pretty quickly.

Modify the code to avoid doing a memset in the case
where the tip hash is empty as that we know we'll
never find anything.  With full BGP feeds this
small memset does take some time.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
bgpd/bgp_nexthop.c

index ed026a2fffe76afadf980d61b4fefcab017316fa..0d8214e4d6ea7b87a82623d395f4f52dd2085eab 100644 (file)
@@ -563,7 +563,7 @@ bool bgp_nexthop_self(struct bgp *bgp, afi_t afi, uint8_t type,
        if (addr)
                return true;
 
-       if (new_afi == AF_INET) {
+       if (new_afi == AF_INET && hashcount(bgp->tip_hash)) {
                memset(&tmp_tip, 0, sizeof(struct tip_addr));
                tmp_tip.addr = attr->nexthop;