netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH 2.6 NET] Device name changing via rtnetlink
@ 2004-09-10 19:50 Jean Tourrilhes
  2004-09-10 20:06 ` Thomas Graf
  0 siblings, 1 reply; 20+ messages in thread
From: Jean Tourrilhes @ 2004-09-10 19:50 UTC (permalink / raw)
  To: Thomas Graf, netdev

Thomas Graf wrote :
> 
> Allows changing of device name via rtnetlink. Last bit needed to do full
> link configuration via rtnetlink.
> 
> Signed-off-by: Thomas Graf <tgraf@suug.ch>

	This does not work, because you don't return the new name to
user space. If the new name is a pattern, such as "eth%d" or "wlan%d",
you absolutely need to return the new instanciated device name to user
space so that userspace doesn't loose track of the device.

	Please look at this snipset from dev.c :

-----------------------------------------------------------------
		/*
		 *	These ioctl calls:
		 *	- require superuser power.
		 *	- require strict serialization.
		 *	- return a value
		 */
		case SIOCGMIIPHY:
		case SIOCGMIIREG:
		case SIOCSIFNAME:
			if (!capable(CAP_NET_ADMIN))
				return -EPERM;
			dev_load(ifr.ifr_name);
			rtnl_lock();
			ret = dev_ifsioc(&ifr, cmd);
			rtnl_unlock();
			if (!ret) {
				if (colon)
					*colon = ':';
				if (copy_to_user(arg, &ifr,
						 sizeof(struct ifreq)))
					ret = -EFAULT;
			}
			return ret;
-----------------------------------------------------------------

	I'm all for converting stuff to RtNetlink, but please don't
criple the functionality...

	Have fun...

	Jean

^ permalink raw reply	[flat|nested] 20+ messages in thread
* [PATCH 2.6 NET] Device name changing via rtnetlink
@ 2004-09-10 13:36 Thomas Graf
  2004-09-10 14:00 ` YOSHIFUJI Hideaki / 吉藤英明
  0 siblings, 1 reply; 20+ messages in thread
From: Thomas Graf @ 2004-09-10 13:36 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev

Allows changing of device name via rtnetlink. Last bit needed to do full
link configuration via rtnetlink.

Signed-off-by: Thomas Graf <tgraf@suug.ch>


diff -Nru linux-2.6.9-rc1-bk15.orig/include/linux/netdevice.h linux-2.6.9-rc1-bk15/include/linux/netdevice.h
--- linux-2.6.9-rc1-bk15.orig/include/linux/netdevice.h	2004-09-08 18:32:05.000000000 +0200
+++ linux-2.6.9-rc1-bk15/include/linux/netdevice.h	2004-09-10 12:42:07.000000000 +0200
@@ -677,6 +677,7 @@
 extern int		dev_ethtool(struct ifreq *);
 extern unsigned		dev_get_flags(const struct net_device *);
 extern int		dev_change_flags(struct net_device *, unsigned);
+extern int		dev_change_name(struct net_device *, char *);
 extern int		dev_set_mtu(struct net_device *, int);
 extern void		dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev);
 
diff -Nru linux-2.6.9-rc1-bk15.orig/net/core/dev.c linux-2.6.9-rc1-bk15/net/core/dev.c
--- linux-2.6.9-rc1-bk15.orig/net/core/dev.c	2004-09-08 18:33:42.000000000 +0200
+++ linux-2.6.9-rc1-bk15/net/core/dev.c	2004-09-10 12:41:19.000000000 +0200
@@ -3347,6 +3347,7 @@
 EXPORT_SYMBOL(dev_set_allmulti);
 EXPORT_SYMBOL(dev_set_promiscuity);
 EXPORT_SYMBOL(dev_change_flags);
+EXPORT_SYMBOL(dev_change_name);
 EXPORT_SYMBOL(dev_set_mtu);
 EXPORT_SYMBOL(free_netdev);
 EXPORT_SYMBOL(netdev_boot_setup_check);
diff -Nru linux-2.6.9-rc1-bk15.orig/net/core/rtnetlink.c linux-2.6.9-rc1-bk15/net/core/rtnetlink.c
--- linux-2.6.9-rc1-bk15.orig/net/core/rtnetlink.c	2004-09-08 18:33:42.000000000 +0200
+++ linux-2.6.9-rc1-bk15/net/core/rtnetlink.c	2004-09-10 12:36:54.000000000 +0200
@@ -345,6 +345,23 @@
 		dev->weight = *((u32 *) RTA_DATA(ida[IFLA_WEIGHT - 1]));
 	}
 
+	if (ida[IFLA_IFNAME - 1]) {
+		char ifname[IFNAMSIZ];
+
+		if (ida[IFLA_IFNAME - 1]->rta_len > RTA_LENGTH(IFNAMSIZ))
+			goto out;
+
+		memset(ifname, 0, sizeof(ifname));
+		memcpy(ifname, RTA_DATA(ida[IFLA_IFNAME - 1]),
+			RTA_PAYLOAD(ida[IFLA_IFNAME - 1]));
+		ifname[IFNAMSIZ - 1] = '\0';
+
+		err = dev_change_name(dev, ifname);
+
+		if (err)
+			goto out;
+	}
+
 	err = 0;
 
 out:

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2004-09-13  0:20 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-10 19:50 [PATCH 2.6 NET] Device name changing via rtnetlink Jean Tourrilhes
2004-09-10 20:06 ` Thomas Graf
2004-09-10 20:13   ` Jean Tourrilhes
2004-09-10 20:22     ` Thomas Graf
2004-09-10 20:31       ` jamal
2004-09-10 20:32       ` Jean Tourrilhes
2004-09-10 20:43         ` Thomas Graf
2004-09-10 22:58           ` jamal
2004-09-10 23:17             ` Thomas Graf
2004-09-11  2:01               ` jamal
2004-09-11 13:44                 ` Thomas Graf
2004-09-11 19:59                   ` jamal
2004-09-11 22:06                     ` Thomas Graf
2004-09-12 17:27                       ` jamal
2004-09-13  0:20                         ` David S. Miller
2004-09-10 23:04           ` David S. Miller
  -- strict thread matches above, loose matches on Subject: below --
2004-09-10 13:36 Thomas Graf
2004-09-10 14:00 ` YOSHIFUJI Hideaki / 吉藤英明
2004-09-10 14:28   ` Thomas Graf
2004-09-10 14:31     ` YOSHIFUJI Hideaki / 吉藤英明

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).