Bug 5910 - getaddrinfo failed for name 0.0.0.0 [Invalid flags in hints] for AIX 5.1
getaddrinfo failed for name 0.0.0.0 [Invalid flags in hints] for AIX 5.1
Status: RESOLVED FIXED
Product: Samba 3.2
Classification: Unclassified
Component: File services
3.2.4
PPC AIX
: P3 regression
: ---
Assigned To: Volker Lendecke
Samba QA Contact
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-11-20 00:11 UTC by Chris Good
Modified: 2010-11-04 12:37 UTC (History)
2 users (show)

See Also:


Attachments
Patch (1.47 KB, patch)
2010-02-07 11:14 UTC, Volker Lendecke
metze: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Good 2008-11-20 00:11:29 UTC
clients cannot connect to smbd shares on aix 5.1 (maintenance level 4 or 9).

Smbd with a debug level of 6 shows:

[2008/11/20 15:55:02,  3] lib/util_sock.c:interpret_string_addr_internal(122)
  interpret_string_addr_internal: getaddrinfo failed for name :: [Invalid flags
in hints]
[2008/11/20 15:55:02,  3] lib/util_sock.c:interpret_string_addr_internal(122)
  interpret_string_addr_internal: getaddrinfo failed for name :: [Invalid flags
in hints]
[2008/11/20 15:55:02,  3] lib/util_sock.c:interpret_string_addr_internal(122)
  interpret_string_addr_internal: getaddrinfo failed for name 0.0.0.0 [Invalid f
lags in hints]
[2008/11/20 15:55:02,  3] lib/util_sock.c:interpret_string_addr_internal(122)
  interpret_string_addr_internal: getaddrinfo failed for name 0.0.0.0 [Invalid f
lags in hints]
[2008/11/20 15:55:02,  0] smbd/server.c:open_sockets_smbd(548)
  open_sockets_smbd: No sockets available to bind to.

smbd runs but no-one can connect to it.

I know that there was a bug in AIX 5.1 getaddrinfo that was fixed in ML7, and another machine that showed this problem with sshd, had this problem fixed by upgrading to ML9, but this has not helped Samba 3.2.4.

I'm using security = server, and defining 'interfaces' & 'hosts allow' did not help.

I compiled on the same machine, but without krb5 & OpenLDAP libraries.
Comment 1 Chris Good 2008-12-07 21:49:59 UTC
I created a test program to try to duplicate & fix the getaddrinfo() problem:

#include <stdio.h>
#include <memory.h>
#include <sys/socket.h>
#include <netdb.h>
#include <errno.h>

int main(argc,argv)

int argc;
char *argv[];

{
int ret, flags;
struct addrinfo hints;
struct addrinfo **ppres;
const char hostname[] = "0.0.0.0";

memset(&hints, '\0', sizeof(hints));
flags = AI_NUMERICHOST|AI_PASSIVE|AI_ADDRCONFIG;
hints.ai_socktype = SOCK_STREAM;
hints.ai_family = AF_INET;
hints.ai_flags = flags;
/* in case memset is incorrect */
hints.ai_addrlen = 0;
hints.ai_canonname = NULL;
hints.ai_addr = NULL;
hints.ai_next = NULL;

ret = getaddrinfo(hostname, NULL,
    &hints,
    ppres);

if (ret) {
    printf("getaddrinfo name=%s returned %d errno=%d\n",
        hostname, ret, errno);
    printf("ai_flags=%d ai_family=%d ai_socktype=%d ai_protocol=%d\n",
        hints.ai_flags, hints.ai_family, hints.ai_socktype,
        hints.ai_protocol);
}
return ret;
}

Unfortunately, no matter what flags & hints I passed, getaddrinfo still failed.

I then updated our test Aix 5.1 (ML1) machine with ML9 & ML9+ (latest available which includes many getaddrinfo bug fixes), but my test program still fails.

I tried my test program on our test AIX 5.3 ML6 machine & it worked fine, so it seems a solution would be to upgrade to AIX 5.3 ML6.

I also tried to compile Samba 3.2.4 using options to use Samba's inbuild replacement function for getaddrinfo. I wasn't sure how to do this and suspect I did it wrong as the test program, still failed with the same err.

I did it by:
  ./configure libreplace_cv_HAVE_GETADDRINFO=no
  make
  make install

Is that correct?
Comment 2 A. Wik 2009-03-24 19:33:10 UTC
This is how I fixed it.  After the change to source/lib/util_sock.c reflected by the patch below, nmbd will not only start, but stay running and working properly for many hours on end (that's about the amount of time there has been since I compiled and started it).

Note that I've only tested this on NetBSD/vax 1.5.2 (most files are actually from 1.5.1), and this information may not be applicable to other systems, such as AIX, but it may be worth a try.

--- samba-3.2.1/source/lib/util_sock.c.orig	Tue Aug  5 06:22 2008
+++ samba-3.2.1/source/lib/util_sock.c	Tue Mar 24 14:59:06 2009
@@ -106,7 +106,10 @@
 	memset(&hints, '\0', sizeof(hints));
 	/* By default make sure it supports TCP. */
 	hints.ai_socktype = SOCK_STREAM;
-	hints.ai_flags = flags;
+	hints.ai_flags = flags & ~AI_ADDRCONFIG;
 
 	/* Linux man page on getaddinfo() says port will be
 	   uninitialized when service string in NULL */
Comment 3 Chris Good 2009-04-07 00:38:51 UTC
A. Wik,

Thanks for the suggestion but it didn't help with AIX 5.1. The result was the same.
Comment 4 Volker Lendecke 2010-02-07 11:14:37 UTC
Created attachment 5293 [details]
Patch

Attached find a patch that uses your test program to detect the broken getaddrinfo. For me on Linux this works fine, on broken platforms this should avoid using getaddrinfo.

Metze, I have requested review from you, I haven't checked this in yet. libreplace is kindof your turf, so feel free to bust this patch :-)

Volker
Comment 5 Stefan Metzmacher 2010-02-08 05:17:06 UTC
Comment on attachment 5293 [details]
Patch

Pushed to master
as commit 6e7bcaa878af80be338b18bfe4e
Comment 6 Chris Good 2010-02-14 22:11:51 UTC
Im not sure if I'm being premature, but I made the mod to libreplace_network.m4 and rebuilt Samba 3.2.4 on AIX 5.1 and when I tried to run it now:

  smbd version 3.2.4 started.
  Copyright Andrew Tridgell and the Samba Team 1992-2008
[2010/02/15 14:23:50,  0] lib/interface.c:load_interfaces(543)
  WARNING: no network interfaces found
[2010/02/15 14:23:50,  0] smbd/server.c:open_sockets_smbd(548)
  open_sockets_smbd: No sockets available to bind to.
[2010/02/15 14:30:31,  0] smbd/server.c:main(1209)

Please let me know if you need any more info.
Comment 7 Volker Lendecke 2010-11-04 12:37:36 UTC
Fixed with 6e7bcaa8 in v3-6-test.