[PATCH v2 07/12] gaih_inet: Split nscd lookup code into its own function.

DJ Delorie dj@redhat.com
Thu Mar 17 04:31:51 GMT 2022


Siddhesh Poyarekar via Libc-alpha <libc-alpha@sourceware.org> writes:
> Add a new member got_ipv6 to indicate if the results have an IPv6
> result and use it instead of the local got_ipv6.

One problem - need to clear res->got_ipv6 at some point (I couldn't find
a global "memset &res 0" that might indirectly clear it).  I think once
you get a valid ipv6 response, it wlil get stuck set to true.

> diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
> index bcceab7d07..ba5028ad7b 100644
> --- a/sysdeps/posix/getaddrinfo.c
> +++ b/sysdeps/posix/getaddrinfo.c
> @@ -121,6 +121,7 @@ struct gaih_result
>    struct gaih_addrtuple *at;
>    char *canon;
>    bool free_at;
> +  bool got_ipv6;

Ok.

>  
> -	got_ipv6 = true;						      \
> +	res.got_ipv6 = true;						      \

Ok.

>   }
>  
> @@ -467,6 +468,128 @@ get_servtuples (const struct gaih_service *service, const struct addrinfo *req,
>    return 0;
>  }
>  
> +#ifdef USE_NSCD
> +/* Query addresses from nscd cache, returning a non-zero value on error.
> +   RES members have the lookup result; RES->AT is NULL if there were no errors
> +   but also no results.  */
> +
> +static int
> +get_nscd_addresses (const char *name, const struct addrinfo *req,
> +		    struct gaih_result *res)
> +{
> + . . .
> +}
> +#endif

Moved, Ok.

>  /* Convert numeric addresses to binary into RES.  On failure, RES->AT is set to
>     NULL and an error code is returned.  If AI_NUMERIC_HOST is not requested and
>     the function cannot determine a result, RES->AT is set to NULL and 0
> @@ -628,7 +751,6 @@ gaih_inet (const char *name, const struct gaih_service *service,
>    struct gaih_servtuple st[sizeof (gaih_inet_typeproto)
>  			   / sizeof (struct gaih_typeproto)] = {0};
>  
> -  bool got_ipv6 = false;

Nothing seems to set res.got_ipv6 to false?

> @@ -670,6 +792,13 @@ gaih_inet (const char *name, const struct gaih_service *service,
>        else if (res.at != NULL)
>  	goto process_list;
>  
> +#ifdef USE_NSCD
> +      if ((result = get_nscd_addresses (name, req, &res)) != 0)
> +	goto free_and_return;
> +      else if (res.at != NULL)
> +	goto process_list;
> +#endif

Ok.

> -#ifdef USE_NSCD
> -      if (__nss_not_use_nscd_hosts > 0
> - . . .
> -	}
> -#endif

Ok.

> -			    got_ipv6 = true;
> +			    res.got_ipv6 = true;

Ok.

> -			  && ((req->ai_flags & AI_ALL) || !got_ipv6)))
> +			  && ((req->ai_flags & AI_ALL) || !res.got_ipv6)))

Ok.

> -	    if (got_ipv6
> +	    if (res.got_ipv6

Ok.



More information about the Libc-alpha mailing list