From: Felix Fietkau Date: Sun, 9 Oct 2011 20:42:34 +0000 (+0200) Subject: fix clearing device state, trigger it on device_init() X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=43d8e8e91a67ba6ecb87621c51614d6325fde7ae;p=oweals%2Fnetifd.git fix clearing device state, trigger it on device_init() --- diff --git a/device.c b/device.c index 5b27ce0..6929177 100644 --- a/device.c +++ b/device.c @@ -206,6 +206,7 @@ int device_init(struct device *dev, const struct device_type *type, const char * if (ret < 0) return ret; + system_if_clear_state(dev); device_check_state(dev); return 0; diff --git a/system-dummy.c b/system-dummy.c index 9a646dc..00a9b2a 100644 --- a/system-dummy.c +++ b/system-dummy.c @@ -64,6 +64,11 @@ int system_if_down(struct device *dev) return 0; } +void system_if_clear_state(struct device *dev) +{ + return 0; +} + int system_if_check(struct device *dev) { dev->ifindex = 0; diff --git a/system-linux.c b/system-linux.c index b823099..9f1aa9e 100644 --- a/system-linux.c +++ b/system-linux.c @@ -202,7 +202,7 @@ static int system_if_flags(const char *ifname, unsigned add, unsigned rem) /* * Clear bridge (membership) state and bring down device */ -static void system_if_clear_state(struct device *dev) +void system_if_clear_state(struct device *dev) { char buf[256]; char *bridge; @@ -236,7 +236,6 @@ int system_bridge_addbr(struct device *bridge, struct bridge_config *cfg) { unsigned long args[4] = {}; - system_if_clear_state(bridge); if (ioctl(sock_ioctl, SIOCBRADDBR, bridge->ifname) < 0) return -1; @@ -291,7 +290,6 @@ static int system_vlan(struct device *dev, int id) int system_vlan_add(struct device *dev, int id) { - system_if_clear_state(dev); return system_vlan(dev, id); } @@ -313,7 +311,6 @@ int system_if_down(struct device *dev) int system_if_check(struct device *dev) { - system_if_clear_state(dev); device_set_present(dev, (system_if_resolve(dev) >= 0)); return 0; } diff --git a/system.h b/system.h index a2bcf04..7600417 100644 --- a/system.h +++ b/system.h @@ -32,6 +32,7 @@ int system_bridge_delif(struct device *bridge, struct device *dev); int system_vlan_add(struct device *dev, int id); int system_vlan_del(struct device *dev); +void system_if_clear_state(struct device *dev); int system_if_up(struct device *dev); int system_if_down(struct device *dev); int system_if_check(struct device *dev);