summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2008-08-19 17:31:46 -0700
committerKarolin Seeger <kseeger@samba.org>2008-08-21 08:45:25 +0200
commit435c10268bb6987ab7e8206cd6c45bd9961c5632 (patch)
treece82a4607ad43c6bbf25f33bdda83b9ee23a3bd2
parenta7058ed1ef2622abdb75fe997ce4a5c570898929 (diff)
downloadsamba-435c10268bb6987ab7e8206cd6c45bd9961c5632.tar.gz
Fix bug 5697 nmbd spins in reload_interfaces when only loopback has an IPv4 address
reported by Ted Percival <ted@midg3t.net>. Jeremy. (cherry picked from commit 4ac537d1b78c915fe25c219958312cf22f3cba80)
-rw-r--r--source/lib/interface.c7
-rw-r--r--source/nmbd/nmbd.c4
-rw-r--r--source/nmbd/nmbd_subnetdb.c11
3 files changed, 13 insertions, 9 deletions
diff --git a/source/lib/interface.c b/source/lib/interface.c
index eb0af9ef341..2e7c2706a06 100644
--- a/source/lib/interface.c
+++ b/source/lib/interface.c
@@ -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++;
}
diff --git a/source/nmbd/nmbd.c b/source/nmbd/nmbd.c
index af4acc84d07..b72be2b482d 100644
--- a/source/nmbd/nmbd.c
+++ b/source/nmbd/nmbd.c
@@ -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();
}
diff --git a/source/nmbd/nmbd_subnetdb.c b/source/nmbd/nmbd_subnetdb.c
index a4422d27d57..225def52cce 100644
--- a/source/nmbd/nmbd_subnetdb.c
+++ b/source/nmbd/nmbd_subnetdb.c
@@ -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);
/*