Device name changing via rtnetlink
Subsystems (2)
PATCH 1/1 Device name changing via rtnetlink
Allows changing of device name via rtnetlink. Last bit needed to do full link configuration via rtnetlink.
include/linux/netdevice.h +1 -0
@@ -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);
net/core/dev.c +1 -0
@@ -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);
net/core/rtnetlink.c +17 -0
@@ -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:
In article <[email protected]> (at Fri, 10 Sep 2004 15:36:37 +0200), Thomas Graf <[email protected]> says:
Quoted 4 lines
Allows changing of device name via rtnetlink. Last bit needed to do full link configuration via rtnetlink.
Signed-off-by Thomas Graf <[email protected]>
:
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (ida[IFLA_IFNAME - 1]->rta_len > RTA_LENGTH(IFNAMSIZ)) + goto out;
Please use sizeof(ifname) instead.
Signature · 2 lines
Hideaki YOSHIFUJI @ USAGI Project <[email protected]> GPG FP: 9022 65EB 1ECF 3AD1 0BDF 80D8 4807 F894 E062 0EEA
* YOSHIFUJI Hideaki / ?$B5HF#1QL@ <[email protected]> 2004-09-10 23:00
Quoted 11 lines
In article <[email protected]> (at Fri, 10 Sep 2004 15:36:37 +0200), Thomas Graf <[email protected]> says:
Quoted 4 lines
Allows changing of device name via rtnetlink. Last bit needed to do full link configuration via rtnetlink.
Signed-off-by Thomas Graf <[email protected]>:
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (ida[IFLA_IFNAME - 1]->rta_len > RTA_LENGTH(IFNAMSIZ)) + goto out;Please use sizeof(ifname) instead.
Thanks for the hint.
Allows changing of device name via rtnetlink. Last bit needed to do full link configuration via rtnetlink.
include/linux/netdevice.h +1 -0
@@ -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);
net/core/dev.c +1 -0
@@ -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);
net/core/rtnetlink.c +17 -0
@@ -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 (sizeof (ifname))) + 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:
In article <[email protected]> (at Fri, 10 Sep 2004 16:28:04 +0200), Thomas Graf <[email protected]> says:
Quoted 8 lines
Quoted 1 line
Please use sizeof(ifname) instead.
Thanks for the hint.
Allows changing of device name via rtnetlink. Last bit needed to do full link configuration via rtnetlink.
Signed-off-by Thomas Graf <[email protected]>
Thanks. Ack.
--yoshfuji