CVS commit: src/sys/rump/net/lib/libvirtif

2020-02-01 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Feb  1 22:45:02 UTC 2020

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
Adopt .


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 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/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.57 src/sys/rump/net/lib/libvirtif/if_virt.c:1.58
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.57	Tue Jun 26 06:48:03 2018
+++ src/sys/rump/net/lib/libvirtif/if_virt.c	Sat Feb  1 22:45:01 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_virt.c,v 1.57 2018/06/26 06:48:03 msaitoh Exp $	*/
+/*	$NetBSD: if_virt.c,v 1.58 2020/02/01 22:45:01 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2008, 2013 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_virt.c,v 1.57 2018/06/26 06:48:03 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_virt.c,v 1.58 2020/02/01 22:45:01 thorpej Exp $");
 
 #include 
 #include 
@@ -325,7 +325,7 @@ virtif_start(struct ifnet *ifp)
 		VIFHYPER_SEND(sc->sc_viu, io, i);
 
 		m_freem(m0);
-		ifp->if_opackets++;
+		if_statinc(ifp, if_opackets);
 	}
 
 	ifp->if_flags &= ~IFF_OACTIVE;



CVS commit: src/sys/rump/net/lib/libvirtif

2020-02-01 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Feb  1 22:45:02 UTC 2020

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
Adopt .


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 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.



CVS commit: src/sys/rump/net/lib/libvirtif

2017-10-23 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Oct 23 13:12:23 UTC 2017

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
 Fix compile error.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 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/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.55 src/sys/rump/net/lib/libvirtif/if_virt.c:1.56
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.55	Mon Oct 23 09:24:34 2017
+++ src/sys/rump/net/lib/libvirtif/if_virt.c	Mon Oct 23 13:12:23 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_virt.c,v 1.55 2017/10/23 09:24:34 msaitoh Exp $	*/
+/*	$NetBSD: if_virt.c,v 1.56 2017/10/23 13:12:23 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2008, 2013 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_virt.c,v 1.55 2017/10/23 09:24:34 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_virt.c,v 1.56 2017/10/23 13:12:23 msaitoh Exp $");
 
 #include 
 #include 
@@ -143,13 +143,13 @@ virtif_clone(struct if_clone *ifc, int n
 		goto fail_2;
 	}
 	snprintf(sc->sc_linkstr, LINKSTRNUMLEN, "%d", sc->sc_num);
-#undef LINKSTRNUMLEN
 	error = virtif_create(ifp);
 	if (error) {
 fail_2:
 		if_detach(ifp);
 		if (sc->sc_linkstr != NULL)
 			kmem_free(sc->sc_linkstr, LINKSTRNUMLEN);
+#undef LINKSTRNUMLEN
 fail_1:
 		kmem_free(sc, sizeof(*sc));
 		ifp->if_softc = NULL;



CVS commit: src/sys/rump/net/lib/libvirtif

2017-10-23 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Oct 23 13:12:23 UTC 2017

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
 Fix compile error.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 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.



CVS commit: src/sys/rump/net/lib/libvirtif

2014-11-06 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Nov  6 23:25:16 UTC 2014

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
Ensure that no two VIRTIF's have the same modname, therefore
allowing them to coexist in the same rump kernel.

from Alexander Guy, via github


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 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/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.48 src/sys/rump/net/lib/libvirtif/if_virt.c:1.49
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.48	Sat Aug  9 09:47:02 2014
+++ src/sys/rump/net/lib/libvirtif/if_virt.c	Thu Nov  6 23:25:16 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_virt.c,v 1.48 2014/08/09 09:47:02 ozaki-r Exp $	*/
+/*	$NetBSD: if_virt.c,v 1.49 2014/11/06 23:25:16 pooka Exp $	*/
 
 /*
  * Copyright (c) 2008, 2013 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.48 2014/08/09 09:47:02 ozaki-r Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.49 2014/11/06 23:25:16 pooka Exp $);
 
 #include sys/param.h
 #include sys/kernel.h
@@ -385,10 +385,16 @@ VIF_DELIVERPKT(struct virtif_sc *sc, str
 	m = NULL;
 }
 
-MODULE(MODULE_CLASS_DRIVER, if_virt, NULL);
-
+/*
+ * The following ensures that no two modules using if_virt end up with
+ * the same module name.  MODULE() and modcmd wrapped in ... bad mojo.
+ */
+#define VIF_MOJO(x) MODULE(MODULE_CLASS_DRIVER,x,NULL);
+#define VIF_MODULE() VIF_MOJO(VIF_BASENAME(if_virt_,VIRTIF_BASE))
+#define VIF_MODCMD VIF_BASENAME3(if_virt_,VIRTIF_BASE,_modcmd)
+VIF_MODULE();
 static int
-if_virt_modcmd(modcmd_t cmd, void *opaque)
+VIF_MODCMD(modcmd_t cmd, void *opaque)
 {
 	int error = 0;
 



CVS commit: src/sys/rump/net/lib/libvirtif

2014-11-06 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Nov  6 23:25:16 UTC 2014

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
Ensure that no two VIRTIF's have the same modname, therefore
allowing them to coexist in the same rump kernel.

from Alexander Guy, via github


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 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.



CVS commit: src/sys/rump/net/lib/libvirtif

2014-08-09 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Sat Aug  9 09:47:02 UTC 2014

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
Count packets in if_virt


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 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/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.47 src/sys/rump/net/lib/libvirtif/if_virt.c:1.48
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.47	Wed Apr  2 19:44:15 2014
+++ src/sys/rump/net/lib/libvirtif/if_virt.c	Sat Aug  9 09:47:02 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_virt.c,v 1.47 2014/04/02 19:44:15 pooka Exp $	*/
+/*	$NetBSD: if_virt.c,v 1.48 2014/08/09 09:47:02 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 2008, 2013 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.47 2014/04/02 19:44:15 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.48 2014/08/09 09:47:02 ozaki-r Exp $);
 
 #include sys/param.h
 #include sys/kernel.h
@@ -310,6 +310,7 @@ virtif_start(struct ifnet *ifp)
 		VIFHYPER_SEND(sc-sc_viu, io, i);
 
 		m_freem(m0);
+		ifp-if_opackets++;
 	}
 
 	ifp-if_flags = ~IFF_OACTIVE;
@@ -372,6 +373,7 @@ VIF_DELIVERPKT(struct virtif_sc *sc, str
 	}
 
 	if (passup) {
+		ifp-if_ipackets++;
 		m-m_pkthdr.rcvif = ifp;
 		KERNEL_LOCK(1, NULL);
 		bpf_mtap(ifp, m);



CVS commit: src/sys/rump/net/lib/libvirtif

2014-08-09 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Sat Aug  9 09:47:02 UTC 2014

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
Count packets in if_virt


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 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.



CVS commit: src/sys/rump/net/lib/libvirtif

2014-04-02 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Apr  2 19:44:15 UTC 2014

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
use if_initname() instead of homegrown sprintf


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 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/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.46 src/sys/rump/net/lib/libvirtif/if_virt.c:1.47
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.46	Thu Mar 20 20:42:08 2014
+++ src/sys/rump/net/lib/libvirtif/if_virt.c	Wed Apr  2 19:44:15 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_virt.c,v 1.46 2014/03/20 20:42:08 christos Exp $	*/
+/*	$NetBSD: if_virt.c,v 1.47 2014/04/02 19:44:15 pooka Exp $	*/
 
 /*
  * Copyright (c) 2008, 2013 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.46 2014/03/20 20:42:08 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.47 2014/04/02 19:44:15 pooka Exp $);
 
 #include sys/param.h
 #include sys/kernel.h
@@ -109,7 +109,8 @@ virtif_clone(struct if_clone *ifc, int n
 	sc = kmem_zalloc(sizeof(*sc), KM_SLEEP);
 	sc-sc_num = num;
 	ifp = sc-sc_ec.ec_if;
-	snprintf(ifp-if_xname, sizeof(ifp-if_xname), %s%d, VIF_NAME, num);
+
+	if_initname(ifp, VIF_NAME, num);
 	ifp-if_softc = sc;
 
 	ifp-if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;



CVS commit: src/sys/rump/net/lib/libvirtif

2014-04-02 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Apr  2 19:44:15 UTC 2014

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
use if_initname() instead of homegrown sprintf


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 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.



CVS commit: src/sys/rump/net/lib/libvirtif

2014-03-18 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Mar 18 18:10:09 UTC 2014

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
Trim alignment out of packet length before passing it up.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 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/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.44 src/sys/rump/net/lib/libvirtif/if_virt.c:1.45
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.44	Thu Mar 13 21:11:12 2014
+++ src/sys/rump/net/lib/libvirtif/if_virt.c	Tue Mar 18 18:10:08 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_virt.c,v 1.44 2014/03/13 21:11:12 pooka Exp $	*/
+/*	$NetBSD: if_virt.c,v 1.45 2014/03/18 18:10:08 pooka Exp $	*/
 
 /*
  * Copyright (c) 2008, 2013 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.44 2014/03/13 21:11:12 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.45 2014/03/18 18:10:08 pooka Exp $);
 
 #include sys/param.h
 #include sys/kernel.h
@@ -353,8 +353,10 @@ VIF_DELIVERPKT(struct virtif_sc *sc, str
 			return;
 		}
 	}
-
 	m-m_data += align;
+	m-m_pkthdr.len -= align;
+	m-m_len -= align;
+
 	eth = mtod(m, struct ether_header *);
 	if (memcmp(eth-ether_dhost, CLLADDR(ifp-if_sadl),
 	ETHER_ADDR_LEN) == 0) {



CVS commit: src/sys/rump/net/lib/libvirtif

2014-03-18 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Mar 18 18:10:09 UTC 2014

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
Trim alignment out of packet length before passing it up.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 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.



CVS commit: src/sys/rump/net/lib/libvirtif

2014-03-14 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri Mar 14 10:06:22 UTC 2014

Modified Files:
src/sys/rump/net/lib/libvirtif: virtif_user.c virtif_user.h

Log Message:
Remember to bump revision for the int my time VIF_DYING change yesterday.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/rump/net/lib/libvirtif/virtif_user.c \
src/sys/rump/net/lib/libvirtif/virtif_user.h

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/virtif_user.c
diff -u src/sys/rump/net/lib/libvirtif/virtif_user.c:1.2 src/sys/rump/net/lib/libvirtif/virtif_user.c:1.3
--- src/sys/rump/net/lib/libvirtif/virtif_user.c:1.2	Thu Mar 13 20:55:26 2014
+++ src/sys/rump/net/lib/libvirtif/virtif_user.c	Fri Mar 14 10:06:22 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: virtif_user.c,v 1.2 2014/03/13 20:55:26 pooka Exp $	*/
+/*	$NetBSD: virtif_user.c,v 1.3 2014/03/14 10:06:22 pooka Exp $	*/
 
 /*
  * Copyright (c) 2013 Antti Kantee.  All Rights Reserved.
@@ -51,7 +51,7 @@
 #include if_virt.h
 #include virtif_user.h
 
-#if VIFHYPER_REVISION != 20140302
+#if VIFHYPER_REVISION != 20140313
 #error VIFHYPER_REVISION mismatch
 #endif
 
Index: src/sys/rump/net/lib/libvirtif/virtif_user.h
diff -u src/sys/rump/net/lib/libvirtif/virtif_user.h:1.2 src/sys/rump/net/lib/libvirtif/virtif_user.h:1.3
--- src/sys/rump/net/lib/libvirtif/virtif_user.h:1.2	Thu Mar 13 20:55:26 2014
+++ src/sys/rump/net/lib/libvirtif/virtif_user.h	Fri Mar 14 10:06:22 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: virtif_user.h,v 1.2 2014/03/13 20:55:26 pooka Exp $	*/
+/*	$NetBSD: virtif_user.h,v 1.3 2014/03/14 10:06:22 pooka Exp $	*/
 
 /*
  * Copyright (c) 2013 Antti Kantee.  All Rights Reserved.
@@ -27,7 +27,7 @@
 
 struct virtif_user;
 
-#define VIFHYPER_REVISION 20140302
+#define VIFHYPER_REVISION 20140313
 
 int 	VIFHYPER_CREATE(const char *, struct virtif_sc *, uint8_t *,
 			struct virtif_user **);



CVS commit: src/sys/rump/net/lib/libvirtif

2014-03-14 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri Mar 14 10:06:22 UTC 2014

Modified Files:
src/sys/rump/net/lib/libvirtif: virtif_user.c virtif_user.h

Log Message:
Remember to bump revision for the int my time VIF_DYING change yesterday.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/rump/net/lib/libvirtif/virtif_user.c \
src/sys/rump/net/lib/libvirtif/virtif_user.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/rump/net/lib/libvirtif

2014-03-13 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Mar 13 18:14:13 UTC 2014

Modified Files:
src/sys/rump/net/lib/libvirtif: Makefile if_virt.c
Added Files:
src/sys/rump/net/lib/libvirtif: virtif_user.c virtif_user.h
Removed Files:
src/sys/rump/net/lib/libvirtif: rumpcomp_user.c rumpcomp_user.h

Log Message:
Rename rumpcomp_user.c - virtif_user.c
Convert to new-style RUMPCOMP_USER_SRCS in Makefile.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/rump/net/lib/libvirtif/Makefile
cvs rdiff -u -r1.40 -r1.41 src/sys/rump/net/lib/libvirtif/if_virt.c
cvs rdiff -u -r1.12 -r0 src/sys/rump/net/lib/libvirtif/rumpcomp_user.c
cvs rdiff -u -r1.6 -r0 src/sys/rump/net/lib/libvirtif/rumpcomp_user.h
cvs rdiff -u -r0 -r1.1 src/sys/rump/net/lib/libvirtif/virtif_user.c \
src/sys/rump/net/lib/libvirtif/virtif_user.h

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/Makefile
diff -u src/sys/rump/net/lib/libvirtif/Makefile:1.8 src/sys/rump/net/lib/libvirtif/Makefile:1.9
--- src/sys/rump/net/lib/libvirtif/Makefile:1.8	Wed Mar 12 23:40:58 2014
+++ src/sys/rump/net/lib/libvirtif/Makefile	Thu Mar 13 18:14:13 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.8 2014/03/12 23:40:58 pooka Exp $
+#	$NetBSD: Makefile,v 1.9 2014/03/13 18:14:13 pooka Exp $
 #
 
 LIB=	rumpnet_virtif
@@ -6,7 +6,7 @@ VIRTIF=	virt
 
 .include ${.CURDIR}/Makefile.virtif
 
-RUMPCOMP_USER=	#defined
+RUMPCOMP_USER_SRCS=	virtif_user.c
 
 .include bsd.lib.mk
 .include bsd.klinks.mk

Index: src/sys/rump/net/lib/libvirtif/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.40 src/sys/rump/net/lib/libvirtif/if_virt.c:1.41
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.40	Wed Mar 12 17:49:13 2014
+++ src/sys/rump/net/lib/libvirtif/if_virt.c	Thu Mar 13 18:14:13 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_virt.c,v 1.40 2014/03/12 17:49:13 pooka Exp $	*/
+/*	$NetBSD: if_virt.c,v 1.41 2014/03/13 18:14:13 pooka Exp $	*/
 
 /*
  * Copyright (c) 2008, 2013 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.40 2014/03/12 17:49:13 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.41 2014/03/13 18:14:13 pooka Exp $);
 
 #include sys/param.h
 #include sys/kernel.h
@@ -47,7 +47,7 @@ __KERNEL_RCSID(0, $NetBSD: if_virt.c,v 
 #include rump_net_private.h
 
 #include if_virt.h
-#include rumpcomp_user.h
+#include virtif_user.h
 
 /*
  * Virtual interface.  Uses hypercalls to shovel packets back

Added files:

Index: src/sys/rump/net/lib/libvirtif/virtif_user.c
diff -u /dev/null src/sys/rump/net/lib/libvirtif/virtif_user.c:1.1
--- /dev/null	Thu Mar 13 18:14:13 2014
+++ src/sys/rump/net/lib/libvirtif/virtif_user.c	Thu Mar 13 18:14:13 2014
@@ -0,0 +1,282 @@
+/*	$NetBSD: virtif_user.c,v 1.1 2014/03/13 18:14:13 pooka Exp $	*/
+
+/*
+ * Copyright (c) 2013 Antti Kantee.  All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _KERNEL
+#include sys/types.h
+#include sys/ioctl.h
+#include sys/uio.h
+
+#include assert.h
+#include errno.h
+#include fcntl.h
+#include inttypes.h
+#include poll.h
+#include pthread.h
+#include stdio.h
+#include stdlib.h
+#include string.h
+#include unistd.h
+
+#ifdef __linux__
+#include net/if.h
+#include linux/if_tun.h
+#endif
+
+#include rump/rumpuser_component.h
+
+#include if_virt.h
+#include virtif_user.h
+
+#if VIFHYPER_REVISION != 20140302
+#error VIFHYPER_REVISION mismatch
+#endif
+
+struct virtif_user {
+	struct virtif_sc *viu_virtifsc;
+	int viu_devnum;
+
+	int viu_fd;
+	int viu_pipe[2];
+	pthread_t viu_rcvthr;
+
+	int viu_dying;
+
+	char viu_rcvbuf[9018]; /* 

CVS commit: src/sys/rump/net/lib/libvirtif

2014-03-13 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Mar 13 20:55:26 UTC 2014

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c virtif_user.c virtif_user.h

Log Message:
allow VIF_DYING() implementation to protest


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/rump/net/lib/libvirtif/if_virt.c
cvs rdiff -u -r1.1 -r1.2 src/sys/rump/net/lib/libvirtif/virtif_user.c \
src/sys/rump/net/lib/libvirtif/virtif_user.h

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/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.41 src/sys/rump/net/lib/libvirtif/if_virt.c:1.42
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.41	Thu Mar 13 18:14:13 2014
+++ src/sys/rump/net/lib/libvirtif/if_virt.c	Thu Mar 13 20:55:26 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_virt.c,v 1.41 2014/03/13 18:14:13 pooka Exp $	*/
+/*	$NetBSD: if_virt.c,v 1.42 2014/03/13 20:55:26 pooka Exp $	*/
 
 /*
  * Copyright (c) 2008, 2013 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.41 2014/03/13 18:14:13 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.42 2014/03/13 20:55:26 pooka Exp $);
 
 #include sys/param.h
 #include sys/kernel.h
@@ -151,11 +151,13 @@ static int
 virtif_unclone(struct ifnet *ifp)
 {
 	struct virtif_sc *sc = ifp-if_softc;
+	int rv;
 
 	if (ifp-if_flags  IFF_UP)
 		return EBUSY;
 
-	VIFHYPER_DYING(sc-sc_viu);
+	if ((rv = VIFHYPER_DYING(sc-sc_viu)) != 0)
+		return rv;
 
 	virtif_stop(ifp, 1);
 	if_down(ifp);

Index: src/sys/rump/net/lib/libvirtif/virtif_user.c
diff -u src/sys/rump/net/lib/libvirtif/virtif_user.c:1.1 src/sys/rump/net/lib/libvirtif/virtif_user.c:1.2
--- src/sys/rump/net/lib/libvirtif/virtif_user.c:1.1	Thu Mar 13 18:14:13 2014
+++ src/sys/rump/net/lib/libvirtif/virtif_user.c	Thu Mar 13 20:55:26 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: virtif_user.c,v 1.1 2014/03/13 18:14:13 pooka Exp $	*/
+/*	$NetBSD: virtif_user.c,v 1.2 2014/03/13 20:55:26 pooka Exp $	*/
 
 /*
  * Copyright (c) 2013 Antti Kantee.  All Rights Reserved.
@@ -251,7 +251,7 @@ VIFHYPER_SEND(struct virtif_user *viu,
 	rumpuser_component_schedule(cookie);
 }
 
-void
+int
 VIFHYPER_DYING(struct virtif_user *viu)
 {
 	void *cookie = rumpuser_component_unschedule();
@@ -259,11 +259,17 @@ VIFHYPER_DYING(struct virtif_user *viu)
 	viu-viu_dying = 1;
 	if (write(viu-viu_pipe[1],
 	viu-viu_dying, sizeof(viu-viu_dying)) == -1) {
+		/*
+		 * this is here mostly to avoid a compiler warning
+		 * about ignoring the return value of write()
+		 */
 		fprintf(stderr, %s: failed to signal thread\n,
 		VIF_STRING(VIFHYPER_DYING));
 	}
 
 	rumpuser_component_schedule(cookie);
