Bug 10597 - nss_wrapper: test_getaddrinfo fails on IPv4-only systems
Summary: nss_wrapper: test_getaddrinfo fails on IPv4-only systems
Status: RESOLVED FIXED
Alias: None
Product: cwrap
Classification: Unclassified
Component: library (show other bugs)
Version: unspecified
Hardware: All All
: P5 normal
Target Milestone: ---
Assignee: Andreas Schneider
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-07 13:07 UTC by jwilk
Modified: 2024-01-11 11:39 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jwilk 2014-05-07 13:07:47 UTC
test_getaddrinfo fails on systems that don't have any (non-loopback) IPv6 addresses configured:

$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0
       valid_lft forever preferred_lft forever

$ ctest --force-new-ctest-process --verbose -R getaddrinfo
UpdateCTestConfiguration  from :/home/jwilk/nss_wrapper-1.0.2/obj/tests/DartConfiguration.tcl
UpdateCTestConfiguration  from :/home/jwilk/nss_wrapper-1.0.2/obj/tests/DartConfiguration.tcl
Test project /home/jwilk/nss_wrapper-1.0.2/obj/tests
Constructing a list of tests
Done constructing a list of tests
Checking test dependency graph...
Checking test dependency graph end
test 2
    Start 2: test_getaddrinfo

2: Test command: /home/jwilk/nss_wrapper-1.0.2/obj/tests/test_getaddrinfo
2: Test timeout computed to be: 9.99988e+06
2: [==========] Running 7 test(s).
2: [ RUN      ] test_nwrap_getaddrinfo
2: [       OK ] test_nwrap_getaddrinfo
2: [ RUN      ] test_nwrap_getaddrinfo_any
2: [       OK ] test_nwrap_getaddrinfo_any
2: [ RUN      ] test_nwrap_getaddrinfo_local
2: [       OK ] test_nwrap_getaddrinfo_local
2: [ RUN      ] test_nwrap_getaddrinfo_name
2: [       OK ] test_nwrap_getaddrinfo_name
2: [ RUN      ] test_nwrap_getaddrinfo_service
2: [       OK ] test_nwrap_getaddrinfo_service
2: [ RUN      ] test_nwrap_getaddrinfo_null
2: 0xfffffffffffffffe != 0
2: /home/jwilk/nss_wrapper-1.0.2/tests/test_getaddrinfo.c:291: error: Failure!
2: [  FAILED  ] test_nwrap_getaddrinfo_null
2: [ RUN      ] test_nwrap_getaddrinfo_ipv6
2: [       OK ] test_nwrap_getaddrinfo_ipv6
2: [==========] 7 test(s) run.
2: [  PASSED  ] 6 test(s).
2: [  FAILED  ] 1 test(s), listed below:
2: [  FAILED  ] test_nwrap_getaddrinfo_null
1/1 Test #2: test_getaddrinfo .................***Failed    1.52 sec

0% tests passed, 1 tests failed out of 1

Total Test time (real) =   1.54 sec

The following tests FAILED:
          2 - test_getaddrinfo (Failed)
Errors while running CTest
Comment 1 Andreas Schneider 2014-05-07 17:03:46 UTC
If you pass a NULL as the node than we call into the glibc to let it handle the getaddrinfo() which fails on your host.

So you should check the return value of getaddrinfo(). Maybe print it with gai_strerror().

Looks like a bug in glibc...
Comment 2 jwilk 2014-05-07 17:42:03 UTC
The error is EAI_NONAME ("Name or service not known").
This is documented behavior of getaddrinfo():
“If hints.ai_flags includes the AI_ADDRCONFIG flag, then IPv4 addresses are returned in the list pointed to by res only if the local system has at least one IPv4 address configured, and IPv6 addresses are returned only if the local system has at least one IPv6 address configured. The loopback address is not considered for this case as valid as a configured address.”
Comment 3 Andreas Schneider 2014-05-07 17:59:10 UTC
Then I think the hints flags should be set to

(AI_V4MAPPED | AI_ADDRCONFIG)
Comment 4 Andreas Schneider 2014-05-08 14:07:39 UTC
Can you test with those flags?
Comment 5 jwilk 2014-05-08 16:44:58 UTC
If you set flags to AI_V4MAPPED | AI_ADDRCONFIG, the test still fails with EAI_NONAME.
However it succeeds if you set flags to AI_V4MAPPED alone, or to 0.
Comment 6 Björn Jacke 2024-01-11 09:33:22 UTC
any update on this?
Comment 7 Andreas Schneider 2024-01-11 11:39:05 UTC
This has been fixed with:

https://git.samba.org/?p=nss_wrapper.git;a=commitdiff;h=fa20a56d4126dd5b111d06f84442dc972f024313