Fix bug 5697 nmbd spins in reload_interfaces when only loopback has an IPv4 address
authorJeremy Allison <jra@samba.org>
Wed, 20 Aug 2008 00:31:46 +0000 (17:31 -0700)
committerKarolin Seeger <kseeger@samba.org>
Thu, 21 Aug 2008 06:45:25 +0000 (08:45 +0200)
reported by Ted Percival <ted@midg3t.net>.
Jeremy.
(cherry picked from commit 4ac537d1b78c915fe25c219958312cf22f3cba80)

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

index eb0af9ef341d85edcad4f5040738f98cc9cc6fef..2e7c2706a0699628df778715c03f7b8257fc5893 100644 (file)
@@ -131,15 +131,18 @@ int iface_count(void)
 }
 
 /****************************************************************************
- How many interfaces do we have (v4 only) ?
+ How many non-loopback IPv4 interfaces do we have ?
 **************************************************************************/
 
-int iface_count_v4(void)
+int iface_count_v4_nl(void)
 {
        int ret = 0;
        struct interface *i;
 
        for (i=local_interfaces;i;i=i->next) {
+               if (is_loopback_addr(&i->ip)) {
+                       continue;
+               }
                if (i->ip.ss_family == AF_INET) {
                        ret++;
                }
index af4acc84d07a217fa5e9f43bfabe97702aa603d9..b72be2b482dac0474a2ee3f3e9df6edf634c7e4b 100644 (file)
@@ -293,8 +293,8 @@ static void reload_interfaces(time_t t)
 
                BlockSignals(false, SIGTERM);
 
-               /* We only count IPv4 interfaces here. */
-               while (iface_count_v4() == 0 && !got_sig_term) {
+               /* We only count IPv4, non-loopback interfaces here. */
+               while (iface_count_v4_nl() == 0 && !got_sig_term) {
                        sleep(5);
                        load_interfaces();
                }
index a4422d27d573541490c721c8f97e4ca044ceb776..225def52cced2c84ea2bc3f7ed746b71e77d765e 100644 (file)
@@ -195,19 +195,20 @@ struct subnet_record *make_normal_subnet(const struct interface *iface)
 bool create_subnets(void)
 {
        /* We only count IPv4 interfaces whilst we're waiting. */
-       int num_interfaces = iface_count_v4();
+       int num_interfaces;
        int i;
        struct in_addr unicast_ip, ipzero;
 
   try_interfaces_again:
 
-       if (iface_count_v4() == 0) {
-               DEBUG(0,("create_subnets: No local interfaces !\n"));
+       /* Only count IPv4, non-loopback interfaces. */
+       if (iface_count_v4_nl() == 0) {
+               DEBUG(0,("create_subnets: No local IPv4 non-loopback interfaces !\n"));
                DEBUG(0,("create_subnets: Waiting for an interface to appear ...\n"));
        }
 
-       /* We only count IPv4 interfaces here. */
-       while (iface_count_v4() == 0) {
+       /* We only count IPv4, non-loopback interfaces here. */
+       while (iface_count_v4_nl() == 0) {
                void (*saved_handler)(int);
 
                /*