diff mbox

[net-next] : net: remove ifalias on empty given alias

Message ID 48D948E8.6090804@hartkopp.net
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Oliver Hartkopp Sept. 23, 2008, 7:52 p.m. UTC
This patch removes the potentially allocated ifalias when the (new) 
given alias is empty.

E.g. when setting

echo "" > /sys/class/net/eth0/ifalias

Signed-off-by: Oliver Hartkopp <oliver@hartkopp.net>
---

Hello Stephen,

this patch allows to 'remove' or reset the ifalias by giving an empty alias.
The patch is tested.
Btw. ifalias is a nice idea also for CAN bus people to 'name' a given 
CAN bus.

Thanks & regards,
Oliver

Comments

stephen hemminger Sept. 23, 2008, 8:14 p.m. UTC | #1
On Tue, 23 Sep 2008 21:52:08 +0200
Oliver Hartkopp <oliver@hartkopp.net> wrote:

> This patch removes the potentially allocated ifalias when the (new) 
> given alias is empty.
> 
> E.g. when setting
> 
> echo "" > /sys/class/net/eth0/ifalias
> 
> Signed-off-by: Oliver Hartkopp <oliver@hartkopp.net>
> ---
> 
> Hello Stephen,
> 
> this patch allows to 'remove' or reset the ifalias by giving an empty alias.
> The patch is tested.
> Btw. ifalias is a nice idea also for CAN bus people to 'name' a given 
> CAN bus.
> 
> Thanks & regards,
> Oliver
> 
> 

Acked-by: Stephen Hemminger <shemminger@vyatta.com>

Also, udev could put a default value in based on the slot information it has.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller Sept. 24, 2008, 4:23 a.m. UTC | #2
From: Stephen Hemminger <shemminger@vyatta.com>
Date: Tue, 23 Sep 2008 13:14:52 -0700

> On Tue, 23 Sep 2008 21:52:08 +0200
> Oliver Hartkopp <oliver@hartkopp.net> wrote:
> 
> > This patch removes the potentially allocated ifalias when the (new) 
> > given alias is empty.
> > 
> > E.g. when setting
> > 
> > echo "" > /sys/class/net/eth0/ifalias
> > 
> > Signed-off-by: Oliver Hartkopp <oliver@hartkopp.net>
> > ---
> > 
> > Hello Stephen,
> > 
> > this patch allows to 'remove' or reset the ifalias by giving an empty alias.
> > The patch is tested.
> > Btw. ifalias is a nice idea also for CAN bus people to 'name' a given 
> > CAN bus.
> > 
> > Thanks & regards,
> > Oliver
> > 
> > 
> 
> Acked-by: Stephen Hemminger <shemminger@vyatta.com>
> 
> Also, udev could put a default value in based on the slot information it has.

I've applied Oliver's patch.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/core/dev.c b/net/core/dev.c
index e913905..a90737f 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -967,6 +967,14 @@  int dev_set_alias(struct net_device *dev, const char *alias, size_t len)
 	if (len >= IFALIASZ)
 		return -EINVAL;
 
+	if (!len) {
+		if (dev->ifalias) {
+			kfree(dev->ifalias);
+			dev->ifalias = NULL;
+		}
+		return 0;
+	}
+
 	dev->ifalias = krealloc(dev->ifalias, len+1, GFP_KERNEL);
 	if (!dev->ifalias)
 		return -ENOMEM;