Bug 8984 - AIX 6.1 nmbd Failed to open nmb bcast socket on interface
Summary: AIX 6.1 nmbd Failed to open nmb bcast socket on interface
Status: NEW
Alias: None
Product: Samba 3.6
Classification: Unclassified
Component: Nmbd (show other bugs)
Version: 3.6.5
Hardware: All All
: P5 normal
Target Milestone: ---
Assignee: Jeremy Allison
QA Contact: Samba QA Contact
URL:
Keywords:
: 9294 (view as bug list)
Depends on: 6970
Blocks:
  Show dependency treegraph
 
Reported: 2012-06-07 02:02 UTC by Ben Lentz
Modified: 2019-01-23 23:14 UTC (History)
8 users (show)

See Also:


Attachments
Patch for master and v3-6-test (957 bytes, patch)
2012-12-18 15:23 UTC, SATOH Fumiyasu
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ben Lentz 2012-06-07 02:02:48 UTC
I am having the same issue as the user who reported this:

http://lists.samba.org/archive/samba/2010-August/157763.html

On AIX 6.1, TL7 SP1, running Samba 3.6.5 compiled from source using gcc.

It seems the subnet math is wrong on this platform, perhaps?

The log below shows the broadcast IP of 10.0.17.239.

This system has IP address 10.0.17.14/24, subnet mask 255.255.255.0, broadcast address should be calculated as 10.0.17.255 not 10.0.17.239.

Help!

$ ifconfig -a
en2: flags=1e080863,480<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,CHECKSUM_OFFLOAD(ACTIVE),CHAIN>
        inet 10.0.17.14 netmask 0xffffff00 broadcast 10.0.17.255
         tcp_sendspace 262144 tcp_recvspace 262144 rfc1323 1
lo0: flags=e08084b,c0<UP,BROADCAST,LOOPBACK,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,LARGESEND,CHAIN>
        inet 127.0.0.1 netmask 0xff000000 broadcast 127.255.255.255
        inet6 ::1%1/0
         tcp_sendspace 131072 tcp_recvspace 131072 rfc1323 1
$ sudo rm -f /opt/local/samba/var/log/log.nmbd
$ sudo startsrc -s nmbd
0513-059 The nmbd Subsystem has been started. Subsystem PID is 17236188.
$ lssrc -s nmbd
Subsystem         Group            PID          Status
 nmbd             tcpip                         inoperative
$ cat /opt/local/samba/var/log/log.nmbd
[2012/06/06 22:00:51,  0] nmbd/nmbd.c:860(main)
  nmbd version 3.6.5 started.
  Copyright Andrew Tridgell and the Samba Team 1992-2011
[2012/06/06 22:00:51,  0] nmbd/nmbd.c:888(main)
  standard input is not a socket, assuming -D option
[2012/06/06 22:00:51,  0] lib/util_sock.c:667(open_socket_in)
  bind failed on port 137 socket_addr = 10.0.17.239.
  Error = Can't assign requested address
[2012/06/06 22:00:51,  0] nmbd/nmbd_subnetdb.c:127(make_subnet)
  nmbd_subnetdb:make_subnet()
    Failed to open nmb bcast socket on interface 10.0.17.239 for port 137.  Error was Can't assign requested address
[2012/06/06 22:00:51,  0] nmbd/nmbd.c:974(main)
  ERROR: Failed when creating subnet lists. Exiting.
[2012/06/06 22:00:51,  0] nmbd/nmbd.c:860(main)
  nmbd version 3.6.5 started.
  Copyright Andrew Tridgell and the Samba Team 1992-2011
[2012/06/06 22:00:51,  0] nmbd/nmbd.c:888(main)
  standard input is not a socket, assuming -D option
[2012/06/06 22:00:51,  0] lib/util_sock.c:667(open_socket_in)
  bind failed on port 137 socket_addr = 10.0.17.239.
  Error = Can't assign requested address
[2012/06/06 22:00:51,  0] nmbd/nmbd_subnetdb.c:127(make_subnet)
  nmbd_subnetdb:make_subnet()
    Failed to open nmb bcast socket on interface 10.0.17.239 for port 137.  Error was Can't assign requested address
[2012/06/06 22:00:51,  0] nmbd/nmbd.c:974(main)
  ERROR: Failed when creating subnet lists. Exiting.
[2012/06/06 22:00:51,  0] nmbd/nmbd.c:860(main)
  nmbd version 3.6.5 started.
  Copyright Andrew Tridgell and the Samba Team 1992-2011
[2012/06/06 22:00:51,  0] nmbd/nmbd.c:888(main)
  standard input is not a socket, assuming -D option
[2012/06/06 22:00:51,  0] lib/util_sock.c:667(open_socket_in)
  bind failed on port 137 socket_addr = 10.0.17.239.
  Error = Can't assign requested address
