netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oliver Hartkopp <oliver@hartkopp.net>
To: Stephen Hemminger <shemminger@vyatta.com>
Cc: David Miller <davem@davemloft.net>, netdev@vger.kernel.org
Subject: [PATCH net-next]: net: remove ifalias on empty given alias
Date: Tue, 23 Sep 2008 21:52:08 +0200	[thread overview]
Message-ID: <48D948E8.6090804@hartkopp.net> (raw)
In-Reply-To: <20080922174346.2ad15d26@extreme>

[-- Attachment #1: Type: text/plain, Size: 430 bytes --]

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



[-- Attachment #2: empty_ifalias.patch --]
[-- Type: text/x-patch, Size: 466 bytes --]

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;

  parent reply	other threads:[~2008-09-23 19:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-23  0:43 [PATCH] net: network device name ifalias support Stephen Hemminger
2008-09-23  2:44 ` David Miller
2008-09-23  3:47   ` Stephen Hemminger
2008-09-23  4:28     ` David Miller
2008-09-23 19:52 ` Oliver Hartkopp [this message]
2008-09-23 20:14   ` [PATCH net-next]: net: remove ifalias on empty given alias Stephen Hemminger
2008-09-24  4:23     ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48D948E8.6090804@hartkopp.net \
    --to=oliver@hartkopp.net \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=shemminger@vyatta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).