From: Patrick O'Rourke <porourke@egenera.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] add module_param to loopback.c to create more than one interface
Date: Thu, 08 Sep 2005 13:48:55 -0400 [thread overview]
Message-ID: <43207987.9060204@egenera.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 222 bytes --]
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@egenera.com
[-- Attachment #2: loopback.txt --]
[-- Type: text/plain, Size: 1467 bytes --]
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;
[-- 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:[~2005-09-08 17:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=43207987.9060204@egenera.com \
--to=porourke@egenera.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.