Re: [OpenWrt-Devel] [PATCH netifd] device: Don't process link events anymore in device user specific callback handlers

2016-05-05 Thread Matthias Schiffer
On 11/02/2015 11:16 AM, Hans Dedecker wrote:
> Set link_state for all device types via the device_set_link API as all 
> devices are registered
> in the device tree list making it possible to always get the device via 
> device_get.
> The decice link state parameter will now actually reflect the corresponding 
> kernel device
> carrier state in all cases.
> Before this change a vlan/macvlan device could still have link_state enabled 
> if an interface
> was brought down; this was the case when the parent vlan/macvlan device was 
> still enabled as
> the netlink link_state event would be dropped for vlan/macvlan devices due to 
> keep_link_state
> in the function cb_rtnl_event.
> 
> Signed-off-by: Hans Dedecker 
> ---

This patch breaks the following setup:

I have a WLAN device, and on top of it a VLAN device which uses a shell
proto. Example:

config interface 'test'
option proto 'static'
option ipaddr '192.168.2.1'
option netmask '255.255.255.0'

config interface 'test2'
option ifname '@test.1'
option proto 'dhcp'


where 'test' is referenced by a wifi-iface. In this setup, wlan0.1 is
created, but the DHCP client never comes up (other shell protos yield the
same result).

If I revert this patch, or change @test.1 to wlan0.1, everything works fine.

Regards,
Matthias



signature.asc
Description: OpenPGP digital signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH netifd] device: Don't process link events anymore in device user specific callback handlers

2015-11-02 Thread Hans Dedecker
Set link_state for all device types via the device_set_link API as all devices 
are registered
in the device tree list making it possible to always get the device via 
device_get.
The decice link state parameter will now actually reflect the corresponding 
kernel device
carrier state in all cases.
Before this change a vlan/macvlan device could still have link_state enabled if 
an interface
was brought down; this was the case when the parent vlan/macvlan device was 
still enabled as
the netlink link_state event would be dropped for vlan/macvlan devices due to 
keep_link_state
in the function cb_rtnl_event.

Signed-off-by: Hans Dedecker 
---
 device.h   | 2 --
 macvlan.c  | 8 
 system-linux.c | 2 +-
 vlan.c | 6 --
 vlandev.c  | 8 
 5 files changed, 1 insertion(+), 25 deletions(-)

diff --git a/device.h b/device.h
index 37814c8..4ff335d 100644
--- a/device.h
+++ b/device.h
@@ -58,8 +58,6 @@ 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 051fe05..a0f11ae 100644
--- a/macvlan.c
+++ b/macvlan.c
@@ -72,12 +72,6 @@ macvlan_base_cb(struct device_user *dev, enum device_event 
ev)
case DEV_EVENT_REMOVE:
device_set_present(>dev, false);
break;
-   case DEV_EVENT_LINK_UP:
-   device_set_link(>dev, true);
-   break;
-   case DEV_EVENT_LINK_DOWN:
-   device_set_link(>dev, false);
-   break;
default:
return;
}
@@ -261,8 +255,6 @@ macvlan_create(const char *name, struct blob_attr *attr)
 const struct device_type macvlan_device_type = {
.name = "MAC VLAN",
.config_params = _attr_list,
-   .keep_link_status = true,
-
.create = macvlan_create,
.config_init = macvlan_config_init,
.reload = macvlan_reload,
diff --git a/system-linux.c b/system-linux.c
index f51c078..38f43fe 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -424,7 +424,7 @@ static int cb_rtnl_event(struct nl_msg *msg, void *arg)
goto out;
 
struct device *dev = device_get(nla_data(nla[IFLA_IFNAME]), false);
-   if (!dev || dev->type->keep_link_status)
+   if (!dev)
goto out;
 
if (!system_get_dev_sysctl("/sys/class/net/%s/carrier", dev->ifname, 
buf, sizeof(buf)))
diff --git a/vlan.c b/vlan.c
index 3d0a4cf..8e7141f 100644
--- a/vlan.c
+++ b/vlan.c
@@ -79,11 +79,6 @@ static void vlan_dev_cb(struct device_user *dep, enum 
device_event ev)
case DEV_EVENT_REMOVE:
device_set_present(>dev, new_state);
break;
-   case DEV_EVENT_LINK_UP:
-   new_state = true;
-   case DEV_EVENT_LINK_DOWN:
-   device_set_link(>dev, new_state);
-   break;
case DEV_EVENT_UPDATE_IFNAME:
vlan_dev_set_name(vldev, dep->dev);
device_broadcast_event(>dev, ev);
@@ -102,7 +97,6 @@ static struct device *get_vlan_device(struct device *dev, 
int id, bool create)
static const struct device_type vlan_type = {
.name = "VLAN",
.config_params = _attr_list,
-   .keep_link_status = true,
.free = free_vlan_if,
};
struct vlan_device *vldev;
diff --git a/vlandev.c b/vlandev.c
index 884e6ef..b93527c 100644
--- a/vlandev.c
+++ b/vlandev.c
@@ -63,12 +63,6 @@ vlandev_base_cb(struct device_user *dev, enum device_event 
ev)
case DEV_EVENT_REMOVE:
device_set_present(>dev, false);
break;
-   case DEV_EVENT_LINK_UP:
-   device_set_link(>dev, true);
-   break;
-   case DEV_EVENT_LINK_DOWN:
-   device_set_link(>dev, false);
-   break;
default:
return;
}
@@ -249,8 +243,6 @@ vlandev_create(const char *name, struct blob_attr *attr)
 const struct device_type vlandev_device_type = {
.name = "VLANDEV",
.config_params = _attr_list,
-   .keep_link_status = true,
-
.create = vlandev_create,
.config_init = vlandev_config_init,
.reload = vlandev_reload,
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel