public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Carlos O'Donell <carlos@redhat.com>
To: DJ Delorie <dj@redhat.com>, libc-alpha@sourceware.org
Subject: Re: v2 [PATCH 4/4] nsswitch: use new internal API
Date: Thu, 13 Aug 2020 16:09:52 -0400	[thread overview]
Message-ID: <951021d2-92f5-9da5-db03-04e93e50d98c@redhat.com> (raw)
In-Reply-To: <xnblkyu57k.fsf@greed.delorie.com>

On 7/1/20 8:32 PM, DJ Delorie via Libc-alpha wrote:
> Stitch new ABI and types throughout all NSS callers and providers.

I have applied your 4 patches to Fedora Rawhide and booted a system
and started testing things out.

The system works perfectly fine, but in the tests I ran the /etc/nsswitch.conf
doesn't reload.

It doesn't reload because of code like this:

 59   if (DATABASE_NAME_SYMBOL == NULL
 60       && __nss_database_lookup2 (DATABASE_NAME_STRING, ALTERNATE_NAME_STRING,
 61                                  DEFAULT_CONFIG, &DATABASE_NAME_SYMBOL) < 0)
 62     return -1;
 63 
 64   *ni = DATABASE_NAME_SYMBOL;
 65 
 66   return __nss_lookup (ni, fct_name, fct2_name, fctp);

and this:

 723           if (__nss_hosts_database == NULL)
 724             no_more = __nss_database_lookup2 ("hosts", NULL,
 725                                               "dns [!UNAVAIL=return] files",
 726                                               &__nss_hosts_database);
 727           else
 728             no_more = 0;
 729           nip = __nss_hosts_database;

Which cache the database lookup.

This is OK for setent/getent/endent where you want a consistent database for
the iterations.

This is not OK for getaddrinfo where subsequent calls should return the new
data for long lived applications.

To me this means that we still have some work to do here, and I would like to
see the following tests added:

(1) Test covering changing data after reload for host interfaces.

* New container test case that has 2 NSS services for hosts providing
  different data.
* Start the test with one set of data and call:
  * gethostbyname
  * gethostbyname_r
  * gethostbyname2
  * gethostbyname2_r
  * gethostbyaddr
  * getaddrinfo
  * getnameinfo
* Collect results.
* Switch interfaces.
* Call functions again.
* Collect results.
* Compare expected vs. observed.

(2) Test covering non-changing reload for setent/getent/endent for hosts.

* New container test case that has 2 NSS services for hosts providing
  different data.
* Start the test with one set of data and call:
  * setent
  * getent ...
* Change the file mid enumeration.
* More of:
  * getent ...
  * endent
* Verify results match first service data (service not changed and cached
  until endent).
* Start a second iteration of:
  * setent
  * getent
  * endent
* Verify results match second service data.

That should be enough to validate the reloading.

We should be on the lookout for this pattern of database caching.

Yes, it means we will stat /etc/nsswitch.conf for every API call, but that
is in the noise compared to the network costs of going to DNS/LDAP or
parsing files. I don't think the added stat cost will make much of a difference
compared to reading and parsing lines from files.

-- 
Cheers,
Carlos.


  reply	other threads:[~2020-08-13 20:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-02  0:32 DJ Delorie
2020-08-13 20:09 ` Carlos O'Donell [this message]
2020-08-14  0:16   ` DJ Delorie
2020-08-27 18:41   ` DJ Delorie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=951021d2-92f5-9da5-db03-04e93e50d98c@redhat.com \
    --to=carlos@redhat.com \
    --cc=dj@redhat.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).