Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/rump/net/lib/libvirtif Make virtif a cloner so that it c...



details:   https://anonhg.NetBSD.org/src/rev/30d59a87d36c
branches:  trunk
changeset: 758110:30d59a87d36c
user:      pooka <pooka%NetBSD.org@localhost>
date:      Tue Oct 19 19:19:41 2010 +0000

description:
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).

diffstat:

 sys/rump/net/lib/libvirtif/component.c |   9 ++++--
 sys/rump/net/lib/libvirtif/if_virt.c   |  44 +++++++++++++++------------------
 2 files changed, 26 insertions(+), 27 deletions(-)

diffs (105 lines):

diff -r 0340ed32420f -r 30d59a87d36c sys/rump/net/lib/libvirtif/component.c
--- a/sys/rump/net/lib/libvirtif/component.c    Tue Oct 19 16:36:36 2010 +0000
+++ b/sys/rump/net/lib/libvirtif/component.c    Tue Oct 19 19:19:41 2010 +0000
@@ -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);
 }
diff -r 0340ed32420f -r 30d59a87d36c sys/rump/net/lib/libvirtif/if_virt.c
--- a/sys/rump/net/lib/libvirtif/if_virt.c      Tue Oct 19 16:36:36 2010 +0000
+++ b/sys/rump/net/lib/libvirtif/if_virt.c      Tue Oct 19 19:19:41 2010 +0000
@@ -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 *);
-
-#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;
+static int  virtif_clone(struct if_clone *, int);
+static int  virtif_unclone(struct ifnet *);
 
-       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;



Home | Main Index | Thread Index | Old Index