+
+	return 0;
 }
 
 void
Index: src/sys/rump/net/lib/libvirtif/virtif_user.h
diff -u src/sys/rump/net/lib/libvirtif/virtif_user.h:1.1 src/sys/rump/net/lib/libvirtif/virtif_user.h:1.2
--- src/sys/rump/net/lib/libvirtif/virtif_user.h:1.1	Thu Mar 13 18:14:13 2014
+++ src/sys/rump/net/lib/libvirtif/virtif_user.h	Thu Mar 13 20:55:26 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: virtif_user.h,v 1.1 2014/03/13 18:14:13 pooka Exp $	*/
+/*	$NetBSD: virtif_user.h,v 1.2 2014/03/13 20:55:26 pooka Exp $	*/
 
 /*
  * Copyright (c) 2013 Antti Kantee.  All Rights Reserved.
@@ -31,7 +31,7 @@ struct virtif_user;
 
 int 	VIFHYPER_CREATE(const char *, struct virtif_sc *, uint8_t *,
 			struct virtif_user **);
-void	VIFHYPER_DYING(struct virtif_user *);
+int	VIFHYPER_DYING(struct virtif_user *);
 void	VIFHYPER_DESTROY(struct virtif_user *);
 
 void	VIFHYPER_SEND(struct virtif_user *, struct iovec *, size_t);



CVS commit: src/sys/rump/net/lib/libvirtif

2014-03-13 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Mar 13 20:59:12 UTC 2014

Modified Files:
src/sys/rump/net/lib/libvirtif: Makefile.virtif if_virt.c

Log Message:
remove unnecessary header inclusions


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/rump/net/lib/libvirtif/Makefile.virtif
cvs rdiff -u -r1.42 -r1.43 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/Makefile.virtif
diff -u src/sys/rump/net/lib/libvirtif/Makefile.virtif:1.2 src/sys/rump/net/lib/libvirtif/Makefile.virtif:1.3
--- src/sys/rump/net/lib/libvirtif/Makefile.virtif:1.2	Wed Mar 12 23:42:33 2014
+++ src/sys/rump/net/lib/libvirtif/Makefile.virtif	Thu Mar 13 20:59:12 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.virtif,v 1.2 2014/03/12 23:42:33 pooka Exp $
+#	$NetBSD: Makefile.virtif,v 1.3 2014/03/13 20:59:12 pooka Exp $
 #
 
 .if !defined(VIRTIF)
@@ -10,7 +10,7 @@ SRCS=	if_virt.c virtif_component.c
 VIRTIFDIR:=	${.PARSEDIR}
 .PATH:		${VIRTIFDIR}
 
-CPPFLAGS+=	-I${VIRTIFDIR}/../../../librump/rumpkern -I${VIRTIFDIR}
-CPPFLAGS+=	-DVIRTIF_BASE=${VIRTIF}
+CPPFLAGS+=	-I${VIRTIFDIR}/../../../librump/rumpkern
 
+CPPFLAGS+=		 -DVIRTIF_BASE=${VIRTIF} -I${VIRTIFDIR}
 RUMPCOMP_USER_CPPFLAGS+= -DVIRTIF_BASE=${VIRTIF} -I${VIRTIFDIR}

Index: src/sys/rump/net/lib/libvirtif/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.42 src/sys/rump/net/lib/libvirtif/if_virt.c:1.43
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.42	Thu Mar 13 20:55:26 2014
+++ src/sys/rump/net/lib/libvirtif/if_virt.c	Thu Mar 13 20:59:12 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_virt.c,v 1.42 2014/03/13 20:55:26 pooka Exp $	*/
+/*	$NetBSD: if_virt.c,v 1.43 2014/03/13 20:59:12 pooka Exp $	*/
 
 /*
  * Copyright (c) 2008, 2013 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.42 2014/03/13 20:55:26 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.43 2014/03/13 20:59:12 pooka Exp $);
 
 #include sys/param.h
 #include sys/kernel.h
@@ -41,11 +41,6 @@ __KERNEL_RCSID(0, $NetBSD: if_virt.c,v 
 #include netinet/in.h
 #include netinet/in_var.h
 
-#include rump/rump.h
-
-#include rump_private.h
-#include rump_net_private.h
-
 #include if_virt.h
 #include virtif_user.h
 



CVS commit: src/sys/rump/net/lib/libvirtif

2014-03-13 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Mar 13 21:11:12 UTC 2014

Modified Files:
src/sys/rump/net/lib/libvirtif: Makefile.virtif if_virt.c
Removed Files:
src/sys/rump/net/lib/libvirtif: virtif_component.c

Log Message:
No reason to attach if_virt as a RUMP_COMPONENT(), simply use MODULE().


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/rump/net/lib/libvirtif/Makefile.virtif
cvs rdiff -u -r1.43 -r1.44 src/sys/rump/net/lib/libvirtif/if_virt.c
cvs rdiff -u -r1.1 -r0 src/sys/rump/net/lib/libvirtif/virtif_component.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/Makefile.virtif
diff -u src/sys/rump/net/lib/libvirtif/Makefile.virtif:1.3 src/sys/rump/net/lib/libvirtif/Makefile.virtif:1.4
--- src/sys/rump/net/lib/libvirtif/Makefile.virtif:1.3	Thu Mar 13 20:59:12 2014
+++ src/sys/rump/net/lib/libvirtif/Makefile.virtif	Thu Mar 13 21:11:12 2014
@@ -1,16 +1,14 @@
-#	$NetBSD: Makefile.virtif,v 1.3 2014/03/13 20:59:12 pooka Exp $
+#	$NetBSD: Makefile.virtif,v 1.4 2014/03/13 21:11:12 pooka Exp $
 #
 
 .if !defined(VIRTIF)
 .error Define VIRTIF when including ${.PARSEFILE}
 .endif
 
-SRCS=	if_virt.c virtif_component.c
+SRCS=	if_virt.c
 
 VIRTIFDIR:=	${.PARSEDIR}
 .PATH:		${VIRTIFDIR}
 
-CPPFLAGS+=	-I${VIRTIFDIR}/../../../librump/rumpkern
-
 CPPFLAGS+=		 -DVIRTIF_BASE=${VIRTIF} -I${VIRTIFDIR}
 RUMPCOMP_USER_CPPFLAGS+= -DVIRTIF_BASE=${VIRTIF} -I${VIRTIFDIR}

Index: src/sys/rump/net/lib/libvirtif/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.43 src/sys/rump/net/lib/libvirtif/if_virt.c:1.44
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.43	Thu Mar 13 20:59:12 2014
+++ src/sys/rump/net/lib/libvirtif/if_virt.c	Thu Mar 13 21:11:12 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_virt.c,v 1.43 2014/03/13 20:59:12 pooka Exp $	*/
+/*	$NetBSD: if_virt.c,v 1.44 2014/03/13 21:11:12 pooka Exp $	*/
 
 /*
  * Copyright (c) 2008, 2013 Antti Kantee.  All Rights Reserved.
@@ -26,12 +26,13 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.43 2014/03/13 20:59:12 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.44 2014/03/13 21:11:12 pooka Exp $);
 
 #include sys/param.h
 #include sys/kernel.h
 #include sys/kmem.h
 #include sys/cprng.h
+#include sys/module.h
 
 #include net/bpf.h
 #include net/if.h
@@ -378,3 +379,31 @@ VIF_DELIVERPKT(struct virtif_sc *sc, str
 	}
 	m = NULL;
 }
+
+MODULE(MODULE_CLASS_DRIVER, if_virt, NULL);
+
+static int
+if_virt_modcmd(modcmd_t cmd, void *opaque)
+{
+	int error = 0;
+
+	switch (cmd) {
+	case MODULE_CMD_INIT:
+		if_clone_attach(VIF_CLONER);
+		break;
+	case MODULE_CMD_FINI:
+		/*
+		 * not sure if interfaces are refcounted
+		 * and properly protected
+		 */
+#if 0
+		if_clone_detach(VIF_CLONER);
+#else
+		error = ENOTTY;
+#endif
+		break;
+	default:
+		error = ENOTTY;
+	}
+	return error;
+}



CVS commit: src/sys/rump/net/lib/libvirtif

2014-03-13 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Mar 13 18:14:13 UTC 2014

Modified Files:
src/sys/rump/net/lib/libvirtif: Makefile if_virt.c
Added Files:
src/sys/rump/net/lib/libvirtif: virtif_user.c virtif_user.h
Removed Files:
src/sys/rump/net/lib/libvirtif: rumpcomp_user.c rumpcomp_user.h

Log Message:
Rename rumpcomp_user.c - virtif_user.c
Convert to new-style RUMPCOMP_USER_SRCS in Makefile.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/rump/net/lib/libvirtif/Makefile
cvs rdiff -u -r1.40 -r1.41 src/sys/rump/net/lib/libvirtif/if_virt.c
cvs rdiff -u -r1.12 -r0 src/sys/rump/net/lib/libvirtif/rumpcomp_user.c
cvs rdiff -u -r1.6 -r0 src/sys/rump/net/lib/libvirtif/rumpcomp_user.h
cvs rdiff -u -r0 -r1.1 src/sys/rump/net/lib/libvirtif/virtif_user.c \
src/sys/rump/net/lib/libvirtif/virtif_user.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/rump/net/lib/libvirtif

2014-03-13 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Mar 13 20:55:26 UTC 2014

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c virtif_user.c virtif_user.h

Log Message:
allow VIF_DYING() implementation to protest


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/rump/net/lib/libvirtif/if_virt.c
cvs rdiff -u -r1.1 -r1.2 src/sys/rump/net/lib/libvirtif/virtif_user.c \
src/sys/rump/net/lib/libvirtif/virtif_user.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/rump/net/lib/libvirtif

2014-03-13 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Mar 13 20:59:12 UTC 2014

Modified Files:
src/sys/rump/net/lib/libvirtif: Makefile.virtif if_virt.c

