MINOR: resolvers: add unique numeric id to nameservers
authorAurelien DARRAGON <adarragon@haproxy.com>
Mon, 4 Dec 2023 14:34:32 +0000 (15:34 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 21 Dec 2023 13:22:27 +0000 (14:22 +0100)
commit2f6120d6d47d7f9bf0adfabc95832752a33ceba3
treeec08f90f7c61a2ade618d9f1cf6afed364298c27
parent4fe0cca305f0393d59bace932c73d3b4df1fe140
MINOR: resolvers: add unique numeric id to nameservers

When we want to avoid keeping pointers on a nameserver struct, it's not
always convenient to refer as a nameserver using it's text-based unique
identifier since it's not limited in length thus it cannot be serialized
and deserialized safely.

To address this limitation, we add a new ->puid member in dns_nameserver
struct which is a parent-unique numeric value that can be used to refer
to the dns nameserver within its parent resolver context.

To achieve this, we reused the resolver->nb_nameserver member that wasn't
used. Each time we add a new nameserver to a resolver: we set ns->puid to
the current number of nameservers within the resolver and we increment
this number right away.

Public helper function find_nameserver_by_resolvers_and_id() was added to
help retrieve nameserver pointer from (resolver X nameserver puid)
combination.
include/haproxy/dns-t.h
include/haproxy/resolvers-t.h
include/haproxy/resolvers.h
src/resolvers.c