registration fixes for vbus venet macvlan driver
Subsystems (2)
cover registration fixes for vbus venet macvlan driver
Applies to alacrityvm.git/master:4ac12ced9)
These patches fix some netdev registration problems discovered with the venet macvlan driver. The newline patch is trivial. The other patch addresses several problems with registration. Worth noting are the problems registering a netdevice that has previously been unregistered. This doesn't seem work and I was wondering if this is expected behavior in net/core(see patch 2/2 for a description).
---
Patrick Mullaney (2):
venet: Fixes for shutdown and re-registration of venet devices.
venet-macvlan: correctly remove newline from lower device name
kernel/vbus/devices/venet/device.c | 11 ++++-- kernel/vbus/devices/venet/macvlan.c | 61 +++++++++++++++++++++++++------ kernel/vbus/devices/venet/venetdevice.h | 7 +++- 3 files changed, 63 insertions(+), 16 deletions(-)
PATCH 1/2 venet-macvlan: correctly remove newline from lower device name
---
kernel/vbus/devices/venet/macvlan.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
kernel/vbus/devices/venet/macvlan.c +5 -1
@@ -350,7 +350,11 @@ ll_ifname_store(struct vbus_device *dev, struct vbus_device_attribute *attr,if (priv->dev.vbus.opened)return -EINVAL ; -strncpy (priv->ll_ifname, buf, count-1 ); +memcpy (priv->ll_ifname, buf, count); + +/* remove trailing newline if present */ +if (priv->ll_ifname[count-1 ] =='\n' ) + priv->ll_ifname[count-1 ] ='\0' ;if (priv->mdev.lowerdev) {dev_put (priv->mdev.lowerdev);
PATCH 2/2 venet: Fixes for shutdown and re-registration of venet devices.
In reply to Patrick MullaneyFixed a problem with simple re-registration of the venet netdevice. The netdev core infrastructure appears to have a problem with re-registering a previously registered netdevice(reg_state and kobj.state_initialized need to be reset to their default values). I now do this prior to calling register_netdev but this probably should be moved to net/core. Fixed an issue with the removal of the lower level device of a venet-macvlan. I'm planning a cleaner solution in the future. Fixed a lock issue with venet-macvlan stop method that was causing a hang.
---
kernel/vbus/devices/venet/device.c | 11 +++++- kernel/vbus/devices/venet/macvlan.c | 55 +++++++++++++++++++++++++------ kernel/vbus/devices/venet/venetdevice.h | 7 +++- 3 files changed, 58 insertions(+), 15 deletions(-)
kernel/vbus/devices/venet/device.c +8 -3
@@ -2300,7 +2300,7 @@ client_mac_show(struct vbus_device *dev, struct vbus_device_attribute *attr,struct vbus_device_attribute attr_cmac =__ATTR (client_mac,S_IRUGO |S_IWUSR , client_mac_show, cmac_store); -static ssize_t +ssize_t enabled_show (struct vbus_device *dev,struct vbus_device_attribute *attr,char *buf) {
@@ -2309,7 +2309,7 @@ enabled_show(struct vbus_device *dev, struct vbus_device_attribute *attr,return snprintf (buf,PAGE_SIZE ,"%d\n" , priv->netif.enabled); } -static ssize_t +ssize_t enabled_store (struct vbus_device *dev,struct vbus_device_attribute *attr,const char *buf,size_t count) {
@@ -2323,8 +2323,13 @@ enabled_store(struct vbus_device *dev, struct vbus_device_attribute *attr,if (enabled !=0 && enabled !=1 )return -EINVAL ; -if (enabled && !priv->netif.enabled) +if (enabled && !priv->netif.enabled) { +/* need to un-initialize certain fields of the +net_device so that it may be re-registered */ + priv->netif.dev->reg_state =NETREG_UNINITIALIZED ; + priv->netif.dev->dev.kobj.state_initialized =0 ; ret =register_netdev (priv->netif.dev); + }if (!enabled && priv->netif.enabled)venetdev_netdev_unregister (priv);
kernel/vbus/devices/venet/macvlan.c +44 -11
110 lines not on this page · raw message
kernel/vbus/devices/venet/venetdevice.h +6 -1
@@ -150,7 +150,7 @@ struct net_device_stats *venetdev_get_stats(struct venetdev *dev);static inline void venetdev_netdev_unregister (struct venetdev *priv) {if (priv->netif.enabled) { -venetdev_netdev_stop (priv->netif.dev); +venetdev_stop (priv);unregister_netdev (priv->netif.dev); } }
@@ -173,6 +173,11 @@ extern struct vbus_device_attribute attr_ifname;extern struct vbus_device_attribute attr_txmitigation;extern struct vbus_device_attribute attr_zcthresh; +ssize_t enabled_store (struct vbus_device *dev, +struct vbus_device_attribute *attr, +const char *buf,size_t count); +ssize_t enabled_show (struct vbus_device *dev, +struct vbus_device_attribute *attr,char *buf);ssize_t cmac_store (struct vbus_device *dev,struct vbus_device_attribute *attr,const char *buf,size_t count);