#52 FQDN set to nsslapd-listenhost makes the server start fail if IPv4-mapped-IPv6 address is given
Closed: wontfix None Opened 12 years ago by mkosek.

https://bugzilla.redhat.com/show_bug.cgi?id=697669

Description of problem:
Setting FQDN to nsslapd-listenhost, the server fails to start as follows.  It
happens on my laptop, but not on my desktop.

    # /usr/lib/dirsrv/slapd-jiji/start-slapd -d 0
    [.] - 389-Directory/1.2.9.a1.git6d094d2 B2011.103.2056 starting up
    [.] - slapd started.  Listening on 2000::1:1234 port 10389 for LDAP
requests
    [.] - Listening on 10.14.54.140 port 10389 for LDAP requests
    [.] - Listening on 10.14.54.140 port 10389 for LDAP requests
    [.] slapd_daemon - PR_Listen() on 10.14.54.140 port 10389 failed: Netscape
Portable Runtime error -5982 (Local Network address is in use.)
    [.] - slapd shutting down - signaling operation threads
    [.] - slapd shutting down - waiting for 28 threads to terminate
    [.] - slapd shutting down - closing down internal subsystems and plugins
    [.] - Waiting for 4 database threads to stop
    [.] - All database threads now stopped
    [.] - userRoot: Cleaning up entry cache
    [.] - userRoot: Cleaning up dn cache
    [.] - slapd stopped.

The problem of my laptop is IPv4-mapped-IPv6 address is returned and the
address is added to the listen host array, which is basically identical to the
IPv4 address pf PR_Listen.  To avoid the problem, I think slapd_listenhost2addr
should check if the address is an IPv4 mapped IPv6 address or not.  And if it
is, it should not add it to the listen host array.

(gdb) p *(*addr)[0]
$15 = {raw = {family = 10,
    data = "\000\000\000\000\000\000 \000\000\000\000\000\000"}, inet = {
    family = 10, port = 0, ip = 0, pad = " \000\000\000\000\000\000"}, ipv6 = {
    family = 10, port = 0, flowinfo = 0, ip = {_S6_un = {
        _S6_u8 = " ", '\000' <repeats 12 times>, "\001\022\064", _S6_u16 = {
          32, 0, 0, 0, 0, 0, 256, 13330}, _S6_u32 = {32, 0, 0, 873595136},
        _S6_u64 = {32, 3752062539064672256}}}, scope_id = 0}, local = {
    family = 10,
    path = "\000\000\000\000\000\000 ", '\000' <repeats 12 times>,
"\001\022\064", '\000' <repeats 81 times>}}
(gdb) p addrbuf
$19 = 0xbffff32c "2000::1:1234"

(gdb) p *(*addr)[1]
$17 = {raw = {family = 2,
    data = "\000\000\n\016\066\214\000\000\000\000\000\000\000"}, inet = {
    family = 2, port = 0, ip = 2352352778,
    pad = "\000\000\000\000\000\000\000"}, ipv6 = {family = 2, port = 0,
    flowinfo = 2352352778, ip = {_S6_un = {_S6_u8 = '\000' <repeats 15 times>,
        _S6_u16 = {0, 0, 0, 0, 0, 0, 0, 0}, _S6_u32 = {0, 0, 0, 0}, _S6_u64 = {
          0, 0}}}, scope_id = 0}, local = {family = 2,
    path = "\000\000\n\016\066\214", '\000' <repeats 97 times>}}
p addrbuf
$20 = 0xbffff32c "10.14.54.140"

(gdb) p *(*addr)[2]
$18 = {raw = {family = 10, data = '\000' <repeats 13 times>}, inet = {
    family = 10, port = 0, ip = 0, pad = "\000\000\000\000\000\000\000"},
  ipv6 = {family = 10, port = 0, flowinfo = 0, ip = {_S6_un = {
        _S6_u8 =
"\000\000\000\000\000\000\000\000\000\000\377\377\n\016\066\214", _S6_u16 = {0,
0, 0, 0, 0, 65535, 3594, 35894}, _S6_u32 = {0, 0, 4294901760,
          2352352778}, _S6_u64 = {0, 10103278254459650048}}}, scope_id = 0},
  local = {family = 10,
    path = '\000' <repeats 16 times>"\377, \377\n\016\066\214", '\000' <repeats
81 times>}}
(gdb) p addrbuf
$21 = 0xbffff32c "::ffff:10.14.54.140"