[2012/06/06 22:00:51,  0] nmbd/nmbd_subnetdb.c:127(make_subnet)
  nmbd_subnetdb:make_subnet()
    Failed to open nmb bcast socket on interface 10.0.17.239 for port 137.  Error was Can't assign requested address
[2012/06/06 22:00:51,  0] nmbd/nmbd.c:974(main)
  ERROR: Failed when creating subnet lists. Exiting.
Comment 1 Ben Lentz 2012-06-07 13:27:25 UTC
Starting nmbd with "-F -d 2 -S" reveals the below output.

First we get:

added interface en2 ip=10.0.17.14 bcast=10.0.17.255 netmask=

But then later we get:

added interface en2 ip=10.0.17.14 bcast=10.0.17.191 netmask=

Here's the top part of the log:

nmbd version 3.6.5 started.
Copyright Andrew Tridgell and the Samba Team 1992-2011
Registered MSG_REQ_POOL_USAGE
Registered MSG_REQ_DMALLOC_MARK and LOG_CHANGED
standard input is not a socket, assuming -D option
Becoming a daemon.
added interface en2 ip=10.0.17.14 bcast=10.0.17.255 netmask=
added interface lo0 ip=127.0.0.1 bcast=127.255.255.255 netmask=
create_subnets: Ignoring loopback interface.
making subnet name:10.0.17.14 Broadcast address:10.0.17.255 Subnet mask:255.255.255.0
making subnet name:UNICAST_SUBNET Broadcast address:0.0.0.0 Subnet mask:0.0.0.0
making subnet name:REMOTE_BROADCAST_SUBNET Broadcast address:0.0.0.0 Subnet mask:0.0.0.0
load_lmhosts_file: Can't open lmhosts file /opt/local/samba/etc/samba/lmhosts. Error was No such file or directory
added interface en2 ip=10.0.17.14 bcast=10.0.17.191 netmask=
added interface lo0 ip=127.0.0.1 bcast=127.255.255.255 netmask=
Found new interface 10.0.17.14
bind failed on port 137 socket_addr = 10.0.17.191.
Error = Can't assign requested address
nmbd_subnetdb:make_subnet()
  Failed to open nmb bcast socket on interface 10.0.17.191 for port 137.  Error was Can't assign requested address
reload_interfaces: Ignoring loopback interface 127.0.0.1
Deleting dead interface 10.0.17.14
Comment 2 Ben Lentz 2012-06-07 13:40:30 UTC
It seems everything is fine until we run the first "send_host_announcement" call. 

Using -d 3 on an AIX 5.3 system (where this works fine):

send_host_announcement: type 819b03 for host OPTAIX53TS on subnet 10.0.17.16 for workgroup CSWG
added interface en2 ip=10.0.17.16 bcast=10.0.17.255 netmask=

Using -d 3 on an AIX 6.1 system (where the bcast address is later miscalculated):

send_host_announcement: type 819b03 for host OPTAIXNIM01 on subnet 10.0.17.14 for workgroup CSWG
added interface en2 ip=10.0.17.14 bcast=10.0.17.191 netmask=
Comment 3 SATOH Fumiyasu 2012-09-20 11:37:50 UTC
Hi, Ben.

Can you try the patch posted in
http://lists.samba.org/archive/samba-technical/2011-August/078954.html ?
I cannot try this patch because I cannot reproduce this bug.
Comment 4 SATOH Fumiyasu 2012-09-20 13:51:23 UTC
See also Bug 6970 – getifaddrs() issues on AIX
https://bugzilla.samba.org/show_bug.cgi?id=6970
Comment 5 Ben Lentz 2012-09-20 19:40:54 UTC
I changed the source like this:

