inet: Properly remove IPv4 address and set interface down
authorPatrik Flykt <patrik.flykt@linux.intel.com>
Tue, 28 Aug 2012 07:51:30 +0000 (10:51 +0300)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Wed, 29 Aug 2012 07:57:15 +0000 (10:57 +0300)
The interface was not properly set down and thus the services
were not removed.

Fixes BMC#25659

src/inet.c

index 75efc26..1f9bd0d 100644 (file)
@@ -311,7 +311,7 @@ done:
 
 int connman_inet_ifdown(int index)
 {
-       struct ifreq ifr;
+       struct ifreq ifr, addr_ifr;
        struct sockaddr_in *addr;
        int sk, err;
 
@@ -332,9 +332,11 @@ int connman_inet_ifdown(int index)
                goto done;
        }
 
-       addr = (struct sockaddr_in *)&ifr.ifr_addr;
+       memset(&addr_ifr, 0, sizeof(addr_ifr));
+       memcpy(&addr_ifr.ifr_name, &ifr.ifr_name, sizeof(ifr.ifr_name));
+       addr = (struct sockaddr_in *)&addr_ifr.ifr_addr;
        addr->sin_family = AF_INET;
-       if (ioctl(sk, SIOCSIFADDR, &ifr) < 0)
+       if (ioctl(sk, SIOCSIFADDR, &addr_ifr) < 0)
                connman_warn("Could not clear IPv4 address index %d", index);
 
        if (!(ifr.ifr_flags & IFF_UP)) {