We create symlinks from /sys/class/net/<bridgename>/brif/<devname> to
/sys/class/net/<devname>/brport, but until now we have never updated the
links when network devices are renamed. This commit fixes this problem.
(Only the <devname> in /sys/class/net/<bridgename>/brif/<devname> needs to
be updated. Symlinks within sysfs have stable targets; that is, no matter
how the object that a sysfs symlink points to moves around, the link is
still maintained correctly.)
#ifdef SUPPORT_SYSFS
if (p->port_no != ODPP_LOCAL)
- sysfs_remove_link(&p->dp->ifobj, p->dev->name);
+ dp_sysfs_del_if(p);
#endif
dp_ifinfo_notify(RTM_DELLINK, p);
if (is_dp_dev(p->dev))
dp_dev_destroy(p->dev);
- if (p->port_no != ODPP_LOCAL)
- dp_sysfs_del_if(p);
dev_put(p->dev);
kobject_put(&p->kobj);
struct datapath *dp;
struct net_device *dev;
struct kobject kobj;
+ char linkname[IFNAMSIZ];
struct list_head node; /* Element in datapath.ports. */
};
void *ptr)
{
struct net_device *dev = ptr;
- struct net_bridge_port *p = dev->br_port;
- if (event == NETDEV_UNREGISTER && p) {
- struct datapath *dp = p->dp;
+ struct net_bridge_port *p;
+ struct datapath *dp;
+
+ p = dev->br_port;
+ if (!p)
+ return NOTIFY_DONE;
+ dp = p->dp;
+
+ switch (event) {
+ case NETDEV_UNREGISTER:
mutex_lock(&dp->mutex);
dp_del_port(p);
mutex_unlock(&dp->mutex);
+ break;
+
+ case NETDEV_CHANGENAME:
+ if (p->port_no != ODPP_LOCAL) {
+ mutex_lock(&dp->mutex);
+ dp_sysfs_del_if(p);
+ dp_sysfs_add_if(p);
+ mutex_unlock(&dp->mutex);
+ }
+ break;
}
return NOTIFY_DONE;
}
err = sysfs_create_link(&dp->ifobj, &p->kobj, p->dev->name);
if (err)
goto err_del;
+ strcpy(p->linkname, p->dev->name);
kobject_uevent(&p->kobj, KOBJ_ADD);
int dp_sysfs_del_if(struct net_bridge_port *p)
{
+ if (p->linkname[0]) {
+ sysfs_remove_link(&p->dp->ifobj, p->linkname);
+ p->linkname[0] = '\0';
+ }
if (p->kobj.dentry) {
kobject_uevent(&p->kobj, KOBJ_REMOVE);
kobject_del(&p->kobj);