Log Message:
remove unnecessary header inclusions


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/rump/net/lib/libvirtif/Makefile.virtif
cvs rdiff -u -r1.42 -r1.43 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.



CVS commit: src/sys/rump/net/lib/libvirtif

2014-03-13 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Mar 13 21:11:12 UTC 2014

Modified Files:
src/sys/rump/net/lib/libvirtif: Makefile.virtif if_virt.c
Removed Files:
src/sys/rump/net/lib/libvirtif: virtif_component.c

Log Message:
No reason to attach if_virt as a RUMP_COMPONENT(), simply use MODULE().


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/rump/net/lib/libvirtif/Makefile.virtif
cvs rdiff -u -r1.43 -r1.44 src/sys/rump/net/lib/libvirtif/if_virt.c
cvs rdiff -u -r1.1 -r0 src/sys/rump/net/lib/libvirtif/virtif_component.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/rump/net/lib/libvirtif

2014-03-12 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Mar 12 17:49:13 UTC 2014

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
When sending, only load mbufs which have a length.  This is especially
useful for fragmented datagrams where the tail of the first packet is
full of nothing.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 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/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.39 src/sys/rump/net/lib/libvirtif/if_virt.c:1.40
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.39	Mon Mar  3 13:56:40 2014
+++ src/sys/rump/net/lib/libvirtif/if_virt.c	Wed Mar 12 17:49:13 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_virt.c,v 1.39 2014/03/03 13:56:40 pooka Exp $	*/
+/*	$NetBSD: if_virt.c,v 1.40 2014/03/12 17:49:13 pooka Exp $	*/
 
 /*
  * Copyright (c) 2008, 2013 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.39 2014/03/03 13:56:40 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.40 2014/03/12 17:49:13 pooka Exp $);
 
 #include sys/param.h
 #include sys/kernel.h
@@ -296,12 +296,15 @@ virtif_start(struct ifnet *ifp)
 		}
 
 		m = m0;
-		for (i = 0; i  LB_SH  m; i++) {
-			io[i].iov_base = mtod(m, void *);
-			io[i].iov_len = m-m_len;
+		for (i = 0; i  LB_SH  m; ) {
+			if (m-m_len) {
+io[i].iov_base = mtod(m, void *);
+io[i].iov_len = m-m_len;
+i++;
+			}
 			m = m-m_next;
 		}
-		if (i == LB_SH)
+		if (i == LB_SH  m)
 			panic(lazy bum);
 		bpf_mtap(ifp, m0);
 



CVS commit: src/sys/rump/net/lib/libvirtif

2014-03-12 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Mar 12 23:40:58 UTC 2014

Modified Files:
src/sys/rump/net/lib/libvirtif: Makefile
Added Files:
src/sys/rump/net/lib/libvirtif: Makefile.virtif

Log Message:
Separate common bits for all interfaces implementing virtif hypercalls
from Makefile to Makefile.virtif.  The latter is meant to be .included.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/rump/net/lib/libvirtif/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/rump/net/lib/libvirtif/Makefile.virtif

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/Makefile
diff -u src/sys/rump/net/lib/libvirtif/Makefile:1.7 src/sys/rump/net/lib/libvirtif/Makefile:1.8
--- src/sys/rump/net/lib/libvirtif/Makefile:1.7	Thu Jul  4 11:46:51 2013
+++ src/sys/rump/net/lib/libvirtif/Makefile	Wed Mar 12 23:40:58 2014
@@ -1,16 +1,12 @@
-#	$NetBSD: Makefile,v 1.7 2013/07/04 11:46:51 pooka Exp $
+#	$NetBSD: Makefile,v 1.8 2014/03/12 23:40:58 pooka Exp $
 #
 
 LIB=	rumpnet_virtif
+VIRTIF=	virt
 
-SRCS=	if_virt.c
-SRCS+=	component.c
-
-CPPFLAGS+=	-I${.CURDIR}/../../../librump/rumpkern -I${.CURDIR}
-CPPFLAGS+=	-DVIRTIF_BASE=virt
+.include ${.CURDIR}/Makefile.virtif
 
 RUMPCOMP_USER=	#defined
-RUMPCOMP_USER_CPPFLAGS+= -DVIRTIF_BASE=virt
 
 .include bsd.lib.mk
 .include bsd.klinks.mk

Added files:

Index: src/sys/rump/net/lib/libvirtif/Makefile.virtif
diff -u /dev/null src/sys/rump/net/lib/libvirtif/Makefile.virtif:1.1
--- /dev/null	Wed Mar 12 23:40:58 2014
+++ src/sys/rump/net/lib/libvirtif/Makefile.virtif	Wed Mar 12 23:40:58 2014
@@ -0,0 +1,16 @@
+#	$NetBSD: Makefile.virtif,v 1.1 2014/03/12 23:40:58 pooka Exp $
+#
+
+.if !defined(VIRTIF)
+.error Define VIRTIF when including ${.PARSEFILE}
+.endif
+
+SRCS=	if_virt.c component.c
+
+VIRTIFDIR:=	${.PARSEDIR}
+.PATH:		${VIRTIFDIR}
+
+CPPFLAGS+=	-I${VIRTIFDIR}/../../../librump/rumpkern -I${VIRTIFDIR}
+CPPFLAGS+=	-DVIRTIF_BASE=${VIRTIF}
+
+RUMPCOMP_USER_CPPFLAGS+= -DVIRTIF_BASE=${VIRTIF} -I${VIRTIFDIR}



CVS commit: src/sys/rump/net/lib/libvirtif

2014-03-12 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Mar 12 23:42:33 UTC 2014

Modified Files:
src/sys/rump/net/lib/libvirtif: Makefile.virtif
Added Files:
src/sys/rump/net/lib/libvirtif: virtif_component.c
Removed Files:
src/sys/rump/net/lib/libvirtif: component.c

Log Message:
component.c - virtif_component.c, just to decrease risk of conflicts.
No runtime change.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/rump/net/lib/libvirtif/Makefile.virtif
cvs rdiff -u -r1.4 -r0 src/sys/rump/net/lib/libvirtif/component.c
cvs rdiff -u -r0 -r1.1 src/sys/rump/net/lib/libvirtif/virtif_component.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/Makefile.virtif
diff -u src/sys/rump/net/lib/libvirtif/Makefile.virtif:1.1 src/sys/rump/net/lib/libvirtif/Makefile.virtif:1.2
--- src/sys/rump/net/lib/libvirtif/Makefile.virtif:1.1	Wed Mar 12 23:40:58 2014
+++ src/sys/rump/net/lib/libvirtif/Makefile.virtif	Wed Mar 12 23:42:33 2014
@@ -1,11 +1,11 @@
-#	$NetBSD: Makefile.virtif,v 1.1 2014/03/12 23:40:58 pooka Exp $
+#	$NetBSD: Makefile.virtif,v 1.2 2014/03/12 23:42:33 pooka Exp $
 #
 
 .if !defined(VIRTIF)
 .error Define VIRTIF when including ${.PARSEFILE}
 .endif
 
-SRCS=	if_virt.c component.c
+SRCS=	if_virt.c virtif_component.c
 
 VIRTIFDIR:=	${.PARSEDIR}
 .PATH:		${VIRTIFDIR}

Added files:

Index: src/sys/rump/net/lib/libvirtif/virtif_component.c
diff -u /dev/null src/sys/rump/net/lib/libvirtif/virtif_component.c:1.1
--- /dev/null	Wed Mar 12 23:42:33 2014
+++ src/sys/rump/net/lib/libvirtif/virtif_component.c	Wed Mar 12 23:42:33 2014
@@ -0,0 +1,47 @@
+/*	$NetBSD: virtif_component.c,v 1.1 2014/03/12 23:42:33 pooka Exp $	*/
+
+/*
+ * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
+ *
+ * Development of this software was supported by The Nokia Foundation
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include sys/cdefs.h
+__KERNEL_RCSID(0, $NetBSD: virtif_component.c,v 1.1 2014/03/12 23:42:33 pooka Exp $);
+
+#include sys/param.h
+#include sys/domain.h
+#include sys/protosw.h
+
+#include net/if.h
+
+#include rump_private.h
+#include if_virt.h
+
+RUMP_COMPONENT(RUMP_COMPONENT_NET_IF)
+{
+	extern struct if_clone VIF_CLONER; /* XXX */
+
+	if_clone_attach(VIF_CLONER);
+}



CVS commit: src/sys/rump/net/lib/libvirtif

2014-03-12 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Mar 12 17:49:13 UTC 2014

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
When sending, only load mbufs which have a length.  This is especially
useful for fragmented datagrams where the tail of the first packet is
full of nothing.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 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.



CVS commit: src/sys/rump/net/lib/libvirtif

2014-03-12 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Mar 12 23:40:58 UTC 2014

Modified Files:
src/sys/rump/net/lib/libvirtif: Makefile
Added Files:
src/sys/rump/net/lib/libvirtif: Makefile.virtif

Log Message:
Separate common bits for all interfaces implementing virtif hypercalls
from Makefile to Makefile.virtif.  The latter is meant to be .included.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/rump/net/lib/libvirtif/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/rump/net/lib/libvirtif/Makefile.virtif

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/rump/net/lib/libvirtif

2014-03-12 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Mar 12 23:42:33 UTC 2014

Modified Files:
src/sys/rump/net/lib/libvirtif: Makefile.virtif
Added Files:
src/sys/rump/net/lib/libvirtif: virtif_component.c
Removed Files:
src/sys/rump/net/lib/libvirtif: component.c

Log Message:
component.c - virtif_component.c, just to decrease risk of conflicts.
No runtime change.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/rump/net/lib/libvirtif/Makefile.virtif
cvs rdiff -u -r1.4 -r0 src/sys/rump/net/lib/libvirtif/component.c
cvs rdiff -u -r0 -r1.1 src/sys/rump/net/lib/libvirtif/virtif_component.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/rump/net/lib/libvirtif

2014-03-03 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Mar  3 13:56:41 UTC 2014

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c if_virt.h rumpcomp_user.c
rumpcomp_user.h

Log Message:
Pull in the changes from the dpdk, netmap and snabb switch repos.
There are two major changes:

1) All thread context policy is pushed down to the hypercalls.
   This is meant to help performance-mongering implementations be
   able to control packet scheduling better (e.g. pin down packet
   reception to certain physical cores).
2) Generalize linkstr, meaning that the interface can now take an
   arbitrary string which is passed to the create() hypercall.  This can
   be used to map backend device characteristics to the rump kernel
   interface instance.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/rump/net/lib/libvirtif/if_virt.c
