lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Fri, 27 Apr 2007 11:53:27 -0700 From: Greg Kroah-Hartman <gregkh@...e.de> To: linux-kernel@...r.kernel.org Cc: Jean Tourrilhes <jt@....hp.com>, Kay Sievers <kay.sievers@...y.org>, Greg Kroah-Hartman <gregkh@...e.de> Subject: [PATCH 13/46] Driver core: notify userspace of network device renames From: Jean Tourrilhes <jt@....hp.com> Provide rename event for when we rename network devices. Signed-off-by: Jean Tourrilhes <jt@....hp.com> Cc: Kay Sievers <kay.sievers@...y.org> Signed-off-by: Greg Kroah-Hartman <gregkh@...e.de> --- lib/kobject.c | 30 ++++++++++++++++++++++++++++++ net/core/net-sysfs.c | 11 +++++++++++ 2 files changed, 41 insertions(+), 0 deletions(-) diff --git a/lib/kobject.c b/lib/kobject.c index bbbfab4..db1d237 100644 --- a/lib/kobject.c +++ b/lib/kobject.c @@ -311,13 +311,43 @@ EXPORT_SYMBOL(kobject_set_name); int kobject_rename(struct kobject * kobj, const char *new_name) { int error = 0; + const char *devpath = NULL; + char *devpath_string = NULL; + char *envp[2]; kobj = kobject_get(kobj); if (!kobj) return -EINVAL; if (!kobj->parent) return -EINVAL; + + devpath = kobject_get_path(kobj, GFP_KERNEL); + if (!devpath) { + error = -ENOMEM; + goto out; + } + devpath_string = kmalloc(strlen(devpath) + 15, GFP_KERNEL); + if (!devpath_string) { + error = -ENOMEM; + goto out; + } + sprintf(devpath_string, "DEVPATH_OLD=%s", devpath); + envp[0] = devpath_string; + envp[1] = NULL; + /* Note : if we want to send the new name alone, not the full path, + * we could probably use kobject_name(kobj); */ + error = sysfs_rename_dir(kobj, kobj->parent->dentry, new_name); + + /* This function is mostly/only used for network interface. + * Some hotplug package track interfaces by their name and + * therefore want to know when the name is changed by the user. */ + if (!error) + kobject_uevent_env(kobj, KOBJ_MOVE, envp); + +out: + kfree(devpath_string); + kfree(devpath); kobject_put(kobj); return error; diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 221a64a..e441ec7 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -424,6 +424,17 @@ static int netdev_uevent(struct device *d, char **envp, if ((size <= 0) || (i >= num_envp)) return -ENOMEM; + /* pass ifindex to uevent. + * ifindex is useful as it won't change (interface name may change) + * and is what RtNetlink uses natively. */ + envp[i++] = buf; + n = snprintf(buf, size, "IFINDEX=%d", dev->ifindex) + 1; + buf += n; + size -= n; + + if ((size <= 0) || (i >= num_envp)) + return -ENOMEM; + envp[i] = NULL; return 0; } -- 1.5.1.2 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@...r.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists