[BZ,24816] Fix nss/tst-nss-files-hosts-long and tst-nss-files-hosts-multi when there is no IPv6 support
Checks
Commit Message
Hi,
This is an updated version of a patch I posted some years ago already:
https://sourceware.org/pipermail/libc-alpha/2019-July/105107.html
With glibc 2.34, now tst-nss-files-hosts-multi also needs to be updated
as well, as it seems my docker container I use to build/test glibc lacks
proper ipv6 configuration.
I tested this on x86-64.
Cheers,
Romain
From 04f5a832acd7417190d272c10db0c47e55fc3a16 Mon Sep 17 00:00:00 2001
From: Romain Geissler <romain.geissler@amadeus.com>
Date: Wed, 17 Jul 2019 12:29:21 +0000
Subject: [PATCH] [BZ 24816] Fix nss/tst-nss-files-hosts-long and
tst-nss-files-hosts-multi when there is no IPv6 support.
---
nss/tst-nss-files-hosts-long.c | 47 +++++++++++++++++++++++++++------
nss/tst-nss-files-hosts-multi.c | 34 ++++++++++++++++++++++++
2 files changed, 73 insertions(+), 8 deletions(-)
Comments
On 8/10/21 6:33 AM, Romain GEISSLER via Libc-alpha wrote:
> Hi,
>
> This is an updated version of a patch I posted some years ago already:
> https://sourceware.org/pipermail/libc-alpha/2019-July/105107.html
>
> With glibc 2.34, now tst-nss-files-hosts-multi also needs to be updated
> as well, as it seems my docker container I use to build/test glibc lacks
> proper ipv6 configuration.
>
> I tested this on x86-64.
Looks like it's regressing i686.
https://patchwork.sourceware.org/project/glibc/patch/20210810010331.GA51141@ncerndobedev6097.etv.nce.amadeus.net/
https://www.delorie.com/trybots/32bit/2629/regressions.txt
Siddhesh
* Siddhesh Poyarekar:
> On 8/10/21 6:33 AM, Romain GEISSLER via Libc-alpha wrote:
>> Hi,
>> This is an updated version of a patch I posted some years ago
>> already:
>> https://sourceware.org/pipermail/libc-alpha/2019-July/105107.html
>> With glibc 2.34, now tst-nss-files-hosts-multi also needs to be
>> updated
>> as well, as it seems my docker container I use to build/test glibc lacks
>> proper ipv6 configuration.
>> I tested this on x86-64.
>
> Looks like it's regressing i686.
>
> https://patchwork.sourceware.org/project/glibc/patch/20210810010331.GA51141@ncerndobedev6097.etv.nce.amadeus.net/
> https://www.delorie.com/trybots/32bit/2629/regressions.txt
It's a test timeout:
<https://www.delorie.com/trybots/32bit/2629/misc-tst-bz21269.out>
I expected those happened before.
Thanks,
Florian
@@ -22,6 +22,31 @@
#include <stdlib.h>
#include <nss.h>
#include <support/check.h>
+#include <ifaddrs.h>
+
+static int
+supports_inet_family(int family)
+{
+ struct ifaddrs *ifaddr, *ifa;
+ int ret = 0;
+
+ if (getifaddrs(&ifaddr) == -1)
+ FAIL_EXIT1("getifaddrs failed");
+
+ for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
+ if (ifa->ifa_addr == NULL)
+ continue;
+
+ if (ifa->ifa_addr->sa_family == family) {
+ ret = 1;
+ break;
+ }
+ }
+
+ freeifaddrs(ifaddr);
+
+ return ret;
+}
static int
do_test (void)
@@ -30,14 +55,20 @@ do_test (void)
/* Run getent to fetch the IPv4 address for host test4.
This forces /etc/hosts to be parsed. */
- ret = system("getent ahostsv4 test4");
- if (ret != 0)
- FAIL_EXIT1("ahostsv4 failed");
-
- /* Likewise for IPv6. */
- ret = system("getent ahostsv6 test6");
- if (ret != 0)
- FAIL_EXIT1("ahostsv6 failed");
+ if (supports_inet_family(AF_INET))
+ {
+ ret = system("getent ahostsv4 test4");
+ if (ret != 0)
+ FAIL_EXIT1("ahostsv4 failed");
+ }
+
+ /* Likewise for IPv6. */
+ if (supports_inet_family(AF_INET6))
+ {
+ ret = system("getent ahostsv6 test6");
+ if (ret != 0)
+ FAIL_EXIT1("ahostsv6 failed");
+ }
exit (0);
}
@@ -19,6 +19,7 @@
#include <dlfcn.h>
#include <errno.h>
#include <gnu/lib-names.h>
+#include <ifaddrs.h>
#include <netdb.h>
#include <nss.h>
#include <stdbool.h>
@@ -37,6 +38,30 @@
struct support_chroot *chroot_env;
+static int
+supports_inet_family(int family)
+{
+ struct ifaddrs *ifaddr, *ifa;
+ int ret = 0;
+
+ if (getifaddrs(&ifaddr) == -1)
+ FAIL_EXIT1("getifaddrs failed");
+
+ for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
+ if (ifa->ifa_addr == NULL)
+ continue;
+
+ if (ifa->ifa_addr->sa_family == family) {
+ ret = 1;
+ break;
+ }
+ }
+
+ freeifaddrs(ifaddr);
+
+ return ret;
+}
+
static void
prepare (int argc, char **argv)
{
@@ -204,6 +229,15 @@ run_gbhn_gai (struct test_params *params)
if (test_verbose > 0)
printf ("info: %s\n", ctx);
+ if (!supports_inet_family(params->family))
+ {
+ printf("Test %s is not supported, skipping this inet family", ctx);
+ free (ctx);
+
+ return;
+ }
+
+
/* Check gethostbyname, gethostbyname2. */
if (params->family == AF_INET)
{