WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] add module_param to loopback.c to create more than o

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] add module_param to loopback.c to create more than one interface
From: Patrick O'Rourke <porourke@xxxxxxxxxxx>
Date: Thu, 08 Sep 2005 13:48:55 -0400
Delivery-date: Thu, 08 Sep 2005 17:44:50 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla Thunderbird 1.0.6 (X11/20050716)
It was suggested on the xen-users list that it would be useful if the loopback driver could instantiate an arbitrary number of interfaces, so the attached patch does that.

Pat

--
Patrick O'Rourke
porourke@xxxxxxxxxxx
diff -u --new-file --recursive 
a/xen-unstable/linux-2.6-xen-sparse/drivers/xen/netback/loopback.c 
b/xen-unstable/linux-2.6-xen-sparse/drivers/xen/netback/loopback.c
--- a/xen-unstable/linux-2.6-xen-sparse/drivers/xen/netback/loopback.c  
2005-09-07 23:58:53.000000000 -0400
+++ b/xen-unstable/linux-2.6-xen-sparse/drivers/xen/netback/loopback.c  
2005-09-08 13:26:39.000000000 -0400
@@ -29,6 +29,11 @@
 #include <linux/skbuff.h>
 #include <net/dst.h>
 
+static int nloopbacks = 1;
+module_param(nloopbacks, int, 0);
+MODULE_PARM_DESC(nloopbacks, "number of devices to create");
+static int make_loopback(int);
+
 struct net_private {
     struct net_device *loopback_dev;
     struct net_device_stats stats;
@@ -120,11 +125,24 @@
 
 static int __init loopback_init(void)
 {
+       int i = 0;
+       int err;
+       do {
+               err = make_loopback(i);
+       } while (!err && (++i < nloopbacks));
+       return err;
+}
+
+static int __init make_loopback(int i)
+{
     struct net_device *dev1, *dev2;
+    char  dev_name[10];
     int err = -ENOMEM;
 
-    dev1 = alloc_netdev(sizeof(struct net_private), "vif0.0", ether_setup);
-    dev2 = alloc_netdev(sizeof(struct net_private), "veth0", ether_setup);
+    sprintf(dev_name, "vif0.%d", i);
+    dev1 = alloc_netdev(sizeof(struct net_private), dev_name, ether_setup);
+    sprintf(dev_name, "veth%d", i);
+    dev2 = alloc_netdev(sizeof(struct net_private), dev_name, ether_setup);
     if ( (dev1 == NULL) || (dev2 == NULL) )
         goto fail;
 
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] add module_param to loopback.c to create more than one interface, Patrick O'Rourke <=