linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matt Domsch <Matt_Domsch@dell.com>
To: linux-hotplug@vger.kernel.org
Subject: Re: net device renaming 2-step, IFNAMSIZ limit
Date: Sat, 29 Jan 2011 15:23:50 +0000	[thread overview]
Message-ID: <20110129152350.GA16050@auslistsprd01.us.dell.com> (raw)
In-Reply-To: <20101129032908.GA29904@auslistsprd01.us.dell.com>

On Tue, Dec 07, 2010 at 12:45:04AM -0200, Piter PUNK wrote:
> Matt Domsch wrote:
> >I see this in the udev debug logs when using biosdevname (which I
> >finally got working with SR-IOV devices tonight):
> >
> >renamed network interface eth60 to eth60-pci2#0_60
> >renamed network interface eth60-pci2#0_60 to pci2#0_60
> >
> >So, it worked, however, note that the rename happens in 2 steps, the
> >middle step of which uses a name that's dangerously close to
> >IFNAMSIZ, in fact it is 15 chars there.
> >
> ><...>
> >
> >I need a solution in which the intermediate name doesn't exceed 15
> >characters, and is guaranteed to be unique, as there may be lots of
> >udev instances running in parallel trying to do the same thing.
> >
> >Ideas?
> 
> As we talk on #udev, there is a patch that uses hash32 function inside 
> libudev to create
> the intermediate name. We use the "oldname-newname" to create the hash. 
> With that,
> exceeding IFNAMSIZ isn't a problem:


Piter's patch works for me, and I need this in udev fairly quickly
please.  Some kind folks from IBM have been testing biosdevname with
quad-port Intel SR-IOV-capable devices, and instantiating all the VFs,
can easily have >100 eth* devices created in the kernel
instantaneously.  That bumps step 1 in the 2-step rename operation
over IFNAMSIZ  (eth100-pci2#3_62 is 16 chars).

Please apply.  I'm re-pasting from the original email for convenience.

Tested-by: Matt Domsch <Matt_Domsch@dell.com>

Thanks,
Matt


-- 
Matt Domsch
Technology Strategist
Dell | Office of the CTO

diff --git a/udev/udev-event.c b/udev/udev-event.c
index 0648735..5387c00 100644
--- a/udev/udev-event.c
+++ b/udev/udev-event.c
@@ -462,6 +462,7 @@ static void rename_netif_kernel_log(struct ifreq ifr)
 static int rename_netif(struct udev_event *event)
 {
 	struct udev_device *dev = event->dev;
+	char iftmp[IFNAMSIZ];
 	int sk;
 	struct ifreq ifr;
 	int loop;
@@ -492,7 +493,8 @@ static int rename_netif(struct udev_event *event)
 		goto out;
 
 	/* free our own name, another process may wait for us */
-	util_strscpyl(ifr.ifr_newname, IFNAMSIZ, udev_device_get_sysname(dev), "-", event->name, NULL);
+	util_strscpyl(iftmp, IFNAMSIZ, udev_device_get_sysname(dev), "-", event->name, NULL);
+	sprintf(ifr.ifr_newname, "eth_%X",util_string_hash32(iftmp));
 	err = ioctl(sk, SIOCSIFNAME, &ifr);
 	if (err < 0) {
 		err = -errno;

  parent reply	other threads:[~2011-01-29 15:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-29  3:29 net device renaming 2-step, IFNAMSIZ limit Matt Domsch
2010-12-07  2:45 ` Piter PUNK
2010-12-07  3:54 ` Matt Domsch
2011-01-29 15:23 ` Matt Domsch [this message]
2011-02-08 14:42 ` Kay Sievers
2011-02-08 18:07 ` Scott James Remnant
2011-02-09 16:21 ` Matt Domsch

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=20110129152350.GA16050@auslistsprd01.us.dell.com \
    --to=matt_domsch@dell.com \
    --cc=linux-hotplug@vger.kernel.org \
    /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).