From: Felix Fietkau Date: Mon, 20 Oct 2014 20:07:18 +0000 (+0200) Subject: device: make link status detection optional for vlan devices X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=commitdiff_plain;h=5a4eb870afc69e9fa93fdccb8a42f75e8e357f4e device: make link status detection optional for vlan devices Fixes a race condition that triggers endless link loss / detect calls when VLAN devices are created. Signed-off-by: Felix Fietkau --- diff --git a/device.h b/device.h index 73b2656..adf72c5 100644 --- a/device.h +++ b/device.h @@ -47,6 +47,8 @@ struct device_type { struct list_head list; const char *name; + bool keep_link_status; + const struct uci_blob_param_list *config_params; struct device *(*create)(const char *name, struct blob_attr *attr); diff --git a/macvlan.c b/macvlan.c index e5a4891..019a7ff 100644 --- a/macvlan.c +++ b/macvlan.c @@ -258,6 +258,7 @@ macvlan_create(const char *name, struct blob_attr *attr) const struct device_type macvlan_device_type = { .name = "MAC VLAN", .config_params = &macvlan_attr_list, + .keep_link_status = true, .create = macvlan_create, .config_init = macvlan_config_init, diff --git a/system-linux.c b/system-linux.c index 7955cec..7ae9e27 100644 --- a/system-linux.c +++ b/system-linux.c @@ -322,7 +322,8 @@ static int cb_rtnl_event(struct nl_msg *msg, void *arg) goto out; device_set_ifindex(dev, ifi->ifi_index); - device_set_link(dev, ifi->ifi_flags & IFF_LOWER_UP ? true : false); + if (!dev->type->keep_link_status) + device_set_link(dev, ifi->ifi_flags & IFF_LOWER_UP ? true : false); out: return 0; diff --git a/vlan.c b/vlan.c index 28b1441..354e12f 100644 --- a/vlan.c +++ b/vlan.c @@ -102,6 +102,7 @@ static struct device *get_vlan_device(struct device *dev, int id, bool create) static const struct device_type vlan_type = { .name = "VLAN", .config_params = &device_attr_list, + .keep_link_status = true, .free = free_vlan_if, }; struct vlan_device *vldev; diff --git a/vlandev.c b/vlandev.c index 36a5c63..7b2038e 100644 --- a/vlandev.c +++ b/vlandev.c @@ -246,6 +246,7 @@ vlandev_create(const char *name, struct blob_attr *attr) const struct device_type vlandev_device_type = { .name = "VLANDEV", .config_params = &vlandev_attr_list, + .keep_link_status = true, .create = vlandev_create, .config_init = vlandev_config_init,