[libvirt] [PATCH 5/5] libvirt_nss: Report newer addresses first

Erik Skultety eskultet at redhat.com
Mon Jul 15 08:16:40 UTC 2019


On Sat, Jul 13, 2019 at 12:58:38PM +0200, Michal Privoznik wrote:
> Ideally, a software that's translating domain names would iterate
> over all addresses the NSS returned, but some software does not
> bother (e.g. ping). What happens is that for instance when
> installing a guest, it's assigned one IP address but once it's
> installed and rebooted it gets a different IP address (because
> client ID used for the first DHCP traffic when installing the
> guest was generated dynamically and never saved so after reboot
> the guest generated new ID which resulted in different IP address
> to be assigned). This results in 'ping $domain' not working
> properly as it still pings the old IP address. Well, it might -
> NSS plugin does not guarantee any order of addresses.
>
> To resolve this problem, we can sort the array just before
> returning it to the caller (ping) so that the newer IP addresses
> come before older ones.
>
> Reported-by: Andrea Bolognani <abologna at redhat.com>
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
...

>      {
>          "ip-address": "192.168.122.254",
>          "mac-address": "52:54:00:3a:b5:0c",
>          "hostname": "gentoo",
> -        "expiry-time": 2000000000
> +        "expiry-time": 2000000001

So, why is ^this specific change needed? In the test, you're expecting
192.168.122.[197-199], 192.168.122.199 has expiry time of 1900000000, so the
test would still work.

192.168.122.254 is only assumed in a gentoo test twice, but there are no other
addresses to sort in those cases, so the expiry time in there should not matter
right?

With the explanation of the above:
Reviewed-by: Erik Skultety <eskultet at redhat.com>




More information about the libvir-list mailing list