cvs rdiff -u -r1.2 -r1.3 src/sys/rump/net/lib/libvirtif/if_virt.h
cvs rdiff -u -r1.11 -r1.12 src/sys/rump/net/lib/libvirtif/rumpcomp_user.c
cvs rdiff -u -r1.5 -r1.6 src/sys/rump/net/lib/libvirtif/rumpcomp_user.h

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/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.38 src/sys/rump/net/lib/libvirtif/if_virt.c:1.39
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.38	Fri Feb 21 08:33:51 2014
+++ src/sys/rump/net/lib/libvirtif/if_virt.c	Mon Mar  3 13:56:40 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_virt.c,v 1.38 2014/02/21 08:33:51 skrll Exp $	*/
+/*	$NetBSD: if_virt.c,v 1.39 2014/03/03 13:56:40 pooka Exp $	*/
 
 /*
  * Copyright (c) 2008, 2013 Antti Kantee.  All Rights Reserved.
@@ -26,24 +26,17 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.38 2014/02/21 08:33:51 skrll Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.39 2014/03/03 13:56:40 pooka Exp $);
 
 #include sys/param.h
-#include sys/condvar.h
-#include sys/fcntl.h
 #include sys/kernel.h
 #include sys/kmem.h
-#include sys/kthread.h
-#include sys/mutex.h
-#include sys/poll.h
-#include sys/sockio.h
-#include sys/socketvar.h
 #include sys/cprng.h
 
 #include net/bpf.h
 #include net/if.h
+#include net/if_dl.h
 #include net/if_ether.h
-#include net/if_tap.h
 
 #include netinet/in.h
 #include netinet/in_var.h
@@ -70,14 +63,11 @@ static void	virtif_stop(struct ifnet *, 
 struct virtif_sc {
 	struct ethercom sc_ec;
 	struct virtif_user *sc_viu;
-	bool sc_dying;
-	struct lwp *sc_l_snd, *sc_l_rcv;
-	kmutex_t sc_mtx;
-	kcondvar_t sc_cv;
+
+	int sc_num;
+	char *sc_linkstr;
 };
 
-static void virtif_receiver(void *);
-static void virtif_sender(void *);
 static int  virtif_clone(struct if_clone *, int);
 static int  virtif_unclone(struct ifnet *);
 
@@ -85,60 +75,74 @@ struct if_clone VIF_CLONER =
 IF_CLONE_INITIALIZER(VIF_NAME, virtif_clone, virtif_unclone);
 
 static int
-virtif_clone(struct if_clone *ifc, int num)
+virtif_create(struct ifnet *ifp)
 {
-	struct virtif_sc *sc;
-	struct virtif_user *viu;
-	struct ifnet *ifp;
 	uint8_t enaddr[ETHER_ADDR_LEN] = { 0xb2, 0x0a, 0x00, 0x0b, 0x0e, 0x01 };
-	int error = 0;
+	char enaddrstr[3*ETHER_ADDR_LEN];
+	struct virtif_sc *sc = ifp-if_softc;
+	int error;
 
-	if (num = 0x100)
-		return E2BIG;
+	if (sc-sc_viu)
+		panic(%s: already created, ifp-if_xname);
 
-	if ((error = VIFHYPER_CREATE(num, viu)) != 0)
+	enaddr[2] = cprng_fast32()  0xff;
+	enaddr[5] = sc-sc_num  0xff;
+
+	if ((error = VIFHYPER_CREATE(sc-sc_linkstr,
+	sc, enaddr, sc-sc_viu)) != 0) {
+		printf(VIFHYPER_CREATE failed: %d\n, error);
 		return error;
+	}
 
-	enaddr[2] = cprng_fast32()  0xff;
-	enaddr[5] = num;
+	ether_ifattach(ifp, enaddr);
+	ether_snprintf(enaddrstr, sizeof(enaddrstr), enaddr);
+	aprint_normal_ifnet(ifp, Ethernet address %s\n, enaddrstr);
 
-	sc = kmem_zalloc(sizeof(*sc), KM_SLEEP);
-	sc-sc_dying = false;
-	sc-sc_viu = viu;
+	IFQ_SET_READY(ifp-if_snd);
 
-	mutex_init(sc-sc_mtx, MUTEX_DEFAULT, IPL_NONE);
-	cv_init(sc-sc_cv, VIF_NAME snd);
+	return 0;
+}
+
+static int
+virtif_clone(struct if_clone *ifc, int num)
+{
+	struct virtif_sc *sc;
+	struct ifnet *ifp;
+	int error = 0;
+
+	sc = kmem_zalloc(sizeof(*sc), KM_SLEEP);
+	sc-sc_num = num;
 	ifp = sc-sc_ec.ec_if;
 	sprintf(ifp-if_xname, %s%d, VIF_NAME, num);
 	ifp-if_softc = sc;
 
-	if (rump_threads) {
-		if ((error = kthread_create(PRI_NONE, KTHREAD_MUSTJOIN, NULL,
-		virtif_receiver, ifp, sc-sc_l_rcv, VIF_NAME ifr)) != 0)
-			goto out;
-
-		if ((error = kthread_create(PRI_NONE,
-		KTHREAD_MUSTJOIN | KTHREAD_MPSAFE, NULL,
-		virtif_sender, ifp, sc-sc_l_snd, VIF_NAME ifs)) != 0)
-			goto out;
-	} else {
-		printf(WARNING: threads not enabled, receive NOT working\n);
-	}
-
 	ifp-if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
 	ifp-if_init = virtif_init;
 	ifp-if_ioctl = virtif_ioctl;
 	ifp-if_start = virtif_start;
 	ifp-if_stop = virtif_stop;
-	IFQ_SET_READY(ifp-if_snd);
+	ifp-if_mtu = ETHERMTU;
+	

CVS commit: src/sys/rump/net/lib/libvirtif

2014-03-03 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Mar  3 13:56:41 UTC 2014

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c if_virt.h rumpcomp_user.c
rumpcomp_user.h

Log Message:
Pull in the changes from the dpdk, netmap and snabb switch repos.
There are two major changes:

1) All thread context policy is pushed down to the hypercalls.
   This is meant to help performance-mongering implementations be
   able to control packet scheduling better (e.g. pin down packet
   reception to certain physical cores).
2) Generalize linkstr, meaning that the interface can now take an
   arbitrary string which is passed to the create() hypercall.  This can
   be used to map backend device characteristics to the rump kernel
   interface instance.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/rump/net/lib/libvirtif/if_virt.c
cvs rdiff -u -r1.2 -r1.3 src/sys/rump/net/lib/libvirtif/if_virt.h
cvs rdiff -u -r1.11 -r1.12 src/sys/rump/net/lib/libvirtif/rumpcomp_user.c
cvs rdiff -u -r1.5 -r1.6 src/sys/rump/net/lib/libvirtif/rumpcomp_user.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/rump/net/lib/libvirtif

2014-02-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Feb 21 08:33:51 UTC 2014

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
Fix typo in fix for PR/48606


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 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/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.37 src/sys/rump/net/lib/libvirtif/if_virt.c:1.38
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.37	Fri Feb 21 02:10:40 2014
+++ src/sys/rump/net/lib/libvirtif/if_virt.c	Fri Feb 21 08:33:51 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_virt.c,v 1.37 2014/02/21 02:10:40 christos Exp $	*/
+/*	$NetBSD: if_virt.c,v 1.38 2014/02/21 08:33:51 skrll Exp $	*/
 
 /*
  * Copyright (c) 2008, 2013 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.37 2014/02/21 02:10:40 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.38 2014/02/21 08:33:51 skrll Exp $);
 
 #include sys/param.h
 #include sys/condvar.h
@@ -278,7 +278,7 @@ virtif_receiver(void *arg)
 		m-m_len = m-m_pkthdr.len = n;
 		m-m_pkthdr.rcvif = ifp;
 		bpf_mtap(ifp, m);
-		(*ipf-if_input)(ifp, m);
+		(*ifp-if_input)(ifp, m);
 	}
 
 	kthread_exit(0);



CVS commit: src/sys/rump/net/lib/libvirtif

2014-02-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Feb 21 08:33:51 UTC 2014

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
Fix typo in fix for PR/48606


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 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.



CVS commit: src/sys/rump/net/lib/libvirtif

2013-10-27 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Sun Oct 27 16:03:20 UTC 2013

Modified Files:
src/sys/rump/net/lib/libvirtif: rumpcomp_user.c rumpcomp_user.h

Log Message:
Give the hypercall interface a version number.  This is for
implementations outside of the tree.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/rump/net/lib/libvirtif/rumpcomp_user.c
cvs rdiff -u -r1.4 -r1.5 src/sys/rump/net/lib/libvirtif/rumpcomp_user.h

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/rumpcomp_user.c
diff -u src/sys/rump/net/lib/libvirtif/rumpcomp_user.c:1.10 src/sys/rump/net/lib/libvirtif/rumpcomp_user.c:1.11
--- src/sys/rump/net/lib/libvirtif/rumpcomp_user.c:1.10	Tue Jul 16 21:14:42 2013
+++ src/sys/rump/net/lib/libvirtif/rumpcomp_user.c	Sun Oct 27 16:03:19 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpcomp_user.c,v 1.10 2013/07/16 21:14:42 pooka Exp $	*/
+/*	$NetBSD: rumpcomp_user.c,v 1.11 2013/10/27 16:03:19 pooka Exp $	*/
 
 /*
  * Copyright (c) 2013 Antti Kantee.  All Rights Reserved.
@@ -48,6 +48,10 @@
 #include if_virt.h
 #include rumpcomp_user.h
 
+#if VIFHYPER_REVISION != 20130704
+#error VIFHYPER_REVISION mismatch
+#endif
+
 struct virtif_user {
 	int viu_fd;
 	int viu_dying;

Index: src/sys/rump/net/lib/libvirtif/rumpcomp_user.h
diff -u src/sys/rump/net/lib/libvirtif/rumpcomp_user.h:1.4 src/sys/rump/net/lib/libvirtif/rumpcomp_user.h:1.5
--- src/sys/rump/net/lib/libvirtif/rumpcomp_user.h:1.4	Thu Jul  4 11:46:51 2013
+++ src/sys/rump/net/lib/libvirtif/rumpcomp_user.h	Sun Oct 27 16:03:19 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpcomp_user.h,v 1.4 2013/07/04 11:46:51 pooka Exp $	*/
+/*	$NetBSD: rumpcomp_user.h,v 1.5 2013/10/27 16:03:19 pooka Exp $	*/
 
 /*
  * Copyright (c) 2013 Antti Kantee.  All Rights Reserved.
@@ -27,6 +27,8 @@
 
 struct virtif_user;
 
+#define VIFHYPER_REVISION 20130704
+
 int 	VIFHYPER_CREATE(int, struct virtif_user **);
 void	VIFHYPER_DYING(struct virtif_user *);
 void	VIFHYPER_DESTROY(struct virtif_user *);



CVS commit: src/sys/rump/net/lib/libvirtif

2013-10-27 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Sun Oct 27 16:03:20 UTC 2013

Modified Files:
src/sys/rump/net/lib/libvirtif: rumpcomp_user.c rumpcomp_user.h

Log Message:
Give the hypercall interface a version number.  This is for
implementations outside of the tree.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/rump/net/lib/libvirtif/rumpcomp_user.c
cvs rdiff -u -r1.4 -r1.5 src/sys/rump/net/lib/libvirtif/rumpcomp_user.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/rump/net/lib/libvirtif

2013-07-16 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Jul 16 19:44:31 UTC 2013

Modified Files:
src/sys/rump/net/lib/libvirtif: rumpcomp_user.c

Log Message:
Explicitly ignore return value of writev() for sending a packet.

Otherwise you get the following with some compilers:
warning: ignoring return value of 'writev', declared with attribute 
warn_unused_result [-Wunused-result]


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/rump/net/lib/libvirtif/rumpcomp_user.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/rumpcomp_user.c
diff -u src/sys/rump/net/lib/libvirtif/rumpcomp_user.c:1.8 src/sys/rump/net/lib/libvirtif/rumpcomp_user.c:1.9
--- src/sys/rump/net/lib/libvirtif/rumpcomp_user.c:1.8	Thu Jul  4 11:46:51 2013
+++ src/sys/rump/net/lib/libvirtif/rumpcomp_user.c	Tue Jul 16 19:44:31 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpcomp_user.c,v 1.8 2013/07/04 11:46:51 pooka Exp $	*/
+/*	$NetBSD: rumpcomp_user.c,v 1.9 2013/07/16 19:44:31 pooka Exp $	*/
 
 /*
  * Copyright (c) 2013 Antti Kantee.  All Rights Reserved.
@@ -134,7 +134,7 @@ VIFHYPER_SEND(struct virtif_user *viu,
 	void *cookie = rumpuser_component_unschedule();
 
 	/* no need to check for return value; packets may be dropped */
-	writev(viu-viu_fd, iov, iovlen);
+	(void)writev(viu-viu_fd, iov, iovlen);
 
 	rumpuser_component_schedule(cookie);
 }



CVS commit: src/sys/rump/net/lib/libvirtif

2013-07-16 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Jul 16 21:14:42 UTC 2013

Modified Files:
src/sys/rump/net/lib/libvirtif: rumpcomp_user.c

Log Message:
A simple (void) is apparently too easy and traditional to make
Wunused-result STFU, so let's invent something a bit more verbose to
try to achieve the desired result of ccg xnaht I really don't care if
you think I should check the return value.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/rump/net/lib/libvirtif/rumpcomp_user.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/rumpcomp_user.c
diff -u src/sys/rump/net/lib/libvirtif/rumpcomp_user.c:1.9 src/sys/rump/net/lib/libvirtif/rumpcomp_user.c:1.10
--- src/sys/rump/net/lib/libvirtif/rumpcomp_user.c:1.9	Tue Jul 16 19:44:31 2013
+++ src/sys/rump/net/lib/libvirtif/rumpcomp_user.c	Tue Jul 16 21:14:42 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpcomp_user.c,v 1.9 2013/07/16 19:44:31 pooka Exp $	*/
+/*	$NetBSD: rumpcomp_user.c,v 1.10 2013/07/16 21:14:42 pooka Exp $	*/
 
 /*
  * Copyright (c) 2013 Antti Kantee.  All Rights Reserved.
@@ -132,9 +132,19 @@ VIFHYPER_SEND(struct virtif_user *viu,
 	struct iovec *iov, size_t iovlen)
 {
 	void *cookie = rumpuser_component_unschedule();
+	ssize_t idontcare __attribute__((__unused__));
 
-	/* no need to check for return value; packets may be dropped */
-	(void)writev(viu-viu_fd, iov, iovlen);
+	/*
+	 * no need to check for return value; packets may be dropped
+	 *
+	 * ... sorry, I spoke too soon.  We need to check it because
+	 * apparently gcc reinvented const poisoning and it's very
+	 * hard to say thanks, I know I'm not using the result,
+	 * but please STFU and let's get on with something useful.
+	 * So let's trick gcc into letting us share the compiler
+	 * experience.
+	 */
+	idontcare = writev(viu-viu_fd, iov, iovlen);
 
 	rumpuser_component_schedule(cookie);
 }



CVS commit: src/sys/rump/net/lib/libvirtif

2013-07-16 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Jul 16 19:44:31 UTC 2013

Modified Files:
src/sys/rump/net/lib/libvirtif: rumpcomp_user.c

Log Message:
Explicitly ignore return value of writev() for sending a packet.

Otherwise you get the following with some compilers:
warning: ignoring return value of 'writev', declared with attribute 
warn_unused_result [-Wunused-result]


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/rump/net/lib/libvirtif/rumpcomp_user.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/rump/net/lib/libvirtif

2013-07-16 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Jul 16 21:14:42 UTC 2013

Modified Files:
src/sys/rump/net/lib/libvirtif: rumpcomp_user.c

Log Message:
A simple (void) is apparently too easy and traditional to make
Wunused-result STFU, so let's invent something a bit more verbose to
try to achieve the desired result of ccg xnaht I really don't care if
you think I should check the return value.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/rump/net/lib/libvirtif/rumpcomp_user.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/rump/net/lib/libvirtif

2013-07-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Jul  4 09:48:01 UTC 2013

Modified Files:
src/sys/rump/net/lib/libvirtif: rumpcomp_user.c

Log Message:
fix warnings


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/rump/net/lib/libvirtif/rumpcomp_user.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/rumpcomp_user.c
diff -u src/sys/rump/net/lib/libvirtif/rumpcomp_user.c:1.6 src/sys/rump/net/lib/libvirtif/rumpcomp_user.c:1.7
--- src/sys/rump/net/lib/libvirtif/rumpcomp_user.c:1.6	Mon May 20 10:24:26 2013
+++ src/sys/rump/net/lib/libvirtif/rumpcomp_user.c	Thu Jul  4 09:48:01 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpcomp_user.c,v 1.6 2013/05/20 10:24:26 pooka Exp $	*/
+/*	$NetBSD: rumpcomp_user.c,v 1.7 2013/07/04 09:48:01 pooka Exp $	*/
 
 /*
  * Copyright (c) 2013 Antti Kantee.  All Rights Reserved.
@@ -36,6 +36,7 @@
 #include stdio.h
 #include stdlib.h
 #include string.h
+#include unistd.h
 
 #ifdef __linux__
 #include net/if.h
@@ -44,6 +45,8 @@
 
 #include rump/rumpuser_component.h
 
+#include rumpcomp_user.h
+
 struct virtif_user {
 	int viu_fd;
 	int viu_dying;
@@ -150,8 +153,11 @@ rumpcomp_virtif_recv(struct virtif_user 
 	pfd.events = POLLIN;
 
 	for (;;) {
-		if (viu-viu_dying)
+		if (viu-viu_dying) {
+			rv = 0;
+			*rcv = 0;
 			break;
+		}
 
 		prv = poll(pfd, 1, POLLTIMO_MS);
 		if (prv == 0)



CVS commit: src/sys/rump/net/lib/libvirtif

2013-07-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Jul  4 11:46:51 UTC 2013

Modified Files:
src/sys/rump/net/lib/libvirtif: Makefile component.c if_virt.c
rumpcomp_user.c rumpcomp_user.h
Added Files:
src/sys/rump/net/lib/libvirtif: if_virt.h

Log Message:
Determine the interface name and the names of exported symbols based
on VIRTIF_BASE.  This allows using various different packet-shoveling
backends in the same rump kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/rump/net/lib/libvirtif/Makefile
cvs rdiff -u -r1.3 -r1.4 src/sys/rump/net/lib/libvirtif/component.c \
src/sys/rump/net/lib/libvirtif/rumpcomp_user.h
cvs rdiff -u -r1.35 -r1.36 src/sys/rump/net/lib/libvirtif/if_virt.c
cvs rdiff -u -r0 -r1.1 src/sys/rump/net/lib/libvirtif/if_virt.h
cvs rdiff -u -r1.7 -r1.8 src/sys/rump/net/lib/libvirtif/rumpcomp_user.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/Makefile
diff -u src/sys/rump/net/lib/libvirtif/Makefile:1.6 src/sys/rump/net/lib/libvirtif/Makefile:1.7
--- src/sys/rump/net/lib/libvirtif/Makefile:1.6	Fri Mar 15 11:30:23 2013
+++ src/sys/rump/net/lib/libvirtif/Makefile	Thu Jul  4 11:46:51 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.6 2013/03/15 11:30:23 pooka Exp $
+#	$NetBSD: Makefile,v 1.7 2013/07/04 11:46:51 pooka Exp $
 #
 
 LIB=	rumpnet_virtif
@@ -7,8 +7,10 @@ SRCS=	if_virt.c
 SRCS+=	component.c
 
 CPPFLAGS+=	-I${.CURDIR}/../../../librump/rumpkern -I${.CURDIR}
+CPPFLAGS+=	-DVIRTIF_BASE=virt
 
 RUMPCOMP_USER=	#defined
+RUMPCOMP_USER_CPPFLAGS+= -DVIRTIF_BASE=virt
 
 .include bsd.lib.mk
 .include bsd.klinks.mk

Index: src/sys/rump/net/lib/libvirtif/component.c
diff -u src/sys/rump/net/lib/libvirtif/component.c:1.3 src/sys/rump/net/lib/libvirtif/component.c:1.4
--- src/sys/rump/net/lib/libvirtif/component.c:1.3	Tue Oct 19 19:19:41 2010
+++ src/sys/rump/net/lib/libvirtif/component.c	Thu Jul  4 11:46:51 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: component.c,v 1.3 2010/10/19 19:19:41 pooka Exp $	*/
+/*	$NetBSD: component.c,v 1.4 2013/07/04 11:46:51 pooka Exp $	*/
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: component.c,v 1.3 2010/10/19 19:19:41 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: component.c,v 1.4 2013/07/04 11:46:51 pooka Exp $);
 
 #include sys/param.h
 #include sys/domain.h
