Module Name: src
Committed By: pooka
Date: Tue Oct 19 19:19:41 UTC 2010
Modified Files:
src/sys/rump/net/lib/libvirtif: component.c if_virt.c
Log Message:
Make virtif a cloner so that it can be brough to life also with
"ifconfig create". As previously, virt<n> interfaces with the
host's /dev/tap<n> (I guess it could be made explicit with
"ifconfig media", but leave it this way for now).
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/rump/net/lib/libvirtif/component.c
cvs rdiff -u -r1.19 -r1.20 src/sys/rump/net/lib/libvirtif/if_virt.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/rump/net/lib/libvirtif/component.c
diff -u src/sys/rump/net/lib/libvirtif/component.c:1.2 src/sys/rump/net/lib/libvirtif/component.c:1.3
--- src/sys/rump/net/lib/libvirtif/component.c:1.2 Mon Mar 1 13:12:21 2010
+++ src/sys/rump/net/lib/libvirtif/component.c Tue Oct 19 19:19:41 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: component.c,v 1.2 2010/03/01 13:12:21 pooka Exp $ */
+/* $NetBSD: component.c,v 1.3 2010/10/19 19:19:41 pooka Exp $ */
/*
* Copyright (c) 2009 Antti Kantee. All Rights Reserved.
@@ -28,17 +28,20 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: component.c,v 1.2 2010/03/01 13:12:21 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: component.c,v 1.3 2010/10/19 19:19:41 pooka Exp $");
#include <sys/param.h>
#include <sys/domain.h>
#include <sys/protosw.h>
+#include <net/if.h>
+
#include "rump_private.h"
#include "rump_net_private.h"
RUMP_COMPONENT(RUMP_COMPONENT_NET_IF)
{
+ extern struct if_clone virtif_cloner; /* XXX */
- rump_dummyif_create();
+ if_clone_attach(&virtif_cloner);
}
Index: src/sys/rump/net/lib/libvirtif/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.19 src/sys/rump/net/lib/libvirtif/if_virt.c:1.20
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.19 Tue Aug 10 18:06:10 2010
+++ src/sys/rump/net/lib/libvirtif/if_virt.c Tue Oct 19 19:19:41 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: if_virt.c,v 1.19 2010/08/10 18:06:10 pooka Exp $ */
+/* $NetBSD: if_virt.c,v 1.20 2010/10/19 19:19:41 pooka Exp $ */
/*
* Copyright (c) 2008 Antti Kantee. All Rights Reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_virt.c,v 1.19 2010/08/10 18:06:10 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_virt.c,v 1.20 2010/10/19 19:19:41 pooka Exp $");
#include <sys/param.h>
#include <sys/condvar.h>
@@ -74,29 +74,11 @@
static void virtif_worker(void *);
static void virtif_sender(void *);
+static int virtif_clone(struct if_clone *, int);
+static int virtif_unclone(struct ifnet *);
-#if 0
-/*
- * Create a socket and call ifioctl() to configure the interface.
- * This trickles down to virtif_ioctl().
- */
-static int
-configaddr(struct ifnet *ifp, struct ifaliasreq *ia)
-{
- struct socket *so;
- int error;
-
- strcpy(ia->ifra_name, ifp->if_xname);
- error = socreate(ia->ifra_addr.sa_family, &so, SOCK_DGRAM,
- 0, curlwp, NULL);
- if (error)
- return error;
- error = ifioctl(so, SIOCAIFADDR, ia, curlwp);
- soclose(so);
-
- return error;
-}
-#endif
+struct if_clone virtif_cloner =
+ IF_CLONE_INITIALIZER(VIRTIF_BASE, virtif_clone, virtif_unclone);
int
rump_virtif_create(int num)
@@ -140,6 +122,20 @@
}
static int
+virtif_clone(struct if_clone *ifc, int unit)
+{
+
+ return rump_virtif_create(unit);
+}
+
+static int
+virtif_unclone(struct ifnet *ifp)
+{
+
+ return EOPNOTSUPP;
+}
+
+static int
virtif_init(struct ifnet *ifp)
{
int rv;