Message ID | 48D948E8.6090804@hartkopp.net |
---|---|
State | Accepted, archived |
Delegated to: | David Miller |
Headers | show |
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
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 --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;
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