[Swan-dev] get rid of getnetbyname() /etc/networks?

Paul Wouters paul at nohats.ca
Sun May 2 19:55:23 UTC 2021


On Sun, 2 May 2021, D. Hugh Redelmeier wrote:

> Subject: [Swan-dev] get rid of getnetbyname() /etc/networks?
> 
> Comments I added recently:
>
> +	/*
> +	 * try a name from /etc/networks
> +	 *
> +	 * Seems pretty obsolete:
> +	 * - latest RFC, 1101, dated April 1989
> +	 * - IPv4 only
> +	 * - doesn't support classless networks
> +	 * - Window has it
> +	 */
>
> We are using this as a fallback when DNS doesn't resolve a name.
> We are not even using it to find a network, only an IP address.

kill it :)

Related, there are still a few places that end up calling
gethostbyname2() which is also obsolete and does not work for IPv6:

lib/libswan/ttoaddress.c:       struct hostent *h = gethostbyname2(p, af);

programs/showhostkey/showhostkey.c:     gethostname(qname, sizeof(qname));

The case in ttoaddress.c is the main one. Since it is used by
ttoaddress_dns() which is used in many places, we cannot replace it
with an async libunbound call. And to do a sync unbound call, last I
looked at this years ago, we would have to start another libunbound
context which gets its own cachce. Also, it would mean people can no
longer compile without libunbound. I guess the best fix would be to
rewrite it to use getaddrinfo() or res_ functions?

Paul


More information about the Swan-dev mailing list