From: Donald Sharp Date: Wed, 16 Sep 2020 21:48:15 +0000 (-0400) Subject: bgpd: Avoid memset when tip hash is empty X-Git-Tag: base_7.6~549^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=3584c85e92b8edfb3a306d26844066bb741a2074;p=matthieu%2Ffrr.git bgpd: Avoid memset when tip hash is empty 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 --- diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c index ed026a2fff..0d8214e4d6 100644 --- a/bgpd/bgp_nexthop.c +++ b/bgpd/bgp_nexthop.c @@ -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;