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>.
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;