@@ -38,10 +38,11 @@ __KERNEL_RCSID(0, $NetBSD: component.c,
 
 #include rump_private.h
 #include rump_net_private.h
+#include if_virt.h
 
 RUMP_COMPONENT(RUMP_COMPONENT_NET_IF)
 {
-	extern struct if_clone virtif_cloner; /* XXX */
+	extern struct if_clone VIF_CLONER; /* XXX */
 
-	if_clone_attach(virtif_cloner);
+	if_clone_attach(VIF_CLONER);
 }
Index: src/sys/rump/net/lib/libvirtif/rumpcomp_user.h
diff -u src/sys/rump/net/lib/libvirtif/rumpcomp_user.h:1.3 src/sys/rump/net/lib/libvirtif/rumpcomp_user.h:1.4
--- src/sys/rump/net/lib/libvirtif/rumpcomp_user.h:1.3	Tue Apr 30 00:03:54 2013
+++ src/sys/rump/net/lib/libvirtif/rumpcomp_user.h	Thu Jul  4 11:46:51 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpcomp_user.h,v 1.3 2013/04/30 00:03:54 pooka Exp $	*/
+/*	$NetBSD: rumpcomp_user.h,v 1.4 2013/07/04 11:46:51 pooka Exp $	*/
 
 /*
  * Copyright (c) 2013 Antti Kantee.  All Rights Reserved.
@@ -27,9 +27,9 @@
 
 struct virtif_user;
 
-int 	rumpcomp_virtif_create(int, struct virtif_user **);
-void	rumpcomp_virtif_dying(struct virtif_user *);
-void	rumpcomp_virtif_destroy(struct virtif_user *);
+int 	VIFHYPER_CREATE(int, struct virtif_user **);
+void	VIFHYPER_DYING(struct virtif_user *);
+void	VIFHYPER_DESTROY(struct virtif_user *);
 
-void	rumpcomp_virtif_send(struct virtif_user *, struct iovec *, size_t);
-int	rumpcomp_virtif_recv(struct virtif_user *, void *, size_t, size_t *);
+void	VIFHYPER_SEND(struct virtif_user *, struct iovec *, size_t);
+int	VIFHYPER_RECV(struct virtif_user *, void *, size_t, size_t *);

Index: src/sys/rump/net/lib/libvirtif/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.35 src/sys/rump/net/lib/libvirtif/if_virt.c:1.36
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.35	Wed Jul  3 20:17:07 2013
+++ src/sys/rump/net/lib/libvirtif/if_virt.c	Thu Jul  4 11:46:51 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_virt.c,v 1.35 2013/07/03 20:17:07 pooka Exp $	*/
+/*	$NetBSD: if_virt.c,v 1.36 2013/07/04 11:46:51 pooka Exp $	*/
 
 /*
  * Copyright (c) 2008, 2013 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.35 2013/07/03 20:17:07 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.36 2013/07/04 11:46:51 pooka Exp $);
 
 #include sys/param.h
 #include sys/condvar.h
@@ -53,6 +53,7 @@ __KERNEL_RCSID(0, $NetBSD: if_virt.c,v 
 #include rump_private.h
 #include rump_net_private.h
 
+#include if_virt.h
 #include rumpcomp_user.h
 
 /*
@@ -61,10 +62,6 @@ __KERNEL_RCSID(0, 

CVS commit: src/sys/rump/net/lib/libvirtif

2013-07-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Jul  4 11:58:11 UTC 2013

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.h

Log Message:
Add a note explaining why there's a homegrown __STRING, __CONCAT, etc.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/rump/net/lib/libvirtif/if_virt.h

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/if_virt.h
diff -u src/sys/rump/net/lib/libvirtif/if_virt.h:1.1 src/sys/rump/net/lib/libvirtif/if_virt.h:1.2
--- src/sys/rump/net/lib/libvirtif/if_virt.h:1.1	Thu Jul  4 11:46:51 2013
+++ src/sys/rump/net/lib/libvirtif/if_virt.h	Thu Jul  4 11:58:11 2013
@@ -1,4 +1,8 @@
-/*	$NetBSD: if_virt.h,v 1.1 2013/07/04 11:46:51 pooka Exp $	*/
+/*	$NetBSD: if_virt.h,v 1.2 2013/07/04 11:58:11 pooka Exp $	*/
+
+/*
+ * NOTE!  This file is supposed to work on !NetBSD platforms.
+ */
 
 #ifndef VIRTIF_BASE
 #error Define VIRTIF_BASE



CVS commit: src/sys/rump/net/lib/libvirtif

2013-07-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Jul  4 09:48:01 UTC 2013

Modified Files:
src/sys/rump/net/lib/libvirtif: rumpcomp_user.c

Log Message:
fix warnings


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/rump/net/lib/libvirtif/rumpcomp_user.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/rump/net/lib/libvirtif

2013-07-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Jul  4 11:46:51 UTC 2013

Modified Files:
src/sys/rump/net/lib/libvirtif: Makefile component.c if_virt.c
rumpcomp_user.c rumpcomp_user.h
Added Files:
src/sys/rump/net/lib/libvirtif: if_virt.h

Log Message:
Determine the interface name and the names of exported symbols based
on VIRTIF_BASE.  This allows using various different packet-shoveling
backends in the same rump kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/rump/net/lib/libvirtif/Makefile
cvs rdiff -u -r1.3 -r1.4 src/sys/rump/net/lib/libvirtif/component.c \
src/sys/rump/net/lib/libvirtif/rumpcomp_user.h
cvs rdiff -u -r1.35 -r1.36 src/sys/rump/net/lib/libvirtif/if_virt.c
cvs rdiff -u -r0 -r1.1 src/sys/rump/net/lib/libvirtif/if_virt.h
cvs rdiff -u -r1.7 -r1.8 src/sys/rump/net/lib/libvirtif/rumpcomp_user.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/rump/net/lib/libvirtif

2013-07-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Jul  4 11:58:11 UTC 2013

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.h

Log Message:
Add a note explaining why there's a homegrown __STRING, __CONCAT, etc.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/rump/net/lib/libvirtif/if_virt.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/rump/net/lib/libvirtif

2013-07-03 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Jul  3 15:06:25 UTC 2013

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
Allow alternate interface base names to be specified at compile time.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 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/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.31 src/sys/rump/net/lib/libvirtif/if_virt.c:1.32
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.31	Tue Apr 30 00:03:54 2013
+++ src/sys/rump/net/lib/libvirtif/if_virt.c	Wed Jul  3 15:06:25 2013
@@ -1,7 +1,7 @@
-/*	$NetBSD: if_virt.c,v 1.31 2013/04/30 00:03:54 pooka Exp $	*/
+/*	$NetBSD: if_virt.c,v 1.32 2013/07/03 15:06:25 pooka Exp $	*/
 
 /*
- * Copyright (c) 2008 Antti Kantee.  All Rights Reserved.
+ * Copyright (c) 2008, 2013 Antti Kantee.  All Rights Reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.31 2013/04/30 00:03:54 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.32 2013/07/03 15:06:25 pooka Exp $);
 
 #include sys/param.h
 #include sys/condvar.h
@@ -56,12 +56,14 @@ __KERNEL_RCSID(0, $NetBSD: if_virt.c,v 
 #include rumpcomp_user.h
 
 /*
- * Virtual interface for userspace purposes.  Uses tap(4) to
- * interface with the kernel and just simply shovels data
- * to/from /dev/tap.
+ * Virtual interface.  Uses hypercalls to shovel packets back
+ * and forth.  The exact method for shoveling depends on the
+ * hypercall implementation.
  */
 
+#ifndef VIRTIF_BASE
 #define VIRTIF_BASE virt
+#endif
 
 static int	virtif_init(struct ifnet *);
 static int	virtif_ioctl(struct ifnet *, u_long, void *);
@@ -108,19 +110,20 @@ rump_virtif_create(int num)
 	sc-sc_viu = viu;
 
 	mutex_init(sc-sc_mtx, MUTEX_DEFAULT, IPL_NONE);
-	cv_init(sc-sc_cv, virtsnd);
+	cv_init(sc-sc_cv, VIRTIF_BASE snd);
 	ifp = sc-sc_ec.ec_if;
 	sprintf(ifp-if_xname, %s%d, VIRTIF_BASE, num);
 	ifp-if_softc = sc;
 
 	if (rump_threads) {
 		if ((error = kthread_create(PRI_NONE, KTHREAD_MUSTJOIN, NULL,
-		virtif_receiver, ifp, sc-sc_l_rcv, virtifr)) != 0)
+		virtif_receiver, ifp, sc-sc_l_rcv,
+		VIRTIF_BASE ifr)) != 0)
 			goto out;
 
 		if ((error = kthread_create(PRI_NONE,
 		KTHREAD_MUSTJOIN | KTHREAD_MPSAFE, NULL,
-		virtif_sender, ifp, sc-sc_l_snd, virtifs)) != 0)
+		virtif_sender, ifp, sc-sc_l_snd, VIRTIF_BASE ifs)) != 0)
 			goto out;
 	} else {
 		printf(WARNING: threads not enabled, receive NOT working\n);



CVS commit: src/sys/rump/net/lib/libvirtif

2013-07-03 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Jul  3 19:23:46 UTC 2013

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
Adjust for rump_virtif_create() removal.  Incidentally, this reduces
the number of exported symbols by one (which is useful for phase 2).


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 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/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.33 src/sys/rump/net/lib/libvirtif/if_virt.c:1.34
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.33	Wed Jul  3 15:08:01 2013
+++ src/sys/rump/net/lib/libvirtif/if_virt.c	Wed Jul  3 19:23:46 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_virt.c,v 1.33 2013/07/03 15:08:01 pooka Exp $	*/
+/*	$NetBSD: if_virt.c,v 1.34 2013/07/03 19:23:46 pooka Exp $	*/
 
 /*
  * Copyright (c) 2008, 2013 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.33 2013/07/03 15:08:01 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.34 2013/07/03 19:23:46 pooka Exp $);
 
 #include sys/param.h
 #include sys/condvar.h
@@ -87,8 +87,8 @@ static int  virtif_unclone(struct ifnet 
 struct if_clone virtif_cloner =
 IF_CLONE_INITIALIZER(VIRTIF_BASE, virtif_clone, virtif_unclone);
 
-int
-rump_virtif_create(int num)
+static int
+virtif_clone(struct if_clone *ifc, int unit)
 {
 	struct virtif_sc *sc;
 	struct virtif_user *viu;
@@ -148,13 +148,6 @@ rump_virtif_create(int num)
 }
 
 static int
-virtif_clone(struct if_clone *ifc, int unit)
-{
-
-	return rump_virtif_create(unit);
-}
-
-static int
 virtif_unclone(struct ifnet *ifp)
 {
 	struct virtif_sc *sc = ifp-if_softc;



CVS commit: src/sys/rump/net/lib/libvirtif

2013-07-03 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Jul  3 20:17:07 UTC 2013

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
fix parameter name


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 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/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.34 src/sys/rump/net/lib/libvirtif/if_virt.c:1.35
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.34	Wed Jul  3 19:23:46 2013
+++ src/sys/rump/net/lib/libvirtif/if_virt.c	Wed Jul  3 20:17:07 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_virt.c,v 1.34 2013/07/03 19:23:46 pooka Exp $	*/
+/*	$NetBSD: if_virt.c,v 1.35 2013/07/03 20:17:07 pooka Exp $	*/
 
 /*
  * Copyright (c) 2008, 2013 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.34 2013/07/03 19:23:46 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.35 2013/07/03 20:17:07 pooka Exp $);
 
 #include sys/param.h
 #include sys/condvar.h
@@ -88,7 +88,7 @@ struct if_clone virtif_cloner =
 IF_CLONE_INITIALIZER(VIRTIF_BASE, virtif_clone, virtif_unclone);
 
 static int
-virtif_clone(struct if_clone *ifc, int unit)
+virtif_clone(struct if_clone *ifc, int num)
 {
 	struct virtif_sc *sc;
 	struct virtif_user *viu;



CVS commit: src/sys/rump/net/lib/libvirtif

2013-07-03 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Jul  3 15:06:25 UTC 2013

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
Allow alternate interface base names to be specified at compile time.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 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.



CVS commit: src/sys/rump/net/lib/libvirtif

2013-07-03 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Jul  3 20:17:07 UTC 2013

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
fix parameter name


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 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.



CVS commit: src/sys/rump/net/lib/libvirtif

2013-05-20 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon May 20 10:24:26 UTC 2013

Modified Files:
src/sys/rump/net/lib/libvirtif: rumpcomp_user.c

Log Message:
Return 0 for success instead of returning an uninitialized automatic variable.

from Gal Sagie, PR 47837


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/rump/net/lib/libvirtif/rumpcomp_user.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/rumpcomp_user.c
diff -u src/sys/rump/net/lib/libvirtif/rumpcomp_user.c:1.5 src/sys/rump/net/lib/libvirtif/rumpcomp_user.c:1.6
--- src/sys/rump/net/lib/libvirtif/rumpcomp_user.c:1.5	Tue Apr 30 12:39:21 2013
+++ src/sys/rump/net/lib/libvirtif/rumpcomp_user.c	Mon May 20 10:24:26 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpcomp_user.c,v 1.5 2013/04/30 12:39:21 pooka Exp $	*/
+/*	$NetBSD: rumpcomp_user.c,v 1.6 2013/05/20 10:24:26 pooka Exp $	*/
 
 /*
  * Copyright (c) 2013 Antti Kantee.  All Rights Reserved.
@@ -114,6 +114,7 @@ rumpcomp_virtif_create(int devnum, struc
 		goto out;
 	}
 	viu-viu_dying = 0;
+	rv = 0;
 
  out:
 	rumpuser_component_schedule(cookie);



CVS commit: src/sys/rump/net/lib/libvirtif

2013-05-20 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon May 20 10:24:26 UTC 2013

Modified Files:
src/sys/rump/net/lib/libvirtif: rumpcomp_user.c

Log Message:
Return 0 for success instead of returning an uninitialized automatic variable.

from Gal Sagie, PR 47837


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/rump/net/lib/libvirtif/rumpcomp_user.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/rump/net/lib/libvirtif

2013-03-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar 16 21:37:04 UTC 2013

Modified Files:
src/sys/rump/net/lib/libvirtif: rumpcomp_user.c

Log Message:
fix the build!


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/rump/net/lib/libvirtif/rumpcomp_user.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/rumpcomp_user.c
diff -u src/sys/rump/net/lib/libvirtif/rumpcomp_user.c:1.2 src/sys/rump/net/lib/libvirtif/rumpcomp_user.c:1.3
--- src/sys/rump/net/lib/libvirtif/rumpcomp_user.c:1.2	Wed Mar 13 17:17:32 2013
+++ src/sys/rump/net/lib/libvirtif/rumpcomp_user.c	Sat Mar 16 17:37:04 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpcomp_user.c,v 1.2 2013/03/13 21:17:32 pooka Exp $	*/
+/*	$NetBSD: rumpcomp_user.c,v 1.3 2013/03/16 21:37:04 christos Exp $	*/
 
 /*
  * Copyright (c) 2013 Antti Kantee.  All Rights Reserved.
@@ -25,6 +25,7 @@
  * SUCH DAMAGE.
  */
 
+#ifndef _KERNEL
 #include sys/types.h
 #include sys/ioctl.h
 #include sys/uio.h
@@ -180,3 +181,4 @@ rumpcomp_virtif_destroy(struct virtif_us
 
 	rumpuser_component_schedule(cookie);
 }
+#endif



CVS commit: src/sys/rump/net/lib/libvirtif

2013-03-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar 16 21:37:04 UTC 2013

Modified Files:
src/sys/rump/net/lib/libvirtif: rumpcomp_user.c

Log Message:
fix the build!


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/rump/net/lib/libvirtif/rumpcomp_user.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/rump/net/lib/libvirtif

2013-03-15 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri Mar 15 11:30:23 UTC 2013

Modified Files:
src/sys/rump/net/lib/libvirtif: Makefile if_virt.c

Log Message:
Rerevert to preprevious now that this builds with build.sh


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/rump/net/lib/libvirtif/Makefile
cvs rdiff -u -r1.29 -r1.30 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/Makefile
diff -u src/sys/rump/net/lib/libvirtif/Makefile:1.5 src/sys/rump/net/lib/libvirtif/Makefile:1.6
--- src/sys/rump/net/lib/libvirtif/Makefile:1.5	Thu Mar 14 01:23:34 2013
+++ src/sys/rump/net/lib/libvirtif/Makefile	Fri Mar 15 11:30:23 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.5 2013/03/14 01:23:34 pooka Exp $
+#	$NetBSD: Makefile,v 1.6 2013/03/15 11:30:23 pooka Exp $
 #
 
 LIB=	rumpnet_virtif
@@ -6,7 +6,9 @@ LIB=	rumpnet_virtif
 SRCS=	if_virt.c
 SRCS+=	component.c
 
-CPPFLAGS+=	-I${.CURDIR}/../../../librump/rumpkern
+CPPFLAGS+=	-I${.CURDIR}/../../../librump/rumpkern -I${.CURDIR}
+
+RUMPCOMP_USER=	#defined
 
 .include bsd.lib.mk
 .include bsd.klinks.mk

Index: src/sys/rump/net/lib/libvirtif/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.29 src/sys/rump/net/lib/libvirtif/if_virt.c:1.30
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.29	Thu Mar 14 01:23:34 2013
+++ src/sys/rump/net/lib/libvirtif/if_virt.c	Fri Mar 15 11:30:23 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_virt.c,v 1.29 2013/03/14 01:23:34 pooka Exp $	*/
+/*	$NetBSD: if_virt.c,v 1.30 2013/03/15 11:30:23 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.29 2013/03/14 01:23:34 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.30 2013/03/15 11:30:23 pooka Exp $);
 
 #include sys/param.h
 #include sys/condvar.h
@@ -49,11 +49,12 @@ __KERNEL_RCSID(0, $NetBSD: if_virt.c,v 
 #include netinet/in_var.h
 
 #include rump/rump.h
-#include rump/rumpuser.h
 
 #include rump_private.h
 #include rump_net_private.h
 
+#include rumpcomp_user.h
+
 /*
  * Virtual interface for userspace purposes.  Uses tap(4) to
  * interface with the kernel and just simply shovels data
@@ -69,7 +70,7 @@ static void	virtif_stop(struct ifnet *, 
 
 struct virtif_sc {
 	struct ethercom sc_ec;
-	int sc_tapfd;
+	struct virtif_user *sc_viu;
 	bool sc_dying;
 	struct lwp *sc_l_snd, *sc_l_rcv;
 	kmutex_t sc_mtx;
@@ -88,27 +89,23 @@ int
 rump_virtif_create(int num)
 {
 	struct virtif_sc *sc;
+	struct virtif_user *viu;
 	struct ifnet *ifp;
 	uint8_t enaddr[ETHER_ADDR_LEN] = { 0xb2, 0x0a, 0x00, 0x0b, 0x0e, 0x01 };
-	char tapdev[16];
-	int fd, error = 0;
+	int error = 0;
 
 	if (num = 0x100)
 		return E2BIG;
 
-	snprintf(tapdev, sizeof(tapdev), /dev/tap%d, num);
-	fd = rumpuser_open(tapdev, RUMPUSER_OPEN_RDWR, error);
-	if (fd == -1) {
-		printf(virtif_create: can't open /dev/tap%d: %d\n,
-		num, error);
-		return error;
-	}
+	if ((viu = rumpcomp_virtif_create(num)) == NULL)
+		return ENXIO;
+
 	enaddr[2] = cprng_fast32()  0xff;
 	enaddr[5] = num;
 
 	sc = kmem_zalloc(sizeof(*sc), KM_SLEEP);
 	sc-sc_dying = false;
-	sc-sc_tapfd = fd;
+	sc-sc_viu = viu;
 
 	mutex_init(sc-sc_mtx, MUTEX_DEFAULT, IPL_NONE);
 	cv_init(sc-sc_cv, virtsnd);
@@ -168,6 +165,8 @@ virtif_unclone(struct ifnet *ifp)
 	cv_broadcast(sc-sc_cv);
 	mutex_exit(sc-sc_mtx);
 
+	rumpcomp_virtif_dying(sc-sc_viu);
+
 	virtif_stop(ifp, 1);
 	if_down(ifp);
 
@@ -180,7 +179,7 @@ virtif_unclone(struct ifnet *ifp)
 		sc-sc_l_rcv = NULL;
 	}
 
-	rumpuser_close(sc-sc_tapfd, NULL);
+	rumpcomp_virtif_destroy(sc-sc_viu);
 
 	mutex_destroy(sc-sc_mtx);
 	cv_destroy(sc-sc_cv);
@@ -220,7 +219,6 @@ virtif_ioctl(struct ifnet *ifp, u_long c
 	return rv;
 }
 
-/* just send everything in-context */
 static void
 virtif_start(struct ifnet *ifp)
 {
@@ -252,35 +250,21 @@ virtif_receiver(void *arg)
 	struct virtif_sc *sc = ifp-if_softc;
 	struct mbuf *m;
 	size_t plen = ETHER_MAX_LEN_JUMBO+1;
-	struct pollfd pfd;
 	ssize_t n;
-	int error, rv;
-
-	pfd.fd = sc-sc_tapfd;
-	pfd.events = POLLIN;
 
 	for (;;) {
 		m = m_gethdr(M_WAIT, MT_DATA);
 		MEXTMALLOC(m, plen, M_WAIT);
 
  again:
-		/* poll, but periodically check if we should die */
-		rv = rumpuser_poll(pfd, 1, POLLTIMO_MS, error);
 		if (sc-sc_dying) {
 			m_freem(m);
 			break;
 		}
-		if (rv == 0)
-			goto again;
-
-		n = rumpuser_read(sc-sc_tapfd, mtod(m, void *), plen, error);
-		KASSERT(n  ETHER_MAX_LEN_JUMBO);
-		if (__predict_false(n  0)) {
-			if (n == -1  error == EAGAIN) {
-goto again;
-			}
-
-			printf(%s: read from /dev/tap failed. host is down?\n,
+		
+		n = rumpcomp_virtif_recv(sc-sc_viu, mtod(m, void *), plen);
+		if (n  0) {
+			printf(%s: read hypercall failed. host if down?\n,
 			ifp-if_xname);
 			mutex_enter(sc-sc_mtx);
 			/* could check if need go, done soon anyway */

CVS commit: src/sys/rump/net/lib/libvirtif

2013-03-15 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri Mar 15 11:30:23 UTC 2013

Modified Files:
src/sys/rump/net/lib/libvirtif: Makefile if_virt.c

Log Message:
Rerevert to preprevious now that this builds with build.sh


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/rump/net/lib/libvirtif/Makefile
cvs rdiff -u -r1.29 -r1.30 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.



CVS commit: src/sys/rump/net/lib/libvirtif

2013-03-13 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Mar 13 21:13:45 UTC 2013

Modified Files:
src/sys/rump/net/lib/libvirtif: Makefile if_virt.c
Added Files:
src/sys/rump/net/lib/libvirtif: rumpcomp_user.c rumpcomp_user.h

Log Message:
Push the bits accessing the networking backend into hypercalls.
This allows a few highly desirable things to happen:

1) Linux support, which is included in this commit (thanks to wanq for
   sending me the magic bits for accessing /dev/net/tun)
2) Reusing the kernel-side of the interface for devices such as
   hardware packet processors which interact directly with user vm spaces
   (not included in the commit).


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/rump/net/lib/libvirtif/Makefile
cvs rdiff -u -r1.27 -r1.28 src/sys/rump/net/lib/libvirtif/if_virt.c
cvs rdiff -u -r0 -r1.1 src/sys/rump/net/lib/libvirtif/rumpcomp_user.c \
src/sys/rump/net/lib/libvirtif/rumpcomp_user.h

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/Makefile
diff -u src/sys/rump/net/lib/libvirtif/Makefile:1.3 src/sys/rump/net/lib/libvirtif/Makefile:1.4
--- src/sys/rump/net/lib/libvirtif/Makefile:1.3	Thu May 28 00:02:17 2009
+++ src/sys/rump/net/lib/libvirtif/Makefile	Wed Mar 13 21:13:45 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.3 2009/05/28 00:02:17 pooka Exp $
+#	$NetBSD: Makefile,v 1.4 2013/03/13 21:13:45 pooka Exp $
 #
 
 LIB=	rumpnet_virtif
@@ -6,7 +6,9 @@ LIB=	rumpnet_virtif
 SRCS=	if_virt.c
 SRCS+=	component.c
 
-CPPFLAGS+=	-I${.CURDIR}/../../../librump/rumpkern
+CPPFLAGS+=	-I${.CURDIR}/../../../librump/rumpkern -I${.CURDIR}
+
+RUMPCOMP_USER=	#defined
 
 .include bsd.lib.mk
 .include bsd.klinks.mk

Index: src/sys/rump/net/lib/libvirtif/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.27 src/sys/rump/net/lib/libvirtif/if_virt.c:1.28
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.27	Fri Sep 14 16:29:22 2012
+++ src/sys/rump/net/lib/libvirtif/if_virt.c	Wed Mar 13 21:13:45 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_virt.c,v 1.27 2012/09/14 16:29:22 pooka Exp $	*/
+/*	$NetBSD: if_virt.c,v 1.28 2013/03/13 21:13:45 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.27 2012/09/14 16:29:22 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.28 2013/03/13 21:13:45 pooka Exp $);
 
 #include sys/param.h
 #include sys/condvar.h
@@ -49,11 +49,12 @@ __KERNEL_RCSID(0, $NetBSD: if_virt.c,v 
 #include netinet/in_var.h
 
 #include rump/rump.h
-#include rump/rumpuser.h
 
 #include rump_private.h
 #include rump_net_private.h
 
+#include rumpcomp_user.h
+
 /*
  * Virtual interface for userspace purposes.  Uses tap(4) to
  * interface with the kernel and just simply shovels data
@@ -69,7 +70,7 @@ static void	virtif_stop(struct ifnet *, 
 
 struct virtif_sc {
 	struct ethercom sc_ec;
-	int sc_tapfd;
+	struct virtif_user *sc_viu;
 	bool sc_dying;
 	struct lwp *sc_l_snd, *sc_l_rcv;
 	kmutex_t sc_mtx;
@@ -88,27 +89,23 @@ int
 rump_virtif_create(int num)
 {
 	struct virtif_sc *sc;
+	struct virtif_user *viu;
 	struct ifnet *ifp;
 	uint8_t enaddr[ETHER_ADDR_LEN] = { 0xb2, 0x0a, 0x00, 0x0b, 0x0e, 0x01 };
-	char tapdev[16];
-	int fd, error = 0;
+	int error = 0;
 
 	if (num = 0x100)
 		return E2BIG;
 
-	snprintf(tapdev, sizeof(tapdev), /dev/tap%d, num);
-	fd = rumpuser_open(tapdev, RUMPUSER_OPEN_RDWR, error);
-	if (fd == -1) {
-		printf(virtif_create: can't open /dev/tap%d: %d\n,
-		num, error);
-		return error;
-	}
+	if ((viu = rumpcomp_virtif_create(num)) == NULL)
+		return ENXIO;
+
 	enaddr[2] = cprng_fast32()  0xff;
 	enaddr[5] = num;
 
 	sc = kmem_zalloc(sizeof(*sc), KM_SLEEP);
 	sc-sc_dying = false;
-	sc-sc_tapfd = fd;
+	sc-sc_viu = viu;
 
 	mutex_init(sc-sc_mtx, MUTEX_DEFAULT, IPL_NONE);
 	cv_init(sc-sc_cv, virtsnd);
@@ -168,6 +165,8 @@ virtif_unclone(struct ifnet *ifp)
 	cv_broadcast(sc-sc_cv);
 	mutex_exit(sc-sc_mtx);
 
+	rumpcomp_virtif_dying(sc-sc_viu);
+
 	virtif_stop(ifp, 1);
 	if_down(ifp);
 
@@ -180,7 +179,7 @@ virtif_unclone(struct ifnet *ifp)
 		sc-sc_l_rcv = NULL;
 	}
 
-	rumpuser_close(sc-sc_tapfd, NULL);
+	rumpcomp_virtif_destroy(sc-sc_viu);
 
 	mutex_destroy(sc-sc_mtx);
 	cv_destroy(sc-sc_cv);
@@ -220,7 +219,6 @@ virtif_ioctl(struct ifnet *ifp, u_long c
 	return rv;
 }
 
-/* just send everything in-context */
 static void
 virtif_start(struct ifnet *ifp)
 {
@@ -252,35 +250,21 @@ virtif_receiver(void *arg)
 	struct virtif_sc *sc = ifp-if_softc;
 	struct mbuf *m;
 	size_t plen = ETHER_MAX_LEN_JUMBO+1;
-	struct pollfd pfd;
 	ssize_t n;
-	int error, rv;
-
-	pfd.fd = sc-sc_tapfd;
-	pfd.events = POLLIN;
 
 	for (;;) {
 		m = m_gethdr(M_WAIT, MT_DATA);
 		MEXTMALLOC(m, plen, M_WAIT);
 
  again:
-		/* poll, but periodically check if we should die */
-		rv = rumpuser_poll(pfd, 1, POLLTIMO_MS, error);
 		if 

CVS commit: src/sys/rump/net/lib/libvirtif

2013-03-13 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Mar 13 21:17:32 UTC 2013

Modified Files:
src/sys/rump/net/lib/libvirtif: rumpcomp_user.c rumpcomp_user.h

Log Message:
Fix a few minor issues found by proofreading the diff one last time.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/rump/net/lib/libvirtif/rumpcomp_user.c \
src/sys/rump/net/lib/libvirtif/rumpcomp_user.h

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/rumpcomp_user.c
diff -u src/sys/rump/net/lib/libvirtif/rumpcomp_user.c:1.1 src/sys/rump/net/lib/libvirtif/rumpcomp_user.c:1.2
--- src/sys/rump/net/lib/libvirtif/rumpcomp_user.c:1.1	Wed Mar 13 21:13:45 2013
+++ src/sys/rump/net/lib/libvirtif/rumpcomp_user.c	Wed Mar 13 21:17:32 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpcomp_user.c,v 1.1 2013/03/13 21:13:45 pooka Exp $	*/
+/*	$NetBSD: rumpcomp_user.c,v 1.2 2013/03/13 21:17:32 pooka Exp $	*/
 
 /*
  * Copyright (c) 2013 Antti Kantee.  All Rights Reserved.
@@ -127,7 +127,7 @@ rumpcomp_virtif_send(struct virtif_user 
 
 /* how often to check for interface going south */
 #define POLLTIMO_MS 10
-size_t
+ssize_t
 rumpcomp_virtif_recv(struct virtif_user *viu, void *data, size_t dlen)
 {
 	void *cookie = rumpuser_component_unschedule();
@@ -145,8 +145,10 @@ rumpcomp_virtif_recv(struct virtif_user 
 		rv = poll(pfd, 1, POLLTIMO_MS);
 		if (rv == 0)
 			continue;
-		if (rv == -1)
+		if (rv == -1) {
+			nn = -1;
 			break;
+		}
 
 		nn = read(viu-viu_fd, data, dlen);
 		if (nn == -1  errno == EAGAIN)
Index: src/sys/rump/net/lib/libvirtif/rumpcomp_user.h
diff -u src/sys/rump/net/lib/libvirtif/rumpcomp_user.h:1.1 src/sys/rump/net/lib/libvirtif/rumpcomp_user.h:1.2
--- src/sys/rump/net/lib/libvirtif/rumpcomp_user.h:1.1	Wed Mar 13 21:13:45 2013
+++ src/sys/rump/net/lib/libvirtif/rumpcomp_user.h	Wed Mar 13 21:17:32 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpcomp_user.h,v 1.1 2013/03/13 21:13:45 pooka Exp $	*/
+/*	$NetBSD: rumpcomp_user.h,v 1.2 2013/03/13 21:17:32 pooka Exp $	*/
 
 /*
  * Copyright (c) 2013 Antti Kantee.  All Rights Reserved.
@@ -32,4 +32,4 @@ void rumpcomp_virtif_dying(struct virtif
 void rumpcomp_virtif_destroy(struct virtif_user *);
 
 void	rumpcomp_virtif_send(struct virtif_user *, struct iovec *, size_t);
-ssize_t	rumpcomp_virtif_recv(struct virtif_user *, void *data, size_t);
+ssize_t	rumpcomp_virtif_recv(struct virtif_user *, void *, size_t);



CVS commit: src/sys/rump/net/lib/libvirtif

2013-03-13 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Mar 14 01:23:35 UTC 2013

Modified Files:
src/sys/rump/net/lib/libvirtif: Makefile if_virt.c

Log Message:
Guess the RUMPCOMP_USER stuff wasn't ready to be in the NetBSD tree yet,
so revert previous commits to fix build.  I'll look at rereverting when
toolchain/47644 is fixed and clean buildtests are again possible.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/rump/net/lib/libvirtif/Makefile
cvs rdiff -u -r1.28 -r1.29 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/Makefile
diff -u src/sys/rump/net/lib/libvirtif/Makefile:1.4 src/sys/rump/net/lib/libvirtif/Makefile:1.5
--- src/sys/rump/net/lib/libvirtif/Makefile:1.4	Wed Mar 13 21:13:45 2013
+++ src/sys/rump/net/lib/libvirtif/Makefile	Thu Mar 14 01:23:34 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.4 2013/03/13 21:13:45 pooka Exp $
+#	$NetBSD: Makefile,v 1.5 2013/03/14 01:23:34 pooka Exp $
 #
 
 LIB=	rumpnet_virtif
@@ -6,9 +6,7 @@ LIB=	rumpnet_virtif
 SRCS=	if_virt.c
 SRCS+=	component.c
 
-CPPFLAGS+=	-I${.CURDIR}/../../../librump/rumpkern -I${.CURDIR}
-
-RUMPCOMP_USER=	#defined
+CPPFLAGS+=	-I${.CURDIR}/../../../librump/rumpkern
 
 .include bsd.lib.mk
 .include bsd.klinks.mk

Index: src/sys/rump/net/lib/libvirtif/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.28 src/sys/rump/net/lib/libvirtif/if_virt.c:1.29
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.28	Wed Mar 13 21:13:45 2013
+++ src/sys/rump/net/lib/libvirtif/if_virt.c	Thu Mar 14 01:23:34 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_virt.c,v 1.28 2013/03/13 21:13:45 pooka Exp $	*/
+/*	$NetBSD: if_virt.c,v 1.29 2013/03/14 01:23:34 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.28 2013/03/13 21:13:45 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.29 2013/03/14 01:23:34 pooka Exp $);
 
 #include sys/param.h
 #include sys/condvar.h
@@ -49,12 +49,11 @@ __KERNEL_RCSID(0, $NetBSD: if_virt.c,v 
 #include netinet/in_var.h
 
 #include rump/rump.h
+#include rump/rumpuser.h
 
 #include rump_private.h
 #include rump_net_private.h
 
-#include rumpcomp_user.h
-
 /*
  * Virtual interface for userspace purposes.  Uses tap(4) to
  * interface with the kernel and just simply shovels data
@@ -70,7 +69,7 @@ static void	virtif_stop(struct ifnet *, 
 
 struct virtif_sc {
 	struct ethercom sc_ec;
-	struct virtif_user *sc_viu;
+	int sc_tapfd;
 	bool sc_dying;
 	struct lwp *sc_l_snd, *sc_l_rcv;
 	kmutex_t sc_mtx;
@@ -89,23 +88,27 @@ int
 rump_virtif_create(int num)
 {
 	struct virtif_sc *sc;
-	struct virtif_user *viu;
 	struct ifnet *ifp;
 	uint8_t enaddr[ETHER_ADDR_LEN] = { 0xb2, 0x0a, 0x00, 0x0b, 0x0e, 0x01 };
-	int error = 0;
+	char tapdev[16];
+	int fd, error = 0;
 
 	if (num = 0x100)
 		return E2BIG;
 
-	if ((viu = rumpcomp_virtif_create(num)) == NULL)
-		return ENXIO;
-
+	snprintf(tapdev, sizeof(tapdev), /dev/tap%d, num);
+	fd = rumpuser_open(tapdev, RUMPUSER_OPEN_RDWR, error);
+	if (fd == -1) {
+		printf(virtif_create: can't open /dev/tap%d: %d\n,
+		num, error);
+		return error;
+	}
 	enaddr[2] = cprng_fast32()  0xff;
 	enaddr[5] = num;
 
 	sc = kmem_zalloc(sizeof(*sc), KM_SLEEP);
 	sc-sc_dying = false;
-	sc-sc_viu = viu;
+	sc-sc_tapfd = fd;
 
 	mutex_init(sc-sc_mtx, MUTEX_DEFAULT, IPL_NONE);
 	cv_init(sc-sc_cv, virtsnd);
@@ -165,8 +168,6 @@ virtif_unclone(struct ifnet *ifp)
 	cv_broadcast(sc-sc_cv);
 	mutex_exit(sc-sc_mtx);
 
-	rumpcomp_virtif_dying(sc-sc_viu);
-
 	virtif_stop(ifp, 1);
 	if_down(ifp);
 
@@ -179,7 +180,7 @@ virtif_unclone(struct ifnet *ifp)
 		sc-sc_l_rcv = NULL;
 	}
 
-	rumpcomp_virtif_destroy(sc-sc_viu);
+	rumpuser_close(sc-sc_tapfd, NULL);
 
 	mutex_destroy(sc-sc_mtx);
 	cv_destroy(sc-sc_cv);
@@ -219,6 +220,7 @@ virtif_ioctl(struct ifnet *ifp, u_long c
 	return rv;
 }
 
+/* just send everything in-context */
 static void
 virtif_start(struct ifnet *ifp)
 {
@@ -250,21 +252,35 @@ virtif_receiver(void *arg)
 	struct virtif_sc *sc = ifp-if_softc;
 	struct mbuf *m;
 	size_t plen = ETHER_MAX_LEN_JUMBO+1;
+	struct pollfd pfd;
 	ssize_t n;
+	int error, rv;
+
+	pfd.fd = sc-sc_tapfd;
+	pfd.events = POLLIN;
 
 	for (;;) {
 		m = m_gethdr(M_WAIT, MT_DATA);
 		MEXTMALLOC(m, plen, M_WAIT);
 
  again:
+		/* poll, but periodically check if we should die */
+		rv = rumpuser_poll(pfd, 1, POLLTIMO_MS, error);
 		if (sc-sc_dying) {
 			m_freem(m);
 			break;
 		}
-		
-		n = rumpcomp_virtif_recv(sc-sc_viu, mtod(m, void *), plen);
-		if (n  0) {
-			printf(%s: read hypercall failed. host if down?\n,
+		if (rv == 0)
+			goto again;
+
+		n = rumpuser_read(sc-sc_tapfd, mtod(m, void *), plen, error);
+		KASSERT(n  ETHER_MAX_LEN_JUMBO);
+		if (__predict_false(n  0)) {
+			if (n == -1  error == EAGAIN) {
+goto again;
+			}
+
+			

CVS commit: src/sys/rump/net/lib/libvirtif

2013-03-13 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Mar 13 21:13:45 UTC 2013

Modified Files:
src/sys/rump/net/lib/libvirtif: Makefile if_virt.c
Added Files:
src/sys/rump/net/lib/libvirtif: rumpcomp_user.c rumpcomp_user.h

Log Message:
Push the bits accessing the networking backend into hypercalls.
This allows a few highly desirable things to happen:

1) Linux support, which is included in this commit (thanks to wanq for
   sending me the magic bits for accessing /dev/net/tun)
2) Reusing the kernel-side of the interface for devices such as
   hardware packet processors which interact directly with user vm spaces
   (not included in the commit).


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/rump/net/lib/libvirtif/Makefile
cvs rdiff -u -r1.27 -r1.28 src/sys/rump/net/lib/libvirtif/if_virt.c
cvs rdiff -u -r0 -r1.1 src/sys/rump/net/lib/libvirtif/rumpcomp_user.c \
src/sys/rump/net/lib/libvirtif/rumpcomp_user.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/rump/net/lib/libvirtif

2013-03-13 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Mar 13 21:17:32 UTC 2013

Modified Files:
src/sys/rump/net/lib/libvirtif: rumpcomp_user.c rumpcomp_user.h

Log Message:
Fix a few minor issues found by proofreading the diff one last time.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/rump/net/lib/libvirtif/rumpcomp_user.c \
src/sys/rump/net/lib/libvirtif/rumpcomp_user.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/rump/net/lib/libvirtif

2013-03-13 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Mar 14 01:23:35 UTC 2013

Modified Files:
src/sys/rump/net/lib/libvirtif: Makefile if_virt.c

Log Message:
Guess the RUMPCOMP_USER stuff wasn't ready to be in the NetBSD tree yet,
so revert previous commits to fix build.  I'll look at rereverting when
toolchain/47644 is fixed and clean buildtests are again possible.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/rump/net/lib/libvirtif/Makefile
cvs rdiff -u -r1.28 -r1.29 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.



CVS commit: src/sys/rump/net/lib/libvirtif

2011-10-31 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Mon Oct 31 13:25:21 UTC 2011

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
fix a type in a printf message


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 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/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.24 src/sys/rump/net/lib/libvirtif/if_virt.c:1.25
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.24	Sun Aug  7 14:03:16 2011
+++ src/sys/rump/net/lib/libvirtif/if_virt.c	Mon Oct 31 13:25:21 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_virt.c,v 1.24 2011/08/07 14:03:16 rmind Exp $	*/
+/*	$NetBSD: if_virt.c,v 1.25 2011/10/31 13:25:21 yamt 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.24 2011/08/07 14:03:16 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.25 2011/10/31 13:25:21 yamt Exp $);
 
 #include sys/param.h
 #include sys/condvar.h
@@ -279,7 +279,7 @@ virtif_receiver(void *arg)
 goto again;
 			}
 
-			printf(%s: read from /dev/tap failed. host if down?\n,
+			printf(%s: read from /dev/tap failed. host is down?\n,
 			ifp-if_xname);
 			mutex_enter(sc-sc_mtx);
 			/* could check if need go, done soon anyway */



CVS commit: src/sys/rump/net/lib/libvirtif

2011-06-21 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Jun 22 04:01:09 UTC 2011

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
fix an operator precedence error picked up by GCC 4.5.3.  real bug.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 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/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.22 src/sys/rump/net/lib/libvirtif/if_virt.c:1.23
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.22	Wed Dec  1 15:13:24 2010
+++ src/sys/rump/net/lib/libvirtif/if_virt.c	Wed Jun 22 04:01:08 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_virt.c,v 1.22 2010/12/01 15:13:24 pooka Exp $	*/
+/*	$NetBSD: if_virt.c,v 1.23 2011/06/22 04:01:08 mrg 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.22 2010/12/01 15:13:24 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.23 2011/06/22 04:01:08 mrg Exp $);
 
 #include sys/param.h
 #include sys/condvar.h
@@ -319,7 +319,7 @@
 	mutex_enter(sc-sc_mtx);
 	KERNEL_LOCK(1, NULL);
 	while (!sc-sc_dying) {
-		if (!ifp-if_flags  IFF_RUNNING) {
+		if (!(ifp-if_flags  IFF_RUNNING)) {
 			cv_wait(sc-sc_cv, sc-sc_mtx);
 			continue;
 		}



CVS commit: src/sys/rump/net/lib/libvirtif

2011-06-21 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Jun 22 04:01:09 UTC 2011

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
fix an operator precedence error picked up by GCC 4.5.3.  real bug.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 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.



CVS commit: src/sys/rump/net/lib/libvirtif

2010-12-01 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Dec  1 15:13:24 UTC 2010

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
Don't bother asserting: if we create the thread without KTHREAD_MPSAFE,
it's not going to be MPSAFE.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 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/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.21 src/sys/rump/net/lib/libvirtif/if_virt.c:1.22
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.21	Mon Nov 15 20:23:11 2010
+++ src/sys/rump/net/lib/libvirtif/if_virt.c	Wed Dec  1 15:13:24 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_virt.c,v 1.21 2010/11/15 20:23:11 pooka Exp $	*/
+/*	$NetBSD: if_virt.c,v 1.22 2010/12/01 15:13:24 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.21 2010/11/15 20:23:11 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.22 2010/12/01 15:13:24 pooka Exp $);
 
 #include sys/param.h
 #include sys/condvar.h
@@ -258,8 +258,6 @@
 	pfd.fd = sc-sc_tapfd;
 	pfd.events = POLLIN;
 
-	KASSERT(rump_kernel_isbiglocked());
-
 	for (;;) {
 		m = m_gethdr(M_WAIT, MT_DATA);
 		MEXTMALLOC(m, plen, M_WAIT);



CVS commit: src/sys/rump/net/lib/libvirtif

2010-12-01 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Dec  1 15:13:24 UTC 2010

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
Don't bother asserting: if we create the thread without KTHREAD_MPSAFE,
it's not going to be MPSAFE.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 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.



CVS commit: src/sys/rump/net/lib/libvirtif

2010-11-15 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Nov 15 20:23:12 UTC 2010

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
Make interface support ifconfig {down,destroy} and generally make
it a little less eager to panic.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 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/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.20 src/sys/rump/net/lib/libvirtif/if_virt.c:1.21
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.20	Tue Oct 19 19:19:41 2010
+++ src/sys/rump/net/lib/libvirtif/if_virt.c	Mon Nov 15 20:23:11 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_virt.c,v 1.20 2010/10/19 19:19:41 pooka Exp $	*/
+/*	$NetBSD: if_virt.c,v 1.21 2010/11/15 20:23:11 pooka Exp $	*/
 
 /*
  * Copyright (c) 2008 Antti Kantee.  All Rights Reserved.
@@ -26,11 +26,12 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.20 2010/10/19 19:19:41 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.21 2010/11/15 20:23:11 pooka Exp $);
 
 #include sys/param.h
 #include sys/condvar.h
 #include sys/fcntl.h
+#include sys/kernel.h
 #include sys/kmem.h
 #include sys/kthread.h
 #include sys/mutex.h
@@ -68,11 +69,13 @@
 struct virtif_sc {
 	struct ethercom sc_ec;
 	int sc_tapfd;
-	kmutex_t sc_sendmtx;
-	kcondvar_t sc_sendcv;
+	bool sc_dying;
+	struct lwp *sc_l_snd, *sc_l_rcv;
+	kmutex_t sc_mtx;
+	kcondvar_t sc_cv;
 };
 
-static void virtif_worker(void *);
+static void virtif_receiver(void *);
 static void virtif_sender(void *);
 static int  virtif_clone(struct if_clone *, int);
 static int  virtif_unclone(struct ifnet *);
@@ -87,7 +90,10 @@
 	struct ifnet *ifp;
 	uint8_t enaddr[ETHER_ADDR_LEN] = { 0xb2, 0x0a, 0x00, 0x0b, 0x0e, 0x01 };
 	char tapdev[16];
-	int fd, error;
+	int fd, error = 0;
+
+	if (num = 0x100)
+		return E2BIG;
 
 	snprintf(tapdev, sizeof(tapdev), /dev/tap%d, num);
 	fd = rumpuser_open(tapdev, O_RDWR, error);
@@ -96,29 +102,48 @@
 		num, error);
 		return error;
 	}
-	KASSERT(num  0x100);
 	enaddr[2] = arc4random()  0xff;
 	enaddr[5] = num;
 
 	sc = kmem_zalloc(sizeof(*sc), KM_SLEEP);
+	sc-sc_dying = false;
 	sc-sc_tapfd = fd;
 
+	mutex_init(sc-sc_mtx, MUTEX_DEFAULT, IPL_NONE);
+	cv_init(sc-sc_cv, virtsnd);
 	ifp = sc-sc_ec.ec_if;
 	sprintf(ifp-if_xname, %s%d, VIRTIF_BASE, num);
 	ifp-if_softc = sc;
+
+	if (rump_threads) {
+		if ((error = kthread_create(PRI_NONE, KTHREAD_JOINABLE, NULL,
+		virtif_receiver, ifp, sc-sc_l_rcv, virtifr)) != 0)
+			goto out;
+
+		if ((error = kthread_create(PRI_NONE,
+		KTHREAD_JOINABLE | KTHREAD_MPSAFE, NULL,
+		virtif_sender, ifp, sc-sc_l_snd, virtifs)) != 0)
+			goto out;
+	} else {
+		printf(WARNING: threads not enabled, receive NOT working\n);
+	}
+
 	ifp-if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
 	ifp-if_init = virtif_init;
 	ifp-if_ioctl = virtif_ioctl;
 	ifp-if_start = virtif_start;
 	ifp-if_stop = virtif_stop;
-
-	mutex_init(sc-sc_sendmtx, MUTEX_DEFAULT, IPL_NONE);
-	cv_init(sc-sc_sendcv, virtsnd);
+	IFQ_SET_READY(ifp-if_snd);
 
 	if_attach(ifp);
 	ether_ifattach(ifp, enaddr);
 
-	return 0;
+ out:
+	if (error) {
+		virtif_unclone(ifp);
+	}
+
+	return error;
 }
 
 static int
@@ -131,31 +156,51 @@
 static int
 virtif_unclone(struct ifnet *ifp)
 {
+	struct virtif_sc *sc = ifp-if_softc;
 
-	return EOPNOTSUPP;
+	mutex_enter(sc-sc_mtx);
+	if (sc-sc_dying) {
+		mutex_exit(sc-sc_mtx);
+		return EINPROGRESS;
+	}
+	sc-sc_dying = true;
+	cv_broadcast(sc-sc_cv);
+	mutex_exit(sc-sc_mtx);
+
+	virtif_stop(ifp, 1);
+	if_down(ifp);
+
+	if (sc-sc_l_snd) {
+		kthread_join(sc-sc_l_snd);
+		sc-sc_l_snd = NULL;
+	}
+	if (sc-sc_l_rcv) {
+		kthread_join(sc-sc_l_rcv);
+		sc-sc_l_rcv = NULL;
+	}
+
+	rumpuser_close(sc-sc_tapfd, NULL);
+
+	mutex_destroy(sc-sc_mtx);
+	cv_destroy(sc-sc_cv);
+	kmem_free(sc, sizeof(*sc));
+
+	ether_ifdetach(ifp);
+	if_detach(ifp);
+
+	return 0;
 }
 
 static int
 virtif_init(struct ifnet *ifp)
 {
-	int rv;
+	struct virtif_sc *sc = ifp-if_softc;
 
-	if (rump_threads) {
-		rv = kthread_create(PRI_NONE, 0, NULL, virtif_worker, ifp,
-		NULL, virtifi);
-		/* XXX: should do proper cleanup */
-		if (rv) {
-			panic(if_virt: can't create worker);
-		}
-		rv = kthread_create(PRI_NONE, 0, NULL, virtif_sender, ifp,
-		NULL, virtifs);
-		if (rv) {
-			panic(if_virt: can't create sender);
-		}
-	} else {
-		printf(WARNING: threads not enabled, receive NOT working\n);
-	}
 	ifp-if_flags |= IFF_RUNNING;
+
+	mutex_enter(sc-sc_mtx);
+	cv_broadcast(sc-sc_cv);
+	mutex_exit(sc-sc_mtx);
 	
 	return 0;
 }
@@ -180,66 +225,86 @@
 {
 	struct virtif_sc *sc = ifp-if_softc;
 
-	mutex_enter(sc-sc_sendmtx);
-	cv_signal(sc-sc_sendcv);
-	mutex_exit(sc-sc_sendmtx);
+	mutex_enter(sc-sc_mtx);
+	ifp-if_flags |= IFF_OACTIVE;
+	cv_broadcast(sc-sc_cv);
+	mutex_exit(sc-sc_mtx);
 }
 
 static void
 

CVS commit: src/sys/rump/net/lib/libvirtif

2010-11-15 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Nov 15 20:23:12 UTC 2010

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
Make interface support ifconfig {down,destroy} and generally make
it a little less eager to panic.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 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.



CVS commit: src/sys/rump/net/lib/libvirtif

2010-10-19 Thread Antti Kantee
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, virtn interfaces with the
host's /dev/tapn (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.



CVS commit: src/sys/rump/net/lib/libvirtif

2010-08-10 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Aug 10 18:06:10 UTC 2010

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
* improve diagnostic print
* deal with a tap quirk when it returns 0 bytes


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 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/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.18 src/sys/rump/net/lib/libvirtif/if_virt.c:1.19
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.18	Mon Apr  5 16:35:30 2010
+++ src/sys/rump/net/lib/libvirtif/if_virt.c	Tue Aug 10 18:06:10 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_virt.c,v 1.18 2010/04/05 16:35:30 joerg Exp $	*/
+/*	$NetBSD: if_virt.c,v 1.19 2010/08/10 18:06:10 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.18 2010/04/05 16:35:30 joerg Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.19 2010/08/10 18:06:10 pooka Exp $);
 
 #include sys/param.h
 #include sys/condvar.h
@@ -110,7 +110,8 @@
 	snprintf(tapdev, sizeof(tapdev), /dev/tap%d, num);
 	fd = rumpuser_open(tapdev, O_RDWR, error);
 	if (fd == -1) {
-		printf(virtif_create: can't open /dev/tap %d\n, error);
+		printf(virtif_create: can't open /dev/tap%d: %d\n,
+		num, error);
 		return error;
 	}
 	KASSERT(num  0x100);
@@ -212,7 +213,7 @@
  again:
 		n = rumpuser_read(sc-sc_tapfd, mtod(m, void *), plen, error);
 		KASSERT(n  ETHER_MAX_LEN_JUMBO);
-		if (n = 0) {
+		if (__predict_false(n  0)) {
 			/*
 			 * work around tap bug: /dev/tap is opened in
 			 * non-blocking mode if it previously was
@@ -227,9 +228,15 @@
 rumpuser_poll(pfd, 1, INFTIM, error);
 goto again;
 			}
+
 			m_freem(m);
 			break;
 		}
+
+		/* tap sometimes returns EOF.  don't sweat it and plow on */
+		if (__predict_false(n == 0))
+			goto again;
+
 		m-m_len = m-m_pkthdr.len = n;
 		m-m_pkthdr.rcvif = ifp;
 		bpf_mtap(ifp, m);



CVS commit: src/sys/rump/net/lib/libvirtif

2010-04-05 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Mon Apr  5 16:35:30 UTC 2010

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
Fix typo


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 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/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.17 src/sys/rump/net/lib/libvirtif/if_virt.c:1.18
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.17	Mon Apr  5 07:22:50 2010
+++ src/sys/rump/net/lib/libvirtif/if_virt.c	Mon Apr  5 16:35:30 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_virt.c,v 1.17 2010/04/05 07:22:50 joerg Exp $	*/
+/*	$NetBSD: if_virt.c,v 1.18 2010/04/05 16:35:30 joerg 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.17 2010/04/05 07:22:50 joerg Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.18 2010/04/05 16:35:30 joerg Exp $);
 
 #include sys/param.h
 #include sys/condvar.h
@@ -232,7 +232,7 @@
 		}
 		m-m_len = m-m_pkthdr.len = n;
 		m-m_pkthdr.rcvif = ifp;
-		bpf_mtap(ifp, m0);
+		bpf_mtap(ifp, m);
 		ether_input(ifp, m);
 	}
 



CVS commit: src/sys/rump/net/lib/libvirtif

2009-10-11 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Oct 12 02:25:44 UTC 2009

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
Bump iovec lazy bum magic value to 32: nfsd likes to write mbufs
with 17 per chain (previous i'm-too-lazy-for-my-forloop value was
of course 16).


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 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/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.11 src/sys/rump/net/lib/libvirtif/if_virt.c:1.12
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.11	Wed Sep 16 13:29:42 2009
+++ src/sys/rump/net/lib/libvirtif/if_virt.c	Mon Oct 12 02:25:44 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_virt.c,v 1.11 2009/09/16 13:29:42 pooka Exp $	*/
+/*	$NetBSD: if_virt.c,v 1.12 2009/10/12 02:25:44 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.11 2009/09/16 13:29:42 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.12 2009/10/12 02:25:44 pooka Exp $);
 
 #include sys/param.h
 #include sys/condvar.h
@@ -237,13 +237,15 @@
 	panic(virtif_workin is a lazy boy %d\n, error);
 }
 
+/* lazy bum stetson-harrison magic value */
+#define LB_SH 32
 static void
 virtif_sender(void *arg)
 {
 	struct ifnet *ifp = arg;
 	struct virtif_sc *sc = ifp-if_softc;
 	struct mbuf *m, *m0;
-	struct rumpuser_iovec io[16];
+	struct rumpuser_iovec io[LB_SH];
 	int i, error;
 
 	mutex_enter(sc-sc_sendmtx);
@@ -256,12 +258,12 @@
 		mutex_exit(sc-sc_sendmtx);
 
 		m = m0;
-		for (i = 0; i  16  m; i++) {
+		for (i = 0; i  LB_SH  m; i++) {
 			io[i].iov_base = mtod(m, void *);
 			io[i].iov_len = m-m_len;
 			m = m-m_next;
 		}
-		if (i == 16)
+		if (i == LB_SH)
 			panic(lazy bum);
 		rumpuser_writev(sc-sc_tapfd, io, i, error);
 		m_freem(m0);



CVS commit: src/sys/rump/net/lib/libvirtif

2009-09-16 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Sep 16 13:29:42 UTC 2009

Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
work around tap bug: if /dev/tapn was previously non-blocking, newly
opened fd's will also be non-blocking.
(yeayea, i'll fix the kernel some day, but I don't want to reboot
my host OS now)


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 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/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.10 src/sys/rump/net/lib/libvirtif/if_virt.c:1.11
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.10	Wed May 27 23:41:20 2009
+++ src/sys/rump/net/lib/libvirtif/if_virt.c	Wed Sep 16 13:29:42 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_virt.c,v 1.10 2009/05/27 23:41:20 pooka Exp $	*/
+/*	$NetBSD: if_virt.c,v 1.11 2009/09/16 13:29:42 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.10 2009/05/27 23:41:20 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_virt.c,v 1.11 2009/09/16 13:29:42 pooka Exp $);
 
 #include sys/param.h
 #include sys/condvar.h
@@ -34,6 +34,7 @@
 #include sys/kmem.h
 #include sys/kthread.h
 #include sys/mutex.h
+#include sys/poll.h
 #include sys/sockio.h
 #include sys/socketvar.h
 
@@ -207,9 +208,24 @@
 		m = m_gethdr(M_WAIT, MT_DATA);
 		MEXTMALLOC(m, plen, M_WAIT);
 
+ again:
 		n = rumpuser_read(sc-sc_tapfd, mtod(m, void *), plen, error);
 		KASSERT(n  ETHER_MAX_LEN_JUMBO);
 		if (n = 0) {
+			/*
+			 * work around tap bug: /dev/tap is opened in
+			 * non-blocking mode if it previously was
+			 * non-blocking.
+			 */
+			if (n == -1  error == EAGAIN) {
+struct pollfd pfd;
+
+pfd.fd = sc-sc_tapfd;
+pfd.events = POLLIN;
+
+rumpuser_poll(pfd, 1, INFTIM, error);
+goto again;
+			}
 			m_freem(m);
 			break;
 		}