]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
Have nmbd check all available interfaces for WINS before failing
authorAravind Srinivasan <aravind.srinivasan@isilon.com>
Thu, 5 Feb 2009 22:46:59 +0000 (14:46 -0800)
committerKarolin Seeger <kseeger@samba.org>
Mon, 16 Feb 2009 08:56:56 +0000 (09:56 +0100)
When nmbd is acting as WINS, it picks the first interface's IP as WINS
server's IP. If the first interface's IP is zero, we will just quit
(even though we might have other interfaces with valid IPs).

This patch makes nmbd look at all interfaces and pick the first interface
with a valid IP as the WINS server's IP.
(cherry picked from commit d998ee9025f2ad2df73e25c12e35e9218b97147e)

source/lib/interface.c
source/nmbd/nmbd_become_dmb.c
source/nmbd/nmbd_subnetdb.c

index 15fed9e71b2a967bceba9a782318abe0cd27fa70..cc8fb371d4ee17d9e5a3f0d10946bb891b43c8f7 100644 (file)
@@ -151,7 +151,8 @@ int iface_count_v4_nl(void)
 }
 
 /****************************************************************************
- Return a pointer to the in_addr of the first IPv4 interface.
+ Return a pointer to the in_addr of the first IPv4 interface that's
+ not 0.0.0.0.
 **************************************************************************/
 
 const struct in_addr *first_ipv4_iface(void)
@@ -159,7 +160,9 @@ const struct in_addr *first_ipv4_iface(void)
        struct interface *i;
 
        for (i=local_interfaces;i ;i=i->next) {
-               if (i->ip.ss_family == AF_INET) {
+               if ((i->ip.ss_family == AF_INET) &&
+                   (!is_zero_ip_v4(((struct sockaddr_in *)&i->ip)->sin_addr)))
+               {
                        break;
                }
        }
index a0b2ef15f8b804c6e2a2be874d3304969c6df84f..827d56cb0624393511d82a678fb6b30b2c320de2 100644 (file)
@@ -128,7 +128,8 @@ in workgroup %s on subnet %s\n",
 
                work->dmb_name = nmbname;
 
-               /* Pick the first interface IPv4 address as the domain master browser ip. */
+               /* Pick the first interface IPv4 address as the domain master
+                * browser ip. */
                nip = first_ipv4_iface();
                if (!nip) {
                        DEBUG(0,("become_domain_master_stage2: "
index 225def52cced2c84ea2bc3f7ed746b71e77d765e..83515e94374a399afda2c273737b0a6df91b2af8 100644 (file)
@@ -287,7 +287,8 @@ bool create_subnets(void)
        }
 
        if (lp_we_are_a_wins_server()) {
-               /* Pick the first interface IPv4 address as the WINS server ip. */
+               /* Pick the first interface IPv4 address as the WINS server
+                * ip. */
                const struct in_addr *nip = first_ipv4_iface();
 
                if (!nip) {