Hi again Anthony, I'm still having a few comments, but I think nothing that I cannot address while merging it:
On Wed, Mar 13, 2024 at 12:33:54PM -0400, Anthony Deschamps wrote: > +static inline u32 chash_compute_server_key(struct server *s) > +{ > + u32 key = 0; > + struct server_inetaddr srv_addr; > + > + enum srv_hash_key hash_key = s->hash_key; In general, it's better to prefer the common "reverse christmas tree" declaration order, i.e. put larger statements first and smaller next, and more importantly not leave empty lines in the middle of declarations as these usually indicate the beginning of statements. > + > + /* If hash-key is addr or addr-port then we need the address, but if we > + * can't determine the address then we fall back on hashing the puid. > + */ > + switch (s->hash_key) { Here I initially got confused by the use of s->hash_key while the rest below uses hash_key, I'd change it to hash_key as well since it's already assigned at the top. > + case SRV_HASH_KEY_ADDR: > + case SRV_HASH_KEY_ADDR_PORT: > + server_get_inetaddr(s, &srv_addr); > + if (srv_addr.family != AF_INET && srv_addr.family != AF_INET6) { > + hash_key = SRV_HASH_KEY_ID; > + } > + break; > + > + default: > + break; > + } > + > + if (hash_key == SRV_HASH_KEY_ADDR_PORT) { > + key = full_hash(srv_addr.port.svc); > + } Given that "key" is used immediately below and that I had to scroll up a bit to verify that it was properly initialized, I'd rather set the default zero value here in an else statement for ease of inspection later. > + switch (hash_key) { > + case SRV_HASH_KEY_ADDR_PORT: > + case SRV_HASH_KEY_ADDR: > + switch (srv_addr.family) { > + case AF_INET: > + key = full_hash(key + srv_addr.addr.v4.s_addr); > + break; > + case AF_INET6: > + key = XXH32(srv_addr.addr.v6.s6_addr, 16, key); > + break; > + default: (...) > + Arguments : > + <key> <key> may be one of the following : > + > + id The node keys will be derived from the server's position in > + the server list. > + Here it's "the server's numeric identifier as set from 'id' or which defaults to its position in the list". The rest is good. If you want I can perform these tiny cosmetic adjustments myself so as to save you a round trip. Thanks! Willy