From: Donald Sharp Date: Sat, 16 Mar 2024 00:42:39 +0000 (-0400) Subject: bgpd: Optimize the usage of jhash X-Git-Tag: base_10.3~289^2~2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=a7f223636f046be7c5a2b99d719e60bdee50b037;p=matthieu%2Ffrr.git bgpd: Optimize the usage of jhash There are a bunch of jhash_1word uses. Let's convert to jhash_3word and get rid of some calls. Signed-off-by: Donald Sharp --- diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index b62319b211..209dcd2288 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -697,14 +697,9 @@ static uint32_t srv6_l3vpn_hash_key_make(const void *p) uint32_t key = 0; key = jhash(&l3vpn->sid, 16, key); - key = jhash_1word(l3vpn->sid_flags, key); - key = jhash_1word(l3vpn->endpoint_behavior, key); - key = jhash_1word(l3vpn->loc_block_len, key); - key = jhash_1word(l3vpn->loc_node_len, key); - key = jhash_1word(l3vpn->func_len, key); - key = jhash_1word(l3vpn->arg_len, key); - key = jhash_1word(l3vpn->transposition_len, key); - key = jhash_1word(l3vpn->transposition_offset, key); + key = jhash_3words(l3vpn->sid_flags, l3vpn->endpoint_behavior, l3vpn->loc_block_len, key); + key = jhash_3words(l3vpn->loc_node_len, l3vpn->func_len, l3vpn->arg_len, key); + key = jhash_2words(l3vpn->transposition_len, l3vpn->transposition_offset, key); return key; } @@ -863,15 +858,11 @@ unsigned int attrhash_key_make(const void *p) if (vnc_subtlvs) MIX(encap_hash_key_make(vnc_subtlvs)); #endif - MIX(attr->mp_nexthop_len); + MIX3(attr->mp_nexthop_len, attr->rmap_table_id, attr->nh_type); key = jhash(attr->mp_nexthop_global.s6_addr, IPV6_MAX_BYTELEN, key); key = jhash(attr->mp_nexthop_local.s6_addr, IPV6_MAX_BYTELEN, key); MIX3(attr->nh_ifindex, attr->nh_lla_ifindex, attr->distance); - MIX(attr->rmap_table_id); - MIX(attr->nh_type); - MIX(attr->bh_type); - MIX(attr->otc); - MIX(bgp_attr_get_aigp_metric(attr)); + MIX3(attr->bh_type, attr->otc, bgp_attr_get_aigp_metric(attr)); return key; }