--- lib/replace/getifaddrs.c	2011-01-07 13:24:23.000000000 +0100
+++ lib/replace/getifaddrs.c	2011-01-07 18:24:13.000000000 +0100
@@ -58,7 +58,7 @@
 {
 	struct sockaddr *ret;
 	socklen_t socklen;
-#ifdef HAVE_SOCKADDR_SA_LEN
+#if defined(HAVE_SOCKADDR_SA_LEN) && !defined(AIX)
 	socklen = sa->sa_len;
 #else
 	socklen = sizeof(struct sockaddr_storage);

and recompiled successfully. I am testing on more machines, but so far, this seems to work better.
Comment 6 Ben Lentz 2012-09-20 20:55:17 UTC
I take it back, I am again getting this error:

[2012/09/20 16:54:37,  0] nmbd/nmbd.c:860(main)
  nmbd version 3.6.5 started.
  Copyright Andrew Tridgell and the Samba Team 1992-2011
[2012/09/20 16:54:37,  0] nmbd/nmbd.c:888(main)
  standard input is not a socket, assuming -D option
[2012/09/20 16:54:37,  0] lib/util_sock.c:667(open_socket_in)
  bind failed on port 137 socket_addr = 10.0.17.239.
  Error = Can't assign requested address
[2012/09/20 16:54:37,  0] nmbd/nmbd_subnetdb.c:127(make_subnet)
  nmbd_subnetdb:make_subnet()
    Failed to open nmb bcast socket on interface 10.0.17.239 for port 137.  Error was Can't assign requested address
[2012/09/20 16:54:37,  0] nmbd/nmbd.c:974(main)
  ERROR: Failed when creating subnet lists. Exiting.
Comment 7 Ben Lentz 2012-09-21 00:08:49 UTC
Ugh.. never mind. The patch I applied was in reverse... fail. A fresh rebuild and I again have good results on two AIX systems, one on 5.3 and one on 6.1.

Can we maybe get this fixed integrated into the next possible release?

Thanks.
Comment 8 SATOH Fumiyasu 2012-12-18 05:56:51 UTC
What should I do?
Comment 9 Ben Lentz 2012-12-18 14:18:48 UTC
Please help get the following patch:

--- lib/replace/getifaddrs.c    2011-01-07 13:24:23.000000000 +0100
+++ lib/replace/getifaddrs.c    2011-01-07 18:24:13.000000000 +0100
@@ -58,7 +58,7 @@
 {
     struct sockaddr *ret;
     socklen_t socklen;
-#ifdef HAVE_SOCKADDR_SA_LEN
+#if defined(HAVE_SOCKADDR_SA_LEN) && !defined(AIX)
     socklen = sa->sa_len;
 #else
     socklen = sizeof(struct sockaddr_storage);

Applied into the mainstream releases.
Comment 10 SATOH Fumiyasu 2012-12-18 15:23:40 UTC
Created attachment 8356 [details]
Patch for master and v3-6-test

I've created a patch by git format-patch.
Comment 11 Jeremy Allison 2012-12-22 00:53:12 UTC
I hate adding #ifdef AIX's for what looks like an AIX bug in their sa_len return.

Is there some way we can detect this in configure ?

Jeremy.
Comment 12 Ben Lentz 2012-12-22 02:14:24 UTC
Jeremy -
I have support for the affected system. I can open a PMR with IBM assuming you are able to prove a defect in one of the system functions.

Let me know if that's something you're able to prove/disprove and I will move forward with triaging the IBM support process.
Comment 13 Jeremy Allison 2012-12-23 20:24:10 UTC
Well not counting the trailing zeros in the IP address just seems completely broken to me. But we can't wait for IBM to fix, that would take forever. Easier to just add a configure test to detect this problem and fix it inside Samba IMHO.

Jeremy.
Comment 14 Christian Ambach 2013-01-11 17:10:36 UTC
I would at least try to open a PMR at the IBM support to ask if they think this is by design or an error.
There have been corrections to ioctls in the past, so maybe they'll accept it as a problem.

I am currently upgrading my AIX machine to the latest AIX6.1 level and see if the problem exists in that as well. More about that next week.
Comment 15 Christian Ambach 2013-02-01 17:11:21 UTC
Still fighting to a get a build on my AIX machine due to Bug 9557
Comment 16 Douglas Raxworthy 2013-02-08 02:06:19 UTC
Just an FYI, I'm on AIX 6100-06-05-1115 using samba 3.6.4 (precompiled by thewrittenword guys for AIX) and had similar problems with the netmask.
Command: /opt/TWWfsw/samba364/sbin/nmbd -F -d 5 -S
- Non-working configuration and debug output from nmbd (nmbd bin explicit required to get nmbd to start)
 Relevant Line(s) in smb.conf
  ---cut---
  bind interfaces only = yes
  nmbd bind explicit broadcast = no
  interfaces = en1
  ---cut---

 Debug output from nmbd - badly calculated netmask
  ---cut---
  dump workgroup on subnet       10.0.9.79: netmask= 255.255.255.16:
  ---cut---
 
- Working configuration and debug output from nmbd
 Relevant Line(s) in smb.conf (nmbd bin explicit no longer required)
  ---cut---
  bind interfaces only = yes
  interfaces = 10.0.9.79/255.255.255.0 127.0.0.1
  ---cut---

 Debug output from nmbd - correct netmask
  ---cut---
  dump workgroup on subnet       10.0.9.79: netmask=  255.255.255.0:
  ---cut---

Christian, precompiled may help you escape from Bug 9557 indirectly as you shouldn't need gcc installed to run things.
Comment 17 Björn Jacke 2014-06-17 12:11:14 UTC
*** Bug 9294 has been marked as a duplicate of this bug. ***