Thread (4 messages) 4 messages, 2 authors, 2011-01-28

Re: [PATCH] RFC: ipv4: share sysctl net/ipv4/conf/DEVNAME/ tables

From: Alexey Dobriyan <hidden>
Date: 2011-01-15 10:47:59

On Sat, Jan 15, 2011 at 04:46:11AM +0200, Lucian Adrian Grijincu wrote:
To gain access to the name of the directory above a file, sysctl
handlers are passed an extra argument: the 'struct file*'
corresponding to the file. From the file we walk up one level to find
the name of the device. None of the other handlers were changed to
receive this extra parameter, but due to C's calling convention they
shouldn't care.
We don't do creepy stuff like that.

I wonder where interactions with device renaming are handled.
+static int devinet_conf_handler(ctl_table *ctl, int write,
+				void __user *buffer,
+				size_t *lenp, loff_t *ppos,
+				struct file *filp,
+				proc_handler *proc_handler)
+{
+	/* The path to this file is of the form /proc/sys/net/ipv4/conf/$DEVNAME/$CTL
+	 *
+	 * To save space, ctl_table is shared between all network
+	 * devices in the same network namespace, but we need to
+	 * change the data corresponding to the $DEVNAME network
+	 * device, not any other's.
+	 *
+	 * Use $DEVNAME to obtain the coresponding ipv4_devconf.
+	 */
+	struct net *net = ctl->extra2;
+	const char *dev_name = filp->f_path.dentry->d_parent->d_name.name;
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help