From owner-svn-src-user@FreeBSD.ORG  Mon Jan  4 00:11:46 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 8B4A7106566C;
	Mon,  4 Jan 2010 00:11:46 +0000 (UTC)
	(envelope-from kmacy@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 7A47C8FC13;
	Mon,  4 Jan 2010 00:11:46 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o040Bkca091863;
	Mon, 4 Jan 2010 00:11:46 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o040Bkje091860;
	Mon, 4 Jan 2010 00:11:46 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001040011.o040Bkje091860@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Mon, 4 Jan 2010 00:11:46 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r201454 - user/kmacy/releng_8_rump/lib/libunet
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Mon, 04 Jan 2010 00:11:46 -0000

Author: kmacy
Date: Mon Jan  4 00:11:46 2010
New Revision: 201454
URL: http://svn.freebsd.org/changeset/base/201454

Log:
  further reduce undefined symbols by ~20 down to 92

Modified:
  user/kmacy/releng_8_rump/lib/libunet/Makefile
  user/kmacy/releng_8_rump/lib/libunet/unet_glue.c

Modified: user/kmacy/releng_8_rump/lib/libunet/Makefile
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/Makefile	Sun Jan  3 23:31:58 2010	(r201453)
+++ user/kmacy/releng_8_rump/lib/libunet/Makefile	Mon Jan  4 00:11:46 2010	(r201454)
@@ -5,6 +5,7 @@ PREFIX= ${.CURDIR}/../../sys
 .PATH: ${PREFIX}/libkern
 .PATH: ${PREFIX}/net
 .PATH: ${PREFIX}/netinet
+.PATH: ${PREFIX}/dev/random
 
 LIB=	unet
 
@@ -14,10 +15,12 @@ UNET_KERN_COMMON_OBJS +=	\
 	kern_mbuf.o		\
 	kern_subr.o		\
 	kern_sysctl.o		\
+	md5c.o			\
 	subr_eventhandler.o	\
 	subr_param.o		\
 	subr_pcpu.o		\
 	subr_sbuf.o		\
+	subr_taskqueue.o	\
 	uipc_accf.o		\
 	uipc_mbuf.o		\
 	uipc_mbuf2.o		\
@@ -51,6 +54,7 @@ UNET_NETINET_COMMON_OBJS +=	\
 	in_proto.o		\
 	in_rmx.o		\
 	ip_encap.o		\
+	ip_fastfwd.o		\
 	ip_icmp.o		\
 	ip_id.o			\
 	ip_input.o		\
@@ -86,6 +90,9 @@ UNET_LIBKERN_COMMON_OBJS =	\
 	strncmp.o		\
 	strtoul.o
 
+UNET_RANDOM_COMMON_OBJS =	\
+	harvest.o
+
 UNET_GLUE_COMMON_OBJS =		\
 	unet_compat.o		\
 	unet_glue.o
@@ -98,6 +105,7 @@ UNET_COMMON_OBJS =			\
 	${UNET_LIBKERN_COMMON_OBJS}	\
 	${UNET_NET_COMMON_OBJS}		\
 	${UNET_NETINET_COMMON_OBJS}	\
+	${UNET_RANDOM_COMMON_OBJS}	\
 	${UNET_GLUE_COMMON_OBJS}
 
 UNET_COMMON_SRCS= ${UNET_COMMON_OBJS:C/.o$/.c/}

Modified: user/kmacy/releng_8_rump/lib/libunet/unet_glue.c
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/unet_glue.c	Sun Jan  3 23:31:58 2010	(r201453)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_glue.c	Mon Jan  4 00:11:46 2010	(r201454)
@@ -3,8 +3,10 @@
 #include <sys/param.h>
 #include <sys/types.h>
 #include <sys/kernel.h>
+#include <sys/limits.h>
 #include <sys/malloc.h>
 #include <sys/refcount.h>
+#include <sys/resourcevar.h>
 #include <sys/sysctl.h>
 #include <sys/systm.h>
 #include <sys/jail.h>
@@ -36,6 +38,7 @@ volatile int smp_started;
 u_int mp_maxid;
 
 int cold;
+struct mtx Giant;
 
 static void	timevalfix(struct timeval *);
 
@@ -253,6 +256,41 @@ ratecheck(struct timeval *lasttime, cons
 	return (rv);
 }
 
+/*
+ * ppsratecheck(): packets (or events) per second limitation.
+ *
+ * Return 0 if the limit is to be enforced (e.g. the caller
+ * should drop a packet because of the rate limitation).
+ *
+ * maxpps of 0 always causes zero to be returned.  maxpps of -1
+ * always causes 1 to be returned; this effectively defeats rate
+ * limiting.
+ *
+ * Note that we maintain the struct timeval for compatibility
+ * with other bsd systems.  We reuse the storage and just monitor
+ * clock ticks for minimal overhead.  
+ */
+int
+ppsratecheck(struct timeval *lasttime, int *curpps, int maxpps)
+{
+	int now;
+
+	/*
+	 * Reset the last time and counter if this is the first call
+	 * or more than a second has passed since the last update of
+	 * lasttime.
+	 */
+	now = ticks;
+	if (lasttime->tv_sec == 0 || (u_int)(now - lasttime->tv_sec) >= hz) {
+		lasttime->tv_sec = now;
+		*curpps = 1;
+		return (maxpps != 0);
+	} else {
+		(*curpps)++;		/* NB: ignore potential overflow */
+		return (maxpps < 0 || *curpps < maxpps);
+	}
+}
+
 void
 bintime(struct bintime *bt)
 {
@@ -274,4 +312,152 @@ getmicrotime(struct timeval *tvp)
 	panic("");
 }
 
+/*
+ * Compute number of ticks in the specified amount of time.
+ */
+int
+tvtohz(tv)
+	struct timeval *tv;
+{
+	register unsigned long ticks;
+	register long sec, usec;
+
+	/*
+	 * If the number of usecs in the whole seconds part of the time
+	 * difference fits in a long, then the total number of usecs will
+	 * fit in an unsigned long.  Compute the total and convert it to
+	 * ticks, rounding up and adding 1 to allow for the current tick
+	 * to expire.  Rounding also depends on unsigned long arithmetic
+	 * to avoid overflow.
+	 *
+	 * Otherwise, if the number of ticks in the whole seconds part of
+	 * the time difference fits in a long, then convert the parts to
+	 * ticks separately and add, using similar rounding methods and
+	 * overflow avoidance.  This method would work in the previous
+	 * case but it is slightly slower and assumes that hz is integral.
+	 *
+	 * Otherwise, round the time difference down to the maximum
+	 * representable value.
+	 *
+	 * If ints have 32 bits, then the maximum value for any timeout in
+	 * 10ms ticks is 248 days.
+	 */
+	sec = tv->tv_sec;
+	usec = tv->tv_usec;
+	if (usec < 0) {
+		sec--;
+		usec += 1000000;
+	}
+	if (sec < 0) {
+#ifdef DIAGNOSTIC
+		if (usec > 0) {
+			sec++;
+			usec -= 1000000;
+		}
+		printf("tvotohz: negative time difference %ld sec %ld usec\n",
+		       sec, usec);
+#endif
+		ticks = 1;
+	} else if (sec <= LONG_MAX / 1000000)
+		ticks = (sec * 1000000 + (unsigned long)usec + (tick - 1))
+			/ tick + 1;
+	else if (sec <= LONG_MAX / hz)
+		ticks = sec * hz
+			+ ((unsigned long)usec + (tick - 1)) / tick + 1;
+	else
+		ticks = LONG_MAX;
+	if (ticks > INT_MAX)
+		ticks = INT_MAX;
+	return ((int)ticks);
+}
+
+int
+copyin(const void *uaddr, void *kaddr, size_t len)
+{
+
+	memcpy(kaddr, uaddr, len);
+
+	return (0);
+}
+
+int
+copyout(const void *kaddr, void *uaddr, size_t len)
+{
+	
+	memcpy(uaddr, kaddr, len);
+
+	return (0);
+}
+
+
+int
+copystr(const void *kfaddr, void *kdaddr, size_t len, size_t *done)
+{
+	size_t bytes;
+	
+	bytes = strlcpy(kdaddr, kfaddr, len);
+	if (done != NULL)
+		*done = bytes;
+
+	return (0);
+}
+
+
+
+int
+copyinstr(const void *uaddr, void *kaddr, size_t len, size_t *done)
+{	
+	size_t bytes;
+	
+	bytes = strlcpy(kaddr, uaddr, len);
+	if (done != NULL)
+		*done = bytes;
+
+	return (0);
+}
+
+
+int
+subyte(void *base, int byte)
+{
+
+	*(char *)base = (uint8_t)byte;
+	return (0);
+}
+
+
+
+/*
+ * Change the total socket buffer size a user has used.
+ */
+int
+chgsbsize(uip, hiwat, to, max)
+	struct	uidinfo	*uip;
+	u_int  *hiwat;
+	u_int	to;
+	rlim_t	max;
+{
+	int diff;
+
+	diff = to - *hiwat;
+	if (diff > 0) {
+		if (atomic_fetchadd_long(&uip->ui_sbsize, (long)diff) + diff > max) {
+			atomic_subtract_long(&uip->ui_sbsize, (long)diff);
+			return (0);
+		}
+	} else {
+		atomic_add_long(&uip->ui_sbsize, (long)diff);
+		if (uip->ui_sbsize < 0)
+			printf("negative sbsize for uid = %d\n", uip->ui_uid);
+	}
+	*hiwat = to;
+	return (1);
+}
+
+int
+useracc(void *addr, int len, int rw)
+{
+	return (1);
+}
 
+