From 3584c85e92b8edfb3a306d26844066bb741a2074 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 16 Sep 2020 17:48:15 -0400 Subject: [PATCH] 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 --- bgpd/bgp_nexthop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- 2.39.5