2751         PRAddrInfo *infop = PR_GetAddrInfoByName( listenhost,
2752                         PR_AF_UNSPEC, (PR_AI_ADDRCONFIG|PR_AI_NOCANONNAME)
);
2753         if ( NULL != infop ) {
2754             void *iter = NULL;
2755             int addrcnt = 0;
2756             int i = 0;
2757             memset( netaddr, 0, sizeof( PRNetAddr ));
2758             /* need to count the address, first */
2759             while ( (iter = PR_EnumerateAddrInfo( iter, infop, 0, netaddr
)     )
2760                             != NULL ) {
2761                 addrcnt++;
2762             }
2763             if ( 0 == addrcnt ) {
2764                 slapi_log_error( SLAPI_LOG_FATAL, logname,
2765                     "PR_EnumerateAddrInfo for %s failed - %s error %d
(%s)\     n",
2766                     listenhost, SLAPI_COMPONENT_NAME_NSPR, prerr,
2767                     slapd_pr_strerror(prerr));
2768                 rval = -1;
2769             } else {
2770                 *addr = (PRNetAddr **)slapi_ch_calloc(addrcnt + 1, sizeof
(     PRNetAddr *));
2771                 iter = NULL; /* from the beginning */
2772                 memset( netaddr, 0, sizeof( PRNetAddr ));
2773                 for  ( i = 0; i < addrcnt; i++ ) {
2774                     iter = PR_EnumerateAddrInfo( iter, infop, 0, netaddr
);
2775                     if ( NULL == iter ) {
2776                         break;
2777                     }
2778                     (*addr)[i] = netaddr;
2779                     netaddr = (PRNetAddr *)slapi_ch_calloc(1,
sizeof(PRNetA     ddr));
2780                 }
2781                 slapi_ch_free((void **)&netaddr); /* not used */
2782             }
2783             PR_FreeAddrInfo( infop );

Steps to verify.
0. for testing, add a IPv4-mapped-IPv6 address to /etc/hosts.
::ffff:<your_IPv4_address> <FQDN>
1. shutdown the server.
2. add "nsslapd-listenhost: <FQDN>" to /etc/dirsrv/slapd-<ID>/dse.ldif
3. restart the server.
The server should start.

I'm confused by this:
{{{
/ IPv4 mapped IPv6; redundant to IPv4;
cut the "::ffff:" part. */
abp = strrchr(abuf, ':');
if (abp) {
abp++;
} else {
abp = abuf;
}
}}}
what would the address look like before and after this code? I'm assuming abuf starts with ::ffff:, and that the ":" after the ffff is the last ":" in abuf?

Replying to [comment:6 rmeggins]:

I'm confused by this:
{{{
/ IPv4 mapped IPv6; redundant to IPv4;
cut the "::ffff:" part. */
abp = strrchr(abuf, ':');
if (abp) {
abp++;
} else {
abp = abuf;
}
}}}
what would the address look like before and after this code? I'm assuming abuf starts with ::ffff:, and that the ":" after the ffff is the last ":" in abuf?

This is the duplicate message logged in the error log:
[24/Jan/2012:11:58:15 -0800] - slapd_listenhost2addr: detected duplicated addre
ss ::ffff:10.14.16.118 [10.14.16.118]

Using this example, original IPv4-mapped IPv6 address is
::ffff:10.14.16.118
while the IPv4 address is
10.14.16.118

The newer notation:
::ffff:192.0.2.128
The old and deprecated notation:
::192.0.2.128.[39]

Reviewed by Rich (Thank you!!!)

Pushed to master.

$ git merge trac52
Updating 8d39bb6..9760c1c
Fast-forward
ldap/servers/slapd/daemon.c | 35 +++++++++++++++++++++++++++++++++--
1 files changed, 33 insertions(+), 2 deletions(-)

$ git push
Counting objects: 11, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 1.22 KiB, done.
Total 6 (delta 4), reused 0 (delta 0)
To ssh://git.fedorahosted.org/git/389/ds.git
8d39bb6..9760c1c master -> master

Added initial screened field value.

Metadata Update from @nkinder:
- Issue assigned to nhosoi
- Issue set to the milestone: 1.2.10.rc1

7 years ago

389-ds-base is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in 389-ds-base's github repository.

This issue has been cloned to Github and is available here:
- https://github.com/389ds/389-ds-base/issues/52

If you want to receive further updates on the issue, please navigate to the github issue
and click on subscribe button.

Thank you for understanding. We apologize for all inconvenience.

Metadata Update from @spichugi:
- Issue close_status updated to: wontfix (was: Fixed)

3 years ago

Login to comment on this ticket.

Metadata