summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGrant Erickson <marathon96@gmail.com>2011-07-15 10:21:34 -0700
committerMarcel Holtmann <marcel@holtmann.org>2011-07-15 22:33:54 +0200
commit70580a5b75b19b97aaf801af27e6bda2a78ab58c (patch)
treee82b694ad9897ce65d0f3f93244a2a1fe6810c03 /plugins
parented074699bb0a55a26e9cccd3e42285fba2107cb7 (diff)
downloadconnman-70580a5b75b19b97aaf801af27e6bda2a78ab58c.tar.gz
connman-70580a5b75b19b97aaf801af27e6bda2a78ab58c.tar.bz2
connman-70580a5b75b19b97aaf801af27e6bda2a78ab58c.zip
loopback: Recover Loopback on Setup when Up but No Address
It is possible to end up in situations in which the loopback interface is up but has no valid address. In that case, we expect SIOCGIFADDR will return EADDRNOTAVAIL and valid_loopback should return FALSE such that connman can add a loopback address back to the interface. This is a partial fix for bug 21001 <https://bugs.meego.com/show_bug.cgi?id=21001>.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/loopback.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/plugins/loopback.c b/plugins/loopback.c
index ac3e2fcf..f9624155 100644
--- a/plugins/loopback.c
+++ b/plugins/loopback.c
@@ -188,11 +188,16 @@ static gboolean valid_loopback(int sk, struct ifreq *ifr)
int err;
char buf[INET_ADDRSTRLEN];
+ /* It is possible to end up in situations in which the
+ * loopback interface is up but has no valid address. In that
+ * case, we expect EADDRNOTAVAIL and should return FALSE.
+ */
+
err = ioctl(sk, SIOCGIFADDR, ifr);
if (err < 0) {
err = -errno;
connman_error("Getting address failed (%s)", strerror(-err));
- return TRUE;
+ return err != -EADDRNOTAVAIL ? TRUE : FALSE;
}
addr = (struct sockaddr_in *) &ifr->ifr_addr;