All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Schwartz <eric.schwartz@hp.com>
To: xen-devel@lists.xensource.com
Subject: PATCH: default number of netloop devices to number of network devices
Date: Thu, 25 Oct 2007 12:38:35 -0600	[thread overview]
Message-ID: <4720E2AB.3090307@hp.com> (raw)

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

Right now, unless specifically overridden, loopback_init() in 
drivers/xen/netback/loopback.c creates 4 netloop devices.  If your 
default network device is eth4 or higher, you're out of luck creating a 
xenbrN device with /etc/xen/scripts/network-bridge unless you explicitly 
set netloop.nloopbacks to something higher.  This patch attempts to set 
a more reasonable default: the number of network devices that exist, as 
reported by dev_get_by_index().

This isn't a perfect solution-- in particular, there will generally be a 
few more devices than there are physical network devices, but looking 
around and consulting with Paul Moore (netlabel maintainer), there 
doesn't seem to be a good way to tell real network devices from pseudo 
ones.  My initial attempt at a patch checked tmp->name for whether it 
began with 'eth', but it's completely reasonable to have network devices 
named anything-- an old laptop used to have its wireless interface named 
'ath0', for instance, and another used 'wlan0'.  So while this approach 
may waste a little bit of memory, at module load time, we can ensure 
that no matter how many devices you have in your system, at least at 
boot time, you can create that many xenbrN devices.

Signed-off-by: Eric Schwartz <eric.schwartz@hp.com>

-=Eric

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

--- linux-2.6.18.ia64/drivers/xen/netback/loopback.c.old	2007-10-25 13:05:30.716516696 -0400
+++ linux-2.6.18.ia64/drivers/xen/netback/loopback.c	2007-10-25 14:14:07.835744809 -0400
@@ -298,9 +298,18 @@
 static int __init loopback_init(void)
 {
 	int i, err = 0;
+	struct net_device *tmp;
 
-	if (nloopbacks == -1)
-		nloopbacks = is_initial_xendomain() ? 4 : 0;
+	if (nloopbacks == -1) {
+		nloopbacks = 0;
+
+		if (is_initial_xendomain()) {
+			for(i = 1; tmp = dev_get_by_index(i); i++) {
+				nloopbacks++;
+				dev_put(tmp);
+			} 
+		} 
+	}
 
 	for (i = 0; i < nloopbacks; i++)
 		if ((err = make_loopback(i)) != 0)

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

             reply	other threads:[~2007-10-25 18:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-25 18:38 Eric Schwartz [this message]
2007-10-26  9:02 ` PATCH: default number of netloop devices to number of network devices Keir Fraser

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=4720E2AB.3090307@hp.com \
    --to=eric.schwartz@hp.com \
    --cc=xen-devel@lists.xensource.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.