diff options
-rw-r--r-- | plugins/loopback.c | 7 |
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; |