system-linux.c: fix sysctl setting
[project/netifd.git] / system-linux.c
index c4d094d..d2e3d06 100644 (file)
@@ -154,7 +154,7 @@ static void system_set_sysctl(const char *path, const char *val)
 
 static void system_set_dev_sysctl(const char *path, const char *device, const char *val)
 {
-       snprintf(dev_buf, sizeof(dev_buf), path, val);
+       snprintf(dev_buf, sizeof(dev_buf), path, device);
        system_set_sysctl(dev_buf, val);
 }
 
@@ -235,6 +235,9 @@ found:
        if (dev->type != &simple_device_type)
                return;
 
+       if (add && system_if_force_external(dev->ifname))
+               return;
+
        device_set_present(dev, add);
 }
 
@@ -275,6 +278,8 @@ int system_bridge_delbr(struct device *bridge)
 static int system_bridge_if(const char *bridge, struct device *dev, int cmd, void *data)
 {
        struct ifreq ifr;
+
+       memset(&ifr, 0, sizeof(ifr));
        if (dev)
                ifr.ifr_ifindex = dev->ifindex;
        else
@@ -350,6 +355,8 @@ static int system_if_resolve(struct device *dev)
 static int system_if_flags(const char *ifname, unsigned add, unsigned rem)
 {
        struct ifreq ifr;
+
+       memset(&ifr, 0, sizeof(ifr));
        strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
        ioctl(sock_ioctl, SIOCGIFFLAGS, &ifr);
        ifr.ifr_flags |= add;