[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#363598: udev should conflict with ifrename



On Fri, Apr 21, 2006 at 02:16:07PM +0200, Marco d'Itri wrote:

> Too bad that it is not what the kernel reports in the hotplug events and
> that there are no symlinks in sysfs to access a kobject by its ifindex.
> Sending a patch RFC to LKML would be the first step to improve this.

What stops udev from looking up the index before invoking any of the
rules? That avoids the races and does not require kernel support at all.

But if you insist on kernel support, here is a possible (untested) patch:

--- net/core/net-sysfs.c	2006-03-20 06:53:29.000000000 +0100
+++ net/core/net-sysfs-ifindex.c	2006-04-25 14:59:14.000000000 +0200
@@ -374,6 +374,15 @@
 	if ((size <= 0) || (i >= num_envp))
 		return -ENOMEM;
 
+	/* pass ifindex to uevent. */
+	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;
 }

Gabor

-- 
     ---------------------------------------------------------
     MTA SZTAKI Computer and Automation Research Institute
                Hungarian Academy of Sciences
     ---------------------------------------------------------



Reply to: