From owner-svn-src-user@FreeBSD.ORG  Sun Jan  3 06:48:54 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 1B0C4106566B;
	Sun,  3 Jan 2010 06:48:54 +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 E55718FC12;
	Sun,  3 Jan 2010 06:48:53 +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 o036mrB2093928;
	Sun, 3 Jan 2010 06:48:53 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o036mr1n093927;
	Sun, 3 Jan 2010 06:48:53 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001030648.o036mr1n093927@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Sun, 3 Jan 2010 06:48:53 +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: r201417 - user/kmacy/releng_8_rump/sys/rump
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: Sun, 03 Jan 2010 06:48:54 -0000

Author: kmacy
Date: Sun Jan  3 06:48:53 2010
New Revision: 201417
URL: http://svn.freebsd.org/changeset/base/201417

Log:
  trying to re-use rump has proven to be more trouble than it is worth

Deleted:
  user/kmacy/releng_8_rump/sys/rump/

From owner-svn-src-user@FreeBSD.ORG  Sun Jan  3 06:50:49 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 AD29C106566C;
	Sun,  3 Jan 2010 06:50:49 +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 9BA298FC14;
	Sun,  3 Jan 2010 06:50:49 +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 o036onsC094548;
	Sun, 3 Jan 2010 06:50:49 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o036onDG094522;
	Sun, 3 Jan 2010 06:50:49 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001030650.o036onDG094522@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Sun, 3 Jan 2010 06:50:49 +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: r201418 - 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: Sun, 03 Jan 2010 06:50:49 -0000

Author: kmacy
Date: Sun Jan  3 06:50:49 2010
New Revision: 201418
URL: http://svn.freebsd.org/changeset/base/201418

Log:
  - create library for user level networking
  - create empty opt headers for now

Added:
  user/kmacy/releng_8_rump/lib/libunet/
  user/kmacy/releng_8_rump/lib/libunet/Makefile   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/bus_if.h   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/device_if.h   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/opt_atalk.h   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/opt_bootp.h   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/opt_carp.h   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/opt_compat.h   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/opt_ddb.h   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/opt_device_polling.h   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/opt_inet.h   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/opt_inet6.h   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/opt_ipfw.h   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/opt_ipsec.h   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/opt_ipstealth.h   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/opt_ipx.h   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/opt_mbuf_profiling.h   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/opt_mbuf_stress_test.h   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/opt_mpath.h   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/opt_mrouting.h   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/opt_param.h   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/opt_pf.h   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/opt_route.h   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/opt_sctp.h   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/opt_tcpdebug.h   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/opt_zero.h   (contents, props changed)

Added: user/kmacy/releng_8_rump/lib/libunet/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/kmacy/releng_8_rump/lib/libunet/Makefile	Sun Jan  3 06:50:49 2010	(r201418)
@@ -0,0 +1,74 @@
+
+PREFIX= ${.CURDIR}/../../sys
+
+.PATH: ${PREFIX}/kern
+.PATH: ${PREFIX}/net
+.PATH: ${PREFIX}/netinet
+
+LIB=	unet
+
+UNET_KERN_COMMON_OBJS +=	\
+	kern_mbuf.o		\
+	uipc_mbuf.o		\
+	uipc_mbuf2.o		\
+	uipc_sockbuf.o		\
+	uipc_socket.o
+
+UNET_NET_COMMON_OBJS +=		\
+	if.o			\
+	if_loop.o		\
+	netisr.o		\
+	radix.o			\
+	route.o			\
+	rtsock.o		
+
+UNET_NETINET_COMMON_OBJS +=	\
+	if_ether.o		\
+	in.o			\
+	in_cksum.o		\
+	in_pcb.o		\
+	in_proto.o		\
+	in_rmx.o		\
+	ip_icmp.o		\
+	ip_id.o			\
+	ip_input.o		\
+	ip_options.o		\
+	ip_output.o		\
+	raw_ip.o		\
+	tcp_debug.o		\
+	tcp_hostcache.o		\
+	tcp_input.o		\
+	tcp_lro.o		\
+	tcp_offload.o		\
+	tcp_output.o		\
+	tcp_reass.o		\
+	tcp_sack.o		\
+	tcp_subr.o		\
+	tcp_syncache.o		\
+	tcp_timer.o		\
+	tcp_timewait.o		\
+	tcp_usrreq.o		\
+	udp_usrreq.o
+
+UNET_GLUE_COMMON_OBJS =		\
+	unet_init.o		\
+	unet_uipc_syscalls.o
+
+
+UNET_COMMON_OBJS =			\
+	${UNET_KERN_COMMON_OBJS}	\
+	${UNET_NET_COMMON_OBJS}		\
+	${UNET_NETINET_COMMON_OBJS}	
+
+UNET_COMMON_SRCS= ${UNET_COMMON_OBJS:C/.o$/.c/}
+
+SRCS=	${UNET_COMMON_SRCS}
+
+CFLAGS+=	-I${PREFIX}
+CFLAGS+=	-I.
+CFLAGS+=	-D_KERNEL
+CFLAGS+=	-fno-builtin
+
+.include <bsd.lib.mk>
+
+

Added: user/kmacy/releng_8_rump/lib/libunet/bus_if.h
==============================================================================

Added: user/kmacy/releng_8_rump/lib/libunet/device_if.h
==============================================================================

Added: user/kmacy/releng_8_rump/lib/libunet/opt_atalk.h
==============================================================================

Added: user/kmacy/releng_8_rump/lib/libunet/opt_bootp.h
==============================================================================

Added: user/kmacy/releng_8_rump/lib/libunet/opt_carp.h
==============================================================================

Added: user/kmacy/releng_8_rump/lib/libunet/opt_compat.h
==============================================================================

Added: user/kmacy/releng_8_rump/lib/libunet/opt_ddb.h
==============================================================================

Added: user/kmacy/releng_8_rump/lib/libunet/opt_device_polling.h
==============================================================================

Added: user/kmacy/releng_8_rump/lib/libunet/opt_inet.h
==============================================================================

Added: user/kmacy/releng_8_rump/lib/libunet/opt_inet6.h
==============================================================================

Added: user/kmacy/releng_8_rump/lib/libunet/opt_ipfw.h
==============================================================================

Added: user/kmacy/releng_8_rump/lib/libunet/opt_ipsec.h
==============================================================================

Added: user/kmacy/releng_8_rump/lib/libunet/opt_ipstealth.h
==============================================================================

Added: user/kmacy/releng_8_rump/lib/libunet/opt_ipx.h
==============================================================================

Added: user/kmacy/releng_8_rump/lib/libunet/opt_mbuf_profiling.h
==============================================================================

Added: user/kmacy/releng_8_rump/lib/libunet/opt_mbuf_stress_test.h
==============================================================================

Added: user/kmacy/releng_8_rump/lib/libunet/opt_mpath.h
==============================================================================

Added: user/kmacy/releng_8_rump/lib/libunet/opt_mrouting.h
==============================================================================

Added: user/kmacy/releng_8_rump/lib/libunet/opt_param.h
==============================================================================

Added: user/kmacy/releng_8_rump/lib/libunet/opt_pf.h
==============================================================================

Added: user/kmacy/releng_8_rump/lib/libunet/opt_route.h
==============================================================================

Added: user/kmacy/releng_8_rump/lib/libunet/opt_sctp.h
==============================================================================

Added: user/kmacy/releng_8_rump/lib/libunet/opt_tcpdebug.h
==============================================================================

Added: user/kmacy/releng_8_rump/lib/libunet/opt_zero.h
==============================================================================

From owner-svn-src-user@FreeBSD.ORG  Sun Jan  3 09:52:36 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 B4AC3106566C;
	Sun,  3 Jan 2010 09:52:36 +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 8A4458FC08;
	Sun,  3 Jan 2010 09:52:36 +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 o039qake047354;
	Sun, 3 Jan 2010 09:52:36 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o039qamg047351;
	Sun, 3 Jan 2010 09:52:36 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001030952.o039qamg047351@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Sun, 3 Jan 2010 09:52:36 +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: r201423 - 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: Sun, 03 Jan 2010 09:52:36 -0000

Author: kmacy
Date: Sun Jan  3 09:52:36 2010
New Revision: 201423
URL: http://svn.freebsd.org/changeset/base/201423

Log:
  - enable ipv4
  - further reduce undefined symbols by ~35%

Modified:
  user/kmacy/releng_8_rump/lib/libunet/Makefile
  user/kmacy/releng_8_rump/lib/libunet/opt_inet.h

Modified: user/kmacy/releng_8_rump/lib/libunet/Makefile
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/Makefile	Sun Jan  3 09:31:33 2010	(r201422)
+++ user/kmacy/releng_8_rump/lib/libunet/Makefile	Sun Jan  3 09:52:36 2010	(r201423)
@@ -2,6 +2,7 @@
 PREFIX= ${.CURDIR}/../../sys
 
 .PATH: ${PREFIX}/kern
+.PATH: ${PREFIX}/libkern
 .PATH: ${PREFIX}/net
 .PATH: ${PREFIX}/netinet
 
@@ -9,26 +10,39 @@ LIB=	unet
 
 UNET_KERN_COMMON_OBJS +=	\
 	kern_mbuf.o		\
+	kern_subr.o		\
+	subr_eventhandler.o	\
+	subr_sbuf.o		\
 	uipc_mbuf.o		\
 	uipc_mbuf2.o		\
+	uipc_domain.o		\
 	uipc_sockbuf.o		\
 	uipc_socket.o
 
 UNET_NET_COMMON_OBJS +=		\
 	if.o			\
+	if_clone.o		\
+	if_dead.o		\
+	if_ether.o		\
 	if_loop.o		\
+	if_llatbl.o		\
 	netisr.o		\
+	pfil.o			\
 	radix.o			\
+	raw_cb.o		\
+	raw_usrreq.o		\
 	route.o			\
 	rtsock.o		
 
 UNET_NETINET_COMMON_OBJS +=	\
-	if_ether.o		\
+	igmp.o			\
 	in.o			\
 	in_cksum.o		\
+	in_mcast.o		\
 	in_pcb.o		\
 	in_proto.o		\
 	in_rmx.o		\
+	ip_encap.o		\
 	ip_icmp.o		\
 	ip_id.o			\
 	ip_input.o		\
@@ -50,6 +64,19 @@ UNET_NETINET_COMMON_OBJS +=	\
 	tcp_usrreq.o		\
 	udp_usrreq.o
 
+UNET_LIBKERN_COMMON_OBJS =	\
+	bcmp.o			\
+	inet_aton.o		\
+	inet_ntoa.o		\
+	memcmp.o		\
+	strcat.o		\
+	strcmp.o		\
+	strcpy.o		\
+	strlcpy.o		\
+	strlen.o		\
+	strncmp.o		\
+	strtoul.o
+
 UNET_GLUE_COMMON_OBJS =		\
 	unet_init.o		\
 	unet_uipc_syscalls.o
@@ -57,6 +84,7 @@ UNET_GLUE_COMMON_OBJS =		\
 
 UNET_COMMON_OBJS =			\
 	${UNET_KERN_COMMON_OBJS}	\
+	${UNET_LIBKERN_COMMON_OBJS}	\
 	${UNET_NET_COMMON_OBJS}		\
 	${UNET_NETINET_COMMON_OBJS}	
 
@@ -67,6 +95,7 @@ SRCS=	${UNET_COMMON_SRCS}
 CFLAGS+=	-I${PREFIX}
 CFLAGS+=	-I.
 CFLAGS+=	-D_KERNEL
+CFLAGS+=	-DUNET
 CFLAGS+=	-fno-builtin
 
 .include <bsd.lib.mk>

Modified: user/kmacy/releng_8_rump/lib/libunet/opt_inet.h
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/opt_inet.h	Sun Jan  3 09:31:33 2010	(r201422)
+++ user/kmacy/releng_8_rump/lib/libunet/opt_inet.h	Sun Jan  3 09:52:36 2010	(r201423)
@@ -0,0 +1 @@
+#define INET 1

From owner-svn-src-user@FreeBSD.ORG  Sun Jan  3 10:52:25 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 5A32A106568F;
	Sun,  3 Jan 2010 10:52:25 +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 48B778FC0A;
	Sun,  3 Jan 2010 10:52:25 +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 o03AqPc8068230;
	Sun, 3 Jan 2010 10:52:25 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o03AqPuN068223;
	Sun, 3 Jan 2010 10:52:25 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001031052.o03AqPuN068223@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Sun, 3 Jan 2010 10:52:25 +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: r201424 - 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: Sun, 03 Jan 2010 10:52:25 -0000

Author: kmacy
Date: Sun Jan  3 10:52:24 2010
New Revision: 201424
URL: http://svn.freebsd.org/changeset/base/201424

Log:
  further grinding away of missing symbols

Added:
  user/kmacy/releng_8_rump/lib/libunet/opt_bpf.h   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/opt_netgraph.h   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/unet_compat.c   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/unet_glue.c   (contents, props changed)
Modified:
  user/kmacy/releng_8_rump/lib/libunet/Makefile

Modified: user/kmacy/releng_8_rump/lib/libunet/Makefile
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/Makefile	Sun Jan  3 09:52:36 2010	(r201423)
+++ user/kmacy/releng_8_rump/lib/libunet/Makefile	Sun Jan  3 10:52:24 2010	(r201424)
@@ -13,6 +13,7 @@ UNET_KERN_COMMON_OBJS +=	\
 	kern_subr.o		\
 	subr_eventhandler.o	\
 	subr_sbuf.o		\
+	uipc_accf.o		\
 	uipc_mbuf.o		\
 	uipc_mbuf2.o		\
 	uipc_domain.o		\
@@ -20,6 +21,7 @@ UNET_KERN_COMMON_OBJS +=	\
 	uipc_socket.o
 
 UNET_NET_COMMON_OBJS +=		\
+	bpf.o			\
 	if.o			\
 	if_clone.o		\
 	if_dead.o		\
@@ -65,6 +67,7 @@ UNET_NETINET_COMMON_OBJS +=	\
 	udp_usrreq.o
 
 UNET_LIBKERN_COMMON_OBJS =	\
+	arc4random.o		\
 	bcmp.o			\
 	inet_aton.o		\
 	inet_ntoa.o		\
@@ -78,15 +81,18 @@ UNET_LIBKERN_COMMON_OBJS =	\
 	strtoul.o
 
 UNET_GLUE_COMMON_OBJS =		\
-	unet_init.o		\
-	unet_uipc_syscalls.o
+	unet_compat.o		\
+	unet_glue.o
+#	unet_init.o		\
+#	unet_uipc_syscalls.o
 
 
 UNET_COMMON_OBJS =			\
 	${UNET_KERN_COMMON_OBJS}	\
 	${UNET_LIBKERN_COMMON_OBJS}	\
 	${UNET_NET_COMMON_OBJS}		\
-	${UNET_NETINET_COMMON_OBJS}	
+	${UNET_NETINET_COMMON_OBJS}	\
+	${UNET_GLUE_COMMON_OBJS}
 
 UNET_COMMON_SRCS= ${UNET_COMMON_OBJS:C/.o$/.c/}
 

Added: user/kmacy/releng_8_rump/lib/libunet/opt_bpf.h
==============================================================================

Added: user/kmacy/releng_8_rump/lib/libunet/opt_netgraph.h
==============================================================================

Added: user/kmacy/releng_8_rump/lib/libunet/unet_compat.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_compat.c	Sun Jan  3 10:52:24 2010	(r201424)
@@ -0,0 +1,44 @@
+#undef _KERNEL
+#define _WANT_UCRED
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/refcount.h>
+#include <sys/ucred.h>
+
+struct malloc_type;
+
+void *
+unet_malloc(unsigned long size, struct malloc_type *type, int flags)
+{
+
+	return (malloc(size));
+}
+
+void
+unet_free(void *addr, struct malloc_type *type)
+{
+
+	free(addr);
+}
+
+/*
+ * Claim another reference to a ucred structure.
+ */
+struct ucred *
+crhold(struct ucred *cr)
+{
+
+	refcount_acquire(&cr->cr_ref);
+	return (cr);
+}
+
+/*
+ * Free a cred structure.  Throws away space when ref count gets to 0.
+ */
+void
+crfree(struct ucred *cr)
+{
+	if (refcount_release(&cr->cr_ref)) {
+		free(cr);
+	}
+}       

Added: user/kmacy/releng_8_rump/lib/libunet/unet_glue.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_glue.c	Sun Jan  3 10:52:24 2010	(r201424)
@@ -0,0 +1,86 @@
+#include <sys/cdefs.h>
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/kernel.h>
+#include <sys/refcount.h>
+#include <sys/systm.h>
+#include <sys/jail.h>
+#include <sys/priv.h>
+
+int
+prison_if(struct ucred *cred, struct sockaddr *sa)
+{
+
+	return (0);
+}
+
+int
+prison_check_af(struct ucred *cred, int af)
+{
+
+	return (0);
+}
+
+int
+prison_check_ip4(struct ucred *cred, struct in_addr *ia)
+{
+
+	return (0);
+}
+
+
+int
+prison_equal_ip4(struct prison *pr1, struct prison *pr2)
+{
+
+	return (1);
+}
+
+/*
+ * See if a prison has the specific flag set.
+ */
+int
+prison_flag(struct ucred *cred, unsigned flag)
+{
+
+	/* This is an atomic read, so no locking is necessary. */
+	return (flag & PR_HOST);
+}
+
+int
+prison_get_ip4(struct ucred *cred, struct in_addr *ia)
+{
+
+	return (0);
+}
+
+int
+prison_local_ip4(struct ucred *cred, struct in_addr *ia)
+{
+
+	return (0);
+}
+
+int
+prison_remote_ip4(struct ucred *cred, struct in_addr *ia)
+{
+
+	return (0);
+}
+
+int
+priv_check(struct thread *td, int priv)
+{
+
+	return (0);
+}
+
+int
+priv_check_cred(struct ucred *cred, int priv, int flags)
+{
+
+	return (0);
+}
+
+

From owner-svn-src-user@FreeBSD.ORG  Sun Jan  3 11:04:49 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 9441F1065670;
	Sun,  3 Jan 2010 11:04:49 +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 837E38FC0C;
	Sun,  3 Jan 2010 11:04:49 +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 o03B4nDI071872;
	Sun, 3 Jan 2010 11:04:49 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o03B4nv4071868;
	Sun, 3 Jan 2010 11:04:49 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001031104.o03B4nv4071868@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Sun, 3 Jan 2010 11:04:49 +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: r201425 - 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: Sun, 03 Jan 2010 11:04:49 -0000

Author: kmacy
Date: Sun Jan  3 11:04:49 2010
New Revision: 201425
URL: http://svn.freebsd.org/changeset/base/201425

Log:
  - add sysctl
  - add vslock glue for sysctl

Added:
  user/kmacy/releng_8_rump/lib/libunet/opt_ktrace.h   (contents, props changed)
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 10:52:24 2010	(r201424)
+++ user/kmacy/releng_8_rump/lib/libunet/Makefile	Sun Jan  3 11:04:49 2010	(r201425)
@@ -11,6 +11,7 @@ LIB=	unet
 UNET_KERN_COMMON_OBJS +=	\
 	kern_mbuf.o		\
 	kern_subr.o		\
+	kern_sysctl.o		\
 	subr_eventhandler.o	\
 	subr_sbuf.o		\
 	uipc_accf.o		\

Added: user/kmacy/releng_8_rump/lib/libunet/opt_ktrace.h
==============================================================================

Modified: user/kmacy/releng_8_rump/lib/libunet/unet_glue.c
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/unet_glue.c	Sun Jan  3 10:52:24 2010	(r201424)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_glue.c	Sun Jan  3 11:04:49 2010	(r201425)
@@ -84,3 +84,16 @@ priv_check_cred(struct ucred *cred, int 
 }
 
 
+int
+vslock(void *addr, size_t len)
+{
+
+	return (0);
+}
+
+int
+vsunlock(void *addr, size_t len)
+{
+
+	return (0);
+}

From owner-svn-src-user@FreeBSD.ORG  Sun Jan  3 23:13:35 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 C06CD106568F;
	Sun,  3 Jan 2010 23:13:35 +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 AFCB88FC1D;
	Sun,  3 Jan 2010 23:13:35 +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 o03NDZGU078870;
	Sun, 3 Jan 2010 23:13:35 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o03NDZGW078865;
	Sun, 3 Jan 2010 23:13:35 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001032313.o03NDZGW078865@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Sun, 3 Jan 2010 23:13:35 +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: r201448 - 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: Sun, 03 Jan 2010 23:13:35 -0000

Author: kmacy
Date: Sun Jan  3 23:13:35 2010
New Revision: 201448
URL: http://svn.freebsd.org/changeset/base/201448

Log:
  further reduce undefined symbols

Added:
  user/kmacy/releng_8_rump/lib/libunet/opt_maxusers.h   (contents, props changed)
Modified:
  user/kmacy/releng_8_rump/lib/libunet/Makefile
  user/kmacy/releng_8_rump/lib/libunet/unet_compat.c
  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 22:29:06 2010	(r201447)
+++ user/kmacy/releng_8_rump/lib/libunet/Makefile	Sun Jan  3 23:13:35 2010	(r201448)
@@ -9,10 +9,14 @@ PREFIX= ${.CURDIR}/../../sys
 LIB=	unet
 
 UNET_KERN_COMMON_OBJS +=	\
+	kern_environment.o	\
+	kern_event.o		\
 	kern_mbuf.o		\
 	kern_subr.o		\
 	kern_sysctl.o		\
 	subr_eventhandler.o	\
+	subr_param.o		\
+	subr_pcpu.o		\
 	subr_sbuf.o		\
 	uipc_accf.o		\
 	uipc_mbuf.o		\
@@ -26,7 +30,7 @@ UNET_NET_COMMON_OBJS +=		\
 	if.o			\
 	if_clone.o		\
 	if_dead.o		\
-	if_ether.o		\
+	if_ethersubr.o		\
 	if_loop.o		\
 	if_llatbl.o		\
 	netisr.o		\
@@ -38,6 +42,7 @@ UNET_NET_COMMON_OBJS +=		\
 	rtsock.o		
 
 UNET_NETINET_COMMON_OBJS +=	\
+	if_ether.o		\
 	igmp.o			\
 	in.o			\
 	in_cksum.o		\
@@ -86,7 +91,7 @@ UNET_GLUE_COMMON_OBJS =		\
 	unet_glue.o
 #	unet_init.o		\
 #	unet_uipc_syscalls.o
-
+#	unet_sys_generic.o
 
 UNET_COMMON_OBJS =			\
 	${UNET_KERN_COMMON_OBJS}	\
@@ -103,6 +108,7 @@ CFLAGS+=	-I${PREFIX}
 CFLAGS+=	-I.
 CFLAGS+=	-D_KERNEL
 CFLAGS+=	-DUNET
+CFLAGS+=	-DMAXUSERS=32
 CFLAGS+=	-fno-builtin
 
 .include <bsd.lib.mk>

Added: user/kmacy/releng_8_rump/lib/libunet/opt_maxusers.h
==============================================================================

Modified: user/kmacy/releng_8_rump/lib/libunet/unet_compat.c
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/unet_compat.c	Sun Jan  3 22:29:06 2010	(r201447)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_compat.c	Sun Jan  3 23:13:35 2010	(r201448)
@@ -42,3 +42,11 @@ crfree(struct ucred *cr)
 		free(cr);
 	}
 }       
+
+void
+panic(const char *fmt, ...)
+{
+
+	abort();
+}
+

Modified: user/kmacy/releng_8_rump/lib/libunet/unet_glue.c
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/unet_glue.c	Sun Jan  3 22:29:06 2010	(r201447)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_glue.c	Sun Jan  3 23:13:35 2010	(r201448)
@@ -3,10 +3,41 @@
 #include <sys/param.h>
 #include <sys/types.h>
 #include <sys/kernel.h>
+#include <sys/malloc.h>
 #include <sys/refcount.h>
+#include <sys/sysctl.h>
 #include <sys/systm.h>
 #include <sys/jail.h>
 #include <sys/priv.h>
+#include <sys/time.h>
+
+
+SYSCTL_NODE(, 0,	  sysctl, CTLFLAG_RW, 0,
+	"Sysctl internal magic");
+
+SYSCTL_NODE(, CTL_KERN,	  kern,   CTLFLAG_RW, 0,
+	"High kernel, proc, limits &c");
+
+SYSCTL_NODE(, CTL_NET,	  net,    CTLFLAG_RW, 0,
+	"Network, (see socket.h)");
+
+MALLOC_DEFINE(M_IOV, "iov", "large iov's");
+MALLOC_DEFINE(M_DEVBUF, "devbuf", "device driver memory");
+MALLOC_DEFINE(M_TEMP, "temp", "misc temporary data buffers");
+
+/* This is used in modules that need to work in both SMP and UP. */
+cpumask_t all_cpus;
+
+int mp_ncpus;
+/* export this for libkvm consumers. */
+int mp_maxcpus = MAXCPU;
+
+volatile int smp_started;
+u_int mp_maxid;
+
+int cold;
+
+static void	timevalfix(struct timeval *);
 
 int
 prison_if(struct ucred *cred, struct sockaddr *sa)
@@ -97,3 +128,150 @@ vsunlock(void *addr, size_t len)
 
 	return (0);
 }
+
+
+/*
+ * Check that a proposed value to load into the .it_value or
+ * .it_interval part of an interval timer is acceptable, and
+ * fix it to have at least minimal value (i.e. if it is less
+ * than the resolution of the clock, round it up.)
+ */
+int
+itimerfix(struct timeval *tv)
+{
+
+	if (tv->tv_sec < 0 || tv->tv_usec < 0 || tv->tv_usec >= 1000000)
+		return (EINVAL);
+	if (tv->tv_sec == 0 && tv->tv_usec != 0 && tv->tv_usec < tick)
+		tv->tv_usec = tick;
+	return (0);
+}
+
+/*
+ * Decrement an interval timer by a specified number
+ * of microseconds, which must be less than a second,
+ * i.e. < 1000000.  If the timer expires, then reload
+ * it.  In this case, carry over (usec - old value) to
+ * reduce the value reloaded into the timer so that
+ * the timer does not drift.  This routine assumes
+ * that it is called in a context where the timers
+ * on which it is operating cannot change in value.
+ */
+int
+itimerdecr(struct itimerval *itp, int usec)
+{
+
+	if (itp->it_value.tv_usec < usec) {
+		if (itp->it_value.tv_sec == 0) {
+			/* expired, and already in next interval */
+			usec -= itp->it_value.tv_usec;
+			goto expire;
+		}
+		itp->it_value.tv_usec += 1000000;
+		itp->it_value.tv_sec--;
+	}
+	itp->it_value.tv_usec -= usec;
+	usec = 0;
+	if (timevalisset(&itp->it_value))
+		return (1);
+	/* expired, exactly at end of interval */
+expire:
+	if (timevalisset(&itp->it_interval)) {
+		itp->it_value = itp->it_interval;
+		itp->it_value.tv_usec -= usec;
+		if (itp->it_value.tv_usec < 0) {
+			itp->it_value.tv_usec += 1000000;
+			itp->it_value.tv_sec--;
+		}
+	} else
+		itp->it_value.tv_usec = 0;		/* sec is already 0 */
+	return (0);
+}
+
+/*
+ * Add and subtract routines for timevals.
+ * N.B.: subtract routine doesn't deal with
+ * results which are before the beginning,
+ * it just gets very confused in this case.
+ * Caveat emptor.
+ */
+void
+timevaladd(struct timeval *t1, const struct timeval *t2)
+{
+
+	t1->tv_sec += t2->tv_sec;
+	t1->tv_usec += t2->tv_usec;
+	timevalfix(t1);
+}
+
+void
+timevalsub(struct timeval *t1, const struct timeval *t2)
+{
+
+	t1->tv_sec -= t2->tv_sec;
+	t1->tv_usec -= t2->tv_usec;
+	timevalfix(t1);
+}
+
+static void
+timevalfix(struct timeval *t1)
+{
+
+	if (t1->tv_usec < 0) {
+		t1->tv_sec--;
+		t1->tv_usec += 1000000;
+	}
+	if (t1->tv_usec >= 1000000) {
+		t1->tv_sec++;
+		t1->tv_usec -= 1000000;
+	}
+}
+
+/*
+ * ratecheck(): simple time-based rate-limit checking.
+ */
+int
+ratecheck(struct timeval *lasttime, const struct timeval *mininterval)
+{
+	struct timeval tv, delta;
+	int rv = 0;
+
+	getmicrouptime(&tv);		/* NB: 10ms precision */
+	delta = tv;
+	timevalsub(&delta, lasttime);
+
+	/*
+	 * check for 0,0 is so that the message will be seen at least once,
+	 * even if interval is huge.
+	 */
+	if (timevalcmp(&delta, mininterval, >=) ||
+	    (lasttime->tv_sec == 0 && lasttime->tv_usec == 0)) {
+		*lasttime = tv;
+		rv = 1;
+	}
+
+	return (rv);
+}
+
+void
+bintime(struct bintime *bt)
+{
+
+	panic("");
+}
+	
+void
+getmicrouptime(struct timeval *tvp)
+{
+
+	panic("");
+}
+
+void
+getmicrotime(struct timeval *tvp)
+{
+
+	panic("");
+}
+
+

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);
+}
 
+       

From owner-svn-src-user@FreeBSD.ORG  Mon Jan  4 04:26:03 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 3A9341065695;
	Mon,  4 Jan 2010 04:26:03 +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 285018FC0A;
	Mon,  4 Jan 2010 04:26:03 +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 o044Q39L048987;
	Mon, 4 Jan 2010 04:26:03 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o044Q2dW048977;
	Mon, 4 Jan 2010 04:26:02 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001040426.o044Q2dW048977@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Mon, 4 Jan 2010 04:26:02 +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: r201470 - 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 04:26:03 -0000

Author: kmacy
Date: Mon Jan  4 04:26:02 2010
New Revision: 201470
URL: http://svn.freebsd.org/changeset/base/201470

Log:
  import zone allocator and further whittle down missing symbols

Added:
  user/kmacy/releng_8_rump/lib/libunet/opt_kdtrace.h   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/opt_sched.h   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/opt_vm.h   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/unet_init_main.c   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/unet_kern_synch.c   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/unet_uma_core.c   (contents, props changed)
Modified:
  user/kmacy/releng_8_rump/lib/libunet/Makefile
  user/kmacy/releng_8_rump/lib/libunet/unet_compat.c
  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	Mon Jan  4 03:40:46 2010	(r201469)
+++ user/kmacy/releng_8_rump/lib/libunet/Makefile	Mon Jan  4 04:26:02 2010	(r201470)
@@ -2,9 +2,9 @@
 PREFIX= ${.CURDIR}/../../sys
 
 .PATH: ${PREFIX}/kern
-.PATH: ${PREFIX}/libkern
 .PATH: ${PREFIX}/net
 .PATH: ${PREFIX}/netinet
+.PATH: ${PREFIX}/libkern
 .PATH: ${PREFIX}/dev/random
 
 LIB=	unet
@@ -12,7 +12,9 @@ LIB=	unet
 UNET_KERN_COMMON_OBJS +=	\
 	kern_environment.o	\
 	kern_event.o		\
+	kern_malloc.o		\
 	kern_mbuf.o		\
+	kern_module.o		\
 	kern_subr.o		\
 	kern_sysctl.o		\
 	md5c.o			\
@@ -95,7 +97,11 @@ UNET_RANDOM_COMMON_OBJS =	\
 
 UNET_GLUE_COMMON_OBJS =		\
 	unet_compat.o		\
-	unet_glue.o
+	unet_glue.o		\
+	unet_init_main.c	\
+	unet_uma_core.c		\
+	unet_kern_synch.o
+
 #	unet_init.o		\
 #	unet_uipc_syscalls.o
 #	unet_sys_generic.o

Added: user/kmacy/releng_8_rump/lib/libunet/opt_kdtrace.h
==============================================================================

Added: user/kmacy/releng_8_rump/lib/libunet/opt_sched.h
==============================================================================

Added: user/kmacy/releng_8_rump/lib/libunet/opt_vm.h
==============================================================================

Modified: user/kmacy/releng_8_rump/lib/libunet/unet_compat.c
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/unet_compat.c	Mon Jan  4 03:40:46 2010	(r201469)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_compat.c	Mon Jan  4 04:26:02 2010	(r201470)
@@ -6,7 +6,7 @@
 #include <sys/ucred.h>
 
 struct malloc_type;
-
+#if 0
 void *
 unet_malloc(unsigned long size, struct malloc_type *type, int flags)
 {
@@ -20,7 +20,7 @@ unet_free(void *addr, struct malloc_type
 
 	free(addr);
 }
-
+#endif
 /*
  * Claim another reference to a ucred structure.
  */

Modified: user/kmacy/releng_8_rump/lib/libunet/unet_glue.c
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/unet_glue.c	Mon Jan  4 03:40:46 2010	(r201469)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_glue.c	Mon Jan  4 04:26:02 2010	(r201470)
@@ -3,16 +3,24 @@
 #include <sys/param.h>
 #include <sys/types.h>
 #include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/event.h>
+#include <sys/jail.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>
 #include <sys/priv.h>
 #include <sys/time.h>
+#include <sys/ucred.h>
 
+#include <vm/vm.h>
+#include <vm/vm_param.h>
+#include <vm/pmap.h>
+#include <vm/vm_object.h>
+#include <vm/vm_map.h>
 
 SYSCTL_NODE(, 0,	  sysctl, CTLFLAG_RW, 0,
 	"Sysctl internal magic");
@@ -23,9 +31,16 @@ SYSCTL_NODE(, CTL_KERN,	  kern,   CTLFLA
 SYSCTL_NODE(, CTL_NET,	  net,    CTLFLAG_RW, 0,
 	"Network, (see socket.h)");
 
+SYSCTL_NODE(, CTL_VM,	  vm,    CTLFLAG_RW, 0,
+	"Virtual memory");
+
 MALLOC_DEFINE(M_IOV, "iov", "large iov's");
-MALLOC_DEFINE(M_DEVBUF, "devbuf", "device driver memory");
-MALLOC_DEFINE(M_TEMP, "temp", "misc temporary data buffers");
+
+
+int	ticks;
+
+time_t time_second = 1;
+time_t time_uptime = 1;
 
 /* This is used in modules that need to work in both SMP and UP. */
 cpumask_t all_cpus;
@@ -37,6 +52,18 @@ int mp_maxcpus = MAXCPU;
 volatile int smp_started;
 u_int mp_maxid;
 
+long first_page = 0;
+
+struct vmmeter cnt;
+vm_map_t kernel_map=0;
+vm_map_t kmem_map=0;
+
+struct vm_object kernel_object_store;
+struct vm_object kmem_object_store;
+
+struct filterops fs_filtops;
+struct filterops sig_filtops;
+
 int cold;
 struct mtx Giant;
 
@@ -103,6 +130,18 @@ prison_remote_ip4(struct ucred *cred, st
 	return (0);
 }
 
+
+/*
+ * Return 1 if the passed credential is in a jail and that jail does not
+ * have its own virtual network stack, otherwise 0.
+ */
+int
+jailed_without_vnet(struct ucred *cred)
+{
+
+	return (0);
+}
+
 int
 priv_check(struct thread *td, int priv)
 {
@@ -454,10 +493,124 @@ chgsbsize(uip, hiwat, to, max)
 	return (1);
 }
 
+
+/*
+ * Return the current (soft) limit for a particular system resource.
+ * The which parameter which specifies the index into the rlimit array
+ */
+rlim_t
+lim_cur(struct proc *p, int which)
+{
+	struct rlimit rl;
+
+	lim_rlimit(p, which, &rl);
+	return (rl.rlim_cur);
+}
+
+/*
+ * Return a copy of the entire rlimit structure for the system limit
+ * specified by 'which' in the rlimit structure pointed to by 'rlp'.
+ */
+void
+lim_rlimit(struct proc *p, int which, struct rlimit *rlp)
+{
+
+#if 0
+	PROC_LOCK_ASSERT(p, MA_OWNED);
+	KASSERT(which >= 0 && which < RLIM_NLIMITS,
+	    ("request for invalid resource limit"));
+	*rlp = p->p_limit->pl_rlimit[which];
+	if (p->p_sysent->sv_fixlimit != NULL)
+		p->p_sysent->sv_fixlimit(rlp, which);
+#endif
+}
+
 int
 useracc(void *addr, int len, int rw)
 {
 	return (1);
 }
 
+
        
+struct proc *
+zpfind(pid_t pid)
+{
+
+	return (NULL);
+}
+
+int
+p_cansee(struct thread *td, struct proc *p)
+{
+
+	return (0);
+}
+
+struct proc *
+pfind(pid_t pid)
+{
+
+	return (NULL);
+}
+
+/*
+ * Fill in a struct xucred based on a struct ucred.
+ */
+void
+cru2x(struct ucred *cr, struct xucred *xcr)
+{
+#if 0
+	int ngroups;
+
+	bzero(xcr, sizeof(*xcr));
+	xcr->cr_version = XUCRED_VERSION;
+	xcr->cr_uid = cr->cr_uid;
+
+	ngroups = MIN(cr->cr_ngroups, XU_NGROUPS);
+	xcr->cr_ngroups = ngroups;
+	bcopy(cr->cr_groups, xcr->cr_groups,
+	    ngroups * sizeof(*cr->cr_groups));
+#endif
+}
+
+int
+cr_cansee(struct ucred *u1, struct ucred *u2)
+{
+
+	return (0);
+}
+
+int
+cr_canseeinpcb(struct ucred *cred, struct inpcb *inp)
+{
+
+	return (0);
+}
+
+int
+securelevel_gt(struct ucred *cr, int level)
+{
+
+	return (0);
+}
+
+
+
+
+/**
+ * @brief Send a 'notification' to userland, using standard ways
+ */
+void
+devctl_notify(const char *system, const char *subsystem, const char *type,
+    const char *data)
+{
+	;	
+}
+
+void
+cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t size)
+{
+	;	
+}
+

Added: user/kmacy/releng_8_rump/lib/libunet/unet_init_main.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_init_main.c	Mon Jan  4 04:26:02 2010	(r201470)
@@ -0,0 +1,273 @@
+/*-
+ * Copyright (c) 1995 Terrence R. Lambert
+ * All rights reserved.
+ *
+ * Copyright (c) 1982, 1986, 1989, 1991, 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS 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.
+ *
+ *	@(#)init_main.c	8.9 (Berkeley) 1/21/94
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "opt_ddb.h"
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/exec.h>
+#include <sys/file.h>
+#include <sys/filedesc.h>
+#include <sys/jail.h>
+#include <sys/ktr.h>
+#include <sys/lock.h>
+#include <sys/mount.h>
+#include <sys/mutex.h>
+#include <sys/syscallsubr.h>
+#include <sys/sysctl.h>
+#include <sys/proc.h>
+#include <sys/resourcevar.h>
+#include <sys/systm.h>
+#include <sys/signalvar.h>
+#include <sys/sysent.h>
+#include <sys/reboot.h>
+#include <sys/sched.h>
+#include <sys/sx.h>
+#include <sys/sysproto.h>
+#include <sys/vmmeter.h>
+#include <sys/unistd.h>
+#include <sys/malloc.h>
+#include <sys/conf.h>
+#include <sys/cpuset.h>
+
+#include <machine/cpu.h>
+
+#include <security/audit/audit.h>
+#include <security/mac/mac_framework.h>
+
+#include <vm/vm.h>
+#include <vm/vm_param.h>
+#include <vm/pmap.h>
+#include <vm/vm_map.h>
+#include <sys/copyright.h>
+
+#include <ddb/ddb.h>
+#include <ddb/db_sym.h>
+
+void mi_startup(void);				/* Should be elsewhere */
+
+/* Components of the first process -- never freed. */
+static struct session session0;
+static struct pgrp pgrp0;
+struct	proc proc0;
+struct	thread thread0 __aligned(16);
+struct	vmspace vmspace0;
+struct	proc *initproc;
+#if 0
+int	boothowto = 0;		/* initialized so that it can be patched */
+SYSCTL_INT(_debug, OID_AUTO, boothowto, CTLFLAG_RD, &boothowto, 0, "");
+int	bootverbose;
+SYSCTL_INT(_debug, OID_AUTO, bootverbose, CTLFLAG_RW, &bootverbose, 0, "");
+#endif
+/*
+ * This ensures that there is at least one entry so that the sysinit_set
+ * symbol is not undefined.  A sybsystem ID of SI_SUB_DUMMY is never
+ * executed.
+ */
+SYSINIT(placeholder, SI_SUB_DUMMY, SI_ORDER_ANY, NULL, NULL);
+
+/*
+ * The sysinit table itself.  Items are checked off as the are run.
+ * If we want to register new sysinit types, add them to newsysinit.
+ */
+SET_DECLARE(sysinit_set, struct sysinit);
+struct sysinit **sysinit, **sysinit_end;
+struct sysinit **newsysinit, **newsysinit_end;
+
+/*
+ * Merge a new sysinit set into the current set, reallocating it if
+ * necessary.  This can only be called after malloc is running.
+ */
+void
+sysinit_add(struct sysinit **set, struct sysinit **set_end)
+{
+	struct sysinit **newset;
+	struct sysinit **sipp;
+	struct sysinit **xipp;
+	int count;
+
+	count = set_end - set;
+	if (newsysinit)
+		count += newsysinit_end - newsysinit;
+	else
+		count += sysinit_end - sysinit;
+	newset = malloc(count * sizeof(*sipp), M_TEMP, M_NOWAIT);
+	if (newset == NULL)
+		panic("cannot malloc for sysinit");
+	xipp = newset;
+	if (newsysinit)
+		for (sipp = newsysinit; sipp < newsysinit_end; sipp++)
+			*xipp++ = *sipp;
+	else
+		for (sipp = sysinit; sipp < sysinit_end; sipp++)
+			*xipp++ = *sipp;
+	for (sipp = set; sipp < set_end; sipp++)
+		*xipp++ = *sipp;
+	if (newsysinit)
+		free(newsysinit, M_TEMP);
+	newsysinit = newset;
+	newsysinit_end = newset + count;
+}
+
+/*
+ * System startup; initialize the world, create process 0, mount root
+ * filesystem, and fork to create init and pagedaemon.  Most of the
+ * hard work is done in the lower-level initialization routines including
+ * startup(), which does memory initialization and autoconfiguration.
+ *
+ * This allows simple addition of new kernel subsystems that require
+ * boot time initialization.  It also allows substitution of subsystem
+ * (for instance, a scheduler, kernel profiler, or VM system) by object
+ * module.  Finally, it allows for optional "kernel threads".
+ */
+void
+mi_startup(void)
+{
+
+	register struct sysinit **sipp;		/* system initialization*/
+	register struct sysinit **xipp;		/* interior loop of sort*/
+	register struct sysinit *save;		/* bubble*/
+
+#if defined(VERBOSE_SYSINIT)
+	int last;
+	int verbose;
+#endif
+
+	if (sysinit == NULL) {
+		sysinit = SET_BEGIN(sysinit_set);
+		sysinit_end = SET_LIMIT(sysinit_set);
+	}
+
+restart:
+	/*
+	 * Perform a bubble sort of the system initialization objects by
+	 * their subsystem (primary key) and order (secondary key).
+	 */
+	for (sipp = sysinit; sipp < sysinit_end; sipp++) {
+		for (xipp = sipp + 1; xipp < sysinit_end; xipp++) {
+			if ((*sipp)->subsystem < (*xipp)->subsystem ||
+			     ((*sipp)->subsystem == (*xipp)->subsystem &&
+			      (*sipp)->order <= (*xipp)->order))
+				continue;	/* skip*/
+			save = *sipp;
+			*sipp = *xipp;
+			*xipp = save;
+		}
+	}
+
+#if defined(VERBOSE_SYSINIT)
+	last = SI_SUB_COPYRIGHT;
+	verbose = 0;
+#if !defined(DDB)
+	printf("VERBOSE_SYSINIT: DDB not enabled, symbol lookups disabled.\n");
+#endif
+#endif
+
+	/*
+	 * Traverse the (now) ordered list of system initialization tasks.
+	 * Perform each task, and continue on to the next task.
+	 *
+	 * The last item on the list is expected to be the scheduler,
+	 * which will not return.
+	 */
+	for (sipp = sysinit; sipp < sysinit_end; sipp++) {
+
+		if ((*sipp)->subsystem == SI_SUB_DUMMY)
+			continue;	/* skip dummy task(s)*/
+
+		if ((*sipp)->subsystem == SI_SUB_DONE)
+			continue;
+
+#if defined(VERBOSE_SYSINIT)
+		if ((*sipp)->subsystem > last) {
+			verbose = 1;
+			last = (*sipp)->subsystem;
+			printf("subsystem %x\n", last);
+		}
+		if (verbose) {
+#if defined(DDB)
+			const char *name;
+			c_db_sym_t sym;
+			db_expr_t  offset;
+
+			sym = db_search_symbol((vm_offset_t)(*sipp)->func,
+			    DB_STGY_PROC, &offset);
+			db_symbol_values(sym, &name, NULL);
+			if (name != NULL)
+				printf("   %s(%p)... ", name, (*sipp)->udata);
+			else
+#endif
+				printf("   %p(%p)... ", (*sipp)->func,
+				    (*sipp)->udata);
+		}
+#endif
+
+		/* Call function */
+		(*((*sipp)->func))((*sipp)->udata);
+
+#if defined(VERBOSE_SYSINIT)
+		if (verbose)
+			printf("done.\n");
+#endif
+
+		/* Check off the one we're just done */
+		(*sipp)->subsystem = SI_SUB_DONE;
+
+		/* Check if we've installed more sysinit items via KLD */
+		if (newsysinit != NULL) {
+			if (sysinit != SET_BEGIN(sysinit_set))
+				free(sysinit, M_TEMP);
+			sysinit = newsysinit;
+			sysinit_end = newsysinit_end;
+			newsysinit = NULL;
+			newsysinit_end = NULL;
+			goto restart;
+		}
+	}
+
+	panic("Shouldn't get here!");
+	/* NOTREACHED*/
+}

Added: user/kmacy/releng_8_rump/lib/libunet/unet_kern_synch.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_kern_synch.c	Mon Jan  4 04:26:02 2010	(r201470)
@@ -0,0 +1,53 @@
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "opt_ktrace.h"
+#include "opt_sched.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/condvar.h>
+#include <sys/kdb.h>
+#include <sys/kernel.h>
+#include <sys/ktr.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/proc.h>
+#include <sys/resourcevar.h>
+#include <sys/sched.h>
+#include <sys/signalvar.h>
+#include <sys/sleepqueue.h>
+#include <sys/smp.h>
+#include <sys/sx.h>
+#include <sys/sysctl.h>
+#include <sys/sysproto.h>
+#include <sys/vmmeter.h>
+#ifdef KTRACE
+#include <sys/uio.h>
+#include <sys/ktrace.h>
+#endif
+
+int	hogticks;
+
+/*
+ * General sleep call.  Suspends the current thread until a wakeup is
+ * performed on the specified identifier.  The thread will then be made
+ * runnable with the specified priority.  Sleeps at most timo/hz seconds
+ * (0 means no timeout).  If pri includes PCATCH flag, signals are checked
+ * before and after sleeping, else signals are not checked.  Returns 0 if
+ * awakened, EWOULDBLOCK if the timeout expires.  If PCATCH is set and a
+ * signal needs to be delivered, ERESTART is returned if the current system
+ * call should be restarted if possible, and EINTR is returned if the system
+ * call should be interrupted by the signal (return EINTR).
+ *
+ * The lock argument is unlocked before the caller is suspended, and
+ * re-locked before _sleep() returns.  If priority includes the PDROP
+ * flag the lock is not re-locked before returning.
+ */
+int
+_sleep(void *ident, struct lock_object *lock, int priority,
+    const char *wmesg, int timo)
+{
+
+	panic("");
+}

Added: user/kmacy/releng_8_rump/lib/libunet/unet_uma_core.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_uma_core.c	Mon Jan  4 04:26:02 2010	(r201470)
@@ -0,0 +1,2809 @@
+/*-
+ * Copyright (c) 2002-2005, 2009 Jeffrey Roberson <jeff@FreeBSD.org>
+ * Copyright (c) 2004, 2005 Bosko Milekic <bmilekic@FreeBSD.org>
+ * Copyright (c) 2004-2006 Robert N. M. Watson
+ * 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 unmodified, 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 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.
+ */
+
+/*
+ * uma_core.c  Implementation of the Universal Memory allocator
+ *
+ * This allocator is intended to replace the multitude of similar object caches
+ * in the standard FreeBSD kernel.  The intent is to be flexible as well as
+ * effecient.  A primary design goal is to return unused memory to the rest of
+ * the system.  This will make the system as a whole more flexible due to the
+ * ability to move memory to subsystems which most need it instead of leaving
+ * pools of reserved memory unused.
+ *
+ * The basic ideas stem from similar slab/zone based allocators whose algorithms
+ * are well known.
+ *
+ */
+
+/*
+ * TODO:
+ *	- Improve memory usage for large allocations
+ *	- Investigate cache size adjustments
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* I should really use ktr.. */
+/*
+#define UMA_DEBUG 1
+#define UMA_DEBUG_ALLOC 1
+#define UMA_DEBUG_ALLOC_1 1
+*/
+
+#include "opt_ddb.h"
+#include "opt_param.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/types.h>
+#include <sys/queue.h>
+#include <sys/malloc.h>
+#include <sys/ktr.h>
+#include <sys/lock.h>
+#include <sys/sysctl.h>
+#include <sys/mutex.h>
+#include <sys/proc.h>
+#include <sys/sbuf.h>
+#include <sys/smp.h>
+#include <sys/vmmeter.h>
+
+#include <vm/vm.h>
+#include <vm/vm_object.h>
+#include <vm/vm_page.h>
+#include <vm/vm_param.h>
+#include <vm/vm_map.h>
+#include <vm/vm_kern.h>
+#include <vm/vm_extern.h>
+#include <vm/uma.h>
+#include <vm/uma_int.h>
+#include <vm/uma_dbg.h>
+
+#include <machine/vmparam.h>
+
+#include <ddb/ddb.h>
+
+#undef UMA_MD_SMALL_ALLOC
+
+/*
+ * This is the zone and keg from which all zones are spawned.  The idea is that
+ * even the zone & keg heads are allocated from the allocator, so we use the
+ * bss section to bootstrap us.
+ */
+static struct uma_keg masterkeg;
+static struct uma_zone masterzone_k;
+static struct uma_zone masterzone_z;
+static uma_zone_t kegs = &masterzone_k;
+static uma_zone_t zones = &masterzone_z;
+
+/* This is the zone from which all of uma_slab_t's are allocated. */
+static uma_zone_t slabzone;
+static uma_zone_t slabrefzone;	/* With refcounters (for UMA_ZONE_REFCNT) */
+
+/*
+ * The initial hash tables come out of this zone so they can be allocated
+ * prior to malloc coming up.
+ */
+static uma_zone_t hashzone;
+
+/* The boot-time adjusted value for cache line alignment. */
+static int uma_align_cache = 64 - 1;
+
+static MALLOC_DEFINE(M_UMAHASH, "UMAHash", "UMA Hash Buckets");
+
+/*
+ * Are we allowed to allocate buckets?
+ */
+static int bucketdisable = 1;
+
+/* Linked list of all kegs in the system */
+static LIST_HEAD(,uma_keg) uma_kegs = LIST_HEAD_INITIALIZER(&uma_kegs);
+
+/* This mutex protects the keg list */
+static struct mtx uma_mtx;
+
+/* Linked list of boot time pages */
+static LIST_HEAD(,uma_slab) uma_boot_pages =
+    LIST_HEAD_INITIALIZER(&uma_boot_pages);
+
+/* This mutex protects the boot time pages list */
+static struct mtx uma_boot_pages_mtx;
+
+/* Is the VM done starting up? */
+static int booted = 0;
+
+/* Maximum number of allowed items-per-slab if the slab header is OFFPAGE */
+static u_int uma_max_ipers;
+static u_int uma_max_ipers_ref;
+
+/*
+ * This is the handle used to schedule events that need to happen
+ * outside of the allocation fast path.
+ */
+static struct callout uma_callout;
+#define	UMA_TIMEOUT	20		/* Seconds for callout interval. */
+
+/*
+ * This structure is passed as the zone ctor arg so that I don't have to create
+ * a special allocation function just for zones.
+ */
+struct uma_zctor_args {
+	char *name;
+	size_t size;
+	uma_ctor ctor;
+	uma_dtor dtor;
+	uma_init uminit;
+	uma_fini fini;
+	uma_keg_t keg;
+	int align;
+	u_int32_t flags;
+};
+
+struct uma_kctor_args {
+	uma_zone_t zone;
+	size_t size;
+	uma_init uminit;
+	uma_fini fini;
+	int align;
+	u_int32_t flags;
+};
+
+struct uma_bucket_zone {
+	uma_zone_t	ubz_zone;
+	char		*ubz_name;
+	int		ubz_entries;
+};
+
+#define	BUCKET_MAX	128
+
+struct uma_bucket_zone bucket_zones[] = {
+	{ NULL, "16 Bucket", 16 },
+	{ NULL, "32 Bucket", 32 },
+	{ NULL, "64 Bucket", 64 },
+	{ NULL, "128 Bucket", 128 },
+	{ NULL, NULL, 0}
+};
+
+#define	BUCKET_SHIFT	4
+#define	BUCKET_ZONES	((BUCKET_MAX >> BUCKET_SHIFT) + 1)
+
+/*
+ * bucket_size[] maps requested bucket sizes to zones that allocate a bucket
+ * of approximately the right size.
+ */
+static uint8_t bucket_size[BUCKET_ZONES];
+
+/*
+ * Flags and enumerations to be passed to internal functions.
+ */
+enum zfreeskip { SKIP_NONE, SKIP_DTOR, SKIP_FINI };
+
+#define	ZFREE_STATFAIL	0x00000001	/* Update zone failure statistic. */
+#define	ZFREE_STATFREE	0x00000002	/* Update zone free statistic. */
+
+/* Prototypes.. */
+
+static void *obj_alloc(uma_zone_t, int, u_int8_t *, int);
+static void *page_alloc(uma_zone_t, int, u_int8_t *, int);
+static void *startup_alloc(uma_zone_t, int, u_int8_t *, int);
+static void page_free(void *, int, u_int8_t);
+static uma_slab_t keg_alloc_slab(uma_keg_t, uma_zone_t, int);
+static void cache_drain(uma_zone_t);
+static void bucket_drain(uma_zone_t, uma_bucket_t);
+static void bucket_cache_drain(uma_zone_t zone);
+static int keg_ctor(void *, int, void *, int);
+static void keg_dtor(void *, int, void *);
+static int zone_ctor(void *, int, void *, int);
+static void zone_dtor(void *, int, void *);
+static int zero_init(void *, int, int);
+static void keg_small_init(uma_keg_t keg);
+static void keg_large_init(uma_keg_t keg);
+static void zone_foreach(void (*zfunc)(uma_zone_t));
+static void zone_timeout(uma_zone_t zone);
+static int hash_alloc(struct uma_hash *);
+static int hash_expand(struct uma_hash *, struct uma_hash *);
+static void hash_free(struct uma_hash *hash);
+static void uma_timeout(void *);
+static void uma_startup3(void);
+static void *zone_alloc_item(uma_zone_t, void *, int);
+static void zone_free_item(uma_zone_t, void *, void *, enum zfreeskip,
+    int);
+static void bucket_enable(void);
+static void bucket_init(void);
+static uma_bucket_t bucket_alloc(int, int);
+static void bucket_free(uma_bucket_t);
+static void bucket_zone_drain(void);
+static int zone_alloc_bucket(uma_zone_t zone, int flags);
+static uma_slab_t zone_fetch_slab(uma_zone_t zone, uma_keg_t last, int flags);
+static uma_slab_t zone_fetch_slab_multi(uma_zone_t zone, uma_keg_t last, int flags);
+static void *slab_alloc_item(uma_zone_t zone, uma_slab_t slab);
+static uma_keg_t uma_kcreate(uma_zone_t zone, size_t size, uma_init uminit,
+    uma_fini fini, int align, u_int32_t flags);
+static inline void zone_relock(uma_zone_t zone, uma_keg_t keg);
+static inline void keg_relock(uma_keg_t keg, uma_zone_t zone);
+
+void uma_print_zone(uma_zone_t);
+void uma_print_stats(void);
+static int sysctl_vm_zone_count(SYSCTL_HANDLER_ARGS);
+static int sysctl_vm_zone_stats(SYSCTL_HANDLER_ARGS);
+
+SYSINIT(uma_startup3, SI_SUB_VM_CONF, SI_ORDER_SECOND, uma_startup3, NULL);
+
+SYSCTL_PROC(_vm, OID_AUTO, zone_count, CTLFLAG_RD|CTLTYPE_INT,
+    0, 0, sysctl_vm_zone_count, "I", "Number of UMA zones");
+
+SYSCTL_PROC(_vm, OID_AUTO, zone_stats, CTLFLAG_RD|CTLTYPE_STRUCT,
+    0, 0, sysctl_vm_zone_stats, "s,struct uma_type_header", "Zone Stats");
+
+/*
+ * This routine checks to see whether or not it's safe to enable buckets.
+ */
+
+static void
+bucket_enable(void)
+{
+	if (cnt.v_free_count < cnt.v_free_min)
+		bucketdisable = 1;
+	else
+		bucketdisable = 0;
+}
+
+/*
+ * Initialize bucket_zones, the array of zones of buckets of various sizes.
+ *
+ * For each zone, calculate the memory required for each bucket, consisting
+ * of the header and an array of pointers.  Initialize bucket_size[] to point
+ * the range of appropriate bucket sizes at the zone.
+ */
+static void
+bucket_init(void)
+{
+	struct uma_bucket_zone *ubz;
+	int i;
+	int j;
+
+	for (i = 0, j = 0; bucket_zones[j].ubz_entries != 0; j++) {
+		int size;
+
+		ubz = &bucket_zones[j];
+		size = roundup(sizeof(struct uma_bucket), sizeof(void *));
+		size += sizeof(void *) * ubz->ubz_entries;
+		ubz->ubz_zone = uma_zcreate(ubz->ubz_name, size,
+		    NULL, NULL, NULL, NULL, UMA_ALIGN_PTR,
+		    UMA_ZFLAG_INTERNAL | UMA_ZFLAG_BUCKET);
+		for (; i <= ubz->ubz_entries; i += (1 << BUCKET_SHIFT))
+			bucket_size[i >> BUCKET_SHIFT] = j;
+	}
+}
+
+/*
+ * Given a desired number of entries for a bucket, return the zone from which
+ * to allocate the bucket.
+ */
+static struct uma_bucket_zone *
+bucket_zone_lookup(int entries)
+{
+	int idx;
+
+	idx = howmany(entries, 1 << BUCKET_SHIFT);
+	return (&bucket_zones[bucket_size[idx]]);
+}
+
+static uma_bucket_t
+bucket_alloc(int entries, int bflags)
+{
+	struct uma_bucket_zone *ubz;
+	uma_bucket_t bucket;
+
+	/*
+	 * This is to stop us from allocating per cpu buckets while we're
+	 * running out of vm.boot_pages.  Otherwise, we would exhaust the
+	 * boot pages.  This also prevents us from allocating buckets in
+	 * low memory situations.
+	 */
+	if (bucketdisable)
+		return (NULL);
+
+	ubz = bucket_zone_lookup(entries);
+	bucket = zone_alloc_item(ubz->ubz_zone, NULL, bflags);
+	if (bucket) {
+#ifdef INVARIANTS
+		bzero(bucket->ub_bucket, sizeof(void *) * ubz->ubz_entries);
+#endif
+		bucket->ub_cnt = 0;
+		bucket->ub_entries = ubz->ubz_entries;
+	}
+
+	return (bucket);
+}
+
+static void
+bucket_free(uma_bucket_t bucket)
+{
+	struct uma_bucket_zone *ubz;
+
+	ubz = bucket_zone_lookup(bucket->ub_entries);
+	zone_free_item(ubz->ubz_zone, bucket, NULL, SKIP_NONE,
+	    ZFREE_STATFREE);
+}
+
+static void
+bucket_zone_drain(void)
+{
+	struct uma_bucket_zone *ubz;
+
+	for (ubz = &bucket_zones[0]; ubz->ubz_entries != 0; ubz++)
+		zone_drain(ubz->ubz_zone);
+}
+
+static inline uma_keg_t
+zone_first_keg(uma_zone_t zone)
+{
+
+	return (LIST_FIRST(&zone->uz_kegs)->kl_keg);
+}
+
+static void
+zone_foreach_keg(uma_zone_t zone, void (*kegfn)(uma_keg_t))
+{
+	uma_klink_t klink;
+
+	LIST_FOREACH(klink, &zone->uz_kegs, kl_link)
+		kegfn(klink->kl_keg);
+}
+
+/*
+ * Routine called by timeout which is used to fire off some time interval
+ * based calculations.  (stats, hash size, etc.)
+ *
+ * Arguments:
+ *	arg   Unused
+ *
+ * Returns:
+ *	Nothing
+ */
+static void
+uma_timeout(void *unused)
+{
+	bucket_enable();
+	zone_foreach(zone_timeout);
+
+	/* Reschedule this event */
+	callout_reset(&uma_callout, UMA_TIMEOUT * hz, uma_timeout, NULL);

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***

From owner-svn-src-user@FreeBSD.ORG  Mon Jan  4 04:29:01 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 D2DB4106566B;
	Mon,  4 Jan 2010 04:29:01 +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 BBD908FC13;
	Mon,  4 Jan 2010 04:29:01 +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 o044T1xs049699;
	Mon, 4 Jan 2010 04:29:01 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o044T1FW049666;
	Mon, 4 Jan 2010 04:29:01 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001040429.o044T1FW049666@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Mon, 4 Jan 2010 04:29:01 +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: r201471 - in user/kmacy/releng_8_rump/lib/libunet: .
	include include/opt
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 04:29:01 -0000

Author: kmacy
Date: Mon Jan  4 04:29:01 2010
New Revision: 201471
URL: http://svn.freebsd.org/changeset/base/201471

Log:
  move kernel opt headers into include/opt

Added:
  user/kmacy/releng_8_rump/lib/libunet/include/
  user/kmacy/releng_8_rump/lib/libunet/include/opt/
  user/kmacy/releng_8_rump/lib/libunet/include/opt/bus_if.h
     - copied unchanged from r201418, user/kmacy/releng_8_rump/lib/libunet/bus_if.h
  user/kmacy/releng_8_rump/lib/libunet/include/opt/device_if.h
     - copied unchanged from r201418, user/kmacy/releng_8_rump/lib/libunet/device_if.h
  user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_atalk.h
     - copied unchanged from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_atalk.h
  user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_bootp.h
     - copied unchanged from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_bootp.h
  user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_bpf.h
     - copied unchanged from r201424, user/kmacy/releng_8_rump/lib/libunet/opt_bpf.h
  user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_carp.h
     - copied unchanged from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_carp.h
  user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_compat.h
     - copied unchanged from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_compat.h
  user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_ddb.h
     - copied unchanged from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_ddb.h
  user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_device_polling.h
     - copied unchanged from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_device_polling.h
  user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_inet.h
     - copied unchanged from r201423, user/kmacy/releng_8_rump/lib/libunet/opt_inet.h
  user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_inet6.h
     - copied unchanged from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_inet6.h
  user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_ipfw.h
     - copied unchanged from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_ipfw.h
  user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_ipsec.h
     - copied unchanged from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_ipsec.h
  user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_ipstealth.h
     - copied unchanged from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_ipstealth.h
  user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_ipx.h
     - copied unchanged from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_ipx.h
  user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_kdtrace.h
     - copied unchanged from r201470, user/kmacy/releng_8_rump/lib/libunet/opt_kdtrace.h
  user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_ktrace.h
     - copied unchanged from r201425, user/kmacy/releng_8_rump/lib/libunet/opt_ktrace.h
  user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_maxusers.h
     - copied unchanged from r201448, user/kmacy/releng_8_rump/lib/libunet/opt_maxusers.h
  user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_mbuf_profiling.h
     - copied unchanged from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_mbuf_profiling.h
  user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_mbuf_stress_test.h
     - copied unchanged from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_mbuf_stress_test.h
  user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_mpath.h
     - copied unchanged from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_mpath.h
  user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_mrouting.h
     - copied unchanged from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_mrouting.h
  user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_netgraph.h
     - copied unchanged from r201424, user/kmacy/releng_8_rump/lib/libunet/opt_netgraph.h
  user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_param.h
     - copied unchanged from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_param.h
  user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_pf.h
     - copied unchanged from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_pf.h
  user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_route.h
     - copied unchanged from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_route.h
  user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_sched.h
     - copied unchanged from r201470, user/kmacy/releng_8_rump/lib/libunet/opt_sched.h
  user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_sctp.h
     - copied unchanged from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_sctp.h
  user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_tcpdebug.h
     - copied unchanged from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_tcpdebug.h
  user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_vm.h
     - copied unchanged from r201470, user/kmacy/releng_8_rump/lib/libunet/opt_vm.h
  user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_zero.h
     - copied unchanged from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_zero.h
Deleted:
  user/kmacy/releng_8_rump/lib/libunet/bus_if.h
  user/kmacy/releng_8_rump/lib/libunet/device_if.h
  user/kmacy/releng_8_rump/lib/libunet/opt_atalk.h
  user/kmacy/releng_8_rump/lib/libunet/opt_bootp.h
  user/kmacy/releng_8_rump/lib/libunet/opt_bpf.h
  user/kmacy/releng_8_rump/lib/libunet/opt_carp.h
  user/kmacy/releng_8_rump/lib/libunet/opt_compat.h
  user/kmacy/releng_8_rump/lib/libunet/opt_ddb.h
  user/kmacy/releng_8_rump/lib/libunet/opt_device_polling.h
  user/kmacy/releng_8_rump/lib/libunet/opt_inet.h
  user/kmacy/releng_8_rump/lib/libunet/opt_inet6.h
  user/kmacy/releng_8_rump/lib/libunet/opt_ipfw.h
  user/kmacy/releng_8_rump/lib/libunet/opt_ipsec.h
  user/kmacy/releng_8_rump/lib/libunet/opt_ipstealth.h
  user/kmacy/releng_8_rump/lib/libunet/opt_ipx.h
  user/kmacy/releng_8_rump/lib/libunet/opt_kdtrace.h
  user/kmacy/releng_8_rump/lib/libunet/opt_ktrace.h
  user/kmacy/releng_8_rump/lib/libunet/opt_maxusers.h
  user/kmacy/releng_8_rump/lib/libunet/opt_mbuf_profiling.h
  user/kmacy/releng_8_rump/lib/libunet/opt_mbuf_stress_test.h
  user/kmacy/releng_8_rump/lib/libunet/opt_mpath.h
  user/kmacy/releng_8_rump/lib/libunet/opt_mrouting.h
  user/kmacy/releng_8_rump/lib/libunet/opt_netgraph.h
  user/kmacy/releng_8_rump/lib/libunet/opt_param.h
  user/kmacy/releng_8_rump/lib/libunet/opt_pf.h
  user/kmacy/releng_8_rump/lib/libunet/opt_route.h
  user/kmacy/releng_8_rump/lib/libunet/opt_sched.h
  user/kmacy/releng_8_rump/lib/libunet/opt_sctp.h
  user/kmacy/releng_8_rump/lib/libunet/opt_tcpdebug.h
  user/kmacy/releng_8_rump/lib/libunet/opt_vm.h
  user/kmacy/releng_8_rump/lib/libunet/opt_zero.h
Modified:
  user/kmacy/releng_8_rump/lib/libunet/Makefile

Modified: user/kmacy/releng_8_rump/lib/libunet/Makefile
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/Makefile	Mon Jan  4 04:26:02 2010	(r201470)
+++ user/kmacy/releng_8_rump/lib/libunet/Makefile	Mon Jan  4 04:29:01 2010	(r201471)
@@ -119,7 +119,7 @@ UNET_COMMON_SRCS= ${UNET_COMMON_OBJS:C/.
 SRCS=	${UNET_COMMON_SRCS}
 
 CFLAGS+=	-I${PREFIX}
-CFLAGS+=	-I.
+CFLAGS+=	-I./include/opt
 CFLAGS+=	-D_KERNEL
 CFLAGS+=	-DUNET
 CFLAGS+=	-DMAXUSERS=32

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/bus_if.h (from r201418, user/kmacy/releng_8_rump/lib/libunet/bus_if.h)
==============================================================================

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/device_if.h (from r201418, user/kmacy/releng_8_rump/lib/libunet/device_if.h)
==============================================================================

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_atalk.h (from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_atalk.h)
==============================================================================

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_bootp.h (from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_bootp.h)
==============================================================================

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_bpf.h (from r201424, user/kmacy/releng_8_rump/lib/libunet/opt_bpf.h)
==============================================================================

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_carp.h (from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_carp.h)
==============================================================================

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_compat.h (from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_compat.h)
==============================================================================

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_ddb.h (from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_ddb.h)
==============================================================================

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_device_polling.h (from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_device_polling.h)
==============================================================================

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_inet.h (from r201423, user/kmacy/releng_8_rump/lib/libunet/opt_inet.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_inet.h	Mon Jan  4 04:29:01 2010	(r201471, copy of r201423, user/kmacy/releng_8_rump/lib/libunet/opt_inet.h)
@@ -0,0 +1 @@
+#define INET 1

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_inet6.h (from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_inet6.h)
==============================================================================

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_ipfw.h (from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_ipfw.h)
==============================================================================

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_ipsec.h (from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_ipsec.h)
==============================================================================

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_ipstealth.h (from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_ipstealth.h)
==============================================================================

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_ipx.h (from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_ipx.h)
==============================================================================

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_kdtrace.h (from r201470, user/kmacy/releng_8_rump/lib/libunet/opt_kdtrace.h)
==============================================================================

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_ktrace.h (from r201425, user/kmacy/releng_8_rump/lib/libunet/opt_ktrace.h)
==============================================================================

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_maxusers.h (from r201448, user/kmacy/releng_8_rump/lib/libunet/opt_maxusers.h)
==============================================================================

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_mbuf_profiling.h (from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_mbuf_profiling.h)
==============================================================================

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_mbuf_stress_test.h (from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_mbuf_stress_test.h)
==============================================================================

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_mpath.h (from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_mpath.h)
==============================================================================

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_mrouting.h (from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_mrouting.h)
==============================================================================

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_netgraph.h (from r201424, user/kmacy/releng_8_rump/lib/libunet/opt_netgraph.h)
==============================================================================

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_param.h (from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_param.h)
==============================================================================

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_pf.h (from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_pf.h)
==============================================================================

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_route.h (from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_route.h)
==============================================================================

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_sched.h (from r201470, user/kmacy/releng_8_rump/lib/libunet/opt_sched.h)
==============================================================================

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_sctp.h (from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_sctp.h)
==============================================================================

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_tcpdebug.h (from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_tcpdebug.h)
==============================================================================

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_vm.h (from r201470, user/kmacy/releng_8_rump/lib/libunet/opt_vm.h)
==============================================================================

Copied: user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_zero.h (from r201418, user/kmacy/releng_8_rump/lib/libunet/opt_zero.h)
==============================================================================

From owner-svn-src-user@FreeBSD.ORG  Mon Jan  4 05:39:00 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 EC9EF1065670;
	Mon,  4 Jan 2010 05:39:00 +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 C600A8FC1E;
	Mon,  4 Jan 2010 05:39:00 +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 o045d0Ok065139;
	Mon, 4 Jan 2010 05:39:00 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o045d0Ix065131;
	Mon, 4 Jan 2010 05:39:00 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001040539.o045d0Ix065131@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Mon, 4 Jan 2010 05:39:00 +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: r201473 - 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 05:39:01 -0000

Author: kmacy
Date: Mon Jan  4 05:39:00 2010
New Revision: 201473
URL: http://svn.freebsd.org/changeset/base/201473

Log:
  add stub locking primitives, interrupts, and taskqueues

Added:
  user/kmacy/releng_8_rump/lib/libunet/unet_kern_intr.c   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/unet_kern_subr.c   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/unet_lock.c   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/unet_subr_taskqueue.c   (contents, props changed)
Modified:
  user/kmacy/releng_8_rump/lib/libunet/Makefile
  user/kmacy/releng_8_rump/lib/libunet/unet_compat.c
  user/kmacy/releng_8_rump/lib/libunet/unet_uma_core.c

Modified: user/kmacy/releng_8_rump/lib/libunet/Makefile
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/Makefile	Mon Jan  4 05:27:49 2010	(r201472)
+++ user/kmacy/releng_8_rump/lib/libunet/Makefile	Mon Jan  4 05:39:00 2010	(r201473)
@@ -15,14 +15,12 @@ UNET_KERN_COMMON_OBJS +=	\
 	kern_malloc.o		\
 	kern_mbuf.o		\
 	kern_module.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		\
@@ -99,8 +97,12 @@ UNET_GLUE_COMMON_OBJS =		\
 	unet_compat.o		\
 	unet_glue.o		\
 	unet_init_main.c	\
+	unet_lock.o		\
 	unet_uma_core.c		\
-	unet_kern_synch.o
+	unet_kern_intr.o	\
+	unet_kern_synch.o	\
+	unet_kern_subr.o	\
+	unet_subr_taskqueue.o
 
 #	unet_init.o		\
 #	unet_uipc_syscalls.o
@@ -124,6 +126,7 @@ CFLAGS+=	-D_KERNEL
 CFLAGS+=	-DUNET
 CFLAGS+=	-DMAXUSERS=32
 CFLAGS+=	-fno-builtin
+CFLAGS+=	-g
 
 .include <bsd.lib.mk>
 

Modified: user/kmacy/releng_8_rump/lib/libunet/unet_compat.c
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/unet_compat.c	Mon Jan  4 05:27:49 2010	(r201472)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_compat.c	Mon Jan  4 05:39:00 2010	(r201473)
@@ -50,3 +50,4 @@ panic(const char *fmt, ...)
 	abort();
 }
 
+

Added: user/kmacy/releng_8_rump/lib/libunet/unet_kern_intr.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_kern_intr.c	Mon Jan  4 05:39:00 2010	(r201473)
@@ -0,0 +1,68 @@
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "opt_ddb.h"
+
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/conf.h>
+#include <sys/cpuset.h>
+#include <sys/rtprio.h>
+#include <sys/systm.h>
+#include <sys/interrupt.h>
+#include <sys/kernel.h>
+#include <sys/kthread.h>
+#include <sys/ktr.h>
+#include <sys/limits.h>
+#include <sys/lock.h>
+#include <sys/malloc.h>
+#include <sys/mutex.h>
+#include <sys/priv.h>
+#include <sys/proc.h>
+#include <sys/random.h>
+#include <sys/resourcevar.h>
+#include <sys/sched.h>
+#include <sys/smp.h>
+#include <sys/sysctl.h>
+#include <sys/syslog.h>
+#include <sys/unistd.h>
+
+/*
+ * Bind an interrupt event to the specified CPU.  Note that not all
+ * platforms support binding an interrupt to a CPU.  For those
+ * platforms this request will fail.  For supported platforms, any
+ * associated ithreads as well as the primary interrupt context will
+ * be bound to the specificed CPU.  Using a cpu id of NOCPU unbinds
+ * the interrupt event.
+ */
+int
+intr_event_bind(struct intr_event *ie, u_char cpu)
+{
+
+	panic("");
+	return (0);
+		    
+}
+
+
+/*
+ * Add a software interrupt handler to a specified event.  If a given event
+ * is not specified, then a new event is created.
+ */
+int
+swi_add(struct intr_event **eventp, const char *name, driver_intr_t handler,
+	    void *arg, int pri, enum intr_type flags, void **cookiep)
+{
+	panic("");
+	return (0);
+}
+
+/*
+ * Schedule a software interrupt thread.
+ */
+void
+swi_sched(void *cookie, int flags)
+{
+
+	panic("");
+}

Added: user/kmacy/releng_8_rump/lib/libunet/unet_kern_subr.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_kern_subr.c	Mon Jan  4 05:39:00 2010	(r201473)
@@ -0,0 +1,146 @@
+
+#include <sys/cdefs.h>
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/ktr.h>
+#include <sys/limits.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/proc.h>
+#include <sys/malloc.h>
+#include <sys/resourcevar.h>
+#include <sys/sched.h>
+#include <sys/sysctl.h>
+#include <sys/uio.h>
+
+/*
+ * General routine to allocate a hash table with control of memory flags.
+ */
+void *
+hashinit_flags(int elements, struct malloc_type *type, u_long *hashmask,
+    int flags)
+{
+	long hashsize;
+	LIST_HEAD(generic, generic) *hashtbl;
+	int i;
+
+	if (elements <= 0)
+		panic("hashinit: bad elements");
+
+	/* Exactly one of HASH_WAITOK and HASH_NOWAIT must be set. */
+	KASSERT((flags & HASH_WAITOK) ^ (flags & HASH_NOWAIT),
+	    ("Bad flags (0x%x) passed to hashinit_flags", flags));
+
+	for (hashsize = 1; hashsize <= elements; hashsize <<= 1)
+		continue;
+	hashsize >>= 1;
+
+	if (flags & HASH_NOWAIT)
+		hashtbl = malloc((u_long)hashsize * sizeof(*hashtbl),
+		    type, M_NOWAIT);
+	else
+		hashtbl = malloc((u_long)hashsize * sizeof(*hashtbl),
+		    type, M_WAITOK);
+
+	if (hashtbl != NULL) {
+		for (i = 0; i < hashsize; i++)
+			LIST_INIT(&hashtbl[i]);
+		*hashmask = hashsize - 1;
+	}
+	return (hashtbl);
+}
+
+/*
+ * Allocate and initialize a hash table with default flag: may sleep.
+ */
+void *
+hashinit(int elements, struct malloc_type *type, u_long *hashmask)
+{
+
+	return (hashinit_flags(elements, type, hashmask, HASH_WAITOK));
+}
+
+void
+hashdestroy(void *vhashtbl, struct malloc_type *type, u_long hashmask)
+{
+	LIST_HEAD(generic, generic) *hashtbl, *hp;
+
+	hashtbl = vhashtbl;
+	for (hp = hashtbl; hp <= &hashtbl[hashmask]; hp++)
+		if (!LIST_EMPTY(hp))
+			panic("hashdestroy: hash not empty");
+	free(hashtbl, type);
+}
+void
+uio_yield(void)
+{
+
+	panic("");
+}
+
+int
+uiomove(void *cp, int n, struct uio *uio)
+{
+	struct thread *td = curthread;
+	struct iovec *iov;
+	u_int cnt;
+	int error = 0;
+	int save = 0;
+
+	KASSERT(uio->uio_rw == UIO_READ || uio->uio_rw == UIO_WRITE,
+	    ("uiomove: mode"));
+	KASSERT(uio->uio_segflg != UIO_USERSPACE || uio->uio_td == curthread,
+	    ("uiomove proc"));
+	WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
+	    "Calling uiomove()");
+
+	save = td->td_pflags & TDP_DEADLKTREAT;
+	td->td_pflags |= TDP_DEADLKTREAT;
+
+	while (n > 0 && uio->uio_resid) {
+		iov = uio->uio_iov;
+		cnt = iov->iov_len;
+		if (cnt == 0) {
+			uio->uio_iov++;
+			uio->uio_iovcnt--;
+			continue;
+		}
+		if (cnt > n)
+			cnt = n;
+
+		switch (uio->uio_segflg) {
+
+		case UIO_USERSPACE:
+			if (ticks - PCPU_GET(switchticks) >= hogticks)
+				uio_yield();
+			if (uio->uio_rw == UIO_READ)
+				error = copyout(cp, iov->iov_base, cnt);
+			else
+				error = copyin(iov->iov_base, cp, cnt);
+			if (error)
+				goto out;
+			break;
+
+		case UIO_SYSSPACE:
+			if (uio->uio_rw == UIO_READ)
+				bcopy(cp, iov->iov_base, cnt);
+			else
+				bcopy(iov->iov_base, cp, cnt);
+			break;
+		case UIO_NOCOPY:
+			break;
+		}
+		iov->iov_base = (char *)iov->iov_base + cnt;
+		iov->iov_len -= cnt;
+		uio->uio_resid -= cnt;
+		uio->uio_offset += cnt;
+		cp = (char *)cp + cnt;
+		n -= cnt;
+	}
+out:
+	if (save == 0)
+		td->td_pflags &= ~TDP_DEADLKTREAT;
+	return (error);
+}

Added: user/kmacy/releng_8_rump/lib/libunet/unet_lock.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_lock.c	Mon Jan  4 05:39:00 2010	(r201473)
@@ -0,0 +1,258 @@
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/conf.h>
+#include <sys/kdb.h>
+#include <sys/kernel.h>
+#include <sys/ktr.h>
+#include <sys/lock.h>
+#include <sys/malloc.h>
+#include <sys/mutex.h>
+#include <sys/rmlock.h>
+#include <sys/rwlock.h>
+#include <sys/sx.h>
+#include <sys/proc.h>
+#include <sys/resourcevar.h>
+#include <sys/sched.h>
+#include <sys/sbuf.h>
+#include <sys/sysctl.h>
+#include <sys/turnstile.h>
+#include <sys/vmmeter.h>
+#include <sys/lock_profile.h>
+
+
+
+void
+mtx_init(struct mtx *m, const char *name, const char *type, int opts)
+{
+
+	panic("");
+}
+
+void
+mtx_destroy(struct mtx *m)
+{
+
+	panic("");
+}
+
+void
+mtx_sysinit(void *arg)
+{
+	
+	panic("");
+}
+
+void
+_mtx_lock_sleep(struct mtx *m, uintptr_t tid, int opts,
+    const char *file, int line)
+{
+
+	panic("");
+}
+
+void
+_mtx_unlock_sleep(struct mtx *m, int opts, const char *file, int line)
+{
+
+	panic("");
+}
+
+
+
+void
+rm_init_flags(struct rmlock *rm, const char *name, int opts)
+{
+	
+	panic("");
+}
+
+void
+rm_destroy(struct rmlock *rm)
+{
+
+	panic("");
+}
+
+void
+_rm_wlock(struct rmlock *rm)
+{
+
+	panic("");
+}
+
+void
+_rm_wunlock(struct rmlock *rm)
+{
+
+	panic("");
+}
+
+void
+_rm_rlock(struct rmlock *rm, struct rm_priotracker *tracker)
+{
+
+	panic("");
+}
+
+void
+_rm_runlock(struct rmlock *rm,  struct rm_priotracker *tracker)
+{
+
+	panic("");
+}
+
+
+
+void
+rw_sysinit(void *arg)
+{
+
+	panic("");
+}
+
+void
+rw_init_flags(struct rwlock *rw, const char *name, int opts)
+{
+
+	panic("");
+}
+
+void
+rw_destroy(struct rwlock *rw)
+{
+	
+	panic("");
+}
+
+void
+_rw_wlock(struct rwlock *rw, const char *file, int line)
+{
+
+	panic("");
+}
+
+int
+_rw_try_wlock(struct rwlock *rw, const char *file, int line)
+{
+
+	panic("");
+	return (0);
+}
+
+void
+_rw_wunlock(struct rwlock *rw, const char *file, int line)
+{
+	
+	panic("");
+}
+
+void
+_rw_rlock(struct rwlock *rw, const char *file, int line)
+{
+	
+	panic("");
+}
+
+int
+_rw_try_rlock(struct rwlock *rw, const char *file, int line)
+{
+	
+	panic("");
+	return (0);
+}
+
+void
+_rw_runlock(struct rwlock *rw, const char *file, int line)
+{
+	
+	panic("");
+}
+
+void
+_rw_wlock_hard(struct rwlock *rw, uintptr_t tid, const char *file,
+    int line)
+{
+	
+	panic("");
+}
+
+void
+_rw_wunlock_hard(struct rwlock *rw, uintptr_t tid, const char *file,
+    int line)
+{
+	
+	panic("");
+}
+
+int
+_rw_try_upgrade(struct rwlock *rw, const char *file, int line)
+{
+	
+	panic("");
+	return (0);
+}
+
+void
+_rw_downgrade(struct rwlock *rw, const char *file, int line)
+{
+	
+	panic("");
+}
+
+
+
+void
+sx_init_flags(struct sx *sx, const char *description, int opts)
+{
+
+	panic("");
+}
+
+void
+sx_destroy(struct sx *sx)
+{
+
+	panic("");
+}
+
+int
+_sx_xlock_hard(struct sx *sx, uintptr_t tid, int opts,
+    const char *file, int line)
+{
+	
+	panic("");
+	return (0);
+}
+
+int
+_sx_slock_hard(struct sx *sx, int opts, const char *file, int line)
+{
+	
+	panic("");
+	return (0);
+}
+
+void
+_sx_xunlock_hard(struct sx *sx, uintptr_t tid, const char *file, int
+    line)
+{
+	
+	panic("");
+}
+
+void
+_sx_sunlock_hard(struct sx *sx, const char *file, int line)
+{
+	
+	panic("");
+}
+
+int
+_sx_try_xlock(struct sx *sx, const char *file, int line)
+{
+	
+	panic("");
+	return (0);
+}
+

Added: user/kmacy/releng_8_rump/lib/libunet/unet_subr_taskqueue.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_subr_taskqueue.c	Mon Jan  4 05:39:00 2010	(r201473)
@@ -0,0 +1,91 @@
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/interrupt.h>
+#include <sys/kernel.h>
+#include <sys/kthread.h>
+#include <sys/lock.h>
+#include <sys/malloc.h>
+#include <sys/mutex.h>
+#include <sys/proc.h>
+#include <sys/sched.h>
+#include <sys/taskqueue.h>
+#include <sys/unistd.h>
+#include <machine/stdarg.h>
+
+static MALLOC_DEFINE(M_TASKQUEUE, "taskqueue", "Task Queues");
+static void	*taskqueue_giant_ih;
+static void	*taskqueue_ih;
+
+struct taskqueue {
+	STAILQ_HEAD(, task)	tq_queue;
+	const char		*tq_name;
+	taskqueue_enqueue_fn	tq_enqueue;
+	void			*tq_context;
+	struct task		*tq_running;
+	struct mtx		tq_mutex;
+	struct thread		**tq_threads;
+	int			tq_tcount;
+	int			tq_spin;
+	int			tq_flags;
+};
+
+#define	TQ_FLAGS_ACTIVE		(1 << 0)
+#define	TQ_FLAGS_BLOCKED	(1 << 1)
+#define	TQ_FLAGS_PENDING	(1 << 2)
+
+struct taskqueue *
+taskqueue_create(const char *name, int mflags,
+				    taskqueue_enqueue_fn enqueue,
+    void *context)
+{
+
+	panic("");
+	return (NULL);
+	
+}
+
+int
+taskqueue_start_threads(struct taskqueue **tqp, int count, int pri,
+    const char *name, ...)
+{
+
+
+	panic("");
+	return (0);
+}
+
+int
+taskqueue_enqueue(struct taskqueue *queue, struct task *task)
+{
+
+	panic("");
+	return (0);
+}
+
+
+void
+taskqueue_drain(struct taskqueue *queue, struct task *task)
+{
+	
+	panic("");
+}
+
+void
+taskqueue_free(struct taskqueue *queue)
+{
+
+	panic("");	
+}
+
+void
+taskqueue_thread_enqueue(void *context)
+{
+	panic("");
+	
+}
+

Modified: user/kmacy/releng_8_rump/lib/libunet/unet_uma_core.c
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/unet_uma_core.c	Mon Jan  4 05:27:49 2010	(r201472)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_uma_core.c	Mon Jan  4 05:39:00 2010	(r201473)
@@ -92,6 +92,28 @@ __FBSDID("$FreeBSD$");
 
 #undef UMA_MD_SMALL_ALLOC
 
+uma_slab_t
+vtoslab(vm_offset_t va)
+{
+
+	panic("");
+	return (NULL);
+}
+
+void
+vsetslab(vm_offset_t va, uma_slab_t slab)
+{
+
+	panic("");
+}
+
+
+void
+vsetobj(vm_offset_t va, vm_object_t obj)
+{
+
+	panic("");
+}
 /*
  * This is the zone and keg from which all zones are spawned.  The idea is that
  * even the zone & keg heads are allocated from the allocator, so we use the

From owner-svn-src-user@FreeBSD.ORG  Mon Jan  4 08:26:34 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 9FC3F10656A3;
	Mon,  4 Jan 2010 08:26:34 +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 75FA48FC22;
	Mon,  4 Jan 2010 08:26:34 +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 o048QY84001958;
	Mon, 4 Jan 2010 08:26:34 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o048QYsD001957;
	Mon, 4 Jan 2010 08:26:34 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001040826.o048QYsD001957@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Mon, 4 Jan 2010 08:26:34 +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: r201474 - user/kmacy/releng_8_rump/sys/kern
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 08:26:34 -0000

Author: kmacy
Date: Mon Jan  4 08:26:34 2010
New Revision: 201474
URL: http://svn.freebsd.org/changeset/base/201474

Log:
  exclude parts that are file specific from UNET

Modified:
  user/kmacy/releng_8_rump/sys/kern/sys_generic.c

Modified: user/kmacy/releng_8_rump/sys/kern/sys_generic.c
==============================================================================
--- user/kmacy/releng_8_rump/sys/kern/sys_generic.c	Mon Jan  4 05:39:00 2010	(r201473)
+++ user/kmacy/releng_8_rump/sys/kern/sys_generic.c	Mon Jan  4 08:26:34 2010	(r201474)
@@ -62,7 +62,9 @@ __FBSDID("$FreeBSD$");
 #include <sys/syscallsubr.h>
 #include <sys/sysctl.h>
 #include <sys/sysent.h>
+#ifndef UNET
 #include <sys/vnode.h>
+#endif
 #include <sys/bio.h>
 #include <sys/buf.h>
 #include <sys/condvar.h>
@@ -92,6 +94,35 @@ static void	seltdinit(struct thread *);
 static int	seltdwait(struct thread *, int);
 static void	seltdclear(struct thread *);
 
+#ifdef UNET
+static int
+dofileread(td, fd, fp, auio, offset, flags)
+	struct thread *td;
+	int fd;
+	struct file *fp;
+	struct uio *auio;
+	off_t offset;
+	int flags;
+{
+	panic("");
+	return (0);
+}
+
+
+static int
+dofilewrite(td, fd, fp, auio, offset, flags)
+	struct thread *td;
+	int fd;
+	struct file *fp;
+	struct uio *auio;
+	off_t offset;
+	int flags;
+{
+	
+	panic("");
+	return (0);
+}
+#endif
 /*
  * One seltd per-thread allocated on demand as needed.
  *
@@ -154,6 +185,7 @@ read(td, uap)
 	return(error);
 }
 
+#ifndef UNET
 /*
  * Positioned read system call
  */
@@ -200,6 +232,7 @@ freebsd6_pread(td, uap)
 	oargs.offset = uap->offset;
 	return (pread(td, &oargs));
 }
+#endif
 
 /*
  * Scatter read system call.
@@ -239,6 +272,7 @@ kern_readv(struct thread *td, int fd, st
 	return (error);
 }
 
+#ifndef UNET
 /*
  * Scatter positioned read system call.
  */
@@ -334,6 +368,7 @@ dofileread(td, fd, fp, auio, offset, fla
 	td->td_retval[0] = cnt;
 	return (error);
 }
+#endif
 
 #ifndef _SYS_SYSPROTO_H_
 struct write_args {
@@ -363,6 +398,7 @@ write(td, uap)
 	return(error);
 }
 
+#ifndef UNET
 /*
  * Positioned write system call.
  */
@@ -409,6 +445,7 @@ freebsd6_pwrite(td, uap)
 	oargs.offset = uap->offset;
 	return (pwrite(td, &oargs));
 }
+#endif
 
 /*
  * Gather write system call.
@@ -448,6 +485,7 @@ kern_writev(struct thread *td, int fd, s
 	return (error);
 }
 
+#ifndef UNET
 /*
  * Gather positioned write system call.
  */
@@ -610,6 +648,7 @@ oftruncate(td, uap)
 	return (kern_ftruncate(td, uap->fd, uap->length));
 }
 #endif /* COMPAT_43 */
+#endif
 
 #ifndef _SYS_SYSPROTO_H_
 struct ioctl_args {
@@ -750,7 +789,7 @@ poll_no_poll(int events)
 
 	return (events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM));
 }
-
+#ifndef UNET
 int
 pselect(struct thread *td, struct pselect_args *uap)
 {
@@ -802,6 +841,7 @@ kern_pselect(struct thread *td, int nd, 
 	error = kern_select(td, nd, in, ou, ex, tvp, abi_nfdbits);
 	return (error);
 }
+#endif
 
 #ifndef _SYS_SYSPROTO_H_
 struct select_args {

From owner-svn-src-user@FreeBSD.ORG  Mon Jan  4 08:33:33 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 D17181065693;
	Mon,  4 Jan 2010 08:33:33 +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 BFC5C8FC08;
	Mon,  4 Jan 2010 08:33:33 +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 o048XXtV003540;
	Mon, 4 Jan 2010 08:33:33 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o048XX0a003533;
	Mon, 4 Jan 2010 08:33:33 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001040833.o048XX0a003533@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Mon, 4 Jan 2010 08:33:33 +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: r201475 - 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 08:33:33 -0000

Author: kmacy
Date: Mon Jan  4 08:33:33 2010
New Revision: 201475
URL: http://svn.freebsd.org/changeset/base/201475

Log:
  shim or stub all remaining functions except kmem, critical, and spinlock

Added:
  user/kmacy/releng_8_rump/lib/libunet/unet_in_cksum.c   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/unet_kern_condvar.c   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/unet_kern_descrip.c   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/unet_kern_timeout.c   (contents, props changed)
Modified:
  user/kmacy/releng_8_rump/lib/libunet/Makefile
  user/kmacy/releng_8_rump/lib/libunet/unet_glue.c
  user/kmacy/releng_8_rump/lib/libunet/unet_kern_subr.c
  user/kmacy/releng_8_rump/lib/libunet/unet_kern_synch.c
  user/kmacy/releng_8_rump/lib/libunet/unet_subr_taskqueue.c

Modified: user/kmacy/releng_8_rump/lib/libunet/Makefile
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/Makefile	Mon Jan  4 08:26:34 2010	(r201474)
+++ user/kmacy/releng_8_rump/lib/libunet/Makefile	Mon Jan  4 08:33:33 2010	(r201475)
@@ -15,12 +15,15 @@ UNET_KERN_COMMON_OBJS +=	\
 	kern_malloc.o		\
 	kern_mbuf.o		\
 	kern_module.o		\
+	kern_mtxpool.o		\
 	kern_sysctl.o		\
 	md5c.o			\
 	subr_eventhandler.o	\
 	subr_param.o		\
 	subr_pcpu.o		\
 	subr_sbuf.o		\
+	sys_generic.o		\
+	sys_socket.o		\
 	uipc_accf.o		\
 	uipc_mbuf.o		\
 	uipc_mbuf2.o		\
@@ -90,18 +93,22 @@ UNET_LIBKERN_COMMON_OBJS =	\
 	strncmp.o		\
 	strtoul.o
 
-UNET_RANDOM_COMMON_OBJS =	\
+UNET_OTHER_COMMON_OBJS =	\
 	harvest.o
 
 UNET_GLUE_COMMON_OBJS =		\
 	unet_compat.o		\
 	unet_glue.o		\
-	unet_init_main.c	\
+	unet_in_cksum.o	\
+	unet_init_main.o	\
 	unet_lock.o		\
 	unet_uma_core.c		\
+	unet_kern_condvar.o	\
+	unet_kern_descrip.o	\
 	unet_kern_intr.o	\
 	unet_kern_synch.o	\
 	unet_kern_subr.o	\
+	unet_kern_timeout.o	\
 	unet_subr_taskqueue.o
 
 #	unet_init.o		\
@@ -113,7 +120,7 @@ UNET_COMMON_OBJS =			\
 	${UNET_LIBKERN_COMMON_OBJS}	\
 	${UNET_NET_COMMON_OBJS}		\
 	${UNET_NETINET_COMMON_OBJS}	\
-	${UNET_RANDOM_COMMON_OBJS}	\
+	${UNET_OTHER_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	Mon Jan  4 08:26:34 2010	(r201474)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_glue.c	Mon Jan  4 08:33:33 2010	(r201475)
@@ -34,8 +34,6 @@ SYSCTL_NODE(, CTL_NET,	  net,    CTLFLAG
 SYSCTL_NODE(, CTL_VM,	  vm,    CTLFLAG_RW, 0,
 	"Virtual memory");
 
-MALLOC_DEFINE(M_IOV, "iov", "large iov's");
-
 
 int	ticks;
 
@@ -596,8 +594,6 @@ securelevel_gt(struct ucred *cr, int lev
 }
 
 
-
-
 /**
  * @brief Send a 'notification' to userland, using standard ways
  */
@@ -614,3 +610,22 @@ cpu_pcpu_init(struct pcpu *pcpu, int cpu
 	;	
 }
 
+/*
+ * Send a SIGIO or SIGURG signal to a process or process group using stored
+ * credentials rather than those of the current process.
+ */
+void
+pgsigio(sigiop, sig, checkctty)
+	struct sigio **sigiop;
+	int sig, checkctty;
+{
+
+	panic("");
+}
+
+void
+kproc_exit(int ecode)
+{
+	panic("");
+}
+

Added: user/kmacy/releng_8_rump/lib/libunet/unet_in_cksum.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_in_cksum.c	Mon Jan  4 08:33:33 2010	(r201475)
@@ -0,0 +1,491 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * 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.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS 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.
+ *
+ *	from tahoe:	in_cksum.c	1.2	86/01/05
+ *	from:		@(#)in_cksum.c	1.3 (Berkeley) 1/19/91
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/mbuf.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+
+#include <machine/in_cksum.h>
+
+/*
+ * Checksum routine for Internet Protocol family headers.
+ *
+ * This routine is very heavily used in the network
+ * code and should be modified for each CPU to be as fast as possible.
+ *
+ * This implementation is 386 version.
+ */
+
+#undef	ADDCARRY
+#define ADDCARRY(x)     if ((x) > 0xffff) (x) -= 0xffff
+/*
+ * icc needs to be special cased here, as the asm code below results
+ * in broken code if compiled with icc.
+ */
+#if !defined(__GNUCLIKE_ASM) || defined(__INTEL_COMPILER)  || defined(UNET)
+/* non gcc parts stolen from sys/alpha/alpha/in_cksum.c */
+#define REDUCE32							  \
+    {									  \
+	q_util.q = sum;							  \
+	sum = q_util.s[0] + q_util.s[1] + q_util.s[2] + q_util.s[3];	  \
+    }
+#define REDUCE16							  \
+    {									  \
+	q_util.q = sum;							  \
+	l_util.l = q_util.s[0] + q_util.s[1] + q_util.s[2] + q_util.s[3]; \
+	sum = l_util.s[0] + l_util.s[1];				  \
+	ADDCARRY(sum);							  \
+    }
+#endif
+#define REDUCE          {sum = (sum & 0xffff) + (sum >> 16); ADDCARRY(sum);}
+
+#if !defined(__GNUCLIKE_ASM) || defined(__INTEL_COMPILER) || defined(UNET)
+static const u_int32_t in_masks[] = {
+	/*0 bytes*/ /*1 byte*/	/*2 bytes*/ /*3 bytes*/
+	0x00000000, 0x000000FF, 0x0000FFFF, 0x00FFFFFF,	/* offset 0 */
+	0x00000000, 0x0000FF00, 0x00FFFF00, 0xFFFFFF00,	/* offset 1 */
+	0x00000000, 0x00FF0000, 0xFFFF0000, 0xFFFF0000,	/* offset 2 */
+	0x00000000, 0xFF000000, 0xFF000000, 0xFF000000,	/* offset 3 */
+};
+
+union l_util {
+	u_int16_t s[2];
+	u_int32_t l;
+};
+union q_util {
+	u_int16_t s[4];
+	u_int32_t l[2];
+	u_int64_t q;
+};
+
+static u_int64_t
+in_cksumdata(const u_int32_t *lw, int len)
+{
+	u_int64_t sum = 0;
+	u_int64_t prefilled;
+	int offset;
+	union q_util q_util;
+
+	if ((3 & (long) lw) == 0 && len == 20) {
+	     sum = (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3] + lw[4];
+	     REDUCE32;
+	     return sum;
+	}
+
+	if ((offset = 3 & (long) lw) != 0) {
+		const u_int32_t *masks = in_masks + (offset << 2);
+		lw = (u_int32_t *) (((long) lw) - offset);
+		sum = *lw++ & masks[len >= 3 ? 3 : len];
+		len -= 4 - offset;
+		if (len <= 0) {
+			REDUCE32;
+			return sum;
+		}
+	}
+#if 0
+	/*
+	 * Force to cache line boundary.
+	 */
+	offset = 32 - (0x1f & (long) lw);
+	if (offset < 32 && len > offset) {
+		len -= offset;
+		if (4 & offset) {
+			sum += (u_int64_t) lw[0];
+			lw += 1;
+		}
+		if (8 & offset) {
+			sum += (u_int64_t) lw[0] + lw[1];
+			lw += 2;
+		}
+		if (16 & offset) {
+			sum += (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3];
+			lw += 4;
+		}
+	}
+#endif
+	/*
+	 * access prefilling to start load of next cache line.
+	 * then add current cache line
+	 * save result of prefilling for loop iteration.
+	 */
+	prefilled = lw[0];
+	while ((len -= 32) >= 4) {
+		u_int64_t prefilling = lw[8];
+		sum += prefilled + lw[1] + lw[2] + lw[3]
+			+ lw[4] + lw[5] + lw[6] + lw[7];
+		lw += 8;
+		prefilled = prefilling;
+	}
+	if (len >= 0) {
+		sum += prefilled + lw[1] + lw[2] + lw[3]
+			+ lw[4] + lw[5] + lw[6] + lw[7];
+		lw += 8;
+	} else {
+		len += 32;
+	}
+	while ((len -= 16) >= 0) {
+		sum += (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3];
+		lw += 4;
+	}
+	len += 16;
+	while ((len -= 4) >= 0) {
+		sum += (u_int64_t) *lw++;
+	}
+	len += 4;
+	if (len > 0)
+		sum += (u_int64_t) (in_masks[len] & *lw);
+	REDUCE32;
+	return sum;
+}
+
+u_short
+in_addword(u_short a, u_short b)
+{
+	u_int64_t sum = a + b;
+
+	ADDCARRY(sum);
+	return (sum);
+}
+
+u_short
+in_pseudo(u_int32_t a, u_int32_t b, u_int32_t c)
+{
+	u_int64_t sum;
+	union q_util q_util;
+	union l_util l_util;
+		    
+	sum = (u_int64_t) a + b + c;
+	REDUCE16;
+	return (sum);
+}
+
+u_short
+in_cksum_skip(struct mbuf *m, int len, int skip)
+{
+	u_int64_t sum = 0;
+	int mlen = 0;
+	int clen = 0;
+	caddr_t addr;
+	union q_util q_util;
+	union l_util l_util;
+
+        len -= skip;
+        for (; skip && m; m = m->m_next) {
+                if (m->m_len > skip) {
+                        mlen = m->m_len - skip;
+			addr = mtod(m, caddr_t) + skip;
+                        goto skip_start;
+                } else {
+                        skip -= m->m_len;
+                }
+        }
+
+	for (; m && len; m = m->m_next) {
+		if (m->m_len == 0)
+			continue;
+		mlen = m->m_len;
+		addr = mtod(m, caddr_t);
+skip_start:
+		if (len < mlen)
+			mlen = len;
+		if ((clen ^ (long) addr) & 1)
+		    sum += in_cksumdata((const u_int32_t *)addr, mlen) << 8;
+		else
+		    sum += in_cksumdata((const u_int32_t *)addr, mlen);
+
+		clen += mlen;
+		len -= mlen;
+	}
+	REDUCE16;
+	return (~sum & 0xffff);
+}
+
+u_int in_cksum_hdr(const struct ip *ip)
+{
+    u_int64_t sum = in_cksumdata((const u_int32_t *)ip, sizeof(struct ip));
+    union q_util q_util;
+    union l_util l_util;
+
+    REDUCE16;
+    return (~sum & 0xffff);
+}
+#else
+
+/*
+ * These asm statements require __volatile because they pass information
+ * via the condition codes.  GCC does not currently provide a way to specify
+ * the condition codes as an input or output operand.
+ *
+ * The LOAD macro below is effectively a prefetch into cache.  GCC will
+ * load the value into a register but will not use it.  Since modern CPUs
+ * reorder operations, this will generally take place in parallel with
+ * other calculations.
+ */
+u_short
+in_cksum_skip(m, len, skip)
+	struct mbuf *m;
+	int len;
+	int skip;
+{
+	register u_short *w;
+	register unsigned sum = 0;
+	register int mlen = 0;
+	int byte_swapped = 0;
+	union { char	c[2]; u_short	s; } su;
+
+	len -= skip;
+	for (; skip && m; m = m->m_next) {
+		if (m->m_len > skip) {
+			mlen = m->m_len - skip;
+			w = (u_short *)(mtod(m, u_char *) + skip);
+			goto skip_start;
+		} else {
+			skip -= m->m_len;
+		}
+	}
+
+	for (;m && len; m = m->m_next) {
+		if (m->m_len == 0)
+			continue;
+		w = mtod(m, u_short *);
+		if (mlen == -1) {
+			/*
+			 * The first byte of this mbuf is the continuation
+			 * of a word spanning between this mbuf and the
+			 * last mbuf.
+			 */
+
+			/* su.c[0] is already saved when scanning previous
+			 * mbuf.  sum was REDUCEd when we found mlen == -1
+			 */
+			su.c[1] = *(u_char *)w;
+			sum += su.s;
+			w = (u_short *)((char *)w + 1);
+			mlen = m->m_len - 1;
+			len--;
+		} else
+			mlen = m->m_len;
+skip_start:
+		if (len < mlen)
+			mlen = len;
+		len -= mlen;
+		/*
+		 * Force to long boundary so we do longword aligned
+		 * memory operations
+		 */
+		if (3 & (int) w) {
+			REDUCE;
+			if ((1 & (int) w) && (mlen > 0)) {
+				sum <<= 8;
+				su.c[0] = *(char *)w;
+				w = (u_short *)((char *)w + 1);
+				mlen--;
+				byte_swapped = 1;
+			}
+			if ((2 & (int) w) && (mlen >= 2)) {
+				sum += *w++;
+				mlen -= 2;
+			}
+		}
+		/*
+		 * Advance to a 486 cache line boundary.
+		 */
+		if (4 & (int) w && mlen >= 4) {
+			__asm __volatile (
+				"addl %1, %0\n"
+				"adcl $0, %0"
+				: "+r" (sum)
+				: "g" (((const u_int32_t *)w)[0])
+			);
+			w += 2;
+			mlen -= 4;
+		}
+		if (8 & (int) w && mlen >= 8) {
+			__asm __volatile (
+				"addl %1, %0\n"
+				"adcl %2, %0\n"
+				"adcl $0, %0"
+				: "+r" (sum)
+				: "g" (((const u_int32_t *)w)[0]),
+				  "g" (((const u_int32_t *)w)[1])
+			);
+			w += 4;
+			mlen -= 8;
+		}
+		/*
+		 * Do as much of the checksum as possible 32 bits at at time.
+		 * In fact, this loop is unrolled to make overhead from
+		 * branches &c small.
+		 */
+		mlen -= 1;
+		while ((mlen -= 32) >= 0) {
+			/*
+			 * Add with carry 16 words and fold in the last
+			 * carry by adding a 0 with carry.
+			 *
+			 * The early ADD(16) and the LOAD(32) are to load
+			 * the next 2 cache lines in advance on 486's.  The
+			 * 486 has a penalty of 2 clock cycles for loading
+			 * a cache line, plus whatever time the external
+			 * memory takes to load the first word(s) addressed.
+			 * These penalties are unavoidable.  Subsequent
+			 * accesses to a cache line being loaded (and to
+			 * other external memory?) are delayed until the
+			 * whole load finishes.  These penalties are mostly
+			 * avoided by not accessing external memory for
+			 * 8 cycles after the ADD(16) and 12 cycles after
+			 * the LOAD(32).  The loop terminates when mlen
+			 * is initially 33 (not 32) to guaranteed that
+			 * the LOAD(32) is within bounds.
+			 */
+			__asm __volatile (
+				"addl %1, %0\n"
+				"adcl %2, %0\n"
+				"adcl %3, %0\n"
+				"adcl %4, %0\n"
+				"adcl %5, %0\n"
+				"mov  %6, %%eax\n"
+				"adcl %7, %0\n"
+				"adcl %8, %0\n"
+				"adcl %9, %0\n"
+				"adcl $0, %0"
+				: "+r" (sum)
+				: "g" (((const u_int32_t *)w)[4]),
+				  "g" (((const u_int32_t *)w)[0]),
+				  "g" (((const u_int32_t *)w)[1]),
+				  "g" (((const u_int32_t *)w)[2]),
+				  "g" (((const u_int32_t *)w)[3]),
+				  "g" (((const u_int32_t *)w)[8]),
+				  "g" (((const u_int32_t *)w)[5]),
+				  "g" (((const u_int32_t *)w)[6]),
+				  "g" (((const u_int32_t *)w)[7])
+				: "eax"
+			);
+			w += 16;
+		}
+		mlen += 32 + 1;
+		if (mlen >= 32) {
+			__asm __volatile (
+				"addl %1, %0\n"
+				"adcl %2, %0\n"
+				"adcl %3, %0\n"
+				"adcl %4, %0\n"
+				"adcl %5, %0\n"
+				"adcl %6, %0\n"
+				"adcl %7, %0\n"
+				"adcl %8, %0\n"
+				"adcl $0, %0"
+				: "+r" (sum)
+				: "g" (((const u_int32_t *)w)[4]),
+				  "g" (((const u_int32_t *)w)[0]),
+				  "g" (((const u_int32_t *)w)[1]),
+				  "g" (((const u_int32_t *)w)[2]),
+				  "g" (((const u_int32_t *)w)[3]),
+				  "g" (((const u_int32_t *)w)[5]),
+				  "g" (((const u_int32_t *)w)[6]),
+				  "g" (((const u_int32_t *)w)[7])
+			);
+			w += 16;
+			mlen -= 32;
+		}
+		if (mlen >= 16) {
+			__asm __volatile (
+				"addl %1, %0\n"
+				"adcl %2, %0\n"
+				"adcl %3, %0\n"
+				"adcl %4, %0\n"
+				"adcl $0, %0"
+				: "+r" (sum)
+				: "g" (((const u_int32_t *)w)[0]),
+				  "g" (((const u_int32_t *)w)[1]),
+				  "g" (((const u_int32_t *)w)[2]),
+				  "g" (((const u_int32_t *)w)[3])
+			);
+			w += 8;
+			mlen -= 16;
+		}
+		if (mlen >= 8) {
+			__asm __volatile (
+				"addl %1, %0\n"
+				"adcl %2, %0\n"
+				"adcl $0, %0"
+				: "+r" (sum)
+				: "g" (((const u_int32_t *)w)[0]),
+				  "g" (((const u_int32_t *)w)[1])
+			);
+			w += 4;
+			mlen -= 8;
+		}
+		if (mlen == 0 && byte_swapped == 0)
+			continue;       /* worth 1% maybe ?? */
+		REDUCE;
+		while ((mlen -= 2) >= 0) {
+			sum += *w++;
+		}
+		if (byte_swapped) {
+			sum <<= 8;
+			byte_swapped = 0;
+			if (mlen == -1) {
+				su.c[1] = *(char *)w;
+				sum += su.s;
+				mlen = 0;
+			} else
+				mlen = -1;
+		} else if (mlen == -1)
+			/*
+			 * This mbuf has odd number of bytes.
+			 * There could be a word split betwen
+			 * this mbuf and the next mbuf.
+			 * Save the last byte (to prepend to next mbuf).
+			 */
+			su.c[0] = *(char *)w;
+	}
+
+	if (len)
+		printf("%s: out of data by %d\n", __func__, len);
+	if (mlen == -1) {
+		/* The last mbuf has odd # of bytes. Follow the
+		   standard (the odd byte is shifted left by 8 bits) */
+		su.c[1] = 0;
+		sum += su.s;
+	}
+	REDUCE;
+	return (~sum & 0xffff);
+}
+#endif

Added: user/kmacy/releng_8_rump/lib/libunet/unet_kern_condvar.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_kern_condvar.c	Mon Jan  4 08:33:33 2010	(r201475)
@@ -0,0 +1,111 @@
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "opt_ktrace.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/proc.h>
+#include <sys/kernel.h>
+#include <sys/ktr.h>
+#include <sys/condvar.h>
+#include <sys/sched.h>
+#include <sys/signalvar.h>
+#include <sys/sleepqueue.h>
+#include <sys/resourcevar.h>
+
+/*
+ * Initialize a condition variable.  Must be called before use.
+ */
+void
+cv_init(struct cv *cvp, const char *desc)
+{
+
+	cvp->cv_description = desc;
+	cvp->cv_waiters = 0;
+}
+
+/*
+ * Destroy a condition variable.  The condition variable must be re-initialized
+ * in order to be re-used.
+ */
+void
+cv_destroy(struct cv *cvp)
+{
+#ifdef INVARIANTS
+	struct sleepqueue *sq;
+
+	sleepq_lock(cvp);
+	sq = sleepq_lookup(cvp);
+	sleepq_release(cvp);
+	KASSERT(sq == NULL, ("%s: associated sleep queue non-empty", __func__));
+#endif
+}
+
+/*
+ * Wait on a condition variable.  The current thread is placed on the condition
+ * variable's wait queue and suspended.  A cv_signal or cv_broadcast on the same
+ * condition variable will resume the thread.  The mutex is released before
+ * sleeping and will be held on return.  It is recommended that the mutex be
+ * held when cv_signal or cv_broadcast are called.
+ */
+void
+_cv_wait(struct cv *cvp, struct lock_object *lock)
+{
+	panic("");
+	
+}
+
+/*
+ * Wait on a condition variable, allowing interruption by signals.  Return 0 if
+ * the thread was resumed with cv_signal or cv_broadcast, EINTR or ERESTART if
+ * a signal was caught.  If ERESTART is returned the system call should be
+ * restarted if possible.
+ */
+int
+_cv_wait_sig(struct cv *cvp, struct lock_object *lock)
+{
+	panic("");
+
+	return (0);
+}
+
+/*
+ * Wait on a condition variable for at most timo/hz seconds.  Returns 0 if the
+ * process was resumed by cv_signal or cv_broadcast, EWOULDBLOCK if the timeout
+ * expires.
+ */
+int
+_cv_timedwait(struct cv *cvp, struct lock_object *lock, int timo)
+{
+	panic("");
+	
+	return (0);
+}
+
+/*
+ * Wait on a condition variable for at most timo/hz seconds, allowing
+ * interruption by signals.  Returns 0 if the thread was resumed by cv_signal
+ * or cv_broadcast, EWOULDBLOCK if the timeout expires, and EINTR or ERESTART if
+ * a signal was caught.
+ */
+int
+_cv_timedwait_sig(struct cv *cvp, struct lock_object *lock, int timo)
+{
+	panic("");
+
+	return (0);
+}
+
+/*
+ * Broadcast a signal to a condition variable.  Wakes up all waiting threads.
+ * Should be called with the same mutex as was passed to cv_wait held.
+ */
+void
+cv_broadcastpri(struct cv *cvp, int pri)
+{
+	panic("");
+	
+}

Added: user/kmacy/releng_8_rump/lib/libunet/unet_kern_descrip.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_kern_descrip.c	Mon Jan  4 08:33:33 2010	(r201475)
@@ -0,0 +1,308 @@
+
+
+/*-
+ * Copyright (c) 1982, 1986, 1989, 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * 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.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS 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.
+ *
+ *	@(#)kern_descrip.c	8.6 (Berkeley) 4/19/94
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "opt_compat.h"
+#include "opt_ddb.h"
+#include "opt_ktrace.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+
+#include <sys/conf.h>
+#include <sys/domain.h>
+#include <sys/fcntl.h>
+#include <sys/file.h>
+#include <sys/filedesc.h>
+#include <sys/filio.h>
+#include <sys/jail.h>
+#include <sys/kernel.h>
+#include <sys/limits.h>
+#include <sys/lock.h>
+#include <sys/malloc.h>
+#include <sys/mount.h>
+#include <sys/mqueue.h>
+#include <sys/mutex.h>
+#include <sys/namei.h>
+#include <sys/priv.h>
+#include <sys/proc.h>
+#include <sys/protosw.h>
+#include <sys/resourcevar.h>
+#include <sys/signalvar.h>
+#include <sys/socketvar.h>
+#include <sys/stat.h>
+#include <sys/sx.h>
+#include <sys/syscallsubr.h>
+#include <sys/sysctl.h>
+#include <sys/sysproto.h>
+#include <sys/tty.h>
+#include <sys/unistd.h>
+#include <sys/user.h>
+
+
+/*
+ * This is common code for FIOSETOWN ioctl called by fcntl(fd, F_SETOWN, arg).
+ *
+ * After permission checking, add a sigio structure to the sigio list for
+ * the process or process group.
+ */
+int
+fsetown(pid_t pgid, struct sigio **sigiop)
+{
+
+	panic("");
+
+	return (0);
+}
+	
+pid_t
+fgetown(struct sigio **sigiop)
+{
+	
+	panic("");
+	return (0);
+}
+
+		
+void
+funsetown(struct sigio **sigiop)
+{
+
+	panic("");
+}
+
+
+/*
+ * Create a new open file structure and allocate a file decriptor for the
+ * process that refers to it.  We add one reference to the file for the
+ * descriptor table and one reference for resultfp. This is to prevent us
+ * being preempted and the entry in the descriptor table closed after we
+ * release the FILEDESC lock.
+ */
+int
+falloc(struct thread *td, struct file **resultfp, int *resultfd)
+{
+	panic("");
+
+	return (0);
+}
+
+
+/*
+ * Handle the last reference to a file being closed.
+ */
+int
+_fdrop(struct file *fp, struct thread *td)
+{
+
+	panic("");
+	return (0);
+}
+	
+void
+finit(struct file *fp, u_int flag, short type, void *data, struct fileops *ops)
+{
+	fp->f_data = data;
+	fp->f_flag = flag;
+	fp->f_type = type;
+	atomic_store_rel_ptr((volatile uintptr_t *)&fp->f_ops, (uintptr_t)ops);
+}
+
+struct file *
+fget_unlocked(struct filedesc *fdp, int fd)
+{
+	struct file *fp;
+	u_int count;
+
+	if (fd < 0 || fd >= fdp->fd_nfiles)
+		return (NULL);
+	/*
+	 * Fetch the descriptor locklessly.  We avoid fdrop() races by
+	 * never raising a refcount above 0.  To accomplish this we have
+	 * to use a cmpset loop rather than an atomic_add.  The descriptor
+	 * must be re-verified once we acquire a reference to be certain
+	 * that the identity is still correct and we did not lose a race
+	 * due to preemption.
+	 */
+	for (;;) {
+		fp = fdp->fd_ofiles[fd];
+		if (fp == NULL)
+			break;
+		count = fp->f_count;
+		if (count == 0)
+			continue;
+		/*
+		 * Use an acquire barrier to prevent caching of fd_ofiles
+		 * so it is refreshed for verification.
+		 */
+		if (atomic_cmpset_acq_int(&fp->f_count, count, count + 1) != 1)
+			continue;
+		if (fp == fdp->fd_ofiles[fd])
+			break;
+		fdrop(fp, curthread);
+	}
+
+	return (fp);
+}
+
+
+/*
+ * Extract the file pointer associated with the specified descriptor for the
+ * current user process.
+ *
+ * If the descriptor doesn't exist or doesn't match 'flags', EBADF is
+ * returned.
+ *
+ * If an error occured the non-zero error is returned and *fpp is set to
+ * NULL.  Otherwise *fpp is held and set and zero is returned.  Caller is
+ * responsible for fdrop().
+ */
+static __inline int
+_fget(struct thread *td, int fd, struct file **fpp, int flags)
+{
+	struct filedesc *fdp;
+	struct file *fp;
+
+	*fpp = NULL;
+	if (td == NULL || (fdp = td->td_proc->p_fd) == NULL)
+		return (EBADF);
+	if ((fp = fget_unlocked(fdp, fd)) == NULL)
+		return (EBADF);
+	if (fp->f_ops == &badfileops) {
+		fdrop(fp, td);
+		return (EBADF);
+	}
+	/*
+	 * FREAD and FWRITE failure return EBADF as per POSIX.
+	 *
+	 * Only one flag, or 0, may be specified.
+	 */
+	if ((flags == FREAD && (fp->f_flag & FREAD) == 0) ||
+	    (flags == FWRITE && (fp->f_flag & FWRITE) == 0)) {
+		fdrop(fp, td);
+		return (EBADF);
+	}
+	*fpp = fp;
+	return (0);
+}
+
+int
+fget(struct thread *td, int fd, struct file **fpp)
+{
+
+	return(_fget(td, fd, fpp, 0));
+}
+
+int
+fget_read(struct thread *td, int fd, struct file **fpp)
+{
+
+	return(_fget(td, fd, fpp, FREAD));
+}
+
+int
+fget_write(struct thread *td, int fd, struct file **fpp)
+{
+
+	return(_fget(td, fd, fpp, FWRITE));
+}
+
+
+/*-------------------------------------------------------------------*/
+
+static int
+badfo_readwrite(struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, struct thread *td)
+{
+
+	return (EBADF);
+}
+
+static int
+badfo_truncate(struct file *fp, off_t length, struct ucred *active_cred, struct thread *td)
+{
+
+	return (EINVAL);
+}
+
+static int
+badfo_ioctl(struct file *fp, u_long com, void *data, struct ucred *active_cred, struct thread *td)
+{
+
+	return (EBADF);
+}
+
+static int
+badfo_poll(struct file *fp, int events, struct ucred *active_cred, struct thread *td)
+{
+
+	return (0);
+}
+
+static int
+badfo_kqfilter(struct file *fp, struct knote *kn)
+{
+
+	return (EBADF);
+}
+
+static int
+badfo_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, struct thread *td)
+{
+
+	return (EBADF);
+}
+
+static int
+badfo_close(struct file *fp, struct thread *td)
+{

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***

From owner-svn-src-user@FreeBSD.ORG  Mon Jan  4 09:02:39 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 A2BE81065679;
	Mon,  4 Jan 2010 09:02:39 +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 923148FC1B;
	Mon,  4 Jan 2010 09:02:39 +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 o0492db5009991;
	Mon, 4 Jan 2010 09:02:39 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o0492dkj009987;
	Mon, 4 Jan 2010 09:02:39 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001040902.o0492dkj009987@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Mon, 4 Jan 2010 09:02:39 +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: r201476 - 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 09:02:39 -0000

Author: kmacy
Date: Mon Jan  4 09:02:39 2010
New Revision: 201476
URL: http://svn.freebsd.org/changeset/base/201476

Log:
  add kmem definitions, remove kern_malloc.c due to use kmem_suballoc

Modified:
  user/kmacy/releng_8_rump/lib/libunet/Makefile
  user/kmacy/releng_8_rump/lib/libunet/unet_compat.c
  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	Mon Jan  4 08:33:33 2010	(r201475)
+++ user/kmacy/releng_8_rump/lib/libunet/Makefile	Mon Jan  4 09:02:39 2010	(r201476)
@@ -12,7 +12,6 @@ LIB=	unet
 UNET_KERN_COMMON_OBJS +=	\
 	kern_environment.o	\
 	kern_event.o		\
-	kern_malloc.o		\
 	kern_mbuf.o		\
 	kern_module.o		\
 	kern_mtxpool.o		\

Modified: user/kmacy/releng_8_rump/lib/libunet/unet_compat.c
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/unet_compat.c	Mon Jan  4 08:33:33 2010	(r201475)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_compat.c	Mon Jan  4 09:02:39 2010	(r201476)
@@ -2,11 +2,30 @@
 #define _WANT_UCRED
 #include <stdlib.h>
 #include <sys/types.h>
+#include <sys/mman.h>
 #include <sys/refcount.h>
 #include <sys/ucred.h>
 
 struct malloc_type;
-#if 0
+
+vm_offset_t kmem_malloc(void * map, int bytes, int wait);
+void kmem_free(void *map, vm_offset_t addr, vm_size_t size);
+
+vm_offset_t
+kmem_malloc(void * map, int bytes, int wait)
+{
+
+	return ((vm_offset_t)mmap(NULL, bytes, PROT_READ|PROT_WRITE, MAP_ANON, -1, 0));
+}
+
+
+void
+kmem_free(void *map, vm_offset_t addr, vm_size_t size)
+{
+
+	munmap((void *)addr, size);
+}
+
 void *
 unet_malloc(unsigned long size, struct malloc_type *type, int flags)
 {
@@ -20,7 +39,7 @@ unet_free(void *addr, struct malloc_type
 
 	free(addr);
 }
-#endif
+
 /*
  * Claim another reference to a ucred structure.
  */

Modified: user/kmacy/releng_8_rump/lib/libunet/unet_glue.c
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/unet_glue.c	Mon Jan  4 08:33:33 2010	(r201475)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_glue.c	Mon Jan  4 09:02:39 2010	(r201476)
@@ -21,6 +21,7 @@
 #include <vm/pmap.h>
 #include <vm/vm_object.h>
 #include <vm/vm_map.h>
+#include <vm/vm_extern.h>
 
 SYSCTL_NODE(, 0,	  sysctl, CTLFLAG_RW, 0,
 	"Sysctl internal magic");
@@ -34,6 +35,9 @@ SYSCTL_NODE(, CTL_NET,	  net,    CTLFLAG
 SYSCTL_NODE(, CTL_VM,	  vm,    CTLFLAG_RW, 0,
 	"Virtual memory");
 
+MALLOC_DEFINE(M_DEVBUF, "devbuf", "device driver memory");
+MALLOC_DEFINE(M_TEMP, "temp", "misc temporary data buffers");
+
 
 int	ticks;
 
@@ -162,11 +166,10 @@ vslock(void *addr, size_t len)
 	return (0);
 }
 
-int
+void
 vsunlock(void *addr, size_t len)
 {
 
-	return (0);
 }
 
 
@@ -629,3 +632,90 @@ kproc_exit(int ecode)
 	panic("");
 }
 
+vm_offset_t
+kmem_alloc_contig(vm_map_t map, vm_size_t size, int flags, vm_paddr_t low,
+    vm_paddr_t high, unsigned long alignment, unsigned long boundary,
+    vm_memattr_t memattr)
+{
+	return (kmem_malloc(map, size, flags));
+}
+
+void
+malloc_init(void *data)
+{
+#ifdef notyet
+	struct malloc_type_internal *mtip;
+	struct malloc_type *mtp;
+
+	KASSERT(cnt.v_page_count != 0, ("malloc_register before vm_init"));
+
+	mtp = data;
+	if (mtp->ks_magic != M_MAGIC)
+		panic("malloc_init: bad malloc type magic");
+
+	mtip = uma_zalloc(mt_zone, M_WAITOK | M_ZERO);
+	mtp->ks_handle = mtip;
+
+	mtx_lock(&malloc_mtx);
+	mtp->ks_next = kmemstatistics;
+	kmemstatistics = mtp;
+	kmemcount++;
+	mtx_unlock(&malloc_mtx);
+#endif
+}
+
+void
+malloc_uninit(void *data)
+{
+#ifdef notyet
+	struct malloc_type_internal *mtip;
+	struct malloc_type_stats *mtsp;
+	struct malloc_type *mtp, *temp;
+	uma_slab_t slab;
+	long temp_allocs, temp_bytes;
+	int i;
+
+	mtp = data;
+	KASSERT(mtp->ks_magic == M_MAGIC,
+	    ("malloc_uninit: bad malloc type magic"));
+	KASSERT(mtp->ks_handle != NULL, ("malloc_deregister: cookie NULL"));
+
+	mtx_lock(&malloc_mtx);
+	mtip = mtp->ks_handle;
+	mtp->ks_handle = NULL;
+	if (mtp != kmemstatistics) {
+		for (temp = kmemstatistics; temp != NULL;
+		    temp = temp->ks_next) {
+			if (temp->ks_next == mtp) {
+				temp->ks_next = mtp->ks_next;
+				break;
+			}
+		}
+		KASSERT(temp,
+		    ("malloc_uninit: type '%s' not found", mtp->ks_shortdesc));
+	} else
+		kmemstatistics = mtp->ks_next;
+	kmemcount--;
+	mtx_unlock(&malloc_mtx);
+
+	/*
+	 * Look for memory leaks.
+	 */
+	temp_allocs = temp_bytes = 0;
+	for (i = 0; i < MAXCPU; i++) {
+		mtsp = &mtip->mti_stats[i];
+		temp_allocs += mtsp->mts_numallocs;
+		temp_allocs -= mtsp->mts_numfrees;
+		temp_bytes += mtsp->mts_memalloced;
+		temp_bytes -= mtsp->mts_memfreed;
+	}
+	if (temp_allocs > 0 || temp_bytes > 0) {
+		printf("Warning: memory type %s leaked memory on destroy "
+		    "(%ld allocations, %ld bytes leaked).\n", mtp->ks_shortdesc,
+		    temp_allocs, temp_bytes);
+	}
+
+	slab = vtoslab((vm_offset_t) mtip & (~UMA_SLAB_MASK));
+	uma_zfree_arg(mt_zone, mtip, slab);
+#endif
+}

From owner-svn-src-user@FreeBSD.ORG  Mon Jan  4 10:25:01 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 044F4106568F;
	Mon,  4 Jan 2010 10:25:01 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id E82D78FC29;
	Mon,  4 Jan 2010 10:25:00 +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 o04AP05S028412;
	Mon, 4 Jan 2010 10:25:00 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o04AP09P028409;
	Mon, 4 Jan 2010 10:25:00 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001041025.o04AP09P028409@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Mon, 4 Jan 2010 10:25:00 +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: r201483 - user/luigi/ipfw3-head/sys/netinet/ipfw
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 10:25:01 -0000

Author: luigi
Date: Mon Jan  4 10:25:00 2010
New Revision: 201483
URL: http://svn.freebsd.org/changeset/base/201483

Log:
  complete work on tag cleanup.

Modified:
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Mon Jan  4 09:59:18 2010	(r201482)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Mon Jan  4 10:25:00 2010	(r201483)
@@ -968,17 +968,21 @@ dummynet_send(struct mbuf *m)
 	for (; m != NULL; m = n) {
 		struct ifnet *ifp;
 		int dst;
+        	struct m_tag *tag;
 
 		n = m->m_nextpkt;
 		m->m_nextpkt = NULL;
-		if (m_tag_first(m) == NULL) {
+		tag = m_tag_first(m);
+		if (tag == NULL) {
 			dst = DIR_DROP;
 		} else {
 			struct dn_pkt_tag *pkt = dn_tag_get(m);
 			/* extract the dummynet info, rename the tag */
 			dst = pkt->dn_dir;
 			ifp = pkt->ifp;
-			// XXX rename the tag
+			/* rename the tag so it carries reinject info */
+			tag->m_tag_cookie = MTAG_IPFW_RULE;
+			tag->m_tag_id = 0;
 		}
 
 		switch (dst) {

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c	Mon Jan  4 09:59:18 2010	(r201482)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c	Mon Jan  4 10:25:00 2010	(r201483)
@@ -81,7 +81,7 @@ ip_divert_packet_t *ip_divert_ptr = NULL
 ng_ipfw_input_t *ng_ipfw_input_p = NULL;
 
 /* Forward declarations. */
-static void	ipfw_divert(struct mbuf **, int, int);
+static int ipfw_divert(struct mbuf **, int, struct ipfw_rule_ref *, int);
 
 #ifdef SYSCTL_NODE
 SYSCTL_DECL(_net_inet_ip_fw);
@@ -205,17 +205,9 @@ again:
 			ret = EACCES;
 			break; /* i.e. drop */
 		}
-		tag = m_tag_alloc(MTAG_IPFW_RULE, 0,
-		    sizeof(struct ipfw_rule_ref), M_NOWAIT);
-		if (tag == NULL) {
-			ret = EACCES;
-			break; /* i.e. drop */
-		}
-		*((struct ipfw_rule_ref *)(tag+1)) = args.rule;
-		m_tag_prepend(*m0, tag);
-
-		ipfw_divert(m0, dir, (ipfw == IP_FW_TEE) ? 1 : 0);
-		/* continue processing for the original packet (tee) */
+		ret = ipfw_divert(m0, dir, &args.rule,
+			(ipfw == IP_FW_TEE) ? 1 : 0);
+		/* continue processing for the original packet (tee). */
 		if (*m0)
 			goto again;
 		break;
@@ -250,8 +242,10 @@ again:
 	return ret;
 }
 
-static void
-ipfw_divert(struct mbuf **m0, int incoming, int tee)
+/* do the divert, return 1 on error 0 on success */
+static int
+ipfw_divert(struct mbuf **m0, int incoming, struct ipfw_rule_ref *rule,
+	int tee)
 {
 	/*
 	 * ipfw_chk() has already tagged the packet with the divert tag.
@@ -260,6 +254,7 @@ ipfw_divert(struct mbuf **m0, int incomi
 	 */
 	struct mbuf *clone;
 	struct ip *ip;
+	struct m_tag *tag;
 
 	/* Cloning needed for tee? */
 	if (tee == 0) {
@@ -271,7 +266,7 @@ ipfw_divert(struct mbuf **m0, int incomi
 		 * chain and continue with the tee-ed packet.
 		 */
 		if (clone == NULL)
-			return;
+			return 1;
 	}
 
 	/*
@@ -290,7 +285,7 @@ ipfw_divert(struct mbuf **m0, int incomi
 		SET_HOST_IPLEN(ip); /* ip_reass wants host order */
 		reass = ip_reass(clone); /* Reassemble packet. */
 		if (reass == NULL)
-			return;
+			return 0; /* not an error */
 		/* if reass = NULL then it was consumed by ip_reass */
 		/*
 		 * IP header checksum fixup after reassembly and leave header
@@ -306,9 +301,19 @@ ipfw_divert(struct mbuf **m0, int incomi
 			ip->ip_sum = in_cksum(reass, hlen);
 		clone = reass;
 	}
+	/* attach a tag to the packet with the reinject info */
+	tag = m_tag_alloc(MTAG_IPFW_RULE, 0,
+		    sizeof(struct ipfw_rule_ref), M_NOWAIT);
+	if (tag == NULL) {
+		FREE_PKT(clone);
+		return 1;
+	}
+	*((struct ipfw_rule_ref *)(tag+1)) = *rule;
+	m_tag_prepend(clone, tag);
 
 	/* Do the dirty job... */
 	ip_divert_ptr(clone, incoming);
+	return 0;
 }
 
 /*

From owner-svn-src-user@FreeBSD.ORG  Mon Jan  4 10:38:54 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 9FC6A1065693;
	Mon,  4 Jan 2010 10:38:54 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 8FF788FC22;
	Mon,  4 Jan 2010 10:38:54 +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 o04Acsjv031642;
	Mon, 4 Jan 2010 10:38:54 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o04Acs3M031640;
	Mon, 4 Jan 2010 10:38:54 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001041038.o04Acs3M031640@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Mon, 4 Jan 2010 10:38:54 +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: r201485 - user/luigi/ipfw3-head/sys/netinet/ipfw
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 10:38:54 -0000

Author: luigi
Date: Mon Jan  4 10:38:54 2010
New Revision: 201485
URL: http://svn.freebsd.org/changeset/base/201485

Log:
  more compact expression of variant function

Modified:
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c	Mon Jan  4 10:37:07 2010	(r201484)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c	Mon Jan  4 10:38:54 2010	(r201485)
@@ -322,17 +322,14 @@ ipfw_divert(struct mbuf **m0, int incomi
 static int
 ipfw_hook(int onoff, int pf)
 {
-	const int arg = PFIL_IN | PFIL_OUT | PFIL_WAITOK;
 	struct pfil_head *pfh;
 
 	pfh = pfil_head_get(PFIL_TYPE_AF, pf);
 	if (pfh == NULL)
 		return ENOENT;
 
-	if (onoff)
-		(void)pfil_add_hook(ipfw_check_hook, NULL, arg, pfh);
-	else
-		(void)pfil_remove_hook(ipfw_check_hook, NULL, arg, pfh);
+	(void) (onoff ? pfil_add_hook : pfil_remove_hook)
+	    (ipfw_check_hook, NULL, PFIL_IN | PFIL_OUT | PFIL_WAITOK, pfh);
 
 	return 0;
 }

From owner-svn-src-user@FreeBSD.ORG  Mon Jan  4 10:39:16 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 BDBB4106566C;
	Mon,  4 Jan 2010 10:39:16 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 949408FC14;
	Mon,  4 Jan 2010 10:39:16 +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 o04AdGhj031777;
	Mon, 4 Jan 2010 10:39:16 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o04AdGOf031775;
	Mon, 4 Jan 2010 10:39:16 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001041039.o04AdGOf031775@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Mon, 4 Jan 2010 10:39:16 +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: r201486 - user/luigi/ipfw3-head/sys/netinet
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 10:39:16 -0000

Author: luigi
Date: Mon Jan  4 10:39:16 2010
New Revision: 201486
URL: http://svn.freebsd.org/changeset/base/201486

Log:
  remove debugging messages

Modified:
  user/luigi/ipfw3-head/sys/netinet/ip_divert.c

Modified: user/luigi/ipfw3-head/sys/netinet/ip_divert.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ip_divert.c	Mon Jan  4 10:38:54 2010	(r201485)
+++ user/luigi/ipfw3-head/sys/netinet/ip_divert.c	Mon Jan  4 10:39:16 2010	(r201486)
@@ -220,7 +220,6 @@ divert_packet(struct mbuf *m, int incomi
 
 	mtag = m_tag_find(m, PACKET_TAG_DIVERT, NULL);
 	if (mtag == NULL) {
-		printf("%s: no divert tag\n", __func__);
 		m_freem(m);
 		return;
 	}
@@ -301,9 +300,6 @@ divert_packet(struct mbuf *m, int incomi
 	/* Put packet on socket queue, if any */
 	sa = NULL;
 	nport = htons((u_int16_t)divert_info(mtag));
-	printf("divert rule %d %s to port %d\n", divsrc.sin_port,
-		incoming ? "in" : "out",
-		ntohs(nport));
 	INP_INFO_RLOCK(&V_divcbinfo);
 	LIST_FOREACH(inp, &V_divcb, inp_list) {
 		/* XXX why does only one socket match? */
@@ -360,7 +356,6 @@ div_output(struct socket *so, struct mbu
 	mtag = m_tag_locate(m, MTAG_IPFW_RULE, 0, NULL);
 	if (mtag == NULL) {
 		/* this should be normal */
-		printf("create divert tag\n");
 		mtag = m_tag_alloc(MTAG_IPFW_RULE, 0,
 		    sizeof(struct ipfw_rule_ref), M_NOWAIT | M_ZERO);
 		if (mtag == NULL) {
@@ -371,9 +366,6 @@ div_output(struct socket *so, struct mbu
 	}
 	dt = (struct ipfw_rule_ref *)(mtag+1);
 
-	printf("%s sin %p dst rule %d addr 0x%x\n", __FUNCTION__,
-		sin, sin? sin->sin_port : -1,
-		sin ? sin->sin_addr.s_addr : 0xdeaddead);
 	/* Loopback avoidance and state recovery */
 	if (sin) {
 		int i;
@@ -470,7 +462,6 @@ div_output(struct socket *so, struct mbu
 		}
 	} else {
 		dt->info |= IP_FW_DIVERT_LOOPBACK_FLAG;
-		printf("divert to loopback\n");
 		if (m->m_pkthdr.rcvif == NULL) {
 			/*
 			 * No luck with the name, check by IP address.
@@ -483,7 +474,6 @@ div_output(struct socket *so, struct mbu
 			sin->sin_port = 0;
 			ifa = ifa_ifwithaddr((struct sockaddr *) sin);
 			if (ifa == NULL) {
-				printf("%s ifa not found ???\n", __FUNCTION__);
 				error = EADDRNOTAVAIL;
 				goto cantsend;
 			}

From owner-svn-src-user@FreeBSD.ORG  Mon Jan  4 11:29:59 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 658A61065670;
	Mon,  4 Jan 2010 11:29:59 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 505868FC14;
	Mon,  4 Jan 2010 11:29:59 +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 o04BTxhO045127;
	Mon, 4 Jan 2010 11:29:59 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o04BTvvO045099;
	Mon, 4 Jan 2010 11:29:57 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001041129.o04BTvvO045099@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Mon, 4 Jan 2010 11:29:57 +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: r201492 - in user/luigi/ipfw3-head: . bin/kenv bin/pax
	bin/pkill bin/sh contrib/top crypto/heimdal/kcm etc
	etc/defaults etc/mtree etc/rc.d games/fortune/datfiles
	games/fortune/strfile g...
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 11:29:59 -0000

Author: luigi
Date: Mon Jan  4 11:29:55 2010
New Revision: 201492
URL: http://svn.freebsd.org/changeset/base/201492

Log:
  svn merge -r 201048:201486 from head

Added:
  user/luigi/ipfw3-head/lib/libarchive/archive_hash.h
     - copied unchanged from r201486, head/lib/libarchive/archive_hash.h
  user/luigi/ipfw3-head/lib/libarchive/archive_read_support_compression_uu.c
     - copied unchanged from r201486, head/lib/libarchive/archive_read_support_compression_uu.c
  user/luigi/ipfw3-head/lib/libarchive/archive_write_set_format_zip.c
     - copied unchanged from r201486, head/lib/libarchive/archive_write_set_format_zip.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_compat_cpio.c
     - copied unchanged from r201486, head/lib/libarchive/test/test_compat_cpio.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_compat_cpio_1.cpio.uu
     - copied unchanged from r201486, head/lib/libarchive/test/test_compat_cpio_1.cpio.uu
  user/luigi/ipfw3-head/lib/libarchive/test/test_compat_lzma.c
     - copied unchanged from r201486, head/lib/libarchive/test/test_compat_lzma.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_compat_lzma_1.tlz.uu
     - copied unchanged from r201486, head/lib/libarchive/test/test_compat_lzma_1.tlz.uu
  user/luigi/ipfw3-head/lib/libarchive/test/test_compat_lzma_2.tlz.uu
     - copied unchanged from r201486, head/lib/libarchive/test/test_compat_lzma_2.tlz.uu
  user/luigi/ipfw3-head/lib/libarchive/test/test_compat_lzma_3.tlz.uu
     - copied unchanged from r201486, head/lib/libarchive/test/test_compat_lzma_3.tlz.uu
  user/luigi/ipfw3-head/lib/libarchive/test/test_fuzz_1.iso.Z.uu
     - copied unchanged from r201486, head/lib/libarchive/test/test_fuzz_1.iso.Z.uu
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_ar.ar.uu
     - copied unchanged from r201486, head/lib/libarchive/test/test_read_format_ar.ar.uu
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_cpio_bin_lzma.c
     - copied unchanged from r201486, head/lib/libarchive/test/test_read_format_cpio_bin_lzma.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_iso.iso.Z.uu
     - copied unchanged from r201486, head/lib/libarchive/test/test_read_format_iso.iso.Z.uu
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_iso_joliet.iso.Z.uu
     - copied unchanged from r201486, head/lib/libarchive/test/test_read_format_iso_joliet.iso.Z.uu
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_iso_joliet_long.iso.Z.uu
     - copied unchanged from r201486, head/lib/libarchive/test/test_read_format_iso_joliet_long.iso.Z.uu
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_iso_joliet_rockridge.iso.Z.uu
     - copied unchanged from r201486, head/lib/libarchive/test/test_read_format_iso_joliet_rockridge.iso.Z.uu
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_iso_multi_extent.c
     - copied unchanged from r201486, head/lib/libarchive/test/test_read_format_iso_multi_extent.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_iso_multi_extent.iso.Z.uu
     - copied unchanged from r201486, head/lib/libarchive/test/test_read_format_iso_multi_extent.iso.Z.uu
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_iso_rockridge.iso.Z.uu
     - copied unchanged from r201486, head/lib/libarchive/test/test_read_format_iso_rockridge.iso.Z.uu
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_iso_rockridge_ce.iso.Z.uu
     - copied unchanged from r201486, head/lib/libarchive/test/test_read_format_iso_rockridge_ce.iso.Z.uu
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_iso_rockridge_new.iso.Z.uu
     - copied unchanged from r201486, head/lib/libarchive/test/test_read_format_iso_rockridge_new.iso.Z.uu
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_iso_rockridge_rr_moved.iso.Z.uu
     - copied unchanged from r201486, head/lib/libarchive/test/test_read_format_iso_rockridge_rr_moved.iso.Z.uu
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_iso_zisofs.iso.Z.uu
     - copied unchanged from r201486, head/lib/libarchive/test/test_read_format_iso_zisofs.iso.Z.uu
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_isojoliet_long.c
     - copied unchanged from r201486, head/lib/libarchive/test/test_read_format_isojoliet_long.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_isojoliet_rr.c
     - copied unchanged from r201486, head/lib/libarchive/test/test_read_format_isojoliet_rr.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_isorr_ce.c
     - copied unchanged from r201486, head/lib/libarchive/test/test_read_format_isorr_ce.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_isorr_new_bz2.c
     - copied unchanged from r201486, head/lib/libarchive/test/test_read_format_isorr_new_bz2.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_isorr_rr_moved.c
     - copied unchanged from r201486, head/lib/libarchive/test/test_read_format_isorr_rr_moved.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_isozisofs_bz2.c
     - copied unchanged from r201486, head/lib/libarchive/test/test_read_format_isozisofs_bz2.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_mtree.mtree.uu
     - copied unchanged from r201486, head/lib/libarchive/test/test_read_format_mtree.mtree.uu
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_tlz.c
     - copied unchanged from r201486, head/lib/libarchive/test/test_read_format_tlz.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_uu.c
     - copied unchanged from r201486, head/lib/libarchive/test/test_read_uu.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_write_disk_symlink.c
     - copied unchanged from r201486, head/lib/libarchive/test/test_write_disk_symlink.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_write_format_zip.c
     - copied unchanged from r201486, head/lib/libarchive/test/test_write_format_zip.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_write_format_zip_empty.c
     - copied unchanged from r201486, head/lib/libarchive/test/test_write_format_zip_empty.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_write_format_zip_no_compression.c
     - copied unchanged from r201486, head/lib/libarchive/test/test_write_format_zip_no_compression.c
  user/luigi/ipfw3-head/sbin/geom/class/cache/gcache.8
     - copied unchanged from r201486, head/sbin/geom/class/cache/gcache.8
  user/luigi/ipfw3-head/sys/arm/arm/cpufunc_asm_fa526.S
     - copied unchanged from r201486, head/sys/arm/arm/cpufunc_asm_fa526.S
  user/luigi/ipfw3-head/sys/arm/conf/CNS11XXNAS
     - copied unchanged from r201486, head/sys/arm/conf/CNS11XXNAS
  user/luigi/ipfw3-head/sys/arm/econa/
     - copied from r201486, head/sys/arm/econa/
  user/luigi/ipfw3-head/sys/boot/pc98/boot2/boot1.S
     - copied unchanged from r201486, head/sys/boot/pc98/boot2/boot1.S
  user/luigi/ipfw3-head/sys/boot/pc98/boot2/boot2.c
     - copied unchanged from r201486, head/sys/boot/pc98/boot2/boot2.c
  user/luigi/ipfw3-head/sys/boot/pc98/libpc98/libpc98.h
     - copied unchanged from r201486, head/sys/boot/pc98/libpc98/libpc98.h
  user/luigi/ipfw3-head/sys/boot/pc98/libpc98/pc98_sys.c
     - copied unchanged from r201486, head/sys/boot/pc98/libpc98/pc98_sys.c
  user/luigi/ipfw3-head/sys/contrib/dev/iwn/iwlwifi-1000-128.50.3.1.fw.uu
     - copied unchanged from r201486, head/sys/contrib/dev/iwn/iwlwifi-1000-128.50.3.1.fw.uu
  user/luigi/ipfw3-head/sys/contrib/dev/iwn/iwlwifi-4965-228.61.2.24.fw.uu
     - copied unchanged from r201486, head/sys/contrib/dev/iwn/iwlwifi-4965-228.61.2.24.fw.uu
  user/luigi/ipfw3-head/sys/contrib/dev/iwn/iwlwifi-5000-8.24.2.12.fw.uu
     - copied unchanged from r201486, head/sys/contrib/dev/iwn/iwlwifi-5000-8.24.2.12.fw.uu
  user/luigi/ipfw3-head/sys/contrib/dev/iwn/iwlwifi-6000-9.176.4.1.fw.uu
     - copied unchanged from r201486, head/sys/contrib/dev/iwn/iwlwifi-6000-9.176.4.1.fw.uu
  user/luigi/ipfw3-head/sys/ia64/ia64/bus_machdep.c
     - copied unchanged from r201486, head/sys/ia64/ia64/bus_machdep.c
  user/luigi/ipfw3-head/sys/modules/iwnfw/iwn1000/
     - copied from r201486, head/sys/modules/iwnfw/iwn1000/
  user/luigi/ipfw3-head/sys/modules/iwnfw/iwn6000/
     - copied from r201486, head/sys/modules/iwnfw/iwn6000/
  user/luigi/ipfw3-head/sys/sys/_umtx.h
     - copied unchanged from r201486, head/sys/sys/_umtx.h
  user/luigi/ipfw3-head/tools/regression/bin/sh/builtins/builtin1.0
     - copied unchanged from r201486, head/tools/regression/bin/sh/builtins/builtin1.0
  user/luigi/ipfw3-head/tools/regression/bin/sh/builtins/command6.0
     - copied unchanged from r201486, head/tools/regression/bin/sh/builtins/command6.0
  user/luigi/ipfw3-head/tools/regression/bin/sh/builtins/command6.0.stdout
     - copied unchanged from r201486, head/tools/regression/bin/sh/builtins/command6.0.stdout
  user/luigi/ipfw3-head/tools/regression/bin/sh/builtins/command7.0
     - copied unchanged from r201486, head/tools/regression/bin/sh/builtins/command7.0
  user/luigi/ipfw3-head/tools/regression/bin/sh/builtins/type2.0
     - copied unchanged from r201486, head/tools/regression/bin/sh/builtins/type2.0
  user/luigi/ipfw3-head/tools/regression/bin/sh/expansion/arith1.0
     - copied unchanged from r201486, head/tools/regression/bin/sh/expansion/arith1.0
  user/luigi/ipfw3-head/tools/regression/bin/sh/expansion/arith2.0
     - copied unchanged from r201486, head/tools/regression/bin/sh/expansion/arith2.0
  user/luigi/ipfw3-head/tools/regression/bin/sh/expansion/cmdsubst1.0
     - copied unchanged from r201486, head/tools/regression/bin/sh/expansion/cmdsubst1.0
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/syntax/directive-t0/
     - copied from r201486, head/tools/regression/usr.bin/make/syntax/directive-t0/
Deleted:
  user/luigi/ipfw3-head/lib/libarchive/test/test_fuzz_1.iso.uu
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_iso_gz.iso.gz.uu
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_isojoliet_bz2.iso.bz2.uu
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_isojolietrr_bz2.iso.bz2.uu
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_isorr_bz2.iso.bz2.uu
  user/luigi/ipfw3-head/share/examples/pppd/
  user/luigi/ipfw3-head/share/examples/slattach/
  user/luigi/ipfw3-head/share/examples/sliplogin/
  user/luigi/ipfw3-head/share/examples/startslip/
  user/luigi/ipfw3-head/sys/boot/pc98/boot2/asm.S
  user/luigi/ipfw3-head/sys/boot/pc98/boot2/asm.h
  user/luigi/ipfw3-head/sys/boot/pc98/boot2/bios.S
  user/luigi/ipfw3-head/sys/boot/pc98/boot2/boot.c
  user/luigi/ipfw3-head/sys/boot/pc98/boot2/boot.h
  user/luigi/ipfw3-head/sys/boot/pc98/boot2/boot2.S
  user/luigi/ipfw3-head/sys/boot/pc98/boot2/dinode.h
  user/luigi/ipfw3-head/sys/boot/pc98/boot2/disk.c
  user/luigi/ipfw3-head/sys/boot/pc98/boot2/fs.h
  user/luigi/ipfw3-head/sys/boot/pc98/boot2/inode.h
  user/luigi/ipfw3-head/sys/boot/pc98/boot2/io.c
  user/luigi/ipfw3-head/sys/boot/pc98/boot2/probe_keyboard.c
  user/luigi/ipfw3-head/sys/boot/pc98/boot2/quota.h
  user/luigi/ipfw3-head/sys/boot/pc98/boot2/serial.S
  user/luigi/ipfw3-head/sys/boot/pc98/boot2/serial_16550.S
  user/luigi/ipfw3-head/sys/boot/pc98/boot2/serial_8251.S
  user/luigi/ipfw3-head/sys/boot/pc98/boot2/start.S
  user/luigi/ipfw3-head/sys/boot/pc98/boot2/sys.c
  user/luigi/ipfw3-head/sys/boot/pc98/boot2/table.c
  user/luigi/ipfw3-head/sys/contrib/dev/iwn/iwlwifi-4965-228.57.2.23.fw.uu
  user/luigi/ipfw3-head/sys/contrib/dev/iwn/iwlwifi-5000-5.4.A.11.fw.uu
Modified:
  user/luigi/ipfw3-head/COPYRIGHT
  user/luigi/ipfw3-head/MAINTAINERS
  user/luigi/ipfw3-head/Makefile.inc1
  user/luigi/ipfw3-head/ObsoleteFiles.inc
  user/luigi/ipfw3-head/bin/kenv/kenv.c
  user/luigi/ipfw3-head/bin/pax/ftree.c
  user/luigi/ipfw3-head/bin/pkill/pkill.c
  user/luigi/ipfw3-head/bin/sh/arith.y
  user/luigi/ipfw3-head/bin/sh/error.c
  user/luigi/ipfw3-head/bin/sh/eval.c
  user/luigi/ipfw3-head/bin/sh/exec.c
  user/luigi/ipfw3-head/bin/sh/exec.h
  user/luigi/ipfw3-head/bin/sh/expand.c
  user/luigi/ipfw3-head/bin/sh/output.h
  user/luigi/ipfw3-head/bin/sh/parser.c
  user/luigi/ipfw3-head/bin/sh/sh.1
  user/luigi/ipfw3-head/crypto/heimdal/kcm/connect.c
  user/luigi/ipfw3-head/etc/defaults/rc.conf
  user/luigi/ipfw3-head/etc/mtree/BSD.usr.dist
  user/luigi/ipfw3-head/etc/network.subr
  user/luigi/ipfw3-head/etc/rc.d/named
  user/luigi/ipfw3-head/etc/rc.d/nsswitch
  user/luigi/ipfw3-head/etc/rc.firewall
  user/luigi/ipfw3-head/games/fortune/datfiles/fortunes
  user/luigi/ipfw3-head/games/fortune/strfile/strfile.c
  user/luigi/ipfw3-head/games/fortune/unstr/unstr.c
  user/luigi/ipfw3-head/games/number/number.c
  user/luigi/ipfw3-head/include/paths.h
  user/luigi/ipfw3-head/lib/Makefile.inc
  user/luigi/ipfw3-head/lib/csu/Makefile.inc
  user/luigi/ipfw3-head/lib/csu/arm/Makefile
  user/luigi/ipfw3-head/lib/csu/i386-elf/Makefile
  user/luigi/ipfw3-head/lib/csu/mips/Makefile
  user/luigi/ipfw3-head/lib/libarchive/Makefile
  user/luigi/ipfw3-head/lib/libarchive/archive.h
  user/luigi/ipfw3-head/lib/libarchive/archive_read.c
  user/luigi/ipfw3-head/lib/libarchive/archive_read_support_compression_all.c
  user/luigi/ipfw3-head/lib/libarchive/archive_read_support_compression_xz.c
  user/luigi/ipfw3-head/lib/libarchive/archive_read_support_format_cpio.c
  user/luigi/ipfw3-head/lib/libarchive/archive_read_support_format_iso9660.c
  user/luigi/ipfw3-head/lib/libarchive/archive_read_support_format_mtree.c
  user/luigi/ipfw3-head/lib/libarchive/archive_read_support_format_tar.c
  user/luigi/ipfw3-head/lib/libarchive/archive_write_disk.c
  user/luigi/ipfw3-head/lib/libarchive/archive_write_private.h
  user/luigi/ipfw3-head/lib/libarchive/archive_write_set_format.c
  user/luigi/ipfw3-head/lib/libarchive/archive_write_set_format_by_name.c
  user/luigi/ipfw3-head/lib/libarchive/archive_write_set_format_cpio.c
  user/luigi/ipfw3-head/lib/libarchive/archive_write_set_format_cpio_newc.c
  user/luigi/ipfw3-head/lib/libarchive/archive_write_set_format_mtree.c
  user/luigi/ipfw3-head/lib/libarchive/archive_write_set_format_pax.c
  user/luigi/ipfw3-head/lib/libarchive/test/Makefile
  user/luigi/ipfw3-head/lib/libarchive/test/main.c
  user/luigi/ipfw3-head/lib/libarchive/test/test.h
  user/luigi/ipfw3-head/lib/libarchive/test/test_acl_pax.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_compat_bzip2.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_compat_solaris_tar_acl.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_entry.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_entry_strmode.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_extattr_freebsd.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_fuzz.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_open_fd.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_open_file.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_pax_filename_encoding.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_compress_program.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_data_large.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_disk.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_disk_entry_from_file.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_extract.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_ar.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_cpio_bin_bz2.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_iso_gz.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_isojoliet_bz2.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_isorr_bz2.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_mtree.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_pax_bz2.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_tar.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_format_tbz.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_read_large.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_tar_large.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_write_compress_program.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_write_disk.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_write_disk_failures.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_write_disk_hardlink.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_write_disk_perms.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_write_disk_secure.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_write_disk_sparse.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_write_disk_times.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_write_format_cpio_empty.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_write_format_cpio_newc.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_write_format_cpio_odc.c
  user/luigi/ipfw3-head/lib/libarchive/test/test_write_format_tar_ustar.c
  user/luigi/ipfw3-head/lib/libauditd/Makefile
  user/luigi/ipfw3-head/lib/libautofs/Makefile
  user/luigi/ipfw3-head/lib/libbegemot/Makefile
  user/luigi/ipfw3-head/lib/libbsm/Makefile
  user/luigi/ipfw3-head/lib/libbz2/Makefile
  user/luigi/ipfw3-head/lib/libc/gen/time.3
  user/luigi/ipfw3-head/lib/libc/gen/time.c
  user/luigi/ipfw3-head/lib/libc/posix1e/Makefile.inc
  user/luigi/ipfw3-head/lib/libc/stdtime/localtime.c
  user/luigi/ipfw3-head/lib/libc/sys/clock_gettime.2
  user/luigi/ipfw3-head/lib/libc/sys/kqueue.2
  user/luigi/ipfw3-head/lib/libcalendar/Makefile
  user/luigi/ipfw3-head/lib/libcam/Makefile
  user/luigi/ipfw3-head/lib/libcompat/Makefile
  user/luigi/ipfw3-head/lib/libcrypt/Makefile
  user/luigi/ipfw3-head/lib/libdevinfo/Makefile
  user/luigi/ipfw3-head/lib/libdevstat/Makefile
  user/luigi/ipfw3-head/lib/libdwarf/Makefile
  user/luigi/ipfw3-head/lib/libedit/Makefile
  user/luigi/ipfw3-head/lib/libelf/Makefile
  user/luigi/ipfw3-head/lib/libexpat/Makefile
  user/luigi/ipfw3-head/lib/libftpio/Makefile
  user/luigi/ipfw3-head/lib/libgeom/geom_getxml.c
  user/luigi/ipfw3-head/lib/libgpib/Makefile
  user/luigi/ipfw3-head/lib/libgssapi/Makefile
  user/luigi/ipfw3-head/lib/libipsec/Makefile
  user/luigi/ipfw3-head/lib/libipx/Makefile
  user/luigi/ipfw3-head/lib/libjail/Makefile
  user/luigi/ipfw3-head/lib/libkiconv/Makefile
  user/luigi/ipfw3-head/lib/libkvm/Makefile
  user/luigi/ipfw3-head/lib/libmagic/Makefile
  user/luigi/ipfw3-head/lib/libmd/Makefile
  user/luigi/ipfw3-head/lib/libmilter/Makefile
  user/luigi/ipfw3-head/lib/libmp/Makefile
  user/luigi/ipfw3-head/lib/libncp/Makefile
  user/luigi/ipfw3-head/lib/libngatm/Makefile
  user/luigi/ipfw3-head/lib/libopie/Makefile
  user/luigi/ipfw3-head/lib/libpam/modules/Makefile.inc
  user/luigi/ipfw3-head/lib/libpam/modules/pam_exec/Makefile
  user/luigi/ipfw3-head/lib/libpam/modules/pam_krb5/Makefile
  user/luigi/ipfw3-head/lib/libpam/modules/pam_radius/Makefile
  user/luigi/ipfw3-head/lib/libpam/modules/pam_ssh/Makefile
  user/luigi/ipfw3-head/lib/libpcap/Makefile
  user/luigi/ipfw3-head/lib/libpmc/Makefile
  user/luigi/ipfw3-head/lib/libproc/Makefile
  user/luigi/ipfw3-head/lib/libradius/Makefile
  user/luigi/ipfw3-head/lib/librpcsec_gss/Makefile
  user/luigi/ipfw3-head/lib/librt/Makefile
  user/luigi/ipfw3-head/lib/libsbuf/Makefile
  user/luigi/ipfw3-head/lib/libsm/Makefile
  user/luigi/ipfw3-head/lib/libsmdb/Makefile
  user/luigi/ipfw3-head/lib/libsmutil/Makefile
  user/luigi/ipfw3-head/lib/libstand/Makefile
  user/luigi/ipfw3-head/lib/libtacplus/Makefile
  user/luigi/ipfw3-head/lib/libthread_db/Makefile
  user/luigi/ipfw3-head/lib/libufs/Makefile
  user/luigi/ipfw3-head/lib/libugidfw/Makefile
  user/luigi/ipfw3-head/lib/libugidfw/ugidfw.c
  user/luigi/ipfw3-head/lib/libulog/Makefile
  user/luigi/ipfw3-head/lib/libusb/Makefile
  user/luigi/ipfw3-head/lib/libutil/Makefile
  user/luigi/ipfw3-head/lib/libvgl/Makefile
  user/luigi/ipfw3-head/lib/libwrap/Makefile
  user/luigi/ipfw3-head/lib/liby/Makefile
  user/luigi/ipfw3-head/lib/libypclnt/Makefile
  user/luigi/ipfw3-head/lib/libz/Makefile
  user/luigi/ipfw3-head/lib/ncurses/Makefile.inc
  user/luigi/ipfw3-head/libexec/Makefile.inc
  user/luigi/ipfw3-head/libexec/atrun/Makefile
  user/luigi/ipfw3-head/libexec/bootpd/Makefile
  user/luigi/ipfw3-head/libexec/bootpd/Makefile.inc
  user/luigi/ipfw3-head/libexec/bootpd/tools/Makefile.inc
  user/luigi/ipfw3-head/libexec/comsat/comsat.c
  user/luigi/ipfw3-head/libexec/fingerd/Makefile
  user/luigi/ipfw3-head/libexec/getty/Makefile
  user/luigi/ipfw3-head/libexec/mail.local/Makefile
  user/luigi/ipfw3-head/libexec/mknetid/Makefile
  user/luigi/ipfw3-head/libexec/pppoed/Makefile
  user/luigi/ipfw3-head/libexec/rbootd/Makefile
  user/luigi/ipfw3-head/libexec/revnetgroup/Makefile
  user/luigi/ipfw3-head/libexec/rpc.rquotad/Makefile
  user/luigi/ipfw3-head/libexec/rpc.rstatd/Makefile
  user/luigi/ipfw3-head/libexec/rpc.rusersd/Makefile
  user/luigi/ipfw3-head/libexec/rpc.rusersd/rusers_proc.c
  user/luigi/ipfw3-head/libexec/rpc.rusersd/rusersd.c
  user/luigi/ipfw3-head/libexec/rpc.rwalld/Makefile
  user/luigi/ipfw3-head/libexec/rpc.sprayd/Makefile
  user/luigi/ipfw3-head/libexec/rshd/Makefile
  user/luigi/ipfw3-head/libexec/rtld-aout/shlib.c
  user/luigi/ipfw3-head/libexec/rtld-aout/support.c
  user/luigi/ipfw3-head/libexec/rtld-elf/Makefile
  user/luigi/ipfw3-head/libexec/smrsh/Makefile
  user/luigi/ipfw3-head/libexec/talkd/Makefile
  user/luigi/ipfw3-head/libexec/tcpd/Makefile
  user/luigi/ipfw3-head/libexec/tftp-proxy/Makefile
  user/luigi/ipfw3-head/libexec/tftpd/Makefile
  user/luigi/ipfw3-head/libexec/ulog-helper/Makefile
  user/luigi/ipfw3-head/libexec/ypxfr/Makefile
  user/luigi/ipfw3-head/release/Makefile
  user/luigi/ipfw3-head/sbin/comcontrol/comcontrol.c
  user/luigi/ipfw3-head/sbin/geom/class/cache/Makefile
  user/luigi/ipfw3-head/sbin/geom/core/geom.8
  user/luigi/ipfw3-head/sbin/growfs/growfs.c
  user/luigi/ipfw3-head/sbin/ldconfig/ldconfig.c
  user/luigi/ipfw3-head/sbin/mount/vfslist.c
  user/luigi/ipfw3-head/sbin/mount_msdosfs/mount_msdosfs.8
  user/luigi/ipfw3-head/sbin/mount_msdosfs/mount_msdosfs.c
  user/luigi/ipfw3-head/sbin/mount_nullfs/mount_nullfs.c
  user/luigi/ipfw3-head/sbin/newfs/mkfs.c
  user/luigi/ipfw3-head/sbin/rcorder/ealloc.c
  user/luigi/ipfw3-head/sbin/rcorder/hash.c
  user/luigi/ipfw3-head/sbin/rcorder/rcorder.c
  user/luigi/ipfw3-head/sbin/reboot/reboot.c
  user/luigi/ipfw3-head/sbin/shutdown/shutdown.c
  user/luigi/ipfw3-head/sbin/umount/umount.c
  user/luigi/ipfw3-head/secure/Makefile
  user/luigi/ipfw3-head/secure/Makefile.inc
  user/luigi/ipfw3-head/share/examples/Makefile
  user/luigi/ipfw3-head/share/man/man4/mfi.4
  user/luigi/ipfw3-head/share/man/man5/rc.conf.5
  user/luigi/ipfw3-head/share/misc/bsd-family-tree
  user/luigi/ipfw3-head/share/mk/bsd.sys.mk
  user/luigi/ipfw3-head/share/zoneinfo/asia
  user/luigi/ipfw3-head/sys/amd64/amd64/mem.c
  user/luigi/ipfw3-head/sys/amd64/conf/GENERIC
  user/luigi/ipfw3-head/sys/amd64/include/cpufunc.h
  user/luigi/ipfw3-head/sys/arm/arm/cpufunc.c
  user/luigi/ipfw3-head/sys/arm/arm/elf_trampoline.c
  user/luigi/ipfw3-head/sys/arm/arm/mem.c
  user/luigi/ipfw3-head/sys/arm/include/cpuconf.h
  user/luigi/ipfw3-head/sys/arm/include/cpufunc.h
  user/luigi/ipfw3-head/sys/boot/common/module.c
  user/luigi/ipfw3-head/sys/boot/pc98/Makefile.inc
  user/luigi/ipfw3-head/sys/boot/pc98/boot0.5/selector.s
  user/luigi/ipfw3-head/sys/boot/pc98/boot2/Makefile
  user/luigi/ipfw3-head/sys/boot/pc98/libpc98/Makefile
  user/luigi/ipfw3-head/sys/boot/pc98/loader/main.c
  user/luigi/ipfw3-head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c
  user/luigi/ipfw3-head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c
  user/luigi/ipfw3-head/sys/conf/Makefile.arm
  user/luigi/ipfw3-head/sys/conf/files
  user/luigi/ipfw3-head/sys/conf/files.ia64
  user/luigi/ipfw3-head/sys/conf/options.arm
  user/luigi/ipfw3-head/sys/dev/adlink/adlink.c
  user/luigi/ipfw3-head/sys/dev/agp/agp.c
  user/luigi/ipfw3-head/sys/dev/aic7xxx/aicasm/Makefile
  user/luigi/ipfw3-head/sys/dev/aic7xxx/aicasm/aicasm.c
  user/luigi/ipfw3-head/sys/dev/aic7xxx/aicasm/aicasm_macro_scan.l
  user/luigi/ipfw3-head/sys/dev/aic7xxx/aicasm/aicasm_scan.l
  user/luigi/ipfw3-head/sys/dev/aic7xxx/aicasm/aicasm_symbol.c
  user/luigi/ipfw3-head/sys/dev/ath/if_ath.c
  user/luigi/ipfw3-head/sys/dev/bge/if_bge.c
  user/luigi/ipfw3-head/sys/dev/bktr/bktr_os.c
  user/luigi/ipfw3-head/sys/dev/cardbus/cardbus_cis.c
  user/luigi/ipfw3-head/sys/dev/dc/if_dc.c
  user/luigi/ipfw3-head/sys/dev/dc/if_dcreg.h
  user/luigi/ipfw3-head/sys/dev/drm/drm_vm.c
  user/luigi/ipfw3-head/sys/dev/exca/excareg.h
  user/luigi/ipfw3-head/sys/dev/fb/creator.c
  user/luigi/ipfw3-head/sys/dev/fb/fb.c
  user/luigi/ipfw3-head/sys/dev/fb/fbreg.h
  user/luigi/ipfw3-head/sys/dev/fb/machfb.c
  user/luigi/ipfw3-head/sys/dev/fb/s3_pci.c
  user/luigi/ipfw3-head/sys/dev/fb/vesa.c
  user/luigi/ipfw3-head/sys/dev/fb/vga.c
  user/luigi/ipfw3-head/sys/dev/fb/vgareg.h
  user/luigi/ipfw3-head/sys/dev/firewire/fwdev.c
  user/luigi/ipfw3-head/sys/dev/firewire/fwmem.c
  user/luigi/ipfw3-head/sys/dev/hifn/hifn7751.c
  user/luigi/ipfw3-head/sys/dev/hwpmc/hwpmc_mod.c
  user/luigi/ipfw3-head/sys/dev/isp/isp.c
  user/luigi/ipfw3-head/sys/dev/iwn/if_iwn.c
  user/luigi/ipfw3-head/sys/dev/iwn/if_iwnreg.h
  user/luigi/ipfw3-head/sys/dev/iwn/if_iwnvar.h
  user/luigi/ipfw3-head/sys/dev/ksyms/ksyms.c
  user/luigi/ipfw3-head/sys/dev/mge/if_mge.c
  user/luigi/ipfw3-head/sys/dev/mii/tdkphy.c
  user/luigi/ipfw3-head/sys/dev/mk48txx/mk48txx.c
  user/luigi/ipfw3-head/sys/dev/mpt/mpt_pci.c
  user/luigi/ipfw3-head/sys/dev/pccard/card_if.m
  user/luigi/ipfw3-head/sys/dev/pci/pci.c
  user/luigi/ipfw3-head/sys/dev/pci/pci_private.h
  user/luigi/ipfw3-head/sys/dev/siis/siis.c
  user/luigi/ipfw3-head/sys/dev/siis/siis.h
  user/luigi/ipfw3-head/sys/dev/sound/pcm/dsp.c
  user/luigi/ipfw3-head/sys/dev/syscons/syscons.c
  user/luigi/ipfw3-head/sys/dev/tdfx/tdfx_pci.c
  user/luigi/ipfw3-head/sys/dev/usb/serial/uipaq.c
  user/luigi/ipfw3-head/sys/dev/usb/usbdevs
  user/luigi/ipfw3-head/sys/dev/xen/blkfront/blkfront.c
  user/luigi/ipfw3-head/sys/dev/xl/if_xl.c
  user/luigi/ipfw3-head/sys/fs/nfsclient/nfs_clrpcops.c
  user/luigi/ipfw3-head/sys/fs/nfsclient/nfs_clstate.c
  user/luigi/ipfw3-head/sys/fs/nfsserver/nfs_nfsdstate.c
  user/luigi/ipfw3-head/sys/geom/geom_io.c
  user/luigi/ipfw3-head/sys/geom/part/g_part_gpt.c
  user/luigi/ipfw3-head/sys/i386/conf/GENERIC
  user/luigi/ipfw3-head/sys/i386/i386/elan-mmcr.c
  user/luigi/ipfw3-head/sys/i386/i386/mem.c
  user/luigi/ipfw3-head/sys/i386/include/cpufunc.h
  user/luigi/ipfw3-head/sys/i386/xbox/xboxfb.c
  user/luigi/ipfw3-head/sys/ia64/conf/GENERIC
  user/luigi/ipfw3-head/sys/ia64/ia64/machdep.c
  user/luigi/ipfw3-head/sys/ia64/ia64/mem.c
  user/luigi/ipfw3-head/sys/ia64/ia64/mp_machdep.c
  user/luigi/ipfw3-head/sys/ia64/ia64/nexus.c
  user/luigi/ipfw3-head/sys/ia64/ia64/sys_machdep.c
  user/luigi/ipfw3-head/sys/ia64/include/bus.h
  user/luigi/ipfw3-head/sys/ia64/include/cpufunc.h
  user/luigi/ipfw3-head/sys/isa/vga_isa.c
  user/luigi/ipfw3-head/sys/kern/kern_conf.c
  user/luigi/ipfw3-head/sys/kern/kern_event.c
  user/luigi/ipfw3-head/sys/kern/kern_umtx.c
  user/luigi/ipfw3-head/sys/kern/sched_4bsd.c
  user/luigi/ipfw3-head/sys/kern/sched_ule.c
  user/luigi/ipfw3-head/sys/kern/subr_bus.c
  user/luigi/ipfw3-head/sys/kern/subr_devstat.c
  user/luigi/ipfw3-head/sys/kern/subr_witness.c
  user/luigi/ipfw3-head/sys/kern/tty.c
  user/luigi/ipfw3-head/sys/mips/mips/mem.c
  user/luigi/ipfw3-head/sys/modules/iwnfw/Makefile
  user/luigi/ipfw3-head/sys/modules/iwnfw/iwn4965/Makefile
  user/luigi/ipfw3-head/sys/modules/iwnfw/iwn5000/Makefile
  user/luigi/ipfw3-head/sys/net/if.c
  user/luigi/ipfw3-head/sys/net/if.h
  user/luigi/ipfw3-head/sys/net/if_llatbl.c
  user/luigi/ipfw3-head/sys/net/if_llatbl.h
  user/luigi/ipfw3-head/sys/net/if_var.h
  user/luigi/ipfw3-head/sys/net/if_vlan.c
  user/luigi/ipfw3-head/sys/net/route.c
  user/luigi/ipfw3-head/sys/net/route.h
  user/luigi/ipfw3-head/sys/net/rtsock.c
  user/luigi/ipfw3-head/sys/netinet/if_ether.c
  user/luigi/ipfw3-head/sys/netinet/in.c
  user/luigi/ipfw3-head/sys/netinet/ip_mroute.c
  user/luigi/ipfw3-head/sys/netinet6/in6.c
  user/luigi/ipfw3-head/sys/netinet6/nd6.c
  user/luigi/ipfw3-head/sys/pc98/cbus/gdc.c
  user/luigi/ipfw3-head/sys/pc98/conf/GENERIC
  user/luigi/ipfw3-head/sys/powerpc/conf/GENERIC
  user/luigi/ipfw3-head/sys/powerpc/ofw/ofw_syscons.c
  user/luigi/ipfw3-head/sys/powerpc/powerpc/mem.c
  user/luigi/ipfw3-head/sys/security/mac_lomac/mac_lomac.c
  user/luigi/ipfw3-head/sys/sparc64/conf/GENERIC
  user/luigi/ipfw3-head/sys/sparc64/conf/NOTES
  user/luigi/ipfw3-head/sys/sparc64/pci/fire.c
  user/luigi/ipfw3-head/sys/sparc64/pci/psycho.c
  user/luigi/ipfw3-head/sys/sparc64/pci/psychovar.h
  user/luigi/ipfw3-head/sys/sparc64/pci/schizo.c
  user/luigi/ipfw3-head/sys/sparc64/pci/schizovar.h
  user/luigi/ipfw3-head/sys/sparc64/sparc64/eeprom.c
  user/luigi/ipfw3-head/sys/sparc64/sparc64/machdep.c
  user/luigi/ipfw3-head/sys/sun4v/conf/GENERIC
  user/luigi/ipfw3-head/sys/sys/conf.h
  user/luigi/ipfw3-head/sys/sys/copyright.h
  user/luigi/ipfw3-head/sys/sys/event.h
  user/luigi/ipfw3-head/sys/sys/ttydevsw.h
  user/luigi/ipfw3-head/sys/sys/umtx.h
  user/luigi/ipfw3-head/sys/vm/device_pager.c
  user/luigi/ipfw3-head/sys/xen/gnttab.c
  user/luigi/ipfw3-head/tools/regression/acct/Makefile
  user/luigi/ipfw3-head/tools/regression/acct/regress.t   (contents, props changed)
  user/luigi/ipfw3-head/tools/regression/bin/date/regress.sh
  user/luigi/ipfw3-head/tools/regression/bin/mv/regress.sh
  user/luigi/ipfw3-head/tools/regression/fifo/fifo_misc/fifo_misc.c
  user/luigi/ipfw3-head/tools/regression/usr.bin/Makefile
  user/luigi/ipfw3-head/tools/regression/usr.bin/jot/regress.sh
  user/luigi/ipfw3-head/tools/regression/usr.bin/lastcomm/values.sh
  user/luigi/ipfw3-head/usr.bin/Makefile.inc
  user/luigi/ipfw3-head/usr.bin/apply/Makefile
  user/luigi/ipfw3-head/usr.bin/ar/Makefile
  user/luigi/ipfw3-head/usr.bin/ar/acpyacc.y
  user/luigi/ipfw3-head/usr.bin/ar/ar.c
  user/luigi/ipfw3-head/usr.bin/ar/read.c
  user/luigi/ipfw3-head/usr.bin/at/Makefile
  user/luigi/ipfw3-head/usr.bin/at/at.c
  user/luigi/ipfw3-head/usr.bin/atm/sscop/Makefile
  user/luigi/ipfw3-head/usr.bin/awk/Makefile
  user/luigi/ipfw3-head/usr.bin/banner/banner.c
  user/luigi/ipfw3-head/usr.bin/biff/biff.c
  user/luigi/ipfw3-head/usr.bin/bluetooth/bthost/Makefile
  user/luigi/ipfw3-head/usr.bin/bsdiff/Makefile.inc
  user/luigi/ipfw3-head/usr.bin/bzip2/Makefile
  user/luigi/ipfw3-head/usr.bin/calendar/Makefile
  user/luigi/ipfw3-head/usr.bin/catman/Makefile
  user/luigi/ipfw3-head/usr.bin/chkey/Makefile
  user/luigi/ipfw3-head/usr.bin/chpass/Makefile
  user/luigi/ipfw3-head/usr.bin/colldef/Makefile
  user/luigi/ipfw3-head/usr.bin/compile_et/Makefile
  user/luigi/ipfw3-head/usr.bin/compress/Makefile
  user/luigi/ipfw3-head/usr.bin/cpio/Makefile
  user/luigi/ipfw3-head/usr.bin/cpio/test/Makefile
  user/luigi/ipfw3-head/usr.bin/cpuset/Makefile
  user/luigi/ipfw3-head/usr.bin/ctags/Makefile
  user/luigi/ipfw3-head/usr.bin/dig/Makefile
  user/luigi/ipfw3-head/usr.bin/du/Makefile
  user/luigi/ipfw3-head/usr.bin/elf2aout/Makefile
  user/luigi/ipfw3-head/usr.bin/elfdump/Makefile
  user/luigi/ipfw3-head/usr.bin/env/Makefile
  user/luigi/ipfw3-head/usr.bin/fetch/Makefile
  user/luigi/ipfw3-head/usr.bin/fetch/fetch.c
  user/luigi/ipfw3-head/usr.bin/file2c/Makefile
  user/luigi/ipfw3-head/usr.bin/find/Makefile
  user/luigi/ipfw3-head/usr.bin/find/function.c
  user/luigi/ipfw3-head/usr.bin/finger/Makefile
  user/luigi/ipfw3-head/usr.bin/fstat/Makefile
  user/luigi/ipfw3-head/usr.bin/fsync/Makefile
  user/luigi/ipfw3-head/usr.bin/ftp/Makefile
  user/luigi/ipfw3-head/usr.bin/gcore/Makefile
  user/luigi/ipfw3-head/usr.bin/gencat/Makefile
  user/luigi/ipfw3-head/usr.bin/gencat/gencat.c
  user/luigi/ipfw3-head/usr.bin/getent/Makefile
  user/luigi/ipfw3-head/usr.bin/gprof/Makefile
  user/luigi/ipfw3-head/usr.bin/gprof/aout.c
  user/luigi/ipfw3-head/usr.bin/gzip/Makefile
  user/luigi/ipfw3-head/usr.bin/head/Makefile
  user/luigi/ipfw3-head/usr.bin/hexdump/Makefile
  user/luigi/ipfw3-head/usr.bin/host/Makefile
  user/luigi/ipfw3-head/usr.bin/id/Makefile
  user/luigi/ipfw3-head/usr.bin/ipcrm/Makefile
  user/luigi/ipfw3-head/usr.bin/ipcs/Makefile
  user/luigi/ipfw3-head/usr.bin/kdump/Makefile
  user/luigi/ipfw3-head/usr.bin/keylogin/Makefile
  user/luigi/ipfw3-head/usr.bin/ktrace/Makefile
  user/luigi/ipfw3-head/usr.bin/ktrdump/Makefile
  user/luigi/ipfw3-head/usr.bin/lam/lam.c
  user/luigi/ipfw3-head/usr.bin/last/Makefile
  user/luigi/ipfw3-head/usr.bin/lastcomm/Makefile
  user/luigi/ipfw3-head/usr.bin/ldd/Makefile
  user/luigi/ipfw3-head/usr.bin/leave/Makefile
  user/luigi/ipfw3-head/usr.bin/less/Makefile.common
  user/luigi/ipfw3-head/usr.bin/lex/Makefile
  user/luigi/ipfw3-head/usr.bin/lex/flex.skl
  user/luigi/ipfw3-head/usr.bin/lex/initscan.c
  user/luigi/ipfw3-head/usr.bin/lex/lib/Makefile
  user/luigi/ipfw3-head/usr.bin/limits/Makefile
  user/luigi/ipfw3-head/usr.bin/locate/Makefile.inc
  user/luigi/ipfw3-head/usr.bin/locate/locate/Makefile
  user/luigi/ipfw3-head/usr.bin/lock/Makefile
  user/luigi/ipfw3-head/usr.bin/logger/Makefile
  user/luigi/ipfw3-head/usr.bin/login/Makefile
  user/luigi/ipfw3-head/usr.bin/login/login.c
  user/luigi/ipfw3-head/usr.bin/login/login_fbtab.c
  user/luigi/ipfw3-head/usr.bin/logins/Makefile
  user/luigi/ipfw3-head/usr.bin/logname/Makefile
  user/luigi/ipfw3-head/usr.bin/look/Makefile
  user/luigi/ipfw3-head/usr.bin/lsvfs/Makefile
  user/luigi/ipfw3-head/usr.bin/m4/Makefile
  user/luigi/ipfw3-head/usr.bin/mail/Makefile
  user/luigi/ipfw3-head/usr.bin/make/Makefile
  user/luigi/ipfw3-head/usr.bin/make/job.c
  user/luigi/ipfw3-head/usr.bin/make/parse.c
  user/luigi/ipfw3-head/usr.bin/minigzip/Makefile
  user/luigi/ipfw3-head/usr.bin/mkfifo/Makefile
  user/luigi/ipfw3-head/usr.bin/mklocale/Makefile
  user/luigi/ipfw3-head/usr.bin/mklocale/lex.l
  user/luigi/ipfw3-head/usr.bin/mklocale/yacc.y
  user/luigi/ipfw3-head/usr.bin/mkstr/Makefile
  user/luigi/ipfw3-head/usr.bin/mkuzip/Makefile
  user/luigi/ipfw3-head/usr.bin/msgs/Makefile
  user/luigi/ipfw3-head/usr.bin/nc/Makefile
  user/luigi/ipfw3-head/usr.bin/ncplist/Makefile
  user/luigi/ipfw3-head/usr.bin/newkey/Makefile
  user/luigi/ipfw3-head/usr.bin/nfsstat/Makefile
  user/luigi/ipfw3-head/usr.bin/nl/Makefile
  user/luigi/ipfw3-head/usr.bin/nohup/Makefile
  user/luigi/ipfw3-head/usr.bin/nslookup/Makefile
  user/luigi/ipfw3-head/usr.bin/nsupdate/Makefile
  user/luigi/ipfw3-head/usr.bin/opieinfo/Makefile
  user/luigi/ipfw3-head/usr.bin/opiekey/Makefile
  user/luigi/ipfw3-head/usr.bin/opiepasswd/Makefile
  user/luigi/ipfw3-head/usr.bin/passwd/Makefile
  user/luigi/ipfw3-head/usr.bin/passwd/passwd.c
  user/luigi/ipfw3-head/usr.bin/pr/Makefile
  user/luigi/ipfw3-head/usr.bin/printf/Makefile
  user/luigi/ipfw3-head/usr.bin/procstat/Makefile
  user/luigi/ipfw3-head/usr.bin/renice/renice.c
  user/luigi/ipfw3-head/usr.bin/revoke/Makefile
  user/luigi/ipfw3-head/usr.bin/rlogin/Makefile
  user/luigi/ipfw3-head/usr.bin/rpcgen/Makefile
  user/luigi/ipfw3-head/usr.bin/rpcgen/rpc_hout.c
  user/luigi/ipfw3-head/usr.bin/rpcgen/rpc_main.c
  user/luigi/ipfw3-head/usr.bin/rpcinfo/Makefile
  user/luigi/ipfw3-head/usr.bin/rsh/Makefile
  user/luigi/ipfw3-head/usr.bin/rup/Makefile
  user/luigi/ipfw3-head/usr.bin/ruptime/Makefile
  user/luigi/ipfw3-head/usr.bin/rusers/Makefile
  user/luigi/ipfw3-head/usr.bin/rwho/Makefile
  user/luigi/ipfw3-head/usr.bin/script/script.c
  user/luigi/ipfw3-head/usr.bin/sed/Makefile
  user/luigi/ipfw3-head/usr.bin/showmount/showmount.c
  user/luigi/ipfw3-head/usr.bin/smbutil/Makefile
  user/luigi/ipfw3-head/usr.bin/sockstat/Makefile
  user/luigi/ipfw3-head/usr.bin/sockstat/sockstat.c
  user/luigi/ipfw3-head/usr.bin/su/Makefile
  user/luigi/ipfw3-head/usr.bin/systat/Makefile
  user/luigi/ipfw3-head/usr.bin/tail/Makefile
  user/luigi/ipfw3-head/usr.bin/tail/misc.c
  user/luigi/ipfw3-head/usr.bin/tar/Makefile
  user/luigi/ipfw3-head/usr.bin/tar/test/Makefile
  user/luigi/ipfw3-head/usr.bin/tcopy/Makefile
  user/luigi/ipfw3-head/usr.bin/telnet/Makefile
  user/luigi/ipfw3-head/usr.bin/tftp/tftp.c
  user/luigi/ipfw3-head/usr.bin/time/Makefile
  user/luigi/ipfw3-head/usr.bin/top/Makefile
  user/luigi/ipfw3-head/usr.bin/tr/Makefile
  user/luigi/ipfw3-head/usr.bin/truss/Makefile
  user/luigi/ipfw3-head/usr.bin/truss/syscalls.c
  user/luigi/ipfw3-head/usr.bin/unifdef/Makefile
  user/luigi/ipfw3-head/usr.bin/unzip/Makefile
  user/luigi/ipfw3-head/usr.bin/users/Makefile
  user/luigi/ipfw3-head/usr.bin/uudecode/Makefile
  user/luigi/ipfw3-head/usr.bin/uuencode/Makefile
  user/luigi/ipfw3-head/usr.bin/vacation/Makefile
  user/luigi/ipfw3-head/usr.bin/vgrind/Makefile
  user/luigi/ipfw3-head/usr.bin/vi/Makefile
  user/luigi/ipfw3-head/usr.bin/vmstat/Makefile
  user/luigi/ipfw3-head/usr.bin/w/Makefile
  user/luigi/ipfw3-head/usr.bin/wall/Makefile
  user/luigi/ipfw3-head/usr.bin/wall/wall.c
  user/luigi/ipfw3-head/usr.bin/wc/Makefile
  user/luigi/ipfw3-head/usr.bin/wc/wc.c
  user/luigi/ipfw3-head/usr.bin/whereis/Makefile
  user/luigi/ipfw3-head/usr.bin/who/Makefile
  user/luigi/ipfw3-head/usr.bin/write/Makefile
  user/luigi/ipfw3-head/usr.bin/xargs/Makefile
  user/luigi/ipfw3-head/usr.bin/xinstall/Makefile
  user/luigi/ipfw3-head/usr.bin/xlint/xlint/Makefile
  user/luigi/ipfw3-head/usr.bin/yacc/Makefile
  user/luigi/ipfw3-head/usr.bin/yacc/skeleton.c
  user/luigi/ipfw3-head/usr.bin/ypcat/Makefile
  user/luigi/ipfw3-head/usr.bin/ypmatch/Makefile
  user/luigi/ipfw3-head/usr.bin/ypwhich/Makefile
  user/luigi/ipfw3-head/usr.sbin/Makefile.inc
  user/luigi/ipfw3-head/usr.sbin/ac/Makefile
  user/luigi/ipfw3-head/usr.sbin/accton/Makefile
  user/luigi/ipfw3-head/usr.sbin/accton/accton.c
  user/luigi/ipfw3-head/usr.sbin/acpi/acpiconf/Makefile
  user/luigi/ipfw3-head/usr.sbin/acpi/acpidump/Makefile
  user/luigi/ipfw3-head/usr.sbin/acpi/iasl/Makefile
  user/luigi/ipfw3-head/usr.sbin/amd/Makefile.inc
  user/luigi/ipfw3-head/usr.sbin/ancontrol/ancontrol.c
  user/luigi/ipfw3-head/usr.sbin/apm/Makefile
  user/luigi/ipfw3-head/usr.sbin/apmd/Makefile
  user/luigi/ipfw3-head/usr.sbin/arp/arp.c
  user/luigi/ipfw3-head/usr.sbin/asf/Makefile
  user/luigi/ipfw3-head/usr.sbin/asf/asf_kld.c
  user/luigi/ipfw3-head/usr.sbin/audit/Makefile
  user/luigi/ipfw3-head/usr.sbin/auditd/Makefile
  user/luigi/ipfw3-head/usr.sbin/auditreduce/Makefile
  user/luigi/ipfw3-head/usr.sbin/authpf/Makefile
  user/luigi/ipfw3-head/usr.sbin/boot0cfg/Makefile
  user/luigi/ipfw3-head/usr.sbin/bootparamd/Makefile.inc
  user/luigi/ipfw3-head/usr.sbin/bsnmpd/bsnmpd/Makefile
  user/luigi/ipfw3-head/usr.sbin/bsnmpd/gensnmptree/Makefile
  user/luigi/ipfw3-head/usr.sbin/bsnmpd/modules/snmp_pf/Makefile
  user/luigi/ipfw3-head/usr.sbin/btxld/Makefile
  user/luigi/ipfw3-head/usr.sbin/burncd/Makefile
  user/luigi/ipfw3-head/usr.sbin/cdcontrol/Makefile
  user/luigi/ipfw3-head/usr.sbin/chkgrp/Makefile
  user/luigi/ipfw3-head/usr.sbin/chown/Makefile
  user/luigi/ipfw3-head/usr.sbin/chroot/Makefile
  user/luigi/ipfw3-head/usr.sbin/chroot/chroot.c
  user/luigi/ipfw3-head/usr.sbin/clear_locks/Makefile
  user/luigi/ipfw3-head/usr.sbin/config/Makefile
  user/luigi/ipfw3-head/usr.sbin/config/lang.l
  user/luigi/ipfw3-head/usr.sbin/cpucontrol/Makefile
  user/luigi/ipfw3-head/usr.sbin/cpucontrol/cpucontrol.c
  user/luigi/ipfw3-head/usr.sbin/cron/cron/Makefile
  user/luigi/ipfw3-head/usr.sbin/crunch/Makefile.inc
  user/luigi/ipfw3-head/usr.sbin/crunch/examples/really-big.conf
  user/luigi/ipfw3-head/usr.sbin/ctm/ctm/Makefile
  user/luigi/ipfw3-head/usr.sbin/ctm/ctm_dequeue/Makefile
  user/luigi/ipfw3-head/usr.sbin/ctm/ctm_rmail/Makefile
  user/luigi/ipfw3-head/usr.sbin/ctm/ctm_smail/Makefile
  user/luigi/ipfw3-head/usr.sbin/daemon/Makefile
  user/luigi/ipfw3-head/usr.sbin/dconschat/Makefile
  user/luigi/ipfw3-head/usr.sbin/devinfo/Makefile
  user/luigi/ipfw3-head/usr.sbin/digictl/Makefile
  user/luigi/ipfw3-head/usr.sbin/diskinfo/Makefile
  user/luigi/ipfw3-head/usr.sbin/dnssec-dsfromkey/Makefile
  user/luigi/ipfw3-head/usr.sbin/dnssec-keyfromlabel/Makefile
  user/luigi/ipfw3-head/usr.sbin/dnssec-keygen/Makefile
  user/luigi/ipfw3-head/usr.sbin/dnssec-signzone/Makefile
  user/luigi/ipfw3-head/usr.sbin/dumpcis/Makefile
  user/luigi/ipfw3-head/usr.sbin/editmap/Makefile
  user/luigi/ipfw3-head/usr.sbin/edquota/Makefile
  user/luigi/ipfw3-head/usr.sbin/eeprom/Makefile
  user/luigi/ipfw3-head/usr.sbin/eeprom/eeprom.c
  user/luigi/ipfw3-head/usr.sbin/extattr/Makefile
  user/luigi/ipfw3-head/usr.sbin/extattrctl/Makefile
  user/luigi/ipfw3-head/usr.sbin/extattrctl/extattrctl.c
  user/luigi/ipfw3-head/usr.sbin/faithd/Makefile
  user/luigi/ipfw3-head/usr.sbin/faithd/faithd.c
  user/luigi/ipfw3-head/usr.sbin/fdcontrol/Makefile
  user/luigi/ipfw3-head/usr.sbin/fdformat/Makefile
  user/luigi/ipfw3-head/usr.sbin/fdread/Makefile
  user/luigi/ipfw3-head/usr.sbin/fdwrite/Makefile
  user/luigi/ipfw3-head/usr.sbin/fifolog/Makefile.inc
  user/luigi/ipfw3-head/usr.sbin/fifolog/lib/getdate.y
  user/luigi/ipfw3-head/usr.sbin/ftp-proxy/libevent/Makefile
  user/luigi/ipfw3-head/usr.sbin/getfmac/Makefile
  user/luigi/ipfw3-head/usr.sbin/getpmac/Makefile
  user/luigi/ipfw3-head/usr.sbin/gstat/Makefile
  user/luigi/ipfw3-head/usr.sbin/inetd/Makefile
  user/luigi/ipfw3-head/usr.sbin/inetd/inetd.c
  user/luigi/ipfw3-head/usr.sbin/iostat/Makefile
  user/luigi/ipfw3-head/usr.sbin/ip6addrctl/Makefile
  user/luigi/ipfw3-head/usr.sbin/ipfwpcap/Makefile
  user/luigi/ipfw3-head/usr.sbin/jail/Makefile
  user/luigi/ipfw3-head/usr.sbin/jexec/Makefile
  user/luigi/ipfw3-head/usr.sbin/jls/Makefile
  user/luigi/ipfw3-head/usr.sbin/kbdcontrol/kbdcontrol.c
  user/luigi/ipfw3-head/usr.sbin/kernbb/Makefile
  user/luigi/ipfw3-head/usr.sbin/lastlogin/Makefile
  user/luigi/ipfw3-head/usr.sbin/lastlogin/lastlogin.c
  user/luigi/ipfw3-head/usr.sbin/lmcconfig/Makefile
  user/luigi/ipfw3-head/usr.sbin/lpr/common_source/Makefile
  user/luigi/ipfw3-head/usr.sbin/lpr/filters.ru/Makefile.inc
  user/luigi/ipfw3-head/usr.sbin/lpr/lpc/Makefile
  user/luigi/ipfw3-head/usr.sbin/lpr/lpd/Makefile
  user/luigi/ipfw3-head/usr.sbin/lpr/lpr/Makefile
  user/luigi/ipfw3-head/usr.sbin/lptcontrol/Makefile
  user/luigi/ipfw3-head/usr.sbin/mailstats/Makefile
  user/luigi/ipfw3-head/usr.sbin/mailwrapper/Makefile
  user/luigi/ipfw3-head/usr.sbin/makemap/Makefile
  user/luigi/ipfw3-head/usr.sbin/memcontrol/Makefile
  user/luigi/ipfw3-head/usr.sbin/mergemaster/mergemaster.8
  user/luigi/ipfw3-head/usr.sbin/mergemaster/mergemaster.sh
  user/luigi/ipfw3-head/usr.sbin/mixer/Makefile
  user/luigi/ipfw3-head/usr.sbin/mld6query/Makefile
  user/luigi/ipfw3-head/usr.sbin/mlxcontrol/Makefile
  user/luigi/ipfw3-head/usr.sbin/mount_portalfs/mount_portalfs.c
  user/luigi/ipfw3-head/usr.sbin/mount_smbfs/Makefile
  user/luigi/ipfw3-head/usr.sbin/moused/Makefile
  user/luigi/ipfw3-head/usr.sbin/mptable/Makefile
  user/luigi/ipfw3-head/usr.sbin/mtree/Makefile
  user/luigi/ipfw3-head/usr.sbin/named-checkconf/Makefile
  user/luigi/ipfw3-head/usr.sbin/named-checkzone/Makefile
  user/luigi/ipfw3-head/usr.sbin/named/Makefile
  user/luigi/ipfw3-head/usr.sbin/ndiscvt/ndiscvt.c
  user/luigi/ipfw3-head/usr.sbin/ndp/Makefile
  user/luigi/ipfw3-head/usr.sbin/newsyslog/Makefile
  user/luigi/ipfw3-head/usr.sbin/nfsd/Makefile
  user/luigi/ipfw3-head/usr.sbin/nfsd/nfsd.c
  user/luigi/ipfw3-head/usr.sbin/nghook/Makefile
  user/luigi/ipfw3-head/usr.sbin/nscd/nscd.conf.5
  user/luigi/ipfw3-head/usr.sbin/ntp/Makefile.inc
  user/luigi/ipfw3-head/usr.sbin/ntp/doc/Makefile
  user/luigi/ipfw3-head/usr.sbin/nvram/Makefile
  user/luigi/ipfw3-head/usr.sbin/ofwdump/Makefile
  user/luigi/ipfw3-head/usr.sbin/pciconf/Makefile
  user/luigi/ipfw3-head/usr.sbin/pkg_install/add/main.c
  user/luigi/ipfw3-head/usr.sbin/pkg_install/create/main.c
  user/luigi/ipfw3-head/usr.sbin/pkg_install/delete/Makefile
  user/luigi/ipfw3-head/usr.sbin/pkg_install/delete/main.c
  user/luigi/ipfw3-head/usr.sbin/pkg_install/info/Makefile
  user/luigi/ipfw3-head/usr.sbin/pkg_install/info/main.c
  user/luigi/ipfw3-head/usr.sbin/pkg_install/updating/Makefile
  user/luigi/ipfw3-head/usr.sbin/pkg_install/version/Makefile
  user/luigi/ipfw3-head/usr.sbin/pkg_install/version/main.c
  user/luigi/ipfw3-head/usr.sbin/pmcannotate/Makefile
  user/luigi/ipfw3-head/usr.sbin/pmcannotate/pmcannotate.c
  user/luigi/ipfw3-head/usr.sbin/pmccontrol/Makefile
  user/luigi/ipfw3-head/usr.sbin/pmcstat/Makefile
  user/luigi/ipfw3-head/usr.sbin/pnpinfo/Makefile
  user/luigi/ipfw3-head/usr.sbin/portsnap/make_index/Makefile
  user/luigi/ipfw3-head/usr.sbin/portsnap/phttpget/Makefile
  user/luigi/ipfw3-head/usr.sbin/portsnap/portsnap/portsnap.sh
  user/luigi/ipfw3-head/usr.sbin/powerd/Makefile
  user/luigi/ipfw3-head/usr.sbin/powerd/powerd.c
  user/luigi/ipfw3-head/usr.sbin/pppctl/Makefile
  user/luigi/ipfw3-head/usr.sbin/praliases/Makefile
  user/luigi/ipfw3-head/usr.sbin/praudit/Makefile
  user/luigi/ipfw3-head/usr.sbin/procctl/Makefile
  user/luigi/ipfw3-head/usr.sbin/pstat/Makefile
  user/luigi/ipfw3-head/usr.sbin/pw/Makefile
  user/luigi/ipfw3-head/usr.sbin/pwd_mkdb/Makefile
  user/luigi/ipfw3-head/usr.sbin/quotaon/Makefile
  user/luigi/ipfw3-head/usr.sbin/quotaon/quotaon.c
  user/luigi/ipfw3-head/usr.sbin/repquota/Makefile
  user/luigi/ipfw3-head/usr.sbin/rip6query/Makefile
  user/luigi/ipfw3-head/usr.sbin/rip6query/rip6query.c
  user/luigi/ipfw3-head/usr.sbin/rmt/Makefile
  user/luigi/ipfw3-head/usr.sbin/rmt/rmt.c
  user/luigi/ipfw3-head/usr.sbin/rndc-confgen/Makefile
  user/luigi/ipfw3-head/usr.sbin/rndc/Makefile
  user/luigi/ipfw3-head/usr.sbin/route6d/Makefile
  user/luigi/ipfw3-head/usr.sbin/rpc.lockd/Makefile
  user/luigi/ipfw3-head/usr.sbin/rpc.statd/Makefile
  user/luigi/ipfw3-head/usr.sbin/rpc.umntall/Makefile
  user/luigi/ipfw3-head/usr.sbin/rpc.umntall/mounttab.c
  user/luigi/ipfw3-head/usr.sbin/rpc.yppasswdd/Makefile
  user/luigi/ipfw3-head/usr.sbin/rpc.ypupdated/Makefile
  user/luigi/ipfw3-head/usr.sbin/rpc.ypxfrd/Makefile
  user/luigi/ipfw3-head/usr.sbin/rpcbind/Makefile
  user/luigi/ipfw3-head/usr.sbin/rrenumd/Makefile
  user/luigi/ipfw3-head/usr.sbin/rtadvd/Makefile
  user/luigi/ipfw3-head/usr.sbin/rtprio/Makefile
  user/luigi/ipfw3-head/usr.sbin/rtsold/Makefile
  user/luigi/ipfw3-head/usr.sbin/rwhod/Makefile
  user/luigi/ipfw3-head/usr.sbin/sa/Makefile
  user/luigi/ipfw3-head/usr.sbin/sa/main.c
  user/luigi/ipfw3-head/usr.sbin/sa/pdb.c
  user/luigi/ipfw3-head/usr.sbin/sa/usrdb.c
  user/luigi/ipfw3-head/usr.sbin/sendmail/Makefile
  user/luigi/ipfw3-head/usr.sbin/setfmac/Makefile
  user/luigi/ipfw3-head/usr.sbin/setpmac/Makefile
  user/luigi/ipfw3-head/usr.sbin/smbmsg/Makefile
  user/luigi/ipfw3-head/usr.sbin/snapinfo/snapinfo.c
  user/luigi/ipfw3-head/usr.sbin/sysinstall/Makefile
  user/luigi/ipfw3-head/usr.sbin/sysinstall/disks.c
  user/luigi/ipfw3-head/usr.sbin/sysinstall/label.c
  user/luigi/ipfw3-head/usr.sbin/tcpdchk/Makefile
  user/luigi/ipfw3-head/usr.sbin/tcpdmatch/Makefile
  user/luigi/ipfw3-head/usr.sbin/tcpdrop/Makefile
  user/luigi/ipfw3-head/usr.sbin/tcpdump/Makefile.inc
  user/luigi/ipfw3-head/usr.sbin/traceroute/Makefile
  user/luigi/ipfw3-head/usr.sbin/traceroute6/Makefile
  user/luigi/ipfw3-head/usr.sbin/tzsetup/Makefile
  user/luigi/ipfw3-head/usr.sbin/uathload/Makefile
  user/luigi/ipfw3-head/usr.sbin/usbdevs/Makefile
  user/luigi/ipfw3-head/usr.sbin/vidcontrol/Makefile
  user/luigi/ipfw3-head/usr.sbin/vipw/Makefile
  user/luigi/ipfw3-head/usr.sbin/wake/Makefile
  user/luigi/ipfw3-head/usr.sbin/wake/wake.8
  user/luigi/ipfw3-head/usr.sbin/watchdogd/Makefile
  user/luigi/ipfw3-head/usr.sbin/watchdogd/watchdogd.c
  user/luigi/ipfw3-head/usr.sbin/wlandebug/Makefile
  user/luigi/ipfw3-head/usr.sbin/wlconfig/Makefile
  user/luigi/ipfw3-head/usr.sbin/yp_mkdb/Makefile
  user/luigi/ipfw3-head/usr.sbin/ypbind/Makefile
  user/luigi/ipfw3-head/usr.sbin/yppoll/Makefile
  user/luigi/ipfw3-head/usr.sbin/yppush/Makefile
  user/luigi/ipfw3-head/usr.sbin/yppush/yppush_main.c
  user/luigi/ipfw3-head/usr.sbin/ypserv/Makefile
  user/luigi/ipfw3-head/usr.sbin/ypset/Makefile
  user/luigi/ipfw3-head/usr.sbin/zic/zdump/Makefile
  user/luigi/ipfw3-head/usr.sbin/zic/zic/Makefile
Directory Properties:
  user/luigi/ipfw3-head/   (props changed)
  user/luigi/ipfw3-head/cddl/contrib/opensolaris/   (props changed)
  user/luigi/ipfw3-head/contrib/bind9/   (props changed)
  user/luigi/ipfw3-head/contrib/cpio/   (props changed)
  user/luigi/ipfw3-head/contrib/csup/   (props changed)
  user/luigi/ipfw3-head/contrib/ee/   (props changed)
  user/luigi/ipfw3-head/contrib/expat/   (props changed)
  user/luigi/ipfw3-head/contrib/file/   (props changed)
  user/luigi/ipfw3-head/contrib/gdb/   (props changed)
  user/luigi/ipfw3-head/contrib/gdtoa/   (props changed)
  user/luigi/ipfw3-head/contrib/less/   (props changed)
  user/luigi/ipfw3-head/contrib/libpcap/   (props changed)
  user/luigi/ipfw3-head/contrib/ncurses/   (props changed)
  user/luigi/ipfw3-head/contrib/netcat/   (props changed)
  user/luigi/ipfw3-head/contrib/ntp/   (props changed)
  user/luigi/ipfw3-head/contrib/openbsm/   (props changed)
  user/luigi/ipfw3-head/contrib/openpam/   (props changed)
  user/luigi/ipfw3-head/contrib/pf/   (props changed)
  user/luigi/ipfw3-head/contrib/sendmail/   (props changed)
  user/luigi/ipfw3-head/contrib/tcpdump/   (props changed)
  user/luigi/ipfw3-head/contrib/tcsh/   (props changed)
  user/luigi/ipfw3-head/contrib/top/   (props changed)
  user/luigi/ipfw3-head/contrib/top/install-sh   (props changed)
  user/luigi/ipfw3-head/contrib/wpa/   (props changed)
  user/luigi/ipfw3-head/crypto/openssh/   (props changed)
  user/luigi/ipfw3-head/crypto/openssl/   (props changed)
  user/luigi/ipfw3-head/lib/libc/   (props changed)
  user/luigi/ipfw3-head/lib/libc/stdtime/   (props changed)
  user/luigi/ipfw3-head/lib/libutil/   (props changed)
  user/luigi/ipfw3-head/sbin/   (props changed)
  user/luigi/ipfw3-head/sbin/ipfw/   (props changed)
  user/luigi/ipfw3-head/share/zoneinfo/   (props changed)
  user/luigi/ipfw3-head/sys/   (props changed)
  user/luigi/ipfw3-head/sys/amd64/include/xen/   (props changed)
  user/luigi/ipfw3-head/sys/cddl/contrib/opensolaris/   (props changed)
  user/luigi/ipfw3-head/sys/contrib/dev/acpica/   (props changed)
  user/luigi/ipfw3-head/sys/contrib/pf/   (props changed)
  user/luigi/ipfw3-head/sys/dev/xen/xenpci/   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/lastcomm/regress.t   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd/expected.status.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd/expected.status.2   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd/expected.status.3   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd/expected.status.4   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd/expected.status.5   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd/expected.status.6   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd/expected.status.7   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd/expected.stderr.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd/expected.stderr.2   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd/expected.stderr.3   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd/expected.stderr.4   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd/expected.stderr.5   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd/expected.stderr.6   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd/expected.stderr.7   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd/expected.stdout.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd/expected.stdout.2   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd/expected.stdout.3   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd/expected.stdout.4   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd/expected.stdout.5   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd/expected.stdout.6   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd/expected.stdout.7   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd_mod/expected.status.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd_mod/expected.status.2   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd_mod/expected.status.3   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd_mod/expected.status.4   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd_mod/expected.status.5   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd_mod/expected.status.6   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd_mod/expected.status.7   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd_mod/expected.stderr.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd_mod/expected.stderr.2   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd_mod/expected.stderr.3   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd_mod/expected.stderr.4   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd_mod/expected.stderr.5   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd_mod/expected.stderr.6   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd_mod/expected.stderr.7   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd_mod/expected.stdout.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd_mod/expected.stdout.2   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd_mod/expected.stdout.3   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd_mod/expected.stdout.4   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd_mod/expected.stdout.5   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd_mod/expected.stdout.6   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_44bsd_mod/expected.stdout.7   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_oldbsd/expected.status.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_oldbsd/expected.status.2   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_oldbsd/expected.status.3   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_oldbsd/expected.status.4   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_oldbsd/expected.status.5   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_oldbsd/expected.status.6   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_oldbsd/expected.status.7   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_oldbsd/expected.stderr.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_oldbsd/expected.stderr.2   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_oldbsd/expected.stderr.3   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_oldbsd/expected.stderr.4   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_oldbsd/expected.stderr.5   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_oldbsd/expected.stderr.6   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_oldbsd/expected.stderr.7   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_oldbsd/expected.stdout.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_oldbsd/expected.stdout.2   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_oldbsd/expected.stdout.3   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_oldbsd/expected.stdout.4   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_oldbsd/expected.stdout.5   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_oldbsd/expected.stdout.6   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/archives/fmt_oldbsd/expected.stdout.7   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/basic/t0/expected.status.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/basic/t0/expected.stderr.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/basic/t0/expected.stdout.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/basic/t1/expected.status.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/basic/t1/expected.stderr.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/basic/t1/expected.stdout.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/basic/t2/expected.status.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/basic/t2/expected.stderr.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/basic/t2/expected.stdout.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/basic/t3/expected.status.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/basic/t3/expected.stderr.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/basic/t3/expected.stdout.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/shell/builtin/expected.status.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/shell/builtin/expected.status.2   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/shell/builtin/expected.stderr.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/shell/builtin/expected.stderr.2   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/shell/builtin/expected.stdout.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/shell/builtin/expected.stdout.2   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/shell/path/expected.status.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/shell/path/expected.status.2   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/shell/path/expected.stderr.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/shell/path/expected.stderr.2   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/shell/path/expected.stdout.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/shell/path/expected.stdout.2   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/shell/path_select/expected.status.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/shell/path_select/expected.status.2   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/shell/path_select/expected.stderr.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/shell/path_select/expected.stderr.2   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/shell/path_select/expected.stdout.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/shell/path_select/expected.stdout.2   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/shell/replace/expected.status.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/shell/replace/expected.status.2   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/shell/replace/expected.stderr.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/shell/replace/expected.stderr.2   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/shell/replace/expected.stdout.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/shell/replace/expected.stdout.2   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/shell/select/expected.status.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/shell/select/expected.status.2   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/shell/select/expected.stderr.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/shell/select/expected.stderr.2   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/shell/select/expected.stdout.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/shell/select/expected.stdout.2   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/suffixes/basic/expected.status.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/suffixes/basic/expected.stderr.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/suffixes/basic/expected.stdout.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/suffixes/src_wild1/expected.status.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/suffixes/src_wild1/expected.stderr.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/suffixes/src_wild1/expected.stdout.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/suffixes/src_wild2/expected.status.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/suffixes/src_wild2/expected.stderr.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/suffixes/src_wild2/expected.stdout.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/syntax/enl/expected.status.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/syntax/enl/expected.status.2   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/syntax/enl/expected.stderr.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/syntax/enl/expected.stderr.2   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/syntax/enl/expected.stdout.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/syntax/enl/expected.stdout.2   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/syntax/semi/expected.status.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/syntax/semi/expected.status.2   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/syntax/semi/expected.stderr.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/syntax/semi/expected.stderr.2   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/syntax/semi/expected.stdout.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/syntax/semi/expected.stdout.2   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/variables/modifier_M/expected.status.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/variables/modifier_M/expected.stderr.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/variables/modifier_M/expected.stdout.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/variables/t0/expected.status.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/variables/t0/expected.stderr.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.bin/make/variables/t0/expected.stdout.1   (props changed)
  user/luigi/ipfw3-head/tools/regression/usr.sbin/sa/regress.t   (props changed)
  user/luigi/ipfw3-head/usr.bin/csup/   (props changed)
  user/luigi/ipfw3-head/usr.bin/procstat/   (props changed)
  user/luigi/ipfw3-head/usr.sbin/zic/   (props changed)

Modified: user/luigi/ipfw3-head/COPYRIGHT
==============================================================================
--- user/luigi/ipfw3-head/COPYRIGHT	Mon Jan  4 11:11:37 2010	(r201491)
+++ user/luigi/ipfw3-head/COPYRIGHT	Mon Jan  4 11:29:55 2010	(r201492)
@@ -4,7 +4,7 @@
 The compilation of software known as FreeBSD is distributed under the
 following terms:
 
-Copyright (c) 1992-2009 The FreeBSD Project. All rights reserved.
+Copyright (c) 1992-2010 The FreeBSD Project. All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions

Modified: user/luigi/ipfw3-head/MAINTAINERS
==============================================================================
--- user/luigi/ipfw3-head/MAINTAINERS	Mon Jan  4 11:11:37 2010	(r201491)
+++ user/luigi/ipfw3-head/MAINTAINERS	Mon Jan  4 11:29:55 2010	(r201492)
@@ -48,7 +48,6 @@ iostat(8)	ken	Pre-commit review requeste
 cd(4)		ken	Pre-commit review requested.
 pass(4)		ken	Pre-commit review requested.
 ch(4)		ken	Pre-commit review requested.
-isp(4)		mjacob	Pre-commit review requested.
 em(4)		jfv	Pre-commit review requested.
 tdfx(4)		cokane  Just keep me informed of changes, try not to break it.
 sendmail	gshapiro	Pre-commit review requested.

Modified: user/luigi/ipfw3-head/Makefile.inc1
==============================================================================
--- user/luigi/ipfw3-head/Makefile.inc1	Mon Jan  4 11:11:37 2010	(r201491)
+++ user/luigi/ipfw3-head/Makefile.inc1	Mon Jan  4 11:29:55 2010	(r201492)
@@ -940,6 +940,11 @@ _mklocale=	usr.bin/mklocale
 _sed=		usr.bin/sed
 .endif
 
+.if ${BOOTSTRAPPING} < 900006
+_lex=		usr.bin/lex
+_yacc=		usr.bin/yacc
+.endif
+
 .if ${BOOTSTRAPPING} < 700018
 _gensnmptree=	usr.sbin/bsnmpd/gensnmptree
 .endif
@@ -966,6 +971,8 @@ bootstrap-tools:
     ${_mklocale} \
     usr.bin/rpcgen \
     ${_sed} \
+    ${_lex} \
+    ${_yacc} \
     usr.bin/xinstall \
     ${_gensnmptree} \
     usr.sbin/config \

Modified: user/luigi/ipfw3-head/ObsoleteFiles.inc
==============================================================================
--- user/luigi/ipfw3-head/ObsoleteFiles.inc	Mon Jan  4 11:11:37 2010	(r201491)
+++ user/luigi/ipfw3-head/ObsoleteFiles.inc	Mon Jan  4 11:29:55 2010	(r201492)
@@ -14,6 +14,32 @@
 # The file is partitioned: OLD_FILES first, then OLD_LIBS and OLD_DIRS last.
 #
 
+# 20100103: ntptrace(8) removed
+OLD_FILES+=usr/sbin/ntptrace
+OLD_FILES+=usr/share/man/man8/ntptrace.8.gz
+# 20091229: remove no longer relevant examples
+OLD_FILES+=usr/share/examples/pppd/auth-down.sample
+OLD_FILES+=usr/share/examples/pppd/auth-up.sample
+OLD_FILES+=usr/share/examples/pppd/chap-secrets.sample
+OLD_FILES+=usr/share/examples/pppd/chat.sh.sample
+OLD_FILES+=usr/share/examples/pppd/ip-down.sample
+OLD_FILES+=usr/share/examples/pppd/ip-up.sample
+OLD_FILES+=usr/share/examples/pppd/options.sample
+OLD_FILES+=usr/share/examples/pppd/pap-secrets.sample
+OLD_FILES+=usr/share/examples/pppd/ppp.deny.sample
+OLD_FILES+=usr/share/examples/pppd/ppp.shells.sample
+OLD_DIRS+=usr/share/examples/pppd
+OLD_FILES+=usr/share/examples/slattach/unit-command.sh
+OLD_DIRS+=usr/share/examples/slattach
+OLD_FILES+=usr/share/examples/sliplogin/slip.hosts
+OLD_FILES+=usr/share/examples/sliplogin/slip.login
+OLD_FILES+=usr/share/examples/sliplogin/slip.logout
+OLD_FILES+=usr/share/examples/sliplogin/slip.slparms
+OLD_DIRS+=usr/share/examples/sliplogin
+OLD_FILES+=usr/share/examples/startslip/sldown.sh
+OLD_FILES+=usr/share/examples/startslip/slip.sh
+OLD_FILES+=usr/share/examples/startslip/slup.sh
+OLD_DIRS+=usr/share/examples/startslip
 # 20091202: unify rc.firewall and rc.firewall6.
 OLD_FILES+=etc/rc.d/ip6fw
 OLD_FILES+=etc/rc.firewall6

Modified: user/luigi/ipfw3-head/bin/kenv/kenv.c
==============================================================================
--- user/luigi/ipfw3-head/bin/kenv/kenv.c	Mon Jan  4 11:11:37 2010	(r201491)
+++ user/luigi/ipfw3-head/bin/kenv/kenv.c	Mon Jan  4 11:29:55 2010	(r201492)
@@ -118,7 +118,7 @@ main(int argc, char **argv)
 }
 
 static int
-kdumpenv()
+kdumpenv(void)
 {
 	char *buf, *cp;
 	int buflen, envlen;

Modified: user/luigi/ipfw3-head/bin/pax/ftree.c
==============================================================================
--- user/luigi/ipfw3-head/bin/pax/ftree.c	Mon Jan  4 11:11:37 2010	(r201491)
+++ user/luigi/ipfw3-head/bin/pax/ftree.c	Mon Jan  4 11:29:55 2010	(r201492)
@@ -219,7 +219,7 @@ ftree_sel(ARCHD *arcn)
  */
 
 void
-ftree_notsel()
+ftree_notsel(void)
 {
 	if (ftent != NULL)
 		(void)fts_set(ftsp, ftent, FTS_SKIP);

Modified: user/luigi/ipfw3-head/bin/pkill/pkill.c
==============================================================================
--- user/luigi/ipfw3-head/bin/pkill/pkill.c	Mon Jan  4 11:11:37 2010	(r201491)
+++ user/luigi/ipfw3-head/bin/pkill/pkill.c	Mon Jan  4 11:29:55 2010	(r201492)
@@ -670,9 +670,6 @@ makelist(struct listhead *head, enum lis
 				if (li->li_number == 0)
 					li->li_number = -1;	/* any jail */
 				break;
-			case LT_TTY:
-				usage();
-				/* NOTREACHED */
 			default:
 				break;
 			}
@@ -708,6 +705,10 @@ makelist(struct listhead *head, enum lis
 			if (stat(buf, &st) != -1)
 				goto foundtty;
 
+			snprintf(buf, sizeof(buf), _PATH_DEV "pts/%s", cp);
+			if (stat(buf, &st) != -1)
+				goto foundtty;
+
 			if (errno == ENOENT)
 				errx(STATUS_BADUSAGE, "No such tty: `%s'", sp);
 			err(STATUS_ERROR, "Cannot access `%s'", sp);

Modified: user/luigi/ipfw3-head/bin/sh/arith.y
==============================================================================
--- user/luigi/ipfw3-head/bin/sh/arith.y	Mon Jan  4 11:11:37 2010	(r201491)
+++ user/luigi/ipfw3-head/bin/sh/arith.y	Mon Jan  4 11:29:55 2010	(r201492)
@@ -85,9 +85,9 @@ expr:
 	ARITH_LPAREN expr ARITH_RPAREN
 		{ $$ = $2; } |
 	expr ARITH_OR expr
-		{ $$ = $1 ? $1 : $3 ? $3 : 0; } |
+		{ $$ = $1 || $3; } |
 	expr ARITH_AND expr
-		{ $$ = $1 ? ( $3 ? $3 : 0 ) : 0; } |
+		{ $$ = $1 && $3; } |
 	expr ARITH_BOR expr
 		{ $$ = $1 | $3; } |
 	expr ARITH_BXOR expr

Modified: user/luigi/ipfw3-head/bin/sh/error.c
==============================================================================
--- user/luigi/ipfw3-head/bin/sh/error.c	Mon Jan  4 11:11:37 2010	(r201491)
+++ user/luigi/ipfw3-head/bin/sh/error.c	Mon Jan  4 11:29:55 2010	(r201492)
@@ -160,8 +160,8 @@ exverror(int cond, const char *msg, va_l
 #endif
 	if (msg) {
 		if (commandname)
-			outfmt(&errout, "%s: ", commandname);
-		doformat(&errout, msg, ap);
+			outfmt(out2, "%s: ", commandname);
+		doformat(out2, msg, ap);
 		out2c('\n');
 	}
 	flushall();

Modified: user/luigi/ipfw3-head/bin/sh/eval.c
==============================================================================
--- user/luigi/ipfw3-head/bin/sh/eval.c	Mon Jan  4 11:11:37 2010	(r201491)
+++ user/luigi/ipfw3-head/bin/sh/eval.c	Mon Jan  4 11:29:55 2010	(r201492)
@@ -646,7 +646,7 @@ evalcommand(union node *cmd, int flags, 
 		out2str(ps4val());
 		for (sp = varlist.list ; sp ; sp = sp->next) {
 			if (sep != 0)
-				outc(' ', &errout);
+				out2c(' ');
 			p = sp->text;
 			while (*p != '=' && *p != '\0')
 				out2c(*p++);
@@ -658,7 +658,7 @@ evalcommand(union node *cmd, int flags, 
 		}
 		for (sp = arglist.list ; sp ; sp = sp->next) {
 			if (sep != 0)
-				outc(' ', &errout);
+				out2c(' ');
 			/* Disambiguate command looking like assignment. */
 			if (sp == arglist.list &&
 					strchr(sp->text, '=') != NULL &&
@@ -670,7 +670,7 @@ evalcommand(union node *cmd, int flags, 
 				out2qstr(sp->text);
 			sep = ' ';
 		}
-		outc('\n', &errout);
+		out2c('\n');
 		flushout(&errout);
 	}
 
@@ -722,10 +722,10 @@ evalcommand(union node *cmd, int flags, 
 					break;
 				if ((cmdentry.u.index = find_builtin(*argv,
 				    &cmdentry.special)) < 0) {
-					outfmt(&errout, "%s: not found\n", *argv);
-					exitstatus = 127;
-					flushout(&errout);
-					return;
+					cmdentry.u.index = BLTINCMD;
+					argv--;
+					argc++;
+					break;
 				}
 				if (cmdentry.u.index != BLTINCMD)
 					break;
@@ -792,20 +792,20 @@ evalcommand(union node *cmd, int flags, 
 			unreffunc(cmdentry.u.func);
 			poplocalvars();
 			localvars = savelocalvars;
+			funcnest--;
 			handler = savehandler;
 			longjmp(handler->loc, 1);
 		}
 		handler = &jmploc;
+		funcnest++;
 		INTON;
 		for (sp = varlist.list ; sp ; sp = sp->next)
 			mklocal(sp->text);
-		funcnest++;
 		exitstatus = oexitstatus;
 		if (flags & EV_TESTED)
 			evaltree(getfuncnode(cmdentry.u.func), EV_TESTED);
 		else
 			evaltree(getfuncnode(cmdentry.u.func), 0);
-		funcnest--;
 		INTOFF;
 		unreffunc(cmdentry.u.func);
 		poplocalvars();
@@ -813,6 +813,7 @@ evalcommand(union node *cmd, int flags, 
 		freeparam(&shellparam);
 		shellparam = saveparam;
 		handler = savehandler;
+		funcnest--;
 		popredir();
 		INTON;
 		if (evalskip == SKIPFUNC) {
@@ -831,6 +832,7 @@ evalcommand(union node *cmd, int flags, 
 			memout.nextc = memout.buf;
 			memout.bufsize = 64;
 			mode |= REDIR_BACKQ;
+			cmdentry.special = 0;
 		}
 		savecmdname = commandname;
 		savetopfile = getcurrentfile();
@@ -864,20 +866,21 @@ cmddone:
 			}
 		}
 		handler = savehandler;
+		if (flags == EV_BACKCMD) {
+			backcmd->buf = memout.buf;
+			backcmd->nleft = memout.nextc - memout.buf;
+			memout.buf = NULL;
+		}
 		if (e != -1) {
 			if ((e != EXERROR && e != EXEXEC)
 			    || cmdentry.special)
 				exraise(e);
 			popfilesupto(savetopfile);
-			FORCEINTON;
+			if (flags != EV_BACKCMD)
+				FORCEINTON;
 		}
 		if (cmdentry.u.index != EXECCMD)
 			popredir();
-		if (flags == EV_BACKCMD) {
-			backcmd->buf = memout.buf;
-			backcmd->nleft = memout.nextc - memout.buf;
-			memout.buf = NULL;
-		}
 	} else {
 #ifdef DEBUG
 		trputs("normal command:  ");  trargs(argv);
@@ -942,12 +945,17 @@ prehash(union node *n)
  */
 
 /*
- * No command given, or a bltin command with no arguments.
+ * No command given, a bltin command with no arguments, or a bltin command
+ * with an invalid name.
  */
 
 int
-bltincmd(int argc __unused, char **argv __unused)
+bltincmd(int argc, char **argv)
 {
+	if (argc > 1) {
+		out2fmt_flush("%s: not found\n", argv[1]);
+		return 127;
+	}
 	/*
 	 * Preserve exitstatus of a previous possible redirection
 	 * as POSIX mandates
@@ -1022,7 +1030,7 @@ commandcmd(int argc, char **argv)
 	if (cmd != -1) {
 		if (argc != 1)
 			error("wrong number of arguments");
-		return typecmd_impl(2, argv - 1, cmd);
+		return typecmd_impl(2, argv - 1, cmd, path);
 	}
 	if (argc != 0) {
 		old = handler;

Modified: user/luigi/ipfw3-head/bin/sh/exec.c
==============================================================================
--- user/luigi/ipfw3-head/bin/sh/exec.c	Mon Jan  4 11:11:37 2010	(r201491)
+++ user/luigi/ipfw3-head/bin/sh/exec.c	Mon Jan  4 11:29:55 2010	(r201492)
@@ -255,7 +255,7 @@ hashcmd(int argc __unused, char **argv _
 				if (cmdp != NULL)
 					printentry(cmdp, verbose);
 				else
-					outfmt(&errout, "%s: not found\n", name);
+					outfmt(out2, "%s: not found\n", name);
 			}
 			flushall();
 		}
@@ -720,7 +720,7 @@ unsetfunc(const char *name)
  */
 
 int
-typecmd_impl(int argc, char **argv, int cmd)
+typecmd_impl(int argc, char **argv, int cmd, const char *path)
 {
 	struct cmdentry entry;
 	struct tblentry *cmdp;
@@ -729,6 +729,9 @@ typecmd_impl(int argc, char **argv, int 
 	int i;
 	int error1 = 0;
 
+	if (path != pathval())
+		clearcmdentry(0);
+
 	for (i = 1; i < argc; i++) {
 		/* First look at the keywords */
 		for (pp = parsekwd; *pp; pp++)
@@ -761,17 +764,17 @@ typecmd_impl(int argc, char **argv, int 
 		}
 		else {
 			/* Finally use brute force */
-			find_command(argv[i], &entry, 0, pathval());
+			find_command(argv[i], &entry, 0, path);
 		}
 
 		switch (entry.cmdtype) {
 		case CMDNORMAL: {
 			if (strchr(argv[i], '/') == NULL) {
-				const char *path = pathval();
+				const char *path2 = path;
 				char *name;
 				int j = entry.u.index;
 				do {
-					name = padvance(&path, argv[i]);
+					name = padvance(&path2, argv[i]);
 					stunalloc(name);
 				} while (--j >= 0);
 				if (cmd == TYPECMD_SMALLV)
@@ -821,6 +824,10 @@ typecmd_impl(int argc, char **argv, int 
 			break;
 		}
 	}
+
+	if (path != pathval())
+		clearcmdentry(0);
+
 	return error1;
 }
 
@@ -831,5 +838,5 @@ typecmd_impl(int argc, char **argv, int 
 int
 typecmd(int argc, char **argv)
 {
-	return typecmd_impl(argc, argv, TYPECMD_TYPE);
+	return typecmd_impl(argc, argv, TYPECMD_TYPE, bltinlookup("PATH", 1));
 }

Modified: user/luigi/ipfw3-head/bin/sh/exec.h
==============================================================================
--- user/luigi/ipfw3-head/bin/sh/exec.h	Mon Jan  4 11:11:37 2010	(r201491)
+++ user/luigi/ipfw3-head/bin/sh/exec.h	Mon Jan  4 11:29:55 2010	(r201492)
@@ -71,6 +71,6 @@ void deletefuncs(void);
 void addcmdentry(const char *, struct cmdentry *);
 void defun(const char *, union node *);
 int unsetfunc(const char *);
-int typecmd_impl(int, char **, int);
+int typecmd_impl(int, char **, int, const char *);
 int typecmd(int, char **);
 void clearcmdentry(int);

Modified: user/luigi/ipfw3-head/bin/sh/expand.c
==============================================================================
--- user/luigi/ipfw3-head/bin/sh/expand.c	Mon Jan  4 11:11:37 2010	(r201491)
+++ user/luigi/ipfw3-head/bin/sh/expand.c	Mon Jan  4 11:29:55 2010	(r201492)
@@ -526,7 +526,7 @@ subevalvar(char *p, char *str, int strlo
 
 	case VSQUESTION:
 		if (*p != CTLENDVAR) {
-			outfmt(&errout, "%s\n", startp);
+			outfmt(out2, "%s\n", startp);
 			error((char *)NULL);
 		}
 		error("%.*s: parameter %snot set", (int)(p - str - 1),

Modified: user/luigi/ipfw3-head/bin/sh/output.h
==============================================================================
--- user/luigi/ipfw3-head/bin/sh/output.h	Mon Jan  4 11:11:37 2010	(r201491)
+++ user/luigi/ipfw3-head/bin/sh/output.h	Mon Jan  4 11:29:55 2010	(r201492)
@@ -46,11 +46,12 @@ struct output {
 	short flags;
 };
 
-extern struct output output;
-extern struct output errout;
+extern struct output output; /* to fd 1 */
+extern struct output errout; /* to fd 2 */
 extern struct output memout;
-extern struct output *out1;
-extern struct output *out2;
+extern struct output *out1; /* &memout if backquote, otherwise &output */
+extern struct output *out2; /* &memout if backquote with 2>&1, otherwise
+			       &errout */
 
 void out1str(const char *);
 void out1qstr(const char *);

Modified: user/luigi/ipfw3-head/bin/sh/parser.c
==============================================================================
--- user/luigi/ipfw3-head/bin/sh/parser.c	Mon Jan  4 11:11:37 2010	(r201491)
+++ user/luigi/ipfw3-head/bin/sh/parser.c	Mon Jan  4 11:29:55 2010	(r201492)
@@ -1311,11 +1311,16 @@ parsebackq: {
 	int savelen;
 	int saveprompt;
 	const int bq_startlinno = plinno;
+	char *volatile ostr = NULL;
+	struct parsefile *const savetopfile = getcurrentfile();
 
 	str = NULL;
 	if (setjmp(jmploc.loc)) {
+		popfilesupto(savetopfile);
 		if (str)
 			ckfree(str);
+		if (ostr)
+			ckfree(ostr);
 		handler = savehandler;
 		if (exception == EXERROR) {
 			startlinno = bq_startlinno;
@@ -1335,13 +1340,12 @@ parsebackq: {
                 /* We must read until the closing backquote, giving special
                    treatment to some slashes, and then push the string and
                    reread it as input, interpreting it normally.  */
-                char *out;
+                char *oout;
                 int c;
-                int savelen;
-                char *str;
+                int olen;
 
 
-                STARTSTACKSTR(out);
+                STARTSTACKSTR(oout);
 		for (;;) {
 			if (needprompt) {
 				setprompt(2);
@@ -1368,7 +1372,7 @@ parsebackq: {
 				}
                                 if (c != '\\' && c != '`' && c != '$'
                                     && (!dblquote || c != '"'))
-                                        STPUTC('\\', out);
+                                        STPUTC('\\', oout);
 				break;
 
 			case '\n':
@@ -1384,16 +1388,16 @@ parsebackq: {
 			default:
 				break;
 			}
-			STPUTC(c, out);
+			STPUTC(c, oout);
                 }
 done:
-                STPUTC('\0', out);
-                savelen = out - stackblock();
-                if (savelen > 0) {
-                        str = ckmalloc(savelen);
-                        memcpy(str, stackblock(), savelen);
-			setinputstring(str, 1);
-                }
+                STPUTC('\0', oout);
+                olen = oout - stackblock();
+		INTOFF;
+		ostr = ckmalloc(olen);
+		memcpy(ostr, stackblock(), olen);
+		setinputstring(ostr, 1);
+		INTON;
         }
 	nlpp = &bqlist;
 	while (*nlpp)
@@ -1435,6 +1439,12 @@ done:
 		str = NULL;
 		INTON;
 	}
+	if (ostr) {
+		INTOFF;
+		ckfree(ostr);
+		ostr = NULL;
+		INTON;
+	}
 	handler = savehandler;
 	if (arinest || dblquote)
 		USTPUTC(CTLBACKQ | CTLQUOTE, out);
@@ -1550,8 +1560,8 @@ STATIC void
 synerror(const char *msg)
 {
 	if (commandname)
-		outfmt(&errout, "%s: %d: ", commandname, startlinno);
-	outfmt(&errout, "Syntax error: %s\n", msg);
+		outfmt(out2, "%s: %d: ", commandname, startlinno);
+	outfmt(out2, "Syntax error: %s\n", msg);
 	error((char *)NULL);
 }
 

Modified: user/luigi/ipfw3-head/bin/sh/sh.1
==============================================================================
--- user/luigi/ipfw3-head/bin/sh/sh.1	Mon Jan  4 11:11:37 2010	(r201491)
+++ user/luigi/ipfw3-head/bin/sh/sh.1	Mon Jan  4 11:29:55 2010	(r201492)
@@ -32,7 +32,7 @@
 .\"	from: @(#)sh.1	8.6 (Berkeley) 5/4/95
 .\" $FreeBSD$
 .\"
-.Dd October 24, 2009
+.Dd December 31, 2009
 .Dt SH 1
 .Os
 .Sh NAME
@@ -865,7 +865,7 @@ command is:
 If
 .Ic in
 and the following words are omitted,
-.Ic in Li $@
+.Ic in Li \&"$@\&"
 is used instead.
 The words are expanded, and then the list is executed
 repeatedly with the variable set to each word in turn.
@@ -1080,7 +1080,7 @@ and
 is
 .Dq Li "def ghi" ,
 then
-.Dq Li $@
+.Li \&"$@\&"
 expands to
 the two arguments:
 .Bd -literal -offset indent
@@ -2137,7 +2137,7 @@ and not found.
 For aliases the alias expansion is printed;
 for commands and tracked aliases
 the complete pathname of the command is printed.
-.It Ic ulimit Oo Fl HSabcdflmnpstuv Oc Op Ar limit
+.It Ic ulimit Oo Fl HSabcdflmnpstuvw Oc Op Ar limit
 Set or display resource limits (see
 .Xr getrlimit 2 ) .
 If
@@ -2201,6 +2201,9 @@ The maximal amount of CPU time to be use
 The maximal number of simultaneous processes for this user ID.
 .It Fl v Ar virtualmem
 The maximal virtual size of a process, in kilobytes.
+.It Fl w Ar swapuse
+The maximum amount of swap space reserved or used for this user ID,
+in kilobytes.
 .El
 .It Ic umask Oo Fl S Oc Op Ar mask
 Set the file creation mask (see

Modified: user/luigi/ipfw3-head/crypto/heimdal/kcm/connect.c
==============================================================================
--- user/luigi/ipfw3-head/crypto/heimdal/kcm/connect.c	Mon Jan  4 11:11:37 2010	(r201491)
+++ user/luigi/ipfw3-head/crypto/heimdal/kcm/connect.c	Mon Jan  4 11:29:55 2010	(r201492)
@@ -149,7 +149,7 @@ update_client_creds(int s, kcm_client *p
 	struct sockcred *sc;
 	
 	memset(&msg, 0, sizeof(msg));
-	crmsgsize = CMSG_SPACE(SOCKCREDSIZE(NGROUPS));
+	crmsgsize = CMSG_SPACE(SOCKCREDSIZE(CMGROUP_MAX));
 	if (crmsgsize == 0)
 	    return 1 ;
 

Modified: user/luigi/ipfw3-head/etc/defaults/rc.conf
==============================================================================
--- user/luigi/ipfw3-head/etc/defaults/rc.conf	Mon Jan  4 11:11:37 2010	(r201491)
+++ user/luigi/ipfw3-head/etc/defaults/rc.conf	Mon Jan  4 11:29:55 2010	(r201492)
@@ -213,6 +213,8 @@ ifconfig_lo0="inet 127.0.0.1"	# default 
 #ifconfig_ed0_ipv6="inet6 2001:db8:1::1 prefixlen 64" # Sample IPv6 addr entry
 #ifconfig_ed0_alias0="inet6 2001:db8:2::1 prefixlen 64" # Sample IPv6 alias
 #ifconfig_fxp0_name="net0"	# Change interface name from fxp0 to net0.
+#vlans_fxp0="101 vlan0"		# vlan(4) interfaces for fxp0 device
+#create_arg_vlan0="vlan 102"	# vlan tag for vlan0 device
 #wlans_ath0="wlan0"		# wlan(4) interfaces for ath0 device
 #wlandebug_wlan0="scan+auth+assoc"	# Set debug flags with wlanddebug(8)
 #ipv4_addrs_fxp0="192.168.0.1/24 192.168.1.1-5/28" # example IPv4 address entry.
@@ -265,7 +267,7 @@ inetd_flags="-wW -C 60"		# Optional flag
 named_enable="NO"		# Run named, the DNS server (or NO).
 named_program="/usr/sbin/named" # Path to named, if you want a different one.
 named_conf="/etc/namedb/named.conf" 	# Path to the configuration file
-#named_flags="-c /etc/namedb/named.conf" # Uncomment for named not in /usr/sbin
+#named_flags=""			# Use this for flags OTHER than -u and -c
 named_pidfile="/var/run/named/pid" # Must set this in named.conf as well
 named_uid="bind" 		# User to run named as
 named_chrootdir="/var/named"	# Chroot directory (or "" not to auto-chroot it)

Modified: user/luigi/ipfw3-head/etc/mtree/BSD.usr.dist
==============================================================================
--- user/luigi/ipfw3-head/etc/mtree/BSD.usr.dist	Mon Jan  4 11:11:37 2010	(r201491)
+++ user/luigi/ipfw3-head/etc/mtree/BSD.usr.dist	Mon Jan  4 11:29:55 2010	(r201492)
@@ -265,8 +265,6 @@
             ..
             ppp
             ..
-            pppd
-            ..
             printing
             ..
             scsi_target
@@ -283,16 +281,10 @@
                 srcs
                 ..
             ..
-            slattach
-            ..
-            sliplogin
-            ..
             smbfs
                 print
                 ..
             ..
-            startslip
-            ..
             sunrpc
                 dir
                 ..

Modified: user/luigi/ipfw3-head/etc/network.subr
==============================================================================
--- user/luigi/ipfw3-head/etc/network.subr	Mon Jan  4 11:11:37 2010	(r201491)
+++ user/luigi/ipfw3-head/etc/network.subr	Mon Jan  4 11:29:55 2010	(r201492)
@@ -971,7 +971,7 @@ clone_down()
 #
 childif_create()
 {
-	local cfg child child_wlans create_args debug_flags ifn i
+	local cfg child child_vlans child_wlans create_args debug_flags ifn i
 	cfg=1
 	ifn=$1
 
@@ -999,6 +999,32 @@ childif_create()
 		fi
 	done
 
+	# Create vlan interfaces
+	child_vlans=`get_if_var $ifn vlans_IF`
+
+	if [ -n "${child_vlans}" ]; then
+		load_kld if_vlan
+	fi
+
+	for child in ${child_vlans}; do
+		if expr $child : '[1-9][0-9]*$' >/dev/null 2>&1; then
+			child="${ifn}.${child}"
+			create_args=`get_if_var $child create_args_IF`
+			ifconfig $child create ${create_args} && cfg=0
+		else
+			create_args="vlandev $ifn `get_if_var $child create_args_IF`"
+			if expr $child : 'vlan[0-9][0-9]*$' >/dev/null 2>&1; then
+				ifconfig $child create ${create_args} && cfg=0
+			else
+				i=`ifconfig vlan create ${create_args}`
+				ifconfig $i name $child && cfg=0
+			fi
+		fi
+		if autoif $child; then
+			ifn_start $child
+		fi
+	done
+
 	return ${cfg}
 }
 
@@ -1007,11 +1033,31 @@ childif_create()
 #
 childif_destroy()
 {
-	local cfg child child_wlans ifn
+	local cfg child child_vlans child_wlans ifn
 	cfg=1
 
-	child_wlans="`get_if_var $ifn wlans_IF` `get_if_var $ifn vaps_IF`"
+	child_wlans=`get_if_var $ifn wlans_IF`
 	for child in ${child_wlans}; do
+		if ! ifexists $child; then
+			continue
+		fi
+		if autoif $child; then
+			ifn_stop $child
+		fi
+		ifconfig $child destroy && cfg=0
+	done
+
+	child_vlans=`get_if_var $ifn vlans_IF`
+	for child in ${child_vlans}; do
+		if expr $child : '[1-9][0-9]*$' >/dev/null 2>&1; then
+			child="${ifn}.${child}"
+		fi
+		if ! ifexists $child; then
+			continue
+		fi
+		if autoif $child; then
+			ifn_stop $child
+		fi
 		ifconfig $child destroy && cfg=0
 	done
 

Modified: user/luigi/ipfw3-head/etc/rc.d/named
==============================================================================
--- user/luigi/ipfw3-head/etc/rc.d/named	Mon Jan  4 11:11:37 2010	(r201491)
+++ user/luigi/ipfw3-head/etc/rc.d/named	Mon Jan  4 11:29:55 2010	(r201492)
@@ -43,19 +43,19 @@ chroot_autoupdate()
 		warn "chroot directory structure not updated"
 	fi
 
-	# Create /etc/namedb symlink
+	# Create (or update) the configuration directory symlink
 	#
-	if [ ! -L /etc/namedb ]; then
-		if [ -d /etc/namedb ]; then
-			warn "named chroot: /etc/namedb is a directory!"
-		elif [ -e /etc/namedb ]; then
-			warn "named chroot: /etc/namedb exists!"
+	if [ ! -L "${named_conf%/*}" ]; then
+		if [ -d "${named_conf%/*}" ]; then
+			warn "named chroot: ${named_conf%/*} is a directory!"
+		elif [ -e "${named_conf%/*}" ]; then
+			warn "named chroot: ${named_conf%/*} exists!"
 		else
-			ln -s ${named_chrootdir}/etc/namedb /etc/namedb
+			ln -s ${named_confdir} ${named_conf%/*}
 		fi
 	else
 		# Make sure it points to the right place.
-		ln -shf ${named_chrootdir}/etc/namedb /etc/namedb
+		ln -shf ${named_confdir} ${named_conf%/*}
 	fi
 
 	# Mount a devfs in the chroot directory if needed
@@ -179,12 +179,12 @@ named_prestart()
 	# Create an rndc.key file for the user if none exists
 	#
 	confgen_command="${command%/named}/rndc-confgen -a -b256 -u $named_uid \
-	    -c ${named_chrootdir}/etc/namedb/rndc.key"
-	if [ -s "${named_chrootdir}/etc/namedb/rndc.conf" ]; then
+	    -c ${named_confdir}/rndc.key"
+	if [ -s "${named_confdir}/rndc.conf" ]; then
 		unset confgen_command
 	fi
-	if [ -s "${named_chrootdir}/etc/namedb/rndc.key" ]; then
-		case `stat -f%Su ${named_chrootdir}/etc/namedb/rndc.key` in
+	if [ -s "${named_confdir}/rndc.key" ]; then
+		case `stat -f%Su ${named_confdir}/rndc.key` in
 		root|$named_uid) ;;
 		*) $confgen_command ;;
 		esac
@@ -198,8 +198,8 @@ named_prestart()
 			warn "named_auto_forward enabled, but no /etc/resolv.conf"
 
 			# Empty the file in case it is included in named.conf
-			[ -s "${named_chrootdir}/etc/namedb/auto_forward.conf" ] &&
-			    create_file ${named_chrootdir}/etc/namedb/auto_forward.conf
+			[ -s "${named_confdir}/auto_forward.conf" ] &&
+			    create_file ${named_confdir}/auto_forward.conf
 
 			${command%/named}/named-checkconf $named_conf ||
 			    err 3 'named-checkconf for $named_conf failed'
@@ -248,19 +248,19 @@ named_prestart()
 			mv /var/run/naf-resolv.conf /etc/resolv.conf
 		fi
 
-		if cmp -s ${named_chrootdir}/etc/namedb/auto_forward.conf \
+		if cmp -s ${named_confdir}/auto_forward.conf \
 		    /var/run/auto_forward.conf; then
 			unlink /var/run/auto_forward.conf
 		else
-			[ -e "${named_chrootdir}/etc/namedb/auto_forward.conf" ] &&
-			    unlink ${named_chrootdir}/etc/namedb/auto_forward.conf
+			[ -e "${named_confdir}/auto_forward.conf" ] &&
+			    unlink ${named_confdir}/auto_forward.conf
 			mv /var/run/auto_forward.conf \
-			    ${named_chrootdir}/etc/namedb/auto_forward.conf
+			    ${named_confdir}/auto_forward.conf
 		fi
 	else
 		# Empty the file in case it is included in named.conf
-		[ -s "${named_chrootdir}/etc/namedb/auto_forward.conf" ] &&
-		    create_file ${named_chrootdir}/etc/namedb/auto_forward.conf
+		[ -s "${named_confdir}/auto_forward.conf" ] &&
+		    create_file ${named_confdir}/auto_forward.conf
 	fi
 
 	${command%/named}/named-checkconf $named_conf ||
@@ -274,5 +274,6 @@ load_rc_config $name
 required_dirs="$named_chrootdir"	# if it is set, it must exist
 required_files="${named_conf:=/etc/namedb/named.conf}"
 pidfile="${named_pidfile:-/var/run/named/pid}"
+named_confdir="${named_chrootdir}${named_conf%/*}"
 
 run_rc_command "$1"

Modified: user/luigi/ipfw3-head/etc/rc.d/nsswitch
==============================================================================
--- user/luigi/ipfw3-head/etc/rc.d/nsswitch	Mon Jan  4 11:11:37 2010	(r201491)
+++ user/luigi/ipfw3-head/etc/rc.d/nsswitch	Mon Jan  4 11:29:55 2010	(r201492)
@@ -77,10 +77,10 @@ generate_host_conf()
 	nis)
 		echo "nis" >> $host_conf
 		;;
-	*=*)
+	cache | *=*)
 		;;
 	*)
-		printf "Warning: unrecognized source [%s]", $_s > "/dev/stderr"
+		printf "Warning: unrecognized source [%s]\n" $_s >&2
 		;;
 	esac
     done

Modified: user/luigi/ipfw3-head/etc/rc.firewall
==============================================================================
--- user/luigi/ipfw3-head/etc/rc.firewall	Mon Jan  4 11:11:37 2010	(r201491)
+++ user/luigi/ipfw3-head/etc/rc.firewall	Mon Jan  4 11:29:55 2010	(r201492)
@@ -230,18 +230,30 @@ case ${firewall_type} in
 
 	# Allow setup of incoming email
 	${fwcmd} add pass tcp from any to me 25 setup
+	if [ -n "$net6" ]; then
+		${fwcmd} add pass tcp from any to me6 25 setup
+	fi
 
 	# Allow setup of outgoing TCP connections only
 	${fwcmd} add pass tcp from me to any setup
+	if [ -n "$net6" ]; then
+		${fwcmd} add pass tcp from me6 to any setup
+	fi
 
 	# Disallow setup of all other TCP connections
 	${fwcmd} add deny tcp from any to any setup
 
 	# Allow DNS queries out in the world
 	${fwcmd} add pass udp from me to any 53 keep-state
+	if [ -n "$net6" ]; then
+		${fwcmd} add pass udp from me6 to any 53 keep-state
+	fi
 
 	# Allow NTP queries out in the world
 	${fwcmd} add pass udp from me to any 123 keep-state
+	if [ -n "$net6" ]; then
+		${fwcmd} add pass udp from me6 to any 123 keep-state
+	fi
 
 	# Everything else is denied by default, unless the
 	# IPFIREWALL_DEFAULT_TO_ACCEPT option is set in your kernel
@@ -388,14 +400,25 @@ case ${firewall_type} in
 
 	# Allow setup of incoming email
 	${fwcmd} add pass tcp from any to me 25 setup
+	if [ -n "$inet6" ]; then
+		${fwcmd} add pass tcp from any to me6 25 setup
+	fi
 
 	# Allow access to our DNS
 	${fwcmd} add pass tcp from any to me 53 setup
 	${fwcmd} add pass udp from any to me 53
 	${fwcmd} add pass udp from me 53 to any
+	if [ -n "$inet6" ]; then
+		${fwcmd} add pass tcp from any to me6 53 setup
+		${fwcmd} add pass udp from any to me6 53
+		${fwcmd} add pass udp from me6 53 to any
+	fi
 
 	# Allow access to our WWW
 	${fwcmd} add pass tcp from any to me 80 setup
+	if [ -n "$inet6" ]; then
+		${fwcmd} add pass tcp from any to me6 80 setup
+	fi
 
 	# Reject&Log all setup of incoming connections from the outside
 	${fwcmd} add deny log ip4 from any to any in via ${oif} setup proto tcp
@@ -409,9 +432,15 @@ case ${firewall_type} in
 
 	# Allow DNS queries out in the world
 	${fwcmd} add pass udp from me to any 53 keep-state
+	if [ -n "$inet6" ]; then
+		${fwcmd} add pass udp from me6 to any 53 keep-state
+	fi
 
 	# Allow NTP queries out in the world
 	${fwcmd} add pass udp from me to any 123 keep-state
+	if [ -n "$inet6" ]; then
+		${fwcmd} add pass udp from me6 to any 123 keep-state
+	fi
 
 	# Everything else is denied by default, unless the
 	# IPFIREWALL_DEFAULT_TO_ACCEPT option is set in your kernel

Modified: user/luigi/ipfw3-head/games/fortune/datfiles/fortunes
==============================================================================
--- user/luigi/ipfw3-head/games/fortune/datfiles/fortunes	Mon Jan  4 11:11:37 2010	(r201491)
+++ user/luigi/ipfw3-head/games/fortune/datfiles/fortunes	Mon Jan  4 11:29:55 2010	(r201492)
@@ -1604,6 +1604,13 @@ friends and family, and then justify thi
 for doing it."
 		-- Bruce Feirstein, "Nice Guys Sleep Alone"
 %
+	As we know, there are known knowns.  There are things we know we
+know.  We also know there are known unknowns.  That is to say, we know
+there're some things we do not know.  But there're also unknown unknowns;
+the ones we don't know we don't know."
+		-- Defense Secretary Donald Rumsfeld,
+		   about the invasion to Iraq.
+%
 	At a recent meeting in Snowmass, Colorado, a participant from
 Los Angeles fainted from hyperoxygenation, and we had to hold his head
 under the exhaust of a bus until he revived.
@@ -46372,6 +46379,13 @@ constitutions, displaying the utmost imp
 overturning everything.
 		-- Plato, "Republic", 370 B.C.
 %
+The investment community feels very putupon.  They feel there is no
+reason why they shouldn't earn $1 million to $200 million a year,
+and they don't want to be held responsible for the global financial
+meltdown.
+		-- Daniel Fass, chairman of Obama's
+		financial-industry fundraising party
+%
 The IQ of the group is the lowest IQ of a member of
 the group divided by the number of people in the group.
 %

Modified: user/luigi/ipfw3-head/games/fortune/strfile/strfile.c
==============================================================================
--- user/luigi/ipfw3-head/games/fortune/strfile/strfile.c	Mon Jan  4 11:11:37 2010	(r201491)
+++ user/luigi/ipfw3-head/games/fortune/strfile/strfile.c	Mon Jan  4 11:29:55 2010	(r201492)
@@ -146,7 +146,8 @@ static void	usage(void);
  *	CHUNKSIZE blocks; if the latter, we just write each pointer,
  *	and then seek back to the beginning to write in the table.
  */
-int main(int ac, char *av[])
+int
+main(int ac, char *av[])
 {
 	char		*sp, dc;
 	FILE		*inf, *outf;
@@ -264,9 +265,8 @@ int main(int ac, char *av[])
 /*
  *	This routine evaluates arguments from the command line
  */
-void getargs(argc, argv)
-int	argc;
-char	**argv;
+void
+getargs(int argc, char **argv)
 {
 	int	ch;
 
@@ -318,7 +318,8 @@ char	**argv;
 	}
 }
 
-void usage()
+void
+usage(void)
 {
 	(void) fprintf(stderr,
 	    "strfile [-Ciorsx] [-c char] source_file [output_file]\n");
@@ -329,9 +330,8 @@ void usage()
  * add_offset:
  *	Add an offset to the list, or write it out, as appropriate.
  */
-void add_offset(fp, off)
-FILE	*fp;
-off_t	off;
+void
+add_offset(FILE *fp, off_t off)
 {
 	off_t beoff;
 
@@ -349,7 +349,8 @@ off_t	off;
  * do_order:
  *	Order the strings alphabetically (possibly ignoring case).
  */
-void do_order()
+void
+do_order(void)
 {
 	uint32_t i;
 	off_t	*lp;
@@ -368,8 +369,8 @@ void do_order()
 	Tbl.str_flags |= STR_ORDERED;
 }
 
-static int stable_collate_range_cmp(c1, c2)
-	int c1, c2;
+static int
+stable_collate_range_cmp(int c1, int c2)
 {
 	static char s1[2], s2[2];
 	int ret;
@@ -385,8 +386,8 @@ static int stable_collate_range_cmp(c1, 
  * cmp_str:
  *	Compare two strings in the file
  */
-int cmp_str(s1, s2)
-const void	*s1, *s2;
+int
+cmp_str(const void *s1, const void *s2)
 {
 	const STR	*p1, *p2;
 	int	c1, c2;
@@ -441,7 +442,8 @@ const void	*s1, *s2;
  *	not to randomize across delimiter boundaries.  All
  *	randomization is done within each block.
  */
-void randomize()
+void
+randomize(void)
 {
 	uint32_t cnt, i;
 	off_t	tmp;

Modified: user/luigi/ipfw3-head/games/fortune/unstr/unstr.c
==============================================================================
--- user/luigi/ipfw3-head/games/fortune/unstr/unstr.c	Mon Jan  4 11:11:37 2010	(r201491)
+++ user/luigi/ipfw3-head/games/fortune/unstr/unstr.c	Mon Jan  4 11:29:55 2010	(r201492)
@@ -79,7 +79,8 @@ FILE	*Inf, *Dataf;
 void order_unstr(STRFILE *);
 
 /* ARGSUSED */
-int main(int ac, char **av)
+int
+main(int ac, char **av)
 {
 	static STRFILE	tbl;		/* description table */
 
@@ -109,8 +110,8 @@ int main(int ac, char **av)
 	exit(0);
 }
 
-void order_unstr(tbl)
-STRFILE	*tbl;
+void
+order_unstr(STRFILE *tbl)
 {
 	uint32_t i;

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***

From owner-svn-src-user@FreeBSD.ORG  Mon Jan  4 11:32:37 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 67888106566C;
	Mon,  4 Jan 2010 11:32:37 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 582288FC1E;
	Mon,  4 Jan 2010 11:32:37 +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 o04BWb7n045716;
	Mon, 4 Jan 2010 11:32:37 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o04BWbXx045714;
	Mon, 4 Jan 2010 11:32:37 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001041132.o04BWbXx045714@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Mon, 4 Jan 2010 11:32:37 +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: r201493 - user/luigi/ipfw3-head/sys/netinet/ipfw
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 11:32:37 -0000

Author: luigi
Date: Mon Jan  4 11:32:37 2010
New Revision: 201493
URL: http://svn.freebsd.org/changeset/base/201493

Log:
  whitespace fix

Modified:
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c	Mon Jan  4 11:29:55 2010	(r201492)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c	Mon Jan  4 11:32:37 2010	(r201493)
@@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$");
 #include <netinet/ip_divert.h>
 #include <netinet/ip_dummynet.h>
 #include <netgraph/ng_ipfw.h>
+
 #include <machine/in_cksum.h>
 
 static VNET_DEFINE(int, fw_enable) = 1;

From owner-svn-src-user@FreeBSD.ORG  Mon Jan  4 16:03:26 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 C40D310656A9;
	Mon,  4 Jan 2010 16:03:26 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id B0DB88FC22;
	Mon,  4 Jan 2010 16:03:26 +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 o04G3QtP011502;
	Mon, 4 Jan 2010 16:03:26 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o04G3QFE011495;
	Mon, 4 Jan 2010 16:03:26 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001041603.o04G3QFE011495@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Mon, 4 Jan 2010 16:03:26 +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: r201516 - in user/luigi/ipfw3-head/sys/netinet: . ipfw
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 16:03:26 -0000

Author: luigi
Date: Mon Jan  4 16:03:26 2010
New Revision: 201516
URL: http://svn.freebsd.org/changeset/base/201516

Log:
  The main purpose of this commit is to fix 'divert', 'diverted' and
  operation with one_pass=0 which was not completed in the previous
  commits (in this branch).
  
  In detail:
  
  === ip_fw_private.h ===
  + introduce enum constants to define the input and output info in
    struct ipfw_rule_ref, so the same format can be used by different
    clients.
  + remember to rename the file, as it exports kernel APIs,
    not private stuff;
  
  === ip_fw_pfil.c ===
  + put the conversion of ip+len and ip_off in the right place
    (was not correct for reinjected packets);
  + optimize the path for net.inet.ip.fw.onepass=1
  
  === ip_fw2.c ===
  + complete the implementation of 'diverted'
  + localize a variable;
  
  === ip_divert.c ===
  + use MTAG_IPFW_RULE tags for divert;
  + extract the rule and divert port directly from the tag;
  + store the return info in the 'info' field;

Modified:
  user/luigi/ipfw3-head/sys/netinet/ip_divert.c
  user/luigi/ipfw3-head/sys/netinet/ip_divert.h
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw2.c
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_private.h

Modified: user/luigi/ipfw3-head/sys/netinet/ip_divert.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ip_divert.c	Mon Jan  4 15:58:36 2010	(r201515)
+++ user/luigi/ipfw3-head/sys/netinet/ip_divert.c	Mon Jan  4 16:03:26 2010	(r201516)
@@ -218,7 +218,7 @@ divert_packet(struct mbuf *m, int incomi
 	struct sockaddr_in divsrc;
 	struct m_tag *mtag;
 
-	mtag = m_tag_find(m, PACKET_TAG_DIVERT, NULL);
+	mtag = m_tag_locate(m, MTAG_IPFW_RULE, 0, NULL);
 	if (mtag == NULL) {
 		m_freem(m);
 		return;
@@ -244,14 +244,15 @@ divert_packet(struct mbuf *m, int incomi
 		ip->ip_len = htons(ip->ip_len);
 	}
 #endif
+	bzero(&divsrc, sizeof(divsrc));
+	divsrc.sin_len = sizeof(divsrc);
+	divsrc.sin_family = AF_INET;
+	/* record matching rule, in host format */
+	divsrc.sin_port = ((struct ipfw_rule_ref *)(mtag+1))->rulenum;
 	/*
 	 * Record receive interface address, if any.
 	 * But only for incoming packets.
 	 */
-	bzero(&divsrc, sizeof(divsrc));
-	divsrc.sin_len = sizeof(divsrc);
-	divsrc.sin_family = AF_INET;
-	divsrc.sin_port = divert_cookie(mtag);	/* record matching rule */
 	if (incoming) {
 		struct ifaddr *ifa;
 		struct ifnet *ifp;
@@ -299,7 +300,7 @@ divert_packet(struct mbuf *m, int incomi
 
 	/* Put packet on socket queue, if any */
 	sa = NULL;
-	nport = htons((u_int16_t)divert_info(mtag));
+	nport = htons((u_int16_t)(((struct ipfw_rule_ref *)(mtag+1))->info));
 	INP_INFO_RLOCK(&V_divcbinfo);
 	LIST_FOREACH(inp, &V_divcb, inp_list) {
 		/* XXX why does only one socket match? */
@@ -395,7 +396,7 @@ div_output(struct socket *so, struct mbu
 		struct ip *const ip = mtod(m, struct ip *);
 		struct inpcb *inp;
 
-		dt->info |= IP_FW_DIVERT_OUTPUT_FLAG;
+		dt->info |= IPFW_IS_DIVERT | IPFW_INFO_OUT;
 		INP_INFO_WLOCK(&V_divcbinfo);
 		inp = sotoinpcb(so);
 		INP_RLOCK(inp);
@@ -461,7 +462,7 @@ div_output(struct socket *so, struct mbu
 				m_freem(options);
 		}
 	} else {
-		dt->info |= IP_FW_DIVERT_LOOPBACK_FLAG;
+		dt->info |= IPFW_IS_DIVERT | IPFW_INFO_IN;
 		if (m->m_pkthdr.rcvif == NULL) {
 			/*
 			 * No luck with the name, check by IP address.

Modified: user/luigi/ipfw3-head/sys/netinet/ip_divert.h
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ip_divert.h	Mon Jan  4 15:58:36 2010	(r201515)
+++ user/luigi/ipfw3-head/sys/netinet/ip_divert.h	Mon Jan  4 16:03:26 2010	(r201516)
@@ -55,15 +55,6 @@ divert_cookie(struct m_tag *mtag)
 	return ((struct ipfw_rule_ref *)(mtag+1))->rulenum;
 }
 
-/*
- * Return the divert info associated with the mbuf; if any.
- */
-static __inline u_int32_t
-divert_info(struct m_tag *mtag)
-{
-	return ((struct ipfw_rule_ref *)(mtag+1))->info;
-}
-
 typedef	void ip_divert_packet_t(struct mbuf *m, int incoming);
 extern	ip_divert_packet_t *ip_divert_ptr;
 

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Mon Jan  4 15:58:36 2010	(r201515)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Mon Jan  4 16:03:26 2010	(r201516)
@@ -1370,7 +1370,7 @@ dummynet_io(struct mbuf **m0, int dir, s
 	struct dn_pipe *pipe;
 	uint64_t len = m->m_pkthdr.len;
 	struct dn_flow_queue *q = NULL;
-	int is_pipe = fwa->rule.info & 0x8000000 ? 0 : 1;
+	int is_pipe = fwa->rule.info & IPFW_IS_PIPE;
 
 	KASSERT(m->m_nextpkt == NULL,
 	    ("dummynet_io: mbuf queue passed to dummynet"));
@@ -1379,16 +1379,13 @@ dummynet_io(struct mbuf **m0, int dir, s
 	io_pkt++;
 	/*
 	 * This is a dummynet rule, so we expect an O_PIPE or O_QUEUE rule.
-	 *
-	 * XXXGL: probably the pipe->fs and fs->pipe logic here
-	 * below can be simplified.
 	 */
 	if (is_pipe) {
-		pipe = locate_pipe(fwa->rule.info & 0xffff);
+		pipe = locate_pipe(fwa->rule.info & IPFW_INFO_MASK);
 		if (pipe != NULL)
 			fs = &(pipe->fs);
 	} else
-		fs = locate_flowset(fwa->rule.info & 0xffff);
+		fs = locate_flowset(fwa->rule.info & IPFW_INFO_MASK);
 
 	if (fs == NULL)
 		goto dropit;	/* This queue/pipe does not exist! */
@@ -1435,6 +1432,7 @@ dummynet_io(struct mbuf **m0, int dir, s
 	 * Build and enqueue packet + parameters.
 	 */
 	pkt->rule = fwa->rule;
+	pkt->rule.info &= IPFW_ONEPASS;	/* only keep this info */
 	pkt->dn_dir = dir;
 	pkt->ifp = fwa->oif;
 

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw2.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw2.c	Mon Jan  4 15:58:36 2010	(r201515)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw2.c	Mon Jan  4 16:03:26 2010	(r201516)
@@ -799,14 +799,6 @@ ipfw_chk(struct ip_fw_args *args)
 	int ucred_lookup = 0;
 
 	/*
-	 * divinput_flags	If non-zero, set to the IP_FW_DIVERT_*_FLAG
-	 *	associated with a packet input on a divert socket.  This
-	 *	will allow to distinguish traffic and its direction when
-	 *	it originates from a divert socket.
-	 */
-	u_int divinput_flags = 0;
-
-	/*
 	 * oif | args->oif	If NULL, ipfw_chk has been called on the
 	 *	inbound path (ether_input, ip_input).
 	 *	If non-NULL, ipfw_chk has been called on the outbound path
@@ -864,7 +856,6 @@ ipfw_chk(struct ip_fw_args *args)
 	int dyn_dir = MATCH_UNKNOWN;
 	ipfw_dyn_rule *q = NULL;
 	struct ip_fw_chain *chain = &V_layer3_chain;
-	struct m_tag *mtag;
 
 	/*
 	 * We store in ulp a pointer to the upper layer protocol header.
@@ -1152,10 +1143,6 @@ do {								\
 	} else {
 		f_pos = 0;
 	}
-#if 0 // XXX to be fixed
-		divinput_flags = divert_info(mtag) &
-		    (IP_FW_DIVERT_OUTPUT_FLAG | IP_FW_DIVERT_LOOPBACK_FLAG);
-#endif
 
 	/*
 	 * Now scan the rules, and parse microinstructions for each rule.
@@ -1306,10 +1293,15 @@ do {								\
 				break;
 
 			case O_DIVERTED:
-				match = (cmd->arg1 & 1 && divinput_flags &
-				    IP_FW_DIVERT_LOOPBACK_FLAG) ||
-					(cmd->arg1 & 2 && divinput_flags &
-				    IP_FW_DIVERT_OUTPUT_FLAG);
+			    {
+				/* For diverted packets, args->rule.info
+				 * contains the divert port (in host format)
+				 * reason and direction.
+	 			 */
+				uint32_t i = args->rule.info;
+				match = (i&IPFW_IS_MASK) == IPFW_IS_DIVERT &&
+				    cmd->arg1 & ((i & IPFW_INFO_IN) ? 1 : 2);
+			    }
 				break;
 
 			case O_PROTO:
@@ -1729,6 +1721,7 @@ do {								\
 				break;
 
 			case O_TAG: {
+				struct m_tag *mtag;
 				uint32_t tag = (cmd->arg1 == IP_FW_TABLEARG) ?
 				    tablearg : cmd->arg1;
 
@@ -1761,6 +1754,7 @@ do {								\
 				break;
 
 			case O_TAGGED: {
+				struct m_tag *mtag;
 				uint32_t tag = (cmd->arg1 == IP_FW_TABLEARG) ?
 				    tablearg : cmd->arg1;
 
@@ -1903,8 +1897,10 @@ do {								\
 				set_match(args, f_pos, chain);
 				args->rule.info = (cmd->arg1 == IP_FW_TABLEARG) ?
 					tablearg : cmd->arg1;
-				if (cmd->opcode == O_QUEUE)
-					args->rule.info |= 0x80000000;
+				if (cmd->opcode == O_PIPE)
+					args->rule.info |= IPFW_IS_PIPE;
+				if (V_fw_one_pass)
+					args->rule.info |= IPFW_ONEPASS;
 				retval = IP_FW_DUMMYNET;
 				l = 0;          /* exit inner loop */
 				done = 1;       /* exit outer loop */
@@ -1917,6 +1913,8 @@ do {								\
 				/* otherwise this is terminal */
 				l = 0;		/* exit inner loop */
 				done = 1;	/* exit outer loop */
+				retval = (cmd->opcode == O_DIVERT) ?
+					IP_FW_DIVERT : IP_FW_TEE;
 				set_match(args, f_pos, chain);
 				args->rule.info = (cmd->arg1 == IP_FW_TABLEARG) ?
 				    tablearg : cmd->arg1;

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c	Mon Jan  4 15:58:36 2010	(r201515)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c	Mon Jan  4 16:03:26 2010	(r201516)
@@ -110,33 +110,35 @@ ipfw_check_hook(void *arg, struct mbuf *
 	struct m_tag *tag;
 	int ipfw;
 	int ret;
-#ifdef IPFIREWALL_FORWARD
-	struct m_tag *fwd_tag;
-#endif
+
+	/* all the processing now uses ip_len in net format */
+	SET_NET_IPLEN(mtod(*m0, struct ip *));
 
 	/* convert dir to IPFW values */
 	dir = (dir == PFIL_IN) ? DIR_IN : DIR_OUT;
 	bzero(&args, sizeof(args));
 
 again:
+	/*
+	 * extract and remove the tag if present. If we are left
+	 * with onepass, optimize the outgoing path.
+	 */
 	tag = m_tag_locate(*m0, MTAG_IPFW_RULE, 0, NULL);
 	if (tag != NULL) {
 		args.rule = *((struct ipfw_rule_ref *)(tag+1));
 		m_tag_delete(*m0, tag);
+		if (args.rule.info & IPFW_ONEPASS) {
+			SET_HOST_IPLEN(mtod(*m0, struct ip *));
+			return 0;
+		}
 	}
 
 	args.m = *m0;
 	args.oif = dir == DIR_OUT ? ifp : NULL;
 	args.inp = inp;
 
-	/* all the processing now uses ip_len in net format */
-	SET_NET_IPLEN(mtod(*m0, struct ip *));
-
-	if (V_fw_one_pass == 0 || args.rule.slot == 0) {
-		ipfw = ipfw_chk(&args);
-		*m0 = args.m;
-	} else
-		ipfw = IP_FW_PASS;
+	ipfw = ipfw_chk(&args);
+	*m0 = args.m;
 
 	KASSERT(*m0 != NULL || ipfw == IP_FW_DENY, ("%s: m0 is NULL",
 	    __func__));
@@ -151,6 +153,9 @@ again:
 #ifndef IPFIREWALL_FORWARD
 		ret = EACCES;
 #else
+	    {
+		struct m_tag *fwd_tag;
+
 		/* Incoming packets should not be tagged so we do not
 		 * m_tag_find. Outgoing packets may be tagged, so we
 		 * reuse the tag if present.
@@ -172,6 +177,7 @@ again:
 
 		if (in_localip(args.next_hop->sin_addr))
 			(*m0)->m_flags |= M_FASTFWD_OURS;
+	    }
 #endif
 		break;
 

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_private.h
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_private.h	Mon Jan  4 15:58:36 2010	(r201515)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_private.h	Mon Jan  4 16:03:26 2010	(r201516)
@@ -51,10 +51,6 @@ enum {
 	IP_FW_REASS,
 };
 
-/* flags for divert mtag */
-#define	IP_FW_DIVERT_LOOPBACK_FLAG	0x00080000
-#define	IP_FW_DIVERT_OUTPUT_FLAG	0x00100000
-
 /*
  * Structure for collecting parameters to dummynet for ip6_output forwarding
  */
@@ -75,13 +71,32 @@ struct _ip6dn_args {
  * A rule is identified by rulenum:rule_id which is ordered.
  * In version chain_id the rule can be found in slot 'slot', so
  * we don't need a lookup if chain_id == chain->id.
+ *
+ * On exit from the firewall this structure refers to the rule after
+ * the matching one (slot points to the new rule; rulenum:rule_id-1
+ * is the matching rule), and additional info (e.g. info often contains
+ * the insn argument or tablearg in the low 16 bits, in host format).
+ * On entry, the structure is valid if slot>0, and refers to the starting
+ * rules. 'info' contains the reason for reinject, e.g. divert port,
+ * divert direction, and so on.
  */
 struct ipfw_rule_ref {
 	uint32_t	slot;		/* slot for matching rule	*/
 	uint32_t	rulenum;	/* matching rule number		*/
 	uint32_t	rule_id;	/* matching rule id		*/
 	uint32_t	chain_id;	/* ruleset id			*/
-	uint32_t	info;		/* reason for reinject		*/
+	uint32_t	info;		/* see below			*/
+};
+
+enum {
+	IPFW_INFO_MASK	= 0x0000ffff,
+	IPFW_INFO_OUT	= 0x00000000,	/* outgoing, just for convenience */
+	IPFW_INFO_IN	= 0x80000000,	/* incoming, overloads dir */
+	IPFW_ONEPASS	= 0x40000000,	/* One-pass, do not reinject */
+	IPFW_IS_MASK	= 0x30000000,	/* which source ? */
+	IPFW_IS_DIVERT	= 0x20000000,
+	IPFW_IS_DUMMYNET =0x10000000,
+	IPFW_IS_PIPE	= 0x08000000,	/* pip1=1, queue = 0 */
 };
 
 /*

From owner-svn-src-user@FreeBSD.ORG  Mon Jan  4 16:58:15 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 961D91065679;
	Mon,  4 Jan 2010 16:58:15 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 834948FC1C;
	Mon,  4 Jan 2010 16:58:15 +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 o04GwFHV023756;
	Mon, 4 Jan 2010 16:58:15 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o04GwFfG023749;
	Mon, 4 Jan 2010 16:58:15 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001041658.o04GwFfG023749@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Mon, 4 Jan 2010 16:58:15 +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: r201517 - in user/luigi/ipfw3-head/sys/netinet: . ipfw
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 16:58:15 -0000

Author: luigi
Date: Mon Jan  4 16:58:15 2010
New Revision: 201517
URL: http://svn.freebsd.org/changeset/base/201517

Log:
  divert has no specific API so we don't really need an ip_divert.h

Modified:
  user/luigi/ipfw3-head/sys/netinet/ip_divert.c
  user/luigi/ipfw3-head/sys/netinet/ip_divert.h
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw2.c
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_private.h
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_sockopt.c

Modified: user/luigi/ipfw3-head/sys/netinet/ip_divert.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ip_divert.c	Mon Jan  4 16:03:26 2010	(r201516)
+++ user/luigi/ipfw3-head/sys/netinet/ip_divert.c	Mon Jan  4 16:58:15 2010	(r201517)
@@ -75,7 +75,6 @@ __FBSDID("$FreeBSD$");
 #include <netinet/ip_var.h>
 #include <netinet/ip_fw.h>
 #include <netinet/ipfw/ip_fw_private.h>
-#include <netinet/ip_divert.h>
 #ifdef SCTP
 #include <netinet/sctp_crc32.h>
 #endif
@@ -194,7 +193,7 @@ div_destroy(void)
  * IPPROTO_DIVERT is not in the real IP protocol number space; this
  * function should never be called.  Just in case, drop any packets.
  */
-void
+static void
 div_input(struct mbuf *m, int off)
 {
 
@@ -596,7 +595,7 @@ div_send(struct socket *so, int flags, s
 	return div_output(so, m, (struct sockaddr_in *)nam, control);
 }
 
-void
+static void
 div_ctlinput(int cmd, struct sockaddr *sa, void *vip)
 {
         struct in_addr faddr;
@@ -809,5 +808,5 @@ static moduledata_t ipdivertmod = {
 };
 
 DECLARE_MODULE(ipdivert, ipdivertmod, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY);
-MODULE_DEPEND(dummynet, ipfw, 2, 2, 2);
+MODULE_DEPEND(ipdivert, ipfw, 2, 2, 2);
 MODULE_VERSION(ipdivert, 1);

Modified: user/luigi/ipfw3-head/sys/netinet/ip_divert.h
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ip_divert.h	Mon Jan  4 16:03:26 2010	(r201516)
+++ user/luigi/ipfw3-head/sys/netinet/ip_divert.h	Mon Jan  4 16:58:15 2010	(r201517)
@@ -36,28 +36,20 @@
 #define	_NETINET_IP_DIVERT_H_
 
 /*
- * Sysctl declaration.
+ * divert has no custom kernel-userland API.
+ *
+ * All communication occurs through a sockaddr_in socket where
+ *
+ * kernel-->userland
+ *	sin_port = matching rule, host format;
+ * 	sin_addr = IN: first address of the incoming interface;
+ *		   OUT: INADDR_ANY
+ *	sin_zero = if fits, the interface name (max 7 bytes + NUL)
+ *
+ * userland->kernel
+ *	sin_port = restart-rule - 1, host order
+ *		(we restart at sin_port + 1)
+ *	sin_addr = IN: address of the incoming interface;
+ *		   OUT: INADDR_ANY
  */
-#ifdef SYSCTL_DECL
-SYSCTL_DECL(_net_inet_divert);
-#endif
-
-/*
- * Divert socket definitions.
- */
-
-/*
- * Return the divert cookie associated with the mbuf; if any.
- */
-static __inline u_int16_t
-divert_cookie(struct m_tag *mtag)
-{
-	return ((struct ipfw_rule_ref *)(mtag+1))->rulenum;
-}
-
-typedef	void ip_divert_packet_t(struct mbuf *m, int incoming);
-extern	ip_divert_packet_t *ip_divert_ptr;
-
-extern	void div_input(struct mbuf *, int);
-extern	void div_ctlinput(int, struct sockaddr *, void *);
 #endif /* _NETINET_IP_DIVERT_H_ */

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw2.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw2.c	Mon Jan  4 16:03:26 2010	(r201516)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw2.c	Mon Jan  4 16:58:15 2010	(r201517)
@@ -74,7 +74,6 @@ __FBSDID("$FreeBSD$");
 #include <netinet/ip_icmp.h>
 #include <netinet/ip_fw.h>
 #include <netinet/ipfw/ip_fw_private.h>
-#include <netinet/ip_divert.h>
 #include <netinet/ip_carp.h>
 #include <netinet/pim.h>
 #include <netinet/tcp_var.h>

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c	Mon Jan  4 16:03:26 2010	(r201516)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c	Mon Jan  4 16:58:15 2010	(r201517)
@@ -59,7 +59,6 @@ __FBSDID("$FreeBSD$");
 #include <netinet/ip_var.h>
 #include <netinet/ip_fw.h>
 #include <netinet/ipfw/ip_fw_private.h>
-#include <netinet/ip_divert.h>
 #include <netinet/ip_dummynet.h>
 #include <netgraph/ng_ipfw.h>
 
@@ -76,7 +75,7 @@ static VNET_DEFINE(int, fw6_enable) = 1;
 int ipfw_chg_hook(SYSCTL_HANDLER_ARGS);
 
 /* Divert hooks. */
-ip_divert_packet_t *ip_divert_ptr = NULL;
+void (*ip_divert_ptr)(struct mbuf *m, int incoming);
 
 /* ng_ipfw hooks. */
 ng_ipfw_input_t *ng_ipfw_input_p = NULL;

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_private.h
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_private.h	Mon Jan  4 16:03:26 2010	(r201516)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_private.h	Mon Jan  4 16:58:15 2010	(r201517)
@@ -289,6 +289,9 @@ int ipfw_del_table_entry(struct ip_fw_ch
 int ipfw_count_table(struct ip_fw_chain *ch, uint32_t tbl, uint32_t *cnt);
 int ipfw_dump_table(struct ip_fw_chain *ch, ipfw_table *tbl);
 
+/* hooks for divert */
+extern void (*ip_divert_ptr)(struct mbuf *m, int incoming);
+
 /* In ip_fw_nat.c */
 
 extern struct cfg_nat *(*lookup_nat_ptr)(struct nat_list *, int);

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_sockopt.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_sockopt.c	Mon Jan  4 16:03:26 2010	(r201516)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_sockopt.c	Mon Jan  4 16:58:15 2010	(r201517)
@@ -65,7 +65,6 @@ __FBSDID("$FreeBSD$");
 #include <netinet/in.h>
 #include <netinet/ip_fw.h>
 #include <netinet/ipfw/ip_fw_private.h>
-#include <netinet/ip_divert.h>
 
 #ifdef MAC
 #include <security/mac/mac_framework.h>

From owner-svn-src-user@FreeBSD.ORG  Mon Jan  4 17:05:17 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 53B1D106568F;
	Mon,  4 Jan 2010 17:05:17 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 41DB38FC1A;
	Mon,  4 Jan 2010 17:05:17 +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 o04H5HgL025382;
	Mon, 4 Jan 2010 17:05:17 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o04H5HFb025380;
	Mon, 4 Jan 2010 17:05:17 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001041705.o04H5HFb025380@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Mon, 4 Jan 2010 17:05:17 +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: r201518 - user/luigi/ipfw3-head/sys/netinet
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 17:05:17 -0000

Author: luigi
Date: Mon Jan  4 17:05:16 2010
New Revision: 201518
URL: http://svn.freebsd.org/changeset/base/201518

Log:
  remove unnecessary headers

Modified:
  user/luigi/ipfw3-head/sys/netinet/ip_divert.c

Modified: user/luigi/ipfw3-head/sys/netinet/ip_divert.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ip_divert.c	Mon Jan  4 16:58:15 2010	(r201517)
+++ user/luigi/ipfw3-head/sys/netinet/ip_divert.c	Mon Jan  4 17:05:16 2010	(r201518)
@@ -52,19 +52,12 @@ __FBSDID("$FreeBSD$");
 #include <sys/priv.h>
 #include <sys/proc.h>
 #include <sys/protosw.h>
-#include <sys/rwlock.h>
-#include <sys/signalvar.h>
 #include <sys/socket.h>
 #include <sys/socketvar.h>
-#include <sys/sx.h>
 #include <sys/sysctl.h>
-#include <sys/systm.h>
-
-#include <vm/uma.h>
 
 #include <net/if.h>
 #include <net/netisr.h> 
-#include <net/route.h>
 #include <net/vnet.h>
 
 #include <netinet/in.h>

From owner-svn-src-user@FreeBSD.ORG  Mon Jan  4 18:31:40 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 12F3210656B3;
	Mon,  4 Jan 2010 18:31:40 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id A64598FC14;
	Mon,  4 Jan 2010 18:31:39 +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 o04IVdff044704;
	Mon, 4 Jan 2010 18:31:39 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o04IVdeM044703;
	Mon, 4 Jan 2010 18:31:39 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001041831.o04IVdeM044703@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Mon, 4 Jan 2010 18:31:39 +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: r201524 - user/ed/utmpx
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 18:31:40 -0000

Author: ed
Date: Mon Jan  4 18:31:39 2010
New Revision: 201524
URL: http://svn.freebsd.org/changeset/base/201524

Log:
  Add a new branch, which I can use to experiment with utmpx in libc.

Added:
     - copied from r201523, head/
Directory Properties:
  user/ed/utmpx/   (props changed)

From owner-svn-src-user@FreeBSD.ORG  Mon Jan  4 20:55:47 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 B3FA31065695;
	Mon,  4 Jan 2010 20:55:47 +0000 (UTC)
	(envelope-from edwin@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id A2EF08FC15;
	Mon,  4 Jan 2010 20:55:47 +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 o04KtlQG077077;
	Mon, 4 Jan 2010 20:55:47 GMT (envelope-from edwin@svn.freebsd.org)
Received: (from edwin@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o04KtlAL077066;
	Mon, 4 Jan 2010 20:55:47 GMT (envelope-from edwin@svn.freebsd.org)
Message-Id: <201001042055.o04KtlAL077066@svn.freebsd.org>
From: Edwin Groothuis <edwin@FreeBSD.org>
Date: Mon, 4 Jan 2010 20:55:47 +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: r201531 - user/edwin/calendar
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 20:55:47 -0000

Author: edwin
Date: Mon Jan  4 20:55:47 2010
New Revision: 201531
URL: http://svn.freebsd.org/changeset/base/201531

Log:
  Behold! Calendar prints events again, even over multiple years.

Modified:
  user/edwin/calendar/calendar.c
  user/edwin/calendar/calendar.h
  user/edwin/calendar/dates.c
  user/edwin/calendar/day.c
  user/edwin/calendar/events.c
  user/edwin/calendar/io.c
  user/edwin/calendar/ostern.c
  user/edwin/calendar/parsedata.c
  user/edwin/calendar/paskha.c
  user/edwin/calendar/pathnames.h

Modified: user/edwin/calendar/calendar.c
==============================================================================
--- user/edwin/calendar/calendar.c	Mon Jan  4 20:34:15 2010	(r201530)
+++ user/edwin/calendar/calendar.c	Mon Jan  4 20:55:47 2010	(r201531)
@@ -1,4 +1,4 @@
-/*
+/*-
  * Copyright (c) 1989, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
  *

Modified: user/edwin/calendar/calendar.h
==============================================================================
--- user/edwin/calendar/calendar.h	Mon Jan  4 20:34:15 2010	(r201530)
+++ user/edwin/calendar/calendar.h	Mon Jan  4 20:55:47 2010	(r201531)
@@ -1,4 +1,4 @@
-/*
+/*-
  * Copyright (c) 1989, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
  *
@@ -83,10 +83,11 @@ extern int	year1, year2;
  * - Use event_continue() to add more text to the last added event
  * - Use event_print_all() to display them in time chronological order
  */
-struct event *event_add(struct event *, int, int, char *, int, char *);
+struct event *event_add(int, int, int, char *, int, char *);
 void	event_continue(struct event *events, char *txt);
-void	event_print_all(FILE *fp, struct event *events);
+void	event_print_all(FILE *fp);
 struct event {
+	int	year;
 	int	month;
 	int	day;
 	int	var;
@@ -140,3 +141,5 @@ int	remember_ymd(int y, int m, int d);
 int	remember_yd(int y, int d, int *rm, int *rd);
 int	first_dayofweek_of_year(int y);
 int	first_dayofweek_of_month(int y, int m);
+int	walkthrough_dates(struct event **e);
+void	addtodate(struct event *e, int year, int month, int day);

Modified: user/edwin/calendar/dates.c
==============================================================================
--- user/edwin/calendar/dates.c	Mon Jan  4 20:34:15 2010	(r201530)
+++ user/edwin/calendar/dates.c	Mon Jan  4 20:55:47 2010	(r201531)
@@ -79,6 +79,8 @@ int	mondaytab[][14] = {
 	{0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 30},
 };
 
+static struct cal_day *	find_day(int yy, int mm, int dd);
+
 static void
 createdate(int y, int m, int d)
 {
@@ -282,7 +284,7 @@ remember_ymd(int yy, int mm, int dd)
 				if (d->dayofmonth == dd)
 					return (1);
 				d = d->nextday;
-				continue;;
+				continue;
 			}
 			return (0);
 		}
@@ -366,3 +368,85 @@ first_dayofweek_of_month(int yy, int mm)
 	/* Should not happen */
 	return (-1);
 }
+
+int
+walkthrough_dates(struct event **e)
+{
+	static struct cal_year *y = NULL;
+	static struct cal_month *m = NULL;
+	static struct cal_day *d = NULL;
+
+	if (y == NULL) {
+		y = hyear;
+		m = y->months;
+		d = m->days;
+		*e = d->events;
+		return (1);
+	};
+	if (d->nextday != NULL) {
+		d = d->nextday;
+		*e = d->events;
+		return (1);
+	}
+	if (m->nextmonth != NULL) {
+		m = m->nextmonth;
+		d = m->days;
+		*e = d->events;
+		return (1);
+	}
+	if (y->nextyear != NULL) {
+		y = y->nextyear;
+		m = y->months;
+		d = m->days;
+		*e = d->events;
+		return (1);
+	}
+
+	return (0);
+}
+
+static struct cal_day *
+find_day(int yy, int mm, int dd)
+{
+	struct cal_year *y;
+	struct cal_month *m;
+	struct cal_day *d;
+
+	if (debug_remember)
+		printf("remember_ymd: %d - %d - %d\n", yy, mm, dd);
+
+	y = hyear;
+	while (y != NULL) {
+		if (y->year != yy) {
+			y = y->nextyear;
+			continue;
+		}
+		m = y->months;
+		while (m != NULL) {
+			if (m->month != mm) {
+				m = m->nextmonth;
+				continue;
+			}
+			d = m->days;
+			while (d != NULL) {
+				if (d->dayofmonth == dd)
+					return (d);
+				d = d->nextday;
+				continue;
+			}
+			return (NULL);
+		}
+		return (NULL);
+	}
+	return (NULL);
+}
+
+void
+addtodate(struct event *e, int year, int month, int day)
+{
+	struct cal_day *d;
+
+	d = find_day(year, month, day);
+	e->next = d->events;
+	d->events = e;
+}

Modified: user/edwin/calendar/day.c
==============================================================================
--- user/edwin/calendar/day.c	Mon Jan  4 20:34:15 2010	(r201530)
+++ user/edwin/calendar/day.c	Mon Jan  4 20:55:47 2010	(r201531)
@@ -1,4 +1,4 @@
-/*
+/*-
  * Copyright (c) 1989, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
  *

Modified: user/edwin/calendar/events.c
==============================================================================
--- user/edwin/calendar/events.c	Mon Jan  4 20:34:15 2010	(r201530)
+++ user/edwin/calendar/events.c	Mon Jan  4 20:55:47 2010	(r201531)
@@ -1,4 +1,4 @@
-/*
+/*-
  * Copyright (c) 1989, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
  *
@@ -44,8 +44,7 @@ __FBSDID("$FreeBSD: user/edwin/calendar/
 #include "calendar.h"
 
 struct event *
-event_add(struct event *events, int month, int day,
-    char *date, int var, char *txt)
+event_add(int year, int month, int day, char *date, int var, char *txt)
 {
 	struct event *e;
 
@@ -68,9 +67,8 @@ event_add(struct event *events, int mont
 	e->text = strdup(txt);
 	if (e->text == NULL)
 		errx(1, "event_add: cannot allocate memory");
-	e->next = events;
-
-	return e;
+	addtodate(e, year, month, day);
+	return (e);
 }
 
 void
@@ -102,42 +100,11 @@ event_continue(struct event *e, char *tx
 }
 
 void
-event_print_all(FILE *fp, struct event *events)
+event_print_all(FILE *fp)
 {
-	struct event *e, *e_next;
-	int daycounter;
-	int day, month;
-
-	/*
-	 * Print all events:
-	 * - We know the number of days to be counted (f_dayAfter + f_dayBefore)
-	 * - We know the current day of the year ("now" - f_dayBefore + counter)
-	 * - We know the number of days in the year (yrdays, set in settime())
-	 * - So we know the date on which the current daycounter is on the
-	 *   calendar in days and months.
-	 * - Go through the list of events, and print all matching dates
-	 */
-	for (daycounter = 0; daycounter <= f_dayAfter + f_dayBefore;
-	    daycounter++) {
-		day = tp1.tm_yday - f_dayBefore + daycounter;
-//		if (day < 0)
-//			day += yrdays;
-//		if (day >= yrdays)
-//			day -= yrdays;
-
-		/*
-		 * When we know the day of the year, we can determine the day
-		 * of the month and the month.
-		 */
-//		month = 1;
-//		while (month <= 12) {
-//			if (day <= cumdays[month])
-//				break;
-//			month++;
-//		}
-//		month--;
-//		day -= cumdays[month];
+	struct event *e;
 
+	while (walkthrough_dates(&e) != 0) {
 #ifdef DEBUG
 		fprintf(stderr, "event_print_allmonth: %d, day: %d\n",
 		    month, day);
@@ -147,14 +114,10 @@ event_print_all(FILE *fp, struct event *
 		 * Go through all events and print the text of the matching
 		 * dates
 		 */
-		for (e = events; e != NULL; e = e_next) {
-			e_next = e->next;
-
-			if (month != e->month || day != e->day)
-				continue;
-
+		while (e != NULL) {
 			(void)fprintf(fp, "%s%c%s\n", e->date,
 			    e->var ? '*' : ' ', e->text);
+			e = e->next;
 		}
 	}
 }

Modified: user/edwin/calendar/io.c
==============================================================================
--- user/edwin/calendar/io.c	Mon Jan  4 20:34:15 2010	(r201530)
+++ user/edwin/calendar/io.c	Mon Jan  4 20:55:47 2010	(r201531)
@@ -1,4 +1,4 @@
-/*
+/*-
  * Copyright (c) 1989, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
  *
@@ -96,7 +96,6 @@ cal(void)
 	static int d_first = -1;
 	char buf[2048 + 1];
 	struct event *events[MAXCOUNT];
-	struct event *eventshead = NULL;
 	struct tm tm;
 	char dbuf[80];
 
@@ -167,12 +166,14 @@ cal(void)
 		/* Trim spaces in front of the tab */
 		while (isspace(pp[-1]))
 			pp--;
+
 		p = *pp;
 		*pp = '\0';
 		if ((count = parsedaymonth(buf, year, month, day, &flags)) == 0)
 			continue;
 		printf("%s - count: %d\n", buf, count);
 		*pp = p;
+
 		/* Find the last tab */
 		while (pp[1] == '\t')
 			pp++;
@@ -183,91 +184,18 @@ cal(void)
 		for (i = 0; i < count; i++) {
 			tm.tm_mon = month[i] - 1;
 			tm.tm_mday = day[i];
-			tm.tm_year = tp1.tm_year; /* unused */
+			tm.tm_year = year[i] - 1900;
 			(void)strftime(dbuf, sizeof(dbuf),
 			    d_first ? "%e %b" : "%b %e", &tm);
-			eventshead = event_add(eventshead, month[i], day[i],
-			    dbuf, (flags &= F_VARIABLE != 0) ? 1 : 0, pp);
-			events[i] = eventshead;
+			events[i] = event_add(year[i], month[i], day[i], dbuf,
+			    ((flags &= F_VARIABLE) != 0) ? 1 : 0, pp);
 		}
 	}
 
-	event_print_all(fp, eventshead);
+	event_print_all(fp);
 	closecal(fp);
 }
 
-#ifdef NOTDEF
-//int
-//getfield(char *p, int *flags)
-//{
-//	int val, var;
-//	char *start, savech;
-//
-//	if (*p == '\0')
-//		return(0);
-//
-//	/* Find the first digit, alpha or * */
-//	for (; !isdigit((unsigned char)*p) && !isalpha((unsigned char)*p)
-//               && *p != '*'; ++p)
-//	       ;
-//	if (*p == '*') {			/* `*' is current month */
-//		*flags |= F_ISMONTH;
-//		return (tp->tm_mon + 1);
-//	}
-//	if (isdigit((unsigned char)*p)) {
-//		val = strtol(p, &p, 10);	/* if 0, it's failure */
-//		for (; !isdigit((unsigned char)*p)
-//                       && !isalpha((unsigned char)*p) && *p != '*'; ++p);
-//		return (val);
-//	}
-//	for (start = p; isalpha((unsigned char)*++p););
-//
-//	/* Sunday-1 */
-//	if (*p == '+' || *p == '-')
-//		for(; isdigit((unsigned char)*++p);)
-//			;
-//
-//	savech = *p;
-//	*p = '\0';
-//
-//	/* Month */
-//	if ((val = getmonth(start)) != 0)
-//		*flags |= F_ISMONTH;
-//
-//	/* Day */
-//	else if ((val = getday(start)) != 0) {
-//		*flags |= F_ISDAY;
-//
-//		/* variable weekday */
-//		if ((var = getdayvar(start)) != 0) {
-//			if (var <= 5 && var >= -4)
-//				val += var * 10;
-//#ifdef DEBUG
-//			printf("var: %d\n", var);
-//#endif
-//		}
-//	}
-//
-//	/* Easter */
-//	else if ((val = geteaster(start, tp->tm_year + 1900)) != 0)
-//		*flags |= F_EASTER;
-//
-//	/* Paskha */
-//	else if ((val = getpaskha(start, tp->tm_year + 1900)) != 0)
-//		*flags |= F_EASTER;
-//
-//	/* undefined rest */
-//	else {
-//		*p = savech;
-//		return (0);
-//	}
-//	for (*p = savech; !isdigit((unsigned char)*p)
-//	   && !isalpha((unsigned char)*p) && *p != '*'; ++p)
-//		;
-//	return (val);
-//}
-#endif
-
 FILE *
 opencal(void)
 {

Modified: user/edwin/calendar/ostern.c
==============================================================================
--- user/edwin/calendar/ostern.c	Mon Jan  4 20:34:15 2010	(r201530)
+++ user/edwin/calendar/ostern.c	Mon Jan  4 20:55:47 2010	(r201531)
@@ -1,4 +1,4 @@
-/*
+/*-
  * Copyright (c) 1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
  * All rights reserved.
  *

Modified: user/edwin/calendar/parsedata.c
==============================================================================
--- user/edwin/calendar/parsedata.c	Mon Jan  4 20:34:15 2010	(r201530)
+++ user/edwin/calendar/parsedata.c	Mon Jan  4 20:55:47 2010	(r201531)
@@ -424,7 +424,7 @@ parsedaymonth(char *date, int *yearp, in
 					 && remember_ymd(year, imonth, d)) {
 						remember(index++, yearp,
 						    monthp, dayp, year, imonth,
-						    rd);
+						    d);
 						continue;
 					}
 					d += 7;
@@ -440,8 +440,7 @@ parsedaymonth(char *date, int *yearp, in
 				}
 				if (remember_ymd(year, imonth, d))
 					remember(index++, yearp,
-					    monthp, dayp, year, imonth,
-					    rd);
+					    monthp, dayp, year, imonth, d);
 				continue;
 			}
 			continue;
@@ -454,7 +453,7 @@ parsedaymonth(char *date, int *yearp, in
 			while (d <= mondays[imonth]) {
 				if (remember_ymd(year, imonth, d))
 					remember(index++, yearp, monthp, dayp,
-					    year, imonth, rd);
+					    year, imonth, d);
 				d += 7;
 			}
 			continue;

Modified: user/edwin/calendar/paskha.c
==============================================================================
--- user/edwin/calendar/paskha.c	Mon Jan  4 20:34:15 2010	(r201530)
+++ user/edwin/calendar/paskha.c	Mon Jan  4 20:55:47 2010	(r201531)
@@ -1,4 +1,4 @@
-/*
+/*-
  * Copyright (C) 1993-1996 by Andrey A. Chernov, Moscow, Russia.
  * All rights reserved.
  *

Modified: user/edwin/calendar/pathnames.h
==============================================================================
--- user/edwin/calendar/pathnames.h	Mon Jan  4 20:34:15 2010	(r201530)
+++ user/edwin/calendar/pathnames.h	Mon Jan  4 20:55:47 2010	(r201531)
@@ -1,4 +1,4 @@
-/*
+/*-
  * Copyright (c) 1989, 1993
  *	The Regents of the University of California.  All rights reserved.
  *

From owner-svn-src-user@FreeBSD.ORG  Mon Jan  4 21:02:02 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 288A41065672;
	Mon,  4 Jan 2010 21:02:02 +0000 (UTC)
	(envelope-from edwin@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id F35D58FC08;
	Mon,  4 Jan 2010 21:02:01 +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 o04L21MO078586;
	Mon, 4 Jan 2010 21:02:01 GMT (envelope-from edwin@svn.freebsd.org)
Received: (from edwin@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o04L21U2078584;
	Mon, 4 Jan 2010 21:02:01 GMT (envelope-from edwin@svn.freebsd.org)
Message-Id: <201001042102.o04L21U2078584@svn.freebsd.org>
From: Edwin Groothuis <edwin@FreeBSD.org>
Date: Mon, 4 Jan 2010 21:02:01 +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: r201533 - user/edwin/calendar
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 21:02:02 -0000

Author: edwin
Date: Mon Jan  4 21:02:01 2010
New Revision: 201533
URL: http://svn.freebsd.org/changeset/base/201533

Log:
  Update copyright, this code was never part of the original distribution.

Modified:
  user/edwin/calendar/events.c

Modified: user/edwin/calendar/events.c
==============================================================================
--- user/edwin/calendar/events.c	Mon Jan  4 20:59:52 2010	(r201532)
+++ user/edwin/calendar/events.c	Mon Jan  4 21:02:01 2010	(r201533)
@@ -1,6 +1,5 @@
 /*-
- * Copyright (c) 1989, 1993, 1994
- *	The Regents of the University of California.  All rights reserved.
+ * Copyright (c) 1992-2009 Edwin Groothuis. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -10,18 +9,11 @@
  * 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.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS BE LIABLE
+ * 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)
@@ -29,6 +21,7 @@
  * 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>

From owner-svn-src-user@FreeBSD.ORG  Mon Jan  4 22:21:57 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 25AAF106566B;
	Mon,  4 Jan 2010 22:21:57 +0000 (UTC) (envelope-from imp@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id F128F8FC17;
	Mon,  4 Jan 2010 22:21:56 +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 o04MLutx097595;
	Mon, 4 Jan 2010 22:21:56 GMT (envelope-from imp@svn.freebsd.org)
Received: (from imp@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o04MLu0i097594;
	Mon, 4 Jan 2010 22:21:56 GMT (envelope-from imp@svn.freebsd.org)
Message-Id: <201001042221.o04MLu0i097594@svn.freebsd.org>
From: Warner Losh <imp@FreeBSD.org>
Date: Mon, 4 Jan 2010 22:21:56 +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: r201537 - user/imp/config_reorg_sys
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 22:21:57 -0000

Author: imp
Date: Mon Jan  4 22:21:56 2010
New Revision: 201537
URL: http://svn.freebsd.org/changeset/base/201537

Log:
  Create a branch to publish my WIP for the config file reshuffling I've
  been working on privately for a while to give it more visibility.

Added:
     - copied from r201536, head/sys/
Directory Properties:
  user/imp/config_reorg_sys/   (props changed)

From owner-svn-src-user@FreeBSD.ORG  Mon Jan  4 22:57:34 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 40ABB1065676;
	Mon,  4 Jan 2010 22:57:34 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 303AB8FC25;
	Mon,  4 Jan 2010 22:57:34 +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 o04MvYWT006200;
	Mon, 4 Jan 2010 22:57:34 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o04MvYH0006196;
	Mon, 4 Jan 2010 22:57:34 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001042257.o04MvYH0006196@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Mon, 4 Jan 2010 22:57:34 +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: r201542 - in user/luigi/ipfw3-head/sys: netgraph
	netinet/ipfw
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 22:57:34 -0000

Author: luigi
Date: Mon Jan  4 22:57:33 2010
New Revision: 201542
URL: http://svn.freebsd.org/changeset/base/201542

Log:
  sync with HEAD

Modified:
  user/luigi/ipfw3-head/sys/netgraph/ng_ipfw.c
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_sockopt.c

Modified: user/luigi/ipfw3-head/sys/netgraph/ng_ipfw.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netgraph/ng_ipfw.c	Mon Jan  4 22:45:20 2010	(r201541)
+++ user/luigi/ipfw3-head/sys/netgraph/ng_ipfw.c	Mon Jan  4 22:57:33 2010	(r201542)
@@ -221,22 +221,23 @@ ng_ipfw_findhook1(node_p node, u_int16_t
 static int
 ng_ipfw_rcvdata(hook_p hook, item_p item)
 {
-	struct ipfw_start_info	*ngit;
+	struct ipfw_rule_ref	*tag;
 	struct mbuf *m;
 
 	NGI_GET_M(item, m);
 	NG_FREE_ITEM(item);
 
-	ngit = (struct ipfw_start_info *)
-		m_tag_locate(m, NGM_IPFW_COOKIE, 0, NULL);
-	if (ngit == NULL) {
+	tag = (struct ipfw_rule_ref *)
+		m_tag_locate(m, MTAG_IPFW_RULE, 0, NULL);
+	if (tag == NULL) {
 		NG_FREE_M(m);
 		return (EINVAL);	/* XXX: find smth better */
 	};
 
-	switch (ngit->info) {
-	case DIR_OUT:
-	    {
+	if (tag->info & IPFW_INFO_IN) {
+		ip_input(m);
+		return (0);
+	} else {
 		struct ip *ip;
 
 		if (m->m_len < sizeof(struct ip) &&
@@ -248,23 +249,13 @@ ng_ipfw_rcvdata(hook_p hook, item_p item
 		SET_HOST_IPLEN(ip);
 
 		return ip_output(m, NULL, NULL, IP_FORWARDING, NULL, NULL);
-	    }
-	case DIR_IN:
-		ip_input(m);
-		return (0);
-	default:
-		panic("ng_ipfw_rcvdata: bad dir %u", ngit->dir);
 	}	
-
-	/* not reached */
-	return (0);
 }
 
 static int
 ng_ipfw_input(struct mbuf **m0, int dir, struct ip_fw_args *fwa, int tee)
 {
 	struct mbuf *m;
-	struct ipfw_start_info *ngit;
 	struct ip *ip;
 	hook_p	hook;
 	int error = 0;
@@ -273,7 +264,7 @@ ng_ipfw_input(struct mbuf **m0, int dir,
 	 * Node must be loaded and corresponding hook must be present.
 	 */
 	if (fw_node == NULL || 
-	   (hook = ng_ipfw_findhook1(fw_node, fwa->cookie)) == NULL) {
+	   (hook = ng_ipfw_findhook1(fw_node, fwa->rule.info)) == NULL) {
 		if (tee == 0)
 			m_freem(*m0);
 		return (ESRCH);		/* no hook associated with this rule */
@@ -286,19 +277,19 @@ ng_ipfw_input(struct mbuf **m0, int dir,
 	 */
 	if (tee == 0) {
 		struct m_tag *tag;
-		struct ipfw_start_info *ngit;
+		struct ipfw_rule_ref *r;
 		m = *m0;
 		*m0 = NULL;	/* it belongs now to netgraph */
 
-		tag = m_tag_alloc(NGM_IPFW_COOKIE, sizeof(*mt),
+		tag = m_tag_alloc(MTAG_IPFW_RULE, 0, sizeof(*r),
 			M_NOWAIT|M_ZERO);
-		if (tagn == NULL) {
+		if (tag == NULL) {
 			m_freem(m);
 			return (ENOMEM);
 		}
-		ngit = (struct ipfw_start_info *)(tag + 1);
-		*ngit = fwa->start
-		ngit->info = dir;
+		r = (struct ipfw_rule_ref *)(tag + 1);
+		*r = fwa->rule;
+		r->info = dir ? IPFW_INFO_IN : IPFW_INFO_OUT;
 		m_tag_prepend(m, tag);
 
 	} else

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Mon Jan  4 22:45:20 2010	(r201541)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Mon Jan  4 22:57:33 2010	(r201542)
@@ -462,15 +462,10 @@ heap_free(struct dn_heap *h)
  */
 
 /*
- * Dispose a packet in dummynet. Use an inline functions so if we
+ * Dispose a list of packet. Use an inline functions so if we
  * need to free extra state associated to a packet, this is a
  * central point to do it.
  */
-static __inline void *dn_free_pkt(struct mbuf *m)
-{
-	FREE_PKT(m);
-	return NULL;
-}
 
 static __inline void dn_free_pkts(struct mbuf *mnext)
 {
@@ -478,7 +473,7 @@ static __inline void dn_free_pkts(struct
 
 	while ((m = mnext) != NULL) {
 		mnext = m->m_nextpkt;
-		dn_free_pkt(m);
+		FREE_PKT(m);
 	}
 }
 
@@ -1032,12 +1027,12 @@ dummynet_send(struct mbuf *m)
 
 		case DIR_DROP:
 			/* drop the packet after some time */
-			dn_free_pkt(m);
+			FREE_PKT(m);
 			break;
 
 		default:
 			printf("dummynet: bad switch %d!\n", dst);
-			dn_free_pkt(m);
+			FREE_PKT(m);
 			break;
 		}
 	}
@@ -1564,7 +1559,8 @@ dropit:
 	if (q)
 		q->drops++;
 	DUMMYNET_UNLOCK();
-	*m0 = dn_free_pkt(m);
+	FREE_PKT(m);
+	*m0 = NULL;
 	return ((fs && (fs->flags_fs & DN_NOERROR)) ? 0 : ENOBUFS);
 }
 

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_sockopt.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_sockopt.c	Mon Jan  4 22:45:20 2010	(r201541)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_sockopt.c	Mon Jan  4 22:57:33 2010	(r201542)
@@ -303,6 +303,8 @@ del_entry(struct ip_fw_chain *chain, u_i
 					n++;
 			}
 		}
+		if (n == 0 && arg == 0)
+			break; /* special case, flush on empty ruleset */
 		/* allocate the map, if needed */
 		if (n > 0)
 			map = get_map(chain, -n, 1 /* locked */);

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 04:07:30 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 AEF24106568B;
	Tue,  5 Jan 2010 04:07:30 +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 9D5AE8FC1E;
	Tue,  5 Jan 2010 04:07:30 +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 o0547Ub8081409;
	Tue, 5 Jan 2010 04:07:30 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o0547UEi081404;
	Tue, 5 Jan 2010 04:07:30 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001050407.o0547UEi081404@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Tue, 5 Jan 2010 04:07:30 +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: r201548 - 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: Tue, 05 Jan 2010 04:07:30 -0000

Author: kmacy
Date: Tue Jan  5 04:07:30 2010
New Revision: 201548
URL: http://svn.freebsd.org/changeset/base/201548

Log:
  - remove reference to spinlocks in unet_kern_timeout
  - define critical sections as thread bucket locks
  - make intr_event_bind return ENOTSUP
  - remove the bulk of libkern as it should all be provided by libc

Modified:
  user/kmacy/releng_8_rump/lib/libunet/Makefile
  user/kmacy/releng_8_rump/lib/libunet/unet_kern_intr.c
  user/kmacy/releng_8_rump/lib/libunet/unet_kern_timeout.c
  user/kmacy/releng_8_rump/lib/libunet/unet_uma_core.c

Modified: user/kmacy/releng_8_rump/lib/libunet/Makefile
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/Makefile	Tue Jan  5 03:39:31 2010	(r201547)
+++ user/kmacy/releng_8_rump/lib/libunet/Makefile	Tue Jan  5 04:07:30 2010	(r201548)
@@ -80,17 +80,7 @@ UNET_NETINET_COMMON_OBJS +=	\
 
 UNET_LIBKERN_COMMON_OBJS =	\
 	arc4random.o		\
-	bcmp.o			\
-	inet_aton.o		\
-	inet_ntoa.o		\
-	memcmp.o		\
-	strcat.o		\
-	strcmp.o		\
-	strcpy.o		\
-	strlcpy.o		\
-	strlen.o		\
-	strncmp.o		\
-	strtoul.o
+	strlcpy.o
 
 UNET_OTHER_COMMON_OBJS =	\
 	harvest.o
@@ -101,15 +91,15 @@ UNET_GLUE_COMMON_OBJS =		\
 	unet_in_cksum.o	\
 	unet_init_main.o	\
 	unet_lock.o		\
-	unet_uma_core.c		\
 	unet_kern_condvar.o	\
 	unet_kern_descrip.o	\
 	unet_kern_intr.o	\
 	unet_kern_synch.o	\
 	unet_kern_subr.o	\
 	unet_kern_timeout.o	\
-	unet_subr_taskqueue.o
-
+	unet_subr_taskqueue.o	\
+	unet_uma_core.c
+#
 #	unet_init.o		\
 #	unet_uipc_syscalls.o
 #	unet_sys_generic.o

Modified: user/kmacy/releng_8_rump/lib/libunet/unet_kern_intr.c
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/unet_kern_intr.c	Tue Jan  5 03:39:31 2010	(r201547)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_kern_intr.c	Tue Jan  5 04:07:30 2010	(r201548)
@@ -39,9 +39,7 @@ int
 intr_event_bind(struct intr_event *ie, u_char cpu)
 {
 
-	panic("");
-	return (0);
-		    
+	return (ENOTSUP);
 }
 
 

Modified: user/kmacy/releng_8_rump/lib/libunet/unet_kern_timeout.c
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/unet_kern_timeout.c	Tue Jan  5 03:39:31 2010	(r201547)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_kern_timeout.c	Tue Jan  5 04:07:30 2010	(r201548)
@@ -81,8 +81,8 @@ struct callout_cpu cc_cpu;
 #define	CC_CPU(cpu)	&cc_cpu
 #define	CC_SELF()	&cc_cpu
 #endif
-#define	CC_LOCK(cc)	mtx_lock_spin(&(cc)->cc_lock)
-#define	CC_UNLOCK(cc)	mtx_unlock_spin(&(cc)->cc_lock)
+#define	CC_LOCK(cc)	mtx_lock(&(cc)->cc_lock)
+#define	CC_UNLOCK(cc)	mtx_unlock(&(cc)->cc_lock)
 
 static int timeout_cpu;
 

Modified: user/kmacy/releng_8_rump/lib/libunet/unet_uma_core.c
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/unet_uma_core.c	Tue Jan  5 03:39:31 2010	(r201547)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_uma_core.c	Tue Jan  5 04:07:30 2010	(r201548)
@@ -284,6 +284,25 @@ SYSCTL_PROC(_vm, OID_AUTO, zone_count, C
 SYSCTL_PROC(_vm, OID_AUTO, zone_stats, CTLFLAG_RD|CTLTYPE_STRUCT,
     0, 0, sysctl_vm_zone_stats, "s,struct uma_type_header", "Zone Stats");
 
+void
+lock_thread_bucket(void)
+{
+
+	panic("");
+}
+
+void
+unlock_thread_bucket(void)
+{
+
+	panic("");
+}
+	       
+
+#define critical_enter()	lock_thread_bucket()
+#define critical_exit()		unlock_thread_bucket()
+
+
 /*
  * This routine checks to see whether or not it's safe to enable buckets.
  */

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 05:37:50 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 44EA3106568B;
	Tue,  5 Jan 2010 05:37:50 +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 324DD8FC0C;
	Tue,  5 Jan 2010 05:37:50 +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 o055bn8o001388;
	Tue, 5 Jan 2010 05:37:49 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o055bnMQ001384;
	Tue, 5 Jan 2010 05:37:49 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001050537.o055bnMQ001384@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Tue, 5 Jan 2010 05:37:49 +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: r201549 - in user/kmacy/releng_8_rump/lib/libunet: .
	include/sys
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: Tue, 05 Jan 2010 05:37:50 -0000

Author: kmacy
Date: Tue Jan  5 05:37:49 2010
New Revision: 201549
URL: http://svn.freebsd.org/changeset/base/201549

Log:
  implement kernel condvar wrappers for pthread condvars

Added:
  user/kmacy/releng_8_rump/lib/libunet/include/sys/
  user/kmacy/releng_8_rump/lib/libunet/include/sys/_lock.h   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/include/sys/condvar.h   (contents, props changed)
Modified:
  user/kmacy/releng_8_rump/lib/libunet/unet_kern_condvar.c

Added: user/kmacy/releng_8_rump/lib/libunet/include/sys/_lock.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/kmacy/releng_8_rump/lib/libunet/include/sys/_lock.h	Tue Jan  5 05:37:49 2010	(r201549)
@@ -0,0 +1,42 @@
+/*-
+ * Copyright (c) 1997 Berkeley Software Design, Inc. 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.
+ * 3. Berkeley Software Design Inc's name may not be used to endorse or
+ *    promote products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``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 BERKELEY SOFTWARE DESIGN INC 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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _SYS__LOCK_H_
+#define	_SYS__LOCK_H_
+
+struct lock_object {
+	const	char *lo_name;		/* Individual lock name. */
+	u_int	lo_flags;
+	u_int	lo_data;		/* General class specific data. */
+	struct	witness *lo_witness;	/* Data for witness. */
+	pthread_mutex_t	lo_mutex;
+};
+
+#endif /* !_SYS__LOCK_H_ */

Added: user/kmacy/releng_8_rump/lib/libunet/include/sys/condvar.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/kmacy/releng_8_rump/lib/libunet/include/sys/condvar.h	Tue Jan  5 05:37:49 2010	(r201549)
@@ -0,0 +1,79 @@
+/*-
+ * Copyright (c) 2000 Jake Burkholder <jake@freebsd.org>.
+ * 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 AND CONTRIBUTORS ``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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef	_SYS_CONDVAR_H_
+#define	_SYS_CONDVAR_H_
+
+#ifndef	LOCORE
+#include <sys/queue.h>
+
+struct lock_object;
+struct thread;
+
+TAILQ_HEAD(cv_waitq, thread);
+
+/*
+ * Condition variable.  The waiters count is protected by the mutex that
+ * protects the condition; that is, the mutex that is passed to cv_wait*()
+ * and is held across calls to cv_signal() and cv_broadcast().  It is an
+ * optimization to avoid looking up the sleep queue if there are no waiters.
+ */
+struct cv {
+	const char	*cv_description;
+	pthread_cond_t	cv_cond;
+};
+
+void	cv_init(struct cv *cvp, const char *desc);
+void	cv_destroy(struct cv *cvp);
+
+void	_cv_wait(struct cv *cvp, struct lock_object *lock);
+void	_cv_wait_unlock(struct cv *cvp, struct lock_object *lock);
+int	_cv_wait_sig(struct cv *cvp, struct lock_object *lock);
+int	_cv_timedwait(struct cv *cvp, struct lock_object *lock, int timo);
+int	_cv_timedwait_sig(struct cv *cvp, struct lock_object *lock, int timo);
+
+void	cv_signal(struct cv *cvp);
+void	cv_broadcastpri(struct cv *cvp, int pri);
+
+#define	cv_wait(cvp, lock)						\
+	_cv_wait((cvp), &(lock)->lock_object)
+#define	cv_wait_unlock(cvp, lock)					\
+	_cv_wait_unlock((cvp), &(lock)->lock_object)
+#define	cv_wait_sig(cvp, lock)						\
+	_cv_wait_sig((cvp), &(lock)->lock_object)
+#define	cv_timedwait(cvp, lock, timo)					\
+	_cv_timedwait((cvp), &(lock)->lock_object, (timo))
+#define	cv_timedwait_sig(cvp, lock, timo)				\
+	_cv_timedwait_sig((cvp), &(lock)->lock_object, (timo))
+
+#define cv_broadcast(cvp)	cv_broadcastpri(cvp, 0)
+
+#define	cv_wmesg(cvp)		((cvp)->cv_description)
+
+#endif	/* !LOCORE */
+#endif	/* _SYS_CONDVAR_H_ */

Modified: user/kmacy/releng_8_rump/lib/libunet/unet_kern_condvar.c
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/unet_kern_condvar.c	Tue Jan  5 04:07:30 2010	(r201548)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_kern_condvar.c	Tue Jan  5 05:37:49 2010	(r201549)
@@ -16,15 +16,18 @@ __FBSDID("$FreeBSD$");
 #include <sys/sleepqueue.h>
 #include <sys/resourcevar.h>
 
+#include <pthread.h>
+
 /*
  * Initialize a condition variable.  Must be called before use.
  */
 void
 cv_init(struct cv *cvp, const char *desc)
 {
-
+	pthread_condattr_t ca;
+    
 	cvp->cv_description = desc;
-	cvp->cv_waiters = 0;
+	pthread_cond_init(&cvp->cv_cond, &ca);
 }
 
 /*
@@ -34,14 +37,8 @@ cv_init(struct cv *cvp, const char *desc
 void
 cv_destroy(struct cv *cvp)
 {
-#ifdef INVARIANTS
-	struct sleepqueue *sq;
 
-	sleepq_lock(cvp);
-	sq = sleepq_lookup(cvp);
-	sleepq_release(cvp);
-	KASSERT(sq == NULL, ("%s: associated sleep queue non-empty", __func__));
-#endif
+	pthread_cond_destroy(&cvp->cv_cond);
 }
 
 /*
@@ -54,8 +51,8 @@ cv_destroy(struct cv *cvp)
 void
 _cv_wait(struct cv *cvp, struct lock_object *lock)
 {
-	panic("");
-	
+
+	pthread_cond_wait(&cvp->cv_cond, &lock->lo_mutex);
 }
 
 /*
@@ -67,9 +64,8 @@ _cv_wait(struct cv *cvp, struct lock_obj
 int
 _cv_wait_sig(struct cv *cvp, struct lock_object *lock)
 {
-	panic("");
 
-	return (0);
+	return (pthread_cond_wait(&cvp->cv_cond, &lock->lo_mutex));
 }
 
 /*
@@ -80,9 +76,19 @@ _cv_wait_sig(struct cv *cvp, struct lock
 int
 _cv_timedwait(struct cv *cvp, struct lock_object *lock, int timo)
 {
-	panic("");
-	
-	return (0);
+	struct timespec abstime;
+	int secs = timo/hz;
+	int nsecs = (timo%hz)*((1000*1000*1000)/hz);
+
+	abstime.tv_sec = secs;
+	abstime.tv_nsec = nsecs;
+
+	/* XXX
+	 * how do we handle getting interrupted by a signal?
+	 * set the sigmask?
+	 */
+	return (pthread_cond_timedwait(&cvp->cv_cond, &lock->lo_mutex,
+		    &abstime));
 }
 
 /*
@@ -94,9 +100,15 @@ _cv_timedwait(struct cv *cvp, struct loc
 int
 _cv_timedwait_sig(struct cv *cvp, struct lock_object *lock, int timo)
 {
-	panic("");
+	struct timespec abstime;
+	int secs = timo/hz;
+	int nsecs = (timo%hz)*((1000*1000*1000)/hz);
 
-	return (0);
+	abstime.tv_sec = secs;
+	abstime.tv_nsec = nsecs;
+
+	return (pthread_cond_timedwait(&cvp->cv_cond, &lock->lo_mutex,
+		    &abstime));
 }
 
 /*
@@ -106,6 +118,6 @@ _cv_timedwait_sig(struct cv *cvp, struct
 void
 cv_broadcastpri(struct cv *cvp, int pri)
 {
-	panic("");
-	
+
+	pthread_cond_broadcast(&cvp->cv_cond);
 }

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 05:40:08 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 12083106568F;
	Tue,  5 Jan 2010 05:40:08 +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 00E1D8FC13;
	Tue,  5 Jan 2010 05:40:08 +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 o055e7Db001951;
	Tue, 5 Jan 2010 05:40:07 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o055e7nu001946;
	Tue, 5 Jan 2010 05:40:07 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001050540.o055e7nu001946@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Tue, 5 Jan 2010 05:40:07 +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: r201550 - 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: Tue, 05 Jan 2010 05:40:08 -0000

Author: kmacy
Date: Tue Jan  5 05:40:07 2010
New Revision: 201550
URL: http://svn.freebsd.org/changeset/base/201550

Log:
  eliminate need for taskqueue by removing kqueue support from the first cut of libunet

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

Modified: user/kmacy/releng_8_rump/lib/libunet/Makefile
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/Makefile	Tue Jan  5 05:37:49 2010	(r201549)
+++ user/kmacy/releng_8_rump/lib/libunet/Makefile	Tue Jan  5 05:40:07 2010	(r201550)
@@ -11,7 +11,6 @@ LIB=	unet
 
 UNET_KERN_COMMON_OBJS +=	\
 	kern_environment.o	\
-	kern_event.o		\
 	kern_mbuf.o		\
 	kern_module.o		\
 	kern_mtxpool.o		\
@@ -116,8 +115,9 @@ UNET_COMMON_SRCS= ${UNET_COMMON_OBJS:C/.
 
 SRCS=	${UNET_COMMON_SRCS}
 
-CFLAGS+=	-I${PREFIX}
+CFLAGS+=	-I./include
 CFLAGS+=	-I./include/opt
+CFLAGS+=	-I${PREFIX}
 CFLAGS+=	-D_KERNEL
 CFLAGS+=	-DUNET
 CFLAGS+=	-DMAXUSERS=32

Modified: user/kmacy/releng_8_rump/lib/libunet/unet_compat.c
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/unet_compat.c	Tue Jan  5 05:37:49 2010	(r201549)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_compat.c	Tue Jan  5 05:40:07 2010	(r201550)
@@ -5,6 +5,7 @@
 #include <sys/mman.h>
 #include <sys/refcount.h>
 #include <sys/ucred.h>
+#include <sys/time.h>
 
 struct malloc_type;
 
@@ -69,4 +70,30 @@ panic(const char *fmt, ...)
 	abort();
 }
 
+void
+bintime(struct bintime *bt)
+{
+	struct timeval tv;
+
+	gettimeofday(&tv, NULL);
+	timeval2bintime(&tv, bt);
+}
+	
+void
+getmicrouptime(struct timeval *tvp)
+{
+	struct timeval tv;
+
+	gettimeofday(&tv, NULL);
+}
+
+void
+getmicrotime(struct timeval *tvp)
+{
+	struct timeval tv;
+
+	gettimeofday(&tv, NULL);
+}
+
+
 

Modified: user/kmacy/releng_8_rump/lib/libunet/unet_glue.c
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/unet_glue.c	Tue Jan  5 05:37:49 2010	(r201549)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_glue.c	Tue Jan  5 05:40:07 2010	(r201550)
@@ -331,27 +331,6 @@ ppsratecheck(struct timeval *lasttime, i
 	}
 }
 
-void
-bintime(struct bintime *bt)
-{
-
-	panic("");
-}
-	
-void
-getmicrouptime(struct timeval *tvp)
-{
-
-	panic("");
-}
-
-void
-getmicrotime(struct timeval *tvp)
-{
-
-	panic("");
-}
-
 /*
  * Compute number of ticks in the specified amount of time.
  */
@@ -613,6 +592,7 @@ cpu_pcpu_init(struct pcpu *pcpu, int cpu
 	;	
 }
 
+
 /*
  * Send a SIGIO or SIGURG signal to a process or process group using stored
  * credentials rather than those of the current process.
@@ -622,14 +602,47 @@ pgsigio(sigiop, sig, checkctty)
 	struct sigio **sigiop;
 	int sig, checkctty;
 {
-
 	panic("");
+#ifdef notyet
+	ksiginfo_t ksi;
+	struct sigio *sigio;
+
+	ksiginfo_init(&ksi);
+	ksi.ksi_signo = sig;
+	ksi.ksi_code = SI_KERNEL;
+
+	SIGIO_LOCK();
+	sigio = *sigiop;
+	if (sigio == NULL) {
+		SIGIO_UNLOCK();
+		return;
+	}
+	if (sigio->sio_pgid > 0) {
+		PROC_LOCK(sigio->sio_proc);
+		if (CANSIGIO(sigio->sio_ucred, sigio->sio_proc->p_ucred))
+			psignal(sigio->sio_proc, sig);
+		PROC_UNLOCK(sigio->sio_proc);
+	} else if (sigio->sio_pgid < 0) {
+		struct proc *p;
+
+		PGRP_LOCK(sigio->sio_pgrp);
+		LIST_FOREACH(p, &sigio->sio_pgrp->pg_members, p_pglist) {
+			PROC_LOCK(p);
+			if (CANSIGIO(sigio->sio_ucred, p->p_ucred) &&
+			    (checkctty == 0 || (p->p_flag & P_CONTROLT)))
+				psignal(p, sig);
+			PROC_UNLOCK(p);
+		}
+		PGRP_UNLOCK(sigio->sio_pgrp);
+	}
+	SIGIO_UNLOCK();
+#endif
 }
 
 void
 kproc_exit(int ecode)
 {
-	panic("");
+	panic("kproc_exit unsupported");
 }
 
 vm_offset_t
@@ -719,3 +732,21 @@ malloc_uninit(void *data)
 	uma_zfree_arg(mt_zone, mtip, slab);
 #endif
 }
+
+void
+knote(struct knlist *list, long hint, int lockflags)
+{
+	
+}
+
+void
+knlist_destroy(struct knlist *knl)
+{
+	
+}
+
+void
+knlist_init_mtx(struct knlist *knl, struct mtx *lock)
+{
+	
+}

Modified: user/kmacy/releng_8_rump/lib/libunet/unet_subr_taskqueue.c
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/unet_subr_taskqueue.c	Tue Jan  5 05:37:49 2010	(r201549)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_subr_taskqueue.c	Tue Jan  5 05:40:07 2010	(r201550)
@@ -39,80 +39,20 @@ struct taskqueue {
 #define	TQ_FLAGS_PENDING	(1 << 2)
 
 
-struct taskqueue *
-taskqueue_create(const char *name, int mflags,
-				    taskqueue_enqueue_fn enqueue,
-    void *context)
-{
-
-	panic("");
-	return (NULL);
-	
-}
-
-int
-taskqueue_start_threads(struct taskqueue **tqp, int count, int pri,
-    const char *name, ...)
-{
-
-
-	panic("");
-	return (0);
-}
-
-
-void
-taskqueue_run(struct taskqueue *queue)
-{
-
-	panic("");
-}
-
+struct taskqueue *taskqueue_swi;
 
 int
 taskqueue_enqueue(struct taskqueue *queue, struct task *task)
 {
 
-	panic("");
+	panic("should be unreachable");
 	return (0);
 }
 
-
 void
 taskqueue_drain(struct taskqueue *queue, struct task *task)
 {
 	
-	panic("");
+	panic("should be unreachable");
 }
 
-void
-taskqueue_free(struct taskqueue *queue)
-{
-
-	panic("");	
-}
-
-void
-taskqueue_thread_enqueue(void *context)
-{
-	panic("");
-	
-}
-
-static void
-taskqueue_swi_enqueue(void *context)
-{
-	swi_sched(taskqueue_ih, 0);
-}
-
-static void
-taskqueue_swi_run(void *dummy)
-{
-	taskqueue_run(taskqueue_swi);
-}
-
-TASKQUEUE_DEFINE(swi, taskqueue_swi_enqueue, NULL,
-		 swi_add(NULL, "task queue", taskqueue_swi_run, NULL, SWI_TQ,
-		     INTR_MPSAFE, &taskqueue_ih)); 
-
-

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 05:43:21 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 55393106566C;
	Tue,  5 Jan 2010 05:43:21 +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 2AFE88FC12;
	Tue,  5 Jan 2010 05:43:21 +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 o055hLHK002674;
	Tue, 5 Jan 2010 05:43:21 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o055hLXP002672;
	Tue, 5 Jan 2010 05:43:21 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001050543.o055hLXP002672@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Tue, 5 Jan 2010 05:43:21 +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: r201551 - user/kmacy/releng_8_rump/sys/kern
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: Tue, 05 Jan 2010 05:43:21 -0000

Author: kmacy
Date: Tue Jan  5 05:43:20 2010
New Revision: 201551
URL: http://svn.freebsd.org/changeset/base/201551

Log:
  simplify first cut by hiding references to kqueue

Modified:
  user/kmacy/releng_8_rump/sys/kern/uipc_socket.c

Modified: user/kmacy/releng_8_rump/sys/kern/uipc_socket.c
==============================================================================
--- user/kmacy/releng_8_rump/sys/kern/uipc_socket.c	Tue Jan  5 05:40:07 2010	(r201550)
+++ user/kmacy/releng_8_rump/sys/kern/uipc_socket.c	Tue Jan  5 05:43:20 2010	(r201551)
@@ -145,6 +145,7 @@ __FBSDID("$FreeBSD$");
 static int	soreceive_rcvoob(struct socket *so, struct uio *uio,
 		    int flags);
 
+#ifndef UNET
 static void	filt_sordetach(struct knote *kn);
 static int	filt_soread(struct knote *kn, long hint);
 static void	filt_sowdetach(struct knote *kn);
@@ -157,7 +158,7 @@ static struct filterops soread_filtops =
 	{ 1, NULL, filt_sordetach, filt_soread };
 static struct filterops sowrite_filtops =
 	{ 1, NULL, filt_sowdetach, filt_sowrite };
-
+#endif
 uma_zone_t socket_zone;
 so_gen_t	so_gencnt;	/* generation count for sockets */
 
@@ -2920,9 +2921,11 @@ sopoll_generic(struct socket *so, int ev
 	return (revents);
 }
 
+
 int
 soo_kqfilter(struct file *fp, struct knote *kn)
 {
+#ifndef UNET
 	struct socket *so = kn->kn_fp->f_data;
 	struct sockbuf *sb;
 
@@ -2946,9 +2949,13 @@ soo_kqfilter(struct file *fp, struct kno
 	knlist_add(&sb->sb_sel.si_note, kn, 1);
 	sb->sb_flags |= SB_KNOTE;
 	SOCKBUF_UNLOCK(sb);
+#else
+	panic("soo_kqfilter not supported");
+#endif
 	return (0);
 }
 
+
 /*
  * Some routines that return EOPNOTSUPP for entry points that are not
  * supported by a protocol.  Fill in as needed.
@@ -3089,6 +3096,7 @@ pru_sopoll_notsupp(struct socket *so, in
 	return EOPNOTSUPP;
 }
 
+#ifndef UNET
 static void
 filt_sordetach(struct knote *kn)
 {
@@ -3168,7 +3176,7 @@ filt_solisten(struct knote *kn, long hin
 	kn->kn_data = so->so_qlen;
 	return (! TAILQ_EMPTY(&so->so_comp));
 }
-
+#endif
 int
 socheckuid(struct socket *so, uid_t uid)
 {

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 05:43:53 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 AD1A91065694;
	Tue,  5 Jan 2010 05:43:53 +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 9C8CC8FC18;
	Tue,  5 Jan 2010 05:43:53 +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 o055hr2E002838;
	Tue, 5 Jan 2010 05:43:53 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o055hroj002836;
	Tue, 5 Jan 2010 05:43:53 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001050543.o055hroj002836@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Tue, 5 Jan 2010 05:43:53 +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: r201552 - user/kmacy/releng_8_rump/sys/sys
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: Tue, 05 Jan 2010 05:43:53 -0000

Author: kmacy
Date: Tue Jan  5 05:43:53 2010
New Revision: 201552
URL: http://svn.freebsd.org/changeset/base/201552

Log:
  map log -> syslog for UNET

Modified:
  user/kmacy/releng_8_rump/sys/sys/systm.h

Modified: user/kmacy/releng_8_rump/sys/sys/systm.h
==============================================================================
--- user/kmacy/releng_8_rump/sys/sys/systm.h	Tue Jan  5 05:43:20 2010	(r201551)
+++ user/kmacy/releng_8_rump/sys/sys/systm.h	Tue Jan  5 05:43:53 2010	(r201552)
@@ -156,6 +156,10 @@ void	panic(const char *, ...) __printfli
 void	panic(const char *, ...) __dead2 __printflike(1, 2);
 #endif
 
+#ifdef UNET
+#define log syslog
+#endif
+
 void	cpu_boot(int);
 void	cpu_flush_dcache(void *, size_t);
 void	cpu_rootconf(void);

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 05:45:52 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 0748D106566B;
	Tue,  5 Jan 2010 05:45:52 +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 EB19C8FC15;
	Tue,  5 Jan 2010 05:45:51 +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 o055jpLa003360;
	Tue, 5 Jan 2010 05:45:51 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o055jprg003358;
	Tue, 5 Jan 2010 05:45:51 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001050545.o055jprg003358@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Tue, 5 Jan 2010 05:45:51 +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: r201554 - user/kmacy/releng_8_rump/sys/sys
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: Tue, 05 Jan 2010 05:45:52 -0000

Author: kmacy
Date: Tue Jan  5 05:45:51 2010
New Revision: 201554
URL: http://svn.freebsd.org/changeset/base/201554

Log:
  prefix malloc and free with unet_ if UNET is defined

Modified:
  user/kmacy/releng_8_rump/sys/sys/malloc.h

Modified: user/kmacy/releng_8_rump/sys/sys/malloc.h
==============================================================================
--- user/kmacy/releng_8_rump/sys/sys/malloc.h	Tue Jan  5 05:44:52 2010	(r201553)
+++ user/kmacy/releng_8_rump/sys/sys/malloc.h	Tue Jan  5 05:45:51 2010	(r201554)
@@ -39,6 +39,11 @@
 #include <sys/queue.h>
 #include <sys/_lock.h>
 #include <sys/_mutex.h>
+#ifdef UNET
+#define	malloc	unet_malloc
+#define	free	unet_free
+#endif
+
 
 #define	MINALLOCSIZE	UMA_SMALLEST_UNIT
 

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 05:50:53 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 C5D651065693;
	Tue,  5 Jan 2010 05:50:53 +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 B36E08FC13;
	Tue,  5 Jan 2010 05:50:53 +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 o055orfT004527;
	Tue, 5 Jan 2010 05:50:53 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o055orYn004524;
	Tue, 5 Jan 2010 05:50:53 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001050550.o055orYn004524@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Tue, 5 Jan 2010 05:50:53 +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: r201556 - in user/kmacy/releng_8_rump/lib/libunet: .
	include/vm
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: Tue, 05 Jan 2010 05:50:53 -0000

Author: kmacy
Date: Tue Jan  5 05:50:53 2010
New Revision: 201556
URL: http://svn.freebsd.org/changeset/base/201556

Log:
  import uma_int.h to facilitate adapting uma to user-land

Added:
  user/kmacy/releng_8_rump/lib/libunet/include/vm/
  user/kmacy/releng_8_rump/lib/libunet/include/vm/uma_int.h   (contents, props changed)
Modified:
  user/kmacy/releng_8_rump/lib/libunet/unet_uma_core.c

Added: user/kmacy/releng_8_rump/lib/libunet/include/vm/uma_int.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/kmacy/releng_8_rump/lib/libunet/include/vm/uma_int.h	Tue Jan  5 05:50:53 2010	(r201556)
@@ -0,0 +1,425 @@
+/*-
+ * Copyright (c) 2002-2005, 2009 Jeffrey Roberson <jeff@FreeBSD.org>
+ * Copyright (c) 2004, 2005 Bosko Milekic <bmilekic@FreeBSD.org>
+ * 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 unmodified, 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 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.
+ *
+ * $FreeBSD$
+ *
+ */
+
+/* 
+ * This file includes definitions, structures, prototypes, and inlines that
+ * should not be used outside of the actual implementation of UMA.
+ */
+
+/* 
+ * Here's a quick description of the relationship between the objects:
+ *
+ * Kegs contain lists of slabs which are stored in either the full bin, empty
+ * bin, or partially allocated bin, to reduce fragmentation.  They also contain
+ * the user supplied value for size, which is adjusted for alignment purposes
+ * and rsize is the result of that.  The Keg also stores information for
+ * managing a hash of page addresses that maps pages to uma_slab_t structures
+ * for pages that don't have embedded uma_slab_t's.
+ *  
+ * The uma_slab_t may be embedded in a UMA_SLAB_SIZE chunk of memory or it may
+ * be allocated off the page from a special slab zone.  The free list within a
+ * slab is managed with a linked list of indexes, which are 8 bit values.  If
+ * UMA_SLAB_SIZE is defined to be too large I will have to switch to 16bit
+ * values.  Currently on alpha you can get 250 or so 32 byte items and on x86
+ * you can get 250 or so 16byte items.  For item sizes that would yield more
+ * than 10% memory waste we potentially allocate a separate uma_slab_t if this
+ * will improve the number of items per slab that will fit.  
+ *
+ * Other potential space optimizations are storing the 8bit of linkage in space
+ * wasted between items due to alignment problems.  This may yield a much better
+ * memory footprint for certain sizes of objects.  Another alternative is to
+ * increase the UMA_SLAB_SIZE, or allow for dynamic slab sizes.  I prefer
+ * dynamic slab sizes because we could stick with 8 bit indexes and only use
+ * large slab sizes for zones with a lot of waste per slab.  This may create
+ * ineffeciencies in the vm subsystem due to fragmentation in the address space.
+ *
+ * The only really gross cases, with regards to memory waste, are for those
+ * items that are just over half the page size.   You can get nearly 50% waste,
+ * so you fall back to the memory footprint of the power of two allocator. I
+ * have looked at memory allocation sizes on many of the machines available to
+ * me, and there does not seem to be an abundance of allocations at this range
+ * so at this time it may not make sense to optimize for it.  This can, of 
+ * course, be solved with dynamic slab sizes.
+ *
+ * Kegs may serve multiple Zones but by far most of the time they only serve
+ * one.  When a Zone is created, a Keg is allocated and setup for it.  While
+ * the backing Keg stores slabs, the Zone caches Buckets of items allocated
+ * from the slabs.  Each Zone is equipped with an init/fini and ctor/dtor
+ * pair, as well as with its own set of small per-CPU caches, layered above
+ * the Zone's general Bucket cache.
+ *
+ * The PCPU caches are protected by critical sections, and may be accessed
+ * safely only from their associated CPU, while the Zones backed by the same
+ * Keg all share a common Keg lock (to coalesce contention on the backing
+ * slabs).  The backing Keg typically only serves one Zone but in the case of
+ * multiple Zones, one of the Zones is considered the Master Zone and all
+ * Zone-related stats from the Keg are done in the Master Zone.  For an
+ * example of a Multi-Zone setup, refer to the Mbuf allocation code.
+ */
+
+/*
+ *	This is the representation for normal (Non OFFPAGE slab)
+ *
+ *	i == item
+ *	s == slab pointer
+ *
+ *	<----------------  Page (UMA_SLAB_SIZE) ------------------>
+ *	___________________________________________________________
+ *     | _  _  _  _  _  _  _  _  _  _  _  _  _  _  _   ___________ |
+ *     ||i||i||i||i||i||i||i||i||i||i||i||i||i||i||i| |slab header||
+ *     ||_||_||_||_||_||_||_||_||_||_||_||_||_||_||_| |___________|| 
+ *     |___________________________________________________________|
+ *
+ *
+ *	This is an OFFPAGE slab. These can be larger than UMA_SLAB_SIZE.
+ *
+ *	___________________________________________________________
+ *     | _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _   |
+ *     ||i||i||i||i||i||i||i||i||i||i||i||i||i||i||i||i||i||i||i|  |
+ *     ||_||_||_||_||_||_||_||_||_||_||_||_||_||_||_||_||_||_||_|  |
+ *     |___________________________________________________________|
+ *       ___________    ^
+ *	|slab header|   |
+ *	|___________|---*
+ *
+ */
+
+#ifndef VM_UMA_INT_H
+#define VM_UMA_INT_H
+
+#define UMA_SLAB_SIZE	PAGE_SIZE	/* How big are our slabs? */
+#define UMA_SLAB_MASK	(PAGE_SIZE - 1)	/* Mask to get back to the page */
+#define UMA_SLAB_SHIFT	PAGE_SHIFT	/* Number of bits PAGE_MASK */
+
+#define UMA_BOOT_PAGES		48	/* Pages allocated for startup */
+
+/* Max waste before going to off page slab management */
+#define UMA_MAX_WASTE	(UMA_SLAB_SIZE / 10)
+
+/*
+ * I doubt there will be many cases where this is exceeded. This is the initial
+ * size of the hash table for uma_slabs that are managed off page. This hash
+ * does expand by powers of two.  Currently it doesn't get smaller.
+ */
+#define UMA_HASH_SIZE_INIT	32		
+
+/* 
+ * I should investigate other hashing algorithms.  This should yield a low
+ * number of collisions if the pages are relatively contiguous.
+ *
+ * This is the same algorithm that most processor caches use.
+ *
+ * I'm shifting and masking instead of % because it should be faster.
+ */
+
+#define UMA_HASH(h, s) ((((unsigned long)s) >> UMA_SLAB_SHIFT) &	\
+    (h)->uh_hashmask)
+
+#define UMA_HASH_INSERT(h, s, mem)					\
+		SLIST_INSERT_HEAD(&(h)->uh_slab_hash[UMA_HASH((h),	\
+		    (mem))], (s), us_hlink);
+#define UMA_HASH_REMOVE(h, s, mem)					\
+		SLIST_REMOVE(&(h)->uh_slab_hash[UMA_HASH((h),		\
+		    (mem))], (s), uma_slab, us_hlink);
+
+/* Hash table for freed address -> slab translation */
+
+SLIST_HEAD(slabhead, uma_slab);
+
+struct uma_hash {
+	struct slabhead	*uh_slab_hash;	/* Hash table for slabs */
+	int		uh_hashsize;	/* Current size of the hash table */
+	int		uh_hashmask;	/* Mask used during hashing */
+};
+
+/*
+ * Structures for per cpu queues.
+ */
+
+struct uma_bucket {
+	LIST_ENTRY(uma_bucket)	ub_link;	/* Link into the zone */
+	int16_t	ub_cnt;				/* Count of free items. */
+	int16_t	ub_entries;			/* Max items. */
+	void	*ub_bucket[];			/* actual allocation storage */
+};
+
+typedef struct uma_bucket * uma_bucket_t;
+
+struct uma_cache {
+	uma_bucket_t	uc_freebucket;	/* Bucket we're freeing to */
+	uma_bucket_t	uc_allocbucket;	/* Bucket to allocate from */
+	u_int64_t	uc_allocs;	/* Count of allocations */
+	u_int64_t	uc_frees;	/* Count of frees */
+};
+
+typedef struct uma_cache * uma_cache_t;
+
+/*
+ * Keg management structure
+ *
+ * TODO: Optimize for cache line size
+ *
+ */
+struct uma_keg {
+	LIST_ENTRY(uma_keg)	uk_link;	/* List of all kegs */
+
+	struct mtx	uk_lock;	/* Lock for the keg */
+	struct uma_hash	uk_hash;
+
+	char		*uk_name;		/* Name of creating zone. */
+	LIST_HEAD(,uma_zone)	uk_zones;	/* Keg's zones */
+	LIST_HEAD(,uma_slab)	uk_part_slab;	/* partially allocated slabs */
+	LIST_HEAD(,uma_slab)	uk_free_slab;	/* empty slab list */
+	LIST_HEAD(,uma_slab)	uk_full_slab;	/* full slabs */
+
+	u_int32_t	uk_recurse;	/* Allocation recursion count */
+	u_int32_t	uk_align;	/* Alignment mask */
+	u_int32_t	uk_pages;	/* Total page count */
+	u_int32_t	uk_free;	/* Count of items free in slabs */
+	u_int32_t	uk_size;	/* Requested size of each item */
+	u_int32_t	uk_rsize;	/* Real size of each item */
+	u_int32_t	uk_maxpages;	/* Maximum number of pages to alloc */
+
+	uma_init	uk_init;	/* Keg's init routine */
+	uma_fini	uk_fini;	/* Keg's fini routine */
+	uma_alloc	uk_allocf;	/* Allocation function */
+	uma_free	uk_freef;	/* Free routine */
+
+	struct vm_object	*uk_obj;	/* Zone specific object */
+	vm_offset_t	uk_kva;		/* Base kva for zones with objs */
+	uma_zone_t	uk_slabzone;	/* Slab zone backing us, if OFFPAGE */
+
+	u_int16_t	uk_pgoff;	/* Offset to uma_slab struct */
+	u_int16_t	uk_ppera;	/* pages per allocation from backend */
+	u_int16_t	uk_ipers;	/* Items per slab */
+	u_int32_t	uk_flags;	/* Internal flags */
+};
+typedef struct uma_keg	* uma_keg_t;
+
+/* Page management structure */
+
+/* Sorry for the union, but space efficiency is important */
+struct uma_slab_head {
+	uma_keg_t	us_keg;			/* Keg we live in */
+	union {
+		LIST_ENTRY(uma_slab)	_us_link;	/* slabs in zone */
+		unsigned long	_us_size;	/* Size of allocation */
+	} us_type;
+	SLIST_ENTRY(uma_slab)	us_hlink;	/* Link for hash table */
+	u_int8_t	*us_data;		/* First item */
+	u_int8_t	us_flags;		/* Page flags see uma.h */
+	u_int8_t	us_freecount;	/* How many are free? */
+	u_int8_t	us_firstfree;	/* First free item index */
+};
+
+/* The standard slab structure */
+struct uma_slab {
+	struct uma_slab_head	us_head;	/* slab header data */
+	struct {
+		u_int8_t	us_item;
+	} us_freelist[1];			/* actual number bigger */
+};
+
+/*
+ * The slab structure for UMA_ZONE_REFCNT zones for whose items we
+ * maintain reference counters in the slab for.
+ */
+struct uma_slab_refcnt {
+	struct uma_slab_head	us_head;	/* slab header data */
+	struct {
+		u_int8_t	us_item;
+		u_int32_t	us_refcnt;
+	} us_freelist[1];			/* actual number bigger */
+};
+
+#define	us_keg		us_head.us_keg
+#define	us_link		us_head.us_type._us_link
+#define	us_size		us_head.us_type._us_size
+#define	us_hlink	us_head.us_hlink
+#define	us_data		us_head.us_data
+#define	us_flags	us_head.us_flags
+#define	us_freecount	us_head.us_freecount
+#define	us_firstfree	us_head.us_firstfree
+
+typedef struct uma_slab * uma_slab_t;
+typedef struct uma_slab_refcnt * uma_slabrefcnt_t;
+typedef uma_slab_t (*uma_slaballoc)(uma_zone_t, uma_keg_t, int);
+
+
+/*
+ * These give us the size of one free item reference within our corresponding
+ * uma_slab structures, so that our calculations during zone setup are correct
+ * regardless of what the compiler decides to do with padding the structure
+ * arrays within uma_slab.
+ */
+#define	UMA_FRITM_SZ	(sizeof(struct uma_slab) - sizeof(struct uma_slab_head))
+#define	UMA_FRITMREF_SZ	(sizeof(struct uma_slab_refcnt) -	\
+    sizeof(struct uma_slab_head))
+
+struct uma_klink {
+	LIST_ENTRY(uma_klink)	kl_link;
+	uma_keg_t		kl_keg;
+};
+typedef struct uma_klink *uma_klink_t;
+
+/*
+ * Zone management structure 
+ *
+ * TODO: Optimize for cache line size
+ *
+ */
+struct uma_zone {
+	char		*uz_name;	/* Text name of the zone */
+	struct mtx	*uz_lock;	/* Lock for the zone (keg's lock) */
+
+	LIST_ENTRY(uma_zone)	uz_link;	/* List of all zones in keg */
+	LIST_HEAD(,uma_bucket)	uz_full_bucket;	/* full buckets */
+	LIST_HEAD(,uma_bucket)	uz_free_bucket;	/* Buckets for frees */
+
+	LIST_HEAD(,uma_klink)	uz_kegs;	/* List of kegs. */
+	struct uma_klink	uz_klink;	/* klink for first keg. */
+
+	uma_slaballoc	uz_slab;	/* Allocate a slab from the backend. */
+	uma_ctor	uz_ctor;	/* Constructor for each allocation */
+	uma_dtor	uz_dtor;	/* Destructor */
+	uma_init	uz_init;	/* Initializer for each item */
+	uma_fini	uz_fini;	/* Discards memory */
+
+	u_int64_t	uz_allocs;	/* Total number of allocations */
+	u_int64_t	uz_frees;	/* Total number of frees */
+	u_int64_t	uz_fails;	/* Total number of alloc failures */
+	u_int32_t	uz_flags;	/* Flags inherited from kegs */
+	u_int32_t	uz_size;	/* Size inherited from kegs */
+	uint16_t	uz_fills;	/* Outstanding bucket fills */
+	uint16_t	uz_count;	/* Highest value ub_ptr can have */
+
+	/*
+	 * This HAS to be the last item because we adjust the zone size
+	 * based on NCPU and then allocate the space for the zones.
+	 */
+	struct uma_cache	uz_cpu[1];	/* Per cpu caches */
+};
+
+/*
+ * These flags must not overlap with the UMA_ZONE flags specified in uma.h.
+ */
+#define	UMA_ZFLAG_BUCKET	0x02000000	/* Bucket zone. */
+#define	UMA_ZFLAG_MULTI		0x04000000	/* Multiple kegs in the zone. */
+#define	UMA_ZFLAG_DRAINING	0x08000000	/* Running zone_drain. */
+#define UMA_ZFLAG_PRIVALLOC	0x10000000	/* Use uz_allocf. */
+#define UMA_ZFLAG_INTERNAL	0x20000000	/* No offpage no PCPU. */
+#define UMA_ZFLAG_FULL		0x40000000	/* Reached uz_maxpages */
+#define UMA_ZFLAG_CACHEONLY	0x80000000	/* Don't ask VM for buckets. */
+
+#define	UMA_ZFLAG_INHERIT	(UMA_ZFLAG_INTERNAL | UMA_ZFLAG_CACHEONLY | \
+				    UMA_ZFLAG_BUCKET)
+
+#ifdef _KERNEL
+/* Internal prototypes */
+static __inline uma_slab_t hash_sfind(struct uma_hash *hash, u_int8_t *data);
+void *uma_large_malloc(int size, int wait);
+void uma_large_free(uma_slab_t slab);
+
+/* Lock Macros */
+
+#define	KEG_LOCK_INIT(k, lc)					\
+	do {							\
+		if ((lc))					\
+			mtx_init(&(k)->uk_lock, (k)->uk_name,	\
+			    (k)->uk_name, MTX_DEF | MTX_DUPOK);	\
+		else						\
+			mtx_init(&(k)->uk_lock, (k)->uk_name,	\
+			    "UMA zone", MTX_DEF | MTX_DUPOK);	\
+	} while (0)
+	    
+#define	KEG_LOCK_FINI(k)	mtx_destroy(&(k)->uk_lock)
+#define	KEG_LOCK(k)	mtx_lock(&(k)->uk_lock)
+#define	KEG_UNLOCK(k)	mtx_unlock(&(k)->uk_lock)
+#define	ZONE_LOCK(z)	mtx_lock((z)->uz_lock)
+#define ZONE_UNLOCK(z)	mtx_unlock((z)->uz_lock)
+
+/*
+ * Find a slab within a hash table.  This is used for OFFPAGE zones to lookup
+ * the slab structure.
+ *
+ * Arguments:
+ *	hash  The hash table to search.
+ *	data  The base page of the item.
+ *
+ * Returns:
+ *	A pointer to a slab if successful, else NULL.
+ */
+static __inline uma_slab_t
+hash_sfind(struct uma_hash *hash, u_int8_t *data)
+{
+        uma_slab_t slab;
+        int hval;
+
+        hval = UMA_HASH(hash, data);
+
+        SLIST_FOREACH(slab, &hash->uh_slab_hash[hval], us_hlink) {
+                if ((u_int8_t *)slab->us_data == data)
+                        return (slab);
+        }
+        return (NULL);
+}
+
+static __inline uma_slab_t
+vtoslab(vm_offset_t va)
+{
+	panic("");
+
+	return (NULL);
+}
+
+static __inline void
+vsetslab(vm_offset_t va, uma_slab_t slab)
+{
+
+	panic("");
+}
+
+static __inline void
+vsetobj(vm_offset_t va, vm_object_t obj)
+{
+
+	panic("");
+}
+
+/*
+ * The following two functions may be defined by architecture specific code
+ * if they can provide more effecient allocation functions.  This is useful
+ * for using direct mapped addresses.
+ */
+void *uma_small_alloc(uma_zone_t zone, int bytes, u_int8_t *pflag, int wait);
+void uma_small_free(void *mem, int size, u_int8_t flags);
+#endif /* _KERNEL */
+
+#endif /* VM_UMA_INT_H */

Modified: user/kmacy/releng_8_rump/lib/libunet/unet_uma_core.c
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/unet_uma_core.c	Tue Jan  5 05:47:18 2010	(r201555)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_uma_core.c	Tue Jan  5 05:50:53 2010	(r201556)
@@ -92,28 +92,6 @@ __FBSDID("$FreeBSD$");
 
 #undef UMA_MD_SMALL_ALLOC
 
-uma_slab_t
-vtoslab(vm_offset_t va)
-{
-
-	panic("");
-	return (NULL);
-}
-
-void
-vsetslab(vm_offset_t va, uma_slab_t slab)
-{
-
-	panic("");
-}
-
-
-void
-vsetobj(vm_offset_t va, vm_object_t obj)
-{
-
-	panic("");
-}
 /*
  * This is the zone and keg from which all zones are spawned.  The idea is that
  * even the zone & keg heads are allocated from the allocator, so we use the

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 06:03:17 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 EC56F10656C0;
	Tue,  5 Jan 2010 06:03:17 +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 DBD818FC0C;
	Tue,  5 Jan 2010 06:03:17 +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 o0563Ht7007301;
	Tue, 5 Jan 2010 06:03:17 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o0563HpI007299;
	Tue, 5 Jan 2010 06:03:17 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001050603.o0563HpI007299@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Tue, 5 Jan 2010 06:03:17 +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: r201557 - 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: Tue, 05 Jan 2010 06:03:18 -0000

Author: kmacy
Date: Tue Jan  5 06:03:17 2010
New Revision: 201557
URL: http://svn.freebsd.org/changeset/base/201557

Log:
  implement uio_yield

Modified:
  user/kmacy/releng_8_rump/lib/libunet/unet_kern_subr.c

Modified: user/kmacy/releng_8_rump/lib/libunet/unet_kern_subr.c
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/unet_kern_subr.c	Tue Jan  5 05:50:53 2010	(r201556)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_kern_subr.c	Tue Jan  5 06:03:17 2010	(r201557)
@@ -15,6 +15,7 @@
 #include <sys/sysctl.h>
 #include <sys/uio.h>
 
+#include <pthread.h>
 /*
  * General routine to allocate a hash table with control of memory flags.
  */
@@ -77,7 +78,7 @@ void
 uio_yield(void)
 {
 
-	panic("");
+	pthread_yield();
 }
 
 int

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 06:13:15 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 8C63F106566C;
	Tue,  5 Jan 2010 06:13:15 +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 7B9468FC12;
	Tue,  5 Jan 2010 06:13:15 +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 o056DFYN009609;
	Tue, 5 Jan 2010 06:13:15 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o056DFgT009606;
	Tue, 5 Jan 2010 06:13:15 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001050613.o056DFgT009606@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Tue, 5 Jan 2010 06:13:15 +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: r201558 - 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: Tue, 05 Jan 2010 06:13:15 -0000

Author: kmacy
Date: Tue Jan  5 06:13:15 2010
New Revision: 201558
URL: http://svn.freebsd.org/changeset/base/201558

Log:
  don't inline mutexes

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

Modified: user/kmacy/releng_8_rump/lib/libunet/Makefile
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/Makefile	Tue Jan  5 06:03:17 2010	(r201557)
+++ user/kmacy/releng_8_rump/lib/libunet/Makefile	Tue Jan  5 06:13:15 2010	(r201558)
@@ -119,6 +119,7 @@ CFLAGS+=	-I./include
 CFLAGS+=	-I./include/opt
 CFLAGS+=	-I${PREFIX}
 CFLAGS+=	-D_KERNEL
+CFLAGS+=	-DMUTEX_NOINLINE
 CFLAGS+=	-DUNET
 CFLAGS+=	-DMAXUSERS=32
 CFLAGS+=	-fno-builtin

Modified: user/kmacy/releng_8_rump/lib/libunet/unet_lock.c
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/unet_lock.c	Tue Jan  5 06:03:17 2010	(r201557)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_lock.c	Tue Jan  5 06:13:15 2010	(r201558)
@@ -44,15 +44,14 @@ mtx_sysinit(void *arg)
 }
 
 void
-_mtx_lock_sleep(struct mtx *m, uintptr_t tid, int opts,
-    const char *file, int line)
+_mtx_lock_flags(struct mtx *m, int opts, const char *file, int line)
 {
 
 	panic("");
 }
 
 void
-_mtx_unlock_sleep(struct mtx *m, int opts, const char *file, int line)
+_mtx_unlock_flags(struct mtx *m, int opts, const char *file, int line)
 {
 
 	panic("");

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 06:34:20 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 566201065692;
	Tue,  5 Jan 2010 06:34:20 +0000 (UTC)
	(envelope-from edwin@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 455D88FC12;
	Tue,  5 Jan 2010 06:34:20 +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 o056YKLN014255;
	Tue, 5 Jan 2010 06:34:20 GMT (envelope-from edwin@svn.freebsd.org)
Received: (from edwin@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o056YK1a014253;
	Tue, 5 Jan 2010 06:34:20 GMT (envelope-from edwin@svn.freebsd.org)
Message-Id: <201001050634.o056YK1a014253@svn.freebsd.org>
From: Edwin Groothuis <edwin@FreeBSD.org>
Date: Tue, 5 Jan 2010 06:34:20 +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: r201560 - user/edwin/calendar
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: Tue, 05 Jan 2010 06:34:20 -0000

Author: edwin
Date: Tue Jan  5 06:34:20 2010
New Revision: 201560
URL: http://svn.freebsd.org/changeset/base/201560

Log:
  Add support for Easter and Paskha back in.
  Remove lots of old code, #ifdeffed out for a long time already.

Modified:
  user/edwin/calendar/parsedata.c

Modified: user/edwin/calendar/parsedata.c
==============================================================================
--- user/edwin/calendar/parsedata.c	Tue Jan  5 06:21:29 2010	(r201559)
+++ user/edwin/calendar/parsedata.c	Tue Jan  5 06:34:20 2010	(r201560)
@@ -42,6 +42,7 @@ static char *getdayofweekname(int i);
 static int checkdayofweek(char *s, int *len, int *offset, char **dow);
 static int isonlydigits(char *s, int nostar);
 static int indextooffset(char *s);
+static int parseoffset(char *s);
 
 /*
  * Expected styles:
@@ -320,6 +321,7 @@ parsedaymonth(char *date, int *yearp, in
 	char month[100], dayofmonth[100], dayofweek[100], modifieroffset[100];
 	char modifierindex[100], specialday[100];
 	int idayofweek, imonth, idayofmonth, year, index;
+	int ieaster, ipaskha;
 
 	int *mondays, d, m, dow, rm, rd, offset;
 
@@ -355,6 +357,7 @@ parsedaymonth(char *date, int *yearp, in
 	index = 0;
 	for (year = year1; year <= year2; year++) {
 		mondays = mondaytab[isleap(year)];
+		ieaster = easter(year);
 
 		/* Same day every year */
 		if (*flags == (F_MONTH | F_DAYOFMONTH)) {
@@ -459,6 +462,30 @@ parsedaymonth(char *date, int *yearp, in
 			continue;
 		}
 
+		/* Easter */
+		if ((*flags & ~F_MODIFIEROFFSET) ==
+		    (F_SPECIALDAY | F_VARIABLE | F_EASTER)) {
+			offset = 0;
+			if ((*flags & F_MODIFIEROFFSET) != 0)
+				offset = parseoffset(modifieroffset);
+			if (remember_yd(year, ieaster + offset, &rm, &rd))
+				remember(index++, yearp, monthp, dayp,
+				    year, rm, rd);
+			continue;
+		}
+
+		/* Paskha */
+		if ((*flags & ~F_MODIFIEROFFSET) ==
+		    (F_SPECIALDAY | F_VARIABLE | F_PASKHA)) {
+			offset = 0;
+			if ((*flags & F_MODIFIEROFFSET) != 0)
+				offset = parseoffset(modifieroffset);
+			if (remember_yd(year, ipaskha + offset, &rm, &rd))
+				remember(index++, yearp, monthp, dayp,
+				    year, rm, rd);
+			continue;
+		}
+
 		printf("Unprocessed:\n");
 		debug_determinestyle(2, date, *flags, month, imonth,
 		    dayofmonth, idayofmonth, dayofweek, idayofweek,
@@ -467,175 +494,6 @@ parsedaymonth(char *date, int *yearp, in
 	}
 
 	return (index);
-
-#ifdef NOTDEF
-	if (!(v1 = getfield(date, &flags)))
-		return (0);
-
-	/* Easter or Easter depending days */
-	if (flags & F_EASTER)
-		day = v1 - 1; /* days since January 1 [0-365] */
-
-	 /*
-	  * 1. {Weekday,Day} XYZ ...
-	  *
-	  *    where Day is > 12
-	  */
-	else if (flags & F_ISDAY || v1 > 12) {
-
-		/* found a day; day: 1-31 or weekday: 1-7 */
-		day = v1;
-
-		/* {Day,Weekday} {Month,Monthname} ... */
-		/* if no recognizable month, assume just a day alone
-		 * in other words, find month or use current month */
-		if (!(month = getfield(endp, &flags)))
-			month = tp->tm_mon + 1;
-	}
-
-	/* 2. {Monthname} XYZ ... */
-	else if (flags & F_ISMONTH) {
-		month = v1;
-
-		/* Monthname {day,weekday} */
-		/* if no recognizable day, assume the first day in month */
-		if (!(day = getfield(endp, &flags)))
-			day = 1;
-	}
-
-	/* Hm ... */
-	else {
-		v2 = getfield(endp, &flags);
-
-		/*
-		 * {Day} {Monthname} ...
-		 * where Day <= 12
-		 */
-		if (flags & F_ISMONTH) {
-			day = v1;
-			month = v2;
-			*varp = 0;
-		}
-
-		/* {Month} {Weekday,Day} ...  */
-		else {
-			/* F_ISDAY set, v2 > 12, or no way to tell */
-			month = v1;
-			/* if no recognizable day, assume the first */
-			day = v2 ? v2 : 1;
-			*varp = 0;
-		}
-	}
-
-	/* convert Weekday into *next*  Day,
-	 * e.g.: 'Sunday' -> 22
-	 *       'SundayLast' -> ??
-	 */
-	if (flags & F_ISDAY) {
-#ifdef DEBUG
-		fprintf(stderr, "\nday: %d %s month %d\n", day, endp, month);
-#endif
-
-		*varp = 1;
-		/* variable weekday, SundayLast, MondayFirst ... */
-		if (day < 0 || day >= 10) {
-
-			/* negative offset; last, -4 .. -1 */
-			if (day < 0) {
-				v1 = day / 10 - 1;	/* offset -4 ... -1 */
-				day = 10 + (day % 10);	/* day 1 ... 7 */
-
-				/* day, eg '22nd' */
-				v2 = tp->tm_mday +
-				    (((day - 1) - tp->tm_wday + 7) % 7);
-
-				/* (month length - day)	/ 7 + 1 */
-				if (cumdays[month + 1] - cumdays[month] >= v2
-				    && ((int)((cumdays[month + 1] -
-				    cumdays[month] - v2) / 7) + 1) == -v1)
-					day = v2;	/* bingo ! */
-
-				/* set to yesterday */
-				else {
-					day = tp->tm_mday - 1;
-					if (day == 0)
-						return (0);
-				}
-			}
-
-			/* first, second ... +1 ... +5 */
-			else {
-				/* offset: +1 (first Sunday) ... */
-				v1 = day / 10;
-				day = day % 10;
-
-				/* day, eg '22th' */
-				v2 = tp->tm_mday +
-				    (((day - 1) - tp->tm_wday + 7) % 7);
-
-				/* Hurrah! matched */
-				if (((v2 - 1 + 7) / 7) == v1 )
-					day = v2;
-
-				else {
-					/* set to yesterday */
-					day = tp->tm_mday - 1;
-					if (day == 0)
-						return (0);
-				}
-			}
-		} else {
-			/* wired */
-			day = tp->tm_mday + (((day - 1) - tp->tm_wday + 7) % 7);
-			*varp = 1;
-		}
-	}
-
-	if (!(flags & F_EASTER)) {
-		if (day + cumdays[month] > cumdays[month + 1]) {
-			/* off end of month, adjust */
-			day -= (cumdays[month + 1] - cumdays[month]);
-			/* next year */
-			if (++month > 12)
-				month = 1;
-		}
-		*monthp = month;
-		*dayp = day;
-		day = cumdays[month] + day;
-	} else {
-		for (v1 = 0; day > cumdays[v1]; v1++)
-			;
-		*monthp = v1 - 1;
-		*dayp = day - cumdays[v1 - 1];
-		*varp = 1;
-	}
-
-#ifdef DEBUG
-	fprintf(stderr, "day2: day %d(%d-%d) yday %d\n",
-	    *dayp, day, cumdays[month], tp->tm_yday);
-#endif
-
-	/* When days before or days after is specified */
-	/* no year rollover */
-	if (day >= tp->tm_yday - f_dayBefore &&
-	    day <= tp->tm_yday + f_dayAfter)
-		return (1);
-
-	/* next year */
-	if (tp->tm_yday + f_dayAfter >= yrdays) {
-		int end = tp->tm_yday + f_dayAfter - yrdays;
-		if (day <= end)
-			return (1);
-	}
-
-	/* previous year */
-	if (tp->tm_yday - f_dayBefore < 0) {
-		int before = yrdays + (tp->tm_yday - f_dayBefore);
-		if (day >= before)
-			return (1);
-	}
-#endif
-	return (0);
 }
 
 static char *
@@ -804,3 +662,10 @@ indextooffset(char *s)
 		return (-1);
 	return (0);
 }
+
+static int
+parseoffset(char *s)
+{
+
+	return strtol(s, NULL, 10);
+}

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 06:43:29 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 9063E106566C;
	Tue,  5 Jan 2010 06:43:29 +0000 (UTC)
	(envelope-from edwin@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 805218FC0C;
	Tue,  5 Jan 2010 06:43:29 +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 o056hTG6016336;
	Tue, 5 Jan 2010 06:43:29 GMT (envelope-from edwin@svn.freebsd.org)
Received: (from edwin@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o056hTvO016334;
	Tue, 5 Jan 2010 06:43:29 GMT (envelope-from edwin@svn.freebsd.org)
Message-Id: <201001050643.o056hTvO016334@svn.freebsd.org>
From: Edwin Groothuis <edwin@FreeBSD.org>
Date: Tue, 5 Jan 2010 06:43:29 +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: r201562 - user/edwin/calendar
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: Tue, 05 Jan 2010 06:43:29 -0000

Author: edwin
Date: Tue Jan  5 06:43:29 2010
New Revision: 201562
URL: http://svn.freebsd.org/changeset/base/201562

Log:
  Be able to redefine the string of the CNY.

Modified:
  user/edwin/calendar/io.c

Modified: user/edwin/calendar/io.c
==============================================================================
--- user/edwin/calendar/io.c	Tue Jan  5 06:40:27 2010	(r201561)
+++ user/edwin/calendar/io.c	Tue Jan  5 06:43:29 2010	(r201562)
@@ -144,6 +144,14 @@ cal(void)
 			npaskha.len = strlen(buf + 7);
 			continue;
 		}
+		if (strncasecmp(buf, "ChineseNewYear=", 15) == 0 && buf[15]) {
+			if (ncny.name != NULL)
+				free(ncny.name);
+			if ((ncny.name = strdup(buf + 15)) == NULL)
+				errx(1, "cannot allocate memory");
+			ncny.len = strlen(buf + 15);
+			continue;
+		}
 
 		/*
 		 * If the line starts with a tab, the data has to be

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 07:36:02 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 841DE1065679;
	Tue,  5 Jan 2010 07:36:02 +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 724C28FC16;
	Tue,  5 Jan 2010 07:36:02 +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 o057a2YZ027941;
	Tue, 5 Jan 2010 07:36:02 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o057a2w6027935;
	Tue, 5 Jan 2010 07:36:02 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001050736.o057a2w6027935@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Tue, 5 Jan 2010 07:36:02 +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: r201564 - in user/kmacy/releng_8_rump/lib/libunet: .
	include/opt include/sys
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: Tue, 05 Jan 2010 07:36:02 -0000

Author: kmacy
Date: Tue Jan  5 07:36:02 2010
New Revision: 201564
URL: http://svn.freebsd.org/changeset/base/201564

Log:
  shim mutexes, rwlocks, and rmlocks

Added:
  user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_mprof.h   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/include/sys/_rwlock.h   (contents, props changed)
Modified:
  user/kmacy/releng_8_rump/lib/libunet/Makefile
  user/kmacy/releng_8_rump/lib/libunet/unet_glue.c
  user/kmacy/releng_8_rump/lib/libunet/unet_lock.c

Modified: user/kmacy/releng_8_rump/lib/libunet/Makefile
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/Makefile	Tue Jan  5 06:58:54 2010	(r201563)
+++ user/kmacy/releng_8_rump/lib/libunet/Makefile	Tue Jan  5 07:36:02 2010	(r201564)
@@ -17,6 +17,7 @@ UNET_KERN_COMMON_OBJS +=	\
 	kern_sysctl.o		\
 	md5c.o			\
 	subr_eventhandler.o	\
+	subr_lock.o		\
 	subr_param.o		\
 	subr_pcpu.o		\
 	subr_sbuf.o		\
@@ -120,6 +121,7 @@ CFLAGS+=	-I./include/opt
 CFLAGS+=	-I${PREFIX}
 CFLAGS+=	-D_KERNEL
 CFLAGS+=	-DMUTEX_NOINLINE
+CFLAGS+=	-DRWLOCK_NOINLINE
 CFLAGS+=	-DUNET
 CFLAGS+=	-DMAXUSERS=32
 CFLAGS+=	-fno-builtin

Added: user/kmacy/releng_8_rump/lib/libunet/include/opt/opt_mprof.h
==============================================================================

Added: user/kmacy/releng_8_rump/lib/libunet/include/sys/_rwlock.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/kmacy/releng_8_rump/lib/libunet/include/sys/_rwlock.h	Tue Jan  5 07:36:02 2010	(r201564)
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 2006 John Baldwin <jhb@FreeBSD.org>
+ * 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.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _SYS__RWLOCK_H_
+#define	_SYS__RWLOCK_H_
+
+/*
+ * Reader/writer lock.
+ */
+struct rwlock {
+	struct lock_object	lock_object;
+	pthread_rwlock_t	rw_lock;
+};
+
+#endif /* !_SYS__RWLOCK_H_ */

Modified: user/kmacy/releng_8_rump/lib/libunet/unet_glue.c
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/unet_glue.c	Tue Jan  5 06:58:54 2010	(r201563)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_glue.c	Tue Jan  5 07:36:02 2010	(r201564)
@@ -67,7 +67,6 @@ struct filterops fs_filtops;
 struct filterops sig_filtops;
 
 int cold;
-struct mtx Giant;
 
 static void	timevalfix(struct timeval *);
 

Modified: user/kmacy/releng_8_rump/lib/libunet/unet_lock.c
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/unet_lock.c	Tue Jan  5 06:58:54 2010	(r201563)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_lock.c	Tue Jan  5 07:36:02 2010	(r201564)
@@ -1,3 +1,5 @@
+
+
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/bus.h>
@@ -20,89 +22,94 @@
 #include <sys/vmmeter.h>
 #include <sys/lock_profile.h>
 
+#include <pthread.h>
 
+struct mtx Giant;
 
-void
-mtx_init(struct mtx *m, const char *name, const char *type, int opts)
-{
-
-	panic("");
-}
 
-void
-mtx_destroy(struct mtx *m)
+static void
+assert_mtx(struct lock_object *lock, int what)
 {
 
-	panic("");
+	mtx_assert((struct mtx *)lock, what);
 }
 
-void
-mtx_sysinit(void *arg)
-{
-	
-	panic("");
-}
+/*
+ * Lock classes for sleep and spin mutexes.
+ */
+struct lock_class lock_class_mtx_sleep = {
+	.lc_name = "sleep mutex",
+	.lc_flags = LC_SLEEPLOCK | LC_RECURSABLE,
+	.lc_assert = assert_mtx,
+#ifdef DDB
+	.lc_ddb_show = db_show_mtx,
+#endif
+#ifdef KDTRACE_HOOKS
+	.lc_owner = owner_mtx,
+#endif
+};
 
 void
-_mtx_lock_flags(struct mtx *m, int opts, const char *file, int line)
+mtx_init(struct mtx *m, const char *name, const char *type, int opts)
 {
+	pthread_mutexattr_t attr;
 
-	panic("");
+	lock_init(&m->lock_object, &lock_class_mtx_sleep, name, type, opts);
+	pthread_mutexattr_init(&attr);
+	pthread_mutex_init(&m->lock_object.lo_mutex, &attr);
 }
 
 void
-_mtx_unlock_flags(struct mtx *m, int opts, const char *file, int line)
+mtx_destroy(struct mtx *m)
 {
 
-	panic("");
-}
-
-
-
-void
-rm_init_flags(struct rmlock *rm, const char *name, int opts)
-{
-	
-	panic("");
+	pthread_mutex_destroy(&m->lock_object.lo_mutex);
 }
 
 void
-rm_destroy(struct rmlock *rm)
+mtx_sysinit(void *arg)
 {
+	struct mtx_args *margs = arg;
 
-	panic("");
+	mtx_init(margs->ma_mtx, margs->ma_desc, NULL, margs->ma_opts);
 }
 
 void
-_rm_wlock(struct rmlock *rm)
+_mtx_lock_flags(struct mtx *m, int opts, const char *file, int line)
 {
 
-	panic("");
+	pthread_mutex_lock(&m->lock_object.lo_mutex);
 }
 
 void
-_rm_wunlock(struct rmlock *rm)
+_mtx_unlock_flags(struct mtx *m, int opts, const char *file, int line)
 {
 
-	panic("");
+	pthread_mutex_unlock(&m->lock_object.lo_mutex);
 }
 
-void
-_rm_rlock(struct rmlock *rm, struct rm_priotracker *tracker)
-{
 
-	panic("");
-}
+
 
 void
-_rm_runlock(struct rmlock *rm,  struct rm_priotracker *tracker)
+assert_rw(struct lock_object *lock, int what)
 {
 
-	panic("");
+	rw_assert((struct rwlock *)lock, what);
 }
 
+struct lock_class lock_class_rw = {
+	.lc_name = "rw",
+	.lc_flags = LC_SLEEPLOCK | LC_RECURSABLE | LC_UPGRADABLE,
+	.lc_assert = assert_rw,
+#ifdef DDB
+	.lc_ddb_show = db_show_rwlock,
+#endif
 
-
+#ifdef KDTRACE_HOOKS
+	.lc_owner = owner_rw,
+#endif
+};
 void
 rw_sysinit(void *arg)
 {
@@ -113,90 +120,160 @@ rw_sysinit(void *arg)
 void
 rw_init_flags(struct rwlock *rw, const char *name, int opts)
 {
+	pthread_rwlockattr_t attr;
+	int flags;
 
-	panic("");
+	MPASS((opts & ~(RW_DUPOK | RW_NOPROFILE | RW_NOWITNESS | RW_QUIET |
+	    RW_RECURSE)) == 0);
+	ASSERT_ATOMIC_LOAD_PTR(rw->rw_lock,
+	    ("%s: rw_lock not aligned for %s: %p", __func__, name,
+	    &rw->rw_lock));
+
+	flags = LO_UPGRADABLE;
+	if (opts & RW_DUPOK)
+		flags |= LO_DUPOK;
+	if (opts & RW_NOPROFILE)
+		flags |= LO_NOPROFILE;
+	if (!(opts & RW_NOWITNESS))
+		flags |= LO_WITNESS;
+	if (opts & RW_RECURSE)
+		flags |= LO_RECURSABLE;
+	if (opts & RW_QUIET)
+		flags |= LO_QUIET;
+
+	lock_init(&rw->lock_object, &lock_class_rw, name, NULL, flags);
+	pthread_rwlockattr_init(&attr);
+	pthread_rwlock_init(&rw->rw_lock, &attr);
 }
 
+
 void
 rw_destroy(struct rwlock *rw)
 {
 	
-	panic("");
+	pthread_rwlock_destroy(&rw->rw_lock);
 }
 
 void
 _rw_wlock(struct rwlock *rw, const char *file, int line)
 {
 
-	panic("");
+	pthread_rwlock_wrlock(&rw->rw_lock);
 }
 
 int
 _rw_try_wlock(struct rwlock *rw, const char *file, int line)
 {
 
-	panic("");
-	return (0);
+	return (pthread_rwlock_trywrlock(&rw->rw_lock));
 }
 
 void
 _rw_wunlock(struct rwlock *rw, const char *file, int line)
 {
 	
-	panic("");
+	pthread_rwlock_unlock(&rw->rw_lock);
 }
 
 void
 _rw_rlock(struct rwlock *rw, const char *file, int line)
 {
 	
-	panic("");
+	pthread_rwlock_rdlock(&rw->rw_lock);
 }
 
 int
 _rw_try_rlock(struct rwlock *rw, const char *file, int line)
 {
 	
-	panic("");
-	return (0);
+	pthread_rwlock_tryrdlock(&rw->rw_lock);
+
 }
 
 void
 _rw_runlock(struct rwlock *rw, const char *file, int line)
 {
 	
-	panic("");
+	pthread_rwlock_unlock(&rw->rw_lock);
 }
 
-void
-_rw_wlock_hard(struct rwlock *rw, uintptr_t tid, const char *file,
-    int line)
+int
+_rw_try_upgrade(struct rwlock *rw, const char *file, int line)
 {
 	
-	panic("");
+	return (0);
 }
 
 void
-_rw_wunlock_hard(struct rwlock *rw, uintptr_t tid, const char *file,
-    int line)
+_rw_downgrade(struct rwlock *rw, const char *file, int line)
 {
 	
 	panic("");
 }
 
-int
-_rw_try_upgrade(struct rwlock *rw, const char *file, int line)
+
+
+static void
+assert_rm(struct lock_object *lock, int what)
 {
-	
-	panic("");
-	return (0);
+
+	panic("assert_rm called");
 }
 
+struct lock_class lock_class_rm = {
+	.lc_name = "rm",
+	.lc_flags = LC_SLEEPLOCK | LC_RECURSABLE,
+	.lc_assert = assert_rm,
+#if 0
+#ifdef DDB
+	.lc_ddb_show = db_show_rwlock,
+#endif
+#endif
+#ifdef KDTRACE_HOOKS
+	.lc_owner = owner_rm,
+#endif
+};
+
 void
-_rw_downgrade(struct rwlock *rw, const char *file, int line)
+rm_init_flags(struct rmlock *rm, const char *name, int opts)
 {
-	
-	panic("");
+
+	rw_init_flags((struct rwlock *)rm, name, opts);
+}
+
+void
+rm_destroy(struct rmlock *rm)
+{
+
+	rw_destroy((struct rwlock *)rm);
+}
+
+void
+_rm_wlock(struct rmlock *rm)
+{
+
+	_rw_wlock((struct rwlock *)rm, __FILE__, __LINE__);
+}
+
+void
+_rm_wunlock(struct rmlock *rm)
+{
+
+	_rw_wunlock((struct rwlock *)rm, __FILE__, __LINE__);
+}
+
+void
+_rm_rlock(struct rmlock *rm, struct rm_priotracker *tracker)
+{
+
+	_rw_rlock((struct rwlock *)rm, __FILE__, __LINE__);
+}
+
+void
+_rm_runlock(struct rmlock *rm,  struct rm_priotracker *tracker)
+{
+
+	_rw_runlock((struct rwlock *)rm, __FILE__, __LINE__);
 }
 
 

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 11:30:08 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 914D71065697;
	Tue,  5 Jan 2010 11:30:08 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 675048FC17;
	Tue,  5 Jan 2010 11:30:08 +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 o05BU8P7082671;
	Tue, 5 Jan 2010 11:30:08 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o05BU755082669;
	Tue, 5 Jan 2010 11:30:07 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001051130.o05BU755082669@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Tue, 5 Jan 2010 11:30:07 +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: r201569 - user/luigi/ipfw3-head/sys/net
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: Tue, 05 Jan 2010 11:30:08 -0000

Author: luigi
Date: Tue Jan  5 11:30:06 2010
New Revision: 201569
URL: http://svn.freebsd.org/changeset/base/201569

Log:
  adjust if_bridge and if_ethersubr to the new tagging for dummynet

Modified:
  user/luigi/ipfw3-head/sys/net/if_bridge.c
  user/luigi/ipfw3-head/sys/net/if_ethersubr.c

Modified: user/luigi/ipfw3-head/sys/net/if_bridge.c
==============================================================================
--- user/luigi/ipfw3-head/sys/net/if_bridge.c	Tue Jan  5 11:00:31 2010	(r201568)
+++ user/luigi/ipfw3-head/sys/net/if_bridge.c	Tue Jan  5 11:30:06 2010	(r201569)
@@ -135,7 +135,6 @@ __FBSDID("$FreeBSD$");
 #include <net/route.h>
 #include <netinet/ip_fw.h>
 #include <netinet/ipfw/ip_fw_private.h>
-#include <netinet/ip_dummynet.h>
 
 /*
  * Size of the route hash table.  Must be a power of two.
@@ -3051,15 +3050,15 @@ bridge_pfil(struct mbuf **mp, struct ifn
 		if (mtag == NULL) {
 			args.rule.slot = 0;
 		} else {
-			struct dn_pkt_tag *dn_tag;
+			struct ipfw_rule_ref *r;
 
 			/* XXX can we free the tag after use ? */
 			mtag->m_tag_id = PACKET_TAG_NONE;
-			dn_tag = (struct dn_pkt_tag *)(mtag + 1);
+			r = (struct ipfw_rule_ref *)(mtag + 1);
 			/* packet already partially processed ? */
-			if (dn_tag->rule.slot != 0 && V_fw_one_pass)
+			if (r->info & IPFW_ONEPASS)
 				goto ipfwpass;
-			args.rule = dn_tag->rule;
+			args.rule = *r;
 		}
 
 		args.m = *mp;

Modified: user/luigi/ipfw3-head/sys/net/if_ethersubr.c
==============================================================================
--- user/luigi/ipfw3-head/sys/net/if_ethersubr.c	Tue Jan  5 11:00:31 2010	(r201568)
+++ user/luigi/ipfw3-head/sys/net/if_ethersubr.c	Tue Jan  5 11:30:06 2010	(r201569)
@@ -72,7 +72,6 @@
 #include <netinet/if_ether.h>
 #include <netinet/ip_fw.h>
 #include <netinet/ipfw/ip_fw_private.h>
-#include <netinet/ip_dummynet.h>
 #include <netinet/ip_var.h>
 #endif
 #ifdef INET6
@@ -474,15 +473,15 @@ ether_ipfw_chk(struct mbuf **m0, struct 
 	if (mtag == NULL) {
 		args.rule.slot = 0;
 	} else {
-		struct dn_pkt_tag *dn_tag;
+		/* dummynet packet, already partially processed */
+		struct ipfw_rule_ref *r;
 
 		/* XXX can we free it after use ? */
 		mtag->m_tag_id = PACKET_TAG_NONE;
-		dn_tag = (struct dn_pkt_tag *)(mtag + 1);
-		if (dn_tag->rule.slot != 0 && V_fw_one_pass)
-			/* dummynet packet, already partially processed */
+		r = (struct ipfw_rule_ref *)(mtag + 1);
+		if (r->info & IPFW_ONEPASS)
 			return (1);
-		args.rule = dn_tag->rule;
+		args.rule = *r;
 	}
 
 	/*

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 11:38:38 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 506351065693;
	Tue,  5 Jan 2010 11:38:38 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 3F8BC8FC18;
	Tue,  5 Jan 2010 11:38:38 +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 o05Bccql084547;
	Tue, 5 Jan 2010 11:38:38 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o05BccWo084545;
	Tue, 5 Jan 2010 11:38:38 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001051138.o05BccWo084545@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Tue, 5 Jan 2010 11:38:38 +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: r201570 - user/luigi/ipfw3-head/sys/netinet/ipfw
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: Tue, 05 Jan 2010 11:38:38 -0000

Author: luigi
Date: Tue Jan  5 11:38:37 2010
New Revision: 201570
URL: http://svn.freebsd.org/changeset/base/201570

Log:
  remove unnecessary dependency

Modified:
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c	Tue Jan  5 11:30:06 2010	(r201569)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c	Tue Jan  5 11:38:37 2010	(r201570)
@@ -59,7 +59,6 @@ __FBSDID("$FreeBSD$");
 #include <netinet/ip_var.h>
 #include <netinet/ip_fw.h>
 #include <netinet/ipfw/ip_fw_private.h>
-#include <netinet/ip_dummynet.h>
 #include <netgraph/ng_ipfw.h>
 
 #include <machine/in_cksum.h>

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 11:39:49 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 2342C1065693;
	Tue,  5 Jan 2010 11:39:49 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 10AA48FC21;
	Tue,  5 Jan 2010 11:39:49 +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 o05BdnRb084848;
	Tue, 5 Jan 2010 11:39:49 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o05Bdmdk084842;
	Tue, 5 Jan 2010 11:39:48 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001051139.o05Bdmdk084842@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Tue, 5 Jan 2010 11:39:48 +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: r201571 - in user/luigi/ipfw3-head/sys: conf netinet
	netinet/ipfw
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: Tue, 05 Jan 2010 11:39:49 -0000

Author: luigi
Date: Tue Jan  5 11:39:48 2010
New Revision: 201571
URL: http://svn.freebsd.org/changeset/base/201571

Log:
  move the binary heap code outside ip_dummynet.c;
  remove kernel-private definitions and data structures from ip_dummynet.h

Added:
  user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c   (contents, props changed)
  user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.h   (contents, props changed)
Modified:
  user/luigi/ipfw3-head/sys/conf/files
  user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c

Modified: user/luigi/ipfw3-head/sys/conf/files
==============================================================================
--- user/luigi/ipfw3-head/sys/conf/files	Tue Jan  5 11:38:37 2010	(r201570)
+++ user/luigi/ipfw3-head/sys/conf/files	Tue Jan  5 11:39:48 2010	(r201571)
@@ -2449,6 +2449,7 @@ netinet/in_proto.c		optional inet \
 	compile-with "${NORMAL_C} -I$S/contrib/pf"
 netinet/in_rmx.c		optional inet
 netinet/ip_divert.c		optional inet ipdivert ipfirewall
+netinet/ipfw/dn_heap.c		optional inet dummynet
 netinet/ipfw/ip_dummynet.c	optional inet dummynet
 netinet/ip_ecn.c		optional inet | inet6
 netinet/ip_encap.c		optional inet | inet6

Modified: user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h	Tue Jan  5 11:38:37 2010	(r201570)
+++ user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h	Tue Jan  5 11:39:48 2010	(r201571)
@@ -38,93 +38,12 @@
  */
 
 /*
- * We start with a heap, which is used in the scheduler to decide when
- * to transmit packets etc.
- *
- * The key for the heap is used for two different values:
- *
- * 1. timer ticks- max 10K/second, so 32 bits are enough;
- *
- * 2. virtual times. These increase in steps of len/x, where len is the
- *    packet length, and x is either the weight of the flow, or the
- *    sum of all weights.
- *    If we limit to max 1000 flows and a max weight of 100, then
- *    x needs 17 bits. The packet size is 16 bits, so we can easily
- *    overflow if we do not allow errors.
- * So we use a key "dn_key" which is 64 bits. Some macros are used to
- * compare key values and handle wraparounds.
- * MAX64 returns the largest of two key values.
- * MY_M is used as a shift count when doing fixed point arithmetic
- * (a better name would be useful...).
- */
-typedef u_int64_t dn_key ;      /* sorting key */
-#define DN_KEY_LT(a,b)     ((int64_t)((a)-(b)) < 0)
-#define DN_KEY_LEQ(a,b)    ((int64_t)((a)-(b)) <= 0)
-#define DN_KEY_GT(a,b)     ((int64_t)((a)-(b)) > 0)
-#define DN_KEY_GEQ(a,b)    ((int64_t)((a)-(b)) >= 0)
-#define MAX64(x,y)  (( (int64_t) ( (y)-(x) )) > 0 ) ? (y) : (x)
-#define MY_M	16 /* number of left shift to obtain a larger precision */
-
-/*
- * XXX With this scaling, max 1000 flows, max weight 100, 1Gbit/s, the
- * virtual time wraps every 15 days.
- */
-
-
-/*
  * The maximum hash table size for queues.  This value must be a power
  * of 2.
  */
 #define DN_MAX_HASH_SIZE 65536
 
-/*
- * A heap entry is made of a key and a pointer to the actual
- * object stored in the heap.
- * The heap is an array of dn_heap_entry entries, dynamically allocated.
- * Current size is "size", with "elements" actually in use.
- * The heap normally supports only ordered insert and extract from the top.
- * If we want to extract an object from the middle of the heap, we
- * have to know where the object itself is located in the heap (or we
- * need to scan the whole array). To this purpose, an object has a
- * field (int) which contains the index of the object itself into the
- * heap. When the object is moved, the field must also be updated.
- * The offset of the index in the object is stored in the 'offset'
- * field in the heap descriptor. The assumption is that this offset
- * is non-zero if we want to support extract from the middle.
- */
-struct dn_heap_entry {
-    dn_key key ;	/* sorting key. Topmost element is smallest one */
-    void *object ;	/* object pointer */
-} ;
-
-struct dn_heap {
-    int size ;
-    int elements ;
-    int offset ; /* XXX if > 0 this is the offset of direct ptr to obj */
-    struct dn_heap_entry *p ;	/* really an array of "size" entries */
-} ;
-
-#ifdef _KERNEL
-/*
- * Packets processed by dummynet have an mbuf tag associated with
- * them that carries their dummynet state.  This is used within
- * the dummynet code as well as outside when checking for special
- * processing requirements.
- * Note that the first part is the reinject info and is common to
- * other forms of packet reinjection.
- */
-struct dn_pkt_tag {
-	struct ipfw_rule_ref rule;	/* matching rule */
-
-    /* second part, dummynet specific */
-    int dn_dir;			/* action when packet comes out. */
-				/* see ip_fw_private.h */
-
-    dn_key output_time;		/* when the pkt is due for delivery	*/
-    struct ifnet *ifp;		/* interface, for ip_output		*/
-    struct _ip6dn_args ip6opt;	/* XXX ipv6 options			*/
-};
-#endif /* _KERNEL */
+typedef uint64_t dn_key;
 
 /*
  * Overall structure of dummynet (with WF2Q+):
@@ -303,6 +222,7 @@ struct dn_flow_set {
 };
 SLIST_HEAD(dn_flow_set_head, dn_flow_set);
 
+struct dn_heap;
 /*
  * Pipe descriptor. Contains global parameters, delay-line queue,
  * and the flow_set used for fixed-rate queues.
@@ -327,9 +247,9 @@ struct dn_pipe {		/* a pipe */
     struct	mbuf *head, *tail ;	/* packets in delay line */
 
     /* WF2Q+ */
-    struct dn_heap scheduler_heap ; /* top extract - key Finish time*/
-    struct dn_heap not_eligible_heap; /* top extract- key Start time */
-    struct dn_heap idle_heap ; /* random extract - key Start=Finish time */
+    struct dn_heap *scheduler_heap ; /* top extract - key Finish time*/
+    struct dn_heap *not_eligible_heap; /* top extract- key Start time */
+    struct dn_heap *idle_heap ; /* random extract - key Start=Finish time */
 
     dn_key V ;			/* virtual time */
     int sum;			/* sum of weights of all active sessions */

Added: user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c	Tue Jan  5 11:39:48 2010	(r201571)
@@ -0,0 +1,251 @@
+/*-
+ * Copyright (c) 1998-2002 Luigi Rizzo, Universita` di Pisa
+ * 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 AND CONTRIBUTORS ``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>
+__FBSDID("$FreeBSD$");
+
+/*
+ * A binary heap data structure used in dummynet
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/kernel.h>
+#include <netinet/ipfw/dn_heap.h>
+
+MALLOC_DEFINE(M_DN_HEAP, "dummynet", "dummynet heap");
+
+/*
+ * Heap management functions.
+ *
+ * In the heap, first node is element 0. Children of i are 2i+1 and 2i+2.
+ * Some macros help finding parent/children so we can optimize them.
+ *
+ * heap_init() is called to expand the heap when needed.
+ * Increment size in blocks of 16 entries.
+ * XXX failure to allocate a new element is a pretty bad failure
+ * as we basically stall a whole queue forever!!
+ * Returns 1 on error, 0 on success
+ */
+#define HEAP_FATHER(x) ( ( (x) - 1 ) / 2 )
+#define HEAP_LEFT(x) ( 2*(x) + 1 )
+#define HEAP_IS_LEFT(x) ( (x) & 1 )
+#define HEAP_RIGHT(x) ( 2*(x) + 2 )
+#define	HEAP_SWAP(a, b, buffer) { buffer = a ; a = b ; b = buffer ; }
+#define HEAP_INCREMENT	15
+
+int
+heap_init(struct dn_heap *h, int new_size)
+{
+	struct dn_heap_entry *p;
+
+	if (h->size >= new_size ) {
+		printf("%s: Bogus call, have %d want %d\n",
+			__func__, h->size, new_size);
+		return 0;
+	}
+	new_size = (new_size + HEAP_INCREMENT ) & ~HEAP_INCREMENT;
+	p = malloc(new_size * sizeof(*p), M_DN_HEAP, M_NOWAIT);
+	if (p == NULL) {
+		printf("%s, resize %d failed\n", __func__, new_size );
+		return 1; /* error */
+	}
+	if (h->size > 0) {
+		bcopy(h->p, p, h->size * sizeof(*p) );
+		free(h->p, M_DN_HEAP);
+	}
+	h->p = p;
+	h->size = new_size;
+	return 0;
+}
+
+/*
+ * Insert element in heap. Normally, p != NULL, we insert p in
+ * a new position and bubble up. If p == NULL, then the element is
+ * already in place, and key is the position where to start the
+ * bubble-up.
+ * Returns 1 on failure (cannot allocate new heap entry)
+ *
+ * If offset > 0 the position (index, int) of the element in the heap is
+ * also stored in the element itself at the given offset in bytes.
+ */
+#define SET_OFFSET(heap, node) \
+    if (heap->offset > 0) \
+	    *((int *)((char *)(heap->p[node].object) + heap->offset)) = node;
+/*
+ * RESET_OFFSET is used for sanity checks. It sets offset
+ * to an invalid value.
+ */
+#define RESET_OFFSET(heap, node) \
+    if (heap->offset > 0) \
+	    *((int *)((char *)(heap->p[node].object) + heap->offset)) = -1;
+int
+heap_insert(struct dn_heap *h, uint64_t key1, void *p)
+{
+	int son = h->elements;
+
+	if (p == NULL)	/* data already there, set starting point */
+		son = key1;
+	else {/* insert new element at the end, possibly resize */
+		son = h->elements;
+		if (son == h->size) /* need resize... */
+			if (heap_init(h, h->elements+1) )
+				return 1; /* failure... */
+		h->p[son].object = p;
+		h->p[son].key = key1;
+		h->elements++;
+	}
+	while (son > 0) {			/* bubble up */
+		int father = HEAP_FATHER(son);
+		struct dn_heap_entry tmp;
+
+		if (DN_KEY_LT( h->p[father].key, h->p[son].key ) )
+			break; /* found right position */
+		/* son smaller than father, swap and repeat */
+		HEAP_SWAP(h->p[son], h->p[father], tmp);
+		SET_OFFSET(h, son);
+		son = father;
+	}
+	SET_OFFSET(h, son);
+	return 0;
+}
+
+/*
+ * remove top element from heap, or obj if obj != NULL
+ */
+void
+heap_extract(struct dn_heap *h, void *obj)
+{
+	int child, father, max = h->elements - 1;
+
+	if (max < 0) {
+		printf("%s: empty heap 0x%p\n", __FUNCTION__, h);
+		return;
+	}
+	father = 0; /* default: move up smallest child */
+	if (obj != NULL) { /* extract specific element, index is at offset */
+		if (h->offset <= 0)
+			panic("%s: extract from middle not set on %p\n",
+				__FUNCTION__, h);
+		father = *((int *)((char *)obj + h->offset));
+		if (father < 0 || father >= h->elements) {
+			panic("%s: heap_extract, father %d out of bound 0..%d\n",
+				__FUNCTION__, father, h->elements);
+		}
+	}
+	RESET_OFFSET(h, father);
+	child = HEAP_LEFT(father);		/* left child */
+	while (child <= max) {		/* valid entry */
+		if (child != max &&
+		    DN_KEY_LT(h->p[child+1].key, h->p[child].key) )
+			child++; /* take right child, otherwise left */
+		h->p[father] = h->p[child];
+		SET_OFFSET(h, father);
+		father = child;
+		child = HEAP_LEFT(child); /* prepare for next loop */
+	}
+	h->elements--;
+	if (father != max) {
+		/*
+		 * Fill hole with last entry and bubble up,
+		 * reusing the insert code
+		 */
+		h->p[father] = h->p[max];
+		heap_insert(h, father, NULL);
+	}
+}
+
+#if 0
+/*
+ * change object position and update references
+ * XXX this one is never used!
+ */
+static void
+heap_move(struct dn_heap *h, uint64_t new_key, void *object)
+{
+	int temp;
+	int i;
+	int max = h->elements-1;
+	struct dn_heap_entry buf;
+
+	if (h->offset <= 0)
+		panic("cannot move items on this heap");
+
+	i = *((int *)((char *)object + h->offset));
+	if (DN_KEY_LT(new_key, h->p[i].key) ) { /* must move up */
+		h->p[i].key = new_key;
+		for (; i>0 &&
+		    DN_KEY_LT(new_key, h->p[(temp = HEAP_FATHER(i))].key);
+		    i = temp ) { /* bubble up */
+			HEAP_SWAP(h->p[i], h->p[temp], buf);
+			SET_OFFSET(h, i);
+		}
+	} else {		/* must move down */
+		h->p[i].key = new_key;
+		while ( (temp = HEAP_LEFT(i)) <= max ) {
+			/* found left child */
+			if ((temp != max) &&
+			    DN_KEY_GT(h->p[temp].key, h->p[temp+1].key))
+				temp++; /* select child with min key */
+			if (DN_KEY_GT(new_key, h->p[temp].key)) {
+				/* go down */
+				HEAP_SWAP(h->p[i], h->p[temp], buf);
+				SET_OFFSET(h, i);
+			} else
+				break;
+			i = temp;
+		}
+	}
+	SET_OFFSET(h, i);
+}
+#endif /* heap_move, unused */
+
+/*
+ * heapify() will reorganize data inside an array to maintain the
+ * heap property. It is needed when we delete a bunch of entries.
+ */
+void
+heapify(struct dn_heap *h)
+{
+	int i;
+
+	printf("%s on %p for %d elements\n",
+		__FUNCTION__, h, h->elements);
+	for (i = 0; i < h->elements; i++ )
+		heap_insert(h, i , NULL);
+}
+
+/*
+ * cleanup the heap and free data structure
+ */
+void
+heap_free(struct dn_heap *h)
+{
+	if (h->size >0 )
+		free(h->p, M_DN_HEAP);
+	bzero(h, sizeof(*h) );
+}

Added: user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.h	Tue Jan  5 11:39:48 2010	(r201571)
@@ -0,0 +1,70 @@
+/*-
+ * Copyright (c) 1998-2002 Luigi Rizzo, Universita` di Pisa
+ * 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 AND CONTRIBUTORS ``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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _IP_DN_HEAP_H
+#define _IP_DN_HEAP_H
+
+#define DN_KEY_LT(a,b)     ((int64_t)((a)-(b)) < 0)
+#define DN_KEY_LEQ(a,b)    ((int64_t)((a)-(b)) <= 0)
+#define DN_KEY_GT(a,b)     ((int64_t)((a)-(b)) > 0)
+#define DN_KEY_GEQ(a,b)    ((int64_t)((a)-(b)) >= 0)
+
+/*
+ * A heap entry is made of a key and a pointer to the actual
+ * object stored in the heap.
+ * The heap is an array of dn_heap_entry entries, dynamically allocated.
+ * Current size is "size", with "elements" actually in use.
+ * The heap normally supports only ordered insert and extract from the top.
+ * If we want to extract an object from the middle of the heap, we
+ * have to know where the object itself is located in the heap (or we
+ * need to scan the whole array). To this purpose, an object has a
+ * field (int) which contains the index of the object itself into the
+ * heap. When the object is moved, the field must also be updated.
+ * The offset of the index in the object is stored in the 'offset'
+ * field in the heap descriptor. The assumption is that this offset
+ * is non-zero if we want to support extract from the middle.
+ */
+struct dn_heap_entry {
+	uint64_t key;	/* sorting key. Topmost element is smallest one */
+	void *object;	/* object pointer */
+} ;
+
+struct dn_heap {
+	int size;	/* the size of the array */
+	int elements;	/* elements in use */
+	int offset; /* XXX if > 0 this is the offset of direct ptr to obj */
+	struct dn_heap_entry *p ;	/* really an array of "size" entries */
+} ;
+
+int     heap_init(struct dn_heap *h, int size);
+int     heap_insert (struct dn_heap *h, uint64_t key1, void *p);
+void    heap_extract(struct dn_heap *h, void *obj);
+void heapify(struct dn_heap *h);
+void heap_free(struct dn_heap *h);
+
+#endif /* _IP_DN_HEAP_H */

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Tue Jan  5 11:38:37 2010	(r201570)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Tue Jan  5 11:39:48 2010	(r201571)
@@ -77,6 +77,7 @@ __FBSDID("$FreeBSD$");
 #include <netinet/ip.h>		/* ip_len, ip_off */
 #include <netinet/ip_fw.h>
 #include <netinet/ipfw/ip_fw_private.h>
+#include <netinet/ipfw/dn_heap.h>
 #include <netinet/ip_dummynet.h>
 #include <netinet/ip_var.h>	/* ip_output(), IP_FORWARDING */
 
@@ -128,15 +129,33 @@ static unsigned long	io_pkt_drop;
  *
  * extract_heap contains pipes associated with delay lines.
  *
+ * The key for the heap is used for two different values:
+ *
+ * 1. timer ticks- max 10K/second, so 32 bits are enough;
+ *
+ * 2. virtual times. These increase in steps of len/x, where len is the
+ *    packet length, and x is either the weight of the flow, or the
+ *    sum of all weights.
+ *    If we limit to max 1000 flows and a max weight of 100, then
+ *    x needs 17 bits. The packet size is 16 bits, so we can easily
+ *    overflow if we do not allow errors.
+ * So we use a key "dn_key" which is 64 bits. Some macros are used to
+ * compare key values and handle wraparounds.
+ * MAX64 returns the largest of two key values.
+ * MY_M is used as a shift count when doing fixed point arithmetic
+ * (a better name would be useful...).
+ */
+#define MAX64(x,y)  (( (int64_t) ( (y)-(x) )) > 0 ) ? (y) : (x)
+#define MY_M    16 /* number of left shift to obtain a larger precision */
+  
+/*
+ * XXX With this scaling, max 1000 flows, max weight 100, 1Gbit/s, the
+ * virtual time wraps every 15 days.
  */
 
 MALLOC_DEFINE(M_DUMMYNET, "dummynet", "dummynet heap");
 
 static struct dn_heap ready_heap, extract_heap, wfq_ready_heap ;
-
-static int	heap_init(struct dn_heap *h, int size);
-static int	heap_insert (struct dn_heap *h, dn_key key1, void *p);
-static void	heap_extract(struct dn_heap *h, void *obj);
 static void	transmit_event(struct dn_pipe *pipe, struct mbuf **head,
 		    struct mbuf **tail);
 static void	ready_event(struct dn_flow_queue *q, struct mbuf **head,
@@ -256,212 +275,6 @@ static int	dummynet_io(struct mbuf **, i
 	(q)->fs->pipe->bandwidth >= (q)->fs->pipe->burst))
 
 /*
- * Heap management functions.
- *
- * In the heap, first node is element 0. Children of i are 2i+1 and 2i+2.
- * Some macros help finding parent/children so we can optimize them.
- *
- * heap_init() is called to expand the heap when needed.
- * Increment size in blocks of 16 entries.
- * XXX failure to allocate a new element is a pretty bad failure
- * as we basically stall a whole queue forever!!
- * Returns 1 on error, 0 on success
- */
-#define HEAP_FATHER(x) ( ( (x) - 1 ) / 2 )
-#define HEAP_LEFT(x) ( 2*(x) + 1 )
-#define HEAP_IS_LEFT(x) ( (x) & 1 )
-#define HEAP_RIGHT(x) ( 2*(x) + 2 )
-#define	HEAP_SWAP(a, b, buffer) { buffer = a ; a = b ; b = buffer ; }
-#define HEAP_INCREMENT	15
-
-static int
-heap_init(struct dn_heap *h, int new_size)
-{
-    struct dn_heap_entry *p;
-
-    if (h->size >= new_size ) {
-	printf("dummynet: %s, Bogus call, have %d want %d\n", __func__,
-		h->size, new_size);
-	return 0 ;
-    }
-    new_size = (new_size + HEAP_INCREMENT ) & ~HEAP_INCREMENT ;
-    p = malloc(new_size * sizeof(*p), M_DUMMYNET, M_NOWAIT);
-    if (p == NULL) {
-	printf("dummynet: %s, resize %d failed\n", __func__, new_size );
-	return 1 ; /* error */
-    }
-    if (h->size > 0) {
-	bcopy(h->p, p, h->size * sizeof(*p) );
-	free(h->p, M_DUMMYNET);
-    }
-    h->p = p ;
-    h->size = new_size ;
-    return 0 ;
-}
-
-/*
- * Insert element in heap. Normally, p != NULL, we insert p in
- * a new position and bubble up. If p == NULL, then the element is
- * already in place, and key is the position where to start the
- * bubble-up.
- * Returns 1 on failure (cannot allocate new heap entry)
- *
- * If offset > 0 the position (index, int) of the element in the heap is
- * also stored in the element itself at the given offset in bytes.
- */
-#define SET_OFFSET(heap, node) \
-    if (heap->offset > 0) \
-	    *((int *)((char *)(heap->p[node].object) + heap->offset)) = node ;
-/*
- * RESET_OFFSET is used for sanity checks. It sets offset to an invalid value.
- */
-#define RESET_OFFSET(heap, node) \
-    if (heap->offset > 0) \
-	    *((int *)((char *)(heap->p[node].object) + heap->offset)) = -1 ;
-static int
-heap_insert(struct dn_heap *h, dn_key key1, void *p)
-{
-    int son = h->elements ;
-
-    if (p == NULL)	/* data already there, set starting point */
-	son = key1 ;
-    else {		/* insert new element at the end, possibly resize */
-	son = h->elements ;
-	if (son == h->size) /* need resize... */
-	    if (heap_init(h, h->elements+1) )
-		return 1 ; /* failure... */
-	h->p[son].object = p ;
-	h->p[son].key = key1 ;
-	h->elements++ ;
-    }
-    while (son > 0) {				/* bubble up */
-	int father = HEAP_FATHER(son) ;
-	struct dn_heap_entry tmp  ;
-
-	if (DN_KEY_LT( h->p[father].key, h->p[son].key ) )
-	    break ; /* found right position */
-	/* son smaller than father, swap and repeat */
-	HEAP_SWAP(h->p[son], h->p[father], tmp) ;
-	SET_OFFSET(h, son);
-	son = father ;
-    }
-    SET_OFFSET(h, son);
-    return 0 ;
-}
-
-/*
- * remove top element from heap, or obj if obj != NULL
- */
-static void
-heap_extract(struct dn_heap *h, void *obj)
-{
-    int child, father, max = h->elements - 1 ;
-
-    if (max < 0) {
-	printf("dummynet: warning, extract from empty heap 0x%p\n", h);
-	return ;
-    }
-    father = 0 ; /* default: move up smallest child */
-    if (obj != NULL) { /* extract specific element, index is at offset */
-	if (h->offset <= 0)
-	    panic("dummynet: heap_extract from middle not supported on this heap!!!\n");
-	father = *((int *)((char *)obj + h->offset)) ;
-	if (father < 0 || father >= h->elements) {
-	    printf("dummynet: heap_extract, father %d out of bound 0..%d\n",
-		father, h->elements);
-	    panic("dummynet: heap_extract");
-	}
-    }
-    RESET_OFFSET(h, father);
-    child = HEAP_LEFT(father) ;		/* left child */
-    while (child <= max) {		/* valid entry */
-	if (child != max && DN_KEY_LT(h->p[child+1].key, h->p[child].key) )
-	    child = child+1 ;		/* take right child, otherwise left */
-	h->p[father] = h->p[child] ;
-	SET_OFFSET(h, father);
-	father = child ;
-	child = HEAP_LEFT(child) ;   /* left child for next loop */
-    }
-    h->elements-- ;
-    if (father != max) {
-	/*
-	 * Fill hole with last entry and bubble up, reusing the insert code
-	 */
-	h->p[father] = h->p[max] ;
-	heap_insert(h, father, NULL); /* this one cannot fail */
-    }
-}
-
-#if 0
-/*
- * change object position and update references
- * XXX this one is never used!
- */
-static void
-heap_move(struct dn_heap *h, dn_key new_key, void *object)
-{
-    int temp;
-    int i ;
-    int max = h->elements-1 ;
-    struct dn_heap_entry buf ;
-
-    if (h->offset <= 0)
-	panic("cannot move items on this heap");
-
-    i = *((int *)((char *)object + h->offset));
-    if (DN_KEY_LT(new_key, h->p[i].key) ) { /* must move up */
-	h->p[i].key = new_key ;
-	for (; i>0 && DN_KEY_LT(new_key, h->p[(temp = HEAP_FATHER(i))].key) ;
-		 i = temp ) { /* bubble up */
-	    HEAP_SWAP(h->p[i], h->p[temp], buf) ;
-	    SET_OFFSET(h, i);
-	}
-    } else {		/* must move down */
-	h->p[i].key = new_key ;
-	while ( (temp = HEAP_LEFT(i)) <= max ) { /* found left child */
-	    if ((temp != max) && DN_KEY_GT(h->p[temp].key, h->p[temp+1].key))
-		temp++ ; /* select child with min key */
-	    if (DN_KEY_GT(new_key, h->p[temp].key)) { /* go down */
-		HEAP_SWAP(h->p[i], h->p[temp], buf) ;
-		SET_OFFSET(h, i);
-	    } else
-		break ;
-	    i = temp ;
-	}
-    }
-    SET_OFFSET(h, i);
-}
-#endif /* heap_move, unused */
-
-/*
- * heapify() will reorganize data inside an array to maintain the
- * heap property. It is needed when we delete a bunch of entries.
- */
-static void
-heapify(struct dn_heap *h)
-{
-    int i ;
-
-    for (i = 0 ; i < h->elements ; i++ )
-	heap_insert(h, i , NULL) ;
-}
-
-/*
- * cleanup the heap and free data structure
- */
-static void
-heap_free(struct dn_heap *h)
-{
-    if (h->size >0 )
-	free(h->p, M_DUMMYNET);
-    bzero(h, sizeof(*h) );
-}
-
-/*
- * --- end of heap management functions ---
- */
-
-/*
  * Dispose a list of packet. Use an inline functions so if we
  * need to free extra state associated to a packet, this is a
  * central point to do it.
@@ -478,6 +291,25 @@ static __inline void dn_free_pkts(struct
 }
 
 /*
+ * Packets processed by dummynet have an mbuf tag associated with
+ * them that carries their dummynet state.  This is used within
+ * the dummynet code as well as outside when checking for special
+ * processing requirements.
+ * Note that the first part is the reinject info and is common to
+ * other forms of packet reinjection.
+ */
+struct dn_pkt_tag {
+	struct ipfw_rule_ref rule;	/* matching rule		*/
+
+	/* second part, dummynet specific */
+	int dn_dir;		/* action when packet comes out.	*/
+				/* see ip_fw_private.h			*/
+	dn_key output_time;	/* when the pkt is due for delivery	*/
+	struct ifnet *ifp;	/* interface, for ip_output		*/
+	struct _ip6dn_args ip6opt;	/* XXX ipv6 options		*/
+};
+
+/*
  * Return the mbuf tag holding the dummynet state.  As an optimization
  * this is assumed to be the first tag on the list.  If this turns out
  * wrong we'll need to search the list.
@@ -703,8 +535,8 @@ static void
 ready_event_wfq(struct dn_pipe *p, struct mbuf **head, struct mbuf **tail)
 {
 	int p_was_empty = (p->head == NULL);
-	struct dn_heap *sch = &(p->scheduler_heap);
-	struct dn_heap *neh = &(p->not_eligible_heap);
+	struct dn_heap *sch = p->scheduler_heap;
+	struct dn_heap *neh = p->not_eligible_heap;
 	int64_t p_numbytes = p->numbytes;
 
 	/*
@@ -753,7 +585,7 @@ ready_event_wfq(struct dn_pipe *p, struc
 			if (q->len == 0) {
 				/* Flow not backlogged any more. */
 				fs->backlogged--;
-				heap_insert(&(p->idle_heap), q->F, q);
+				heap_insert(p->idle_heap, q->F, q);
 			} else {
 				/* Still backlogged. */
 
@@ -796,19 +628,19 @@ ready_event_wfq(struct dn_pipe *p, struc
 		 * No traffic and no events scheduled.
 		 * We can get rid of idle-heap.
 		 */
-		if (p->idle_heap.elements > 0) {
+		if (p->idle_heap->elements > 0) {
 			int i;
 
-			for (i = 0; i < p->idle_heap.elements; i++) {
+			for (i = 0; i < p->idle_heap->elements; i++) {
 				struct dn_flow_queue *q;
 				
-				q = p->idle_heap.p[i].object;
+				q = p->idle_heap->p[i].object;
 				q->F = 0;
 				q->S = q->F + 1;
 			}
 			p->sum = 0;
 			p->V = 0;
-			p->idle_heap.elements = 0;
+			p->idle_heap->elements = 0;
 		}
 	}
 	/*
@@ -934,12 +766,12 @@ dummynet_task(void *context, int pending
 	/* Sweep pipes trying to expire idle flow_queues. */
 	for (i = 0; i < HASHSIZE; i++) {
 		SLIST_FOREACH(pipe, &pipehash[i], next) {
-			if (pipe->idle_heap.elements > 0 &&
-			    DN_KEY_LT(pipe->idle_heap.p[0].key, pipe->V)) {
+			if (pipe->idle_heap->elements > 0 &&
+			    DN_KEY_LT(pipe->idle_heap->p[0].key, pipe->V)) {
 				struct dn_flow_queue *q =
-				    pipe->idle_heap.p[0].object;
+				    pipe->idle_heap->p[0].object;
 
-				heap_extract(&(pipe->idle_heap), NULL);
+				heap_extract(pipe->idle_heap, NULL);
 				/* Mark timestamp as invalid. */
 				q->S = q->F + 1;
 				pipe->sum -= q->fs->weight;
@@ -1454,8 +1286,8 @@ dummynet_io(struct mbuf **m0, int dir, s
 		}
 	} else {			/* WF2Q. */
 		if (pipe->idle_time < curr_time &&
-		    pipe->scheduler_heap.elements == 0 &&
-		    pipe->not_eligible_heap.elements == 0) {
+		    pipe->scheduler_heap->elements == 0 &&
+		    pipe->not_eligible_heap->elements == 0) {
 			/* Calculate available burst size. */
 			pipe->numbytes +=
 			    (curr_time - pipe->idle_time - 1) * pipe->bandwidth;
@@ -1501,13 +1333,13 @@ dummynet_io(struct mbuf **m0, int dir, s
 			q->S = pipe->V;
 			pipe->sum += fs->weight; /* Add weight of new queue. */
 		} else {
-			heap_extract(&(pipe->idle_heap), q);
+			heap_extract(pipe->idle_heap, q);
 			q->S = MAX64(q->F, pipe->V);
 		}
 		q->F = q->S + div64(len << MY_M, fs->weight);
 
-		if (pipe->not_eligible_heap.elements == 0 &&
-		    pipe->scheduler_heap.elements == 0)
+		if (pipe->not_eligible_heap->elements == 0 &&
+		    pipe->scheduler_heap->elements == 0)
 			pipe->V = MAX64(q->S, pipe->V);
 		fs->backlogged++;
 		/*
@@ -1524,13 +1356,13 @@ dummynet_io(struct mbuf **m0, int dir, s
 		 * SCH+NEH, we only need to look into NEH.
 		 */
 		if (DN_KEY_GT(q->S, pipe->V)) {		/* Not eligible. */
-			if (pipe->scheduler_heap.elements == 0)
+			if (pipe->scheduler_heap->elements == 0)
 				printf("dummynet: ++ ouch! not eligible but empty scheduler!\n");
-			heap_insert(&(pipe->not_eligible_heap), q->S, q);
+			heap_insert(pipe->not_eligible_heap, q->S, q);
 		} else {
-			heap_insert(&(pipe->scheduler_heap), q->F, q);
+			heap_insert(pipe->scheduler_heap, q->F, q);
 			if (pipe->numbytes >= 0) {	 /* Pipe is idle. */
-				if (pipe->scheduler_heap.elements != 1)
+				if (pipe->scheduler_heap->elements != 1)
 					printf("dummynet: OUCH! pipe should have been idle!\n");
 				DPRINTF(("dummynet: waking up pipe %d at %d\n",
 				    pipe->pipe_nr, (int)(q->F >> MY_M)));
@@ -1613,9 +1445,9 @@ purge_pipe(struct dn_pipe *pipe)
 
     dn_free_pkts(pipe->head);
 
-    heap_free( &(pipe->scheduler_heap) );
-    heap_free( &(pipe->not_eligible_heap) );
-    heap_free( &(pipe->idle_heap) );
+    heap_free( pipe->scheduler_heap );
+    heap_free( pipe->not_eligible_heap );
+    heap_free( pipe->idle_heap );
 }
 
 /*
@@ -1790,21 +1622,28 @@ config_pipe(struct dn_pipe *p)
 		pipe = locate_pipe(p->pipe_nr);	/* locate pipe */
 
 		if (pipe == NULL) {		/* new pipe */
-			pipe = malloc(sizeof(struct dn_pipe), M_DUMMYNET,
+			pipe = malloc(sizeof(struct dn_pipe) +
+				3 * sizeof(struct dn_heap), M_DUMMYNET,
 			    M_NOWAIT | M_ZERO);
 			if (pipe == NULL) {
 				DUMMYNET_UNLOCK();
 				printf("dummynet: no memory for new pipe\n");
 				return (ENOMEM);
 			}
+
+			/* the heaps are right after the pipe */
+			pipe->scheduler_heap = (struct dn_heap *)(pipe + 1);
+			pipe->not_eligible_heap = pipe->scheduler_heap + 1;
+			pipe->idle_heap = pipe->scheduler_heap + 2;
+
 			pipe->pipe_nr = p->pipe_nr;
 			pipe->fs.pipe = pipe;
 			/*
 			 * idle_heap is the only one from which
 			 * we extract from the middle.
 			 */
-			pipe->idle_heap.size = pipe->idle_heap.elements = 0;
-			pipe->idle_heap.offset =
+			pipe->idle_heap->size = pipe->idle_heap->elements = 0;
+			pipe->idle_heap->offset =
 			    offsetof(struct dn_flow_queue, heap_pos);
 		} else {
 			/* Flush accumulated credit for all queues. */
@@ -2048,10 +1887,10 @@ delete_pipe(struct dn_pipe *p)
 	if (fs->pipe != NULL) {
 	    /* Update total weight on parent pipe and cleanup parent heaps. */
 	    fs->pipe->sum -= fs->weight * fs->backlogged ;
-	    fs_remove_from_heap(&(fs->pipe->not_eligible_heap), fs);
-	    fs_remove_from_heap(&(fs->pipe->scheduler_heap), fs);
+	    fs_remove_from_heap(fs->pipe->not_eligible_heap, fs);
+	    fs_remove_from_heap(fs->pipe->scheduler_heap, fs);
 #if 1	/* XXX should i remove from idle_heap as well ? */
-	    fs_remove_from_heap(&(fs->pipe->idle_heap), fs);
+	    fs_remove_from_heap(fs->pipe->idle_heap, fs);
 #endif
 	}
 	purge_flow_set(fs, 1);

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 12:03:30 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 CF864106566C;
	Tue,  5 Jan 2010 12:03:30 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id BEDD58FC13;
	Tue,  5 Jan 2010 12:03:30 +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 o05C3UuM090084;
	Tue, 5 Jan 2010 12:03:30 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o05C3Uq0090082;
	Tue, 5 Jan 2010 12:03:30 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001051203.o05C3Uq0090082@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Tue, 5 Jan 2010 12:03:30 +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: r201572 - user/luigi/ipfw3-head/sys/netinet/ipfw
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: Tue, 05 Jan 2010 12:03:30 -0000

Author: luigi
Date: Tue Jan  5 12:03:30 2010
New Revision: 201572
URL: http://svn.freebsd.org/changeset/base/201572

Log:
  remove stale comment

Modified:
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Tue Jan  5 11:39:48 2010	(r201571)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Tue Jan  5 12:03:30 2010	(r201572)
@@ -52,8 +52,6 @@ __FBSDID("$FreeBSD$");
  * 000601: WF2Q support
  * 000106: large rewrite, use heaps to handle very many pipes.
  * 980513:	initial release
- *
- * include files marked with XXX are probably not needed
  */
 
 #include <sys/param.h>

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 12:29:03 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 AFA2C1065696;
	Tue,  5 Jan 2010 12:29:03 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 853AF8FC18;
	Tue,  5 Jan 2010 12:29:03 +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 o05CT3Jx095740;
	Tue, 5 Jan 2010 12:29:03 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o05CT3AN095738;
	Tue, 5 Jan 2010 12:29:03 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001051229.o05CT3AN095738@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Tue, 5 Jan 2010 12:29:03 +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: r201573 - user/luigi/ipfw3-head/sys/netinet/ipfw
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: Tue, 05 Jan 2010 12:29:03 -0000

Author: luigi
Date: Tue Jan  5 12:29:03 2010
New Revision: 201573
URL: http://svn.freebsd.org/changeset/base/201573

Log:
  add testing code (to be run in userland)

Modified:
  user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c	Tue Jan  5 12:03:30 2010	(r201572)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c	Tue Jan  5 12:29:03 2010	(r201573)
@@ -32,10 +32,27 @@ __FBSDID("$FreeBSD$");
  */
 
 #include <sys/param.h>
+#ifdef _KERNEL
 #include <sys/systm.h>
 #include <sys/malloc.h>
 #include <sys/kernel.h>
 #include <netinet/ipfw/dn_heap.h>
+#define log(x, arg...)
+
+#else /* !_KERNEL */
+
+#include <stdio.h>
+#include <strings.h>
+#include <stdlib.h>
+#include  "dn_heap.h"
+#define log(x, arg...)	fprintf(stderr, ## arg)
+#define panic(x...)	fprintf(stderr, ## x), exit(1)
+#define MALLOC_DEFINE(a, b, c)
+static void *my_malloc(int s) {	return malloc(s); }
+static void my_free(void *p) {	free(p); }
+#define malloc(s, t, w)	my_malloc(s)
+#define free(p, t)	my_free(p)
+#endif /* !_KERNEL */
 
 MALLOC_DEFINE(M_DN_HEAP, "dummynet", "dummynet heap");
 
@@ -108,6 +125,7 @@ heap_insert(struct dn_heap *h, uint64_t 
 {
 	int son = h->elements;
 
+	//log("%s key %llu p %p\n", __FUNCTION__, key1, p);
 	if (p == NULL)	/* data already there, set starting point */
 		son = key1;
 	else {/* insert new element at the end, possibly resize */
@@ -249,3 +267,32 @@ heap_free(struct dn_heap *h)
 		free(h->p, M_DN_HEAP);
 	bzero(h, sizeof(*h) );
 }
+
+#ifndef _KERNEL
+/*
+ * testing code for the heap
+ */
+int
+main(int argc, char *argv[])
+{
+	struct dn_heap h;
+	int i, n;
+	struct timeval tv;
+	uint64_t k;
+
+	n = (argc > 1) ? atoi(argv[1]) : 0;
+	if (n <= 0 || n > 10000)
+		n = 100;
+	bzero(&h, sizeof(h));
+	gettimeofday(&tv, NULL);
+	srandom(tv.tv_usec);
+	heap_init(&h, 0);
+	for (i=0; i < n; i++)
+		heap_insert(&h, random(), (void *)(100+i));
+	for (i=0; h.elements > 0; i++) {
+		printf("%d key %llu, val %p\n",
+			i, h.p[0].key, h.p[0].object);
+		heap_extract(&h, NULL);
+	}
+}
+#endif

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 15:04:08 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 CE68E1065679;
	Tue,  5 Jan 2010 15:04:08 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id BD1E78FC21;
	Tue,  5 Jan 2010 15:04:08 +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 o05F48Kc031243;
	Tue, 5 Jan 2010 15:04:08 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o05F48vG031241;
	Tue, 5 Jan 2010 15:04:08 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001051504.o05F48vG031241@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Tue, 5 Jan 2010 15:04:08 +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: r201589 - user/luigi/ipfw3-head/sys/netinet/ipfw
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: Tue, 05 Jan 2010 15:04:09 -0000

Author: luigi
Date: Tue Jan  5 15:04:08 2010
New Revision: 201589
URL: http://svn.freebsd.org/changeset/base/201589

Log:
  more debugging stuff

Modified:
  user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c	Tue Jan  5 14:03:46 2010	(r201588)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c	Tue Jan  5 15:04:08 2010	(r201589)
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
 #include <stdio.h>
 #include <strings.h>
 #include <stdlib.h>
+
 #include  "dn_heap.h"
 #define log(x, arg...)	fprintf(stderr, ## arg)
 #define panic(x...)	fprintf(stderr, ## x), exit(1)
@@ -64,14 +65,10 @@ MALLOC_DEFINE(M_DN_HEAP, "dummynet", "du
  *
  * heap_init() is called to expand the heap when needed.
  * Increment size in blocks of 16 entries.
- * XXX failure to allocate a new element is a pretty bad failure
- * as we basically stall a whole queue forever!!
  * Returns 1 on error, 0 on success
  */
 #define HEAP_FATHER(x) ( ( (x) - 1 ) / 2 )
-#define HEAP_LEFT(x) ( 2*(x) + 1 )
-#define HEAP_IS_LEFT(x) ( (x) & 1 )
-#define HEAP_RIGHT(x) ( 2*(x) + 2 )
+#define HEAP_LEFT(x) ( (x)+(x) + 1 )
 #define	HEAP_SWAP(a, b, buffer) { buffer = a ; a = b ; b = buffer ; }
 #define HEAP_INCREMENT	15
 
@@ -137,7 +134,8 @@ heap_insert(struct dn_heap *h, uint64_t 
 		h->p[son].key = key1;
 		h->elements++;
 	}
-	while (son > 0) {			/* bubble up */
+	/* make sure that son >= father along the path */
+	while (son > 0) {
 		int father = HEAP_FATHER(son);
 		struct dn_heap_entry tmp;
 
@@ -164,8 +162,9 @@ heap_extract(struct dn_heap *h, void *ob
 		printf("%s: empty heap 0x%p\n", __FUNCTION__, h);
 		return;
 	}
-	father = 0; /* default: move up smallest child */
-	if (obj != NULL) { /* extract specific element, index is at offset */
+	if (obj == NULL)
+		father = 0; /* default: move up smallest child */
+	else { /* extract specific element, index is at offset */
 		if (h->offset <= 0)
 			panic("%s: extract from middle not set on %p\n",
 				__FUNCTION__, h);
@@ -175,16 +174,20 @@ heap_extract(struct dn_heap *h, void *ob
 				__FUNCTION__, father, h->elements);
 		}
 	}
+	/*
+	 * below, father is the index of the empty element, which
+	 * we replace at each step with the smallest child until we
+	 * reach the bottom level.
+	 */
+	// XXX why removing RESET_OFFSET increases runtime by 10% ?
 	RESET_OFFSET(h, father);
-	child = HEAP_LEFT(father);		/* left child */
-	while (child <= max) {		/* valid entry */
+	while ( (child = HEAP_LEFT(father)) <= max) {
 		if (child != max &&
 		    DN_KEY_LT(h->p[child+1].key, h->p[child].key) )
 			child++; /* take right child, otherwise left */
 		h->p[father] = h->p[child];
 		SET_OFFSET(h, father);
 		father = child;
-		child = HEAP_LEFT(child); /* prepare for next loop */
 	}
 	h->elements--;
 	if (father != max) {
@@ -276,23 +279,34 @@ int
 main(int argc, char *argv[])
 {
 	struct dn_heap h;
-	int i, n;
-	struct timeval tv;
-	uint64_t k;
+	int i, n, n2, n3;
 
+	/* n = elements, n2 = cycles */
 	n = (argc > 1) ? atoi(argv[1]) : 0;
-	if (n <= 0 || n > 10000)
+	if (n <= 0 || n > 1000000)
 		n = 100;
+	n2 = (argc > 2) ? atoi(argv[2]) : 0;
+	if (n2 <= 0)
+		n = 1000000;
+	n3 = (argc > 3) ? atoi(argv[3]) : 0;
 	bzero(&h, sizeof(h));
-	gettimeofday(&tv, NULL);
-	srandom(tv.tv_usec);
-	heap_init(&h, 0);
-	for (i=0; i < n; i++)
-		heap_insert(&h, random(), (void *)(100+i));
-	for (i=0; h.elements > 0; i++) {
-		printf("%d key %llu, val %p\n",
-			i, h.p[0].key, h.p[0].object);
-		heap_extract(&h, NULL);
+	heap_init(&h, n);
+	while (n2-- > 0) {
+		uint64_t prevk = 0;
+		for (i=0; i < n; i++)
+			heap_insert(&h, n3 ? n-i: random(), (void *)(100+i));
+		
+		for (i=0; h.elements > 0; i++) {
+			uint64_t k = h.p[0].key;
+			if (k < prevk)
+				panic("wrong sequence\n");
+			prevk = k;
+			if (0)
+			printf("%d key %llu, val %p\n",
+				i, h.p[0].key, h.p[0].object);
+			heap_extract(&h, NULL);
+		}
 	}
+	return 0;
 }
 #endif

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 15:15:16 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 09795106566B;
	Tue,  5 Jan 2010 15:15:16 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id DFB188FC0A;
	Tue,  5 Jan 2010 15:15:15 +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 o05FFFDD033796;
	Tue, 5 Jan 2010 15:15:15 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o05FFFtd033766;
	Tue, 5 Jan 2010 15:15:15 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001051515.o05FFFtd033766@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Tue, 5 Jan 2010 15:15:15 +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: r201590 - in user/ed/utmpx: . bin/csh bin/date bin/pax
	contrib/opie/libopie contrib/tcsh contrib/telnet/telnetd
	crypto/openssh include lib/libc/gen lib/libopie lib/libutil
	libexec/comsa...
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: Tue, 05 Jan 2010 15:15:16 -0000

Author: ed
Date: Tue Jan  5 15:15:15 2010
New Revision: 201590
URL: http://svn.freebsd.org/changeset/base/201590

Log:
  Add a stub <utmpx.h> implementation and remove <utmp.h>.
  
  The functions in libc are just empty, so right now logging is actually
  broken. The tree should build, but I had to disable some apps that I
  haven't ported to <utmpx.h> yet. TODO.
  
  Also remove login(3), logout(3) and logwtmp(3). libutil doesn't use
  symbol versioning, so I am considering bumping the major number.

Added:
  user/ed/utmpx/include/utmpx.h   (contents, props changed)
  user/ed/utmpx/lib/libc/gen/getutxent.c   (contents, props changed)
Deleted:
  user/ed/utmpx/lib/libutil/login.3
  user/ed/utmpx/lib/libutil/login.c
  user/ed/utmpx/lib/libutil/logout.3
  user/ed/utmpx/lib/libutil/logout.c
  user/ed/utmpx/lib/libutil/logwtmp.3
  user/ed/utmpx/lib/libutil/logwtmp.c
Modified:
  user/ed/utmpx/ObsoleteFiles.inc
  user/ed/utmpx/bin/csh/config.h
  user/ed/utmpx/bin/date/Makefile
  user/ed/utmpx/bin/date/date.c
  user/ed/utmpx/bin/pax/gen_subs.c
  user/ed/utmpx/contrib/opie/libopie/getutmpentry.c
  user/ed/utmpx/contrib/opie/libopie/insecure.c
  user/ed/utmpx/contrib/tcsh/tc.who.c
  user/ed/utmpx/contrib/telnet/telnetd/sys_term.c
  user/ed/utmpx/contrib/telnet/telnetd/telnetd.c
  user/ed/utmpx/crypto/openssh/config.h
  user/ed/utmpx/crypto/openssh/sshd.c
  user/ed/utmpx/include/Makefile
  user/ed/utmpx/include/utmp.h
  user/ed/utmpx/lib/libc/gen/Makefile.inc
  user/ed/utmpx/lib/libc/gen/Symbol.map
  user/ed/utmpx/lib/libopie/Makefile
  user/ed/utmpx/lib/libopie/config.h
  user/ed/utmpx/lib/libutil/Makefile
  user/ed/utmpx/lib/libutil/libutil.h
  user/ed/utmpx/libexec/comsat/comsat.c
  user/ed/utmpx/libexec/ftpd/logwtmp.c
  user/ed/utmpx/libexec/rlogind/Makefile
  user/ed/utmpx/libexec/rlogind/rlogind.c
  user/ed/utmpx/libexec/rpc.rusersd/Makefile
  user/ed/utmpx/libexec/rpc.rusersd/rusers_proc.c
  user/ed/utmpx/libexec/talkd/Makefile
  user/ed/utmpx/libexec/talkd/process.c
  user/ed/utmpx/libexec/telnetd/Makefile
  user/ed/utmpx/sbin/init/init.c
  user/ed/utmpx/sbin/reboot/Makefile
  user/ed/utmpx/sbin/reboot/reboot.c
  user/ed/utmpx/usr.bin/Makefile
  user/ed/utmpx/usr.bin/systat/Makefile
  user/ed/utmpx/usr.bin/systat/vmstat.c
  user/ed/utmpx/usr.bin/users/Makefile
  user/ed/utmpx/usr.bin/users/users.c
  user/ed/utmpx/usr.bin/w/Makefile
  user/ed/utmpx/usr.bin/w/w.c
  user/ed/utmpx/usr.bin/wall/Makefile
  user/ed/utmpx/usr.bin/wall/wall.c
  user/ed/utmpx/usr.bin/who/Makefile
  user/ed/utmpx/usr.bin/who/who.c
  user/ed/utmpx/usr.bin/write/Makefile
  user/ed/utmpx/usr.bin/write/write.c
  user/ed/utmpx/usr.sbin/Makefile
  user/ed/utmpx/usr.sbin/ac/Makefile
  user/ed/utmpx/usr.sbin/ac/ac.c
  user/ed/utmpx/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile
  user/ed/utmpx/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c
  user/ed/utmpx/usr.sbin/rwhod/Makefile
  user/ed/utmpx/usr.sbin/rwhod/rwhod.c
  user/ed/utmpx/usr.sbin/syslogd/Makefile
  user/ed/utmpx/usr.sbin/syslogd/syslogd.c
  user/ed/utmpx/usr.sbin/timed/timed/master.c
  user/ed/utmpx/usr.sbin/timed/timed/slave.c

Modified: user/ed/utmpx/ObsoleteFiles.inc
==============================================================================
--- user/ed/utmpx/ObsoleteFiles.inc	Tue Jan  5 15:04:08 2010	(r201589)
+++ user/ed/utmpx/ObsoleteFiles.inc	Tue Jan  5 15:15:15 2010	(r201590)
@@ -14,6 +14,10 @@
 # The file is partitioned: OLD_FILES first, then OLD_LIBS and OLD_DIRS last.
 #
 
+# 20100104: login(3), logout(3) and logwtmp(3) removed
+OLD_FILES+=usr/share/man/man3/login.3.gz
+OLD_FILES+=usr/share/man/man3/logout.3.gz
+OLD_FILES+=usr/share/man/man3/logwtmp.3.gz
 # 20100103: ntptrace(8) removed
 OLD_FILES+=usr/sbin/ntptrace
 OLD_FILES+=usr/share/man/man8/ntptrace.8.gz

Modified: user/ed/utmpx/bin/csh/config.h
==============================================================================
--- user/ed/utmpx/bin/csh/config.h	Tue Jan  5 15:04:08 2010	(r201589)
+++ user/ed/utmpx/bin/csh/config.h	Tue Jan  5 15:15:15 2010	(r201590)
@@ -130,10 +130,10 @@
 #define HAVE_STRUCT_UTMP_UT_HOST 1
 
 /* Define to 1 if `ut_tv' is member of `struct utmp'. */
-/* #undef HAVE_STRUCT_UTMP_UT_TV */
+#define HAVE_STRUCT_UTMP_UT_TV 1
 
 /* Define to 1 if `ut_user' is member of `struct utmp'. */
-/* #undef HAVE_STRUCT_UTMP_UT_USER */
+#define HAVE_STRUCT_UTMP_UT_USER 1
 
 /* Define to 1 if `ut_xtime' is member of `struct utmp'. */
 /* #undef HAVE_STRUCT_UTMP_UT_XTIME */
@@ -159,10 +159,10 @@
 #define HAVE_UNISTD_H 1
 
 /* Define to 1 if you have the <utmpx.h> header file. */
-/* #undef HAVE_UTMPX_H */
+#define HAVE_UTMPX_H 1
 
 /* Define to 1 if you have the <utmp.h> header file. */
-#define HAVE_UTMP_H 1
+/* #undef HAVE_UTMP_H */
 
 /* Define to 1 if you have the <wchar.h> header file. */
 #define HAVE_WCHAR_H 1

Modified: user/ed/utmpx/bin/date/Makefile
==============================================================================
--- user/ed/utmpx/bin/date/Makefile	Tue Jan  5 15:04:08 2010	(r201589)
+++ user/ed/utmpx/bin/date/Makefile	Tue Jan  5 15:15:15 2010	(r201590)
@@ -3,7 +3,5 @@
 
 PROG=	date
 SRCS=	date.c netdate.c vary.c
-DPADD=	${LIBULOG}
-LDADD=	-lulog
 
 .include <bsd.prog.mk>

Modified: user/ed/utmpx/bin/date/date.c
==============================================================================
--- user/ed/utmpx/bin/date/date.c	Tue Jan  5 15:04:08 2010	(r201589)
+++ user/ed/utmpx/bin/date/date.c	Tue Jan  5 15:15:15 2010	(r201590)
@@ -52,9 +52,8 @@ __FBSDID("$FreeBSD$");
 #include <stdlib.h>
 #include <string.h>
 #include <syslog.h>
-#define	_ULOG_POSIX_NAMES
-#include <ulog.h>
 #include <unistd.h>
+#include <utmpx.h>
 
 #include "extern.h"
 #include "vary.h"

Modified: user/ed/utmpx/bin/pax/gen_subs.c
==============================================================================
--- user/ed/utmpx/bin/pax/gen_subs.c	Tue Jan  5 15:04:08 2010	(r201589)
+++ user/ed/utmpx/bin/pax/gen_subs.c	Tue Jan  5 15:15:15 2010	(r201590)
@@ -45,7 +45,6 @@ __FBSDID("$FreeBSD$");
 #include <langinfo.h>
 #include <stdint.h>
 #include <stdio.h>
-#include <utmp.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
@@ -66,10 +65,6 @@ __FBSDID("$FreeBSD$");
 #define OLDFRMTM	"%b %e  %Y"
 #define CURFRMTD	"%e %b %H:%M"
 #define OLDFRMTD	"%e %b  %Y"
-#ifndef UT_NAMESIZE
-#define UT_NAMESIZE	8
-#endif
-#define UT_GRPSIZE	6
 
 static int d_first = -1;
 
@@ -116,9 +111,8 @@ ls_list(ARCHD *arcn, time_t now, FILE *f
 	 */
 	if (strftime(f_date,DATELEN,timefrmt,localtime(&(sbp->st_mtime))) == 0)
 		f_date[0] = '\0';
-	(void)fprintf(fp, "%s%2u %-*s %-*s ", f_mode, sbp->st_nlink,
-		UT_NAMESIZE, name_uid(sbp->st_uid, 1), UT_GRPSIZE,
-		name_gid(sbp->st_gid, 1));
+	(void)fprintf(fp, "%s%2u %-12s %-12s ", f_mode, sbp->st_nlink,
+		name_uid(sbp->st_uid, 1), name_gid(sbp->st_gid, 1));
 
 	/*
 	 * print device id's for devices, or sizes for other nodes

Modified: user/ed/utmpx/contrib/opie/libopie/getutmpentry.c
==============================================================================
--- user/ed/utmpx/contrib/opie/libopie/getutmpentry.c	Tue Jan  5 15:04:08 2010	(r201589)
+++ user/ed/utmpx/contrib/opie/libopie/getutmpentry.c	Tue Jan  5 15:15:15 2010	(r201590)
@@ -15,13 +15,14 @@ you didn't get a copy, you may request o
 #include "opie_cfg.h"
 #include <stdio.h>
 #include <sys/types.h>
-#include <utmp.h>
 
 #if DOUTMPX
 #include <utmpx.h>
 #define setutent setutxent
 #define getutline(x) getutxline(x)
 #define utmp utmpx
+#else
+#include <utmp.h>
 #endif /* DOUTMPX */
 
 #if HAVE_STRING_H

Modified: user/ed/utmpx/contrib/opie/libopie/insecure.c
==============================================================================
--- user/ed/utmpx/contrib/opie/libopie/insecure.c	Tue Jan  5 15:04:08 2010	(r201589)
+++ user/ed/utmpx/contrib/opie/libopie/insecure.c	Tue Jan  5 15:15:15 2010	(r201590)
@@ -39,11 +39,12 @@ $FreeBSD$
 #include <sys/param.h>
 #include <unistd.h>
 
-#include <utmp.h>
 #if DOUTMPX
 #include <utmpx.h>
 #define utmp utmpx
 #define endutent endutxent
+#else
+#include <utmp.h>
 #endif	/* DOUTMPX */
 
 #if HAVE_SYS_UTSNAME_H

Modified: user/ed/utmpx/contrib/tcsh/tc.who.c
==============================================================================
--- user/ed/utmpx/contrib/tcsh/tc.who.c	Tue Jan  5 15:04:08 2010	(r201589)
+++ user/ed/utmpx/contrib/tcsh/tc.who.c	Tue Jan  5 15:15:15 2010	(r201590)
@@ -55,6 +55,8 @@ RCSID("$tcsh: tc.who.c,v 3.51 2006/03/03
 #  define TCSH_PATH_UTMP _PATH_UTMPX
 # elif defined(UTMPX_FILE)
 #  define TCSH_PATH_UTMP UTMPX_FILE
+# else
+#  define TCSH_PATH_UTMP "/nonexistent"
 # endif /* __UTMPX_FILE && !UTMPX_FILE */
 # ifdef TCSH_PATH_UTMP
 #  define utmp utmpx

Modified: user/ed/utmpx/contrib/telnet/telnetd/sys_term.c
==============================================================================
--- user/ed/utmpx/contrib/telnet/telnetd/sys_term.c	Tue Jan  5 15:04:08 2010	(r201589)
+++ user/ed/utmpx/contrib/telnet/telnetd/sys_term.c	Tue Jan  5 15:15:15 2010	(r201590)
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/tty.h>
 #include <libutil.h>
 #include <stdlib.h>
+#include <ulog.h>
 
 #include "telnetd.h"
 #include "pathnames.h"
@@ -1314,8 +1315,7 @@ cleanup(int sig __unused)
 	 */
 	sigfillset(&mask);
 	sigprocmask(SIG_SETMASK, &mask, NULL);
-	if (logout(p))
-		logwtmp(p, "", "");
+	ulog_logout(p);
 	(void)chmod(line, 0666);
 	(void)chown(line, 0, 0);
 	*p = 'p';

Modified: user/ed/utmpx/contrib/telnet/telnetd/telnetd.c
==============================================================================
--- user/ed/utmpx/contrib/telnet/telnetd/telnetd.c	Tue Jan  5 15:04:08 2010	(r201589)
+++ user/ed/utmpx/contrib/telnet/telnetd/telnetd.c	Tue Jan  5 15:15:15 2010	(r201590)
@@ -47,7 +47,6 @@ __FBSDID("$FreeBSD$");
 #include <libutil.h>
 #include <paths.h>
 #include <termcap.h>
-#include <utmp.h>
 
 #include <arpa/inet.h>
 
@@ -61,7 +60,6 @@ int	auth_level = 0;
 #include <libtelnet/misc.h>
 
 char	remote_hostname[MAXHOSTNAMELEN];
-size_t	utmp_len = sizeof(remote_hostname) - 1;
 int	registerd_host_only = 0;
 
 
@@ -286,12 +284,6 @@ main(int argc, char *argv[])
 #endif
 			break;
 
-		case 'u':
-			utmp_len = (size_t)atoi(optarg);
-			if (utmp_len >= sizeof(remote_hostname))
-				utmp_len = sizeof(remote_hostname) - 1;
-			break;
-
 		case 'U':
 			registerd_host_only = 1;
 			break;
@@ -661,7 +653,6 @@ terminaltypeok(char *s)
 void
 doit(struct sockaddr *who)
 {
-	int err_; /* XXX */
 	int ptynum;
 
 	/*
@@ -693,13 +684,6 @@ doit(struct sockaddr *who)
 	Please contact your net administrator");
 	remote_hostname[sizeof(remote_hostname) - 1] = '\0';
 
-	trimdomain(remote_hostname, UT_HOSTSIZE);
-	if (!isdigit(remote_hostname[0]) && strlen(remote_hostname) > utmp_len)
-		err_ = getnameinfo(who, who->sa_len, remote_hostname,
-				  sizeof(remote_hostname), NULL, 0,
-				  NI_NUMERICHOST);
-		/* XXX: do 'err_' check */
-
 	(void) gethostname(host_name, sizeof(host_name) - 1);
 	host_name[sizeof(host_name) - 1] = '\0';
 	hostname = host_name;

Modified: user/ed/utmpx/crypto/openssh/config.h
==============================================================================
--- user/ed/utmpx/crypto/openssh/config.h	Tue Jan  5 15:04:08 2010	(r201589)
+++ user/ed/utmpx/crypto/openssh/config.h	Tue Jan  5 15:15:15 2010	(r201590)
@@ -85,13 +85,13 @@
 /* #undef CONF_UTMPX_FILE */
 
 /* Define if you want to specify the path to your utmp file */
-#define CONF_UTMP_FILE "/var/run/utmp"
+/* #undef CONF_UTMP_FILE */
 
 /* Define if you want to specify the path to your wtmpx file */
 /* #undef CONF_WTMPX_FILE */
 
 /* Define if you want to specify the path to your wtmp file */
-#define CONF_WTMP_FILE "/var/log/wtmp"
+/* #undef CONF_WTMP_FILE */
 
 /* Define if your platform needs to skip post auth file descriptor passing */
 /* #undef DISABLE_FD_PASSING */
@@ -112,13 +112,13 @@
 /* #undef DISABLE_SHADOW */
 
 /* Define if you don't want to use utmp */
-/* #undef DISABLE_UTMP */
+#define DISABLE_UTMP 1
 
 /* Define if you don't want to use utmpx */
-#define DISABLE_UTMPX 1
+/* #undef DISABLE_UTMPX */
 
 /* Define if you don't want to use wtmp */
-/* #undef DISABLE_WTMP */
+#define DISABLE_WTMP 1
 
 /* Define if you don't want to use wtmpx */
 #define DISABLE_WTMPX 1
@@ -319,7 +319,7 @@
 /* #undef HAVE_ENDUTENT */
 
 /* Define to 1 if you have the `endutxent' function. */
-/* #undef HAVE_ENDUTXENT */
+#define HAVE_ENDUTXENT 1
 
 /* Define if your system has /etc/default/login */
 /* #undef HAVE_ETC_DEFAULT_LOGIN */
@@ -445,13 +445,13 @@
 /* #undef HAVE_GETUTLINE */
 
 /* Define to 1 if you have the `getutxent' function. */
-/* #undef HAVE_GETUTXENT */
+#define HAVE_GETUTXENT 1
 
 /* Define to 1 if you have the `getutxid' function. */
 /* #undef HAVE_GETUTXID */
 
 /* Define to 1 if you have the `getutxline' function. */
-/* #undef HAVE_GETUTXLINE */
+#define HAVE_GETUTXLINE 1
 
 /* Define to 1 if you have the `get_default_context_with_level' function. */
 /* #undef HAVE_GET_DEFAULT_CONTEXT_WITH_LEVEL */
@@ -487,7 +487,7 @@
 #define HAVE_HOST_IN_UTMP 1
 
 /* Define if you have ut_host in utmpx.h */
-/* #undef HAVE_HOST_IN_UTMPX */
+#define HAVE_HOST_IN_UTMPX 1
 
 /* Define to 1 if you have the <iaf.h> header file. */
 /* #undef HAVE_IAF_H */
@@ -499,7 +499,7 @@
 /* #undef HAVE_ID_IN_UTMP */
 
 /* Define if you have ut_id in utmpx.h */
-/* #undef HAVE_ID_IN_UTMPX */
+#define HAVE_ID_IN_UTMPX 1
 
 /* Define to 1 if you have the `inet_aton' function. */
 #define HAVE_INET_ATON 1
@@ -574,7 +574,7 @@
 /* #undef HAVE_LINUX_IF_TUN_H */
 
 /* Define if your libraries define login() */
-#define HAVE_LOGIN 1
+/* #undef HAVE_LOGIN */
 
 /* Define to 1 if you have the <login_cap.h> header file. */
 #define HAVE_LOGIN_CAP_H 1
@@ -704,7 +704,7 @@
 /* #undef HAVE_PUTUTLINE */
 
 /* Define to 1 if you have the `pututxline' function. */
-/* #undef HAVE_PUTUTXLINE */
+#define HAVE_PUTUTXLINE 1
 
 /* Define if your password has a pw_change field */
 #define HAVE_PW_CHANGE_IN_PASSWD 1
@@ -800,7 +800,7 @@
 /* #undef HAVE_SETUTENT */
 
 /* Define to 1 if you have the `setutxent' function. */
-/* #undef HAVE_SETUTXENT */
+#define HAVE_SETUTXENT 1
 
 /* Define to 1 if you have the `setvbuf' function. */
 #define HAVE_SETVBUF 1
@@ -1043,7 +1043,7 @@
 /* #undef HAVE_TV_IN_UTMP */
 
 /* Define if you have ut_tv in utmpx.h */
-/* #undef HAVE_TV_IN_UTMPX */
+#define HAVE_TV_IN_UTMPX 1
 
 /* Define if you have ut_type in utmp.h */
 /* #undef HAVE_TYPE_IN_UTMP */
@@ -1091,10 +1091,10 @@
 /* #undef HAVE_UTMPXNAME */
 
 /* Define to 1 if you have the <utmpx.h> header file. */
-/* #undef HAVE_UTMPX_H */
+#define HAVE_UTMPX_H 1
 
 /* Define to 1 if you have the <utmp.h> header file. */
-#define HAVE_UTMP_H 1
+/* #undef HAVE_UTMP_H */
 
 /* define if you have u_char data type */
 #define HAVE_U_CHAR 1
@@ -1175,7 +1175,7 @@
 /* #undef KRB5 */
 
 /* Define if pututxline updates lastlog too */
-/* #undef LASTLOG_WRITE_PUTUTXLINE */
+#define LASTLOG_WRITE_PUTUTXLINE 1
 
 /* Define if you want TCP Wrappers support */
 #define LIBWRAP 1

Modified: user/ed/utmpx/crypto/openssh/sshd.c
==============================================================================
--- user/ed/utmpx/crypto/openssh/sshd.c	Tue Jan  5 15:04:08 2010	(r201589)
+++ user/ed/utmpx/crypto/openssh/sshd.c	Tue Jan  5 15:15:15 2010	(r201590)
@@ -73,7 +73,6 @@ __RCSID("$FreeBSD$");
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <utmp.h>
 
 #include <openssl/dh.h>
 #include <openssl/bn.h>
@@ -240,7 +239,7 @@ u_char *session_id2 = NULL;
 u_int session_id2_len = 0;
 
 /* record remote hostname or ip */
-u_int utmp_len = UT_HOSTSIZE;
+u_int utmp_len = MAXHOSTNAMELEN;
 
 /* options.max_startup sized array of fd ints */
 int *startup_pipes = NULL;

Modified: user/ed/utmpx/include/Makefile
==============================================================================
--- user/ed/utmpx/include/Makefile	Tue Jan  5 15:04:08 2010	(r201589)
+++ user/ed/utmpx/include/Makefile	Tue Jan  5 15:15:15 2010	(r201590)
@@ -23,8 +23,8 @@ INCS=	a.out.h ar.h assert.h bitstring.h 
 	stdbool.h stddef.h stdio.h stdlib.h string.h stringlist.h \
 	strings.h sysexits.h tar.h termios.h tgmath.h \
 	time.h timeconv.h timers.h ttyent.h \
-	ulimit.h unistd.h utime.h utmp.h uuid.h varargs.h vis.h wchar.h \
-	wctype.h wordexp.h
+	ulimit.h unistd.h utime.h utmp.h utmpx.h uuid.h varargs.h vis.h \
+	wchar.h wctype.h wordexp.h
 
 MHDRS=	float.h floatingpoint.h stdarg.h
 

Modified: user/ed/utmpx/include/utmp.h
==============================================================================
--- user/ed/utmpx/include/utmp.h	Tue Jan  5 15:04:08 2010	(r201589)
+++ user/ed/utmpx/include/utmp.h	Tue Jan  5 15:15:15 2010	(r201590)
@@ -1,73 +1,2 @@
-/*
- * Copyright (c) 1988, 1993
- *	The Regents of the University of California.  All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS 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.
- *
- *	@(#)utmp.h	8.2 (Berkeley) 1/21/94
- * $FreeBSD$
- */
-
-#ifndef	_UTMP_H_
-#define	_UTMP_H_
-
-#define	_PATH_UTMP	"/var/run/utmp"
-#define	_PATH_WTMP	"/var/log/wtmp"
-#define	_PATH_LASTLOG	"/var/log/lastlog"
-
-/*
- * XXX: These values are too low, but cannot be changed without breaking
- * the file format.  Right now pts(4) is limited to 1000 instances,
- * because /dev/pts/1000 would require UT_LINESIZE to be bigger.
- * UT_HOSTSIZE is also too small to hold most common hostnames or IPv6
- * addresses.
- */
-#define	UT_NAMESIZE	16	/* see MAXLOGNAME in <sys/param.h> */
-#define	UT_LINESIZE	8
-#define	UT_HOSTSIZE	16
-
-struct lastlog {
-	int32_t	ll_time;
-	char	ll_line[UT_LINESIZE];
-	char	ll_host[UT_HOSTSIZE];
-};
-
-struct utmp {
-	char	ut_line[UT_LINESIZE];
-	char	ut_name[UT_NAMESIZE];
-	char	ut_host[UT_HOSTSIZE];
-	int32_t	ut_time;
-};
-
-#endif /* !_UTMP_H_ */
+/* $FreeBSD$ */
+#error "<utmp.h> has been replaced by <utmpx.h>"

Added: user/ed/utmpx/include/utmpx.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/ed/utmpx/include/utmpx.h	Tue Jan  5 15:15:15 2010	(r201590)
@@ -0,0 +1,71 @@
+/*-
+ * Copyright (c) 2010 Ed Schouten <ed@FreeBSD.org>
+ * 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 AND CONTRIBUTORS ``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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _UTMPX_H_
+#define	_UTMPX_H_
+
+#include <sys/cdefs.h>
+#include <sys/_timeval.h>
+#include <sys/_types.h>
+
+#ifndef _PID_T_DECLARED
+typedef	__pid_t		pid_t;
+#define	_PID_T_DECLARED
+#endif
+
+struct utmpx {
+	char		ut_user[32];
+	char		ut_id[8];
+	char		ut_line[32];
+	char		ut_host[256];
+	pid_t		ut_pid;
+	short		ut_type;
+#define	EMPTY		0
+#define	BOOT_TIME	1
+#define	OLD_TIME	2
+#define	NEW_TIME	3
+#define	USER_PROCESS	4
+#define	INIT_PROCESS	5
+#define	LOGIN_PROCESS	6
+#define	DEAD_PROCESS	7
+#if __BSD_VISIBLE
+#define	SHUTDOWN_TIME	8
+#endif
+	struct timeval	ut_tv;
+};
+
+__BEGIN_DECLS
+void	endutxent(void);
+struct utmpx *getutxent(void);
+struct utmpx *getutxid(const struct utmpx *);
+struct utmpx *getutxline(const struct utmpx *);
+struct utmpx *pututxline(const struct utmpx *);
+void	setutxent(void);
+__END_DECLS
+
+#endif /* !_UTMPX_H_ */

Modified: user/ed/utmpx/lib/libc/gen/Makefile.inc
==============================================================================
--- user/ed/utmpx/lib/libc/gen/Makefile.inc	Tue Jan  5 15:04:08 2010	(r201589)
+++ user/ed/utmpx/lib/libc/gen/Makefile.inc	Tue Jan  5 15:15:15 2010	(r201590)
@@ -18,7 +18,7 @@ SRCS+=  __getosreldate.c __xuname.c \
 	gethostname.c getloadavg.c getlogin.c getmntinfo.c getnetgrent.c \
 	getosreldate.c getpagesize.c getpagesizes.c \
 	getpeereid.c getprogname.c getpwent.c getttyent.c \
-	getusershell.c getvfsbyname.c glob.c \
+	getutxent.c getusershell.c getvfsbyname.c glob.c \
 	initgroups.c isatty.c isinf.c isnan.c jrand48.c lcong48.c \
 	lockf.c lrand48.c mrand48.c nftw.c nice.c \
 	nlist.c nrand48.c opendir.c \

Modified: user/ed/utmpx/lib/libc/gen/Symbol.map
==============================================================================
--- user/ed/utmpx/lib/libc/gen/Symbol.map	Tue Jan  5 15:04:08 2010	(r201589)
+++ user/ed/utmpx/lib/libc/gen/Symbol.map	Tue Jan  5 15:15:15 2010	(r201590)
@@ -367,7 +367,13 @@ FBSD_1.1 {
 
 FBSD_1.2 {
 	basename_r;
+	endutxent;
 	getpagesizes;
+	getutxent;
+	getutxid;
+	getutxline;
+	pututxline;
+	setutxent;
 };
 
 FBSDprivate_1.0 {

Added: user/ed/utmpx/lib/libc/gen/getutxent.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/ed/utmpx/lib/libc/gen/getutxent.c	Tue Jan  5 15:15:15 2010	(r201590)
@@ -0,0 +1,71 @@
+/*-
+ * Copyright (c) 2010 Ed Schouten <ed@FreeBSD.org>
+ * 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 AND CONTRIBUTORS ``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.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <stdio.h>
+#include <utmpx.h>
+
+void
+endutxent(void)
+{
+}
+
+struct utmpx *
+getutxent(void)
+{
+
+	return (NULL);
+}
+
+struct utmpx *
+getutxid(const struct utmpx *id)
+{
+
+	return (NULL);
+}
+
+struct utmpx *
+getutxline(const struct utmpx *line)
+{
+
+	return (NULL);
+}
+
+struct utmpx *
+pututxline(const struct utmpx *utmpx)
+{
+
+	return (NULL);
+}
+
+void
+setutxent(void)
+{
+}

Modified: user/ed/utmpx/lib/libopie/Makefile
==============================================================================
--- user/ed/utmpx/lib/libopie/Makefile	Tue Jan  5 15:04:08 2010	(r201589)
+++ user/ed/utmpx/lib/libopie/Makefile	Tue Jan  5 15:15:15 2010	(r201590)
@@ -8,15 +8,14 @@ SHLIB_MAJOR=    6
 
 KEYFILE?=	\"/etc/opiekeys\"
 
-.PATH: ${DIST_DIR} ${OPIE_DIST}/libmissing
+.PATH: ${DIST_DIR}
 
 LIB=	opie
 SRCS=	atob8.c btoa8.c btoh.c challenge.c getsequence.c hash.c hashlen.c \
 	keycrunch.c lock.c lookup.c newseed.c parsechallenge.c passcheck.c \
 	passwd.c randomchallenge.c readpass.c unlock.c verify.c version.c \
 	btoe.c accessfile.c generator.c insecure.c getutmpentry.c \
-	readrec.c writerec.c open.c \
-	getutline.c pututline.c endutent.c setutent.c # from libmissing
+	readrec.c writerec.c open.c
 SRCS+=	opieextra.c
 INCS=	${OPIE_DIST}/opie.h
 

Modified: user/ed/utmpx/lib/libopie/config.h
==============================================================================
--- user/ed/utmpx/lib/libopie/config.h	Tue Jan  5 15:04:08 2010	(r201589)
+++ user/ed/utmpx/lib/libopie/config.h	Tue Jan  5 15:15:15 2010	(r201590)
@@ -216,7 +216,7 @@
 #define HAVE_GETUSERSHELL 1
 
 /* Define if you have the getutxline function.  */
-/* #undef HAVE_GETUTXLINE */
+#define HAVE_GETUTXLINE 1
 
 /* Define if you have the getwd function.  */
 /* #undef HAVE_GETWD */
@@ -231,7 +231,7 @@
 /* #undef HAVE_ON_EXIT */
 
 /* Define if you have the pututxline function.  */
-/* #undef HAVE_PUTUTXLINE */
+#define HAVE_PUTUTXLINE 1
 
 /* Define if you have the rindex function.  */
 /* #undef HAVE_RINDEX */
@@ -366,7 +366,7 @@
 #define HAVE_UNISTD_H 1
 
 /* Define if you have the <utmpx.h> header file.  */
-/* #undef HAVE_UTMPX_H */
+#define HAVE_UTMPX_H 1
 
 /* Define if you have the crypt library (-lcrypt).  */
 #define HAVE_LIBCRYPT 1

Modified: user/ed/utmpx/lib/libutil/Makefile
==============================================================================
--- user/ed/utmpx/lib/libutil/Makefile	Tue Jan  5 15:04:08 2010	(r201589)
+++ user/ed/utmpx/lib/libutil/Makefile	Tue Jan  5 15:15:15 2010	(r201590)
@@ -10,9 +10,9 @@ SHLIB_MAJOR= 8
 
 SRCS=	_secure_path.c auth.c expand_number.c flopen.c fparseln.c gr_util.c \
 	hexdump.c humanize_number.c kinfo_getfile.c kinfo_getvmmap.c kld.c \
-	login.c login_auth.c login_cap.c \
+	login_auth.c login_cap.c \
 	login_class.c login_crypt.c login_ok.c login_times.c login_tty.c \
-	logout.c logwtmp.c pidfile.c property.c pty.c pw_util.c realhostname.c \
+	pidfile.c property.c pty.c pw_util.c realhostname.c \
 	stub.c trimdomain.c uucplock.c
 INCS=	libutil.h login_cap.h
 
@@ -24,7 +24,7 @@ CFLAGS+= -DINET6
 
 CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../libc/gen/
 
-MAN+=	kld.3 login.3 login_auth.3 login_tty.3 logout.3 logwtmp.3 pty.3 \
+MAN+=	kld.3 login_auth.3 login_tty.3 pty.3 \
 	login_cap.3 login_class.3 login_times.3 login_ok.3 \
 	_secure_path.3 uucplock.3 property.3 auth.3 realhostname.3 \
 	realhostname_sa.3 trimdomain.3 fparseln.3 humanize_number.3 \

Modified: user/ed/utmpx/lib/libutil/libutil.h
==============================================================================
--- user/ed/utmpx/lib/libutil/libutil.h	Tue Jan  5 15:04:08 2010	(r201589)
+++ user/ed/utmpx/lib/libutil/libutil.h	Tue Jan  5 15:15:15 2010	(r201590)
@@ -90,7 +90,6 @@ struct pidfh {
 /* Avoid pulling in all the include files for no need */
 struct termios;
 struct winsize;
-struct utmp;
 struct in_addr;
 struct kinfo_file;
 struct kinfo_vmentry;
@@ -102,10 +101,7 @@ int	extattr_namespace_to_string(int _att
 int	extattr_string_to_namespace(const char *_string, int *_attrnamespace);
 int	flopen(const char *_path, int _flags, ...);
 void	hexdump(const void *ptr, int length, const char *hdr, int flags);
-void	login(struct utmp *_ut);
 int	login_tty(int _fd);
-int	logout(const char *_line);
-void	logwtmp(const char *_line, const char *_name, const char *_host);
 void	trimdomain(char *_fullhost, int _hostsize);
 int	openpty(int *_amaster, int *_aslave, char *_name,
 		     struct termios *_termp, struct winsize *_winp);

Modified: user/ed/utmpx/libexec/comsat/comsat.c
==============================================================================
--- user/ed/utmpx/libexec/comsat/comsat.c	Tue Jan  5 15:04:08 2010	(r201589)
+++ user/ed/utmpx/libexec/comsat/comsat.c	Tue Jan  5 15:15:15 2010	(r201590)
@@ -66,7 +66,7 @@ static const char rcsid[] =
 #include <string.h>
 #include <syslog.h>
 #include <unistd.h>
-#include <utmp.h>
+#include <utmpx.h>
 
 int	debug = 0;
 #define	dsyslog	if (debug) syslog
@@ -74,14 +74,10 @@ int	debug = 0;
 #define MAXIDLE	120
 
 char	hostname[MAXHOSTNAMELEN];
-struct	utmp *utmp = NULL;
-time_t	lastmsgtime;
-int	nutmp, uf;
 
 void jkfprintf(FILE *, char[], char[], off_t);
 void mailfor(char *);
-void notify(struct utmp *, char[], off_t, int);
-void onalrm(int);
+void notify(struct utmpx *, char[], off_t, int);
 void reapchildren(int);
 
 int
@@ -102,15 +98,7 @@ main(int argc __unused, char *argv[] __u
 		(void) recv(0, msgbuf, sizeof(msgbuf) - 1, 0);
 		exit(1);
 	}
-	if ((uf = open(_PATH_UTMP, O_RDONLY, 0)) < 0) {
-		syslog(LOG_ERR, "open: %s: %m", _PATH_UTMP);
-		(void) recv(0, msgbuf, sizeof(msgbuf) - 1, 0);
-		exit(1);
-	}
-	(void)time(&lastmsgtime);
 	(void)gethostname(hostname, sizeof(hostname));
-	onalrm(0);
-	(void)signal(SIGALRM, onalrm);
 	(void)signal(SIGTTOU, SIG_IGN);
 	(void)signal(SIGCHLD, reapchildren);
 	for (;;) {
@@ -121,11 +109,7 @@ main(int argc __unused, char *argv[] __u
 			errno = 0;
 			continue;
 		}
-		if (!nutmp)		/* no one has logged in yet */
-			continue;
-		sigblock(sigmask(SIGALRM));
 		msgbuf[cc] = '\0';
-		(void)time(&lastmsgtime);
 		mailfor(msgbuf);
 		sigsetmask(0L);
 	}
@@ -138,40 +122,15 @@ reapchildren(int signo __unused)
 }
 
 void
-onalrm(int signo __unused)
-{
-	static off_t utmpsize;		/* last malloced size for utmp */
-	static time_t utmpmtime;	/* last modification time for utmp */
-	struct stat statbf;
-
-	if (time(NULL) - lastmsgtime >= MAXIDLE)
-		exit(0);
-	(void)alarm((u_int)15);
-	(void)fstat(uf, &statbf);
-	if (statbf.st_mtime > utmpmtime) {
-		utmpmtime = statbf.st_mtime;
-		if (statbf.st_size > utmpsize) {
-			utmpsize = statbf.st_size + 10 * sizeof(struct utmp);
-			if ((utmp = realloc(utmp, utmpsize)) == NULL) {
-				syslog(LOG_ERR, "%s", strerror(errno));
-				exit(1);
-			}
-		}
-		(void)lseek(uf, (off_t)0, SEEK_SET);
-		nutmp = read(uf, utmp, (size_t)statbf.st_size)/sizeof(struct utmp);
-	}
-}
-
-void
 mailfor(char *name)
 {
-	struct utmp *utp = &utmp[nutmp];
+	struct utmpx *utp;
 	char *cp;
 	char *file;
 	off_t offset;
 	int folder;
-	char buf[sizeof(_PATH_MAILDIR) + sizeof(utmp[0].ut_name) + 1];
-	char buf2[sizeof(_PATH_MAILDIR) + sizeof(utmp[0].ut_name) + 1];
+	char buf[sizeof(_PATH_MAILDIR) + sizeof(utp->ut_user) + 1];
+	char buf2[sizeof(_PATH_MAILDIR) + sizeof(utp->ut_user) + 1];
 
 	if (!(cp = strchr(name, '@')))
 		return;
@@ -181,33 +140,35 @@ mailfor(char *name)
 		file = name;
 	else
 		file = cp + 1;
-	sprintf(buf, "%s/%.*s", _PATH_MAILDIR, (int)sizeof(utmp[0].ut_name),
+	sprintf(buf, "%s/%.*s", _PATH_MAILDIR, (int)sizeof(utp->ut_user),
 	    name);
 	if (*file != '/') {
 		sprintf(buf2, "%s/%.*s", _PATH_MAILDIR,
-		    (int)sizeof(utmp[0].ut_name), file);
+		    (int)sizeof(utp->ut_user), file);
 		file = buf2;
 	}
 	folder = strcmp(buf, file);
-	while (--utp >= utmp)
-		if (!strncmp(utp->ut_name, name, sizeof(utmp[0].ut_name)))
+	setutxent();
+	while ((utp = getutxent()) != NULL)
+		if (utp->ut_type == USER_PROCESS && !strcmp(utp->ut_user, name))
 			notify(utp, file, offset, folder);
+	endutxent();
 }
 
 static const char *cr;
 
 void
-notify(struct utmp *utp, char file[], off_t offset, int folder)
+notify(struct utmpx *utp, char file[], off_t offset, int folder)
 {
 	FILE *tp;
 	struct stat stb;
 	struct termios tio;
-	char tty[20], name[sizeof(utmp[0].ut_name) + 1];
-	const char *line = utp->ut_line;
+	char tty[20];
+	const char *s = utp->ut_line;
 
-	if (strncmp(line, "pts/", 4) == 0)
-		line += 4;
-	if (strchr(line, '/')) {
+	if (strncmp(s, "pts/", 4) == 0)
+		s += 4;
+	if (strchr(s, '/')) {
 		/* A slash is an attempt to break security... */
 		syslog(LOG_AUTH | LOG_NOTICE, "Unexpected `/' in `%s'",
 		    utp->ut_line);
@@ -216,10 +177,10 @@ notify(struct utmp *utp, char file[], of
 	(void)snprintf(tty, sizeof(tty), "%s%.*s",
 	    _PATH_DEV, (int)sizeof(utp->ut_line), utp->ut_line);
 	if (stat(tty, &stb) == -1 || !(stb.st_mode & (S_IXUSR | S_IXGRP))) {
-		dsyslog(LOG_DEBUG, "%s: wrong mode on %s", utp->ut_name, tty);
+		dsyslog(LOG_DEBUG, "%s: wrong mode on %s", utp->ut_user, tty);
 		return;
 	}
-	dsyslog(LOG_DEBUG, "notify %s on %s\n", utp->ut_name, tty);
+	dsyslog(LOG_DEBUG, "notify %s on %s\n", utp->ut_user, tty);
 	switch (fork()) {
 	case -1:
 		syslog(LOG_NOTICE, "fork failed (%m)");
@@ -229,25 +190,21 @@ notify(struct utmp *utp, char file[], of
 	default:
 		return;
 	}
-	(void)signal(SIGALRM, SIG_DFL);
-	(void)alarm((u_int)30);
 	if ((tp = fopen(tty, "w")) == NULL) {
 		dsyslog(LOG_ERR, "%s: %s", tty, strerror(errno));
 		_exit(1);
 	}
 	(void)tcgetattr(fileno(tp), &tio);
 	cr = ((tio.c_oflag & (OPOST|ONLCR)) == (OPOST|ONLCR)) ?  "\n" : "\n\r";
-	(void)strncpy(name, utp->ut_name, sizeof(utp->ut_name));
-	name[sizeof(name) - 1] = '\0';
 	switch (stb.st_mode & (S_IXUSR | S_IXGRP)) {
 	case S_IXUSR:
 	case (S_IXUSR | S_IXGRP):
 		(void)fprintf(tp, 
 		    "%s\007New mail for %s@%.*s\007 has arrived%s%s%s:%s----%s",
-		    cr, name, (int)sizeof(hostname), hostname,
+		    cr, utp->ut_user, (int)sizeof(hostname), hostname,
 		    folder ? cr : "", folder ? "to " : "", folder ? file : "",
 		    cr, cr);
-		jkfprintf(tp, name, file, offset);
+		jkfprintf(tp, utp->ut_user, file, offset);
 		break;
 	case S_IXGRP:
 		(void)fprintf(tp, "\007");

Modified: user/ed/utmpx/libexec/ftpd/logwtmp.c
==============================================================================
--- user/ed/utmpx/libexec/ftpd/logwtmp.c	Tue Jan  5 15:04:08 2010	(r201589)
+++ user/ed/utmpx/libexec/ftpd/logwtmp.c	Tue Jan  5 15:15:15 2010	(r201590)
@@ -50,14 +50,18 @@ __FBSDID("$FreeBSD$");
 #include <time.h>
 #include <timeconv.h>
 #include <netdb.h>
+#if 0
 #include <utmp.h>
+#endif
 #include <unistd.h>
 #include <stdio.h>
 #include <string.h>
 #include <libutil.h>
 #include "extern.h"
 
+#if 0
 static int fd = -1;
+#endif
 
 /*
  * Modified version of logwtmp that holds wtmp file open
@@ -69,6 +73,7 @@ ftpd_logwtmp(line, name, addr)
 	char *line, *name;
 	struct sockaddr *addr;
 {
+#if 0
 	struct utmp ut;
 	struct stat buf;
 	char host[UT_HOSTSIZE];
@@ -89,4 +94,5 @@ ftpd_logwtmp(line, name, addr)
 		    sizeof(struct utmp))
 			(void)ftruncate(fd, buf.st_size);
 	}
+#endif
 }

Modified: user/ed/utmpx/libexec/rlogind/Makefile
==============================================================================
--- user/ed/utmpx/libexec/rlogind/Makefile	Tue Jan  5 15:04:08 2010	(r201589)
+++ user/ed/utmpx/libexec/rlogind/Makefile	Tue Jan  5 15:15:15 2010	(r201590)
@@ -5,8 +5,8 @@
 
 PROG=	rlogind
 MAN=	rlogind.8
-DPADD=	${LIBUTIL}
-LDADD=	-lutil
+DPADD=	${LIBULOG} ${LIBUTIL}
+LDADD=	-lulog -lutil
 WARNS?=	2
 
 .if ${MK_INET6_SUPPORT} != "no"

Modified: user/ed/utmpx/libexec/rlogind/rlogind.c
==============================================================================
--- user/ed/utmpx/libexec/rlogind/rlogind.c	Tue Jan  5 15:04:08 2010	(r201589)
+++ user/ed/utmpx/libexec/rlogind/rlogind.c	Tue Jan  5 15:15:15 2010	(r201590)
@@ -85,6 +85,7 @@ __FBSDID("$FreeBSD$");
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <ulog.h>
 #include <unistd.h>
 
 
@@ -482,8 +483,7 @@ cleanup(int signo)
 	char *p;
 
 	p = line + sizeof(_PATH_DEV) - 1;
-	if (logout(p))
-		logwtmp(p, "", "");
+	ulog_logout(p);
 	(void)chflags(line, 0);
 	(void)chmod(line, 0666);
 	(void)chown(line, 0, 0);

Modified: user/ed/utmpx/libexec/rpc.rusersd/Makefile
==============================================================================
--- user/ed/utmpx/libexec/rpc.rusersd/Makefile	Tue Jan  5 15:04:08 2010	(r201589)
+++ user/ed/utmpx/libexec/rpc.rusersd/Makefile	Tue Jan  5 15:15:15 2010	(r201590)
@@ -4,8 +4,8 @@ PROG =	rpc.rusersd
 SRCS =	rusersd.c rusers_proc.c
 MAN =	rpc.rusersd.8
 
-DPADD=	${LIBRPCSVC} ${LIBULOG} ${LIBUTIL}
-LDADD=	-lrpcsvc -lulog -lutil
+DPADD=	${LIBRPCSVC} ${LIBUTIL}
+LDADD=	-lrpcsvc -lutil
 
 #.if exists(/usr/X11R6/include/X11/extensions/xidle.h)
 #CFLAGS+= -DXIDLE

Modified: user/ed/utmpx/libexec/rpc.rusersd/rusers_proc.c
==============================================================================
--- user/ed/utmpx/libexec/rpc.rusersd/rusers_proc.c	Tue Jan  5 15:04:08 2010	(r201589)
+++ user/ed/utmpx/libexec/rpc.rusersd/rusers_proc.c	Tue Jan  5 15:15:15 2010	(r201590)
@@ -45,8 +45,7 @@ static const char rcsid[] =
 #include <sys/stat.h>

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 15:54:10 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 349FF1065670;
	Tue,  5 Jan 2010 15:54:10 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 2292C8FC15;
	Tue,  5 Jan 2010 15:54:10 +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 o05FsAJk042523;
	Tue, 5 Jan 2010 15:54:10 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o05FsANx042519;
	Tue, 5 Jan 2010 15:54:10 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001051554.o05FsANx042519@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Tue, 5 Jan 2010 15:54:09 +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: r201591 - user/luigi/ipfw3-head/sys/netinet/ipfw
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: Tue, 05 Jan 2010 15:54:10 -0000

Author: luigi
Date: Tue Jan  5 15:54:09 2010
New Revision: 201591
URL: http://svn.freebsd.org/changeset/base/201591

Log:
  try to isolate the heap code a bit more.
  Also mark a strange performance problem -- when an apparently innocuous
  RESET_OFFSET()  (equivalent to "if (condition) x++;" ) the runtime
  decreases by some 10% for no clear reason (I suppose it is related to
  branch prediction or code alignment).

Modified:
  user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c
  user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.h
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c	Tue Jan  5 15:15:15 2010	(r201590)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c	Tue Jan  5 15:54:09 2010	(r201591)
@@ -24,15 +24,14 @@
  * SUCH DAMAGE.
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 /*
  * A binary heap data structure used in dummynet
  */
 
+#include <sys/cdefs.h>
 #include <sys/param.h>
 #ifdef _KERNEL
+__FBSDID("$FreeBSD$");
 #include <sys/systm.h>
 #include <sys/malloc.h>
 #include <sys/kernel.h>
@@ -104,19 +103,20 @@ heap_init(struct dn_heap *h, int new_siz
  * bubble-up.
  * Returns 1 on failure (cannot allocate new heap entry)
  *
- * If offset > 0 the position (index, int) of the element in the heap is
+ * If ofs > 0 the position (index, int) of the element in the heap is
  * also stored in the element itself at the given offset in bytes.
  */
 #define SET_OFFSET(heap, node) \
-    if (heap->offset > 0) \
-	    *((int *)((char *)(heap->p[node].object) + heap->offset)) = node;
+    if (heap->ofs > 0) \
+	    *((int *)((char *)(heap->p[node].object) + heap->ofs)) = node;
 /*
- * RESET_OFFSET is used for sanity checks. It sets offset
+ * RESET_OFFSET is used for sanity checks. It sets ofs
  * to an invalid value.
  */
 #define RESET_OFFSET(heap, node) \
-    if (heap->offset > 0) \
-	    *((int *)((char *)(heap->p[node].object) + heap->offset)) = -1;
+    if (heap->ofs > 0) \
+	*((int *)((char *)(heap->p[node].object) + heap->ofs)) = -1;
+
 int
 heap_insert(struct dn_heap *h, uint64_t key1, void *p)
 {
@@ -165,10 +165,10 @@ heap_extract(struct dn_heap *h, void *ob
 	if (obj == NULL)
 		father = 0; /* default: move up smallest child */
 	else { /* extract specific element, index is at offset */
-		if (h->offset <= 0)
+		if (h->ofs <= 0)
 			panic("%s: extract from middle not set on %p\n",
 				__FUNCTION__, h);
-		father = *((int *)((char *)obj + h->offset));
+		father = *((int *)((char *)obj + h->ofs));
 		if (father < 0 || father >= h->elements) {
 			panic("%s: heap_extract, father %d out of bound 0..%d\n",
 				__FUNCTION__, father, h->elements);
@@ -180,8 +180,8 @@ heap_extract(struct dn_heap *h, void *ob
 	 * reach the bottom level.
 	 */
 	// XXX why removing RESET_OFFSET increases runtime by 10% ?
-	RESET_OFFSET(h, father);
-	while ( (child = HEAP_LEFT(father)) <= max) {
+	//RESET_OFFSET(h, father);
+	while ( (child = HEAP_LEFT(father)) <= max ) {
 		if (child != max &&
 		    DN_KEY_LT(h->p[child+1].key, h->p[child].key) )
 			child++; /* take right child, otherwise left */
@@ -213,10 +213,10 @@ heap_move(struct dn_heap *h, uint64_t ne
 	int max = h->elements-1;
 	struct dn_heap_entry buf;
 
-	if (h->offset <= 0)
+	if (h->ofs <= 0)
 		panic("cannot move items on this heap");
 
-	i = *((int *)((char *)object + h->offset));
+	i = *((int *)((char *)object + h->ofs));
 	if (DN_KEY_LT(new_key, h->p[i].key) ) { /* must move up */
 		h->p[i].key = new_key;
 		for (; i>0 &&

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.h
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.h	Tue Jan  5 15:15:15 2010	(r201590)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.h	Tue Jan  5 15:54:09 2010	(r201591)
@@ -45,7 +45,7 @@
  * need to scan the whole array). To this purpose, an object has a
  * field (int) which contains the index of the object itself into the
  * heap. When the object is moved, the field must also be updated.
- * The offset of the index in the object is stored in the 'offset'
+ * The offset of the index in the object is stored in the 'ofs'
  * field in the heap descriptor. The assumption is that this offset
  * is non-zero if we want to support extract from the middle.
  */
@@ -57,10 +57,12 @@ struct dn_heap_entry {
 struct dn_heap {
 	int size;	/* the size of the array */
 	int elements;	/* elements in use */
-	int offset; /* XXX if > 0 this is the offset of direct ptr to obj */
-	struct dn_heap_entry *p ;	/* really an array of "size" entries */
+	int ofs; /* XXX if > 0 this is the offset of direct ptr to obj */
+	struct dn_heap_entry *p;	/* really an array of "size" entries */
 } ;
 
+/* HEAP_TOP returns the pointer to the top element of the heap */
+#define HEAP_TOP(h)	((h)->p)
 int     heap_init(struct dn_heap *h, int size);
 int     heap_insert (struct dn_heap *h, uint64_t key1, void *p);
 void    heap_extract(struct dn_heap *h, void *obj);

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Tue Jan  5 15:15:15 2010	(r201590)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Tue Jan  5 15:54:09 2010	(r201591)
@@ -568,7 +568,7 @@ ready_event_wfq(struct dn_pipe *p, struc
 	while (p_numbytes >= 0 && (sch->elements > 0 || neh->elements > 0)) {
 		if (sch->elements > 0) {
 			/* Have some eligible pkts to send out. */
-			struct dn_flow_queue *q = sch->p[0].object;
+			struct dn_flow_queue *q = HEAP_TOP(sch)->object;
 			struct mbuf *pkt = q->head;
 			struct dn_flow_set *fs = q->fs;
 			uint64_t len = pkt->m_pkthdr.len;
@@ -607,10 +607,10 @@ ready_event_wfq(struct dn_pipe *p, struc
 		 * if sch is empty we only need to look at neh.
 		 */
 		if (sch->elements == 0 && neh->elements > 0)
-			p->V = MAX64(p->V, neh->p[0].key);
+			p->V = MAX64(p->V, HEAP_TOP(neh)->key);
 		/* Move from neh to sch any packets that have become eligible */
-		while (neh->elements > 0 && DN_KEY_LEQ(neh->p[0].key, p->V)) {
-			struct dn_flow_queue *q = neh->p[0].object;
+		while (neh->elements > 0 && DN_KEY_LEQ(HEAP_TOP(neh)->key, p->V)) {
+			struct dn_flow_queue *q = HEAP_TOP(neh)->object;
 			heap_extract(neh, NULL);
 			heap_insert(sch, q->F, q);
 		}
@@ -629,6 +629,7 @@ ready_event_wfq(struct dn_pipe *p, struc
 		if (p->idle_heap->elements > 0) {
 			int i;
 
+			/* XXX do a heap_extract perhaps ? */
 			for (i = 0; i < p->idle_heap->elements; i++) {
 				struct dn_flow_queue *q;
 				
@@ -738,13 +739,14 @@ dummynet_task(void *context, int pending
 
 	for (i = 0; i < 3; i++) {
 		h = heaps[i];
-		while (h->elements > 0 && DN_KEY_LEQ(h->p[0].key, curr_time)) {
-			if (h->p[0].key > curr_time)
+		while (h->elements > 0 && DN_KEY_LEQ(HEAP_TOP(h)->key, curr_time)) {
+			// XXX can this happen ?
+			if (HEAP_TOP(h)->key > curr_time)
 				printf("dummynet: warning, "
 				    "heap %d is %d ticks late\n",
-				    i, (int)(curr_time - h->p[0].key));
+				    i, (int)(curr_time - HEAP_TOP(h)->key));
 			/* store a copy before heap_extract */
-			p = h->p[0].object;
+			p = HEAP_TOP(h)->object;
 			/* need to extract before processing */
 			heap_extract(h, NULL);
 			if (i == 0)
@@ -765,9 +767,9 @@ dummynet_task(void *context, int pending
 	for (i = 0; i < HASHSIZE; i++) {
 		SLIST_FOREACH(pipe, &pipehash[i], next) {
 			if (pipe->idle_heap->elements > 0 &&
-			    DN_KEY_LT(pipe->idle_heap->p[0].key, pipe->V)) {
+			    DN_KEY_LT(HEAP_TOP(pipe->idle_heap)->key, pipe->V)) {
 				struct dn_flow_queue *q =
-				    pipe->idle_heap->p[0].object;
+				    HEAP_TOP(pipe->idle_heap)->object;
 
 				heap_extract(pipe->idle_heap, NULL);
 				/* Mark timestamp as invalid. */
@@ -1640,8 +1642,7 @@ config_pipe(struct dn_pipe *p)
 			 * idle_heap is the only one from which
 			 * we extract from the middle.
 			 */
-			pipe->idle_heap->size = pipe->idle_heap->elements = 0;
-			pipe->idle_heap->offset =
+			pipe->idle_heap->ofs =
 			    offsetof(struct dn_flow_queue, heap_pos);
 		} else {
 			/* Flush accumulated credit for all queues. */
@@ -1757,6 +1758,8 @@ config_pipe(struct dn_pipe *p)
 /*
  * Helper function to remove from a heap queues which are linked to
  * a flow_set about to be deleted.
+ * XXX this should be moved to the heap code, as we remove entries
+ * from the heap under certain conditions.
  */
 static void
 fs_remove_from_heap(struct dn_heap *h, struct dn_flow_set *fs)
@@ -2115,14 +2118,9 @@ ip_dn_init(void)
 		SLIST_INIT(&pipehash[i]);
 		SLIST_INIT(&flowsethash[i]);
 	}
-	ready_heap.size = ready_heap.elements = 0;
-	ready_heap.offset = 0;
-
-	wfq_ready_heap.size = wfq_ready_heap.elements = 0;
-	wfq_ready_heap.offset = 0;
-
-	extract_heap.size = extract_heap.elements = 0;
-	extract_heap.offset = 0;
+	bzero(&ready_heap, sizeof(ready_heap));
+	bzero(&wfq_ready_heap, sizeof(wfq_ready_heap));
+	bzero(&extract_heap, sizeof(extract_heap));
 
 	ip_dn_ctl_ptr = ip_dn_ctl;
 	ip_dn_io_ptr = dummynet_io;

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 16:49:12 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 DC511106566C;
	Tue,  5 Jan 2010 16:49:12 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id CAF328FC14;
	Tue,  5 Jan 2010 16:49:12 +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 o05GnCai054725;
	Tue, 5 Jan 2010 16:49:12 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o05GnCbt054721;
	Tue, 5 Jan 2010 16:49:12 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001051649.o05GnCbt054721@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Tue, 5 Jan 2010 16:49:12 +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: r201592 - user/luigi/ipfw3-head/sys/netinet/ipfw
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: Tue, 05 Jan 2010 16:49:12 -0000

Author: luigi
Date: Tue Jan  5 16:49:12 2010
New Revision: 201592
URL: http://svn.freebsd.org/changeset/base/201592

Log:
  introduce heap_scan() to run a callback on all heap elements.

Modified:
  user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c
  user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.h
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c	Tue Jan  5 15:54:09 2010	(r201591)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c	Tue Jan  5 16:49:12 2010	(r201592)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 1998-2002 Luigi Rizzo, Universita` di Pisa
+ * Copyright (c) 1998-2002,2010 Luigi Rizzo, Universita` di Pisa
  * All rights reserved
  *
  * Redistribution and use in source and binary forms, with or without
@@ -180,7 +180,7 @@ heap_extract(struct dn_heap *h, void *ob
 	 * reach the bottom level.
 	 */
 	// XXX why removing RESET_OFFSET increases runtime by 10% ?
-	//RESET_OFFSET(h, father);
+	RESET_OFFSET(h, father);
 	while ( (child = HEAP_LEFT(father)) <= max ) {
 		if (child != max &&
 		    DN_KEY_LT(h->p[child+1].key, h->p[child].key) )
@@ -249,17 +249,37 @@ heap_move(struct dn_heap *h, uint64_t ne
  * heapify() will reorganize data inside an array to maintain the
  * heap property. It is needed when we delete a bunch of entries.
  */
-void
+static void
 heapify(struct dn_heap *h)
 {
 	int i;
 
-	printf("%s on %p for %d elements\n",
-		__FUNCTION__, h, h->elements);
 	for (i = 0; i < h->elements; i++ )
 		heap_insert(h, i , NULL);
 }
 
+int
+heap_scan(struct dn_heap *h, int (*fn)(void *, uintptr_t),
+	uintptr_t arg)
+{
+	int i, ret, found;
+
+	for (i = found = 0 ; i < h->elements ;) {
+		ret = fn(h->p[i].object, arg);
+		if (ret & HEAP_SCAN_DEL) {
+			h->elements-- ;
+			h->p[i] = h->p[h->elements] ;
+			found++ ;
+		} else
+			i++ ;
+		if (ret & HEAP_SCAN_END)
+			break;
+	}
+	if (found)
+		heapify(h);
+	return found;
+}
+
 /*
  * cleanup the heap and free data structure
  */

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.h
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.h	Tue Jan  5 15:54:09 2010	(r201591)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.h	Tue Jan  5 16:49:12 2010	(r201592)
@@ -66,7 +66,20 @@ struct dn_heap {
 int     heap_init(struct dn_heap *h, int size);
 int     heap_insert (struct dn_heap *h, uint64_t key1, void *p);
 void    heap_extract(struct dn_heap *h, void *obj);
-void heapify(struct dn_heap *h);
+/* void heapify(struct dn_heap *h); */
 void heap_free(struct dn_heap *h);
+enum {
+	HEAP_SCAN_DEL = 1,
+	HEAP_SCAN_END = 2,
+};
+/*
+ * heap_scan scans the entire heap calling fn on each entry. 
+ * fn() can return a combination of HEAP_SCAN_DEL and HEAP_SCAN_END,
+ * where HEAP_SCAN_DEL means the current element must be removed,
+ * and HEAP_SCAN_END means no further entry need to be analysed.
+ * At the end, heap_scan calls heapify() if records are deleted.
+ * The function returns the number of matching elements.
+ */
+int heap_scan(struct dn_heap *, int (*)(void *, uintptr_t), uintptr_t);
 
 #endif /* _IP_DN_HEAP_H */

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Tue Jan  5 15:54:09 2010	(r201591)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Tue Jan  5 16:49:12 2010	(r201592)
@@ -521,6 +521,17 @@ ready_event(struct dn_flow_queue *q, str
 		transmit_event(p, head, tail);
 }
 
+/* callback to clean the idle heap */
+static int
+clean_fq(void *_q, uintptr_t arg)
+{
+	struct dn_flow_queue *q = _q;
+
+	q->F = 0;
+	q->S = q->F + 1;
+	return HEAP_SCAN_DEL;
+}
+
 /*
  * Called when we can transmit packets on WF2Q queues. Take pkts out of
  * the queues at their start time, and enqueue into the delay line.
@@ -627,16 +638,7 @@ ready_event_wfq(struct dn_pipe *p, struc
 		 * We can get rid of idle-heap.
 		 */
 		if (p->idle_heap->elements > 0) {
-			int i;
-
-			/* XXX do a heap_extract perhaps ? */
-			for (i = 0; i < p->idle_heap->elements; i++) {
-				struct dn_flow_queue *q;
-				
-				q = p->idle_heap->p[i].object;
-				q->F = 0;
-				q->S = q->F + 1;
-			}
+			heap_scan(p->idle_heap, clean_fq, 0);
 			p->sum = 0;
 			p->V = 0;
 			p->idle_heap->elements = 0;
@@ -1761,39 +1763,26 @@ config_pipe(struct dn_pipe *p)
  * XXX this should be moved to the heap code, as we remove entries
  * from the heap under certain conditions.
  */
+static int
+scan_remove_fs(void *_o, uintptr_t fs)
+{
+	struct dn_flow_queue *fq = _o;
+	return (fq->fs == (struct dn_flow_set *)fs) ? HEAP_SCAN_DEL : 0;
+}
+
 static void
 fs_remove_from_heap(struct dn_heap *h, struct dn_flow_set *fs)
 {
-    int i, found;
-
-    for (i = found = 0 ; i < h->elements ;) {
-	if ( ((struct dn_flow_queue *)h->p[i].object)->fs == fs) {
-	    h->elements-- ;
-	    h->p[i] = h->p[h->elements] ;
-	    found++ ;
-	} else
-	    i++ ;
-    }
-    if (found)
-	heapify(h);
+	heap_scan(h, scan_remove_fs, (uintptr_t)fs);
 }
 
 /*
  * helper function to remove a pipe from a heap (can be there at most once)
  */
-static void
-pipe_remove_from_heap(struct dn_heap *h, struct dn_pipe *p)
+static int
+scan_remove_pipe(void *_o, uintptr_t p)
 {
-	int i;
-
-	for (i=0; i < h->elements ; i++ ) {
-		if (h->p[i].object == p) { /* found it */
-			h->elements-- ;
-			h->p[i] = h->p[h->elements] ;
-			heapify(h);
-			break ;
-		}
-	}
+	return (0 == (void *)p) ? HEAP_SCAN_DEL | HEAP_SCAN_END : 0;
 }
 
 /*
@@ -1866,8 +1855,8 @@ delete_pipe(struct dn_pipe *p)
 	fs_remove_from_heap(&ready_heap, &(pipe->fs));
 	purge_pipe(pipe); /* remove all data associated to this pipe */
 	/* remove reference to here from extract_heap and wfq_ready_heap */
-	pipe_remove_from_heap(&extract_heap, pipe);
-	pipe_remove_from_heap(&wfq_ready_heap, pipe);
+	heap_scan(&extract_heap, scan_remove_pipe, (uintptr_t)pipe);
+	heap_scan(&wfq_ready_heap, scan_remove_pipe, (uintptr_t)pipe);
 	DUMMYNET_UNLOCK();
 
 	free_pipe(pipe);

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 17:05:12 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 832EC1065884;
	Tue,  5 Jan 2010 17:05:12 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 687818FC1A;
	Tue,  5 Jan 2010 17:05:12 +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 o05H5Cqe058428;
	Tue, 5 Jan 2010 17:05:12 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o05H5CNL058426;
	Tue, 5 Jan 2010 17:05:12 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001051705.o05H5CNL058426@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Tue, 5 Jan 2010 17:05:12 +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: r201595 - user/luigi/ipfw3-head/sys/netinet/ipfw
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: Tue, 05 Jan 2010 17:05:12 -0000

Author: luigi
Date: Tue Jan  5 17:05:12 2010
New Revision: 201595
URL: http://svn.freebsd.org/changeset/base/201595

Log:
  simplify a function

Modified:
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Tue Jan  5 17:04:39 2010	(r201594)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Tue Jan  5 17:05:12 2010	(r201595)
@@ -38,7 +38,6 @@ __FBSDID("$FreeBSD$");
  * Description of the data structures used is in ip_dummynet.h
  * Here you mainly find the following blocks of code:
  *  + variable declarations;
- *  + heap management functions;
  *  + scheduler and dummynet functions;
  *  + configuration and initialization.
  *
@@ -1624,6 +1623,7 @@ config_pipe(struct dn_pipe *p)
 		pipe = locate_pipe(p->pipe_nr);	/* locate pipe */
 
 		if (pipe == NULL) {		/* new pipe */
+			/* space for pipe + 3 heaps right after the pipe */
 			pipe = malloc(sizeof(struct dn_pipe) +
 				3 * sizeof(struct dn_heap), M_DUMMYNET,
 			    M_NOWAIT | M_ZERO);
@@ -1633,7 +1633,6 @@ config_pipe(struct dn_pipe *p)
 				return (ENOMEM);
 			}
 
-			/* the heaps are right after the pipe */
 			pipe->scheduler_heap = (struct dn_heap *)(pipe + 1);
 			pipe->not_eligible_heap = pipe->scheduler_heap + 1;
 			pipe->idle_heap = pipe->scheduler_heap + 2;
@@ -1820,22 +1819,21 @@ dummynet_drain(void)
 static int
 delete_pipe(struct dn_pipe *p)
 {
-
-    if (p->pipe_nr == 0 && p->fs.fs_nr == 0)
-	return EINVAL ;
-    if (p->pipe_nr != 0 && p->fs.fs_nr != 0)
+    struct dn_pipe *pipe;
+    struct dn_flow_set *fs;
+    int err = 0;
+    
+    if (p->pipe_nr != 0 && p->fs.fs_nr != 0) /* cannot have both set */
 	return EINVAL ;
+    DUMMYNET_LOCK();
     if (p->pipe_nr != 0) { /* this is an old-style pipe */
-	struct dn_pipe *pipe;
-	struct dn_flow_set *fs;
 	int i;
 
-	DUMMYNET_LOCK();
 	pipe = locate_pipe(p->pipe_nr);	/* locate pipe */
 
 	if (pipe == NULL) {
-	    DUMMYNET_UNLOCK();
-	    return (ENOENT);	/* not found */
+		err = ENOENT;	/* not found */
+		goto done;
 	}
 
 	/* Unlink from list of pipes. */
@@ -1857,18 +1855,14 @@ delete_pipe(struct dn_pipe *p)
 	/* remove reference to here from extract_heap and wfq_ready_heap */
 	heap_scan(&extract_heap, scan_remove_pipe, (uintptr_t)pipe);
 	heap_scan(&wfq_ready_heap, scan_remove_pipe, (uintptr_t)pipe);
-	DUMMYNET_UNLOCK();
-
-	free_pipe(pipe);
     } else { /* this is a WF2Q queue (dn_flow_set) */
-	struct dn_flow_set *fs;
+	pipe = NULL;
 
-	DUMMYNET_LOCK();
 	fs = locate_flowset(p->fs.fs_nr); /* locate set */
 
 	if (fs == NULL) {
-	    DUMMYNET_UNLOCK();
-	    return (ENOENT); /* not found */
+		err = ENOENT;	/* not found */
+		goto done;
 	}
 
 	/* Unlink from list of flowsets. */
@@ -1879,14 +1873,15 @@ delete_pipe(struct dn_pipe *p)
 	    fs->pipe->sum -= fs->weight * fs->backlogged ;
 	    fs_remove_from_heap(fs->pipe->not_eligible_heap, fs);
 	    fs_remove_from_heap(fs->pipe->scheduler_heap, fs);
-#if 1	/* XXX should i remove from idle_heap as well ? */
 	    fs_remove_from_heap(fs->pipe->idle_heap, fs);
-#endif
 	}
 	purge_flow_set(fs, 1);
-	DUMMYNET_UNLOCK();
     }
-    return 0 ;
+done:
+    DUMMYNET_UNLOCK();
+    if (pipe)
+	free_pipe(pipe);
+    return err;
 }
 
 /*

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 18:07:20 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 95175106566B;
	Tue,  5 Jan 2010 18:07:20 +0000 (UTC)
	(envelope-from ermal.luci@gmail.com)
Received: from mail-ew0-f226.google.com (mail-ew0-f226.google.com
	[209.85.219.226])
	by mx1.freebsd.org (Postfix) with ESMTP id C10A98FC16;
	Tue,  5 Jan 2010 18:07:19 +0000 (UTC)
Received: by ewy26 with SMTP id 26so14530064ewy.3
	for <multiple recipients>; Tue, 05 Jan 2010 10:07:11 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:mime-version:sender:received:in-reply-to
	:references:from:date:x-google-sender-auth:message-id:subject:to:cc
	:content-type; bh=KnL+q9p+pBJzA2ocCU8cPUZuDkmGc4klzbzxuopAUws=;
	b=qOWHl+s43Jves/fWl8w2i0D9NAkFL5eDEn0PIperoxfFLb1tfoPjOQWBGiI6rIMh70
	wnpB3Gxu46mZB4f09BpWHY4VimPcX1bthAuBSznW7D2qPX9y6WKXqo2EpW9WcRMCdIvL
	WrBH7cZT1mYTj0yJzCY5KtTymU4r/GAhRvcLo=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=mime-version:sender:in-reply-to:references:from:date
	:x-google-sender-auth:message-id:subject:to:cc:content-type;
	b=k97wPrmTDC7+OwZjXq+xWucGNmitFymlebZJSGrQ4b6KVhu8m8ykn1U6sMC5/Q93SV
	dymcuCtIRNhHl+KLy7QGB5Jc6JLNn/E6fJOz8I9DKgzzOAPhx/qw9glvQCy8oLj1CxL6
	WH+xkCqwWeDDsJRD64eN9oMyQ9pl6d/HkshZE=
MIME-Version: 1.0
Sender: ermal.luci@gmail.com
Received: by 10.216.89.206 with SMTP id c56mr1022139wef.123.1262714831208; 
	Tue, 05 Jan 2010 10:07:11 -0800 (PST)
In-Reply-To: <201001041658.o04GwFfG023749@svn.freebsd.org>
References: <201001041658.o04GwFfG023749@svn.freebsd.org>
From: =?ISO-8859-1?Q?Ermal_Lu=E7i?= <eri@freebsd.org>
Date: Tue, 5 Jan 2010 19:06:51 +0100
X-Google-Sender-Auth: 35e96daa00536959
Message-ID: <9a542da31001051006r61af058eg715c29ef0d3d2020@mail.gmail.com>
To: Luigi Rizzo <luigi@freebsd.org>
Content-Type: text/plain; charset=ISO-8859-1
X-Content-Filtered-By: Mailman/MimeDel 2.1.5
Cc: src-committers@freebsd.org, svn-src-user@freebsd.org
Subject: Re: svn commit: r201517 - in user/luigi/ipfw3-head/sys/netinet: . 
	ipfw
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: Tue, 05 Jan 2010 18:07:20 -0000

On Mon, Jan 4, 2010 at 5:58 PM, Luigi Rizzo <luigi@freebsd.org> wrote:

> Author: luigi
> Date: Mon Jan  4 16:58:15 2010
> New Revision: 201517
> URL: http://svn.freebsd.org/changeset/base/201517
>
> Log:
>  divert has no specific API so we don't really need an ip_divert.h
>
>
>  DECLARE_MODULE(ipdivert, ipdivertmod, SI_SUB_PROTO_IFATTACHDOMAIN,
> SI_ORDER_ANY);
> -MODULE_DEPEND(dummynet, ipfw, 2, 2, 2);
> +MODULE_DEPEND(ipdivert, ipfw, 2, 2, 2);
>  MODULE_VERSION(ipdivert, 1);
>

I would suggest to remove the dependency altogether  since divert(4) does
not really depend on ipfw(4). Furthermore, the newest pf(4) can work
together with divert(4) so the it will have more than one consumer in the
tree.

-- 
Ermal

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 18:18:48 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 86FB31065676;
	Tue,  5 Jan 2010 18:18:48 +0000 (UTC)
	(envelope-from luigi@onelab2.iet.unipi.it)
Received: from onelab2.iet.unipi.it (onelab2.iet.unipi.it [131.114.59.238])
	by mx1.freebsd.org (Postfix) with ESMTP id 357258FC15;
	Tue,  5 Jan 2010 18:18:47 +0000 (UTC)
Received: by onelab2.iet.unipi.it (Postfix, from userid 275)
	id DBF00730A1; Tue,  5 Jan 2010 19:26:43 +0100 (CET)
Date: Tue, 5 Jan 2010 19:26:43 +0100
From: Luigi Rizzo <rizzo@iet.unipi.it>
To: Ermal Lu?i <eri@freebsd.org>
Message-ID: <20100105182643.GA93051@onelab2.iet.unipi.it>
References: <201001041658.o04GwFfG023749@svn.freebsd.org>
	<9a542da31001051006r61af058eg715c29ef0d3d2020@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <9a542da31001051006r61af058eg715c29ef0d3d2020@mail.gmail.com>
User-Agent: Mutt/1.4.2.3i
Cc: Luigi Rizzo <luigi@freebsd.org>, src-committers@freebsd.org,
	svn-src-user@freebsd.org
Subject: Re: svn commit: r201517 - in user/luigi/ipfw3-head/sys/netinet: .
	ipfw
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: Tue, 05 Jan 2010 18:18:48 -0000

On Tue, Jan 05, 2010 at 07:06:51PM +0100, Ermal Lu?i wrote:
> On Mon, Jan 4, 2010 at 5:58 PM, Luigi Rizzo <luigi@freebsd.org> wrote:
> 
> > Author: luigi
> > Date: Mon Jan  4 16:58:15 2010
> > New Revision: 201517
> > URL: http://svn.freebsd.org/changeset/base/201517
> >
> > Log:
> >  divert has no specific API so we don't really need an ip_divert.h
> >
> >
> >  DECLARE_MODULE(ipdivert, ipdivertmod, SI_SUB_PROTO_IFATTACHDOMAIN,
> > SI_ORDER_ANY);
> > -MODULE_DEPEND(dummynet, ipfw, 2, 2, 2);
> > +MODULE_DEPEND(ipdivert, ipfw, 2, 2, 2);
> >  MODULE_VERSION(ipdivert, 1);
> >
> 
> I would suggest to remove the dependency altogether  since divert(4) does
> not really depend on ipfw(4). Furthermore, the newest pf(4) can work
> together with divert(4) so the it will have more than one consumer in the
> tree.

I was not aware of pf support -- in fact, i wonder how divert could work
without ipfw because the function pointer ip_divert_ptr at the moment
is defined in ip_fw_pfil.c .

There are in fact, I believe, two things that enforce the dependency:
1. the ip_divert_ptr above. We should move it elsewhere, in the
  standard ip_* files;

2. the tag that is attached to the packet to record the reinject cookie
  (I have recently redefined it as MTAG_IPFW_RULE because i was
  not aware of the pf(4) support -- i need to revert/fix this if
  we want divert and pf cooperation (though note that I tried to
  have the same mtag format for all reinjected packets -- dummynet,
  divert, netgraph, ... so once we fix it for one application it
  should work for all with no special code).

cheers
luigi

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 18:26:26 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 BD7C110656A3;
	Tue,  5 Jan 2010 18:26:26 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id AC0C38FC20;
	Tue,  5 Jan 2010 18:26:26 +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 o05IQQwo076461;
	Tue, 5 Jan 2010 18:26:26 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o05IQQS0076459;
	Tue, 5 Jan 2010 18:26:26 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001051826.o05IQQS0076459@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Tue, 5 Jan 2010 18:26:26 +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: r201598 - user/luigi/ipfw3-head/sys/netinet
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: Tue, 05 Jan 2010 18:26:26 -0000

Author: luigi
Date: Tue Jan  5 18:26:26 2010
New Revision: 201598
URL: http://svn.freebsd.org/changeset/base/201598

Log:
  start bringing in the definitions for the new kernel-userland API

Modified:
  user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h

Modified: user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h	Tue Jan  5 18:25:41 2010	(r201597)
+++ user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h	Tue Jan  5 18:26:26 2010	(r201598)
@@ -31,19 +31,298 @@
 #define _IP_DUMMYNET_H
 
 /*
- * Definition of dummynet data structures. In the structures, I decided
- * not to use the macros in <sys/queue.h> in the hope of making the code
- * easier to port to other architectures. The type of lists and queue we
- * use here is pretty simple anyways.
+ * Definition of the kernel-userland API for dummynet.
+ *
+ * Setsockopt() and getsockopt() pass a batch of objects, each
+ * of them starting with a "struct dn_id" which should fully identify
+ * the object and its relation with others in the sequence.
+ * objects in a batch of requests.
+ * This struct store in the type field an identifier of the type of object
+ * passed (for example a pipe, a scheduler...). The subtype
+ * field contains more detail info, if needed.
+ */
+
+struct dn_id {
+	uint16_t	len;	/* total len including this header */
+	uint8_t		type;
+	uint8_t		subtype;
+	uint32_t	id;	/* identifier in the sequence */
+};
+
+/*
+ * These values are in the type field of struct dn_id.
+ * To preserve the ABI, never rearrange the list or delete
+ * entries with the exception of DN_LAST
+ */
+enum {
+	DN_PIPE = 1,
+	DN_FS,
+	DN_SCH,
+	DN_SCH_I,
+	DN_QUEUE,
+	DN_DELAY_LINE,
+	DN_PROFILE,
+	DN_FS_EXT,
+	DN_QUEUE_EXT,
+	DN_UNKNOW,
+	DN_CMD_CONFIGURE,
+	DN_CMD_DELETE,
+	DN_LAST,
+};
+ 
+/* These values are in the subtype field of struct gen */
+enum dn_configure {
+	DN_CONF_PIPE  = 1,
+	DN_CONF_QUEUE = 2,
+	DN_CONF_SCHED = 3,
+};
+ 
+/* These values are in the flag field of a scheduler
+ * Some of them are used only by kernel (k)
+ */
+enum sched_flag {
+    DN_SCH_RECONFIGURE          = 0x0001, /* (k) */
+    DN_SCH_HAVE_MASK            = 0x0002,
+    DN_SCH_DELETE               = 0x0004, /* (k) */
+    DN_SCH_REENQUEUE            = 0x0008, /* (k) */
+    DN_SCH_ACTIVE               = 0x0010, /* (k) */
+//     DN_SCH_BUSY                 = 0x0020, /* (k) */
+    DN_SCH_DELETE_DELAY_LINE  = 0x0040, /* (k) */
+};
+
+SLIST_HEAD(new_queue_head, new_queue);
+typedef uint64_t dn_key;
+
+/* Pipe template
+ * All pipe are linked in a list, there is a 1-1 mapping between
+ * 'ipfw pipe XX ...' commands and pipe XX
+ */
+struct new_pipe {
+	struct dn_id id;
+
+	/* these initial fields are set from the command line
+	 * pipe N config bw B delay D profile PRF (mask M1 plr P queue Q
+	 *                                         buckets BB ) ...
+	 * The second set of parameters (M1, ...) belong to the
+	 * scheduler or the flowset. They can be specified in 'pipe config'
+	 * only for backward compatibility.
+	 * Userland sets bw and delay in bits/s and milliseconds.
+	 * The kernel converts this back and forth to bits/tick and ticks.
+	 */
+	int32_t pipe_nr ;           /* N, number               */
+	int bandwidth;              /* B, really, bits/tick.   */
+	int delay ;                 /* D, really, ticks        */
+
+	/*
+	 * When the tx clock comes from an interface (if_name[0] != '\0'),
+	 * its name is stored below.
+	 */
+	char if_name[IFNAMSIZ];
+
+	/* fields to simulate a delay profile */
+#define ED_MAX_NAME_LEN         32
+	char name[ED_MAX_NAME_LEN];
+	int loss_level;
+	int samples_no;
+	int user_samples[0]; /* this has actually samples_no slots */
+
+	/*
+	 * The following parameters set at runtime and only valid
+	 * in the kernel. Userland should not look at these fields.
+	 */
+	int *samples; /* pointer to memory for user_samples[] */
+	struct ifnet *ifp;
+	int ready ; /* set if ifp != NULL and we got a signal from it */
+
+	SLIST_ENTRY(new_pipe) next; /* Global list of all pipes */
+};
+
+/*
+ * generic text string, in case we need one
+ */
+struct new_text {
+	struct dn_id id;
+	int len;
+	char text[0];	/* len bytes, NUL terminated */
+};
+
+/*
+ * description of a flow set.
+ * All flowset are linked in a list, there is a 1-1 mapping between
+ * 'ipfw queue XX ...' commands and flowset XX
+ * (plus there is a FIFO flowset for each pipe)
+ */
+struct new_fs {
+	struct dn_id id;
+
+	/* these initial fields are set from the command line
+	 * queue N config mask M pipe P buckets B plr PLR queue QSZ ...
+	 */
+	int fs_nr;  /* N, the flowset number */
+	/* The flowset implicitly created for pipe N is N+offset */
+
+	int qsize; /* QSZ, queue size in slots or bytes */
+
+	/* Number of buckets used for the hash table in this fs. */
+	int bucket;     /* B */
+	int plr ;       /* PLR, pkt loss rate (2^31-1 means 100%) */
+
+	/* Copy of command line  */
+	struct new_text *cmdline;
+
+	/* mask to select the appropriate queue */
+	struct ipfw_flow_id flow_mask;  /* M */
+	int sched_nr;   /* P, the pipe we attach to */
+
+	/*--- parameters set at runtime */
+	SLIST_ENTRY(new_fs) next;   /* list of flow sets */
+
+	/* Used to link flowset to be configured */
+	struct new_fs *confnext;
+
+	/* DN_FS_DELETE
+	* DN_FS_REENQUEUE
+	* DN_HAVE_FLOW_MASK
+	* DN_QSIZE_IS_BYTES
+	* DN_NOERROR
+	*/
+	int flags;
+
+	/* Number of queues attached to this flowset */
+	int active_f;
+
+	/* Number of packets in the scheduler mutex queue */
+	int busy;
+
+	/* Scheduler associated with this flowset, set when the
+	* scheduler for the pipe P is defined.
+	*/
+	struct new_sch *ptr_sched;
+	int ptr_sched_val; /* to check if the pointer is correct */
+
+	/*
+	* Pointer to scheduler-specific parameters for this flowset
+	* (for examples, the weight parameter of wf2q+ algorithm goes here)
+	*/
+	struct dn_id *alg_fs;
+	/* Pointer to scheduler functions */
+	struct scheduler *fp;
+};
+
+/*
+ * Scheduler instance.
+ * Contains variables and all queues relative to a this instance.
+ * This struct is created a runtime.
+ */
+struct new_sch_inst {
+	struct dn_id sch_id;
+
+	struct new_sch_inst *next; /* next item in the bucket */
+
+	/* Parent scheduler */
+	int sched_nr;
+	struct new_sch * ptr_sched;
+
+	int hash_slot; /* used to print the id of the scheduler instance */
+
+	/* flow id associated with this scheduler instance */
+	struct ipfw_flow_id id;
+
+	int flags;    /* DN_SCHED_ACTIVE */
+
+	/* Pointer to the delay line for this scheduler instance */
+	struct delay_line *dline;
+
+	/* List of queues that will be returned when user type a command like
+	* 'ipfw pipe | queue list'.
+	* List is automatically update when a queue is created and destroyed
+	*/
+	struct new_queue_head ql_list;
+
+	int64_t numbytes;       /* bits I can transmit (more or less). */
+	dn_key sched_time ;     /* time pipe was scheduled in ready_heap */
+	dn_key idle_time;       /* start of scheduler instance idle time */
+};
+
+/* Scheduler template
+ * All scheduler are linked in a list, there is a 1-1 mapping between
+ * 'ipfw sched XX ...' commands and sched XX
+ * (plus there is a FIFO scheduler for each pipe)
  */
+struct new_sch {
+	struct dn_id g;
+
+	/* these initial fields are set from the command line
+	* sched N config mask M ...
+	*/
+
+	int sched_nr; /* N, scheduler number */
+	uint64_t burst; /* burst size, scaled. bits*Hz */
+	int bucket; /* number of buckets for the instances */
+
+	/* mask to select the appropriate scheduler instance */
+	struct ipfw_flow_id sched_mask; /* M */
+
+	/*--- parameters set at runtime */
+
+	/* This structure is in a list of schedulers where we do
+	* the lookup when necessary. 'next' is the link field.
+	* Also, all instances of this scheduler may be in a heap used
+	* to fetch them when they are ready. 'inst_counter' counts
+	* how many instances are in the heap and can be used
+	* as a reference count.
+	*/
+	SLIST_ENTRY(new_sch) next;  /* List of all templates */
+
+	/* number of scheduler instances for this scheduler in the ready_heap
+	* Used to check when we can delete a scheduler safely
+	*/
+	int inst_counter;
+
+	/* Pointer to the parent pipe */
+	int pipe_nr;
+	struct new_pipe *ptr_pipe;
+
+	/* Copy of command line  */
+	#define DN_MAX_COMMAND  256
+	char command_line[DN_MAX_COMMAND];
+
+	/* Hash table contains all scheduler instances associated with
+	* this scheduler
+	*/
+	int sch_i_size;
+	int sch_i_elements;
+	struct new_sch_inst **sch_i;
+
+	/*
+	* DN_HAVE_SCH_MASK
+	* DN_SCH_DELETE
+	* DN_SCH_REENQUEUE
+	* DN_SCH_REENQUEUE
+	* DN_FORCE_DELETE_DELAY_LINE
+	*/
+	int flags;
+
+	/* Pointer to scheduler functions */
+	struct scheduler *fp;
+
+	/* Counter of packets pending to entering in this scheduler.
+	* Used to avoid to delete the scheduler if some packets are in the mutex
+	* queue
+	*/
+	int busy;
 
+	/* Mutex to protect a single scheduler */
+	// struct mtx sch_mtx;
+};
+
+/*---- old parameters ---*/
 /*
  * The maximum hash table size for queues.  This value must be a power
  * of 2.
  */
 #define DN_MAX_HASH_SIZE 65536
 
-typedef uint64_t dn_key;
 
 /*
  * Overall structure of dummynet (with WF2Q+):

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 18:39:21 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 76FA4106566C;
	Tue,  5 Jan 2010 18:39:21 +0000 (UTC)
	(envelope-from ermal.luci@gmail.com)
Received: from mail-ew0-f226.google.com (mail-ew0-f226.google.com
	[209.85.219.226])
	by mx1.freebsd.org (Postfix) with ESMTP id 6B9C98FC15;
	Tue,  5 Jan 2010 18:39:20 +0000 (UTC)
Received: by ewy26 with SMTP id 26so14563740ewy.3
	for <multiple recipients>; Tue, 05 Jan 2010 10:39:14 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:mime-version:sender:received:in-reply-to
	:references:from:date:x-google-sender-auth:message-id:subject:to:cc
	:content-type; bh=NvjJk014aARMrAeQhMeDJRSUU00wol6Pgf4FnLXl7yI=;
	b=TWAI8IszYzMCnAwOMzpQeMCwabMRJL/bRuR/pS2/bYb5MeoMu0sECD9cZNxhpcSmbz
	Aya81QMbB87y/HeSSpnVBvP6WGZ5GKV+eTbIHrRzgUsgqtp0BjWHRUXDYmE1HkyZEfSN
	hqThnCF0/Ei6keLVYygR5Q2w2zldPxVuhOvv4=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=mime-version:sender:in-reply-to:references:from:date
	:x-google-sender-auth:message-id:subject:to:cc:content-type;
	b=aEISDjKxPl8y24jH1D9FlWh2xxVW7ahvgoVH7TWdeMgHlpYvWStqv8eaDzx0CHdCqp
	oJ2+28+SG+yuStG6CsdIOxFMIq28GLl3ebbaPOSQCphOGaKO8pU32WjB2srcwGMyP3fU
	UvzBgTlT25J+vKBkkXzsyQgKkjwfkrX08Mlpk=
MIME-Version: 1.0
Sender: ermal.luci@gmail.com
Received: by 10.216.85.14 with SMTP id t14mr330044wee.222.1262716752906; Tue, 
	05 Jan 2010 10:39:12 -0800 (PST)
In-Reply-To: <20100105182643.GA93051@onelab2.iet.unipi.it>
References: <201001041658.o04GwFfG023749@svn.freebsd.org>
	<9a542da31001051006r61af058eg715c29ef0d3d2020@mail.gmail.com> 
	<20100105182643.GA93051@onelab2.iet.unipi.it>
From: =?ISO-8859-1?Q?Ermal_Lu=E7i?= <eri@freebsd.org>
Date: Tue, 5 Jan 2010 19:38:51 +0100
X-Google-Sender-Auth: e7c12a555a366916
Message-ID: <9a542da31001051038t9f253fbo79241b11dbba9100@mail.gmail.com>
To: Luigi Rizzo <rizzo@iet.unipi.it>
Content-Type: text/plain; charset=ISO-8859-1
X-Content-Filtered-By: Mailman/MimeDel 2.1.5
Cc: =?ISO-8859-1?Q?Ermal_Lu=E7i?= <eri@freebsd.org>,
	Luigi Rizzo <luigi@freebsd.org>, src-committers@freebsd.org,
	svn-src-user@freebsd.org
Subject: Re: svn commit: r201517 - in user/luigi/ipfw3-head/sys/netinet: . 
	ipfw
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: Tue, 05 Jan 2010 18:39:21 -0000

On Tue, Jan 5, 2010 at 7:26 PM, Luigi Rizzo <rizzo@iet.unipi.it> wrote:

> On Tue, Jan 05, 2010 at 07:06:51PM +0100, Ermal Lu?i wrote:
> > On Mon, Jan 4, 2010 at 5:58 PM, Luigi Rizzo <luigi@freebsd.org> wrote:
> >
> > > Author: luigi
> > > Date: Mon Jan  4 16:58:15 2010
> > > New Revision: 201517
> > > URL: http://svn.freebsd.org/changeset/base/201517
> > >
> > > Log:
> > >  divert has no specific API so we don't really need an ip_divert.h
> > >
> > >
> > >  DECLARE_MODULE(ipdivert, ipdivertmod, SI_SUB_PROTO_IFATTACHDOMAIN,
> > > SI_ORDER_ANY);
> > > -MODULE_DEPEND(dummynet, ipfw, 2, 2, 2);
> > > +MODULE_DEPEND(ipdivert, ipfw, 2, 2, 2);
> > >  MODULE_VERSION(ipdivert, 1);
> > >
> >
> > I would suggest to remove the dependency altogether  since divert(4) does
> > not really depend on ipfw(4). Furthermore, the newest pf(4) can work
> > together with divert(4) so the it will have more than one consumer in the
> > tree.
>
> I was not aware of pf support -- in fact, i wonder how divert could work
> without ipfw because the function pointer ip_divert_ptr at the moment
> is defined in ip_fw_pfil.c .
>
> There are in fact, I believe, two things that enforce the dependency:
> 1. the ip_divert_ptr above. We should move it elsewhere, in the
>  standard ip_* files;
>
> 2. the tag that is attached to the packet to record the reinject cookie
>  (I have recently redefined it as MTAG_IPFW_RULE because i was
>  not aware of the pf(4) support -- i need to revert/fix this if
>  we want divert and pf cooperation (though note that I tried to
>  have the same mtag format for all reinjected packets -- dummynet,
>  divert, netgraph, ... so once we fix it for one application it
>  should work for all with no special code).
>
> cheers
> luigi
>

Check it out here
http://svn.freebsd.org/viewvc/base/user/eri/pf45/head/

<http://svn.freebsd.org/viewvc/base/user/eri/pf45/head/>The divert support
with the pointer moving is commit 198045 for checking on how i have done in
that branch. If you find a better solution go ahead and i will update the
referenced pf branch as well.



-- 
Ermal

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 22:50:36 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 AC39B106568F;
	Tue,  5 Jan 2010 22:50:36 +0000 (UTC)
	(envelope-from rpaulo@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 9C0E98FC1B;
	Tue,  5 Jan 2010 22:50:36 +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 o05Moae3036804;
	Tue, 5 Jan 2010 22:50:36 GMT (envelope-from rpaulo@svn.freebsd.org)
Received: (from rpaulo@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o05MoaKo036802;
	Tue, 5 Jan 2010 22:50:36 GMT (envelope-from rpaulo@svn.freebsd.org)
Message-Id: <201001052250.o05MoaKo036802@svn.freebsd.org>
From: Rui Paulo <rpaulo@FreeBSD.org>
Date: Tue, 5 Jan 2010 22:50:36 +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: r201618 - user/rpaulo/ubthidctl
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: Tue, 05 Jan 2010 22:50:36 -0000

Author: rpaulo
Date: Tue Jan  5 22:50:36 2010
New Revision: 201618
URL: http://svn.freebsd.org/changeset/base/201618

Log:
  Try to cope with the new usb stack.

Modified:
  user/rpaulo/ubthidctl/ubthidctl.c

Modified: user/rpaulo/ubthidctl/ubthidctl.c
==============================================================================
--- user/rpaulo/ubthidctl/ubthidctl.c	Tue Jan  5 22:37:05 2010	(r201617)
+++ user/rpaulo/ubthidctl/ubthidctl.c	Tue Jan  5 22:50:36 2010	(r201618)
@@ -22,9 +22,6 @@
  * 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.
- *
- * $FreeBSD$
- *
  */
 
 /*
@@ -33,9 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-#ifdef __FreeBSD__
 __FBSDID("$FreeBSD$");
-#endif
 
 #include <err.h>
 #include <fcntl.h>
@@ -46,7 +41,8 @@ __FBSDID("$FreeBSD$");
 
 #include <sys/ioctl.h>
 
-#include <dev/usb/usb.h>
+#include <dev/usb/usb_ioctl.h>
+#include <dev/usb/usbdi.h>
 
 typedef enum {
 	HCI = 0,
@@ -81,7 +77,7 @@ finddevice(tblentry_t tblentry)
 	dev.devno = -1;
 	
 	for (i = 0; i < 20; i++) {
-		snprintf(filename, sizeof(filename) - 1, "/dev/usb%d", i); 
+		snprintf(filename, sizeof(filename) - 1, "/dev/ugen%d.1", i); 
 		fd = open(filename, O_RDONLY);
 		if (fd < 0)
 			return dev;
@@ -171,7 +167,7 @@ switchmode(const char *dev, const int de
 	USETW(req.ucr_request.wIndex, 0);
 	USETW(req.ucr_request.wLength, 0);
 	req.ucr_data = NULL;
-	req.ucr_flags = USBD_SHORT_XFER_OK;
+	req.ucr_flags = USB_SHORT_XFER_OK;
 	req.ucr_request.bmRequestType = UT_VENDOR;
 	req.ucr_request.bRequest = 0;
 

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 22:53:20 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 BC9D11065672;
	Tue,  5 Jan 2010 22:53:20 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id AAF9A8FC19;
	Tue,  5 Jan 2010 22:53:20 +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 o05MrKgO037494;
	Tue, 5 Jan 2010 22:53:20 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o05MrKxc037489;
	Tue, 5 Jan 2010 22:53:20 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001052253.o05MrKxc037489@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Tue, 5 Jan 2010 22:53:20 +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: r201619 - user/ed/utmpx/lib/libc/gen
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: Tue, 05 Jan 2010 22:53:20 -0000

Author: ed
Date: Tue Jan  5 22:53:20 2010
New Revision: 201619
URL: http://svn.freebsd.org/changeset/base/201619

Log:
  Partially implement pututxline().
  
  Right now it only writes entries to the lastlog and wtmp files, called
  utx.lastlogin and utx.log.

Added:
  user/ed/utmpx/lib/libc/gen/pututxline.c   (contents, props changed)
  user/ed/utmpx/lib/libc/gen/utxdb.h   (contents, props changed)
Modified:
  user/ed/utmpx/lib/libc/gen/Makefile.inc
  user/ed/utmpx/lib/libc/gen/getutxent.c

Modified: user/ed/utmpx/lib/libc/gen/Makefile.inc
==============================================================================
--- user/ed/utmpx/lib/libc/gen/Makefile.inc	Tue Jan  5 22:50:36 2010	(r201618)
+++ user/ed/utmpx/lib/libc/gen/Makefile.inc	Tue Jan  5 22:53:20 2010	(r201619)
@@ -23,7 +23,7 @@ SRCS+=  __getosreldate.c __xuname.c \
 	lockf.c lrand48.c mrand48.c nftw.c nice.c \
 	nlist.c nrand48.c opendir.c \
 	pause.c pmadvise.c popen.c posix_spawn.c \
-	psignal.c pw_scan.c pwcache.c \
+	psignal.c pututxline.c pw_scan.c pwcache.c \
 	raise.c readdir.c readpassphrase.c rewinddir.c \
 	scandir.c seed48.c seekdir.c sem.c semctl.c \
 	setdomainname.c sethostname.c setjmperr.c setmode.c \

Modified: user/ed/utmpx/lib/libc/gen/getutxent.c
==============================================================================
--- user/ed/utmpx/lib/libc/gen/getutxent.c	Tue Jan  5 22:50:36 2010	(r201618)
+++ user/ed/utmpx/lib/libc/gen/getutxent.c	Tue Jan  5 22:53:20 2010	(r201619)
@@ -58,13 +58,6 @@ getutxline(const struct utmpx *line)
 	return (NULL);
 }
 
-struct utmpx *
-pututxline(const struct utmpx *utmpx)
-{
-
-	return (NULL);
-}
-
 void
 setutxent(void)
 {

Added: user/ed/utmpx/lib/libc/gen/pututxline.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/ed/utmpx/lib/libc/gen/pututxline.c	Tue Jan  5 22:53:20 2010	(r201619)
@@ -0,0 +1,183 @@
+/*-
+ * Copyright (c) 2010 Ed Schouten <ed@FreeBSD.org>
+ * 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 AND CONTRIBUTORS ``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.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <fcntl.h>
+#include <string.h>
+#include <unistd.h>
+#include <utmpx.h>
+#include "utxdb.h"
+
+static int
+utx_to_futx(const struct utmpx *ut, struct futx *fu)
+{
+
+	memset(fu, 0, sizeof *fu);
+
+	switch (ut->ut_type) {
+	case BOOT_TIME:
+	case OLD_TIME:
+	case NEW_TIME:
+	/* Extension: shutdown time. */
+	case SHUTDOWN_TIME:
+		break;
+	case USER_PROCESS:
+		UTOF_STRING(ut, fu, id);
+		UTOF_STRING(ut, fu, user);
+		UTOF_STRING(ut, fu, line);
+		/* Extension: host name. */
+		UTOF_STRING(ut, fu, host);
+		UTOF_PID(ut, fu);
+		break;
+#if 0
+	case INIT_PROCESS:
+		UTOF_STRING(ut, fu, id);
+		UTOF_PID(ut, fu);
+		break;
+	case LOGIN_PROCESS:
+		UTOF_STRING(ut, fu, id);
+		UTOF_STRING(ut, fu, user);
+		UTOF_PID(ut, fu);
+		break;
+#endif
+	case DEAD_PROCESS:
+		UTOF_STRING(ut, fu, id);
+		UTOF_PID(ut, fu);
+		break;
+	default:
+		return (-1);
+	}
+
+	UTOF_TYPE(ut, fu);
+	UTOF_TV(ut, fu);
+
+	return (0);
+}
+
+static void
+utx_active_add(const struct futx *fu)
+{
+}
+
+static int
+utx_active_remove(const struct futx *fu)
+{
+
+	return (0);
+}
+
+static void
+utx_lastlogin_add(const struct futx *fu)
+{
+	int fd;
+	struct futx fe;
+
+	/*
+	 * Write an entry to lastlogin.  Overwrite the entry if the
+	 * current user already has an entry.  If not, append a new
+	 * entry.
+	 */
+	fd = open(_PATH_UTX_LASTLOGIN, O_CREAT|O_RDWR, 0644);
+	if (fd < 0)
+		return;
+	if (lockf(fd, F_LOCK, 0) == -1) {
+		close(fd);
+		return;
+	}
+	while (read(fd, &fe, sizeof fe) == sizeof fe) {
+		if (strncmp(fu->fu_user, fe.fu_user, sizeof fe.fu_user) == 0) {
+			lseek(fd, -sizeof fe, SEEK_CUR);
+			break;
+		}
+	}
+	write(fd, fu, sizeof *fu);
+	lockf(fd, F_ULOCK, 0);
+	close(fd);
+}
+
+static void
+utx_log_add(const struct futx *fu)
+{
+	struct {
+		uint16_t	len;
+		struct futx	data;
+	} __packed r;
+	size_t l;
+	int f;
+
+	/*
+	 * Append an entry to the log file.  We only need to append
+	 * records to this file, so to conserve space, trim any trailing
+	 * zero-bytes.  Prepend a length field, indicating the record of
+	 * the length, excluding the length field itself.
+	 */
+	for (l = sizeof *fu; l > 0 && ((char *)fu)[l - 1] == '\0'; l--);
+	r.len = htobe16(l);
+	memcpy(&r.data, fu, l);
+
+	f = open(_PATH_UTX_LOG, O_CREAT|O_WRONLY|O_APPEND, 0644);
+	if (f < 0)
+		return;
+	write(f, &r, sizeof r.len + l);
+	close(f);
+}
+
+struct utmpx *
+pututxline(const struct utmpx *utmpx)
+{
+	struct futx fu;
+
+	if (utx_to_futx(utmpx, &fu) != 0)
+		return (NULL);
+	
+	switch (utmpx->ut_type) {
+	case BOOT_TIME:
+	case OLD_TIME:
+	case NEW_TIME:
+	case SHUTDOWN_TIME:
+		utx_log_add(&fu);
+		break;
+	case USER_PROCESS:
+		utx_active_add(&fu);
+		utx_lastlogin_add(&fu);
+		utx_log_add(&fu);
+		break;
+#if 0
+	case INIT_PROCESS:
+	case LOGIN_PROCESS:
+#endif
+	case DEAD_PROCESS:
+		if (utx_active_remove(&fu) != 0)
+			return (NULL);
+		utx_log_add(&fu);
+	}
+
+	return (NULL);
+}

Added: user/ed/utmpx/lib/libc/gen/utxdb.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/ed/utmpx/lib/libc/gen/utxdb.h	Tue Jan  5 22:53:20 2010	(r201619)
@@ -0,0 +1,74 @@
+/*-
+ * Copyright (c) 2010 Ed Schouten <ed@FreeBSD.org>
+ * 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 AND CONTRIBUTORS ``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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _UTXDB_H_
+#define	_UTXDB_H_
+
+#include <sys/cdefs.h>
+#include <sys/endian.h>
+#include <sys/param.h>
+#include <stdint.h>
+
+#define	_PATH_UTX_ACTIVE	"/var/run/utx.active"
+#define	_PATH_UTX_LASTLOGIN	"/var/log/utx.lastlogin"
+#define	_PATH_UTX_LOG		"/var/log/utx.log"
+
+/*
+ * Entries in struct futx are ordered by how often they are used.  In
+ * utx.log only entries will be written until the last non-zero byte,
+ * which means we want to put the hostname at the end. Most primitive
+ * records only store a ut_type and ut_tv, which means we want to store
+ * those at the front.
+ */
+
+struct futx {
+	uint8_t		fu_type;
+	uint64_t	fu_tv;
+	char		fu_id[8];
+	uint32_t	fu_pid;
+	char		fu_user[32];
+	char		fu_line[32];
+	char		fu_host[256];
+} __packed;
+
+#define	UTOF_STRING(ut, fu, field) do { \
+	strncpy((fu)->fu_ ## field, (ut)->ut_ ## field,		\
+	    MIN(sizeof (fu)->fu_ ## field, sizeof (ut)->ut_ ## field));	\
+} while (0)
+#define	UTOF_PID(ut, fu) do { \
+	(fu)->fu_pid = htobe32((ut)->ut_pid);				\
+} while (0)
+#define	UTOF_TYPE(ut, fu) do { \
+	(fu)->fu_type = (ut)->ut_type;					\
+} while (0)
+#define	UTOF_TV(ut, fu) do { \
+	(fu)->fu_tv = htobe64((uint64_t)(ut)->ut_tv.tv_sec * 1000000 +	\
+	    (uint64_t)(ut)->ut_tv.tv_usec);				\
+} while (0)
+
+#endif /* !_UTXDB_H_ */

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 23:01: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 A8AA81065696;
	Tue,  5 Jan 2010 23:01:46 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 9877E8FC1A;
	Tue,  5 Jan 2010 23:01: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 o05N1krH039542;
	Tue, 5 Jan 2010 23:01:46 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o05N1kIT039540;
	Tue, 5 Jan 2010 23:01:46 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001052301.o05N1kIT039540@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Tue, 5 Jan 2010 23:01: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: r201621 - user/ed/utmpx/lib/libc/gen
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: Tue, 05 Jan 2010 23:01:46 -0000

Author: ed
Date: Tue Jan  5 23:01:46 2010
New Revision: 201621
URL: http://svn.freebsd.org/changeset/base/201621

Log:
  Also implement utx_active_add() for now.
  
  This means we at least write to all three the database files, which
  means I can implement and test the reading functions.

Modified:
  user/ed/utmpx/lib/libc/gen/pututxline.c

Modified: user/ed/utmpx/lib/libc/gen/pututxline.c
==============================================================================
--- user/ed/utmpx/lib/libc/gen/pututxline.c	Tue Jan  5 22:59:59 2010	(r201620)
+++ user/ed/utmpx/lib/libc/gen/pututxline.c	Tue Jan  5 23:01:46 2010	(r201621)
@@ -84,6 +84,33 @@ utx_to_futx(const struct utmpx *ut, stru
 static void
 utx_active_add(const struct futx *fu)
 {
+	int fd;
+	struct futx fe;
+
+	/*
+	 * Register user login sessions.  Overwrite entries of sessions
+	 * that have already been terminated.
+	 */
+	fd = open(_PATH_UTX_ACTIVE, O_CREAT|O_RDWR, 0644);
+	if (fd < 0)
+		return;
+	if (lockf(fd, F_LOCK, 0) == -1) {
+		close(fd);
+		return;
+	}
+	while (read(fd, &fe, sizeof fe) == sizeof fe) {
+		/*
+		 * XXX: This check is invalid.  We should perform a
+		 * similar comparison as getutxid().
+		 */
+		if (fe.fu_type != USER_PROCESS) {
+			lseek(fd, -sizeof fe, SEEK_CUR);
+			break;
+		}
+	}
+	write(fd, fu, sizeof *fu);
+	lockf(fd, F_ULOCK, 0);
+	close(fd);
 }
 
 static int

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 23:09:34 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 5F478106566B;
	Tue,  5 Jan 2010 23:09:34 +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 4ED278FC14;
	Tue,  5 Jan 2010 23:09:34 +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 o05N9YhU041396;
	Tue, 5 Jan 2010 23:09:34 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o05N9Yo6041394;
	Tue, 5 Jan 2010 23:09:34 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001052309.o05N9Yo6041394@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Tue, 5 Jan 2010 23:09:34 +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: r201623 - 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: Tue, 05 Jan 2010 23:09:34 -0000

Author: kmacy
Date: Tue Jan  5 23:09:34 2010
New Revision: 201623
URL: http://svn.freebsd.org/changeset/base/201623

Log:
  shim sx locks

Modified:
  user/kmacy/releng_8_rump/lib/libunet/unet_lock.c

Modified: user/kmacy/releng_8_rump/lib/libunet/unet_lock.c
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/unet_lock.c	Tue Jan  5 23:03:59 2010	(r201622)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_lock.c	Tue Jan  5 23:09:34 2010	(r201623)
@@ -277,19 +277,29 @@ _rm_runlock(struct rmlock *rm,  struct r
 }
 
 
+struct lock_class lock_class_sx = {
+	.lc_name = "sx",
+	.lc_flags = LC_SLEEPLOCK | LC_SLEEPABLE | LC_RECURSABLE | LC_UPGRADABLE,
+#ifdef DDB
+	.lc_ddb_show = db_show_sx,
+#endif
+#ifdef KDTRACE_HOOKS
+	.lc_owner = owner_sx,
+#endif
+};
 
 void
 sx_init_flags(struct sx *sx, const char *description, int opts)
 {
 
-	panic("");
+	rw_init_flags((struct rwlock *)sx, description, opts);
 }
 
 void
 sx_destroy(struct sx *sx)
 {
 
-	panic("");
+	rw_destroy((struct rwlock *)sx);
 }
 
 int
@@ -297,7 +307,7 @@ _sx_xlock_hard(struct sx *sx, uintptr_t 
     const char *file, int line)
 {
 	
-	panic("");
+	_rw_wlock((struct rwlock *)sx, file, line);
 	return (0);
 }
 
@@ -305,7 +315,7 @@ int
 _sx_slock_hard(struct sx *sx, int opts, const char *file, int line)
 {
 	
-	panic("");
+	_rw_rlock((struct rwlock *)sx, file, line);
 	return (0);
 }
 
@@ -314,21 +324,20 @@ _sx_xunlock_hard(struct sx *sx, uintptr_
     line)
 {
 	
-	panic("");
+	_rw_wunlock((struct rwlock *)sx, file, line);
 }
 
 void
 _sx_sunlock_hard(struct sx *sx, const char *file, int line)
 {
 	
-	panic("");
+	_rw_runlock((struct rwlock *)sx, file, line);
 }
 
 int
 _sx_try_xlock(struct sx *sx, const char *file, int line)
 {
-	
-	panic("");
-	return (0);
+
+	return (_rw_try_wlock((struct rwlock *)sx, file, line));
 }
 

From owner-svn-src-user@FreeBSD.ORG  Tue Jan  5 23:26:45 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 D9585106566C;
	Tue,  5 Jan 2010 23:26:45 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id BE1008FC08;
	Tue,  5 Jan 2010 23:26:45 +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 o05NQjhO045721;
	Tue, 5 Jan 2010 23:26:45 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o05NQj7s045718;
	Tue, 5 Jan 2010 23:26:45 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001052326.o05NQj7s045718@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Tue, 5 Jan 2010 23:26:45 +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: r201624 - user/ed/utmpx/lib/libc/gen
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: Tue, 05 Jan 2010 23:26:46 -0000

Author: ed
Date: Tue Jan  5 23:26:45 2010
New Revision: 201624
URL: http://svn.freebsd.org/changeset/base/201624

Log:
  Last commit for today. Don't forget the un-namespacing.

Modified:
  user/ed/utmpx/lib/libc/gen/getutxent.c
  user/ed/utmpx/lib/libc/gen/pututxline.c

Modified: user/ed/utmpx/lib/libc/gen/getutxent.c
==============================================================================
--- user/ed/utmpx/lib/libc/gen/getutxent.c	Tue Jan  5 23:09:34 2010	(r201623)
+++ user/ed/utmpx/lib/libc/gen/getutxent.c	Tue Jan  5 23:26:45 2010	(r201624)
@@ -29,8 +29,10 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include "namespace.h"
 #include <stdio.h>
 #include <utmpx.h>
+#include "un-namespace.h"
 
 void
 endutxent(void)

Modified: user/ed/utmpx/lib/libc/gen/pututxline.c
==============================================================================
--- user/ed/utmpx/lib/libc/gen/pututxline.c	Tue Jan  5 23:09:34 2010	(r201623)
+++ user/ed/utmpx/lib/libc/gen/pututxline.c	Tue Jan  5 23:26:45 2010	(r201624)
@@ -29,11 +29,13 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include "namespace.h"
 #include <fcntl.h>
 #include <string.h>
 #include <unistd.h>
 #include <utmpx.h>
 #include "utxdb.h"
+#include "un-namespace.h"
 
 static int
 utx_to_futx(const struct utmpx *ut, struct futx *fu)
@@ -91,14 +93,14 @@ utx_active_add(const struct futx *fu)
 	 * Register user login sessions.  Overwrite entries of sessions
 	 * that have already been terminated.
 	 */
-	fd = open(_PATH_UTX_ACTIVE, O_CREAT|O_RDWR, 0644);
+	fd = _open(_PATH_UTX_ACTIVE, O_CREAT|O_RDWR, 0644);
 	if (fd < 0)
 		return;
 	if (lockf(fd, F_LOCK, 0) == -1) {
-		close(fd);
+		_close(fd);
 		return;
 	}
-	while (read(fd, &fe, sizeof fe) == sizeof fe) {
+	while (_read(fd, &fe, sizeof fe) == sizeof fe) {
 		/*
 		 * XXX: This check is invalid.  We should perform a
 		 * similar comparison as getutxid().
@@ -108,9 +110,9 @@ utx_active_add(const struct futx *fu)
 			break;
 		}
 	}
-	write(fd, fu, sizeof *fu);
+	_write(fd, fu, sizeof *fu);
 	lockf(fd, F_ULOCK, 0);
-	close(fd);
+	_close(fd);
 }
 
 static int
@@ -131,22 +133,22 @@ utx_lastlogin_add(const struct futx *fu)
 	 * current user already has an entry.  If not, append a new
 	 * entry.
 	 */
-	fd = open(_PATH_UTX_LASTLOGIN, O_CREAT|O_RDWR, 0644);
+	fd = _open(_PATH_UTX_LASTLOGIN, O_CREAT|O_RDWR, 0644);
 	if (fd < 0)
 		return;
 	if (lockf(fd, F_LOCK, 0) == -1) {
-		close(fd);
+		_close(fd);
 		return;
 	}
-	while (read(fd, &fe, sizeof fe) == sizeof fe) {
+	while (_read(fd, &fe, sizeof fe) == sizeof fe) {
 		if (strncmp(fu->fu_user, fe.fu_user, sizeof fe.fu_user) == 0) {
 			lseek(fd, -sizeof fe, SEEK_CUR);
 			break;
 		}
 	}
-	write(fd, fu, sizeof *fu);
+	_write(fd, fu, sizeof *fu);
 	lockf(fd, F_ULOCK, 0);
-	close(fd);
+	_close(fd);
 }
 
 static void
@@ -169,11 +171,11 @@ utx_log_add(const struct futx *fu)
 	r.len = htobe16(l);
 	memcpy(&r.data, fu, l);
 
-	f = open(_PATH_UTX_LOG, O_CREAT|O_WRONLY|O_APPEND, 0644);
+	f = _open(_PATH_UTX_LOG, O_CREAT|O_WRONLY|O_APPEND, 0644);
 	if (f < 0)
 		return;
-	write(f, &r, sizeof r.len + l);
-	close(f);
+	_write(f, &r, sizeof r.len + l);
+	_close(f);
 }
 
 struct utmpx *
@@ -189,12 +191,10 @@ pututxline(const struct utmpx *utmpx)
 	case OLD_TIME:
 	case NEW_TIME:
 	case SHUTDOWN_TIME:
-		utx_log_add(&fu);
 		break;
 	case USER_PROCESS:
 		utx_active_add(&fu);
 		utx_lastlogin_add(&fu);
-		utx_log_add(&fu);
 		break;
 #if 0
 	case INIT_PROCESS:
@@ -203,8 +203,10 @@ pututxline(const struct utmpx *utmpx)
 	case DEAD_PROCESS:
 		if (utx_active_remove(&fu) != 0)
 			return (NULL);
-		utx_log_add(&fu);
+	default:
+		return (NULL);
 	}
 
+	utx_log_add(&fu);
 	return (NULL);
 }

From owner-svn-src-user@FreeBSD.ORG  Wed Jan  6 01:59:20 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 CEC42106566B;
	Wed,  6 Jan 2010 01:59:20 +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 B3EE48FC08;
	Wed,  6 Jan 2010 01:59:20 +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 o061xKxr079657;
	Wed, 6 Jan 2010 01:59:20 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o061xKu7079656;
	Wed, 6 Jan 2010 01:59:20 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001060159.o061xKu7079656@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Wed, 6 Jan 2010 01:59:20 +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: r201628 - 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: Wed, 06 Jan 2010 01:59:21 -0000

Author: kmacy
Date: Wed Jan  6 01:59:20 2010
New Revision: 201628
URL: http://svn.freebsd.org/changeset/base/201628

Log:
  implement most of sleep / wakeup

Modified:
  user/kmacy/releng_8_rump/lib/libunet/unet_kern_synch.c

Modified: user/kmacy/releng_8_rump/lib/libunet/unet_kern_synch.c
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/unet_kern_synch.c	Wed Jan  6 00:20:37 2010	(r201627)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_kern_synch.c	Wed Jan  6 01:59:20 2010	(r201628)
@@ -11,6 +11,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/kernel.h>
 #include <sys/ktr.h>
 #include <sys/lock.h>
+#include <sys/malloc.h>
 #include <sys/mutex.h>
 #include <sys/proc.h>
 #include <sys/resourcevar.h>
@@ -20,15 +21,76 @@ __FBSDID("$FreeBSD$");
 #include <sys/smp.h>
 #include <sys/sx.h>
 #include <sys/sysctl.h>
-#include <sys/sysproto.h>
 #include <sys/vmmeter.h>
 #ifdef KTRACE
 #include <sys/uio.h>
 #include <sys/ktrace.h>
 #endif
 
+#include <pthread.h>
+
 int	hogticks;
 
+typedef struct sleep_entry {
+	void 		*chan;
+	const char 	*wmesg;
+	pthread_cond_t	cond;
+	int		waiters;
+} *sleep_entry_t;
+
+static void synch_setup(void *dummy);
+SYSINIT(synch_setup, SI_SUB_KICK_SCHEDULER, SI_ORDER_FIRST, synch_setup,
+    NULL);
+
+static struct se_head *se_active;
+static u_long se_hashmask;
+static pthread_mutex_t synch_lock;
+
+static void
+synch_setup(void *arg)
+{
+	pthread_mutexattr_t attr;
+
+	pthread_mutexattr_init(&attr);
+	pthread_mutex_init(&synch_lock, &attr);
+	se_active = hashinit(64, M_TEMP, &se_hashmask);
+}
+
+sleep_entry_t
+se_alloc(void *chan, const char *wmesg)
+{
+	sleep_entry_t se;
+	pthread_condattr_t attr;
+
+	se = malloc(sizeof(*se), M_DEVBUF, 0);
+	se->chan = chan;
+	se->wmesg = wmesg;
+	pthread_condattr_init(&attr);
+	pthread_cond_init(&se->cond, &attr);
+
+	/* insert in hash table */
+	return (se);
+}
+
+sleep_entry_t
+se_lookup(void *chan)
+{
+	/* lookup in hashtable */
+	return (NULL);
+}
+
+void
+se_free(sleep_entry_t se)
+{
+
+	if (--se->waiters == 0) {
+		/* unlink se */
+		pthread_cond_destroy(&se->cond);
+		free(se, M_DEVBUF);
+	}
+}
+		
+
 /*
  * General sleep call.  Suspends the current thread until a wakeup is
  * performed on the specified identifier.  The thread will then be made
@@ -48,22 +110,49 @@ int
 _sleep(void *ident, struct lock_object *lock, int priority,
     const char *wmesg, int timo)
 {
+	sleep_entry_t se;
+	int rv;
+	struct timespec ts;
+
+	pthread_mutex_lock(&synch_lock);
+	if ((se = se_lookup(ident)) != NULL)
+		se->waiters++;
+	else
+		se = se_alloc(ident, wmesg);
+	pthread_mutex_unlock(&synch_lock);
+	
+	if (timo)
+		rv = pthread_cond_timedwait(&se->cond, &lock->lo_mutex, &ts);
+	else
+		rv = pthread_cond_wait(&se->cond, &lock->lo_mutex);
+
+	pthread_mutex_lock(&synch_lock);
+	se_free(se);
+	pthread_mutex_unlock(&synch_lock);	
 
-	panic("");
+	return (rv);
 }
 
 void
 wakeup(void *chan)
 {
-	panic("");
-	
+	sleep_entry_t se;
+
+	pthread_mutex_lock(&synch_lock);
+	if ((se = se_lookup(chan)) != NULL)
+		pthread_cond_broadcast(&se->cond);
+	pthread_mutex_unlock(&synch_lock);
 }
 
 
 void
 wakeup_one(void *chan)
 {
+	sleep_entry_t se;
 
-	panic("");
+	pthread_mutex_lock(&synch_lock);
+	if ((se = se_lookup(chan)) != NULL)
+		pthread_cond_signal(&se->cond);
+	pthread_mutex_unlock(&synch_lock);
 }
 

From owner-svn-src-user@FreeBSD.ORG  Wed Jan  6 07:50:27 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 D2B9C1065672;
	Wed,  6 Jan 2010 07:50:27 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id C2CBC8FC14;
	Wed,  6 Jan 2010 07:50:27 +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 o067oR3s058868;
	Wed, 6 Jan 2010 07:50:27 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o067oRLV058865;
	Wed, 6 Jan 2010 07:50:27 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001060750.o067oRLV058865@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Wed, 6 Jan 2010 07:50:27 +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: r201632 - user/ed/utmpx/crypto/openssh
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: Wed, 06 Jan 2010 07:50:27 -0000

Author: ed
Date: Wed Jan  6 07:50:27 2010
New Revision: 201632
URL: http://svn.freebsd.org/changeset/base/201632

Log:
  Make OpenSSH and utmpx actually work.
  
  I wonder why I need these modifications. I would have expected OpenSSH
  to work out of the box.

Modified:
  user/ed/utmpx/crypto/openssh/defines.h
  user/ed/utmpx/crypto/openssh/loginrec.c

Modified: user/ed/utmpx/crypto/openssh/defines.h
==============================================================================
--- user/ed/utmpx/crypto/openssh/defines.h	Wed Jan  6 06:42:08 2010	(r201631)
+++ user/ed/utmpx/crypto/openssh/defines.h	Wed Jan  6 07:50:27 2010	(r201632)
@@ -674,7 +674,7 @@ struct winsize {
 #else
 /* Simply select your favourite login types. */
 /* Can't do if-else because some systems use several... <sigh> */
-#  if defined(UTMPX_FILE) && !defined(DISABLE_UTMPX)
+#  if !defined(DISABLE_UTMPX)
 #    define USE_UTMPX
 #  endif
 #  if defined(UTMP_FILE) && !defined(DISABLE_UTMP)

Modified: user/ed/utmpx/crypto/openssh/loginrec.c
==============================================================================
--- user/ed/utmpx/crypto/openssh/loginrec.c	Wed Jan  6 06:42:08 2010	(r201631)
+++ user/ed/utmpx/crypto/openssh/loginrec.c	Wed Jan  6 07:50:27 2010	(r201632)
@@ -758,8 +758,8 @@ construct_utmpx(struct logininfo *li, st
 	utx->ut_pid = li->pid;
 
 	/* strncpy(): Don't necessarily want null termination */
-	strncpy(utx->ut_name, li->username,
-	    MIN_SIZEOF(utx->ut_name, li->username));
+	strncpy(utx->ut_user, li->username,
+	    MIN_SIZEOF(utx->ut_user, li->username));
 
 	if (li->type == LTYPE_LOGOUT)
 		return;

From owner-svn-src-user@FreeBSD.ORG  Wed Jan  6 10:29:54 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 58ADD1065693;
	Wed,  6 Jan 2010 10:29:54 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 4748D8FC12;
	Wed,  6 Jan 2010 10:29:54 +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 o06ATsmu096577;
	Wed, 6 Jan 2010 10:29:54 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o06ATsvs096571;
	Wed, 6 Jan 2010 10:29:54 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001061029.o06ATsvs096571@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Wed, 6 Jan 2010 10:29:54 +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: r201637 - in user/ed/utmpx: include lib/libc/gen
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: Wed, 06 Jan 2010 10:29:54 -0000

Author: ed
Date: Wed Jan  6 10:29:53 2010
New Revision: 201637
URL: http://svn.freebsd.org/changeset/base/201637

Log:
  Make utmpx actually work.

Modified:
  user/ed/utmpx/include/utmpx.h
  user/ed/utmpx/lib/libc/gen/Symbol.map
  user/ed/utmpx/lib/libc/gen/getutxent.c
  user/ed/utmpx/lib/libc/gen/pututxline.c
  user/ed/utmpx/lib/libc/gen/utxdb.h

Modified: user/ed/utmpx/include/utmpx.h
==============================================================================
--- user/ed/utmpx/include/utmpx.h	Wed Jan  6 10:21:16 2010	(r201636)
+++ user/ed/utmpx/include/utmpx.h	Wed Jan  6 10:29:53 2010	(r201637)
@@ -42,7 +42,11 @@ struct utmpx {
 	char		ut_user[32];
 	char		ut_id[8];
 	char		ut_line[32];
-	char		ut_host[256];
+#if __BSD_VISIBLE
+	char		ut_host[128];
+#else
+	char		__ut_host[128];
+#endif
 	pid_t		ut_pid;
 	short		ut_type;
 #define	EMPTY		0
@@ -59,6 +63,12 @@ struct utmpx {
 	struct timeval	ut_tv;
 };
 
+#if __BSD_VISIBLE
+#define	UTXDB_ACTIVE	0
+#define	UTXDB_LASTLOGIN	1
+#define	UTXDB_LOG	2
+#endif
+
 __BEGIN_DECLS
 void	endutxent(void);
 struct utmpx *getutxent(void);
@@ -66,6 +76,10 @@ struct utmpx *getutxid(const struct utmp
 struct utmpx *getutxline(const struct utmpx *);
 struct utmpx *pututxline(const struct utmpx *);
 void	setutxent(void);
+
+#if __BSD_VISIBLE
+int	setutxdb(int, const char *);
+#endif
 __END_DECLS
 
 #endif /* !_UTMPX_H_ */

Modified: user/ed/utmpx/lib/libc/gen/Symbol.map
==============================================================================
--- user/ed/utmpx/lib/libc/gen/Symbol.map	Wed Jan  6 10:21:16 2010	(r201636)
+++ user/ed/utmpx/lib/libc/gen/Symbol.map	Wed Jan  6 10:29:53 2010	(r201637)
@@ -373,6 +373,7 @@ FBSD_1.2 {
 	getutxid;
 	getutxline;
 	pututxline;
+	setutxdb;
 	setutxent;
 };
 

Modified: user/ed/utmpx/lib/libc/gen/getutxent.c
==============================================================================
--- user/ed/utmpx/lib/libc/gen/getutxent.c	Wed Jan  6 10:21:16 2010	(r201636)
+++ user/ed/utmpx/lib/libc/gen/getutxent.c	Wed Jan  6 10:29:53 2010	(r201637)
@@ -22,45 +22,219 @@
  * 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.
- *
- * $FreeBSD$
  */
 
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
 #include "namespace.h"
+#include <errno.h>
 #include <stdio.h>
+#include <string.h>
 #include <utmpx.h>
+#include "utxdb.h"
 #include "un-namespace.h"
 
+static FILE *uf = NULL;
+static int udb;
+static struct utmpx utx;
+
+int
+setutxdb(int db, const char *file)
+{
+
+	switch (db) {
+	case UTXDB_ACTIVE:
+		if (file == NULL)
+			file = _PATH_UTX_ACTIVE;
+		break;
+	case UTXDB_LASTLOGIN:
+		if (file == NULL)
+			file = _PATH_UTX_LASTLOGIN;
+		break;
+	case UTXDB_LOG:
+		if (file == NULL)
+			file = _PATH_UTX_LOG;
+		break;
+	default:
+		errno = EINVAL;
+		return (-1);
+	}
+
+	if (uf != NULL)
+		fclose(uf);
+	uf = fopen(file, "r");
+	if (uf == NULL)
+		return (-1);
+	udb = db;
+	return (0);
+}
+
+void
+setutxent(void)
+{
+
+	setutxdb(UTXDB_ACTIVE, NULL);
+}
+
 void
 endutxent(void)
 {
+
+	if (uf != NULL) {
+		fclose(uf);
+		uf = NULL;
+	}
+}
+
+static void
+futx_to_utx(const struct futx *fu, struct utmpx *ut)
+{
+
+	memset(ut, 0, sizeof *ut);
+
+	switch (fu->fu_type) {
+	case BOOT_TIME:
+	case OLD_TIME:
+	case NEW_TIME:
+	/* Extension: shutdown time. */
+	case SHUTDOWN_TIME:
+		break;
+	case USER_PROCESS:
+		FTOU_STRING(fu, ut, id);
+		FTOU_STRING(fu, ut, user);
+		FTOU_STRING(fu, ut, line);
+		/* Extension: host name. */
+		FTOU_STRING(fu, ut, host);
+		FTOU_PID(fu, ut);
+		break;
+	case INIT_PROCESS:
+		FTOU_STRING(fu, ut, id);
+		FTOU_PID(fu, ut);
+		break;
+	case LOGIN_PROCESS:
+		FTOU_STRING(fu, ut, id);
+		FTOU_STRING(fu, ut, user);
+		FTOU_PID(fu, ut);
+		break;
+	case DEAD_PROCESS:
+		FTOU_STRING(fu, ut, id);
+		FTOU_PID(fu, ut);
+		break;
+	default:
+		ut->ut_type = EMPTY;
+		return;
+	}
+
+	FTOU_TYPE(fu, ut);
+	FTOU_TV(fu, ut);
+}
+
+static struct futx *
+getfutxent(void)
+{
+	static struct futx fu;
+
+	if (uf == NULL)
+		setutxent();
+	if (uf == NULL)
+		return (NULL);
+
+	if (udb == UTXDB_LOG) {
+		uint16_t len;
+
+		if (fread(&len, sizeof len, 1, uf) != 1)
+			return (NULL);
+		len = be16toh(len);
+		if (len > sizeof fu) {
+			/* Forward compatibility. */
+			if (fread(&fu, sizeof fu, 1, uf) != 1)
+				return (NULL);
+			fseek(uf, len - sizeof fu, SEEK_CUR);
+		} else {
+			/* Partial record. */
+			memset(&fu, 0, sizeof fu);
+			if (fread(&fu, len, 1, uf) != 1)
+				return (NULL);
+		}
+		return (NULL);
+	} else {
+		if (fread(&fu, sizeof fu, 1, uf) != 1)
+			return (NULL);
+	}
+	return (&fu);
 }
 
 struct utmpx *
 getutxent(void)
 {
+	struct futx *fu;
 
-	return (NULL);
+	fu = getfutxent();
+	if (fu == NULL)
+		return (NULL);
+	futx_to_utx(fu, &utx);
+	return (&utx);
 }
 
 struct utmpx *
 getutxid(const struct utmpx *id)
 {
+	struct futx *fu;
 
-	return (NULL);
+	for (;;) {
+		fu = getfutxent();
+		if (fu == NULL)
+			return (NULL);
+
+		switch (fu->fu_type) {
+		case BOOT_TIME:
+		case OLD_TIME:
+		case NEW_TIME:
+		case SHUTDOWN_TIME:
+			if (fu->fu_type == id->ut_type)
+				goto found;
+		case USER_PROCESS:
+		case INIT_PROCESS:
+		case LOGIN_PROCESS:
+		case DEAD_PROCESS:
+			switch (id->ut_type) {
+			case USER_PROCESS:
+			case INIT_PROCESS:
+			case LOGIN_PROCESS:
+			case DEAD_PROCESS:
+				if (strncmp(fu->fu_id, id->ut_id,
+				    MIN(sizeof fu->fu_id, sizeof id->ut_id)) == 0)
+					goto found;
+			}
+		}
+	}
+
+found:
+	futx_to_utx(fu, &utx);
+	return (&utx);
 }
 
 struct utmpx *
 getutxline(const struct utmpx *line)
 {
+	struct futx *fu;
 
-	return (NULL);
-}
-
-void
-setutxent(void)
-{
+	for (;;) {
+		fu = getfutxent();
+		if (fu == NULL)
+			return (NULL);
+
+		switch (fu->fu_type) {
+		case USER_PROCESS:
+		case LOGIN_PROCESS:
+			if (strncmp(fu->fu_line, line->ut_line,
+			    MIN(sizeof fu->fu_line, sizeof line->ut_line)) == 0)
+				goto found;
+		}
+	}
+
+found:
+	futx_to_utx(fu, &utx);
+	return (&utx);
 }

Modified: user/ed/utmpx/lib/libc/gen/pututxline.c
==============================================================================
--- user/ed/utmpx/lib/libc/gen/pututxline.c	Wed Jan  6 10:21:16 2010	(r201636)
+++ user/ed/utmpx/lib/libc/gen/pututxline.c	Wed Jan  6 10:29:53 2010	(r201637)
@@ -22,14 +22,13 @@
  * 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.
- *
- * $FreeBSD$
  */
 
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
 #include "namespace.h"
+#include <sys/stat.h>
 #include <fcntl.h>
 #include <string.h>
 #include <unistd.h>
@@ -38,6 +37,25 @@ __FBSDID("$FreeBSD$");
 #include "un-namespace.h"
 
 static int
+futx_open(const char *file)
+{
+	int fd;
+	struct stat sb;
+
+	fd = _open(file, O_CREAT|O_RDWR, 0644);
+	if (fd < 0)
+		return (-1);
+
+	/* Safety check: never use broken files. */
+	if (_fstat(fd, &sb) != -1 && sb.st_size % sizeof(struct futx) != 0) {
+		_close(fd);
+		return (-1);
+	}
+
+	return (fd);
+}
+
+static int
 utx_to_futx(const struct utmpx *ut, struct futx *fu)
 {
 
@@ -58,7 +76,6 @@ utx_to_futx(const struct utmpx *ut, stru
 		UTOF_STRING(ut, fu, host);
 		UTOF_PID(ut, fu);
 		break;
-#if 0
 	case INIT_PROCESS:
 		UTOF_STRING(ut, fu, id);
 		UTOF_PID(ut, fu);
@@ -68,7 +85,6 @@ utx_to_futx(const struct utmpx *ut, stru
 		UTOF_STRING(ut, fu, user);
 		UTOF_PID(ut, fu);
 		break;
-#endif
 	case DEAD_PROCESS:
 		UTOF_STRING(ut, fu, id);
 		UTOF_PID(ut, fu);
@@ -93,7 +109,7 @@ utx_active_add(const struct futx *fu)
 	 * Register user login sessions.  Overwrite entries of sessions
 	 * that have already been terminated.
 	 */
-	fd = _open(_PATH_UTX_ACTIVE, O_CREAT|O_RDWR, 0644);
+	fd = futx_open(_PATH_UTX_ACTIVE);
 	if (fd < 0)
 		return;
 	if (lockf(fd, F_LOCK, 0) == -1) {
@@ -101,15 +117,19 @@ utx_active_add(const struct futx *fu)
 		return;
 	}
 	while (_read(fd, &fe, sizeof fe) == sizeof fe) {
-		/*
-		 * XXX: This check is invalid.  We should perform a
-		 * similar comparison as getutxid().
-		 */
-		if (fe.fu_type != USER_PROCESS) {
+		switch (fe.fu_type) {
+		case USER_PROCESS:
+		case INIT_PROCESS:
+		case LOGIN_PROCESS:
+			if (strncmp(fu->fu_id, fe.fu_id, sizeof fe.fu_id) != 0)
+				continue;
+			/* FALLTHROUGH */
+		default:
 			lseek(fd, -sizeof fe, SEEK_CUR);
-			break;
+			goto found;
 		}
 	}
+found:
 	_write(fd, fu, sizeof *fu);
 	lockf(fd, F_ULOCK, 0);
 	_close(fd);
@@ -118,8 +138,37 @@ utx_active_add(const struct futx *fu)
 static int
 utx_active_remove(const struct futx *fu)
 {
+	int fd;
+	struct futx fe;
 
-	return (0);
+	/*
+	 * Remove user login sessions, having the same ut_id.
+	 */
+	fd = futx_open(_PATH_UTX_ACTIVE);
+	if (fd < 0)
+		return (0);
+	if (lockf(fd, F_LOCK, 0) == -1) {
+		_close(fd);
+		return (0);
+	}
+	while (_read(fd, &fe, sizeof fe) == sizeof fe) {
+		switch (fe.fu_type) {
+		case USER_PROCESS:
+		case INIT_PROCESS:
+		case LOGIN_PROCESS:
+			if (strncmp(fu->fu_id, fe.fu_id, sizeof fe.fu_id) != 0)
+				continue;
+			lseek(fd, -sizeof fe, SEEK_CUR);
+			_write(fd, fu, sizeof *fu);
+			lockf(fd, F_ULOCK, 0);
+			_close(fd);
+			return (0);
+		}
+	}
+
+	lockf(fd, F_ULOCK, 0);
+	_close(fd);
+	return (1);
 }
 
 static void
@@ -133,7 +182,7 @@ utx_lastlogin_add(const struct futx *fu)
 	 * current user already has an entry.  If not, append a new
 	 * entry.
 	 */
-	fd = _open(_PATH_UTX_LASTLOGIN, O_CREAT|O_RDWR, 0644);
+	fd = futx_open(_PATH_UTX_LASTLOGIN);
 	if (fd < 0)
 		return;
 	if (lockf(fd, F_LOCK, 0) == -1) {
@@ -164,8 +213,8 @@ utx_log_add(const struct futx *fu)
 	/*
 	 * Append an entry to the log file.  We only need to append
 	 * records to this file, so to conserve space, trim any trailing
-	 * zero-bytes.  Prepend a length field, indicating the record of
-	 * the length, excluding the length field itself.
+	 * zero-bytes.  Prepend a length field, indicating the length of
+	 * the record, excluding the length field itself.
 	 */
 	for (l = sizeof *fu; l > 0 && ((char *)fu)[l - 1] == '\0'; l--);
 	r.len = htobe16(l);
@@ -186,7 +235,7 @@ pututxline(const struct utmpx *utmpx)
 	if (utx_to_futx(utmpx, &fu) != 0)
 		return (NULL);
 	
-	switch (utmpx->ut_type) {
+	switch (fu.fu_type) {
 	case BOOT_TIME:
 	case OLD_TIME:
 	case NEW_TIME:
@@ -196,9 +245,11 @@ pututxline(const struct utmpx *utmpx)
 		utx_active_add(&fu);
 		utx_lastlogin_add(&fu);
 		break;
-#if 0
+#if 0 /* XXX: Are these records of any use to us? */
 	case INIT_PROCESS:
 	case LOGIN_PROCESS:
+		utx_active_add(&fu);
+		break;
 #endif
 	case DEAD_PROCESS:
 		if (utx_active_remove(&fu) != 0)

Modified: user/ed/utmpx/lib/libc/gen/utxdb.h
==============================================================================
--- user/ed/utmpx/lib/libc/gen/utxdb.h	Wed Jan  6 10:21:16 2010	(r201636)
+++ user/ed/utmpx/lib/libc/gen/utxdb.h	Wed Jan  6 10:29:53 2010	(r201637)
@@ -53,9 +53,26 @@ struct futx {
 	uint32_t	fu_pid;
 	char		fu_user[32];
 	char		fu_line[32];
-	char		fu_host[256];
+	char		fu_host[128];
 } __packed;
 
+#define	FTOU_STRING(fu, ut, field) do { \
+	strncpy((ut)->ut_ ## field, (fu)->fu_ ## field,		\
+	    MIN(sizeof (ut)->ut_ ## field - 1, sizeof (fu)->fu_ ## field)); \
+} while (0)
+#define	FTOU_PID(fu, ut) do { \
+	(ut)->ut_pid = be32toh((fu)->fu_pid);				\
+} while (0)
+#define	FTOU_TYPE(fu, ut) do { \
+	(ut)->ut_type = (fu)->fu_type;					\
+} while (0)
+#define	FTOU_TV(fu, ut) do { \
+	uint64_t t;							\
+	t = be64toh((fu)->fu_tv);					\
+	(ut)->ut_tv.tv_sec = t / 1000000;				\
+	(ut)->ut_tv.tv_usec = t % 1000000;				\
+} while (0)
+
 #define	UTOF_STRING(ut, fu, field) do { \
 	strncpy((fu)->fu_ ## field, (ut)->ut_ ## field,		\
 	    MIN(sizeof (fu)->fu_ ## field, sizeof (ut)->ut_ ## field));	\

From owner-svn-src-user@FreeBSD.ORG  Wed Jan  6 10:41:27 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 CF67D1065672;
	Wed,  6 Jan 2010 10:41:27 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id BF4CC8FC14;
	Wed,  6 Jan 2010 10:41:27 +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 o06AfRmQ099226;
	Wed, 6 Jan 2010 10:41:27 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o06AfRT5099222;
	Wed, 6 Jan 2010 10:41:27 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001061041.o06AfRT5099222@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Wed, 6 Jan 2010 10:41:27 +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: r201638 - in user/ed/utmpx: include lib/libc/gen
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: Wed, 06 Jan 2010 10:41:27 -0000

Author: ed
Date: Wed Jan  6 10:41:27 2010
New Revision: 201638
URL: http://svn.freebsd.org/changeset/base/201638

Log:
  Reintroduce getutxuser().
  
  This function will be used by applications that crawl through the
  lastlogin database.

Modified:
  user/ed/utmpx/include/utmpx.h
  user/ed/utmpx/lib/libc/gen/Symbol.map
  user/ed/utmpx/lib/libc/gen/getutxent.c

Modified: user/ed/utmpx/include/utmpx.h
==============================================================================
--- user/ed/utmpx/include/utmpx.h	Wed Jan  6 10:29:53 2010	(r201637)
+++ user/ed/utmpx/include/utmpx.h	Wed Jan  6 10:41:27 2010	(r201638)
@@ -78,6 +78,7 @@ struct utmpx *pututxline(const struct ut
 void	setutxent(void);
 
 #if __BSD_VISIBLE
+struct utmpx *getutxuser(const char *);
 int	setutxdb(int, const char *);
 #endif
 __END_DECLS

Modified: user/ed/utmpx/lib/libc/gen/Symbol.map
==============================================================================
--- user/ed/utmpx/lib/libc/gen/Symbol.map	Wed Jan  6 10:29:53 2010	(r201637)
+++ user/ed/utmpx/lib/libc/gen/Symbol.map	Wed Jan  6 10:41:27 2010	(r201638)
@@ -372,6 +372,7 @@ FBSD_1.2 {
 	getutxent;
 	getutxid;
 	getutxline;
+	getutxuser;
 	pututxline;
 	setutxdb;
 	setutxent;

Modified: user/ed/utmpx/lib/libc/gen/getutxent.c
==============================================================================
--- user/ed/utmpx/lib/libc/gen/getutxent.c	Wed Jan  6 10:29:53 2010	(r201637)
+++ user/ed/utmpx/lib/libc/gen/getutxent.c	Wed Jan  6 10:41:27 2010	(r201638)
@@ -238,3 +238,25 @@ found:
 	futx_to_utx(fu, &utx);
 	return (&utx);
 }
+
+struct utmpx *
+getutxuser(const char *user)
+{
+	struct futx *fu;
+
+	for (;;) {
+		fu = getfutxent();
+		if (fu == NULL)
+			return (NULL);
+
+		switch (fu->fu_type) {
+		case USER_PROCESS:
+			if (strncmp(fu->fu_user, user, sizeof fu->fu_user) == 0)
+				goto found;
+		}
+	}
+
+found:
+	futx_to_utx(fu, &utx);
+	return (&utx);
+}

From owner-svn-src-user@FreeBSD.ORG  Wed Jan  6 11:42:50 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 DD9491065692;
	Wed,  6 Jan 2010 11:42:50 +0000 (UTC)
	(envelope-from luigi@onelab2.iet.unipi.it)
Received: from onelab2.iet.unipi.it (onelab2.iet.unipi.it [131.114.59.238])
	by mx1.freebsd.org (Postfix) with ESMTP id 593478FC12;
	Wed,  6 Jan 2010 11:42:50 +0000 (UTC)
Received: by onelab2.iet.unipi.it (Postfix, from userid 275)
	id A0517730A1; Wed,  6 Jan 2010 12:50:43 +0100 (CET)
Date: Wed, 6 Jan 2010 12:50:43 +0100
From: Luigi Rizzo <rizzo@iet.unipi.it>
To: Ermal Lu?i <eri@freebsd.org>
Message-ID: <20100106115043.GA6064@onelab2.iet.unipi.it>
References: <201001041658.o04GwFfG023749@svn.freebsd.org>
	<9a542da31001051006r61af058eg715c29ef0d3d2020@mail.gmail.com>
	<20100105182643.GA93051@onelab2.iet.unipi.it>
	<9a542da31001051038t9f253fbo79241b11dbba9100@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <9a542da31001051038t9f253fbo79241b11dbba9100@mail.gmail.com>
User-Agent: Mutt/1.4.2.3i
Cc: Luigi Rizzo <luigi@freebsd.org>, src-committers@freebsd.org,
	svn-src-user@freebsd.org
Subject: Re: svn commit: r201517 - in user/luigi/ipfw3-head/sys/netinet: .
	ipfw
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: Wed, 06 Jan 2010 11:42:51 -0000

On Tue, Jan 05, 2010 at 07:38:51PM +0100, Ermal Lu?i wrote:
> On Tue, Jan 5, 2010 at 7:26 PM, Luigi Rizzo <rizzo@iet.unipi.it> wrote:
...
> > I was not aware of pf support -- in fact, i wonder how divert could work
> > without ipfw because the function pointer ip_divert_ptr at the moment
> > is defined in ip_fw_pfil.c .
> >
> > There are in fact, I believe, two things that enforce the dependency:
> > 1. the ip_divert_ptr above. We should move it elsewhere, in the
> >  standard ip_* files;
> >
> > 2. the tag that is attached to the packet to record the reinject cookie
> >  (I have recently redefined it as MTAG_IPFW_RULE because i was
> >  not aware of the pf(4) support -- i need to revert/fix this if
> >  we want divert and pf cooperation (though note that I tried to
> >  have the same mtag format for all reinjected packets -- dummynet,
> >  divert, netgraph, ... so once we fix it for one application it
> >  should work for all with no special code).
> >
> > cheers
> > luigi
> >
> 
> Check it out here
> http://svn.freebsd.org/viewvc/base/user/eri/pf45/head/
> 
> <http://svn.freebsd.org/viewvc/base/user/eri/pf45/head/>The divert support
> with the pointer moving is commit 198045 for checking on how i have done in
> that branch. If you find a better solution go ahead and i will update the
> referenced pf branch as well.

very good. moving ip_divert_ptr to ip_input or some other global
place is trivial. The other change required is to move the
MTAG_IPFW_RULE (and struct ipfw_rule_ref) to some common
header instead of the ipfw-specific headers. Renaming the
struct or fields is fine.
As you see, the tag contains 2 pieces of information:
- a rule identifier (in ipfw it is rulenum:rule_id), which can
  be used for a lookup even if the configuration changes
  (and we cannot hold a lock or a refcount) as the packet may not
  come back;
- a "quick reference", protected by a version number, to be used
  to save the cost of a lookup in case the configuration has not changed.

I suppose the existing fields should be enough for pf as well,
possibly changing 'slot' to uintptr_t so you can put there a
pointer instead of a slot number.

can you give a try at adapting pf.c to this structure while I
move the ipfw_rule_ref to a common header ?

cheers
luigi

From owner-svn-src-user@FreeBSD.ORG  Wed Jan  6 12:42:17 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 2AA541065670;
	Wed,  6 Jan 2010 12:42:17 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 1666E8FC14;
	Wed,  6 Jan 2010 12:42:17 +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 o06CgGq8026242;
	Wed, 6 Jan 2010 12:42:16 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o06CgGPZ026230;
	Wed, 6 Jan 2010 12:42:16 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001061242.o06CgGPZ026230@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Wed, 6 Jan 2010 12:42:16 +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: r201640 - in user/ed/utmpx: usr.bin/finger usr.bin/who
	usr.sbin/ac usr.sbin/lastlogin
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: Wed, 06 Jan 2010 12:42:17 -0000

Author: ed
Date: Wed Jan  6 12:42:16 2010
New Revision: 201640
URL: http://svn.freebsd.org/changeset/base/201640

Log:
  Make more tools use the utmpx interface.

Modified:
  user/ed/utmpx/usr.bin/finger/Makefile
  user/ed/utmpx/usr.bin/finger/finger.c
  user/ed/utmpx/usr.bin/finger/lprint.c
  user/ed/utmpx/usr.bin/finger/net.c
  user/ed/utmpx/usr.bin/finger/sprint.c
  user/ed/utmpx/usr.bin/finger/util.c
  user/ed/utmpx/usr.bin/who/who.c
  user/ed/utmpx/usr.sbin/ac/Makefile
  user/ed/utmpx/usr.sbin/ac/ac.c
  user/ed/utmpx/usr.sbin/lastlogin/Makefile
  user/ed/utmpx/usr.sbin/lastlogin/lastlogin.c

Modified: user/ed/utmpx/usr.bin/finger/Makefile
==============================================================================
--- user/ed/utmpx/usr.bin/finger/Makefile	Wed Jan  6 12:15:10 2010	(r201639)
+++ user/ed/utmpx/usr.bin/finger/Makefile	Wed Jan  6 12:42:16 2010	(r201640)
@@ -7,7 +7,4 @@ MAN=	finger.1 finger.conf.5
 
 WARNS?=	2
 
-DPADD=	${LIBULOG}
-LDADD=	-lulog
-
 .include <bsd.prog.mk>

Modified: user/ed/utmpx/usr.bin/finger/finger.c
==============================================================================
--- user/ed/utmpx/usr.bin/finger/finger.c	Wed Jan  6 12:15:10 2010	(r201639)
+++ user/ed/utmpx/usr.bin/finger/finger.c	Wed Jan  6 12:42:16 2010	(r201640)
@@ -82,9 +82,8 @@ __FBSDID("$FreeBSD$");
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
-#define	_ULOG_POSIX_NAMES
-#include <ulog.h>
 #include <unistd.h>
+#include <utmpx.h>
 #include <locale.h>
 
 #include "finger.h"

Modified: user/ed/utmpx/usr.bin/finger/lprint.c
==============================================================================
--- user/ed/utmpx/usr.bin/finger/lprint.c	Wed Jan  6 12:15:10 2010	(r201639)
+++ user/ed/utmpx/usr.bin/finger/lprint.c	Wed Jan  6 12:42:16 2010	(r201640)
@@ -56,9 +56,8 @@ __FBSDID("$FreeBSD$");
 #include <pwd.h>
 #include <stdio.h>
 #include <string.h>
-#define	_ULOG_POSIX_NAMES
-#include <ulog.h>
 #include <unistd.h>
+#include <utmpx.h>
 #include "finger.h"
 #include "pathnames.h"
 

Modified: user/ed/utmpx/usr.bin/finger/net.c
==============================================================================
--- user/ed/utmpx/usr.bin/finger/net.c	Wed Jan  6 12:15:10 2010	(r201639)
+++ user/ed/utmpx/usr.bin/finger/net.c	Wed Jan  6 12:42:16 2010	(r201640)
@@ -54,9 +54,8 @@ __FBSDID("$FreeBSD$");
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#define	_ULOG_POSIX_NAMES
-#include <ulog.h>
 #include <unistd.h>
+#include <utmpx.h>
 #include "finger.h"
 
 static void cleanup(int sig);

Modified: user/ed/utmpx/usr.bin/finger/sprint.c
==============================================================================
--- user/ed/utmpx/usr.bin/finger/sprint.c	Wed Jan  6 12:15:10 2010	(r201639)
+++ user/ed/utmpx/usr.bin/finger/sprint.c	Wed Jan  6 12:42:16 2010	(r201640)
@@ -53,8 +53,7 @@ __FBSDID("$FreeBSD$");
 #include <stdio.h>
 #include <string.h>
 #include <time.h>
-#define	_ULOG_POSIX_NAMES
-#include <ulog.h>
+#include <utmpx.h>
 #include "finger.h"
 
 static void	  stimeprint(WHERE *);

Modified: user/ed/utmpx/usr.bin/finger/util.c
==============================================================================
--- user/ed/utmpx/usr.bin/finger/util.c	Wed Jan  6 12:15:10 2010	(r201639)
+++ user/ed/utmpx/usr.bin/finger/util.c	Wed Jan  6 12:42:16 2010	(r201640)
@@ -56,9 +56,8 @@ __FBSDID("$FreeBSD$");
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#define	_ULOG_POSIX_NAMES
-#include <ulog.h>
 #include <unistd.h>
+#include <utmpx.h>
 #include "finger.h"
 #include "pathnames.h"
 
@@ -110,11 +109,11 @@ void
 enter_lastlog(PERSON *pn)
 {
 	WHERE *w;
-	struct ulog_utmpx *ut;
+	struct utmpx *ut = NULL;
 	char doit = 0;
 
-	ulog_setutxfile(UTXI_USER, NULL);
-	ut = ulog_getutxuser(pn->name);
+	if (setutxdb(UTXDB_LASTLOGIN, NULL) == 0)
+		ut = getutxuser(pn->name);
 	if ((w = pn->whead) == NULL)
 		doit = 1;
 	else if (ut != NULL && ut->ut_type == USER_PROCESS) {
@@ -140,7 +139,7 @@ enter_lastlog(PERSON *pn)
 		strcpy(w->host, ut->ut_host);
 		w->loginat = ut->ut_tv.tv_sec;
 	}
-	ulog_endutxent();
+	endutxent();
 }
 
 void

Modified: user/ed/utmpx/usr.bin/who/who.c
==============================================================================
--- user/ed/utmpx/usr.bin/who/who.c	Wed Jan  6 12:15:10 2010	(r201639)
+++ user/ed/utmpx/usr.bin/who/who.c	Wed Jan  6 12:42:16 2010	(r201640)
@@ -107,12 +107,10 @@ main(int argc, char *argv[])
 	if (argc > 1)
 		usage();
 
-#if 0
 	if (*argv != NULL) {
-		if (ulog_setutxfile(UTXI_TTY, *argv) != 0)
+		if (setutxdb(UTXDB_ACTIVE, *argv) != 0)
 			err(1, "%s", *argv);
 	}
-#endif
 
 	if (qflag)
 		quick();

Modified: user/ed/utmpx/usr.sbin/ac/Makefile
==============================================================================
--- user/ed/utmpx/usr.sbin/ac/Makefile	Wed Jan  6 12:15:10 2010	(r201639)
+++ user/ed/utmpx/usr.sbin/ac/Makefile	Wed Jan  6 12:42:16 2010	(r201640)
@@ -5,9 +5,6 @@ MAN=	ac.8
 
 WARNS?=	6
 
-DPADD=	${LIBULOG}
-LDADD=	-lulog
-
 # Temporary, while tracking down problem wrt 64-bit time_t's on sparc64
 .if ${MACHINE_ARCH} == "sparc64"
 CFLAGS+=-DDEBUG

Modified: user/ed/utmpx/usr.sbin/ac/ac.c
==============================================================================
--- user/ed/utmpx/usr.sbin/ac/ac.c	Wed Jan  6 12:15:10 2010	(r201639)
+++ user/ed/utmpx/usr.sbin/ac/ac.c	Wed Jan  6 12:42:16 2010	(r201640)
@@ -26,9 +26,8 @@ __FBSDID("$FreeBSD$");
 #include <stdlib.h>
 #include <string.h>
 #include <timeconv.h>
-#define	_ULOG_POSIX_NAMES
-#include <ulog.h>
 #include <unistd.h>
+#include <utmpx.h>
 
 /*
  * this is for our list of currently logged in sessions
@@ -486,7 +485,7 @@ ac(const char *file)
 	prev_secs = 1;			/* Minimum acceptable date == 1970 */
 	rfound = tchanged = tskipped = 0;
 	secs = 0;
-	if (ulog_setutxfile(UTXI_TIME, file) != 0)
+	if (setutxdb(UTXDB_LOG, file) != 0)
 		err(1, "%s", file);
 	while ((usr = getutxent()) != NULL) {
 		rfound++;

Modified: user/ed/utmpx/usr.sbin/lastlogin/Makefile
==============================================================================
--- user/ed/utmpx/usr.sbin/lastlogin/Makefile	Wed Jan  6 12:15:10 2010	(r201639)
+++ user/ed/utmpx/usr.sbin/lastlogin/Makefile	Wed Jan  6 12:42:16 2010	(r201640)
@@ -3,7 +3,4 @@
 PROG=	lastlogin
 MAN=	lastlogin.8
 
-DPADD=	${LIBULOG}
-LDADD=	-lulog
-
 .include <bsd.prog.mk>

Modified: user/ed/utmpx/usr.sbin/lastlogin/lastlogin.c
==============================================================================
--- user/ed/utmpx/usr.sbin/lastlogin/lastlogin.c	Wed Jan  6 12:15:10 2010	(r201639)
+++ user/ed/utmpx/usr.sbin/lastlogin/lastlogin.c	Wed Jan  6 12:42:16 2010	(r201640)
@@ -41,62 +41,62 @@ __RCSID("$NetBSD: lastlogin.c,v 1.4 1998
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
-#include <ulog.h>
 #include <unistd.h>
+#include <utmpx.h>
 
 	int	main(int, char **);
-static	void	output(struct ulog_utmpx *);
+static	void	output(struct utmpx *);
 static	void	usage(void);
 
 int
 main(int argc, char *argv[])
 {
 	int	ch, i;
-	struct ulog_utmpx *u;
+	struct utmpx *u;
 
 	while ((ch = getopt(argc, argv, "")) != -1) {
 		usage();
 	}
 
-	if (ulog_setutxfile(UTXI_USER, NULL) != 0)
-		errx(1, "failed to open lastlog database");
-
 	setpassent(1);	/* Keep passwd file pointers open */
 
 	/* Process usernames given on the command line. */
 	if (argc > 1) {
 		for (i = 1; i < argc; ++i) {
-			if ((u = ulog_getutxuser(argv[i])) == NULL) {
+			if (setutxdb(UTXDB_LASTLOGIN, NULL) != 0)
+				errx(1, "failed to open lastlog database");
+			if ((u = getutxuser(argv[i])) == NULL) {
 				warnx("user '%s' not found", argv[i]);
 				continue;
 			}
 			output(u);
+			endutxent();
 		}
 	}
 	/* Read all lastlog entries, looking for active ones */
 	else {
-		while ((u = ulog_getutxent()) != NULL) {
+		if (setutxdb(UTXDB_LASTLOGIN, NULL) != 0)
+			errx(1, "failed to open lastlog database");
+		while ((u = getutxent()) != NULL) {
 			if (u->ut_type != USER_PROCESS)
 				continue;
 			output(u);
 		}
+		endutxent();
 	}
 
 	setpassent(0);	/* Close passwd file pointers */
-
-	ulog_endutxent();
 	exit(0);
 }
 
 /* Duplicate the output of last(1) */
 static void
-output(struct ulog_utmpx *u)
+output(struct utmpx *u)
 {
 	time_t t = u->ut_tv.tv_sec;
 
 	printf("%-16s  %-8s %-16s   %s",
-		u->ut_user, u->ut_line, u->ut_host,
-		(u->ut_type == USER_PROCESS) ? ctime(&t) : "Never logged in\n");
+		u->ut_user, u->ut_line, u->ut_host, ctime(&t));
 }
 
 static void

From owner-svn-src-user@FreeBSD.ORG  Wed Jan  6 12:42:47 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 EC8B610656C0;
	Wed,  6 Jan 2010 12:42:46 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id DC2D68FC30;
	Wed,  6 Jan 2010 12:42: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 o06Cgk7c026378;
	Wed, 6 Jan 2010 12:42:46 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o06Cgk7k026371;
	Wed, 6 Jan 2010 12:42:46 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001061242.o06Cgk7k026371@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Wed, 6 Jan 2010 12:42: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: r201641 - user/ed/utmpx/lib/libulog
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: Wed, 06 Jan 2010 12:42:47 -0000

Author: ed
Date: Wed Jan  6 12:42:46 2010
New Revision: 201641
URL: http://svn.freebsd.org/changeset/base/201641

Log:
  Remove the utmpx interface from libulog.

Deleted:
  user/ed/utmpx/lib/libulog/ulog_getutxent.3
  user/ed/utmpx/lib/libulog/ulog_getutxent.c
  user/ed/utmpx/lib/libulog/ulog_internal.h
  user/ed/utmpx/lib/libulog/ulog_pututxline.c
  user/ed/utmpx/lib/libulog/ulog_setutxfile.3
  user/ed/utmpx/lib/libulog/ulog_util.c
Modified:
  user/ed/utmpx/lib/libulog/Makefile
  user/ed/utmpx/lib/libulog/Symbol.map
  user/ed/utmpx/lib/libulog/ulog.h
  user/ed/utmpx/lib/libulog/ulog_login.c
  user/ed/utmpx/lib/libulog/ulog_login_pseudo.c
  user/ed/utmpx/lib/libulog/utempter.c

Modified: user/ed/utmpx/lib/libulog/Makefile
==============================================================================
--- user/ed/utmpx/lib/libulog/Makefile	Wed Jan  6 12:42:16 2010	(r201640)
+++ user/ed/utmpx/lib/libulog/Makefile	Wed Jan  6 12:42:46 2010	(r201641)
@@ -7,32 +7,18 @@ SHLIBDIR?=/lib
 LIB=	ulog
 SHLIB_MAJOR= 0
 INCS=	ulog.h utempter.h
-SRCS=	ulog.h ulog_getutxent.c ulog_internal.h ulog_login.c \
-	ulog_login_pseudo.c ulog_pututxline.c ulog_util.c utempter.c
+SRCS=	ulog.h ulog_login.c ulog_login_pseudo.c utempter.c
 
-MAN=	ulog_getutxent.3 ulog_login.3 ulog_setutxfile.3 \
-	utempter_add_record.3
-MLINKS+=ulog_getutxent.3 ulog_endutxent.3 \
-	ulog_getutxent.3 ulog_getutxline.3 \
-	ulog_getutxent.3 ulog_pututxline.3 \
-	ulog_getutxent.3 ulog_setutxent.3 \
-	ulog_login.3 ulog_login_pseudo.3 \
+MAN=	ulog_login.3 utempter_add_record.3
+MLINKS+=ulog_login.3 ulog_login_pseudo.3 \
 	ulog_login.3 ulog_logout.3 \
 	ulog_login.3 ulog_logout_pseudo.3 \
-	ulog_setutxfile.3 ulog_getutxuser.3 \
 	utempter_add_record.3 utempter_remove_added_record.3 \
 	utempter_add_record.3 utempter_remove_record.3 \
 	utempter_add_record.3 addToUtmp.3 \
 	utempter_remove_added_record.3 removeFromUtmp.3 \
 	utempter_remove_record.3 removeLineFromUtmp.3
 
-# Add links to <utmpx.h>-style functions.
-MLINKS+=ulog_endutxent.3 endutxent.3 \
-	ulog_getutxent.3 getutxent.3 \
-	ulog_getutxline.3 getutxline.3 \
-	ulog_pututxline.3 pututxline.3 \
-	ulog_setutxent.3 setutxent.3
-
 VERSION_DEF= ${.CURDIR}/../libc/Versions.def
 SYMBOL_MAPS= ${.CURDIR}/Symbol.map
 

Modified: user/ed/utmpx/lib/libulog/Symbol.map
==============================================================================
--- user/ed/utmpx/lib/libulog/Symbol.map	Wed Jan  6 12:42:16 2010	(r201640)
+++ user/ed/utmpx/lib/libulog/Symbol.map	Wed Jan  6 12:42:46 2010	(r201641)
@@ -3,17 +3,10 @@
  */	
 
 FBSD_1.2 {
-	ulog_endutxent;
-	ulog_getutxent;
-	ulog_getutxline;
-	ulog_getutxuser;
 	ulog_login;
 	ulog_login_pseudo;
 	ulog_logout;
 	ulog_logout_pseudo;
-	ulog_pututxline;
-	ulog_setutxent;
-	ulog_setutxfile;
 
 	addToUtmp;
 	removeFromUtmp;

Modified: user/ed/utmpx/lib/libulog/ulog.h
==============================================================================
--- user/ed/utmpx/lib/libulog/ulog.h	Wed Jan  6 12:42:16 2010	(r201640)
+++ user/ed/utmpx/lib/libulog/ulog.h	Wed Jan  6 12:42:46 2010	(r201641)
@@ -30,79 +30,12 @@
 #define	_ULOG_H_
 
 #include <sys/cdefs.h>
-#include <sys/_timeval.h>
-#include <sys/_types.h>
-
-#ifndef _PID_T_DECLARED
-typedef	__pid_t		pid_t;
-#define	_PID_T_DECLARED
-#endif
-
-/*
- * libulog.
- *
- * This library is provided as a migratory tool towards <utmpx.h>.  We
- * cannot yet implement <utmpx.h>, because our on-disk file format lacks
- * various fields.  <utmpx.h> also has some shortcomings.  Ideally we
- * want to allow logging of user login records generated by unprivileged
- * processes as well, provided that they hold a file descriptor to a
- * pseudo-terminal master device.
- *
- * This library (or at least parts of it) will hopefully deprecate over
- * time, when we provide the <utmpx.h> API.
- */
-
-struct ulog_utmpx {
-	char		ut_user[32];
-	char		ut_id[8];	/* XXX: unsupported. */
-	char		ut_line[32];
-	char		ut_host[256];
-	pid_t		ut_pid;		/* XXX: unsupported. */
-	short		ut_type;
-#define	EMPTY		0
-#define	BOOT_TIME	1
-#define	OLD_TIME	2
-#define	NEW_TIME	3
-#define	USER_PROCESS	4
-#define	INIT_PROCESS	5		/* XXX: unsupported. */
-#define	LOGIN_PROCESS	6		/* XXX: unsupported. */
-#define	DEAD_PROCESS	7
-#define	SHUTDOWN_TIME	8
-	struct timeval	ut_tv;
-};
 
 __BEGIN_DECLS
-/* POSIX routines. */
-void	ulog_endutxent(void);
-struct ulog_utmpx *ulog_getutxent(void);
-#if 0
-struct ulog_utmpx *ulog_getutxid(const struct ulog_utmpx *);
-#endif
-struct ulog_utmpx *ulog_getutxline(const struct ulog_utmpx *);
-struct ulog_utmpx *ulog_pututxline(const struct ulog_utmpx *);
-void	ulog_setutxent(void);
-
-/* Extensions. */
-struct ulog_utmpx *ulog_getutxuser(const char *);
-int	ulog_setutxfile(int, const char *);
-#define	UTXI_TTY	0
-#define	UTXI_TIME	1
-#define	UTXI_USER	2
-
-/* Login/logout utility functions. */
 void	ulog_login(const char *, const char *, const char *);
 void	ulog_login_pseudo(int, const char *);
 void	ulog_logout(const char *);
 void	ulog_logout_pseudo(int);
 __END_DECLS
 
-#ifdef _ULOG_POSIX_NAMES
-#define	utmpx		ulog_utmpx
-#define	endutxent	ulog_endutxent
-#define	getutxent	ulog_getutxent
-#define	getutxline	ulog_getutxline
-#define	pututxline	ulog_pututxline
-#define	setutxent	ulog_setutxent
-#endif /* _ULOG_POSIX_NAMES */
-
 #endif /* !_ULOG_H_ */

Modified: user/ed/utmpx/lib/libulog/ulog_login.c
==============================================================================
--- user/ed/utmpx/lib/libulog/ulog_login.c	Wed Jan  6 12:42:16 2010	(r201640)
+++ user/ed/utmpx/lib/libulog/ulog_login.c	Wed Jan  6 12:42:46 2010	(r201641)
@@ -30,13 +30,13 @@ __FBSDID("$FreeBSD$");
 #include <sys/time.h>
 #include <paths.h>
 #include <string.h>
-
-#include "ulog_internal.h"
+#include <utmpx.h>
+#include "ulog.h"
 
 void
 ulog_login(const char *line, const char *user, const char *host)
 {
-	struct ulog_utmpx utx;
+	struct utmpx utx;
 
 	/* Remove /dev/ component. */
 	if (strncmp(line, _PATH_DEV, sizeof _PATH_DEV - 1) == 0)
@@ -52,13 +52,13 @@ ulog_login(const char *line, const char 
 		strncpy(utx.ut_host, host, sizeof utx.ut_host);
 	gettimeofday(&utx.ut_tv, NULL);
 
-	ulog_pututxline(&utx);
+	pututxline(&utx);
 }
 
 void
 ulog_logout(const char *line)
 {
-	struct ulog_utmpx utx;
+	struct utmpx utx;
 
 	/* Remove /dev/ component. */
 	if (strncmp(line, _PATH_DEV, sizeof _PATH_DEV - 1) == 0)
@@ -71,5 +71,5 @@ ulog_logout(const char *line)
 	strncpy(utx.ut_line, line, sizeof utx.ut_line);
 	gettimeofday(&utx.ut_tv, NULL);
 
-	ulog_pututxline(&utx);
+	pututxline(&utx);
 }

Modified: user/ed/utmpx/lib/libulog/ulog_login_pseudo.c
==============================================================================
--- user/ed/utmpx/lib/libulog/ulog_login_pseudo.c	Wed Jan  6 12:42:16 2010	(r201640)
+++ user/ed/utmpx/lib/libulog/ulog_login_pseudo.c	Wed Jan  6 12:42:46 2010	(r201641)
@@ -34,8 +34,7 @@ __FBSDID("$FreeBSD$");
 #include <stdlib.h>
 #include <sysexits.h>
 #include <unistd.h>
-
-#include "ulog_internal.h"
+#include "ulog.h"
 
 #define	_PATH_ULOG_HELPER	"/usr/libexec/ulog-helper"
 

Modified: user/ed/utmpx/lib/libulog/utempter.c
==============================================================================
--- user/ed/utmpx/lib/libulog/utempter.c	Wed Jan  6 12:42:16 2010	(r201640)
+++ user/ed/utmpx/lib/libulog/utempter.c	Wed Jan  6 12:42:46 2010	(r201641)
@@ -27,7 +27,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "ulog_internal.h"
+#include "ulog.h"
 #include "utempter.h"
 
 static int last_fd = -1;

From owner-svn-src-user@FreeBSD.ORG  Wed Jan  6 12:43:20 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 0D21D10656C2;
	Wed,  6 Jan 2010 12:43:20 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id F123C8FC08;
	Wed,  6 Jan 2010 12:43:19 +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 o06ChJJc026548;
	Wed, 6 Jan 2010 12:43:19 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o06ChJpS026546;
	Wed, 6 Jan 2010 12:43:19 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001061243.o06ChJpS026546@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Wed, 6 Jan 2010 12:43:19 +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: r201642 - user/ed/utmpx/lib/libpam/modules/pam_lastlog
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: Wed, 06 Jan 2010 12:43:20 -0000

Author: ed
Date: Wed Jan  6 12:43:19 2010
New Revision: 201642
URL: http://svn.freebsd.org/changeset/base/201642

Log:
  Let pam_lastlog use utmpx.

Modified:
  user/ed/utmpx/lib/libpam/modules/pam_lastlog/pam_lastlog.c

Modified: user/ed/utmpx/lib/libpam/modules/pam_lastlog/pam_lastlog.c
==============================================================================
--- user/ed/utmpx/lib/libpam/modules/pam_lastlog/pam_lastlog.c	Wed Jan  6 12:42:46 2010	(r201641)
+++ user/ed/utmpx/lib/libpam/modules/pam_lastlog/pam_lastlog.c	Wed Jan  6 12:43:19 2010	(r201642)
@@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$");
 #include <pwd.h>
 #include <time.h>
 #include <ulog.h>
+#include <utmpx.h>
 
 #define PAM_SM_SESSION
 
@@ -61,7 +62,7 @@ pam_sm_open_session(pam_handle_t *pamh, 
     int argc __unused, const char *argv[] __unused)
 {
 	struct passwd *pwd;
-	struct ulog_utmpx *utx;
+	struct utmpx *utx;
 	time_t t;
 	const char *user;
 	const void *rhost, *tty;
@@ -91,10 +92,10 @@ pam_sm_open_session(pam_handle_t *pamh, 
 	}
 
 	if ((flags & PAM_SILENT) == 0) {
-		if (ulog_setutxfile(UTXI_USER, NULL) != 0) {
-			PAM_LOG("Failed to open lastlog database");
+		if (setutxdb(UTXDB_LASTLOGIN, NULL) != 0) {
+			PAM_LOG("Failed to open lastlogin database");
 		} else {
-			utx = ulog_getutxuser(user);
+			utx = getutxuser(user);
 			if (utx != NULL && utx->ut_type == USER_PROCESS) {
 				t = utx->ut_tv.tv_sec;
 				if (*utx->ut_host != '\0')
@@ -104,7 +105,7 @@ pam_sm_open_session(pam_handle_t *pamh, 
 					pam_info(pamh, "Last login: %.*s on %s",
 					    24 - 5, ctime(&t), utx->ut_line);
 			}
-			ulog_endutxent();
+			endutxent();
 		}
 	}
 

From owner-svn-src-user@FreeBSD.ORG  Wed Jan  6 12:43:59 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 99DD01065693;
	Wed,  6 Jan 2010 12:43:59 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 706118FC24;
	Wed,  6 Jan 2010 12:43:59 +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 o06Chxvi026716;
	Wed, 6 Jan 2010 12:43:59 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o06Chxqj026713;
	Wed, 6 Jan 2010 12:43:59 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001061243.o06Chxqj026713@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Wed, 6 Jan 2010 12:43:59 +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: r201643 - in user/ed/utmpx: . share/man/man5
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: Wed, 06 Jan 2010 12:43:59 -0000

Author: ed
Date: Wed Jan  6 12:43:59 2010
New Revision: 201643
URL: http://svn.freebsd.org/changeset/base/201643

Log:
  Remove the utmp manpage and add it to ObsoleteFiles.
  
  Also add the libulog manpages to ObsoleteFiles that were missing in one
  of the previous commits.

Deleted:
  user/ed/utmpx/share/man/man5/utmp.5
Modified:
  user/ed/utmpx/ObsoleteFiles.inc
  user/ed/utmpx/share/man/man5/Makefile

Modified: user/ed/utmpx/ObsoleteFiles.inc
==============================================================================
--- user/ed/utmpx/ObsoleteFiles.inc	Wed Jan  6 12:43:19 2010	(r201642)
+++ user/ed/utmpx/ObsoleteFiles.inc	Wed Jan  6 12:43:59 2010	(r201643)
@@ -14,10 +14,25 @@
 # The file is partitioned: OLD_FILES first, then OLD_LIBS and OLD_DIRS last.
 #
 
-# 20100104: login(3), logout(3) and logwtmp(3) removed
+# 20100104: utmp and utility functions replaced by utmpx
+OLD_FILES+=usr/share/man/man3/endutxent.3.gz
+OLD_FILES+=usr/share/man/man3/getutxent.3.gz
+OLD_FILES+=usr/share/man/man3/getutxline.3.gz
 OLD_FILES+=usr/share/man/man3/login.3.gz
 OLD_FILES+=usr/share/man/man3/logout.3.gz
 OLD_FILES+=usr/share/man/man3/logwtmp.3.gz
+OLD_FILES+=usr/share/man/man3/pututxline.3.gz
+OLD_FILES+=usr/share/man/man3/setutxent.3.gz
+OLD_FILES+=usr/share/man/man3/ulog_endutxent.3.gz
+OLD_FILES+=usr/share/man/man3/ulog_getutxent.3.gz
+OLD_FILES+=usr/share/man/man3/ulog_getutxline.3.gz
+OLD_FILES+=usr/share/man/man3/ulog_getutxuser.3.gz
+OLD_FILES+=usr/share/man/man3/ulog_pututxline.3.gz
+OLD_FILES+=usr/share/man/man3/ulog_setutxent.3.gz
+OLD_FILES+=usr/share/man/man3/ulog_setutxfile.3.gz
+OLD_FILES+=usr/share/man/man5/lastlog.5.gz
+OLD_FILES+=usr/share/man/man5/utmp.5.gz
+OLD_FILES+=usr/share/man/man5/wtmp.5.gz
 # 20100103: ntptrace(8) removed
 OLD_FILES+=usr/sbin/ntptrace
 OLD_FILES+=usr/share/man/man8/ntptrace.8.gz

Modified: user/ed/utmpx/share/man/man5/Makefile
==============================================================================
--- user/ed/utmpx/share/man/man5/Makefile	Wed Jan  6 12:43:19 2010	(r201642)
+++ user/ed/utmpx/share/man/man5/Makefile	Wed Jan  6 12:43:59 2010	(r201643)
@@ -68,7 +68,6 @@ MAN=	acct.5 \
 	style.Makefile.5 \
 	sysctl.conf.5 \
 	tmpfs.5 \
-	utmp.5 \
 	xfs.5
 
 MLINKS=	dir.5 dirent.5
@@ -79,7 +78,6 @@ MLINKS+=passwd.5 master.passwd.5
 MLINKS+=quota.user.5 quota.group.5
 MLINKS+=rc.conf.5 rc.conf.local.5
 MLINKS+=resolver.5 resolv.conf.5
-MLINKS+=utmp.5 lastlog.5 utmp.5 wtmp.5
 
 .if ${MK_HESIOD} != "no"
 MAN+=	hesiod.conf.5 

From owner-svn-src-user@FreeBSD.ORG  Wed Jan  6 19:29:19 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 2DF8C106568F;
	Wed,  6 Jan 2010 19:29:19 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 1DC3E8FC13;
	Wed,  6 Jan 2010 19:29:19 +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 o06JTJGv017507;
	Wed, 6 Jan 2010 19:29:19 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o06JTIW2017504;
	Wed, 6 Jan 2010 19:29:18 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001061929.o06JTIW2017504@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Wed, 6 Jan 2010 19:29:18 +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: r201660 - user/ed/utmpx/lib/libc/gen
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: Wed, 06 Jan 2010 19:29:19 -0000

Author: ed
Date: Wed Jan  6 19:29:18 2010
New Revision: 201660
URL: http://svn.freebsd.org/changeset/base/201660

Log:
  Remove silly bugs from getutxent() and pututxline().
  
  - Unbreak getutxent() on UTXDB_LOG (wtmp) files by not always returning
    NULL instead of the proper entry.
  - Unbreak UTXDB_LOG writing of pututxline() of DEAD_PROCESS by properly
    breaking from the switch statement.

Modified:
  user/ed/utmpx/lib/libc/gen/getutxent.c
  user/ed/utmpx/lib/libc/gen/pututxline.c

Modified: user/ed/utmpx/lib/libc/gen/getutxent.c
==============================================================================
--- user/ed/utmpx/lib/libc/gen/getutxent.c	Wed Jan  6 18:21:22 2010	(r201659)
+++ user/ed/utmpx/lib/libc/gen/getutxent.c	Wed Jan  6 19:29:18 2010	(r201660)
@@ -157,7 +157,6 @@ getfutxent(void)
 			if (fread(&fu, len, 1, uf) != 1)
 				return (NULL);
 		}
-		return (NULL);
 	} else {
 		if (fread(&fu, sizeof fu, 1, uf) != 1)
 			return (NULL);

Modified: user/ed/utmpx/lib/libc/gen/pututxline.c
==============================================================================
--- user/ed/utmpx/lib/libc/gen/pututxline.c	Wed Jan  6 18:21:22 2010	(r201659)
+++ user/ed/utmpx/lib/libc/gen/pututxline.c	Wed Jan  6 19:29:18 2010	(r201660)
@@ -254,10 +254,12 @@ pututxline(const struct utmpx *utmpx)
 	case DEAD_PROCESS:
 		if (utx_active_remove(&fu) != 0)
 			return (NULL);
+		break;
 	default:
 		return (NULL);
 	}
 
 	utx_log_add(&fu);
+	/* XXX: return an entry on success! */
 	return (NULL);
 }

From owner-svn-src-user@FreeBSD.ORG  Wed Jan  6 19:57:39 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 0F9761065676;
	Wed,  6 Jan 2010 19:57:39 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id F39F28FC1B;
	Wed,  6 Jan 2010 19:57:38 +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 o06Jvc0J023815;
	Wed, 6 Jan 2010 19:57:38 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o06JvcVL023814;
	Wed, 6 Jan 2010 19:57:38 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001061957.o06JvcVL023814@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Wed, 6 Jan 2010 19:57:38 +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: r201661 - user/ed/utmpx/usr.sbin/ac
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: Wed, 06 Jan 2010 19:57:39 -0000

Author: ed
Date: Wed Jan  6 19:57:38 2010
New Revision: 201661
URL: http://svn.freebsd.org/changeset/base/201661

Log:
  Make ac(8) work with utmpx.
  
  For DEAD_PROCESS entries we should always just compare ut_id's.
  DEAD_PROCESS entries don't have a user name nor a TTY device.

Modified:
  user/ed/utmpx/usr.sbin/ac/ac.c

Modified: user/ed/utmpx/usr.sbin/ac/ac.c
==============================================================================
--- user/ed/utmpx/usr.sbin/ac/ac.c	Wed Jan  6 19:29:18 2010	(r201660)
+++ user/ed/utmpx/usr.sbin/ac/ac.c	Wed Jan  6 19:57:38 2010	(r201661)
@@ -378,7 +378,8 @@ log_out(struct utmp_list *head, struct u
 
 	for (lp = head, lp2 = NULL; lp != NULL; )
 		if (up->ut_type == BOOT_TIME || up->ut_type == SHUTDOWN_TIME ||
-		    strcmp(lp->usr.ut_line, up->ut_line) == 0) {
+		    (up->ut_type == DEAD_PROCESS &&
+		    strcmp(lp->usr.ut_id, up->ut_id) == 0)) {
 			secs = up->ut_tv.tv_sec - lp->usr.ut_tv.tv_sec;
 			Users = update_user(Users, lp->usr.ut_user, secs);
 #ifdef DEBUG
@@ -553,6 +554,7 @@ ac(const char *file)
 			for (lp = head; lp != NULL; lp = lp->next)
 				lp->usr.ut_tv.tv_sec -= secs;
 			break;
+		case BOOT_TIME:
 		case SHUTDOWN_TIME:
 			head = log_out(head, usr);
 			FirstTime = ut_timecopy; /* shouldn't be needed */

From owner-svn-src-user@FreeBSD.ORG  Wed Jan  6 20:04:37 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 150F41065672;
	Wed,  6 Jan 2010 20:04:37 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 04EEB8FC1A;
	Wed,  6 Jan 2010 20:04:37 +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 o06K4axr025386;
	Wed, 6 Jan 2010 20:04:36 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o06K4aob025384;
	Wed, 6 Jan 2010 20:04:36 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001062004.o06K4aob025384@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Wed, 6 Jan 2010 20:04:36 +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: r201662 - user/ed/utmpx/lib/libc/gen
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: Wed, 06 Jan 2010 20:04:37 -0000

Author: ed
Date: Wed Jan  6 20:04:36 2010
New Revision: 201662
URL: http://svn.freebsd.org/changeset/base/201662

Log:
  Add some checks to time stamps:
  
  - Prevent login sessions from ever getting a negative duration.
  - Don't update lastlogin when the timestamp is lower than the old value.

Modified:
  user/ed/utmpx/lib/libc/gen/pututxline.c

Modified: user/ed/utmpx/lib/libc/gen/pututxline.c
==============================================================================
--- user/ed/utmpx/lib/libc/gen/pututxline.c	Wed Jan  6 19:57:38 2010	(r201661)
+++ user/ed/utmpx/lib/libc/gen/pututxline.c	Wed Jan  6 20:04:36 2010	(r201662)
@@ -136,7 +136,7 @@ found:
 }
 
 static int
-utx_active_remove(const struct futx *fu)
+utx_active_remove(struct futx *fu)
 {
 	int fd;
 	struct futx fe;
@@ -158,6 +158,15 @@ utx_active_remove(const struct futx *fu)
 		case LOGIN_PROCESS:
 			if (strncmp(fu->fu_id, fe.fu_id, sizeof fe.fu_id) != 0)
 				continue;
+
+			/*
+			 * Prevent login sessions from having a negative
+			 * timespan.
+			 */
+			if (fu->fu_tv < fe.fu_tv)
+				fu->fu_tv = fe.fu_tv;
+
+			/* Terminate session. */
 			lseek(fd, -sizeof fe, SEEK_CUR);
 			_write(fd, fu, sizeof *fu);
 			lockf(fd, F_ULOCK, 0);
@@ -190,12 +199,19 @@ utx_lastlogin_add(const struct futx *fu)
 		return;
 	}
 	while (_read(fd, &fe, sizeof fe) == sizeof fe) {
-		if (strncmp(fu->fu_user, fe.fu_user, sizeof fe.fu_user) == 0) {
-			lseek(fd, -sizeof fe, SEEK_CUR);
-			break;
-		}
+		if (strncmp(fu->fu_user, fe.fu_user, sizeof fe.fu_user) != 0)
+			continue;
+
+		/* Prevent lowering of the time value. */
+		if (fu->fu_tv <= fe.fu_tv)
+			goto done;
+		
+		/* Found a previous lastlogin entry for this * user. */
+		lseek(fd, -sizeof fe, SEEK_CUR);
+		break;
 	}
 	_write(fd, fu, sizeof *fu);
+done:
 	lockf(fd, F_ULOCK, 0);
 	_close(fd);
 }

From owner-svn-src-user@FreeBSD.ORG  Wed Jan  6 20:08:20 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 9BF901065693;
	Wed,  6 Jan 2010 20:08:20 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 8BE968FC22;
	Wed,  6 Jan 2010 20:08:20 +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 o06K8K6G026290;
	Wed, 6 Jan 2010 20:08:20 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o06K8KFa026288;
	Wed, 6 Jan 2010 20:08:20 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001062008.o06K8KFa026288@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Wed, 6 Jan 2010 20:08:20 +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: r201664 - user/ed/utmpx/lib/libc/gen
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: Wed, 06 Jan 2010 20:08:20 -0000

Author: ed
Date: Wed Jan  6 20:08:20 2010
New Revision: 201664
URL: http://svn.freebsd.org/changeset/base/201664

Log:
  Remove a " * " from the comment, caused by vim(1) line wrapping.

Modified:
  user/ed/utmpx/lib/libc/gen/pututxline.c

Modified: user/ed/utmpx/lib/libc/gen/pututxline.c
==============================================================================
--- user/ed/utmpx/lib/libc/gen/pututxline.c	Wed Jan  6 20:07:18 2010	(r201663)
+++ user/ed/utmpx/lib/libc/gen/pututxline.c	Wed Jan  6 20:08:20 2010	(r201664)
@@ -202,11 +202,11 @@ utx_lastlogin_add(const struct futx *fu)
 		if (strncmp(fu->fu_user, fe.fu_user, sizeof fe.fu_user) != 0)
 			continue;
 
-		/* Prevent lowering of the time value. */
+		/* Prevent lowering the time value. */
 		if (fu->fu_tv <= fe.fu_tv)
 			goto done;
 		
-		/* Found a previous lastlogin entry for this * user. */
+		/* Found a previous lastlogin entry for this user. */
 		lseek(fd, -sizeof fe, SEEK_CUR);
 		break;
 	}

From owner-svn-src-user@FreeBSD.ORG  Wed Jan  6 20:39:57 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 87C9D10656A5;
	Wed,  6 Jan 2010 20:39:57 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 7646E8FC0A;
	Wed,  6 Jan 2010 20:39:57 +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 o06Kdv2g033351;
	Wed, 6 Jan 2010 20:39:57 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o06KdvA5033349;
	Wed, 6 Jan 2010 20:39:57 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001062039.o06KdvA5033349@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Wed, 6 Jan 2010 20:39:57 +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: r201666 - user/ed/utmpx/lib/libulog
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: Wed, 06 Jan 2010 20:39:57 -0000

Author: ed
Date: Wed Jan  6 20:39:57 2010
New Revision: 201666
URL: http://svn.freebsd.org/changeset/base/201666

Log:
  Let libulog use ut_id properly, now we have it.

Modified:
  user/ed/utmpx/lib/libulog/ulog_login.c

Modified: user/ed/utmpx/lib/libulog/ulog_login.c
==============================================================================
--- user/ed/utmpx/lib/libulog/ulog_login.c	Wed Jan  6 20:28:47 2010	(r201665)
+++ user/ed/utmpx/lib/libulog/ulog_login.c	Wed Jan  6 20:39:57 2010	(r201666)
@@ -30,9 +30,27 @@ __FBSDID("$FreeBSD$");
 #include <sys/time.h>
 #include <paths.h>
 #include <string.h>
+#include <unistd.h>
 #include <utmpx.h>
 #include "ulog.h"
 
+static void
+ulog_genid(struct utmpx *utx, const char *line)
+{
+	size_t s, d;
+
+	/*
+	 * Generate an ut_id based on the TTY name.  Use a reverse order
+	 * to prevent the limited space we have to be wasted on prefixes
+	 * like "tty" and "pts/".  It also makes sure aliasing because
+	 * of cropping of "pts/1000" and "pts/1001" is less likely.
+	 * Prepend an 'u' to indicate it was done by libulog.
+	 */
+	utx->ut_id[0] = 'u';
+	for (s = strlen(line), d = 1; s > 0 && d <= sizeof utx->ut_id; s--, d++)
+		utx->ut_id[d] = line[s - 1];
+}
+
 void
 ulog_login(const char *line, const char *user, const char *host)
 {
@@ -44,8 +62,9 @@ ulog_login(const char *line, const char 
 
 	memset(&utx, 0, sizeof utx);
 
-	/* XXX: ut_id, ut_pid missing. */
 	utx.ut_type = USER_PROCESS;
+	utx.ut_pid = getpid();
+	ulog_genid(&utx, line);
 	strncpy(utx.ut_line, line, sizeof utx.ut_line);
 	strncpy(utx.ut_user, user, sizeof utx.ut_user);
 	if (host != NULL)
@@ -66,9 +85,8 @@ ulog_logout(const char *line)
 
 	memset(&utx, 0, sizeof utx);
 
-	/* XXX: ut_id, ut_pid missing. ut_line not needed */
 	utx.ut_type = DEAD_PROCESS;
-	strncpy(utx.ut_line, line, sizeof utx.ut_line);
+	ulog_genid(&utx, line);
 	gettimeofday(&utx.ut_tv, NULL);
 
 	pututxline(&utx);

From owner-svn-src-user@FreeBSD.ORG  Wed Jan  6 20:46:05 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 F16271065692;
	Wed,  6 Jan 2010 20:46:05 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id E18258FC21;
	Wed,  6 Jan 2010 20:46:05 +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 o06Kk5Vj034896;
	Wed, 6 Jan 2010 20:46:05 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o06Kk5s3034894;
	Wed, 6 Jan 2010 20:46:05 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001062046.o06Kk5s3034894@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Wed, 6 Jan 2010 20:46:05 +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: r201670 - user/ed/utmpx/lib/libulog
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: Wed, 06 Jan 2010 20:46:06 -0000

Author: ed
Date: Wed Jan  6 20:46:05 2010
New Revision: 201670
URL: http://svn.freebsd.org/changeset/base/201670

Log:
  We can also add the pid for logout entries.

Modified:
  user/ed/utmpx/lib/libulog/ulog_login.c

Modified: user/ed/utmpx/lib/libulog/ulog_login.c
==============================================================================
--- user/ed/utmpx/lib/libulog/ulog_login.c	Wed Jan  6 20:43:40 2010	(r201669)
+++ user/ed/utmpx/lib/libulog/ulog_login.c	Wed Jan  6 20:46:05 2010	(r201670)
@@ -86,6 +86,7 @@ ulog_logout(const char *line)
 	memset(&utx, 0, sizeof utx);
 
 	utx.ut_type = DEAD_PROCESS;
+	utx.ut_pid = getpid();
 	ulog_genid(&utx, line);
 	gettimeofday(&utx.ut_tv, NULL);
 

From owner-svn-src-user@FreeBSD.ORG  Wed Jan  6 21:11:38 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 04C32106566B;
	Wed,  6 Jan 2010 21:11:38 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id E87F98FC0A;
	Wed,  6 Jan 2010 21:11:37 +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 o06LBbpN040841;
	Wed, 6 Jan 2010 21:11:37 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o06LBb8q040837;
	Wed, 6 Jan 2010 21:11:37 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001062111.o06LBb8q040837@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Wed, 6 Jan 2010 21:11:37 +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: r201673 - user/ed/utmpx/lib/libc/gen
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: Wed, 06 Jan 2010 21:11:38 -0000

Author: ed
Date: Wed Jan  6 21:11:37 2010
New Revision: 201673
URL: http://svn.freebsd.org/changeset/base/201673

Log:
  Treat ut_id as binary information, not a string.
  
  Looking at both the implementation from Solaris and NetBSD, ut_id isn't
  supposed to be a string. It makes sense, because I can imagine certain
  applications just write random binary data into this field to identify
  sessions.

Modified:
  user/ed/utmpx/lib/libc/gen/getutxent.c
  user/ed/utmpx/lib/libc/gen/pututxline.c
  user/ed/utmpx/lib/libc/gen/utxdb.h

Modified: user/ed/utmpx/lib/libc/gen/getutxent.c
==============================================================================
--- user/ed/utmpx/lib/libc/gen/getutxent.c	Wed Jan  6 20:54:04 2010	(r201672)
+++ user/ed/utmpx/lib/libc/gen/getutxent.c	Wed Jan  6 21:11:37 2010	(r201673)
@@ -101,7 +101,7 @@ futx_to_utx(const struct futx *fu, struc
 	case SHUTDOWN_TIME:
 		break;
 	case USER_PROCESS:
-		FTOU_STRING(fu, ut, id);
+		FTOU_ID(fu, ut);
 		FTOU_STRING(fu, ut, user);
 		FTOU_STRING(fu, ut, line);
 		/* Extension: host name. */
@@ -109,16 +109,16 @@ futx_to_utx(const struct futx *fu, struc
 		FTOU_PID(fu, ut);
 		break;
 	case INIT_PROCESS:
-		FTOU_STRING(fu, ut, id);
+		FTOU_ID(fu, ut);
 		FTOU_PID(fu, ut);
 		break;
 	case LOGIN_PROCESS:
-		FTOU_STRING(fu, ut, id);
+		FTOU_ID(fu, ut);
 		FTOU_STRING(fu, ut, user);
 		FTOU_PID(fu, ut);
 		break;
 	case DEAD_PROCESS:
-		FTOU_STRING(fu, ut, id);
+		FTOU_ID(fu, ut);
 		FTOU_PID(fu, ut);
 		break;
 	default:
@@ -202,7 +202,7 @@ getutxid(const struct utmpx *id)
 			case INIT_PROCESS:
 			case LOGIN_PROCESS:
 			case DEAD_PROCESS:
-				if (strncmp(fu->fu_id, id->ut_id,
+				if (memcmp(fu->fu_id, id->ut_id,
 				    MIN(sizeof fu->fu_id, sizeof id->ut_id)) == 0)
 					goto found;
 			}

Modified: user/ed/utmpx/lib/libc/gen/pututxline.c
==============================================================================
--- user/ed/utmpx/lib/libc/gen/pututxline.c	Wed Jan  6 20:54:04 2010	(r201672)
+++ user/ed/utmpx/lib/libc/gen/pututxline.c	Wed Jan  6 21:11:37 2010	(r201673)
@@ -69,7 +69,7 @@ utx_to_futx(const struct utmpx *ut, stru
 	case SHUTDOWN_TIME:
 		break;
 	case USER_PROCESS:
-		UTOF_STRING(ut, fu, id);
+		UTOF_ID(ut, fu);
 		UTOF_STRING(ut, fu, user);
 		UTOF_STRING(ut, fu, line);
 		/* Extension: host name. */
@@ -77,16 +77,16 @@ utx_to_futx(const struct utmpx *ut, stru
 		UTOF_PID(ut, fu);
 		break;
 	case INIT_PROCESS:
-		UTOF_STRING(ut, fu, id);
+		UTOF_ID(ut, fu);
 		UTOF_PID(ut, fu);
 		break;
 	case LOGIN_PROCESS:
-		UTOF_STRING(ut, fu, id);
+		UTOF_ID(ut, fu);
 		UTOF_STRING(ut, fu, user);
 		UTOF_PID(ut, fu);
 		break;
 	case DEAD_PROCESS:
-		UTOF_STRING(ut, fu, id);
+		UTOF_ID(ut, fu);
 		UTOF_PID(ut, fu);
 		break;
 	default:
@@ -121,7 +121,7 @@ utx_active_add(const struct futx *fu)
 		case USER_PROCESS:
 		case INIT_PROCESS:
 		case LOGIN_PROCESS:
-			if (strncmp(fu->fu_id, fe.fu_id, sizeof fe.fu_id) != 0)
+			if (memcmp(fu->fu_id, fe.fu_id, sizeof fe.fu_id) != 0)
 				continue;
 			/* FALLTHROUGH */
 		default:
@@ -156,7 +156,7 @@ utx_active_remove(struct futx *fu)
 		case USER_PROCESS:
 		case INIT_PROCESS:
 		case LOGIN_PROCESS:
-			if (strncmp(fu->fu_id, fe.fu_id, sizeof fe.fu_id) != 0)
+			if (memcmp(fu->fu_id, fe.fu_id, sizeof fe.fu_id) != 0)
 				continue;
 
 			/*

Modified: user/ed/utmpx/lib/libc/gen/utxdb.h
==============================================================================
--- user/ed/utmpx/lib/libc/gen/utxdb.h	Wed Jan  6 20:54:04 2010	(r201672)
+++ user/ed/utmpx/lib/libc/gen/utxdb.h	Wed Jan  6 21:11:37 2010	(r201673)
@@ -60,6 +60,10 @@ struct futx {
 	strncpy((ut)->ut_ ## field, (fu)->fu_ ## field,		\
 	    MIN(sizeof (ut)->ut_ ## field - 1, sizeof (fu)->fu_ ## field)); \
 } while (0)
+#define	FTOU_ID(fu, ut) do { \
+	memcpy((ut)->ut_id, (fu)->fu_id,				\
+	    MIN(sizeof (ut)->ut_id, sizeof (fu)->fu_id));		\
+} while (0)
 #define	FTOU_PID(fu, ut) do { \
 	(ut)->ut_pid = be32toh((fu)->fu_pid);				\
 } while (0)
@@ -77,6 +81,10 @@ struct futx {
 	strncpy((fu)->fu_ ## field, (ut)->ut_ ## field,		\
 	    MIN(sizeof (fu)->fu_ ## field, sizeof (ut)->ut_ ## field));	\
 } while (0)
+#define	UTOF_ID(ut, fu) do { \
+	memcpy((fu)->fu_id, (ut)->ut_id,				\
+	    MIN(sizeof (fu)->fu_id, sizeof (ut)->ut_id));		\
+} while (0)
 #define	UTOF_PID(ut, fu) do { \
 	(fu)->fu_pid = htobe32((ut)->ut_pid);				\
 } while (0)

From owner-svn-src-user@FreeBSD.ORG  Wed Jan  6 21:12:38 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 A99F21065670;
	Wed,  6 Jan 2010 21:12:38 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 99EB68FC13;
	Wed,  6 Jan 2010 21:12:38 +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 o06LCcQ4041158;
	Wed, 6 Jan 2010 21:12:38 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o06LCc1l041156;
	Wed, 6 Jan 2010 21:12:38 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001062112.o06LCc1l041156@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Wed, 6 Jan 2010 21:12:38 +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: r201674 - user/ed/utmpx/usr.sbin/ac
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: Wed, 06 Jan 2010 21:12:38 -0000

Author: ed
Date: Wed Jan  6 21:12:38 2010
New Revision: 201674
URL: http://svn.freebsd.org/changeset/base/201674

Log:
  Also fix ac(8) now that ut_id is binary.

Modified:
  user/ed/utmpx/usr.sbin/ac/ac.c

Modified: user/ed/utmpx/usr.sbin/ac/ac.c
==============================================================================
--- user/ed/utmpx/usr.sbin/ac/ac.c	Wed Jan  6 21:11:37 2010	(r201673)
+++ user/ed/utmpx/usr.sbin/ac/ac.c	Wed Jan  6 21:12:38 2010	(r201674)
@@ -379,7 +379,7 @@ log_out(struct utmp_list *head, struct u
 	for (lp = head, lp2 = NULL; lp != NULL; )
 		if (up->ut_type == BOOT_TIME || up->ut_type == SHUTDOWN_TIME ||
 		    (up->ut_type == DEAD_PROCESS &&
-		    strcmp(lp->usr.ut_id, up->ut_id) == 0)) {
+		    memcmp(lp->usr.ut_id, up->ut_id) == 0)) {
 			secs = up->ut_tv.tv_sec - lp->usr.ut_tv.tv_sec;
 			Users = update_user(Users, lp->usr.ut_user, secs);
 #ifdef DEBUG

From owner-svn-src-user@FreeBSD.ORG  Wed Jan  6 21:13:29 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 0098F106568B;
	Wed,  6 Jan 2010 21:13:29 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id E4E8A8FC13;
	Wed,  6 Jan 2010 21:13:28 +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 o06LDSOI041437;
	Wed, 6 Jan 2010 21:13:28 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o06LDSdn041435;
	Wed, 6 Jan 2010 21:13:28 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001062113.o06LDSdn041435@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Wed, 6 Jan 2010 21:13:28 +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: r201675 - user/ed/utmpx/usr.sbin/ac
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: Wed, 06 Jan 2010 21:13:29 -0000

Author: ed
Date: Wed Jan  6 21:13:28 2010
New Revision: 201675
URL: http://svn.freebsd.org/changeset/base/201675

Log:
  Fix stupidity on my side.

Modified:
  user/ed/utmpx/usr.sbin/ac/ac.c

Modified: user/ed/utmpx/usr.sbin/ac/ac.c
==============================================================================
--- user/ed/utmpx/usr.sbin/ac/ac.c	Wed Jan  6 21:12:38 2010	(r201674)
+++ user/ed/utmpx/usr.sbin/ac/ac.c	Wed Jan  6 21:13:28 2010	(r201675)
@@ -379,7 +379,7 @@ log_out(struct utmp_list *head, struct u
 	for (lp = head, lp2 = NULL; lp != NULL; )
 		if (up->ut_type == BOOT_TIME || up->ut_type == SHUTDOWN_TIME ||
 		    (up->ut_type == DEAD_PROCESS &&
-		    memcmp(lp->usr.ut_id, up->ut_id) == 0)) {
+		    memcmp(lp->usr.ut_id, up->ut_id, sizeof up->ut_id) == 0)) {
 			secs = up->ut_tv.tv_sec - lp->usr.ut_tv.tv_sec;
 			Users = update_user(Users, lp->usr.ut_user, secs);
 #ifdef DEBUG

From owner-svn-src-user@FreeBSD.ORG  Wed Jan  6 21:22:30 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 2AEEC1065698;
	Wed,  6 Jan 2010 21:22:30 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 1AB198FC1A;
	Wed,  6 Jan 2010 21:22:30 +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 o06LMTp4043603;
	Wed, 6 Jan 2010 21:22:30 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o06LMT0n043601;
	Wed, 6 Jan 2010 21:22:29 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001062122.o06LMT0n043601@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Wed, 6 Jan 2010 21:22:29 +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: r201676 - user/luigi/ipfw3-head/sys/netinet/ipfw
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: Wed, 06 Jan 2010 21:22:30 -0000

Author: luigi
Date: Wed Jan  6 21:22:29 2010
New Revision: 201676
URL: http://svn.freebsd.org/changeset/base/201676

Log:
  probable fix for broken keepalives. These packets go to ip_output()
  so they need ip_len in network format.

Modified:
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_dynamic.c

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_dynamic.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_dynamic.c	Wed Jan  6 21:13:28 2010	(r201675)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_dynamic.c	Wed Jan  6 21:22:29 2010	(r201676)
@@ -1002,7 +1002,7 @@ ipfw_send_pkt(struct mbuf *replyto, stru
 		h->ip_hl = sizeof(*h) >> 2;
 		h->ip_tos = IPTOS_LOWDELAY;
 		h->ip_off = 0;
-		h->ip_len = htons(len);
+		h->ip_len = len; // XXX was htons(len); 
 		h->ip_ttl = V_ip_defttl;
 		h->ip_sum = 0;
 		break;

From owner-svn-src-user@FreeBSD.ORG  Wed Jan  6 21:27:06 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 D404A1065696;
	Wed,  6 Jan 2010 21:27:06 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id C45138FC08;
	Wed,  6 Jan 2010 21:27:06 +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 o06LR6q4044646;
	Wed, 6 Jan 2010 21:27:06 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o06LR6YK044644;
	Wed, 6 Jan 2010 21:27:06 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001062127.o06LR6YK044644@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Wed, 6 Jan 2010 21:27:06 +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: r201677 - user/ed/utmpx/lib/libc/gen
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: Wed, 06 Jan 2010 21:27:06 -0000

Author: ed
Date: Wed Jan  6 21:27:06 2010
New Revision: 201677
URL: http://svn.freebsd.org/changeset/base/201677

Log:
  Respect the byte ordering of fu_tv.

Modified:
  user/ed/utmpx/lib/libc/gen/pututxline.c

Modified: user/ed/utmpx/lib/libc/gen/pututxline.c
==============================================================================
--- user/ed/utmpx/lib/libc/gen/pututxline.c	Wed Jan  6 21:22:29 2010	(r201676)
+++ user/ed/utmpx/lib/libc/gen/pututxline.c	Wed Jan  6 21:27:06 2010	(r201677)
@@ -163,7 +163,7 @@ utx_active_remove(struct futx *fu)
 			 * Prevent login sessions from having a negative
 			 * timespan.
 			 */
-			if (fu->fu_tv < fe.fu_tv)
+			if (be64toh(fu->fu_tv) < be64toh(fe.fu_tv))
 				fu->fu_tv = fe.fu_tv;
 
 			/* Terminate session. */
@@ -203,7 +203,7 @@ utx_lastlogin_add(const struct futx *fu)
 			continue;
 
 		/* Prevent lowering the time value. */
-		if (fu->fu_tv <= fe.fu_tv)
+		if (be64toh(fu->fu_tv) <= be64toh(fe.fu_tv))
 			goto done;
 		
 		/* Found a previous lastlogin entry for this user. */

From owner-svn-src-user@FreeBSD.ORG  Wed Jan  6 21:36:34 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 3D6F41065670;
	Wed,  6 Jan 2010 21:36:34 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 2DC838FC0A;
	Wed,  6 Jan 2010 21:36:34 +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 o06LaYuY046763;
	Wed, 6 Jan 2010 21:36:34 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o06LaYwq046760;
	Wed, 6 Jan 2010 21:36:34 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001062136.o06LaYwq046760@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Wed, 6 Jan 2010 21:36:34 +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: r201678 - user/ed/utmpx/sbin/init
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: Wed, 06 Jan 2010 21:36:34 -0000

Author: ed
Date: Wed Jan  6 21:36:33 2010
New Revision: 201678
URL: http://svn.freebsd.org/changeset/base/201678

Log:
  Calling ulog_logout() here makes no sense at all.
  
  Now that we have ut_id, we should walk through all sessions using
  getutxline() and terminate all of them by hand.

Modified:
  user/ed/utmpx/sbin/init/Makefile
  user/ed/utmpx/sbin/init/init.c

Modified: user/ed/utmpx/sbin/init/Makefile
==============================================================================
--- user/ed/utmpx/sbin/init/Makefile	Wed Jan  6 21:27:06 2010	(r201677)
+++ user/ed/utmpx/sbin/init/Makefile	Wed Jan  6 21:36:33 2010	(r201678)
@@ -6,8 +6,8 @@ MAN=	init.8
 PRECIOUSPROG=
 INSTALLFLAGS=-b -B.bak
 CFLAGS+=-DDEBUGSHELL -DSECURE -DLOGIN_CAP -DCOMPAT_SYSV_INIT
-DPADD=	${LIBUTIL} ${LIBULOG} ${LIBCRYPT}
-LDADD=	-lutil -lulog -lcrypt
+DPADD=	${LIBUTIL} ${LIBCRYPT}
+LDADD=	-lutil -lcrypt
 
 NO_SHARED?=	YES
 

Modified: user/ed/utmpx/sbin/init/init.c
==============================================================================
--- user/ed/utmpx/sbin/init/init.c	Wed Jan  6 21:27:06 2010	(r201677)
+++ user/ed/utmpx/sbin/init/init.c	Wed Jan  6 21:36:33 2010	(r201678)
@@ -569,10 +569,13 @@ transition(state_t s)
  * NB: should send a message to the session logger to avoid blocking.
  */
 static void
-clear_session_logs(session_t *sp)
+clear_session_logs(session_t *sp __unused)
 {
 
-	ulog_logout(sp->se_device);
+	/*
+	 * XXX: Use getutxline() and call pututxline() for each entry.
+	 * Is this safe to do this here?  Is it really required anyway?
+	 */
 }
 
 /*

From owner-svn-src-user@FreeBSD.ORG  Wed Jan  6 22:15:26 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 9A838106566C;
	Wed,  6 Jan 2010 22:15:26 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 8AC9A8FC15;
	Wed,  6 Jan 2010 22:15:26 +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 o06MFQOI055609;
	Wed, 6 Jan 2010 22:15:26 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o06MFQSL055606;
	Wed, 6 Jan 2010 22:15:26 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001062215.o06MFQSL055606@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Wed, 6 Jan 2010 22:15:26 +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: r201682 - user/ed/utmpx/crypto/openssh
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: Wed, 06 Jan 2010 22:15:26 -0000

Author: ed
Date: Wed Jan  6 22:15:26 2010
New Revision: 201682
URL: http://svn.freebsd.org/changeset/base/201682

Log:
  Improve hacks on OpenSSH:
  
  - Reduce the diff against config.h generated by openssh-portable.
  - Add some bits to make Last login: work. This should eventually be sent
    upstream.

Modified:
  user/ed/utmpx/crypto/openssh/config.h
  user/ed/utmpx/crypto/openssh/loginrec.c

Modified: user/ed/utmpx/crypto/openssh/config.h
==============================================================================
--- user/ed/utmpx/crypto/openssh/config.h	Wed Jan  6 22:14:05 2010	(r201681)
+++ user/ed/utmpx/crypto/openssh/config.h	Wed Jan  6 22:15:26 2010	(r201682)
@@ -448,7 +448,7 @@
 #define HAVE_GETUTXENT 1
 
 /* Define to 1 if you have the `getutxid' function. */
-/* #undef HAVE_GETUTXID */
+#define HAVE_GETUTXID 1
 
 /* Define to 1 if you have the `getutxline' function. */
 #define HAVE_GETUTXLINE 1
@@ -484,7 +484,7 @@
 #define HAVE_HEADER_AD 1
 
 /* Define if you have ut_host in utmp.h */
-#define HAVE_HOST_IN_UTMP 1
+/* #undef HAVE_HOST_IN_UTMP */
 
 /* Define if you have ut_host in utmpx.h */
 #define HAVE_HOST_IN_UTMPX 1
@@ -586,10 +586,10 @@
 /* #undef HAVE_LOGIN_H */
 
 /* Define to 1 if you have the `logout' function. */
-#define HAVE_LOGOUT 1
+/* #undef HAVE_LOGOUT */
 
 /* Define to 1 if you have the `logwtmp' function. */
-#define HAVE_LOGWTMP 1
+/* #undef HAVE_LOGWTMP */
 
 /* Define to 1 if the system has the type `long double'. */
 #define HAVE_LONG_DOUBLE 1
@@ -1025,7 +1025,7 @@
 #define HAVE_TIME_H 1
 
 /* Define if you have ut_time in utmp.h */
-#define HAVE_TIME_IN_UTMP 1
+/* #undef HAVE_TIME_IN_UTMP */
 
 /* Define if you have ut_time in utmpx.h */
 /* #undef HAVE_TIME_IN_UTMPX */
@@ -1049,7 +1049,7 @@
 /* #undef HAVE_TYPE_IN_UTMP */
 
 /* Define if you have ut_type in utmpx.h */
-/* #undef HAVE_TYPE_IN_UTMPX */
+#define HAVE_TYPE_IN_UTMPX 1
 
 /* Define to 1 if you have the <ucred.h> header file. */
 /* #undef HAVE_UCRED_H */
@@ -1175,7 +1175,7 @@
 /* #undef KRB5 */
 
 /* Define if pututxline updates lastlog too */
-#define LASTLOG_WRITE_PUTUTXLINE 1
+/* #undef LASTLOG_WRITE_PUTUTXLINE */
 
 /* Define if you want TCP Wrappers support */
 #define LIBWRAP 1

Modified: user/ed/utmpx/crypto/openssh/loginrec.c
==============================================================================
--- user/ed/utmpx/crypto/openssh/loginrec.c	Wed Jan  6 22:14:05 2010	(r201681)
+++ user/ed/utmpx/crypto/openssh/loginrec.c	Wed Jan  6 22:15:26 2010	(r201682)
@@ -509,6 +509,10 @@ getlast_entry(struct logininfo *li)
 	return(lastlog_get_entry(li));
 #else /* !USE_LASTLOG */
 
+#if 1
+	return (utmpx_get_entry(li));
+#endif
+
 #if defined(DISABLE_LASTLOG)
 	/* On some systems we shouldn't even try to obtain last login
 	 * time, e.g. AIX */
@@ -1608,6 +1612,30 @@ lastlog_get_entry(struct logininfo *li)
 #endif /* HAVE_GETLASTLOGXBYNAME */
 #endif /* USE_LASTLOG */
 
+#if 1
+int
+utmpx_get_entry(struct logininfo *li)
+{
+	struct utmpx *utx;
+
+	if (setutxdb(UTXDB_LASTLOGIN, NULL) != 0)
+		return (0);
+	utx = getutxuser(li->username);
+	if (utx == NULL) {
+		endutxent();
+		return (0);
+	}
+
+	line_fullname(li->line, utx->ut_line, sizeof(utx->ut_line));
+	strlcpy(li->hostname, utx->ut_host,
+		MIN_SIZEOF(li->hostname, utx->ut_host));
+	li->tv_sec = utx->ut_tv.tv_sec;
+	li->tv_usec = utx->ut_tv.tv_usec;
+	endutxent();
+	return (1);
+}
+#endif
+
 #ifdef USE_BTMP
   /*
    * Logs failed login attempts in _PATH_BTMP if that exists.

From owner-svn-src-user@FreeBSD.ORG  Wed Jan  6 22:19:58 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 3E37F106566B;
	Wed,  6 Jan 2010 22:19:58 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 2ED668FC1B;
	Wed,  6 Jan 2010 22:19:58 +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 o06MJwJr056626;
	Wed, 6 Jan 2010 22:19:58 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o06MJw24056624;
	Wed, 6 Jan 2010 22:19:58 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001062219.o06MJw24056624@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Wed, 6 Jan 2010 22:19:58 +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: r201683 - user/ed/utmpx/crypto/openssh
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: Wed, 06 Jan 2010 22:19:58 -0000

Author: ed
Date: Wed Jan  6 22:19:57 2010
New Revision: 201683
URL: http://svn.freebsd.org/changeset/base/201683

Log:
  The size argument needs to be the size of the destination buffer.

Modified:
  user/ed/utmpx/crypto/openssh/loginrec.c

Modified: user/ed/utmpx/crypto/openssh/loginrec.c
==============================================================================
--- user/ed/utmpx/crypto/openssh/loginrec.c	Wed Jan  6 22:15:26 2010	(r201682)
+++ user/ed/utmpx/crypto/openssh/loginrec.c	Wed Jan  6 22:19:57 2010	(r201683)
@@ -1626,7 +1626,7 @@ utmpx_get_entry(struct logininfo *li)
 		return (0);
 	}
 
-	line_fullname(li->line, utx->ut_line, sizeof(utx->ut_line));
+	line_fullname(li->line, utx->ut_line, sizeof(li->line));
 	strlcpy(li->hostname, utx->ut_host,
 		MIN_SIZEOF(li->hostname, utx->ut_host));
 	li->tv_sec = utx->ut_tv.tv_sec;

From owner-svn-src-user@FreeBSD.ORG  Wed Jan  6 23:36:15 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 3DA1E10656AD;
	Wed,  6 Jan 2010 23:36:15 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 2E56C8FC18;
	Wed,  6 Jan 2010 23:36:15 +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 o06NaFND074569;
	Wed, 6 Jan 2010 23:36:15 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o06NaFYb074567;
	Wed, 6 Jan 2010 23:36:15 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001062336.o06NaFYb074567@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Wed, 6 Jan 2010 23:36:15 +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: r201695 - user/ed/utmpx/lib/libc/gen
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: Wed, 06 Jan 2010 23:36:15 -0000

Author: ed
Date: Wed Jan  6 23:36:14 2010
New Revision: 201695
URL: http://svn.freebsd.org/changeset/base/201695

Log:
  Truncate utx.active when (re)booting.
  
  This makes sure utmp entries never survive a reboot.

Modified:
  user/ed/utmpx/lib/libc/gen/pututxline.c

Modified: user/ed/utmpx/lib/libc/gen/pututxline.c
==============================================================================
--- user/ed/utmpx/lib/libc/gen/pututxline.c	Wed Jan  6 23:34:53 2010	(r201694)
+++ user/ed/utmpx/lib/libc/gen/pututxline.c	Wed Jan  6 23:36:14 2010	(r201695)
@@ -181,6 +181,13 @@ utx_active_remove(struct futx *fu)
 }
 
 static void
+utx_active_purge(void)
+{
+
+	truncate(_PATH_UTX_ACTIVE, 0);
+}
+
+static void
 utx_lastlogin_add(const struct futx *fu)
 {
 	int fd;
@@ -253,9 +260,11 @@ pututxline(const struct utmpx *utmpx)
 	
 	switch (fu.fu_type) {
 	case BOOT_TIME:
+	case SHUTDOWN_TIME:
+		utx_active_purge();
+		break;
 	case OLD_TIME:
 	case NEW_TIME:
-	case SHUTDOWN_TIME:
 		break;
 	case USER_PROCESS:
 		utx_active_add(&fu);

From owner-svn-src-user@FreeBSD.ORG  Thu Jan  7 06:59:16 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 534E0106568F;
	Thu,  7 Jan 2010 06:59:16 +0000 (UTC)
	(envelope-from edwin@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 40CD98FC0C;
	Thu,  7 Jan 2010 06:59:16 +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 o076xGP9073608;
	Thu, 7 Jan 2010 06:59:16 GMT (envelope-from edwin@svn.freebsd.org)
Received: (from edwin@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o076xGf2073602;
	Thu, 7 Jan 2010 06:59:16 GMT (envelope-from edwin@svn.freebsd.org)
Message-Id: <201001070659.o076xGf2073602@svn.freebsd.org>
From: Edwin Groothuis <edwin@FreeBSD.org>
Date: Thu, 7 Jan 2010 06:59:16 +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: r201718 - user/edwin/calendar
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: Thu, 07 Jan 2010 06:59:16 -0000

Author: edwin
Date: Thu Jan  7 06:59:16 2010
New Revision: 201718
URL: http://svn.freebsd.org/changeset/base/201718

Log:
  Add support for phase of the moon.

Added:
  user/edwin/calendar/pom.c
Modified:
  user/edwin/calendar/Makefile
  user/edwin/calendar/calendar.h
  user/edwin/calendar/io.c
  user/edwin/calendar/parsedata.c

Modified: user/edwin/calendar/Makefile
==============================================================================
--- user/edwin/calendar/Makefile	Thu Jan  7 06:20:07 2010	(r201717)
+++ user/edwin/calendar/Makefile	Thu Jan  7 06:59:16 2010	(r201718)
@@ -5,13 +5,17 @@ CFLAGS=	 -pipe  -g -std=gnu99 -fstack-pr
 
 PROG=	calendar
 SRCS=   calendar.c locale.c events.c dates.c parsedata.c io.c day.c \
-	ostern.c paskha.c
+	ostern.c paskha.c pom.c
+LDADD=	-lm
 INTER=          de_AT.ISO_8859-15 de_DE.ISO8859-1 fr_FR.ISO8859-1 \
 		hr_HR.ISO8859-2 hu_HU.ISO8859-2 ru_RU.KOI8-R uk_UA.KOI8-U
 DE_LINKS=       de_DE.ISO8859-15
 FR_LINKS=       fr_FR.ISO8859-15
 TEXTMODE?=	444
 
+pom: pom.c
+	gcc -g -Wall -o pom pom.c -lm
+
 beforeinstall:
 	${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${TEXTMODE} \
 	    ${.CURDIR}/calendars/calendar.* ${DESTDIR}${SHAREDIR}/calendar

Modified: user/edwin/calendar/calendar.h
==============================================================================
--- user/edwin/calendar/calendar.h	Thu Jan  7 06:20:07 2010	(r201717)
+++ user/edwin/calendar/calendar.h	Thu Jan  7 06:59:16 2010	(r201718)
@@ -47,28 +47,32 @@ extern struct tm tp1, tp2;
 extern time_t t1, t2;
 extern const char *calendarFile;
 extern int yrdays;
-extern struct fixs neaster, npaskha, ncny;
+extern struct fixs neaster, npaskha, ncny, nfullmoon, nnewmoon;
 
 #define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)
 
 /* Flags to determine the returned values by determinestyle() in parsedata.c */
-#define	F_NONE			0x000
-#define	F_MONTH			0x001
-#define	F_DAYOFWEEK		0x002
-#define	F_DAYOFMONTH		0x004
-#define	F_MODIFIERINDEX		0x008
-#define	F_MODIFIEROFFSET	0x010
-#define	F_SPECIALDAY		0x020
-#define	F_ALLMONTH		0x040
-#define	F_ALLDAY		0x080
-#define	F_VARIABLE		0x100
-#define	F_EASTER		0x200
-#define	F_CNY			0x400
-#define	F_PASKHA		0x800
+#define	F_NONE			0x0000
+#define	F_MONTH			0x0001
+#define	F_DAYOFWEEK		0x0002
+#define	F_DAYOFMONTH		0x0004
+#define	F_MODIFIERINDEX		0x0008
+#define	F_MODIFIEROFFSET	0x0010
+#define	F_SPECIALDAY		0x0020
+#define	F_ALLMONTH		0x0040
+#define	F_ALLDAY		0x0080
+#define	F_VARIABLE		0x0100
+#define	F_EASTER		0x0200
+#define	F_CNY			0x0400
+#define	F_PASKHA		0x0800
+#define	F_NEWMOON		0x1000
+#define	F_FULLMOON		0x2000
 
 #define	STRING_EASTER	"Easter"
 #define	STRING_PASKHA	"Paskha"
 #define	STRING_CNY	"ChineseNewYear"
+#define STRING_NEWMOON	"NewMoon"
+#define STRING_FULLMOON	"FullMoon"
 
 extern int	debug;		/* show parsing of the input */
 extern int	f_dayAfter;	/* days after current date */
@@ -143,3 +147,8 @@ int	first_dayofweek_of_year(int y);
 int	first_dayofweek_of_month(int y, int m);
 int	walkthrough_dates(struct event **e);
 void	addtodate(struct event *e, int year, int month, int day);
+
+/* pom.c */
+#define	MAXMOONS	15
+void	pom(int year, int *fms, int *nms);
+

Modified: user/edwin/calendar/io.c
==============================================================================
--- user/edwin/calendar/io.c	Thu Jan  7 06:20:07 2010	(r201717)
+++ user/edwin/calendar/io.c	Thu Jan  7 06:59:16 2010	(r201718)
@@ -69,7 +69,7 @@ const char *calendarNoMail = "nomail";	/
 
 char	path[MAXPATHLEN];
 
-struct fixs neaster, npaskha, ncny;
+struct fixs neaster, npaskha, ncny, nfullmoon, nnewmoon;
 
 struct iovec header[] = {
 	{"From: ", 6},
@@ -152,6 +152,22 @@ cal(void)
 			ncny.len = strlen(buf + 15);
 			continue;
 		}
+		if (strncasecmp(buf, "NewMoon=", 8) == 0 && buf[8]) {
+			if (nnewmoon.name != NULL)
+				free(nnewmoon.name);
+			if ((nnewmoon.name = strdup(buf + 8)) == NULL)
+				errx(1, "cannot allocate memory");
+			nnewmoon.len = strlen(buf + 8);
+			continue;
+		}
+		if (strncasecmp(buf, "FullMoon=", 9) == 0 && buf[9]) {
+			if (nfullmoon.name != NULL)
+				free(nfullmoon.name);
+			if ((nfullmoon.name = strdup(buf + 9)) == NULL)
+				errx(1, "cannot allocate memory");
+			nfullmoon.len = strlen(buf + 9);
+			continue;
+		}
 
 		/*
 		 * If the line starts with a tab, the data has to be

Modified: user/edwin/calendar/parsedata.c
==============================================================================
--- user/edwin/calendar/parsedata.c	Thu Jan  7 06:20:07 2010	(r201717)
+++ user/edwin/calendar/parsedata.c	Thu Jan  7 06:59:16 2010	(r201718)
@@ -121,6 +121,14 @@ determinestyle(char *date, int *flags,
 			CHECKSPECIAL(date, STRING_CNY, strlen(STRING_CNY),
 			    F_CNY);
 			CHECKSPECIAL(date, ncny.name, ncny.len, F_CNY);
+			CHECKSPECIAL(date, STRING_NEWMOON,
+			    strlen(STRING_NEWMOON), F_NEWMOON);
+			CHECKSPECIAL(date, nnewmoon.name, nnewmoon.len,
+			    F_NEWMOON);
+			CHECKSPECIAL(date, STRING_FULLMOON,
+			    strlen(STRING_FULLMOON), F_FULLMOON);
+			CHECKSPECIAL(date, nfullmoon.name, nfullmoon.len,
+			    F_FULLMOON);
 			CHECKSPECIAL(date, STRING_PASKHA,
 			    strlen(STRING_PASKHA), F_PASKHA);
 			CHECKSPECIAL(date, npaskha.name, npaskha.len, F_PASKHA);
@@ -321,7 +329,9 @@ parsedaymonth(char *date, int *yearp, in
 	char month[100], dayofmonth[100], dayofweek[100], modifieroffset[100];
 	char modifierindex[100], specialday[100];
 	int idayofweek, imonth, idayofmonth, year, index;
+
 	int ieaster, ipaskha;
+	int ifullmoon[MAXMOONS], inewmoon[MAXMOONS];
 
 	int *mondays, d, m, dow, rm, rd, offset;
 
@@ -358,6 +368,7 @@ parsedaymonth(char *date, int *yearp, in
 	for (year = year1; year <= year2; year++) {
 		mondays = mondaytab[isleap(year)];
 		ieaster = easter(year);
+		pom(year, ifullmoon, inewmoon);
 
 		/* Same day every year */
 		if (*flags == (F_MONTH | F_DAYOFMONTH)) {
@@ -486,6 +497,40 @@ parsedaymonth(char *date, int *yearp, in
 			continue;
 		}
 
+		/* FullMoon */
+		if ((*flags & ~F_MODIFIEROFFSET) ==
+		    (F_SPECIALDAY | F_VARIABLE | F_FULLMOON)) {
+			int i;
+
+			offset = 0;
+			if ((*flags & F_MODIFIEROFFSET) != 0)
+				offset = parseoffset(modifieroffset);
+			for (i = 0; ifullmoon[i] != 0; i++) {
+				if (remember_yd(year, ifullmoon[i] + offset,
+				    &rm, &rd))
+					remember(index++, yearp, monthp, dayp,
+						year, rm, rd);
+			}
+			continue;
+		}
+
+		/* NewMoon */
+		if ((*flags & ~F_MODIFIEROFFSET) ==
+		    (F_SPECIALDAY | F_VARIABLE | F_NEWMOON)) {
+			int i;
+
+			offset = 0;
+			if ((*flags & F_MODIFIEROFFSET) != 0)
+				offset = parseoffset(modifieroffset);
+			for (i = 0; ifullmoon[i] != 0; i++) {
+				if (remember_yd(year, inewmoon[i] + offset,
+				    &rm, &rd))
+					remember(index++, yearp, monthp, dayp,
+						year, rm, rd);
+			}
+			continue;
+		}
+
 		printf("Unprocessed:\n");
 		debug_determinestyle(2, date, *flags, month, imonth,
 		    dayofmonth, idayofmonth, dayofweek, idayofweek,
@@ -526,6 +571,10 @@ showflags(int flags)
 		strcat(s, "paskha ");
 	if ((flags & F_EASTER) != 0)
 		strcat(s, "easter ");
+	if ((flags & F_FULLMOON) != 0)
+		strcat(s, "fullmoon ");
+	if ((flags & F_NEWMOON) != 0)
+		strcat(s, "newmoon ");
 
 	return s;
 }

Added: user/edwin/calendar/pom.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/edwin/calendar/pom.c	Thu Jan  7 06:59:16 2010	(r201718)
@@ -0,0 +1,222 @@
+/*
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software posted to USENET.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS 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.
+ */
+
+#if 0
+#ifndef lint
+static const char copyright[] =
+"@(#) Copyright (c) 1989, 1993\n\
+	The Regents of the University of California.  All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static const char sccsid[] = "@(#)pom.c       8.1 (Berkeley) 5/31/93";
+#endif /* not lint */
+#endif
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: head/games/pom/pom.c 201613 2010-01-05 21:14:48Z edwin $");
+
+/*
+ * Phase of the Moon.  Calculates the current phase of the moon.
+ * Based on routines from `Practical Astronomy with Your Calculator',
+ * by Duffett-Smith.  Comments give the section from the book that
+ * particular piece of code was adapted from.
+ *
+ * -- Keith E. Brandt  VIII 1984
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
+#include <sysexits.h>
+#include <time.h>
+#include <unistd.h> 
+
+#ifndef	PI
+#define	PI	  3.14159265358979323846
+#endif
+#define	EPOCH	  85
+#define	EPSILONg  279.611371	/* solar ecliptic long at EPOCH */
+#define	RHOg	  282.680403	/* solar ecliptic long of perigee at EPOCH */
+#define	ECCEN	  0.01671542	/* solar orbit eccentricity */
+#define	lzero	  18.251907	/* lunar mean long at EPOCH */
+#define	Pzero	  192.917585	/* lunar mean long of perigee at EPOCH */
+#define	Nzero	  55.204723	/* lunar mean long of node at EPOCH */
+#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)
+
+static void	adj360(double *);
+static double	dtor(double);
+static double	potm(double);
+
+void
+pom(int year, int *fms, int *nms)
+{
+	time_t tt;
+	struct tm GMT, tmd_today, tmd_tomorrow;
+	double days_today, days_tomorrow, today, tomorrow;
+	int cnt, d;
+	int yeardays;
+	int olddir, newdir;
+	int *pnms, *pfms;
+
+	pnms = nms;
+	pfms = fms;
+
+	/*
+	 * We take the phase of the moon one second before and one second
+	 * after midnight.
+	 */
+	memset(&tmd_today, 0, sizeof(tmd_today));
+	tmd_today.tm_year = year - 1900;
+	tmd_today.tm_mon = 0;
+	tmd_today.tm_mday = 0;		/* 31 December */
+	tmd_today.tm_hour = 23;
+	tmd_today.tm_min = 59;
+	tmd_today.tm_sec = 59;
+	memset(&tmd_tomorrow, 0, sizeof(tmd_tomorrow));
+	tmd_tomorrow.tm_year = year - 1900;
+	tmd_tomorrow.tm_mon = 0;
+	tmd_tomorrow.tm_mday = 1;	/* 1 January */
+	tmd_tomorrow.tm_hour = 0;
+	tmd_tomorrow.tm_min = 0;
+	tmd_tomorrow.tm_sec = 1;
+
+	tt = mktime(&tmd_today);
+	gmtime_r(&tt, &GMT);
+	yeardays = 0;
+	for (cnt = EPOCH; cnt < GMT.tm_year; ++cnt)
+		yeardays += isleap(1900 + cnt) ? 366 : 365;
+	days_today = (GMT.tm_yday + 1) + ((GMT.tm_hour +
+	    (GMT.tm_min / 60.0) + (GMT.tm_sec / 3600.0)) / 24.0);
+	days_today += yeardays;
+
+	tt = mktime(&tmd_tomorrow);
+	gmtime_r(&tt, &GMT);
+	yeardays = 0;
+	for (cnt = EPOCH; cnt < GMT.tm_year; ++cnt)
+		yeardays += isleap(1900 + cnt) ? 366 : 365;
+	days_tomorrow = (GMT.tm_yday + 1) + ((GMT.tm_hour +
+	    (GMT.tm_min / 60.0) + (GMT.tm_sec / 3600.0)) / 24.0);
+	days_tomorrow += yeardays;
+
+	today = potm(days_today);		/* 30 December 23:59:59 */
+	tomorrow = potm(days_tomorrow);		/* 31 December 00:00:01 */
+	olddir = today > tomorrow ? -1 : +1;
+
+	yeardays = isleap(year) ? 366 : 365;	/* reuse */
+	for (d = 0; d <= yeardays; d++) {
+		today = potm(days_today);
+		tomorrow = potm(days_tomorrow);
+		newdir = today > tomorrow ? -1 : +1;
+		if (olddir == -1 && newdir == +1) {
+			*pnms = d;
+			pnms++;
+		}
+		if (olddir == +1 && newdir == -1) {
+			*pfms = d;
+			pfms++;
+		}
+		olddir = newdir;
+		days_today++;
+		days_tomorrow++;
+	}
+	*pfms = 0;
+	*pnms = 0;
+}
+
+/*
+ * potm --
+ *	return phase of the moon
+ */
+static double
+potm(double days)
+{
+	double N, Msol, Ec, LambdaSol, l, Mm, Ev, Ac, A3, Mmprime;
+	double A4, lprime, V, ldprime, D, Nm;
+
+	N = 360 * days / 365.2422;				/* sec 42 #3 */
+	adj360(&N);
+	Msol = N + EPSILONg - RHOg;				/* sec 42 #4 */
+	adj360(&Msol);
+	Ec = 360 / PI * ECCEN * sin(dtor(Msol));		/* sec 42 #5 */
+	LambdaSol = N + Ec + EPSILONg;				/* sec 42 #6 */
+	adj360(&LambdaSol);
+	l = 13.1763966 * days + lzero;				/* sec 61 #4 */
+	adj360(&l);
+	Mm = l - (0.1114041 * days) - Pzero;			/* sec 61 #5 */
+	adj360(&Mm);
+	Nm = Nzero - (0.0529539 * days);			/* sec 61 #6 */
+	adj360(&Nm);
+	Ev = 1.2739 * sin(dtor(2*(l - LambdaSol) - Mm));	/* sec 61 #7 */
+	Ac = 0.1858 * sin(dtor(Msol));				/* sec 61 #8 */
+	A3 = 0.37 * sin(dtor(Msol));
+	Mmprime = Mm + Ev - Ac - A3;				/* sec 61 #9 */
+	Ec = 6.2886 * sin(dtor(Mmprime));			/* sec 61 #10 */
+	A4 = 0.214 * sin(dtor(2 * Mmprime));			/* sec 61 #11 */
+	lprime = l + Ev + Ec - Ac + A4;				/* sec 61 #12 */
+	V = 0.6583 * sin(dtor(2 * (lprime - LambdaSol)));	/* sec 61 #13 */
+	ldprime = lprime + V;					/* sec 61 #14 */
+	D = ldprime - LambdaSol;				/* sec 63 #2 */
+	return(50 * (1 - cos(dtor(D))));			/* sec 63 #3 */
+}
+
+/*
+ * dtor --
+ *	convert degrees to radians
+ */
+static double
+dtor(double deg)
+{
+
+	return(deg * PI / 180);
+}
+
+/*
+ * adj360 --
+ *	adjust value so 0 <= deg <= 360
+ */
+static void
+adj360(double *deg)
+{
+
+	for (;;)
+		if (*deg < 0)
+			*deg += 360;
+		else if (*deg > 360)
+			*deg -= 360;
+		else
+			break;
+}

From owner-svn-src-user@FreeBSD.ORG  Thu Jan  7 09:54:31 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 915AE1065670;
	Thu,  7 Jan 2010 09:54:31 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 7FAF68FC12;
	Thu,  7 Jan 2010 09:54:31 +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 o079sVdE013484;
	Thu, 7 Jan 2010 09:54:31 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o079sVvP013482;
	Thu, 7 Jan 2010 09:54:31 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001070954.o079sVvP013482@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Thu, 7 Jan 2010 09:54:31 +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: r201728 - user/luigi/ipfw3-head/sys/netinet/ipfw
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: Thu, 07 Jan 2010 09:54:31 -0000

Author: luigi
Date: Thu Jan  7 09:54:31 2010
New Revision: 201728
URL: http://svn.freebsd.org/changeset/base/201728

Log:
  add some temporary documentation

Added:
  user/luigi/ipfw3-head/sys/netinet/ipfw/dummynet.txt   (contents, props changed)

Added: user/luigi/ipfw3-head/sys/netinet/ipfw/dummynet.txt
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/dummynet.txt	Thu Jan  7 09:54:31 2010	(r201728)
@@ -0,0 +1,756 @@
+Notes on the internal structure of dummynet (2010 version)
+by Riccardo Panicucci and Luigi Rizzo
+
+*********
+* INDEX *
+*********
+Implementation of new dummynet
+    Internal structure
+    Files
+Packet arrival
+    The reconfiguration routine
+dummynet_task()
+Configuration
+    Add a pipe
+    Add a scheduler
+    Add a flowset
+Listing object
+Delete of object
+    Delete a pipe
+    Delete a flowset
+    Delete a scheduler
+Compatibility with FreeBSD7.2 and FreeBSD 8 ipfw binary
+    ip_dummynet_glue.c
+    ip_fw_glue.c
+How to configure dummynet
+How to implement a new scheduler
+
+
+
+
+Dummynet is a traffic shaper and network emulator. Packets are
+selected by an external filter such as ipfw, and passed to the emulator
+with a tag such as "pipe 10" or "queue 5" which tells what to
+do with the packet. As an example
+
+	ipfw add queue 5 icmp from 10.0.0.2 to all
+
+All packets with the same tag belong to a "flowset", or a set
+of flows which can be further partitioned according to a mask.
+Flowsets are then passed to a scheduler for processing. The
+association of flowsets and schedulers is configurable e.g.
+
+	ipfw queue 5 config sched 10 weight 3 flow_mask xxxx
+	ipfw queue 8 config sched 10 weight 1 ...
+	ipfw queue 3 config sched 20 weight 1 ...
+
+"sched 10" represents one or more scheduler instances,
+selected through a mask on the 5-tuple itself.
+
+	ipfw sched 20 config sched_mask yyy ...
+
+There are in fact two masks applied to each packet:
++ the "sched_mask" sends packets arriving to a scheduler_id to
+  one of many instances.
++ the "flow_mask" together with the flowset_id is used to
+  collect packets into independent flows on each scheduler.
+
+As an example, we can have
+	ipfw queue 5 config sched 10 flow_mask src-ip 0x000000ff
+	ipfw sched 10 config sched_mask src-ip 0xffffff00
+
+means that sched 10 will have one instance per /24 source subnet,
+and within that, each individual source will be a flow.
+	
+Internal structure
+-----------------
+Dummynet-related data is split into five main strucs:
+
+- struct new_pipe: contains data about the physical link such
+  as bandwith, delay, fields to simulate a delay profile and so on.
+
+- struct new_fs: describes a flowset. It contains template values for the
+  specified flowset, and a pointer (alg_fs) to an opaque struct that
+  can contain per-flowset scheduler-specific parameters, such as
+  weight, priorities, slot sizes and the like.
+  It also contains a flow_mask to allow to create more queues
+  depending of the flow id of the packet. All queues are stored into the
+  scheduler instance.
+
+- struct new_sch: it acts as a template for the scheduler used. It contains
+  enqueue and dequeue packet functions, a configure function for
+  possible global parameters, and two functions to create and destroy
+  the scheduler instance.
+  A scheduler can have more scheduler instance: a field sched_mask is
+  used to know how many instance could exist for this scheduler.
+  This struct also contains an hash table of queues pointers
+
+- struct new_sch_inst: it is the struct that represents the instance of the
+  scheduler. It has a pointer to the template, and some general parameter
+  and status variable relative to the single instance.
+  It also contains all queues associated with this instance and the delay line,
+  which is a list of packets that will be sent after a certain amount of time.
+
+- struct new_queue: it contains all data belonging to a single queue, as
+  total bytes, number of packets dropped, list of packet...
+  It can have some extra data about the scheduling algorithm.
+  XXX this is one instance of a flowset ?
+
+
+                                +----------------+
+      +--------+   ptr_sched    |                |         +----------+
+      | new_fs |--------------->|     new_sch    |-------->| new_pipe |
+      `--------'                |                |         +----------+
+          |                     +----------------+
+          |                             |       ^
+          |                             V        \___
+          |                      +------------+      |
+          |                      | hash table |      |
+          |                      |    (m1)    |      |
+          |                      +------------+      |
+          |                         |  ..... \_      |
+   -----------+     ...             v          \     |
+  | new_queue |<-----|          --------------  |    |
+  +-----------+      |         |              | |    |
+       ....          |         | new_sch_inst | |    |
+   -----------+      |         |              | |    |
+  | new_queue |<-----|          --------------  |    |
+  +-----------+      |                          v    |
+      |       .--------------.       --------------  |
+      |       |  hash table  |      |              | |
+      |       |     (m2) +   |<-----| new_sch_inst |_/
+      |       | new_sch_inst |      |              |
+      |       `--------------'       --------------
+      |                                 ^
+      |                                 |
+      `---------------------------------'
+
+Note that the hash table m2 is not mandatory, a scheduler instance
+can use its own struct to store its queues
+
+Three global data structures (hash tables) contain all
+pipes, schedulers and flowsets.
+- pipehash[x]:      contains all pipes in the system
+- schedulerhash[x]: contains all scheduler templates in the system
+- flowsethash[x]:   contains all flowset linked with a scheduler (or pipe).
+Additionally, a list that contains all unlinked flowset:
+- unlinkedflowset:  contains flowset that are not linked with any scheduler
+flowset are put in this list when they refer to a non
+existing scheduler or pipe.
+
+Scheduler instances and the delay lines associated with pipes
+need to be woken up at certain times. Because we have many
+such objects, we keep them in a priority heap (system_heap).
+
+Almost all objects in this implementation are preceded
+by a structure (struct dn_id) which makes it easier to
+identify it.
+
+
+Files
+-----
+New dummynet is split in several files.
+Two headers, a file to implement the userland part and some files for the
+kernel side are provided.
+- ip_dummynet_s.h is the minimal header that is used to implement
+  a scheduler
+- ip_dummynet.h is the main header, that includes the ip_dummynet_s.h and is
+  use by both kernel and user space.
+- dummynet.c is the file used to implement the user side of dummynet.
+  It contains the function to parsing command line, and functions to
+  show the output of dummynet objects.
+- ip_dummynet.c is the main files for the kernel side of dummynet. It contains
+  main functions for processing packets, some functions exported to help
+  writing new scheduler, and the handler for the various dummynet socket
+  options.
+- ip_dummynet_config.c cointains functions to create and delete objects.
+- ip_dummynet_get.c contains functions to prepare the buffer to pass to
+  userland to show object info.
+Moreover, there are two new file (ip_dummynet_glue.c and ip_fw_glue.c) that
+are used to allow compatibility with the "ipfw" binary from FreeBSd 7.2 and
+FreeBSD 8.
+
+
+Packet arrival
+==============
+A packet enter in dummynet process throught the function dummynet_io().
+When a packet arrives, first it is checked the flow set number and the flowset
+is searched in the flowset list and if it isn't found the packet is dropped.
+Dummynet uses a generation number to check if pointers are valid. The
+flowset has a pointer to the scheduler that could be deleted, so in the
+flowset struct there is a value that contain a number. If this number doesn't
+match the generation number, a reconfigure routine is started to check if
+pointers are valid. The generation number is incremented when a change in
+the internal struct occurs (for example when a new object is inserted or
+deleted).
+
+At this point, the pointer to the scheduler is valid, and the scheduler
+instance is searched from all scheduler instance of the scheduler, depending
+of the sched_mask field. If a scheduler instance isn't found, a new one is
+created now.
+
+Now the enqueue() function of the scheduler is called and if the scheduler
+instance was idle the dequeue() function is called now, else it will
+be called by system later. After the dequeue(), the packet returned is moved
+in the delay line and send after a delay depending on link parameters.
+See ip_dummynet.c dummynet_io() function for more details
+
+The reconfiguretion routine
+---------------------------
+The reconfigure routine is called by the system when the flowset ptr_sched_val
+number differs from the generation number. This means that a new object is
+inserted in the system or a object was deleted and no new packet belonging to
+this flowset are yet arrived.
+
+The reconfigure routine first check if the scheduler pointed by the flowset is
+the same that the scheduler located by the number. If so, and if the type are
+the same, it means that the scheduler wasn't changed. Now is check if the pipe
+exist, and eventually the pointer in the scheduler is updated. If scheduler
+and pipe exists, the packet can be enqueued.
+
+If the scheduler type differs from flowset type, it means that the scheduler
+has changed type so the flowset must be deleted and recreated. The pointer
+are update and the packet can be enqueued.
+
+If the scheduler no longer exists, the flowset is remove from flowset list
+and inserted in the unlinked flowset list, so that new packet are discarded
+early.
+
+If scheduler or pipe don't exist,packet shoubl be dropped and the function
+return 1 so that dummynet_io() can drop the packet.
+
+dummynet_task()
+===============
+The dummynet_task() is the the main dummynet processing function and is
+called every tick. This function first calculate the new current time, then
+it checks if it is the time to wake up object from the system_heap comparing
+the current time and the key of the heap. Two types of object (really the
+heap contains pointer to objects) are in the
+system_heap:
+
+- scheduler instance: if a scheduler instance is waked up, the dequeue()
+  function is called until it has credit. If the dequeue() returns packets,
+  the scheduler instance is inserted in the heap with a new key depending of
+  the data that will be send out. If the scheduler instance remains with
+  some credit, it means that is hasn't other packet to send and so the
+  instance is no longer inserted in the heap.
+
+  If the scheduler instance extracted from the heap has the DELETE flag set,
+  the dequeue() is not called and the instance is destroyed now.
+
+- delay line: when extracting a delay line, the function transmit_event() is
+  called to send out packet from delay line.
+
+  If the scheduler instance associated with this delay line doesn't exists,
+  the delay line will be delete now.
+
+Configuration
+=============
+To create a pipe, queue or scheduler, the user should type commands like:
+"ipfw pipe x config"
+"ipfw queue y config pipe x"
+"ipfw pipe x config sched <type>"
+
+The userland side of dummynet will prepare a buffer contains data to pass to
+kernel side.
+The buffer contains all struct needed to configure an object. In more detail,
+to configure a pipe all three structs (new_pipe, new_sch, new_fs) are needed,
+plus the delay profile struct if the pipe has a delay profile.
+
+If configuring a scheduler only the struct new_sch is wrote in the buffer,
+while if configuring a flowset only the new_fs struct is wrote.
+
+The first struct in the buffer contains the type of command request, that is
+if it is configuring a pipe, a queue, or a scheduler. Then there are structs
+need to configure the object, and finally there is the struct that mark
+the end of the buffer.
+
+To support the insertion of pipe and queue using the old syntax, when adding
+a pipe it's necessary to create a FIFO flowset and a FIFO scheduler, which
+have a number x + DN_PIPEOFFSET.
+
+Add a pipe
+----------
+A pipe is only a template for a link.
+If the pipe already exists, parameters are updated. If a delay profile exists
+it is deleted and a new one is created.
+If the pipe doesn't exist a new one is created. After the creation, the
+flowset unlinked list is scanned to see if there are some flowset that would
+be linked with this pipe. If so, these flowset will be of wf2q+ type (for
+compatibility) and a new wf2q+ scheduler is created now.
+
+Add a scheduler
+---------------
+If the scheduler already exists, and the type and the mask are the same, the
+scheduler is simply reconfigured calling the config_scheduler() scheduler
+function with the RECONFIGURE flag active.
+If the type or the mask differ, it is necessary to delete the old scheduler
+and create a new one.
+If the scheduler doesn't exists, a new one is created. If the scheduler has
+a mask, the hash table is created to store pointers to scheduler instances.
+When a new scheduler is created, it is necessary to scan the unlinked
+flowset list to search eventually flowset that would be linked with this
+scheduler number. If some are found, flowsets became of the type of this
+scheduler and they are configured properly.
+
+Add a flowset
+-------------
+Flowset pointers are store in the system in two list. The unlinked flowset list
+contains all flowset that aren't linked with a scheduler, the flowset list
+contains flowset linked to a scheduler, and so they have a type.
+When adding a new flowset, first it is checked if the flowset exists (that is,
+it is in the flowset list) and if it doesn't exists a new flowset is created
+and added to unlinked flowset list if the scheduler which the flowset would be
+linked doesn't exists, or added in the flowset list and configured properly if
+the scheduler exists. If the flowset (before to be created) was in the
+unlinked flowset list, it is removed and deleted, and then recreated.
+If the flowset exists, to allow reconfiguration of this flowset, the
+scheduler number and types must match with the one in memory. If this isn't
+so, the flowset is deleted and a new one will be created. Really, the flowset
+it isn't deleted now, but it is removed from flowset list and it will be
+deleted later because there could be some queues that are using it.
+
+Listing of object
+=================
+The user can request a list of object present in dummynet through the command
+"ipfw [-v] pipe|queue [x] list|show"
+The kernel side of dummynet send a buffer to user side that contains all
+pipe, all scheduler, all flowset, plus all scheduler instances and all queues.
+The dummynet user land will format the output and show only the relevant
+information.
+The buffer sent start with all pipe from the system. The entire struct new_pipe
+is passed, except the delay_profile struct that is useless in user space.
+After pipes, all flowset are wrote in the buffer. The struct contains
+scheduler flowset specific data is linked with the flowset writing the
+'obj' id of the extension into the 'alg_fs' pointer.
+Then schedulers are wrote. If a scheduler has one or more scheduler instance,
+these are linked to the parent scheduler writing the id of the parent in the
+'ptr_sched' pointer. If a scheduler instance has queues, there are wrote in
+the buffer and linked thorugh the 'obj' and 'sched_inst' pointer.
+Finally, flowsets in the unlinked flowset list  are write in the buffer, and
+then a struct gen in saved in the buffer to mark the last struct in the buffer.
+
+
+Delete of object
+================
+An object is usually removed by user through a command like
+"ipfw pipe|queue x delete". XXX sched?
+ipfw pass to the kernel a struct gen that contains the type and the number
+of the object to remove
+
+Delete of pipe x
+----------------
+A pipe can be deleted by the user throught the command 'ipfw pipe x delete'.
+To delete a pipe, the pipe is removed from the pipe list, and then deleted.
+Also the scheduler associated with this pipe should be deleted.
+For compatibility with old dummynet syntax, the associated FIFO scheduler and
+FIFO flowset must be deleted.
+
+Delete of flowset x
+-------------------
+To remove a flowset, we must be sure that is no loger referenced by any object.
+If the flowset to remove is in the unlinked flowset list, there is not any
+issue, the flowset can be safely removed calling a free() (the flowset
+extension is not yet created if the flowset is in this list).
+If the flowset is in the flowset list, first we remove from it so new packet
+are discarded when arrive. Next, the flowset is marked as delete.
+Now we must check if some queue is using this flowset.
+To do this, a counter (active_f) is provided. This counter indicate how many
+queues exist using this flowset.
+The active_f counter is automatically incremented when a queue is created
+and decremented when a queue is deleted.
+If the counter is 0, the flowset can be safely deleted, and the delete_alg_fs()
+scheduler function is called before deallocate memory.
+If the counter is not 0, the flowset remain in memory until the counter become
+zero. When a queue is delete (by dn_delete_queue() function) it is checked if
+the linked flowset is deleting and if so the counter is decrementing. If the
+counter reaches 0, the flowset is deleted.
+The deletion of a queue can be done only by the scheduler, or when the scheduler
+is destroyed.
+
+Delete of scheduler x
+---------------------
+To delete a scheduler we must be sure that any scheduler instance of this type
+are in the system_heap. To do so, a counter (inst_counter) is provided.
+This counter is managed by the system: it is incremented every time it is
+inserted in the system_heap, and decremented every time it is extracted from it.
+To delete the scheduler, first we remove it from the scheduler list, so new
+packet are discarded when they arrive, and mark the scheduler as deleting.
+
+If the counter is 0, we can remove the scheduler safely calling the
+really_deletescheduler() function. This function will scan all scheduler
+instances and call the delete_scheduler_instance() function that will delete
+the instance. When all instance are deleted, the scheduler template is
+deleted calling the delete_scheduler_template(). If the delay line associate
+with the scheduler is empty, it is deleted now, else it will be deleted when
+it will became empy.
+If the counter was not 0, we wait for it. Every time the dummynet_task()
+function extract a scheduler from the system_heap, the counter is decremented.
+If the scheduler has the delete flag enabled the dequeue() is not called and
+delete_scheduler_instance() is called to delete the instance.
+Obviously this scheduler instance is no loger inserted in the system_heap.
+If the counter reaches 0, the delete_scheduler_template() function is called
+all memory is released.
+NOTE: Flowsets that belong to this scheduler are not deleted, so if a new
+      scheduler with the same number is inserted will use these flowsets.
+      To do so, the best approach would be insert these flowset in the
+      unlinked flowset list, but doing this now will be very expensive.
+      So flowsets will remain in memory and linked with a scheduler that no
+      longer exists until a packet belonging to this flowset arrives. When
+      this packet arrives, the reconfigure() function is called because the
+      generation number mismatch with one contains in the flowset and so
+      the flowset will be moved into the flowset unlinked list, or will be
+      linked with the new scheduler if a new one was created.
+
+
+COMPATIBILITY WITH FREEBSD 7.2 AND FREEBSD 8 'IPFW' BINARY
+==========================================================
+Dummynet is not compatible with old ipfw binary because internal structs are
+changed. Moreover, the old ipfw binary is not compatible with new kernels
+because the struct that represents a firewall rule has changed. So, if a user
+install a new kernel on a FreeBSD 7.2, the ipfw (and possibly many other
+commands) will not work.
+New dummynet uses a new socket option: IP_DUMMYNET3, used for both set and get.
+The old option can be used to allow compatibility with the 'ipfw' binary of
+older version (tested with 7.2 and 8.0) of FreeBSD.
+Two file are provided for this purpose:
+- ip_dummynet_glue.c translates old dummynet requests to the new ones,
+- ip_fw_glue.c converts the rule format between 7.2 and 8 versions.
+Let see in detail these two files.
+
+IP_DUMMYNET_GLUE.C
+------------------
+The internal structs of new dummynet are very different from the original.
+Because of there are some difference from between dummynet in FreeBSD 7.2 and
+dummynet in FreeBSD 8 (the FreeBSD 8 version includes support to pipe delay
+profile and burst option), I have to include both header files. I copied
+the revision 191715 (for version 7.2) and the revision 196045 (for version 8)
+and I appended a number to each struct to mark them.
+
+The main function of this file is ip_dummynet_compat() that is called by
+ip_dn_ctl() when it receive a request of old socket option.
+
+A global variabile ('is7') store the version of 'ipfw' that FreeBSD is using.
+This variable is set every time a request of configuration is done, because
+with this request we receive a buffer of which size depending of ipfw version.
+Because of in general the first action is a configuration, this variable is
+usually set accordly. If the first action is a request of listing of pipes
+or queues, the system cannot know the version of ipfw, and we suppose that
+version 7.2 is used. If version is wrong, the output can be senseless, but
+the application should not crash.
+
+There are four request for old dummynet:
+- IP_DUMMYNET_FLUSH: the flush options have no parameter, so simply the
+  dummynet_flush() function is called;
+- IP_DUMMYNET_DEL: the delete option need to be translate.
+  It is only necessary to extract the number and the type of the object
+  (pipe or queue) to delete from the buffer received and build a new struct
+  gen contains the right parameters, then call the delete_object() function;
+- IP_DUMMYNET_CONFIGURE: the configure command receive a buffer depending of
+  the ipfw version. After the properly extraction of all data, that depends
+  by the ipfw version used, new structures are filled and then the dummynet
+  config_pipe() function is properly called. Note that the 7.2 version does
+  not support some parameter as burst or delay profile.
+- IP_DUMMYNET_GET: The get command should send to the ipfw the correct buffer
+  depending of its version. There are two function that build the
+  corrected buffer, ip_dummynet_get7() and ip_dummynet_get8(). These
+  functions reproduce the buffer exactly as 'ipfw' expect. The only difference
+  is that the weight parameter for a queue is no loger sent by dummynet and so
+  it is set to 0.
+  Moreover, because of the internal structure has changed, the bucket size
+  of a queue could not be correct, because now all flowset share the hash
+  table.
+  If the version of ipfw is wrong, the output could be senseless or truncated,
+  but the application should not crash.
+
+IP_FW_GLUE.C
+------------
+The ipfw binary also is used to add rules to FreeBSD firewall. Because of the
+struct ip_fw is changed from FreeBsd 7.2 to FreeBSD 8, it is necessary
+to write some glue code to allow use ipfw from FreeBSD 7.2 with the kernel
+provided with FreeBSD 8.
+This file contains two functions to convert a rule from FreeBSD 7.2 format to
+FreeBSD 8 format, and viceversa.
+The conversion should be done when a rule passes from userspace to kernel space
+and viceversa.
+I have to modify the ip_fw2.c file to manage these two case, and added a
+variable (is7) to store the ipfw version used, using an approach like the
+previous file:
+- when a new rule is added (option IP_FW_ADD) the is7 variable is set if the
+  size of the rule received corrispond to FreeBSD 7.2 ipfw version. If so, the
+  rule is converted to version 8 calling the function convert_rule_to_8().
+  Moreover, after the insertion of the rule, the rule is now reconverted to
+  version 7 because the ipfw binary will print it.
+- when the user request a list of rules (option IP_FW_GET) the is7 variable
+  should be set correctly because we suppose that a configure command was done,
+  else we suppose that the FreeBSD version is 8. The function ipfw_getrules()
+  in ip_fw2.c file return all rules, eventually converted to version 7 (if
+  the is7 is set) to the ipfw binary.
+The conversion of a rule is quite simple. The only difference between the
+two structures (struct ip_fw) is that in the new there is a new field
+(uint32_t id). So, I copy the entire rule in a buffer and the copy the rule in
+the right position in the new (or old) struct. The size of commands are not
+changed, and the copy is done into a cicle.
+
+How to configure dummynet
+=========================
+It is possible to configure dummynet through two main commands:
+'ipfw pipe' and 'ipfw queue'.
+To allow compatibility with old version, it is possible configure dummynet
+using the old command syntax. Doing so, obviously, it is only possible to
+configure a FIFO scheduler or a wf2q+ scheduler.
+A new command, 'ipfw pipe x config sched <type>' is supported to add a new
+scheduler to the system.
+
+- ipfw pipe x config ...
+  create a new pipe with the link parameters
+  create a new scheduler fifo (x + offset)
+  create a new flowset fifo (x + offset)
+  the mask is eventually stored in the FIFO scheduler
+
+- ipfw queue y config pipe x ...
+  create a new flowset y linked to sched x.
+    The type of flowset depends by the specified scheduler.
+    If the scheduler does not exist, this flowset is inserted in a special
+    list and will be not active.
+    If pipe x exists and sched does not exist, a new wf2q+ scheduler is
+    created and the flowset will be linked to this new scheduler (this is
+    done for compatibility with old syntax).
+
+- ipfw pipe x config sched <type> ...
+  create a new scheduler x of type <type>.
+  Search into the flowset unlinked list if there are some flowset that
+  should be linked with this new scheduler.
+
+- ipfw pipe x delete
+  delete the pipe x
+  delete the scheduler fifo (x + offset)
+  delete the scheduler x
+  delete the flowset fifo (x + offset)
+
+- ipfw queue x delete
+  delete the flowset x
+
+- ipfw sched x delete ///XXX
+  delete the scheduler x
+
+Follow now some examples to how configure dummynet:
+- Ex1:
+  ipfw pipe 10 config bw 1M delay 15 // create a pipe with band and delay
+                                        A FIFO flowset and scheduler is
+                                        also created
+  ipfw queue 5 config pipe 10 weight 56 // create a flowset. This flowset
+                                           will be of wf2q+ because a pipe 10
+                                           exists. Moreover, the wf2q+
+                                           scheduler is created now.
+- Ex2:
+  ipfw queue 5 config pipe 10 weight 56 // Create a flowset. Scheduler 10
+                                           does not exist, so this flowset
+                                           is inserted in the unlinked
+                                           flowset list.
+  ipfw pipe 10 config bw... // Create a pipe, a FIFO flowset and scheduler.
+                               Because of a flowset with 'pipe 10' exists,
+                               a wf2q+ scheduler is created now and that
+                               flowset is linked with this sceduler.
+
+- Ex3:
+  ipfw pipe 10 config bw...    // Create a pipe, a FIFO flowset and scheduler.
+  ipfw pipe 10 config sched rr // Create a scheduler of type RR, linked to
+                                  pipe 10
+  ipfw queue 5 config pipe 10 weight 56 // Create a flowset 5. This flowset
+                                           will belong to scheduler 10 and
+                                           it is of type RR
+
+- Ex4:
+  ipfw pipe 10 config sched rr // Create a scheduler of type RR, linked to
+                                  pipe 10 (not exist yet)
+  ipfw pipe 10 config bw... // Create a pipe, a FIFO flowset and scheduler.
+  ipfw queue 5 config pipe 10 weight 56 // Create a flowset 5.This flowset
+                                           will belong to scheduler 10 and
+                                           it is of type RR
+  ipfw pipe 10 config sched wf2q+ // Modify the type of scheduler 10. It
+                                     becomes a wf2q+ scheduler.
+                                     When a new packet of flowset 5 arrives,
+                                     the flowset 5 becomes to wf2q+ type.
+
+How to implement a new scheduler
+================================
+In dummynet, a scheduler algorithm is represented by two main structs, some
+functions and other minor structs.
+- A struct new_sch_xyz (where xyz is the 'type' of scheduler algorithm
+  implemented) contains data relative to scheduler, as global parameter that
+  are common to all instances of the scheduler
+- A struct new_sch_inst_xyz contains data relative to a single scheduler
+  instance, as local status variable depending for example by flows that
+  are linked with the scheduler, and so on.
+To add a scheduler to dummynet, the user should type a command like:
+'ipfw pipe x config sched <type> [mask ... ...]'
+This command creates a new struct new_sch_xyz of type <type>, and
+store the optional parameter in that struct.
+
+The parameter mask determines how many scheduler instance of this
+scheduler may exist. For example, it is possible to divide traffic
+depending on the source port (or destination, or ip address...),
+so that every scheduler instance act as an independent scheduler.
+If the mask is not set, all traffic goes to the same instance.
+
+When a packet arrives to a scheduler, the system search the corrected
+scheduler instance, and if it does not exist it is created now (the
+struct new_sch_inst_xyz is allocated by the system, and the scheduler
+fills the field correctly). It is a task of the scheduler to create
+the struct that contains all queues for a scheduler instance.
+Dummynet provides some function to create an hash table to store
+queues, but the schedule algorithm can choice the own struct.
+
+To link a flow to a scheduler, the user should type a command like:
+'ipfw queue z config pipe x [mask... ...]'
+
+This command creates a new 'new_fs' struct that will be inserted
+in the system.  If the scheduler x exists, this flowset will be
+linked to that scheduler and the flowset type become the same as
+the scheduler type. At this point, the function create_alg_fs_xyz()
+is called to allow store eventually parameter for the flowset that
+depend by scheduler (for example the 'weight' parameter for a wf2q+
+scheduler, or some priority...). A parameter mask can be used for
+a flowset. If the mask parameter is set, the scheduler instance can
+separate packet according to its flow id (src and dst ip, ports...)
+and assign it to a separate queue. This is done by the scheduler,
+so it can ignore the mask if it wants.
+
+See now the two main structs:
+struct new_sch_xyz {
+    struct gen g; /* important the name g */
+    /* global params */
+};
+struct new_sch_inst_xyz {
+    struct gen g; /* important the name g */
+    /* params of the instance */
+};
+It is important to embed the struct gen as first parameter. The struct gen
+contains some values that the scheduler instance must fill (the 'type' of
+scheduler, the 'len' of the struct...)
+The function create_scheduler_xyz() should be implemented to initialize global
+parameters in the first struct, and if memory allocation is done it is
+mandatory to implement the delete_scheduler_template() function to free that
+memory.
+The function create_scheduler_instance_xyz() must be implemented even if the
+scheduler instance does not use extra parameters. In this function the struct
+gen fields must be filled with corrected infos. The
+delete_scheduler_instance_xyz() function must bu implemented if the instance
+has allocated some memory in the previous function.
+
+To store data belonging to a flowset the follow struct is used:
+struct alg_fs_xyz {
+    struct gen g;
+    /* fill correctly the gen struct
+     g.subtype = DN_XYZ;
+     g.len = sizeof(struct alg_fs_xyz)
+     ...
+     */
+    /* params for the flow */
+};
+The create_alg_fs_xyz() function is mandatory, because it must fill the struct
+gen, but the delete_alg_fs_xyz() is mandatory only if the previous function
+has allocated some memory.
+
+A struct new_queue contains packets belonging to a queue and some statistical
+data. The scheduler could have to store data in this struct, so it must define
+a new_queue_xyz struct:
+struct new_queue_xyz {
+    struct new_queue q;
+    /* parameter for a queue */
+}
+
+All structures are allocated by the system. To do so, the scheduler must
+set the size of its structs in the scheduler descriptor:
+scheduler_size:     sizeof(new_sch_xyz)
+scheduler_i_size:   sizeof(new_sch_inst_xyz)
+flowset_size:       sizeof(alg_fs_xyz)
+queue_size:         sizeof(new_queue_xyz);
+The scheduler_size could be 0, but other struct must have at least a struct gen.
+
+
+After the definition of structs, it is necessary to implement the
+scheduler functions.
+
+- int (*config_scheduler)(char *command, void *sch, int reconfigure);
+    Configure a scheduler, or reconfigure if 'reconfigure' == 1.
+    This function performs additional allocation and initialization of global
+    parameter for this scheduler.
+    If memory is allocated here, the delete_scheduler_template() function
+    should be implemented to remove this memory.
+- int (*delete_scheduler_template)(void* sch);
+    Delete a scheduler template. This function is mandatory if the scheduler
+    uses extra data respect the struct new_sch.
+- int (*create_scheduler_instance)(void *s);
+    Create a new scheduler instance. The system allocate the necessary memory
+    and the schedulet can access it using the 's' pointer.
+    The scheduler instance stores all queues, and to do this can use the
+    hash table provided by the system.
+- int (*delete_scheduler_instance)(void *s);
+    Delete a scheduler instance. It is important to free memory allocated
+    by create_scheduler_instance() function. The memory allocated by system
+    is freed by the system itself. The struct contains all queue also has
+    to be deleted.
+- int (*enqueue)(void *s, struct gen *f, struct mbuf *m,
+                 struct ipfw_flow_id *id);
+    Called when a packet arrives. The packet 'm' belongs to the scheduler
+    instance 's', has a flowset 'f' and the flowid 'id' has already been
+    masked. The enqueue() must call dn_queue_packet(q, m) function to really
+    enqueue packet in the queue q. The queue 'q' is chosen by the scheduler
+    and if it does not exist should be created calling the dn_create_queue()
+    function. If the schedule want to drop the packet, it must call the
+    dn_drop_packet() function and then return 1.
+- struct mbuf * (*dequeue)(void *s);
+    Called when the timer expires (or when a packet arrives and the scheduler
+    instance is idle).
+    This function is called when at least a packet can be send out. The
+    scheduler choices the packet and returns it; if no packet are in the
+    schedulerinstance, the function must return NULL.
+    Before return a packet, it is important to call the function
+    dn_return_packet() to update some statistic of the queue and update the
+    queue counters.
+- int (*drain_queue)(void *s, int flag);
+    The system request to scheduler to delete all queues that is not using
+    to free memory. The flag parameter indicate if a queue must be deleted
+    even if it is active.
+
+- int (*create_alg_fs)(char *command, struct gen *g, int reconfigure);
+    It is called when a flowset is linked with a scheduler. This is done
+    when the scheduler is defined, so we can know the type of flowset.
+    The function initialize the flowset paramenter parsing the command
+    line. The parameter will be stored in the g struct that have the right
+    size allocated by the system. If the reconfigure flag is set, it means
+    that the flowset is reconfiguring
+- int (*delete_alg_fs)(struct gen *f);
+    It is called when a flowset is deleting. Must remove the memory allocate
+    by the create_alg_fs() function.
+
+- int (*create_queue_alg)(struct new_queue *q, struct gen *f);
+    Called when a queue is created. The function should link the queue
+    to the struct used by the scheduler instance to store all queues.
+- int (*delete_queue_alg)(struct new_queue *q);
+    Called when a queue is deleting. The function should remove extra data
+    and update the struct contains all queues in the scheduler instance.
+
+The struct scheduler represent the scheduler descriptor that is passed to
+dummynet when a scheduler module is loaded.
+This struct contains the type of scheduler, the lenght of all structs and
+all function pointers.
+If a function is not implemented should be initialize to NULL. Some functions
+are mandatory, other are mandatory if some memory should be freed.
+Mandatory functions:
+- create_scheduler_instance()
+- enqueue()
+- dequeue()
+- create_alg_fs()
+- drain_queue()
+Optional functions:
+- config_scheduler()
+- create_queue_alg()
+Mandatory functions if the corresponding create...() has allocated memory:
+- delete_scheduler_template()
+- delete_scheduler_instance()
+- delete_alg_fs()
+- delete_queue_alg()
+

From owner-svn-src-user@FreeBSD.ORG  Thu Jan  7 09:55:05 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 71F12106572F;
	Thu,  7 Jan 2010 09:55:00 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 2FBD58FC1F;
	Thu,  7 Jan 2010 09:55:00 +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 o079t0Iv013616;
	Thu, 7 Jan 2010 09:55:00 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o079t0uo013614;
	Thu, 7 Jan 2010 09:55:00 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001070955.o079t0uo013614@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Thu, 7 Jan 2010 09:55:00 +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: r201729 - user/luigi/ipfw3-head/sys/netinet/ipfw
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: Thu, 07 Jan 2010 09:55:05 -0000

Author: luigi
Date: Thu Jan  7 09:54:59 2010
New Revision: 201729
URL: http://svn.freebsd.org/changeset/base/201729

Log:
  sync with HEAD

Modified:
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_dynamic.c

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_dynamic.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_dynamic.c	Thu Jan  7 09:54:31 2010	(r201728)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_dynamic.c	Thu Jan  7 09:54:59 2010	(r201729)
@@ -1002,7 +1002,8 @@ ipfw_send_pkt(struct mbuf *replyto, stru
 		h->ip_hl = sizeof(*h) >> 2;
 		h->ip_tos = IPTOS_LOWDELAY;
 		h->ip_off = 0;
-		h->ip_len = len; // XXX was htons(len); 
+		/* ip_len must be in host format for ip_output */
+		h->ip_len = len;
 		h->ip_ttl = V_ip_defttl;
 		h->ip_sum = 0;
 		break;

From owner-svn-src-user@FreeBSD.ORG  Thu Jan  7 09:56:08 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 21579106568B;
	Thu,  7 Jan 2010 09:56:08 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id EBD798FC0A;
	Thu,  7 Jan 2010 09:56:07 +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 o079u7AA013904;
	Thu, 7 Jan 2010 09:56:07 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o079u75H013899;
	Thu, 7 Jan 2010 09:56:07 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001070956.o079u75H013899@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Thu, 7 Jan 2010 09:56:07 +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: r201730 - user/luigi/ipfw3-head/sys/netinet/ipfw
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: Thu, 07 Jan 2010 09:56:08 -0000

Author: luigi
Date: Thu Jan  7 09:56:07 2010
New Revision: 201730
URL: http://svn.freebsd.org/changeset/base/201730

Log:
  shuffle headers

Modified:
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_log.c
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_sockopt.c
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_table.c

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Thu Jan  7 09:54:59 2010	(r201729)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Thu Jan  7 09:56:07 2010	(r201730)
@@ -72,11 +72,11 @@ __FBSDID("$FreeBSD$");
 #include <net/netisr.h>
 #include <netinet/in.h>
 #include <netinet/ip.h>		/* ip_len, ip_off */
+#include <netinet/ip_var.h>	/* ip_output(), IP_FORWARDING */
 #include <netinet/ip_fw.h>
 #include <netinet/ipfw/ip_fw_private.h>
 #include <netinet/ipfw/dn_heap.h>
 #include <netinet/ip_dummynet.h>
-#include <netinet/ip_var.h>	/* ip_output(), IP_FORWARDING */
 
 #include <netinet/if_ether.h> /* various ether_* routines */
 

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_log.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_log.c	Thu Jan  7 09:54:59 2010	(r201729)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_log.c	Thu Jan  7 09:56:07 2010	(r201730)
@@ -58,6 +58,7 @@ __FBSDID("$FreeBSD$");
 #include <netinet/in.h>
 #include <netinet/ip.h>
 #include <netinet/ip_icmp.h>
+#include <netinet/ip_var.h>
 #include <netinet/ip_fw.h>
 #include <netinet/ipfw/ip_fw_private.h>
 #include <netinet/tcp_var.h>

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_sockopt.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_sockopt.c	Thu Jan  7 09:54:59 2010	(r201729)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_sockopt.c	Thu Jan  7 09:56:07 2010	(r201730)
@@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$");
 #include <net/vnet.h>
 
 #include <netinet/in.h>
+#include <netinet/ip_var.h>	/* hooks */
 #include <netinet/ip_fw.h>
 #include <netinet/ipfw/ip_fw_private.h>
 
@@ -676,7 +677,7 @@ check_ipfw_struct(struct ip_fw *rule, in
 				goto check_size;
 		case O_NETGRAPH:
 		case O_NGTEE:
-			if (!NG_IPFW_LOADED)
+			if (ng_ipfw_input_p == NULL)
 				return EINVAL;
 			else
 				goto check_size;

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_table.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_table.c	Thu Jan  7 09:54:59 2010	(r201729)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_table.c	Thu Jan  7 09:56:07 2010	(r201730)
@@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$");
 #include <net/vnet.h>
 
 #include <netinet/in.h>
+#include <netinet/ip_var.h>	/* struct ipfw_rule_ref */
 #include <netinet/ip_fw.h>
 #include <netinet/ipfw/ip_fw_private.h>
 

From owner-svn-src-user@FreeBSD.ORG  Thu Jan  7 10:06:10 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 2F9D81065692;
	Thu,  7 Jan 2010 10:06:10 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 1DFB18FC17;
	Thu,  7 Jan 2010 10:06:10 +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 o07A6ALZ016228;
	Thu, 7 Jan 2010 10:06:10 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o07A69hj016222;
	Thu, 7 Jan 2010 10:06:09 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001071006.o07A69hj016222@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Thu, 7 Jan 2010 10:06:09 +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: r201731 - in user/luigi/ipfw3-head/sys/netinet: . ipfw
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: Thu, 07 Jan 2010 10:06:10 -0000

Author: luigi
Date: Thu Jan  7 10:06:09 2010
New Revision: 201731
URL: http://svn.freebsd.org/changeset/base/201731

Log:
  snapshot to decouple ip_divert from ipfw

Modified:
  user/luigi/ipfw3-head/sys/netinet/ip_divert.c
  user/luigi/ipfw3-head/sys/netinet/ip_var.h
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_private.h
  user/luigi/ipfw3-head/sys/netinet/raw_ip.c

Modified: user/luigi/ipfw3-head/sys/netinet/ip_divert.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ip_divert.c	Thu Jan  7 09:56:07 2010	(r201730)
+++ user/luigi/ipfw3-head/sys/netinet/ip_divert.c	Thu Jan  7 10:06:09 2010	(r201731)
@@ -32,14 +32,10 @@ __FBSDID("$FreeBSD$");
 
 #if !defined(KLD_MODULE)
 #include "opt_inet.h"
-#include "opt_ipfw.h"
 #include "opt_sctp.h"
 #ifndef INET
 #error "IPDIVERT requires INET."
 #endif
-#ifndef IPFIREWALL
-#error "IPDIVERT requires IPFIREWALL"
-#endif
 #endif
 
 #include <sys/param.h>
@@ -55,10 +51,10 @@ __FBSDID("$FreeBSD$");
 #include <sys/socket.h>
 #include <sys/socketvar.h>
 #include <sys/sysctl.h>
+#include <net/vnet.h>
 
 #include <net/if.h>
 #include <net/netisr.h> 
-#include <net/vnet.h>
 
 #include <netinet/in.h>
 #include <netinet/in_pcb.h>
@@ -66,8 +62,6 @@ __FBSDID("$FreeBSD$");
 #include <netinet/in_var.h>
 #include <netinet/ip.h>
 #include <netinet/ip_var.h>
-#include <netinet/ip_fw.h>
-#include <netinet/ipfw/ip_fw_private.h>
 #ifdef SCTP
 #include <netinet/sctp_crc32.h>
 #endif
@@ -85,27 +79,29 @@ __FBSDID("$FreeBSD$");
 #define	DIVRCVQ		(65536 + 100)
 
 /*
- * Divert sockets work in conjunction with ipfw, see the divert(4)
- * manpage for features.
- * Internally, packets selected by ipfw in ip_input() or ip_output(),
- * and never diverted before, are passed to the input queue of the
- * divert socket with a given 'divert_port' number (as specified in
- * the matching ipfw rule), and they are tagged with a 16 bit cookie
- * (representing the rule number of the matching ipfw rule), which
- * is passed to process reading from the socket.
+ * Divert sockets work in conjunction with ipfw or other packet filters,
+ * see the divert(4) manpage for features.
+ * Packets are selected by the packet filter and tagged with an
+ * MTAG_IPFW_RULE tag carrying the 'divert port' number (as set by
+ * the packet filter) and information on the matching filter rule for
+ * subsequent reinjection. The divert_port is used to put the packet
+ * on the corresponding divert socket, while the rule number is passed
+ * up (at least partially) as the sin_port in the struct sockaddr.
  *
- * Packets written to the divert socket are again tagged with a cookie
- * (usually the same as above) and a destination address.
- * If the destination address is INADDR_ANY then the packet is
- * treated as outgoing and sent to ip_output(), otherwise it is
- * treated as incoming and sent to ip_input().
- * In both cases, the packet is tagged with the cookie.
+ * Packets written to the divert socket carry in sin_addr a
+ * destination address, and in sin_port the number of the filter rule
+ * after which to continue processing.
+ * If the destination address is INADDR_ANY, the packet is treated as
+ * as outgoing and sent to ip_output(); otherwise it is treated as
+ * incoming and sent to ip_input().
+ * Further, sin_zero carries some information on the interface,
+ * which can be used in the reinject -- see comments in the code.
  *
  * On reinjection, processing in ip_input() and ip_output()
  * will be exactly the same as for the original packet, except that
- * ipfw processing will start at the rule number after the one
- * written in the cookie (so, tagging a packet with a cookie of 0
- * will cause it to be effectively considered as a standard packet).
+ * packet filter processing will start at the rule number after the one
+ * written in the sin_port (ipfw does not allow a rule #0, so sin_port=0
+ * will apply the entire ruleset to the packet).
  */
 
 /* Internal variables. */

Modified: user/luigi/ipfw3-head/sys/netinet/ip_var.h
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ip_var.h	Thu Jan  7 09:56:07 2010	(r201730)
+++ user/luigi/ipfw3-head/sys/netinet/ip_var.h	Thu Jan  7 10:06:09 2010	(r201731)
@@ -249,7 +249,43 @@ VNET_DECLARE(struct pfil_head, inet_pfil
 
 void	in_delayed_cksum(struct mbuf *m);
 
-/* ipfw and dummynet hooks. Most are declared in raw_ip.c */
+/* Hooks for ipfw, dummynet, divert etc. Most are declared in raw_ip.c */
+/*
+ * Reference to an ipfw or packet filter rule that can be carried
+ * outside critical sections.
+ * A rule is identified by rulenum:rule_id which is ordered.
+ * In version chain_id the rule can be found in slot 'slot', so
+ * we don't need a lookup if chain_id == chain->id.
+ *
+ * On exit from the firewall this structure refers to the rule after
+ * the matching one (slot points to the new rule; rulenum:rule_id-1
+ * is the matching rule), and additional info (e.g. info often contains
+ * the insn argument or tablearg in the low 16 bits, in host format).
+ * On entry, the structure is valid if slot>0, and refers to the starting
+ * rules. 'info' contains the reason for reinject, e.g. divert port,
+ * divert direction, and so on.
+ */
+struct ipfw_rule_ref {
+	uint32_t	slot;		/* slot for matching rule	*/
+	uint32_t	rulenum;	/* matching rule number		*/
+	uint32_t	rule_id;	/* matching rule id		*/
+	uint32_t	chain_id;	/* ruleset id			*/
+	uint32_t	info;		/* see below			*/
+};
+
+enum {
+	IPFW_INFO_MASK	= 0x0000ffff,
+	IPFW_INFO_OUT	= 0x00000000,	/* outgoing, just for convenience */
+	IPFW_INFO_IN	= 0x80000000,	/* incoming, overloads dir */
+	IPFW_ONEPASS	= 0x40000000,	/* One-pass, do not reinject */
+	IPFW_IS_MASK	= 0x30000000,	/* which source ? */
+	IPFW_IS_DIVERT	= 0x20000000,
+	IPFW_IS_DUMMYNET =0x10000000,
+	IPFW_IS_PIPE	= 0x08000000,	/* pip1=1, queue = 0 */
+};
+#define MTAG_IPFW	1148380143	/* IPFW-tagged cookie */
+#define MTAG_IPFW_RULE	1262273568	/* rule reference */
+
 struct ip_fw_args;
 typedef int	(*ip_fw_chk_ptr_t)(struct ip_fw_args *args);
 typedef int	(*ip_fw_ctl_ptr_t)(struct sockopt *);
@@ -258,9 +294,14 @@ VNET_DECLARE(ip_fw_ctl_ptr_t, ip_fw_ctl_
 #define	V_ip_fw_chk_ptr		VNET(ip_fw_chk_ptr)
 #define	V_ip_fw_ctl_ptr		VNET(ip_fw_ctl_ptr)
 
+/* Divert hooks. */
+extern void	(*ip_divert_ptr)(struct mbuf *m, int incoming);
+/* ng_ipfw hooks -- XXX make it the same as divert and dummynet */
+extern int	(*ng_ipfw_input_p)(struct mbuf **, int,
+			struct ip_fw_args *, int);
+
 extern int	(*ip_dn_ctl_ptr)(struct sockopt *);
-extern int	(*ip_dn_io_ptr)(struct mbuf **m, int dir, struct ip_fw_args *fwa);
-extern void	(*ip_dn_ruledel_ptr)(void *);		/* in ip_fw2.c */
+extern int	(*ip_dn_io_ptr)(struct mbuf **, int, struct ip_fw_args *);
 
 VNET_DECLARE(int, ip_do_randomid);
 #define	V_ip_do_randomid	VNET(ip_do_randomid)

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c	Thu Jan  7 09:56:07 2010	(r201730)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c	Thu Jan  7 10:06:09 2010	(r201731)
@@ -73,12 +73,6 @@ static VNET_DEFINE(int, fw6_enable) = 1;
 
 int ipfw_chg_hook(SYSCTL_HANDLER_ARGS);
 
-/* Divert hooks. */
-void (*ip_divert_ptr)(struct mbuf *m, int incoming);
-
-/* ng_ipfw hooks. */
-ng_ipfw_input_t *ng_ipfw_input_p = NULL;
-
 /* Forward declarations. */
 static int ipfw_divert(struct mbuf **, int, struct ipfw_rule_ref *, int);
 
@@ -219,7 +213,7 @@ again:
 
 	case IP_FW_NGTEE:
 	case IP_FW_NETGRAPH:
-		if (!NG_IPFW_LOADED) {
+		if (ng_ipfw_input_p == NULL) {
 			ret = EACCES;
 			break; /* i.e. drop */
 		}

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_private.h
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_private.h	Thu Jan  7 09:56:07 2010	(r201730)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_private.h	Thu Jan  7 10:06:09 2010	(r201731)
@@ -35,8 +35,6 @@
 
 #ifdef _KERNEL
 
-#define MTAG_IPFW	1148380143	/* IPFW-tagged cookie */
-#define MTAG_IPFW_RULE	1262273568	/* rule reference */
 
 /* Return values from ipfw_chk() */
 enum {
@@ -66,38 +64,6 @@ struct _ip6dn_args {
        struct route_in6 ro_pmtu_or;
 };
 
-/*
- * Reference to an ipfw rule that can be carried outside critical sections.
- * A rule is identified by rulenum:rule_id which is ordered.
- * In version chain_id the rule can be found in slot 'slot', so
- * we don't need a lookup if chain_id == chain->id.
- *
- * On exit from the firewall this structure refers to the rule after
- * the matching one (slot points to the new rule; rulenum:rule_id-1
- * is the matching rule), and additional info (e.g. info often contains
- * the insn argument or tablearg in the low 16 bits, in host format).
- * On entry, the structure is valid if slot>0, and refers to the starting
- * rules. 'info' contains the reason for reinject, e.g. divert port,
- * divert direction, and so on.
- */
-struct ipfw_rule_ref {
-	uint32_t	slot;		/* slot for matching rule	*/
-	uint32_t	rulenum;	/* matching rule number		*/
-	uint32_t	rule_id;	/* matching rule id		*/
-	uint32_t	chain_id;	/* ruleset id			*/
-	uint32_t	info;		/* see below			*/
-};
-
-enum {
-	IPFW_INFO_MASK	= 0x0000ffff,
-	IPFW_INFO_OUT	= 0x00000000,	/* outgoing, just for convenience */
-	IPFW_INFO_IN	= 0x80000000,	/* incoming, overloads dir */
-	IPFW_ONEPASS	= 0x40000000,	/* One-pass, do not reinject */
-	IPFW_IS_MASK	= 0x30000000,	/* which source ? */
-	IPFW_IS_DIVERT	= 0x20000000,
-	IPFW_IS_DUMMYNET =0x10000000,
-	IPFW_IS_PIPE	= 0x08000000,	/* pip1=1, queue = 0 */
-};
 
 /*
  * Arguments for calling ipfw_chk() and dummynet_io(). We put them
@@ -289,10 +255,7 @@ int ipfw_del_table_entry(struct ip_fw_ch
 int ipfw_count_table(struct ip_fw_chain *ch, uint32_t tbl, uint32_t *cnt);
 int ipfw_dump_table(struct ip_fw_chain *ch, ipfw_table *tbl);
 
-/* hooks for divert */
-extern void (*ip_divert_ptr)(struct mbuf *m, int incoming);
-
-/* In ip_fw_nat.c */
+/* In ip_fw_nat.c -- XXX to be moved to ip_var.h */
 
 extern struct cfg_nat *(*lookup_nat_ptr)(struct nat_list *, int);
 
@@ -307,14 +270,5 @@ extern ipfw_nat_cfg_t *ipfw_nat_del_ptr;
 extern ipfw_nat_cfg_t *ipfw_nat_get_cfg_ptr;
 extern ipfw_nat_cfg_t *ipfw_nat_get_log_ptr;
 
-/* netgraph prototypes */
-
-typedef int ng_ipfw_input_t(struct mbuf **, int, struct ip_fw_args *, int);
-extern  ng_ipfw_input_t *ng_ipfw_input_p;
-#define NG_IPFW_LOADED  (ng_ipfw_input_p != NULL)
-
-#define TAGSIZ  (sizeof(struct ng_ipfw_tag) - sizeof(struct m_tag))
-
-
 #endif /* _KERNEL */
 #endif /* _IPFW2_PRIVATE_H */

Modified: user/luigi/ipfw3-head/sys/netinet/raw_ip.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/raw_ip.c	Thu Jan  7 09:56:07 2010	(r201730)
+++ user/luigi/ipfw3-head/sys/netinet/raw_ip.c	Thu Jan  7 10:06:09 2010	(r201731)
@@ -80,14 +80,18 @@ VNET_DEFINE(struct inpcbinfo, ripcbinfo)
 #define	V_ripcbinfo		VNET(ripcbinfo)
 
 /*
- * Control and data hooks for ipfw and dummynet.
+ * Control and data hooks for ipfw, dummynet, divert and so on.
  * The data hooks are not used here but it is convenient
  * to keep them all in one place.
  */
 VNET_DEFINE(ip_fw_chk_ptr_t, ip_fw_chk_ptr) = NULL;
 VNET_DEFINE(ip_fw_ctl_ptr_t, ip_fw_ctl_ptr) = NULL;
-int (*ip_dn_ctl_ptr)(struct sockopt *) = NULL;
-int (*ip_dn_io_ptr)(struct mbuf **m, int dir, struct ip_fw_args *fwa) = NULL;
+
+int	(*ip_dn_ctl_ptr)(struct sockopt *);
+int	(*ip_dn_io_ptr)(struct mbuf **, int, struct ip_fw_args *);
+void	(*ip_divert_ptr)(struct mbuf *, int);
+int	(*ng_ipfw_input_p)(struct mbuf **, int,
+			struct ip_fw_args *, int);
 
 /*
  * Hooks for multicast routing. They all default to NULL, so leave them not

From owner-svn-src-user@FreeBSD.ORG  Thu Jan  7 10:23:07 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 AED60106566B;
	Thu,  7 Jan 2010 10:23:07 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 9E8E88FC12;
	Thu,  7 Jan 2010 10:23:07 +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 o07AN75C020062;
	Thu, 7 Jan 2010 10:23:07 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o07AN7dL020059;
	Thu, 7 Jan 2010 10:23:07 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001071023.o07AN7dL020059@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Thu, 7 Jan 2010 10:23:07 +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: r201733 - in user/luigi/ipfw3-head/sys: net netgraph
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: Thu, 07 Jan 2010 10:23:07 -0000

Author: luigi
Date: Thu Jan  7 10:23:07 2010
New Revision: 201733
URL: http://svn.freebsd.org/changeset/base/201733

Log:
  missing header shuffling to make this compile

Modified:
  user/luigi/ipfw3-head/sys/net/if_ethersubr.c
  user/luigi/ipfw3-head/sys/netgraph/ng_ipfw.c

Modified: user/luigi/ipfw3-head/sys/net/if_ethersubr.c
==============================================================================
--- user/luigi/ipfw3-head/sys/net/if_ethersubr.c	Thu Jan  7 10:08:05 2010	(r201732)
+++ user/luigi/ipfw3-head/sys/net/if_ethersubr.c	Thu Jan  7 10:23:07 2010	(r201733)
@@ -70,9 +70,9 @@
 #include <netinet/in.h>
 #include <netinet/in_var.h>
 #include <netinet/if_ether.h>
+#include <netinet/ip_var.h>
 #include <netinet/ip_fw.h>
 #include <netinet/ipfw/ip_fw_private.h>
-#include <netinet/ip_var.h>
 #endif
 #ifdef INET6
 #include <netinet6/nd6.h>

Modified: user/luigi/ipfw3-head/sys/netgraph/ng_ipfw.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netgraph/ng_ipfw.c	Thu Jan  7 10:08:05 2010	(r201732)
+++ user/luigi/ipfw3-head/sys/netgraph/ng_ipfw.c	Thu Jan  7 10:23:07 2010	(r201733)
@@ -43,10 +43,10 @@
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
 #include <netinet/in_var.h>
+#include <netinet/ip_var.h>
 #include <netinet/ip_fw.h>
 #include <netinet/ipfw/ip_fw_private.h>
 #include <netinet/ip.h>
-#include <netinet/ip_var.h>
 
 #include <netgraph/ng_message.h>
 #include <netgraph/ng_parse.h>

From owner-svn-src-user@FreeBSD.ORG  Thu Jan  7 12:06:33 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 41691106566B;
	Thu,  7 Jan 2010 12:06:33 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 3109E8FC12;
	Thu,  7 Jan 2010 12:06:33 +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 o07C6XHx045406;
	Thu, 7 Jan 2010 12:06:33 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o07C6Xq1045403;
	Thu, 7 Jan 2010 12:06:33 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001071206.o07C6Xq1045403@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Thu, 7 Jan 2010 12:06:33 +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: r201741 - user/luigi/ipfw3-head/sys/netinet/ipfw
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: Thu, 07 Jan 2010 12:06:33 -0000

Author: luigi
Date: Thu Jan  7 12:06:32 2010
New Revision: 201741
URL: http://svn.freebsd.org/changeset/base/201741

Log:
  some patches from HEAD

Modified:
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_sockopt.c

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c	Thu Jan  7 12:00:54 2010	(r201740)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c	Thu Jan  7 12:06:32 2010	(r201741)
@@ -104,7 +104,8 @@ ipfw_check_hook(void *arg, struct mbuf *
 	int ret;
 
 	/* all the processing now uses ip_len in net format */
-	SET_NET_IPLEN(mtod(*m0, struct ip *));
+	if (mtod(*m0, struct ip *)->ip_v == 4)
+		SET_NET_IPLEN(mtod(*m0, struct ip *));
 
 	/* convert dir to IPFW values */
 	dir = (dir == PFIL_IN) ? DIR_IN : DIR_OUT;
@@ -236,7 +237,7 @@ again:
 			FREE_PKT(*m0);
 		*m0 = NULL;
 	}
-	if (*m0)
+	if (*m0 && mtod(*m0, struct ip *)->ip_v == 4)
 		SET_HOST_IPLEN(mtod(*m0, struct ip *));
 	return ret;
 }

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_sockopt.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_sockopt.c	Thu Jan  7 12:00:54 2010	(r201740)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_sockopt.c	Thu Jan  7 12:06:32 2010	(r201741)
@@ -63,7 +63,7 @@ __FBSDID("$FreeBSD$");
 #include <net/vnet.h>
 
 #include <netinet/in.h>
-#include <netinet/ip_var.h>	/* hooks */
+#include <netinet/ip_var.h> /* hooks */
 #include <netinet/ip_fw.h>
 #include <netinet/ipfw/ip_fw_private.h>
 

From owner-svn-src-user@FreeBSD.ORG  Thu Jan  7 14:05:41 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 2CDB2106568B;
	Thu,  7 Jan 2010 14:05:41 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 1ABC68FC18;
	Thu,  7 Jan 2010 14:05:41 +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 o07E5fEo072127;
	Thu, 7 Jan 2010 14:05:41 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o07E5fPv072123;
	Thu, 7 Jan 2010 14:05:41 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001071405.o07E5fPv072123@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Thu, 7 Jan 2010 14:05:41 +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: r201746 - user/luigi/ipfw3-head/sys/netinet/ipfw
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: Thu, 07 Jan 2010 14:05:41 -0000

Author: luigi
Date: Thu Jan  7 14:05:40 2010
New Revision: 201746
URL: http://svn.freebsd.org/changeset/base/201746

Log:
  snapshot -- split I/O from configuration functions.

Added:
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c   (contents, props changed)
Modified:
  user/luigi/ipfw3-head/sys/netinet/ipfw/dummynet.txt
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/dummynet.txt
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/dummynet.txt	Thu Jan  7 13:53:47 2010	(r201745)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/dummynet.txt	Thu Jan  7 14:05:40 2010	(r201746)
@@ -131,15 +131,32 @@ can use its own struct to store its queu
 Three global data structures (hash tables) contain all
 pipes, schedulers and flowsets.
 - pipehash[x]:      contains all pipes in the system
+	not needed to be efficient - we never do a lookup
+	in a critical section
+
 - schedulerhash[x]: contains all scheduler templates in the system
+	this needs to be a hash table because we may have to do
+	a lookup upon arrival of a packet.
+	We have one entry per 'sched X config' command
+	(plus one for each 'pipe X config').
+
 - flowsethash[x]:   contains all flowset linked with a scheduler (or pipe).
+	we do a lookup on this for each packet.
+	We have one entry for each 'queue X config'
+	(plus one for each 'pipe X config').
+
 Additionally, a list that contains all unlinked flowset:
 - unlinkedflowset:  contains flowset that are not linked with any scheduler
-flowset are put in this list when they refer to a non
-existing scheduler or pipe.
+	flowset are put in this list when they refer to a non
+	existing scheduler or pipe.
+	We keep them out of the main hash table because we do not
+	want to send packets to those flowsets.
+	We don't need an efficient data structure as we never search
+	here on a packet arrival -- at most we put here a flowset
+	for which a scheduler does not exist anymore.
 
-Scheduler instances and the delay lines associated with pipes
-need to be woken up at certain times. Because we have many
+Scheduler instances and the delay lines associated with each scheduler
+instance need to be woken up at certain times. Because we have many
 such objects, we keep them in a priority heap (system_heap).
 
 Almost all objects in this implementation are preceded

Added: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c	Thu Jan  7 14:05:40 2010	(r201746)
@@ -0,0 +1,1327 @@
+/*-
+ * Copyright (c) 2010 Luigi Rizzo, Universita` di Pisa
+ * 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 AND CONTRIBUTORS ``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.
+ */
+
+/*
+ * Dummynet portions related to packet handling.
+ */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#define	DUMMYNET_DEBUG
+
+#include "opt_inet6.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/mbuf.h>
+#include <sys/kernel.h>
+#include <sys/lock.h>
+#include <sys/module.h>
+#include <sys/priv.h>
+#include <sys/proc.h>
+#include <sys/rwlock.h>
+#include <sys/socket.h>
+//#include <sys/socketvar.h>
+#include <sys/time.h>
+#include <sys/sysctl.h>
+//#include <sys/taskqueue.h>
+#include <net/if.h>	/* IFNAMSIZ, struct ifaddr, ifq head, lock.h mutex.h */
+#include <net/netisr.h>
+#include <netinet/in.h>
+#include <netinet/ip.h>		/* ip_len, ip_off */
+#include <netinet/ip_var.h>	/* ip_output(), IP_FORWARDING */
+#include <netinet/ip_fw.h>
+#include <netinet/ipfw/ip_fw_private.h>
+#include <netinet/ipfw/dn_heap.h>
+#include <netinet/ip_dummynet.h>
+#include <netinet/ipfw/ip_dn_private.h>
+
+#include <netinet/if_ether.h> /* various ether_* routines */
+
+#include <netinet/ip6.h>       /* for ip6_input, ip6_output prototypes */
+#include <netinet6/ip6_var.h>
+
+/*
+ * We keep a private variable for the simulation time, but we could
+ * probably use an existing one ("softticks" in sys/kern/kern_timeout.c)
+ */
+static dn_key curr_time = 0 ; /* current simulation time */
+
+/* statistics on number of queue searches and search steps */
+static long searches, search_steps ;
+static int pipe_expire = 1 ;   /* expire queue if empty */
+static int dn_max_ratio = 16 ; /* max queues/buckets ratio */
+
+struct dn_parms dn_cfg = {
+	.pipe_slot_limit = 100, /* Foot shooting limit for pipe queues. */
+	.pipe_byte_limit = 1024 * 1024,
+
+	.hash_size = 64,		/* default hash size */
+	.red_lookup_depth = 256,	/* RED - default lookup table depth */
+	.red_avg_pkt_size = 512,      /* RED - default medium packet size */
+	.red_max_pkt_size = 1500,     /* RED - default max packet size */
+};
+
+//static struct timeval t;
+static long tick_last;			/* Last tick duration (usec). */
+static long tick_delta;			/* Last vs standard tick diff (usec). */
+static long tick_delta_sum;		/* Accumulated tick difference (usec).*/
+static long tick_adjustment;		/* Tick adjustments done. */
+static long tick_lost;			/* Lost(coalesced) ticks number. */
+/* Adjusted vs non-adjusted curr_time difference (ticks). */
+static long tick_diff;
+
+static unsigned long	io_pkt;
+static unsigned long	io_pkt_fast;
+static unsigned long	io_pkt_drop;
+
+/*
+ * Three heaps contain queues and pipes that the scheduler handles:
+ *
+ * ready_heap contains all dn_flow_queue related to fixed-rate pipes.
+ *
+ * wfq_ready_heap contains the pipes associated with WF2Q flows
+ *
+ * extract_heap contains pipes associated with delay lines.
+ *
+ * The key for the heap is used for two different values:
+ *
+ * 1. timer ticks- max 10K/second, so 32 bits are enough;
+ *
+ * 2. virtual times. These increase in steps of len/x, where len is the
+ *    packet length, and x is either the weight of the flow, or the
+ *    sum of all weights.
+ *    If we limit to max 1000 flows and a max weight of 100, then
+ *    x needs 17 bits. The packet size is 16 bits, so we can easily
+ *    overflow if we do not allow errors.
+ * So we use a key "dn_key" which is 64 bits. Some macros are used to
+ * compare key values and handle wraparounds.
+ * MAX64 returns the largest of two key values.
+ * MY_M is used as a shift count when doing fixed point arithmetic
+ * (a better name would be useful...).
+ */
+#define MAX64(x,y)  (( (int64_t) ( (y)-(x) )) > 0 ) ? (y) : (x)
+#define MY_M    16 /* number of left shift to obtain a larger precision */
+  
+/*
+ * XXX With this scaling, max 1000 flows, max weight 100, 1Gbit/s, the
+ * virtual time wraps every 15 days.
+ */
+
+MALLOC_DEFINE(M_DUMMYNET, "dummynet", "dummynet heap");
+
+static void	transmit_event(struct dn_pipe *pipe, struct mbuf **head,
+		    struct mbuf **tail);
+static void	ready_event(struct dn_flow_queue *q, struct mbuf **head,
+		    struct mbuf **tail);
+static void	ready_event_wfq(struct dn_pipe *p, struct mbuf **head,
+		    struct mbuf **tail);
+
+struct dn_heap ready_heap, extract_heap, wfq_ready_heap ;
+struct dn_pipe_head	pipehash[DN_HASHSIZE];	/* all pipes */
+struct dn_flow_set_head	flowsethash[DN_HASHSIZE];	/* all flowsets */
+
+extern	void (*bridge_dn_p)(struct mbuf *, struct ifnet *);
+
+#ifdef SYSCTL_NODE
+SYSCTL_DECL(_net_inet);
+SYSCTL_DECL(_net_inet_ip);
+
+SYSCTL_NODE(_net_inet_ip, OID_AUTO, dummynet, CTLFLAG_RW, 0, "Dummynet");
+SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, hash_size,
+    CTLFLAG_RW, &dn_cfg.hash_size, 0, "Default hash table size");
+#if 0	/* curr_time is 64 bit */
+SYSCTL_LONG(_net_inet_ip_dummynet, OID_AUTO, curr_time,
+    CTLFLAG_RD, &curr_time, 0, "Current tick");
+#endif
+SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, ready_heap,
+    CTLFLAG_RD, &ready_heap.size, 0, "Size of ready heap");
+SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, extract_heap,
+    CTLFLAG_RD, &extract_heap.size, 0, "Size of extract heap");
+SYSCTL_LONG(_net_inet_ip_dummynet, OID_AUTO, searches,
+    CTLFLAG_RD, &searches, 0, "Number of queue searches");
+SYSCTL_LONG(_net_inet_ip_dummynet, OID_AUTO, search_steps,
+    CTLFLAG_RD, &search_steps, 0, "Number of queue search steps");
+SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, expire,
+    CTLFLAG_RW, &pipe_expire, 0, "Expire queue if empty");
+SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, max_chain_len,
+    CTLFLAG_RW, &dn_max_ratio, 0,
+    "Max ratio between dynamic queues and buckets");
+SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, red_lookup_depth,
+    CTLFLAG_RD, &dn_cfg.red_lookup_depth, 0, "Depth of RED lookup table");
+SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, red_avg_pkt_size,
+    CTLFLAG_RD, &dn_cfg.red_avg_pkt_size, 0, "RED Medium packet size");
+SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, red_max_pkt_size,
+    CTLFLAG_RD, &dn_cfg.red_max_pkt_size, 0, "RED Max packet size");
+SYSCTL_LONG(_net_inet_ip_dummynet, OID_AUTO, tick_delta,
+    CTLFLAG_RD, &tick_delta, 0, "Last vs standard tick difference (usec).");
+SYSCTL_LONG(_net_inet_ip_dummynet, OID_AUTO, tick_delta_sum,
+    CTLFLAG_RD, &tick_delta_sum, 0, "Accumulated tick difference (usec).");
+SYSCTL_LONG(_net_inet_ip_dummynet, OID_AUTO, tick_adjustment,
+    CTLFLAG_RD, &tick_adjustment, 0, "Tick adjustments done.");
+SYSCTL_LONG(_net_inet_ip_dummynet, OID_AUTO, tick_diff,
+    CTLFLAG_RD, &tick_diff, 0,
+    "Adjusted vs non-adjusted curr_time difference (ticks).");
+SYSCTL_LONG(_net_inet_ip_dummynet, OID_AUTO, tick_lost,
+    CTLFLAG_RD, &tick_lost, 0,
+    "Number of ticks coalesced by dummynet taskqueue.");
+SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, io_fast,
+    CTLFLAG_RW, &dn_cfg.io_fast, 0, "Enable fast dummynet io.");
+SYSCTL_ULONG(_net_inet_ip_dummynet, OID_AUTO, io_pkt,
+    CTLFLAG_RD, &io_pkt, 0,
+    "Number of packets passed to dummynet.");
+SYSCTL_ULONG(_net_inet_ip_dummynet, OID_AUTO, io_pkt_fast,
+    CTLFLAG_RD, &io_pkt_fast, 0,
+    "Number of packets bypassed dummynet scheduler.");
+SYSCTL_ULONG(_net_inet_ip_dummynet, OID_AUTO, io_pkt_drop,
+    CTLFLAG_RD, &io_pkt_drop, 0,
+    "Number of packets dropped by dummynet.");
+SYSCTL_LONG(_net_inet_ip_dummynet, OID_AUTO, pipe_slot_limit,
+    CTLFLAG_RW, &dn_cfg.pipe_slot_limit, 0, "Upper limit in slots for pipe queue.");
+SYSCTL_LONG(_net_inet_ip_dummynet, OID_AUTO, pipe_byte_limit,
+    CTLFLAG_RW, &dn_cfg.pipe_byte_limit, 0, "Upper limit in bytes for pipe queue.");
+#endif
+
+#ifdef DUMMYNET_DEBUG
+int	dummynet_debug = 0;
+#ifdef SYSCTL_NODE
+SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, debug, CTLFLAG_RW, &dummynet_debug,
+	    0, "control debugging printfs");
+#endif
+#define	DPRINTF(X)	if (dummynet_debug) printf X
+#else
+#define	DPRINTF(X)
+#endif
+
+struct mtx dummynet_mtx;
+
+static void	dummynet_send(struct mbuf *);
+
+/*
+ * Flow queue is idle if:
+ *   1) it's empty for at least 1 tick
+ *   2) it has invalid timestamp (WF2Q case)
+ *   3) parent pipe has no 'exhausted' burst.
+ */
+#define QUEUE_IS_IDLE(q) ((q)->head == NULL && (q)->S == (q)->F + 1 && \
+	curr_time > (q)->idle_time + 1 && \
+	((q)->numbytes + (curr_time - (q)->idle_time - 1) * \
+	(q)->fs->pipe->bandwidth >= (q)->fs->pipe->burst))
+
+/*
+ * Packets processed by dummynet have an mbuf tag associated with
+ * them that carries their dummynet state.  This is used within
+ * the dummynet code as well as outside when checking for special
+ * processing requirements.
+ * Note that the first part is the reinject info and is common to
+ * other forms of packet reinjection.
+ */
+struct dn_pkt_tag {
+	struct ipfw_rule_ref rule;	/* matching rule		*/
+
+	/* second part, dummynet specific */
+	int dn_dir;		/* action when packet comes out.	*/
+				/* see ip_fw_private.h			*/
+	dn_key output_time;	/* when the pkt is due for delivery	*/
+	struct ifnet *ifp;	/* interface, for ip_output		*/
+	struct _ip6dn_args ip6opt;	/* XXX ipv6 options		*/
+};
+
+/*
+ * Return the mbuf tag holding the dummynet state.  As an optimization
+ * this is assumed to be the first tag on the list.  If this turns out
+ * wrong we'll need to search the list.
+ */
+static struct dn_pkt_tag *
+dn_tag_get(struct mbuf *m)
+{
+    struct m_tag *mtag = m_tag_first(m);
+    KASSERT(mtag != NULL &&
+	    mtag->m_tag_cookie == MTAG_ABI_COMPAT &&
+	    mtag->m_tag_id == PACKET_TAG_DUMMYNET,
+	    ("packet on dummynet queue w/o dummynet tag!"));
+    return (struct dn_pkt_tag *)(mtag+1);
+}
+
+/*
+ * Scheduler functions:
+ *
+ * transmit_event() is called when the delay-line needs to enter
+ * the scheduler, either because of existing pkts getting ready,
+ * or new packets entering the queue. The event handled is the delivery
+ * time of the packet.
+ *
+ * ready_event() does something similar with fixed-rate queues, and the
+ * event handled is the finish time of the head pkt.
+ *
+ * wfq_ready_event() does something similar with WF2Q queues, and the
+ * event handled is the start time of the head pkt.
+ *
+ * In all cases, we make sure that the data structures are consistent
+ * before passing pkts out, because this might trigger recursive
+ * invocations of the procedures.
+ */
+static void
+transmit_event(struct dn_pipe *pipe, struct mbuf **head, struct mbuf **tail)
+{
+	struct mbuf *m;
+	struct dn_pkt_tag *pkt;
+
+	DUMMYNET_LOCK_ASSERT();
+
+	while ((m = pipe->head) != NULL) {
+		pkt = dn_tag_get(m);
+		if (!DN_KEY_LEQ(pkt->output_time, curr_time))
+			break;
+
+		pipe->head = m->m_nextpkt;
+		if (*tail != NULL)
+			(*tail)->m_nextpkt = m;
+		else
+			*head = m;
+		*tail = m;
+	}
+	if (*tail != NULL)
+		(*tail)->m_nextpkt = NULL;
+
+	/* If there are leftover packets, put into the heap for next event. */
+	if ((m = pipe->head) != NULL) {
+		pkt = dn_tag_get(m);
+		/*
+		 * XXX Should check errors on heap_insert, by draining the
+		 * whole pipe p and hoping in the future we are more successful.
+		 */
+		heap_insert(&extract_heap, pkt->output_time, pipe);
+	}
+}
+
+#define div64(a, b)	((int64_t)(a) / (int64_t)(b))
+/*
+ * Compute how many ticks we have to wait before being able to send
+ * a packet. This is computed as the "wire time" for the packet
+ * (length + extra bits), minus the credit available, scaled to ticks.
+ * Check that the result is not be negative (it could be if we have
+ * too much leftover credit in q->numbytes).
+ */
+static inline dn_key
+set_ticks(struct mbuf *m, struct dn_flow_queue *q, struct dn_pipe *p)
+{
+	int64_t ret;
+
+	ret = div64( (m->m_pkthdr.len * 8 + q->extra_bits) * hz
+		- q->numbytes + p->bandwidth - 1 , p->bandwidth);
+	if (ret < 0)
+		ret = 0;
+	return ret;
+}
+
+/*
+ * Convert the additional MAC overheads/delays into an equivalent
+ * number of bits for the given data rate. The samples are in milliseconds
+ * so we need to divide by 1000.
+ */
+static dn_key
+compute_extra_bits(struct mbuf *pkt, struct dn_pipe *p)
+{
+	int index;
+	dn_key extra_bits;
+
+	if (!p->samples || p->samples_no == 0)
+		return 0;
+	index  = random() % p->samples_no;
+	extra_bits = div64((dn_key)p->samples[index] * p->bandwidth, 1000);
+	if (index >= p->loss_level) {
+		struct dn_pkt_tag *dt = dn_tag_get(pkt);
+		if (dt)
+			dt->dn_dir = DIR_DROP;
+	}
+	return extra_bits;
+}
+
+/*
+ * extract pkt from queue, compute output time (could be now)
+ * and put into delay line (p_queue)
+ */
+static void
+move_pkt(struct mbuf *pkt, struct dn_flow_queue *q, struct dn_pipe *p,
+    int len)
+{
+    struct dn_pkt_tag *dt = dn_tag_get(pkt);
+
+    q->head = pkt->m_nextpkt ;
+    q->len-- ;
+    q->len_bytes -= len ;
+
+    dt->output_time = curr_time + p->delay ;
+
+    if (p->head == NULL)
+	p->head = pkt;
+    else
+	p->tail->m_nextpkt = pkt;
+    p->tail = pkt;
+    p->tail->m_nextpkt = NULL;
+}
+
+/*
+ * ready_event() is invoked every time the queue must enter the
+ * scheduler, either because the first packet arrives, or because
+ * a previously scheduled event fired.
+ * On invokation, drain as many pkts as possible (could be 0) and then
+ * if there are leftover packets reinsert the pkt in the scheduler.
+ */
+static void
+ready_event(struct dn_flow_queue *q, struct mbuf **head, struct mbuf **tail)
+{
+	struct mbuf *pkt;
+	struct dn_pipe *p = q->fs->pipe;
+	int p_was_empty;
+
+	DUMMYNET_LOCK_ASSERT();
+
+	if (p == NULL) {
+		printf("dummynet: ready_event- pipe is gone\n");
+		return;
+	}
+	p_was_empty = (p->head == NULL);
+
+	/*
+	 * Schedule fixed-rate queues linked to this pipe:
+	 * account for the bw accumulated since last scheduling, then
+	 * drain as many pkts as allowed by q->numbytes and move to
+	 * the delay line (in p) computing output time.
+	 * bandwidth==0 (no limit) means we can drain the whole queue,
+	 * setting len_scaled = 0 does the job.
+	 */
+	q->numbytes += (curr_time - q->sched_time) * p->bandwidth;
+	while ((pkt = q->head) != NULL) {
+		int len = pkt->m_pkthdr.len;
+		dn_key len_scaled = p->bandwidth ? len*8*hz
+			+ q->extra_bits*hz
+			: 0;
+
+		if (DN_KEY_GT(len_scaled, q->numbytes))
+			break;
+		q->numbytes -= len_scaled;
+		move_pkt(pkt, q, p, len);
+		if (q->head)
+			q->extra_bits = compute_extra_bits(q->head, p);
+	}
+	/*
+	 * If we have more packets queued, schedule next ready event
+	 * (can only occur when bandwidth != 0, otherwise we would have
+	 * flushed the whole queue in the previous loop).
+	 * To this purpose we record the current time and compute how many
+	 * ticks to go for the finish time of the packet.
+	 */
+	if ((pkt = q->head) != NULL) {	/* this implies bandwidth != 0 */
+		dn_key t = set_ticks(pkt, q, p); /* ticks i have to wait */
+
+		q->sched_time = curr_time;
+		heap_insert(&ready_heap, curr_time + t, (void *)q);
+		/*
+		 * XXX Should check errors on heap_insert, and drain the whole
+		 * queue on error hoping next time we are luckier.
+		 */
+	} else		/* RED needs to know when the queue becomes empty. */
+		q->idle_time = curr_time;
+
+	/*
+	 * If the delay line was empty call transmit_event() now.
+	 * Otherwise, the scheduler will take care of it.
+	 */
+	if (p_was_empty)
+		transmit_event(p, head, tail);
+}
+
+/* callback to clean the idle heap */
+static int
+clean_fq(void *_q, uintptr_t arg)
+{
+	struct dn_flow_queue *q = _q;
+
+	q->F = 0;
+	q->S = q->F + 1;
+	return HEAP_SCAN_DEL;
+}
+
+/*
+ * Called when we can transmit packets on WF2Q queues. Take pkts out of
+ * the queues at their start time, and enqueue into the delay line.
+ * Packets are drained until p->numbytes < 0. As long as
+ * len_scaled >= p->numbytes, the packet goes into the delay line
+ * with a deadline p->delay. For the last packet, if p->numbytes < 0,
+ * there is an additional delay.
+ */
+static void
+ready_event_wfq(struct dn_pipe *p, struct mbuf **head, struct mbuf **tail)
+{
+	int p_was_empty = (p->head == NULL);
+	struct dn_heap *sch = p->scheduler_heap;
+	struct dn_heap *neh = p->not_eligible_heap;
+	int64_t p_numbytes = p->numbytes;
+
+	/*
+	 * p->numbytes is only 32bits in FBSD7, but we might need 64 bits.
+	 * Use a local variable for the computations, and write back the
+	 * results when done, saturating if needed.
+	 * The local variable has no impact on performance and helps
+	 * reducing diffs between the various branches.
+	 */
+
+	DUMMYNET_LOCK_ASSERT();
+
+	if (p->if_name[0] == 0)		/* tx clock is simulated */
+		p_numbytes += (curr_time - p->sched_time) * p->bandwidth;
+	else {	/*
+		 * tx clock is for real,
+		 * the ifq must be empty or this is a NOP.
+		 */
+		if (p->ifp && p->ifp->if_snd.ifq_head != NULL)
+			return;
+		else {
+			DPRINTF(("dummynet: pipe %d ready from %s --\n",
+			    p->pipe_nr, p->if_name));
+		}
+	}
+
+	/*
+	 * While we have backlogged traffic AND credit, we need to do
+	 * something on the queue.
+	 */
+	while (p_numbytes >= 0 && (sch->elements > 0 || neh->elements > 0)) {
+		if (sch->elements > 0) {
+			/* Have some eligible pkts to send out. */
+			struct dn_flow_queue *q = HEAP_TOP(sch)->object;
+			struct mbuf *pkt = q->head;
+			struct dn_flow_set *fs = q->fs;
+			uint64_t len = pkt->m_pkthdr.len;
+			int len_scaled = p->bandwidth ? len * 8 * hz : 0;
+
+			heap_extract(sch, NULL); /* Remove queue from heap. */
+			p_numbytes -= len_scaled;
+			move_pkt(pkt, q, p, len);
+
+			p->V += div64((len << MY_M), p->sum);	/* Update V. */
+			q->S = q->F;			/* Update start time. */
+			if (q->len == 0) {
+				/* Flow not backlogged any more. */
+				fs->backlogged--;
+				heap_insert(p->idle_heap, q->F, q);
+			} else {
+				/* Still backlogged. */
+
+				/*
+				 * Update F and position in backlogged queue,
+				 * then put flow in not_eligible_heap
+				 * (we will fix this later).
+				 */
+				len = (q->head)->m_pkthdr.len;
+				q->F += div64((len << MY_M), fs->weight);
+				if (DN_KEY_LEQ(q->S, p->V))
+					heap_insert(neh, q->S, q);
+				else
+					heap_insert(sch, q->F, q);
+			}
+		}
+		/*
+		 * Now compute V = max(V, min(S_i)). Remember that all elements
+		 * in sch have by definition S_i <= V so if sch is not empty,
+		 * V is surely the max and we must not update it. Conversely,
+		 * if sch is empty we only need to look at neh.
+		 */
+		if (sch->elements == 0 && neh->elements > 0)
+			p->V = MAX64(p->V, HEAP_TOP(neh)->key);
+		/* Move from neh to sch any packets that have become eligible */
+		while (neh->elements > 0 && DN_KEY_LEQ(HEAP_TOP(neh)->key, p->V)) {
+			struct dn_flow_queue *q = HEAP_TOP(neh)->object;
+			heap_extract(neh, NULL);
+			heap_insert(sch, q->F, q);
+		}
+
+		if (p->if_name[0] != '\0') { /* Tx clock is from a real thing */
+			p_numbytes = -1;	/* Mark not ready for I/O. */
+			break;
+		}
+	}
+	if (sch->elements == 0 && neh->elements == 0 && p_numbytes >= 0) {
+		p->idle_time = curr_time;
+		/*
+		 * No traffic and no events scheduled.
+		 * We can get rid of idle-heap.
+		 */
+		if (p->idle_heap->elements > 0) {
+			heap_scan(p->idle_heap, clean_fq, 0);
+			p->sum = 0;
+			p->V = 0;
+			p->idle_heap->elements = 0;
+		}
+	}
+	/*
+	 * If we are getting clocks from dummynet (not a real interface) and
+	 * If we are under credit, schedule the next ready event.
+	 * Also fix the delivery time of the last packet.
+	 */
+	if (p->if_name[0]==0 && p_numbytes < 0) { /* This implies bw > 0. */
+		dn_key t = 0;		/* Number of ticks i have to wait. */
+
+		if (p->bandwidth > 0)
+			t = div64(p->bandwidth - 1 - p_numbytes, p->bandwidth);
+		dn_tag_get(p->tail)->output_time += t;
+		p->sched_time = curr_time;
+		heap_insert(&wfq_ready_heap, curr_time + t, (void *)p);
+		/*
+		 * XXX Should check errors on heap_insert, and drain the whole
+		 * queue on error hoping next time we are luckier.
+		 */
+	}
+
+	/* Write back p_numbytes (adjust 64->32bit if necessary). */
+	p->numbytes = p_numbytes;
+
+	/*
+	 * If the delay line was empty call transmit_event() now.
+	 * Otherwise, the scheduler will take care of it.
+	 */
+	if (p_was_empty)
+		transmit_event(p, head, tail);
+}
+
+/*
+ * The timer handler for dummynet. Time is computed in ticks, but
+ * but the code is tolerant to the actual rate at which this is called.
+ * Once complete, the function reschedules itself for the next tick.
+ */
+void
+dummynet_task(void *context, int pending)
+{
+	struct mbuf *head = NULL, *tail = NULL;
+	struct dn_pipe *pipe;
+	struct dn_heap *heaps[3];
+	struct dn_heap *h;
+	void *p;	/* generic parameter to handler */
+	int i;
+	struct timeval t;
+
+	DUMMYNET_LOCK();
+
+	heaps[0] = &ready_heap;			/* fixed-rate queues */
+	heaps[1] = &wfq_ready_heap;		/* wfq queues */
+	heaps[2] = &extract_heap;		/* delay line */
+
+ 	/* Update number of lost(coalesced) ticks. */
+ 	tick_lost += pending - 1;
+ 
+ 	getmicrouptime(&t);
+ 	/* Last tick duration (usec). */
+ 	tick_last = (t.tv_sec - dn_cfg.prev_t.tv_sec) * 1000000 +
+ 	    (t.tv_usec - dn_cfg.prev_t.tv_usec);
+ 	/* Last tick vs standard tick difference (usec). */
+ 	tick_delta = (tick_last * hz - 1000000) / hz;
+ 	/* Accumulated tick difference (usec). */
+ 	tick_delta_sum += tick_delta;
+ 
+ 	dn_cfg.prev_t = t;
+ 
+ 	/*
+ 	 * Adjust curr_time if accumulated tick difference greater than
+ 	 * 'standard' tick. Since curr_time should be monotonically increasing,
+ 	 * we do positive adjustment as required and throttle curr_time in
+ 	 * case of negative adjustment.
+ 	 */
+  	curr_time++;
+ 	if (tick_delta_sum - tick >= 0) {
+ 		int diff = tick_delta_sum / tick;
+ 
+ 		curr_time += diff;
+ 		tick_diff += diff;
+ 		tick_delta_sum %= tick;
+ 		tick_adjustment++;
+ 	} else if (tick_delta_sum + tick <= 0) {
+ 		curr_time--;
+ 		tick_diff--;
+ 		tick_delta_sum += tick;
+ 		tick_adjustment++;
+ 	}
+
+	for (i = 0; i < 3; i++) {
+		h = heaps[i];
+		while (h->elements > 0 && DN_KEY_LEQ(HEAP_TOP(h)->key, curr_time)) {
+			// XXX can this happen ?
+			if (HEAP_TOP(h)->key > curr_time)
+				printf("dummynet: warning, "
+				    "heap %d is %d ticks late\n",
+				    i, (int)(curr_time - HEAP_TOP(h)->key));
+			/* store a copy before heap_extract */
+			p = HEAP_TOP(h)->object;
+			/* need to extract before processing */
+			heap_extract(h, NULL);
+			if (i == 0)
+				ready_event(p, &head, &tail);
+			else if (i == 1) {
+				struct dn_pipe *pipe = p;
+				if (pipe->if_name[0] != '\0')
+					printf("dummynet: bad ready_event_wfq "
+					    "for pipe %s\n", pipe->if_name);
+				else
+					ready_event_wfq(p, &head, &tail);
+			} else
+				transmit_event(p, &head, &tail);
+		}
+	}
+
+	/* Sweep pipes trying to expire idle flow_queues. */
+	for (i = 0; i < DN_HASHSIZE; i++) {
+		SLIST_FOREACH(pipe, &pipehash[i], next) {
+			if (pipe->idle_heap->elements > 0 &&
+			    DN_KEY_LT(HEAP_TOP(pipe->idle_heap)->key, pipe->V)) {
+				struct dn_flow_queue *q =
+				    HEAP_TOP(pipe->idle_heap)->object;
+
+				heap_extract(pipe->idle_heap, NULL);
+				/* Mark timestamp as invalid. */
+				q->S = q->F + 1;
+				pipe->sum -= q->fs->weight;
+			}
+		}
+	}
+
+	DUMMYNET_UNLOCK();
+
+	if (head != NULL)
+		dummynet_send(head);
+
+	dn_reschedule();
+}
+
+static void
+dummynet_send(struct mbuf *m)
+{
+	struct mbuf *n;
+
+	for (; m != NULL; m = n) {
+		struct ifnet *ifp;
+		int dst;
+        	struct m_tag *tag;
+
+		n = m->m_nextpkt;
+		m->m_nextpkt = NULL;
+		tag = m_tag_first(m);
+		if (tag == NULL) {
+			dst = DIR_DROP;
+		} else {
+			struct dn_pkt_tag *pkt = dn_tag_get(m);
+			/* extract the dummynet info, rename the tag */
+			dst = pkt->dn_dir;
+			ifp = pkt->ifp;
+			/* rename the tag so it carries reinject info */
+			tag->m_tag_cookie = MTAG_IPFW_RULE;
+			tag->m_tag_id = 0;
+		}
+
+		switch (dst) {
+		case DIR_OUT:
+			SET_HOST_IPLEN(mtod(m, struct ip *));
+			ip_output(m, NULL, NULL, IP_FORWARDING, NULL, NULL);
+			break ;
+		case DIR_IN :
+			/* put header in network format for ip_input() */
+			//SET_NET_IPLEN(mtod(m, struct ip *));
+			netisr_dispatch(NETISR_IP, m);
+			break;
+#ifdef INET6
+		case DIR_IN | PROTO_IPV6:
+			netisr_dispatch(NETISR_IPV6, m);
+			break;
+
+		case DIR_OUT | PROTO_IPV6:
+			SET_HOST_IPLEN(mtod(m, struct ip *));
+			ip6_output(m, NULL, NULL, IPV6_FORWARDING, NULL, NULL, NULL);
+			break;
+#endif
+		case DIR_FWD | PROTO_IFB: /* DN_TO_IFB_FWD: */
+			if (bridge_dn_p != NULL)
+				((*bridge_dn_p)(m, ifp));
+			else
+				printf("dummynet: if_bridge not loaded\n");
+
+			break;
+		case DIR_IN | PROTO_LAYER2: /* DN_TO_ETH_DEMUX: */
+			/*
+			 * The Ethernet code assumes the Ethernet header is
+			 * contiguous in the first mbuf header.
+			 * Insure this is true.
+			 */
+			if (m->m_len < ETHER_HDR_LEN &&
+			    (m = m_pullup(m, ETHER_HDR_LEN)) == NULL) {
+				printf("dummynet/ether: pullup failed, "
+				    "dropping packet\n");
+				break;
+			}
+			ether_demux(m->m_pkthdr.rcvif, m);
+			break;
+		case DIR_OUT | PROTO_LAYER2: /* N_TO_ETH_OUT: */
+			ether_output_frame(ifp, m);
+			break;
+
+		case DIR_DROP:
+			/* drop the packet after some time */
+			FREE_PKT(m);
+			break;
+
+		default:
+			printf("dummynet: bad switch %d!\n", dst);
+			FREE_PKT(m);
+			break;
+		}
+	}
+}
+
+/*
+ * Unconditionally expire empty queues in case of shortage.
+ * Returns the number of queues freed.
+ */
+static int
+expire_queues(struct dn_flow_set *fs)
+{
+    struct dn_flow_queue *q, *prev ;
+    int i, initial_elements = fs->rq_elements ;
+
+    if (fs->last_expired == time_uptime)
+	return 0 ;
+    fs->last_expired = time_uptime ;
+    for (i = 0 ; i <= fs->rq_size ; i++) { /* last one is overflow */
+	for (prev=NULL, q = fs->rq[i] ; q != NULL ; ) {
+	    if (!QUEUE_IS_IDLE(q)) {
+  		prev = q ;
+  	        q = q->next ;
+  	    } else { /* entry is idle, expire it */
+		struct dn_flow_queue *old_q = q ;
+
+		if (prev != NULL)
+		    prev->next = q = q->next ;
+		else
+		    fs->rq[i] = q = q->next ;
+		fs->rq_elements-- ;
+		free(old_q, M_DUMMYNET);
+	    }
+	}
+    }
+    return initial_elements - fs->rq_elements ;
+}
+
+/*
+ * If room, create a new queue and put at head of slot i;
+ * otherwise, create or use the default queue.
+ */
+static struct dn_flow_queue *
+create_queue(struct dn_flow_set *fs, int i)
+{
+	struct dn_flow_queue *q;
+
+	if (fs->rq_elements > fs->rq_size * dn_max_ratio &&
+	    expire_queues(fs) == 0) {
+		/* No way to get room, use or create overflow queue. */
+		i = fs->rq_size;
+		if (fs->rq[i] != NULL)
+		    return fs->rq[i];
+	}
+	q = malloc(sizeof(*q), M_DUMMYNET, M_NOWAIT | M_ZERO);
+	if (q == NULL) {
+		printf("dummynet: sorry, cannot allocate queue for new flow\n");
+		return (NULL);
+	}
+	q->fs = fs;
+	q->hash_slot = i;
+	q->next = fs->rq[i];
+	q->S = q->F + 1;	/* hack - mark timestamp as invalid. */
+	q->numbytes = fs->pipe->burst + (dn_cfg.io_fast ? fs->pipe->bandwidth : 0);
+	fs->rq[i] = q;
+	fs->rq_elements++;
+	return (q);
+}
+
+/*
+ * Given a flow_set and a pkt in last_pkt, find a matching queue
+ * after appropriate masking. The queue is moved to front
+ * so that further searches take less time.
+ */
+static struct dn_flow_queue *
+find_queue(struct dn_flow_set *fs, struct ipfw_flow_id *id)
+{
+    int i = 0 ; /* we need i and q for new allocations */
+    struct dn_flow_queue *q, *prev;
+    int is_v6 = IS_IP6_FLOW_ID(id);
+
+    if ( !(fs->flags_fs & DN_HAVE_FLOW_MASK) )
+	q = fs->rq[0] ;
+    else {
+	/* first, do the masking, then hash */
+	id->dst_port &= fs->flow_mask.dst_port ;
+	id->src_port &= fs->flow_mask.src_port ;
+	id->proto &= fs->flow_mask.proto ;
+	id->flags = 0 ; /* we don't care about this one */
+	if (is_v6) {
+	    APPLY_MASK(&id->dst_ip6, &fs->flow_mask.dst_ip6);
+	    APPLY_MASK(&id->src_ip6, &fs->flow_mask.src_ip6);
+	    id->flow_id6 &= fs->flow_mask.flow_id6;
+
+	    i = ((id->dst_ip6.__u6_addr.__u6_addr32[0]) & 0xffff)^
+		((id->dst_ip6.__u6_addr.__u6_addr32[1]) & 0xffff)^
+		((id->dst_ip6.__u6_addr.__u6_addr32[2]) & 0xffff)^
+		((id->dst_ip6.__u6_addr.__u6_addr32[3]) & 0xffff)^
+
+		((id->dst_ip6.__u6_addr.__u6_addr32[0] >> 15) & 0xffff)^
+		((id->dst_ip6.__u6_addr.__u6_addr32[1] >> 15) & 0xffff)^
+		((id->dst_ip6.__u6_addr.__u6_addr32[2] >> 15) & 0xffff)^
+		((id->dst_ip6.__u6_addr.__u6_addr32[3] >> 15) & 0xffff)^
+
+		((id->src_ip6.__u6_addr.__u6_addr32[0] << 1) & 0xfffff)^
+		((id->src_ip6.__u6_addr.__u6_addr32[1] << 1) & 0xfffff)^
+		((id->src_ip6.__u6_addr.__u6_addr32[2] << 1) & 0xfffff)^
+		((id->src_ip6.__u6_addr.__u6_addr32[3] << 1) & 0xfffff)^
+
+		((id->src_ip6.__u6_addr.__u6_addr32[0] << 16) & 0xffff)^
+		((id->src_ip6.__u6_addr.__u6_addr32[1] << 16) & 0xffff)^
+		((id->src_ip6.__u6_addr.__u6_addr32[2] << 16) & 0xffff)^
+		((id->src_ip6.__u6_addr.__u6_addr32[3] << 16) & 0xffff)^
+
+		(id->dst_port << 1) ^ (id->src_port) ^
+		(id->proto ) ^
+		(id->flow_id6);
+	} else {
+	    id->dst_ip &= fs->flow_mask.dst_ip ;
+	    id->src_ip &= fs->flow_mask.src_ip ;
+
+	    i = ( (id->dst_ip) & 0xffff ) ^
+		( (id->dst_ip >> 15) & 0xffff ) ^
+		( (id->src_ip << 1) & 0xffff ) ^
+		( (id->src_ip >> 16 ) & 0xffff ) ^
+		(id->dst_port << 1) ^ (id->src_port) ^
+		(id->proto );
+	}
+	i = i % fs->rq_size ;
+	/* finally, scan the current list for a match */
+	searches++ ;
+	for (prev=NULL, q = fs->rq[i] ; q ; ) {
+	    search_steps++;
+	    if (is_v6 &&
+		    IN6_ARE_ADDR_EQUAL(&id->dst_ip6,&q->id.dst_ip6) &&  
+		    IN6_ARE_ADDR_EQUAL(&id->src_ip6,&q->id.src_ip6) &&  
+		    id->dst_port == q->id.dst_port &&
+		    id->src_port == q->id.src_port &&
+		    id->proto == q->id.proto &&
+		    id->flags == q->id.flags &&
+		    id->flow_id6 == q->id.flow_id6)
+		break ; /* found */
+
+	    if (!is_v6 && id->dst_ip == q->id.dst_ip &&
+		    id->src_ip == q->id.src_ip &&
+		    id->dst_port == q->id.dst_port &&
+		    id->src_port == q->id.src_port &&
+		    id->proto == q->id.proto &&
+		    id->flags == q->id.flags)
+		break ; /* found */
+
+	    /* No match. Check if we can expire the entry */
+	    if (pipe_expire && QUEUE_IS_IDLE(q)) {
+		/* entry is idle and not in any heap, expire it */
+		struct dn_flow_queue *old_q = q ;
+
+		if (prev != NULL)
+		    prev->next = q = q->next ;
+		else
+		    fs->rq[i] = q = q->next ;
+		fs->rq_elements-- ;

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***

From owner-svn-src-user@FreeBSD.ORG  Thu Jan  7 18:11:03 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 83A0710656C3;
	Thu,  7 Jan 2010 18:11:03 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 7159D8FC20;
	Thu,  7 Jan 2010 18:11:03 +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 o07IB3IJ026438;
	Thu, 7 Jan 2010 18:11:03 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o07IB3pj026431;
	Thu, 7 Jan 2010 18:11:03 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001071811.o07IB3pj026431@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Thu, 7 Jan 2010 18:11:03 +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: r201753 - in user/luigi/ipfw3-head: sbin/ipfw
	sys/netinet sys/netinet/ipfw
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: Thu, 07 Jan 2010 18:11:03 -0000

Author: luigi
Date: Thu Jan  7 18:11:03 2010
New Revision: 201753
URL: http://svn.freebsd.org/changeset/base/201753

Log:
  snapshot of today's changes (not working)

Modified:
  user/luigi/ipfw3-head/sbin/ipfw/dummynet.c
  user/luigi/ipfw3-head/sbin/ipfw/ipfw2.h
  user/luigi/ipfw3-head/sbin/ipfw/main.c
  user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c

Modified: user/luigi/ipfw3-head/sbin/ipfw/dummynet.c
==============================================================================
--- user/luigi/ipfw3-head/sbin/ipfw/dummynet.c	Thu Jan  7 17:46:25 2010	(r201752)
+++ user/luigi/ipfw3-head/sbin/ipfw/dummynet.c	Thu Jan  7 18:11:03 2010	(r201753)
@@ -46,6 +46,7 @@
 #include <netinet/ip_dummynet.h>
 #include <arpa/inet.h>	/* inet_ntoa */
 
+
 static struct _s_x dummynet_params[] = {
 	{ "plr",		TOK_PLR },
 	{ "noerror",		TOK_NOERROR },
@@ -57,7 +58,9 @@ static struct _s_x dummynet_params[] = {
 	{ "proto",		TOK_PROTO },
 	{ "weight",		TOK_WEIGHT },
 	{ "all",		TOK_ALL },
-	{ "mask",		TOK_MASK },
+	//{ "mask",		TOK_MASK },
+	{ "sched_mask",		TOK_SCHED_MASK },
+	{ "flow_mask",		TOK_FLOW_MASK },
 	{ "droptail",		TOK_DROPTAIL },
 	{ "red",		TOK_RED },
 	{ "gred",		TOK_GRED },
@@ -65,7 +68,9 @@ static struct _s_x dummynet_params[] = {
 	{ "bandwidth",		TOK_BW },
 	{ "delay",		TOK_DELAY },
 	{ "pipe",		TOK_PIPE },
-	{ "queue",		TOK_QUEUE },
+	{ "queue",		TOK_FLOWSET },
+	{ "flowset",		TOK_FLOWSET },
+	{ "sched",		TOK_SCHED },
 	{ "flow-id",		TOK_FLOWID},
 	{ "dst-ipv6",		TOK_DSTIP6},
 	{ "dst-ip6",		TOK_DSTIP6},
@@ -77,6 +82,21 @@ static struct _s_x dummynet_params[] = {
 	{ NULL, 0 }	/* terminator */
 };
 
+#define O_NEXT(p, len) ((void *)(char *)(p) + len)
+
+/* make room in the buffer and move the pointer forward */
+static void *
+o_next(struct dn_id **o, int len, int type)
+{
+	void *ret = *o;
+	(*o)->len = len;
+	(*o)->type = type;
+	(*o)->subtype = 0;
+	(*o)->id = 0;
+	*o = O_NEXT(*o, len);
+	return ret;
+}
+
 static int
 sort_q(void *arg, const void *pa, const void *pb)
 {
@@ -550,7 +570,9 @@ compare_points(const void *vp1, const vo
 
 #define ED_EFMT(s) EX_DATAERR,"error in %s at line %d: "#s,filename,lineno
 
-static void
+void
+load_extra_delays(const char *filename, struct dn_pipe *p);
+void
 load_extra_delays(const char *filename, struct dn_pipe *p)
 {
 	char    line[ED_MAX_LINE_LEN];
@@ -694,26 +716,62 @@ load_extra_delays(const char *filename, 
 	strncpy(p->name, profile_name, sizeof(p->name));
 }
 
+/*
+ * configuration of pipes, schedulers, flowsets.
+ * do_pipe = 1 -> pipe (1 pipe + 1 flowset + 1 FIFO + 1 WFQ)
+ * do_pipe = 2 -> flowset
+ * do_pipe = 3 -> sched
+ * pipe ==>
+ */
 void
 ipfw_config_pipe(int ac, char **av)
 {
-	int samples[ED_MAX_SAMPLES_NO];
-	struct dn_pipe p;
-	int i;
+	int i = -1;
 	char *end;
 	void *par = NULL;
-
-	memset(&p, 0, sizeof p);
-	p.bandwidth = -1;
+	struct dn_id *buf, *base;
+	struct new_sch *sch = NULL, *sch2 = NULL;
+	struct new_pipe *p = NULL;
+	struct new_fs *fs = NULL;
+	struct ipfw_flow_id *mask = NULL;
+	int lmax = sizeof(*sch)*2 + sizeof(*p) + sizeof(*fs);
+
+fprintf(stderr, "configuring %d\n", co.do_pipe);
+	base = buf = calloc(1, lmax);
+	if (buf == NULL) {
+		errx(1, "no memory for pipe buffer");
+	}
 
 	av++; ac--;
 	/* Pipe number */
 	if (ac && isdigit(**av)) {
 		i = atoi(*av); av++; ac--;
-		if (co.do_pipe == 1)
-			p.pipe_nr = i;
-		else
-			p.fs.fs_nr = i;
+	}
+	if (i <= 0)
+		errx(EX_USAGE, "need a pipe/flowset/sched number");
+	switch (co.do_pipe) {
+	case 1:
+		sch = o_next(&buf, sizeof(*sch), DN_SCH);
+		sch2 = o_next(&buf, sizeof(*sch2), DN_SCH);
+		p = o_next(&buf, sizeof(*p), DN_PIPE);
+		fs = o_next(&buf, sizeof(*fs), DN_FS);
+		mask = &sch->sched_mask; // XXX or both ?
+		p->pipe_nr = i + DN_PIPEOFFSET;
+		fs->fs_nr = i;
+		fs->sched_nr = i;
+		sch->sched_nr = i;
+		sch2->sched_nr = i + DN_PIPEOFFSET;
+		break;
+	case 2: /* flowset */
+		fs = o_next(&buf, sizeof(*fs), DN_FS);
+		fs->fs_nr = i;
+		mask = &fs->flow_mask;
+		break;
+	case 3: /* scheduler */
+		sch = o_next(&buf, sizeof(*sch), DN_SCH);
+		sch->sched_nr = i;
+		mask = &sch->sched_mask; // XXX or both ?
+		break;
 	}
 	while (ac > 0) {
 		double d;
@@ -722,41 +780,46 @@ ipfw_config_pipe(int ac, char **av)
 
 		switch(tok) {
 		case TOK_NOERROR:
-			p.fs.flags_fs |= DN_NOERROR;
+			NEED(fs, "noerror is only for pipes");
+			fs->flags |= DN_NOERROR;
 			break;
 
 		case TOK_PLR:
+			NEED(fs, "plr is only for pipes");
 			NEED1("plr needs argument 0..1\n");
 			d = strtod(av[0], NULL);
 			if (d > 1)
 				d = 1;
 			else if (d < 0)
 				d = 0;
-			p.fs.plr = (int)(d*0x7fffffff);
+			fs->plr = (int)(d*0x7fffffff);
 			ac--; av++;
 			break;
 
 		case TOK_QUEUE:
+			NEED(fs, "queue is only for pipes or flowsets");
 			NEED1("queue needs queue size\n");
 			end = NULL;
-			p.fs.qsize = strtoul(av[0], &end, 0);
+			fs->qsize = strtoul(av[0], &end, 0);
 			if (*end == 'K' || *end == 'k') {
-				p.fs.flags_fs |= DN_QSIZE_IS_BYTES;
-				p.fs.qsize *= 1024;
+				fs->flags |= DN_QSIZE_IS_BYTES;
+				fs->qsize *= 1024;
 			} else if (*end == 'B' ||
 			    _substrcmp2(end, "by", "bytes") == 0) {
-				p.fs.flags_fs |= DN_QSIZE_IS_BYTES;
+				fs->flags |= DN_QSIZE_IS_BYTES;
 			}
 			ac--; av++;
 			break;
 
 		case TOK_BUCKETS:
+			NEED(fs, "buckets is only for pipes or flowsets");
 			NEED1("buckets needs argument\n");
-			p.fs.rq_size = strtoul(av[0], NULL, 0);
+			// XXX fs->rq_size = strtoul(av[0], NULL, 0);
 			ac--; av++;
 			break;
 
 		case TOK_MASK:
+			NEED(mask, "tok_mask");
 			NEED1("mask needs mask specifier\n");
 			/*
 			 * per-flow queue, mask is dst_ip, dst_port,
@@ -764,7 +827,7 @@ ipfw_config_pipe(int ac, char **av)
 			 */
 			par = NULL;
 
-			bzero(&p.fs.flow_mask, sizeof(p.fs.flow_mask));
+			bzero(mask, sizeof(*mask));
 			end = NULL;
 
 			while (ac >= 1) {
@@ -781,43 +844,43 @@ ipfw_config_pipe(int ac, char **av)
 				    /*
 				     * special case, all bits significant
 				     */
-				    p.fs.flow_mask.dst_ip = ~0;
-				    p.fs.flow_mask.src_ip = ~0;
-				    p.fs.flow_mask.dst_port = ~0;
-				    p.fs.flow_mask.src_port = ~0;
-				    p.fs.flow_mask.proto = ~0;
-				    n2mask(&(p.fs.flow_mask.dst_ip6), 128);
-				    n2mask(&(p.fs.flow_mask.src_ip6), 128);
-				    p.fs.flow_mask.flow_id6 = ~0;
-				    p.fs.flags_fs |= DN_HAVE_FLOW_MASK;
+				    mask->dst_ip = ~0;
+				    mask->src_ip = ~0;
+				    mask->dst_port = ~0;
+				    mask->src_port = ~0;
+				    mask->proto = ~0;
+				    n2mask(&mask->dst_ip6, 128);
+				    n2mask(&mask->src_ip6, 128);
+				    mask->flow_id6 = ~0;
+				    fs->flags |= DN_HAVE_FLOW_MASK;
 				    goto end_mask;
 
 			    case TOK_DSTIP:
-				    p32 = &p.fs.flow_mask.dst_ip;
+				    p32 = &mask->dst_ip;
 				    break;
 
 			    case TOK_SRCIP:
-				    p32 = &p.fs.flow_mask.src_ip;
+				    p32 = &mask->src_ip;
 				    break;
 
 			    case TOK_DSTIP6:
-				    pa6 = &(p.fs.flow_mask.dst_ip6);
+				    pa6 = &mask->dst_ip6;
 				    break;
 			    
 			    case TOK_SRCIP6:
-				    pa6 = &(p.fs.flow_mask.src_ip6);
+				    pa6 = &mask->src_ip6;
 				    break;
 
 			    case TOK_FLOWID:
-				    p20 = &p.fs.flow_mask.flow_id6;
+				    p20 = &mask->flow_id6;
 				    break;
 
 			    case TOK_DSTPORT:
-				    p16 = &p.fs.flow_mask.dst_port;
+				    p16 = &mask->dst_port;
 				    break;
 
 			    case TOK_SRCPORT:
-				    p16 = &p.fs.flow_mask.src_port;
+				    p16 = &mask->src_port;
 				    break;
 
 			    case TOK_PROTO:
@@ -857,19 +920,20 @@ ipfw_config_pipe(int ac, char **av)
 				    if (a > 0xFF)
 					    errx(EX_DATAERR,
 						"proto mask must be 8 bit");
-				    p.fs.flow_mask.proto = (uint8_t)a;
+				    fs->flow_mask.proto = (uint8_t)a;
 			    }
 			    if (a != 0)
-				    p.fs.flags_fs |= DN_HAVE_FLOW_MASK;
+				    fs->flags |= DN_HAVE_FLOW_MASK;
 			    ac--; av++;
 			} /* end while, config masks */
 end_mask:
 			break;
 
+#if 0
 		case TOK_RED:
 		case TOK_GRED:
 			NEED1("red/gred needs w_q/min_th/max_th/max_p\n");
-			p.fs.flags_fs |= DN_IS_RED;
+			fs->flags |= DN_IS_RED;
 			if (tok == TOK_GRED)
 				p.fs.flags_fs |= DN_IS_GENTLE_RED;
 			/*
@@ -879,10 +943,10 @@ end_mask:
 			    double w_q = strtod(end, NULL);
 			    if (w_q > 1 || w_q <= 0)
 				errx(EX_DATAERR, "0 < w_q <= 1");
-			    p.fs.w_q = (int) (w_q * (1 << SCALE_RED));
+			    fs->w_q = (int) (w_q * (1 << SCALE_RED));
 			}
 			if ((end = strsep(&av[0], "/"))) {
-			    p.fs.min_th = strtoul(end, &end, 0);
+			    fs->min_th = strtoul(end, &end, 0);
 			    if (*end == 'K' || *end == 'k')
 				p.fs.min_th *= 1024;
 			}
@@ -899,62 +963,66 @@ end_mask:
 			}
 			ac--; av++;
 			break;
+#endif
 
 		case TOK_DROPTAIL:
-			p.fs.flags_fs &= ~(DN_IS_RED|DN_IS_GENTLE_RED);
+			NEED(fs, "droptail is only for flowsets");
+			fs->flags &= ~(DN_IS_RED|DN_IS_GENTLE_RED);
 			break;
 
 		case TOK_BW:
+			NEED(p, "bw is only for pipe");
 			NEED1("bw needs bandwidth or interface\n");
-			if (co.do_pipe != 1)
-			    errx(EX_DATAERR, "bandwidth only valid for pipes");
-			read_bandwidth(av[0], &p.bandwidth, p.if_name, sizeof(p.if_name));
+			read_bandwidth(av[0], &p->bandwidth, p->if_name, sizeof(p->if_name));
 			ac--; av++;
 			break;
 
 		case TOK_DELAY:
-			if (co.do_pipe != 1)
-				errx(EX_DATAERR, "delay only valid for pipes");
+			NEED(p, "delay is only for pipes");
 			NEED1("delay needs argument 0..10000ms\n");
-			p.delay = strtoul(av[0], NULL, 0);
+			p->delay = strtoul(av[0], NULL, 0);
 			ac--; av++;
 			break;
 
+#if 0
 		case TOK_WEIGHT:
-			if (co.do_pipe == 1)
-				errx(EX_DATAERR,"weight only valid for queues");
+			NEED(fs, "weight is only for flowsets");
 			NEED1("weight needs argument 0..100\n");
-			p.fs.weight = strtoul(av[0], &end, 0);
+			fs->weight = strtoul(av[0], &end, 0);
 			ac--; av++;
 			break;
+#endif
 
+		case TOK_SCHED:
 		case TOK_PIPE:
-			if (co.do_pipe == 1)
-				errx(EX_DATAERR,"pipe only valid for queues");
+			NEED(fs, "pipe/sched");
 			NEED1("pipe needs pipe_number\n");
-			p.fs.parent_nr = strtoul(av[0], &end, 0);
+			fs->sched_nr = strtoul(av[0], &end, 0);
 			ac--; av++;
 			break;
 
+#if 0
 		case TOK_PIPE_PROFILE:
+		    {
+			int samples[ED_MAX_SAMPLES_NO];
 			if (co.do_pipe != 1)
 			    errx(EX_DATAERR, "extra delay only valid for pipes");
 			NEED1("extra delay needs the file name\n");
 			p.samples = &samples[0];
 			load_extra_delays(av[0], &p);
 			--ac; ++av;
+		    }
 			break;
-
+#endif
 		case TOK_BURST:
-			if (co.do_pipe != 1)
-				errx(EX_DATAERR, "burst only valid for pipes");
+			NEED(sch, "burst");
 			NEED1("burst needs argument\n");
 			errno = 0;
-			if (expand_number(av[0], (int64_t *)&p.burst) < 0)
+			if (expand_number(av[0], (int64_t *)&sch->burst) < 0)
 				if (errno != ERANGE)
 					errx(EX_DATAERR,
 					    "burst: invalid argument");
-			if (errno || p.burst > (1ULL << 48) - 1)
+			if (errno || sch->burst > (1ULL << 48) - 1)
 				errx(EX_DATAERR,
 				    "burst: out of range (0..2^48-1)");
 			ac--; av++;
@@ -964,26 +1032,19 @@ end_mask:
 			errx(EX_DATAERR, "unrecognised option ``%s''", av[-1]);
 		}
 	}
-	if (co.do_pipe == 1) {
-		if (p.pipe_nr == 0)
-			errx(EX_DATAERR, "pipe_nr must be > 0");
-		if (p.delay > 10000)
-			errx(EX_DATAERR, "delay must be < 10000");
-	} else { /* co.do_pipe == 2, queue */
-		if (p.fs.parent_nr == 0)
-			errx(EX_DATAERR, "pipe must be > 0");
-		if (p.fs.weight >100)
-			errx(EX_DATAERR, "weight must be <= 100");
-	}
 
-	/* check for bandwidth value */
-	if (p.bandwidth == -1) {
-		p.bandwidth = 0;
-		if (p.samples_no > 0)
-			errx(EX_DATAERR, "profile requires a bandwidth limit");
+	/* check validity of parameters */
+	if (p) {
+		if (p->delay > 10000)
+			errx(EX_DATAERR, "delay must be < 10000");
+		if (p->bandwidth == -1)
+			p->bandwidth = 0;
 	}
+	if (fs) {
+		if (fs->sched_nr == 0)
+			errx(EX_DATAERR, "sched must be > 0");
 
-	if (p.fs.flags_fs & DN_QSIZE_IS_BYTES) {
+	    if (fs->flags & DN_QSIZE_IS_BYTES) {
 		size_t len;
 		long limit;
 
@@ -991,9 +1052,9 @@ end_mask:
 		if (sysctlbyname("net.inet.ip.dummynet.pipe_byte_limit",
 			&limit, &len, NULL, 0) == -1)
 			limit = 1024*1024;
-		if (p.fs.qsize > limit)
+		if (fs->qsize > limit)
 			errx(EX_DATAERR, "queue size must be < %ldB", limit);
-	} else {
+	    } else {
 		size_t len;
 		long limit;
 
@@ -1001,9 +1062,11 @@ end_mask:
 		if (sysctlbyname("net.inet.ip.dummynet.pipe_slot_limit",
 			&limit, &len, NULL, 0) == -1)
 			limit = 100;
-		if (p.fs.qsize > limit)
+		if (fs->qsize > limit)
 			errx(EX_DATAERR, "2 <= queue size <= %ld", limit);
+	    }
 	}
+#if 0 /* RED CONFIGURATION */
 	if (p.fs.flags_fs & DN_IS_RED) {
 		size_t len;
 		int lookup_depth, avg_pkt_size;
@@ -1060,10 +1123,10 @@ end_mask:
 		 * NOTA:  (3/w_q) is approx the value x so that
 		 * (1-w_q)^x < 10^-3.
 		 */
-		w_q = ((double)p.fs.w_q) / (1 << SCALE_RED);
+		w_q = ((double)fs->w_q) / (1 << SCALE_RED);
 		idle = s * 3. / w_q;
-		p.fs.lookup_step = (int)idle / lookup_depth;
-		if (!p.fs.lookup_step)
+		fs->lookup_step = (int)idle / lookup_depth;
+		if (!fs->lookup_step)
 			p.fs.lookup_step = 1;
 		weight = 1 - w_q;
 		for (t = p.fs.lookup_step; t > 1; --t)
@@ -1071,15 +1134,14 @@ end_mask:
 		p.fs.lookup_weight = (int)(weight * (1 << SCALE_RED));
 	}
 	if (p.samples_no <= 0) {
-		i = do_cmd(IP_DUMMYNET_CONFIGURE, &p, sizeof p);
-	} else {
-		struct dn_pipe_max pm;
-		int len = sizeof(pm);
-
-		memcpy(&pm.pipe, &p, sizeof(pm.pipe));
-		memcpy(&pm.samples, samples, sizeof(pm.samples));
-
-		i = do_cmd(IP_DUMMYNET_CONFIGURE, &pm, len);
+		struct new_profile *prof;
+		prof = o_next(&o, sizeof(*prof), DN_PROFILE);
+		i = do_cmd(IP_DUMMYNET_CONFIGURE, prof, sizeof *prof);
+	} else
+#endif
+	{
+		i = do_cmd(IP_DUMMYNET_CONFIGURE, base,
+			(char *)buf - (char *)base);
 	}
 
 	if (i)

Modified: user/luigi/ipfw3-head/sbin/ipfw/ipfw2.h
==============================================================================
--- user/luigi/ipfw3-head/sbin/ipfw/ipfw2.h	Thu Jan  7 17:46:25 2010	(r201752)
+++ user/luigi/ipfw3-head/sbin/ipfw/ipfw2.h	Thu Jan  7 18:11:03 2010	(r201753)
@@ -35,7 +35,7 @@ struct cmdline_opts {
 	int	do_resolv;	/* try to resolve all ip to names */
 	int	do_time;	/* Show time stamps */
 	int	do_quiet;	/* Be quiet in add and flush */
-	int	do_pipe;	/* this cmd refers to a pipe */
+	int	do_pipe;	/* this cmd refers to a pipe/queue/sched */
 	int	do_nat; 	/* this cmd refers to a nat config */
 	int	do_dynamic;	/* display dynamic rules */
 	int	do_expired;	/* display expired dynamic rules */
@@ -83,6 +83,8 @@ enum tokens {
 	TOK_COUNT,
 	TOK_PIPE,
 	TOK_QUEUE,
+	TOK_FLOWSET,
+	TOK_SCHED,
 	TOK_DIVERT,
 	TOK_TEE,
 	TOK_NETGRAPH,
@@ -151,6 +153,8 @@ enum tokens {
 	TOK_SRCPORT,
 	TOK_ALL,
 	TOK_MASK,
+	TOK_FLOW_MASK,
+	TOK_SCHED_MASK,
 	TOK_BW,
 	TOK_DELAY,
 	TOK_PIPE_PROFILE,
@@ -192,6 +196,7 @@ enum tokens {
  * the following macro returns an error message if we run out of
  * arguments.
  */
+#define NEED(_p, msg)      {if (!_p) errx(EX_USAGE, msg);}
 #define NEED1(msg)      {if (!ac) errx(EX_USAGE, msg);}
 
 unsigned long long align_uint64(const uint64_t *pll);

Modified: user/luigi/ipfw3-head/sbin/ipfw/main.c
==============================================================================
--- user/luigi/ipfw3-head/sbin/ipfw/main.c	Thu Jan  7 17:46:25 2010	(r201752)
+++ user/luigi/ipfw3-head/sbin/ipfw/main.c	Thu Jan  7 18:11:03 2010	(r201753)
@@ -304,6 +304,10 @@ ipfw_main(int oldac, char **oldav)
 		co.do_pipe = 1;
 	else if (_substrcmp(*av, "queue") == 0)
 		co.do_pipe = 2;
+	else if (_substrcmp(*av, "flowset") == 0)
+		co.do_pipe = 2;
+	else if (_substrcmp(*av, "sched") == 0)
+		co.do_pipe = 3;
 	else if (!strncmp(*av, "set", strlen(*av))) {
 		if (ac > 1 && isdigit(av[1][0])) {
 			co.use_set = strtonum(av[1], 0, resvd_set_number,

Modified: user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h	Thu Jan  7 17:46:25 2010	(r201752)
+++ user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h	Thu Jan  7 18:11:03 2010	(r201753)
@@ -215,7 +215,7 @@ struct new_fs {
  * This struct is created a runtime.
  */
 struct new_sch_inst {
-	struct dn_id sch_id;
+	struct dn_id oid;
 
 	struct new_sch_inst *next; /* next item in the bucket */
 
@@ -250,7 +250,7 @@ struct new_sch_inst {
  * (plus there is a FIFO scheduler for each pipe)
  */
 struct new_sch {
-	struct dn_id g;
+	struct dn_id id;
 
 	/* these initial fields are set from the command line
 	* sched N config mask M ...
@@ -316,6 +316,14 @@ struct new_sch {
 	// struct mtx sch_mtx;
 };
 
+/*
+ * "queue N" and "pipe N" accept 1<=N<=65535. To map the values in
+ * the same namespace (which we search through a hash table) we add
+ * an offset to 'pipe N' below. The value is not so important, but
+ * it should be known to userland as well so we can print it.
+ */
+#define	DN_PIPEOFFSET	1000000
+
 /*---- old parameters ---*/
 /*
  * The maximum hash table size for queues.  This value must be a power

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c	Thu Jan  7 17:46:25 2010	(r201752)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c	Thu Jan  7 18:11:03 2010	(r201753)
@@ -1110,6 +1110,10 @@ ipdn_locate_pipe(int pipe_nr)
  * dummynet hook for packets. Below 'pipe' is a pipe or a queue
  * depending on whether WF2Q or fixed bw is used.
  *
+ * We use the argument to locate the flowset fs and the sched_set sch
+ * associated to it. The we apply flow_mask and sched_mask to
+ * determine the queue and scheduler instances.
+ *
  * pipe_nr	pipe or queue the packet is destined for.
  * dir		where shall we send the packet after dummynet.
  * m		the mbuf with the packet
@@ -1124,39 +1128,39 @@ dummynet_io(struct mbuf **m0, int dir, s
 	struct dn_pkt_tag *pkt;
 	struct m_tag *mtag;
 	struct dn_flow_set *fs = NULL;
-	struct dn_pipe *pipe;
+	struct dn_pipe *pipe = NULL;
 	uint64_t len = m->m_pkthdr.len;
 	struct dn_flow_queue *q = NULL;
-	int is_pipe = fwa->rule.info & IPFW_IS_PIPE;
+	int fs_id = fwa->rule.info & IPFW_INFO_MASK;
+	int is_pipe = 0;
+
+	if (fwa->rule.info & IPFW_IS_PIPE)
+		fs_id += DN_PIPEOFFSET;
 
 	KASSERT(m->m_nextpkt == NULL,
 	    ("dummynet_io: mbuf queue passed to dummynet"));
 
 	DUMMYNET_LOCK();
 	io_pkt++;
-	/*
-	 * This is a dummynet rule, so we expect an O_PIPE or O_QUEUE rule.
-	 */
-	if (is_pipe) {
-		pipe = ipdn_locate_pipe(fwa->rule.info & IPFW_INFO_MASK);
-		if (pipe != NULL)
-			fs = &(pipe->fs);
-	} else
-		fs = ipdn_locate_flowset(fwa->rule.info & IPFW_INFO_MASK);
+	fs = ipdn_locate_flowset(fs_id);
 
 	if (fs == NULL)
 		goto dropit;	/* This queue/pipe does not exist! */
-	pipe = fs->pipe;
-	if (pipe == NULL) {	/* Must be a queue, try find a matching pipe. */
-		pipe = ipdn_locate_pipe(fs->parent_nr);
-		if (pipe != NULL)
-			fs->pipe = pipe;
-		else {
-			printf("dummynet: no pipe %d for queue %d, drop pkt\n",
-			    fs->parent_nr, fs->fs_nr);
+#if 0
+	if (fs->sched_id != dn_cfg.id) {
+		/* configuration changed, update */
+		int ret = reconfigure(fs);
+		if (ret)
+			goto dropit;
+		/* find again, just in case things changed */
+		fs = ipdn_locate_flowset(fs_id);
+		if (fs == NULL)
 			goto dropit;
-		}
 	}
+	sch = fs->sched;
+	if (sch == NULL)
+		goto dropit;
+#endif
 	q = find_queue(fs, &(fwa->f_id));
 	if (q == NULL)
 		goto dropit;		/* Cannot allocate queue. */
@@ -1176,7 +1180,7 @@ dummynet_io(struct mbuf **m0, int dir, s
 	if (fs->flags_fs & DN_IS_RED && red_drops(fs, q, len))
 		goto dropit;
 
-	/* XXX expensive to zero, see if we can remove it. */
+	/* tag the mbuf */
 	mtag = m_tag_get(PACKET_TAG_DUMMYNET,
 	    sizeof(struct dn_pkt_tag), M_NOWAIT | M_ZERO);
 	if (mtag == NULL)

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Thu Jan  7 17:46:25 2010	(r201752)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Thu Jan  7 18:11:03 2010	(r201753)
@@ -67,7 +67,6 @@ __FBSDID("$FreeBSD$");
 //#include <netinet/ip6.h>       /* for ip6_input, ip6_output prototypes */
 //#include <netinet6/ip6_var.h>
 
-static int	config_pipe(struct dn_pipe *p);
 static int	ip_dn_ctl(struct sockopt *sopt);
 
 static struct callout dn_timeout;
@@ -310,8 +309,26 @@ set_fs_parms(struct dn_flow_set *x, stru
 		config_red(src, x);	/* XXX should check errors */
 }
 
+static int
+do_config(void *p, int l)
+{
+	struct dn_id *o = p;
+
+	while (l && o->len > 0) {
+		l -= o->len;
+		o = (struct dn_id *)((char *)o + l);
+	}
+	return 0;
+}
+
 /*
- * Setup pipe or queue parameters.
+ * Setup pipe or flowset parameters.
+ * 'pipe config' (pipe_nr > 0, fs_nr == 0)
+ *	configures a pipe, a FIFO scheduler + flowset, and a WFQ scheduler.
+ * 'queue config' (pipe_nr == 0, fs_nr > 0)
+ *	configures a flowset.
+ * 'sched config' (pipe_nr > 0, fs_nr > 0)
+ *	(re)configures the WFQ scheduler for the pipe.
  */
 static int
 config_pipe(struct dn_pipe *p)
@@ -320,6 +337,9 @@ config_pipe(struct dn_pipe *p)
 	struct dn_flow_queue *q;
 	int i, error;
 
+	/* We need either a pipe number or a flow_set number. */
+	if (p->pipe_nr == 0 && pfs->fs_nr == 0)
+		return (EINVAL);
 	/*
 	 * The config program passes parameters as follows:
 	 * bw = bits/second (0 means no limits),
@@ -329,15 +349,11 @@ config_pipe(struct dn_pipe *p)
 	p->delay = (p->delay * hz) / 1000;
 	/* Scale burst size: bytes -> bits * hz */
 	p->burst *= 8 * hz;
-	/* We need either a pipe number or a flow_set number. */
-	if (p->pipe_nr == 0 && pfs->fs_nr == 0)
-		return (EINVAL);
-	if (p->pipe_nr != 0 && pfs->fs_nr != 0)
-		return (EINVAL);
+
+	DUMMYNET_LOCK();
 	if (p->pipe_nr != 0) {			/* this is a pipe */
 		struct dn_pipe *pipe;
 
-		DUMMYNET_LOCK();
 		pipe = ipdn_locate_pipe(p->pipe_nr);	/* locate pipe */
 
 		if (pipe == NULL) {		/* new pipe */
@@ -418,11 +434,9 @@ config_pipe(struct dn_pipe *p)
 			SLIST_INSERT_HEAD(&pipehash[HASH(pipe->pipe_nr)],
 			    pipe, next);
 		}
-		DUMMYNET_UNLOCK();
 	} else {				/* config queue */
 		struct dn_flow_set *fs;
 
-		DUMMYNET_LOCK();
 		fs = ipdn_locate_flowset(pfs->fs_nr); /* locate flow_set */
 
 		if (fs == NULL) {		/* new */
@@ -469,8 +483,8 @@ config_pipe(struct dn_pipe *p)
 			SLIST_INSERT_HEAD(&flowsethash[HASH(fs->fs_nr)],
 			    fs, next);
 		}
-		DUMMYNET_UNLOCK();
 	}
+	DUMMYNET_UNLOCK();
 	return (0);
 }
 
@@ -719,6 +733,7 @@ ip_dn_ctl(struct sockopt *sopt)
 {
     int error;
     struct dn_pipe *p = NULL;
+    int l;
 
     error = priv_check(sopt->sopt_td, PRIV_NETINET_DUMMYNET);
     if (error)
@@ -726,14 +741,9 @@ ip_dn_ctl(struct sockopt *sopt)
 
     /* Disallow sets in really-really secure mode. */
     if (sopt->sopt_dir == SOPT_SET) {
-#if __FreeBSD_version >= 500034
 	error =  securelevel_ge(sopt->sopt_td->td_ucred, 3);
 	if (error)
 	    return (error);
-#else
-	if (securelevel >= 3)
-	    return (EPERM);
-#endif
     }
 
     switch (sopt->sopt_name) {
@@ -751,13 +761,20 @@ ip_dn_ctl(struct sockopt *sopt)
 	break ;
 
     case IP_DUMMYNET_CONFIGURE :
-	p = malloc(sizeof(struct dn_pipe_max), M_TEMP, M_WAITOK);
-	error = sooptcopyin(sopt, p, sizeof(struct dn_pipe_max), sizeof *p);
+	l = (sopt->sopt_dir == SOPT_SET) ? sopt->sopt_valsize :
+		*(int *)(sopt->sopt_valsize);
+	if (l < 0 || l > 12000) {
+		printf("argument too large, %d\n", l);
+		break;
+	}
+	printf("%s size %d\n", __FUNCTION__, l);
+	p = malloc(l, M_TEMP, M_WAITOK);
+	error = sooptcopyin(sopt, p, l, l);
 	if (error)
 	    break ;
-	if (p->samples_no > 0)
-	    p->samples = &(((struct dn_pipe_max *)p)->samples[0]);
 
+	error = do_config(p, l);
+	break;
 	error = config_pipe(p);
 	break ;
 

From owner-svn-src-user@FreeBSD.ORG  Thu Jan  7 20:40:39 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 1B2101065676;
	Thu,  7 Jan 2010 20:40:39 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 092448FC17;
	Thu,  7 Jan 2010 20:40:39 +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 o07KecFa059748;
	Thu, 7 Jan 2010 20:40:38 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o07KecHW059746;
	Thu, 7 Jan 2010 20:40:38 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001072040.o07KecHW059746@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Thu, 7 Jan 2010 20:40:38 +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: r201757 - user/luigi/ipfw3-head/sys/netinet/ipfw
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: Thu, 07 Jan 2010 20:40:39 -0000

Author: luigi
Date: Thu Jan  7 20:40:38 2010
New Revision: 201757
URL: http://svn.freebsd.org/changeset/base/201757

Log:
  add header to implement schedulers

Added:
  user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched.h   (contents, props changed)

Added: user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched.h	Thu Jan  7 20:40:38 2010	(r201757)
@@ -0,0 +1,215 @@
+/*
+ * Copyright (c) 2010 Riccardo Panicucci, Universita` di Pisa
+ * Copyright (c) 1998-2002,2010 Luigi Rizzo, Universita` di Pisa
+ * 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 AND CONTRIBUTORS ``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.
+ */
+
+/*
+ * The API to write a packet scheduling algorithm for dummynet.
+ */
+
+#ifndef _DN_SCHED_H
+#define _DN_SCHED_H
+
+// MALLOC_DECLARE(M_DUMMYNET);
+
+/*
+ * Descriptor for the scheduler.
+ * Contains all function pointers for a given scheduler
+ * This is typically created when a module is loaded, and stored
+ * in a global list of schedulers.
+ */
+struct dn_sched {
+	int type;           /* the scheduler type */
+	const char *name;   /* scheduler name */
+	int ref_count;      /* number of instances in the system */
+
+	/*
+	 * The following define the size of 4 optional data structures
+	 * that may need to be allocated at runtime:
+	 */
+
+	/*    + parameters attached to the template, e.g.
+	 *	default queue sizes, weights, quantum size, and so on;
+	 */
+	size_t scheduler_size;      // sch_arg
+
+	/*    + per-instance parameters, such as timestamps,
+	 *	ccontainers for queues, etc;
+	 */
+	size_t scheduler_i_size;    // sch_runtime
+
+	/*    + per-flowset parameters, such as individual weights,
+	 *	priorities, queue limits, slot sizes...
+	 */
+	size_t flowset_size;        // fs_arg
+
+	/*    + per-queue parameters (what for ?)
+	 */
+	size_t queue_size;          // queue_arg
+
+	SLIST_ENTRY(dn_sched) next; /* Next scheduler in the list */
+
+	/*
+	 * Methods implemented by the scheduler:
+	 * enqueue	enqueue packet 'm' on scheduler 's'. 'id' is
+	 *	the flow id of the packet, 'f' contains
+	 *	flowset-specific data. Must returns 1 if the packet
+	 *	is NOT enqueued.
+	 *
+	 * dequeue	Called when scheduler instance 's' can
+	 *	dequeue a packet. Return NULL if none are available.
+	 *	XXX what about non work-conserving ?
+	 *
+	 * config	called on 'sched X config ...'
+	 *	updates the field sch_arg
+	 *
+	 * destroy	called on 'sched delete', frees everything
+	 *	in sch_arg (other parts are handled by more specific
+	 *	functions)
+	 *
+	 * new_sched    called when a new instance is
+	 *	created by find_scheduler.
+	 *	Updates sch_runtime
+	 *
+	 * free_sched	called when deleting an instance
+	 *	cleans everything linked to sch_runtime
+	 *
+	 * new_fs    called on 'queue XX config', create fs_arg
+	 *	if the reconfigure flag is set, it means that
+	 *	the fs_arg already exists and need to be update
+	 *
+	 * free_fs    called on 'queue XX delete', frees things in
+	 *	fs_arg. Also called on a 'queue XX config' if the
+	 *	scheduler is different from what was previously.
+	 *
+	 * new_queue	called to link a new queue to sch_runtime
+	 *	can be used to set queue variables e.g. virtual times,
+	 *	update sum of weights, etc.
+	 *
+	 * free_queue	called to unlink a queue from sch_runtime
+	 *	possibly update sum of weights, etc.
+	 *
+	 *  drain_queue     called to free all idle queues, or possibly all of
+	 *                  them (this is a subset of delete_scheduler_instance)
+	 */
+	int (*enqueue)(void *s, struct gen *f, struct mbuf *m,
+		    struct ipfw_flow_id *id);
+	struct mbuf * (*dequeue)(void *s);
+
+	int (*config)(char *command, void *sch, int reconfigure);
+	int (*destroy)(void* sch);
+	int (*new_sched)(void *v);
+	int (*free_sched)(void *s);
+
+	int (*new_fs)(char *command, struct gen *g, int reconfigure);
+	int (*free_fs)(struct gen *f);
+
+	int (*new_queue)(struct new_queue *q, struct gen *f);
+	int (*free_queue)(struct new_queue *q);
+
+	int (*drain_queue)(void *s, int flag);
+};
+SLIST_HEAD(scheduler_head, dn_sched);
+
+/*
+ * Additionally, dummynet exports some variables, functions and macros
+ * to be used by schedulers.
+ */
+
+/*
+ * You must call dn_pkt_done() when extracting packets from a queue.
+ * The function is used to update packet and queue statistics.
+ * - pkt:   packet to return;
+ * - q:     packet belongs to this queue
+ */
+struct mbuf* dn_pkt_done(struct mbuf *pkt, struct new_queue *q);
+
+/* Called to delete a queue 'q'. If packet belong to this queue should be
+ * reenqueued, the 'reenqueue' should be set to 1
+ */
+int dn_delete_queue (struct new_queue *q, int reenqueue);
+
+/* Called by enqueue() when it needs to create a new queue.
+ * - f:     extension of the flowset.
+ * - s:     scheduler specific scheduler instance data
+ * - i:     index of the hash table, or 0 if no hash table is used
+ * - id:    flow id for this queue
+ * - size:  size of the queue, including the private data 
+ */
+struct new_queue * dn_create_queue(struct gen *f, void *s, int i,
+                                    struct ipfw_flow_id *id);
+
+/*  Allocate an hash table.
+ * Returns the pointer to the table
+ * - rq_size:       the returned size of table
+ * - rq_elements:   the number of elements present in the table
+ * - bucket:        the desidered size of the table
+ */
+struct new_queue ** dn_alloc_hash_queue(int *rq_size, int *rq_elements,
+                                         int bucket);
+
+/* Delete all packets from queue 'q' */
+int dn_purge_queue(struct new_queue *q);
+
+/* Really enqueue the packet 'm' into queue 'q'.
+ * If the packet is dropped, the function returns 1
+ */
+int dn_queue_packet(struct new_queue *q, struct mbuf* m);
+
+/* Drop a packet 'm' that belong to queue 'q'
+ * NOTE: q should be NULL if the queue doesn't exist
+ */
+int dn_drop_packet(struct new_queue *q, struct mbuf* m);
+
+/* Returns the index of array of hash table.
+ * The hash is done using flowset pointer and the flow id of the packet.
+ * - id:        flow id
+ * - f:         pointer to the flowset (private data)
+ * - rq_size:   size of the hash table
+ */
+int dn_i_hash_id(struct ipfw_flow_id *id, struct gen *f, int rq_size);
+
+/* Returns the queue that match the flowid at the index i, if exists.
+ * Returns NULL if the queue doesn't exist.
+ * - id:    flow id of the packet
+ * - i:     index of the hash table
+ * - rq:    pointer to the hash table
+ * - f:     pointer to flowset scheduler specific data. Used to access to
+ *          the flowset generic data
+ */
+struct new_queue * dn_q_hash_id(struct ipfw_flow_id *id, int i,
+                                 struct new_queue **rq, struct gen *f);
+
+int dn_sched_modevent(module_t mod, int cmd, void *arg);
+
+#define DECLARE_DNSCHED_MODULE(name, dnsched)			\
+	static moduledata_t name##_mod = {			\
+		#name, dn_sched_modevent, dnsched		\
+	};							\
+	DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS,	\
+		 SI_ORDER_MIDDLE); 				\
+        MODULE_DEPEND(name, dummynet, 3, 3, 3);
+
+#endif /* _DN_SCHED_H */

From owner-svn-src-user@FreeBSD.ORG  Thu Jan  7 22:59:08 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 C0AEB106566B;
	Thu,  7 Jan 2010 22:59:08 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id B035D8FC1A;
	Thu,  7 Jan 2010 22:59:08 +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 o07Mx81L090521;
	Thu, 7 Jan 2010 22:59:08 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o07Mx8UF090519;
	Thu, 7 Jan 2010 22:59:08 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001072259.o07Mx8UF090519@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Thu, 7 Jan 2010 22:59:08 +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: r201761 - user/ed/utmpx/sys/kern
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: Thu, 07 Jan 2010 22:59:08 -0000

Author: ed
Date: Thu Jan  7 22:59:08 2010
New Revision: 201761
URL: http://svn.freebsd.org/changeset/base/201761

Log:
  Remove the pts(4) device limit now that utmpx supports more.

Modified:
  user/ed/utmpx/sys/kern/tty_pts.c

Modified: user/ed/utmpx/sys/kern/tty_pts.c
==============================================================================
--- user/ed/utmpx/sys/kern/tty_pts.c	Thu Jan  7 21:14:46 2010	(r201760)
+++ user/ed/utmpx/sys/kern/tty_pts.c	Thu Jan  7 22:59:08 2010	(r201761)
@@ -71,7 +71,7 @@ __FBSDID("$FreeBSD$");
  * UT_LINESIZE.
  */
 static struct unrhdr *pts_pool;
-static unsigned int pts_maxdev = 999;
+static unsigned int pts_maxdev = INT_MAX;
 SYSCTL_UINT(_kern, OID_AUTO, pts_maxdev, CTLFLAG_RW, &pts_maxdev, 0,
     "Maximum amount of pts(4) pseudo-terminals");
 

From owner-svn-src-user@FreeBSD.ORG  Thu Jan  7 23:17:48 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 E9BD21065692;
	Thu,  7 Jan 2010 23:17:48 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id D76358FC12;
	Thu,  7 Jan 2010 23:17:48 +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 o07NHmBC094665;
	Thu, 7 Jan 2010 23:17:48 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o07NHmnP094661;
	Thu, 7 Jan 2010 23:17:48 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001072317.o07NHmnP094661@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Thu, 7 Jan 2010 23:17:48 +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: r201762 - user/luigi/ipfw3-head/sys/netinet/ipfw
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: Thu, 07 Jan 2010 23:17:49 -0000

Author: luigi
Date: Thu Jan  7 23:17:48 2010
New Revision: 201762
URL: http://svn.freebsd.org/changeset/base/201762

Log:
  snapshot of current version

Modified:
  user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched.h
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched.h
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched.h	Thu Jan  7 22:59:08 2010	(r201761)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched.h	Thu Jan  7 23:17:48 2010	(r201762)
@@ -114,7 +114,7 @@ struct dn_sched {
 	 *  drain_queue     called to free all idle queues, or possibly all of
 	 *                  them (this is a subset of delete_scheduler_instance)
 	 */
-	int (*enqueue)(void *s, struct gen *f, struct mbuf *m,
+	int (*enqueue)(void *s, struct dn_id *f, struct mbuf *m,
 		    struct ipfw_flow_id *id);
 	struct mbuf * (*dequeue)(void *s);
 
@@ -123,15 +123,15 @@ struct dn_sched {
 	int (*new_sched)(void *v);
 	int (*free_sched)(void *s);
 
-	int (*new_fs)(char *command, struct gen *g, int reconfigure);
-	int (*free_fs)(struct gen *f);
+	int (*new_fs)(char *command, struct dn_id *g, int reconfigure);
+	int (*free_fs)(struct dn_id *f);
 
-	int (*new_queue)(struct new_queue *q, struct gen *f);
+	int (*new_queue)(struct new_queue *q, struct dn_id *f);
 	int (*free_queue)(struct new_queue *q);
 
 	int (*drain_queue)(void *s, int flag);
 };
-SLIST_HEAD(scheduler_head, dn_sched);
+SLIST_HEAD(dn_sched_head, dn_sched);
 
 /*
  * Additionally, dummynet exports some variables, functions and macros
@@ -158,7 +158,7 @@ int dn_delete_queue (struct new_queue *q
  * - id:    flow id for this queue
  * - size:  size of the queue, including the private data 
  */
-struct new_queue * dn_create_queue(struct gen *f, void *s, int i,
+struct new_queue * dn_create_queue(struct dn_id *f, void *s, int i,
                                     struct ipfw_flow_id *id);
 
 /*  Allocate an hash table.
@@ -189,7 +189,7 @@ int dn_drop_packet(struct new_queue *q, 
  * - f:         pointer to the flowset (private data)
  * - rq_size:   size of the hash table
  */
-int dn_i_hash_id(struct ipfw_flow_id *id, struct gen *f, int rq_size);
+int dn_i_hash_id(struct ipfw_flow_id *id, struct dn_id *f, int rq_size);
 
 /* Returns the queue that match the flowid at the index i, if exists.
  * Returns NULL if the queue doesn't exist.
@@ -200,7 +200,7 @@ int dn_i_hash_id(struct ipfw_flow_id *id
  *          the flowset generic data
  */
 struct new_queue * dn_q_hash_id(struct ipfw_flow_id *id, int i,
-                                 struct new_queue **rq, struct gen *f);
+                                 struct new_queue **rq, struct dn_id *f);
 
 int dn_sched_modevent(module_t mod, int cmd, void *arg);
 

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c	Thu Jan  7 22:59:08 2010	(r201761)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c	Thu Jan  7 23:17:48 2010	(r201762)
@@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
 #include <netinet/ipfw/dn_heap.h>
 #include <netinet/ip_dummynet.h>
 #include <netinet/ipfw/ip_dn_private.h>
+#include <netinet/ipfw/dn_sched.h>
 
 #include <netinet/if_ether.h> /* various ether_* routines */
 
@@ -86,12 +87,11 @@ struct dn_parms dn_cfg = {
 	.red_max_pkt_size = 1500,     /* RED - default max packet size */
 };
 
-//static struct timeval t;
-static long tick_last;			/* Last tick duration (usec). */
-static long tick_delta;			/* Last vs standard tick diff (usec). */
-static long tick_delta_sum;		/* Accumulated tick difference (usec).*/
-static long tick_adjustment;		/* Tick adjustments done. */
-static long tick_lost;			/* Lost(coalesced) ticks number. */
+//static long tick_last;		/* Last tick duration (usec). */
+static long tick_delta;		/* Last vs standard tick diff (usec). */
+static long tick_delta_sum;	/* Accumulated tick difference (usec).*/
+static long tick_adjustment;	/* Tick adjustments done. */
+static long tick_lost;		/* Lost(coalesced) ticks number. */
 /* Adjusted vs non-adjusted curr_time difference (ticks). */
 static long tick_diff;
 
@@ -100,6 +100,13 @@ static unsigned long	io_pkt_fast;
 static unsigned long	io_pkt_drop;
 
 /*
+ * We use a heap to store entities for which we have pending timer events.
+ * The heap is checked at every tick and all entities with expired events
+ * are extracted.
+ */
+static struct dn_heap *system_heap;
+
+/*
  * Three heaps contain queues and pipes that the scheduler handles:
  *
  * ready_heap contains all dn_flow_queue related to fixed-rate pipes.
@@ -125,7 +132,7 @@ static unsigned long	io_pkt_drop;
  * (a better name would be useful...).
  */
 #define MAX64(x,y)  (( (int64_t) ( (y)-(x) )) > 0 ) ? (y) : (x)
-#define MY_M    16 /* number of left shift to obtain a larger precision */
+#define MY_M    16 /* shift for fixed point arithmetic */
   
 /*
  * XXX With this scaling, max 1000 flows, max weight 100, 1Gbit/s, the
@@ -134,16 +141,9 @@ static unsigned long	io_pkt_drop;
 
 MALLOC_DEFINE(M_DUMMYNET, "dummynet", "dummynet heap");
 
-static void	transmit_event(struct dn_pipe *pipe, struct mbuf **head,
-		    struct mbuf **tail);
-static void	ready_event(struct dn_flow_queue *q, struct mbuf **head,
-		    struct mbuf **tail);
-static void	ready_event_wfq(struct dn_pipe *p, struct mbuf **head,
-		    struct mbuf **tail);
-
 struct dn_heap ready_heap, extract_heap, wfq_ready_heap ;
-struct dn_pipe_head	pipehash[DN_HASHSIZE];	/* all pipes */
-struct dn_flow_set_head	flowsethash[DN_HASHSIZE];	/* all flowsets */
+struct new_pipe_head	pipehash[DN_HASHSIZE];	/* all pipes */
+struct new_fs_head	flowsethash[DN_HASHSIZE];	/* all flowsets */
 
 extern	void (*bridge_dn_p)(struct mbuf *, struct ifnet *);
 
@@ -244,11 +244,11 @@ struct dn_pkt_tag {
 	struct ipfw_rule_ref rule;	/* matching rule		*/
 
 	/* second part, dummynet specific */
-	int dn_dir;		/* action when packet comes out.	*/
-				/* see ip_fw_private.h			*/
-	dn_key output_time;	/* when the pkt is due for delivery	*/
-	struct ifnet *ifp;	/* interface, for ip_output		*/
-	struct _ip6dn_args ip6opt;	/* XXX ipv6 options		*/
+	int dn_dir;		/* action when packet comes out.*/
+				/* see ip_fw_private.h		*/
+	dn_key output_time;	/* when the pkt is due for delivery*/
+	struct ifnet *ifp;	/* interface, for ip_output	*/
+	struct _ip6dn_args ip6opt;	/* XXX ipv6 options	*/
 };
 
 /*
@@ -268,55 +268,43 @@ dn_tag_get(struct mbuf *m)
 }
 
 /*
- * Scheduler functions:
- *
- * transmit_event() is called when the delay-line needs to enter
- * the scheduler, either because of existing pkts getting ready,
- * or new packets entering the queue. The event handled is the delivery
- * time of the packet.
- *
- * ready_event() does something similar with fixed-rate queues, and the
- * event handled is the finish time of the head pkt.
- *
- * wfq_ready_event() does something similar with WF2Q queues, and the
- * event handled is the start time of the head pkt.
- *
- * In all cases, we make sure that the data structures are consistent
- * before passing pkts out, because this might trigger recursive
- * invocations of the procedures.
+ * It is called when we have some packet from delay line to send.
+ * If there are leftover packets, this delay line is reinserted into extract
+ * heap
  */
-static void
-transmit_event(struct dn_pipe *pipe, struct mbuf **head, struct mbuf **tail)
+static
+struct mbuf *
+transmit_event(struct delay_line *dline, dn_key l_curr_time)
 {
-	struct mbuf *m;
-	struct dn_pkt_tag *pkt;
-
-	DUMMYNET_LOCK_ASSERT();
+    struct mbuf *m;
+    struct dn_pkt_tag *pkt;
 
-	while ((m = pipe->head) != NULL) {
-		pkt = dn_tag_get(m);
-		if (!DN_KEY_LEQ(pkt->output_time, curr_time))
-			break;
+    struct mbuf *head = NULL, *tail = NULL;
+    /* XXX scheduler lock */
+    while ((m = dline->head) != NULL) {
+        pkt = dn_tag_get(m);
+        if (!DN_KEY_LEQ(pkt->output_time, l_curr_time))
+            break;
+        dline->head = m->m_nextpkt;
+        if (tail != NULL)
+            tail->m_nextpkt = m;
+        else
+            head = m;
+        tail = m;
+    }
 
-		pipe->head = m->m_nextpkt;
-		if (*tail != NULL)
-			(*tail)->m_nextpkt = m;
-		else
-			*head = m;
-		*tail = m;
-	}
-	if (*tail != NULL)
-		(*tail)->m_nextpkt = NULL;
+    if (tail != NULL)
+        tail->m_nextpkt = NULL;
 
-	/* If there are leftover packets, put into the heap for next event. */
-	if ((m = pipe->head) != NULL) {
-		pkt = dn_tag_get(m);
-		/*
-		 * XXX Should check errors on heap_insert, by draining the
-		 * whole pipe p and hoping in the future we are more successful.
-		 */
-		heap_insert(&extract_heap, pkt->output_time, pipe);
-	}
+    /* If there are leftover packets, put into the heap for next event. */
+    if ((m = dline->head) != NULL) {
+        pkt = dn_tag_get(m);
+        //DN_HEAP_LOCK();
+        heap_insert(system_heap, pkt->output_time, dline);
+        //DN_HEAP_UNLOCK();
+    }
+    /* XXX scheduler unlock */
+    return head;
 }
 
 #define div64(a, b)	((int64_t)(a) / (int64_t)(b))
@@ -345,7 +333,7 @@ set_ticks(struct mbuf *m, struct dn_flow
  * so we need to divide by 1000.
  */
 static dn_key
-compute_extra_bits(struct mbuf *pkt, struct dn_pipe *p)
+compute_extra_bits(struct mbuf *pkt, struct new_pipe *p)
 {
 	int index;
 	dn_key extra_bits;
@@ -362,253 +350,27 @@ compute_extra_bits(struct mbuf *pkt, str
 	return extra_bits;
 }
 
-/*
- * extract pkt from queue, compute output time (could be now)
- * and put into delay line (p_queue)
- */
+/* Insert packet pkt into delay line of si. */
 static void
-move_pkt(struct mbuf *pkt, struct dn_flow_queue *q, struct dn_pipe *p,
-    int len)
+move_pkt(struct mbuf *pkt, struct new_pipe *p, struct new_sch_inst *si,
+          dn_key l_curr_time)
 {
     struct dn_pkt_tag *dt = dn_tag_get(pkt);
+    struct delay_line *d = si->dline;
+ 
+    dt->output_time = l_curr_time + p->delay ;
 
-    q->head = pkt->m_nextpkt ;
-    q->len-- ;
-    q->len_bytes -= len ;
-
-    dt->output_time = curr_time + p->delay ;
-
-    if (p->head == NULL)
-	p->head = pkt;
+    if (d->head == NULL)
+        d->head = pkt;
     else
-	p->tail->m_nextpkt = pkt;
-    p->tail = pkt;
-    p->tail->m_nextpkt = NULL;
-}
-
-/*
- * ready_event() is invoked every time the queue must enter the
- * scheduler, either because the first packet arrives, or because
- * a previously scheduled event fired.
- * On invokation, drain as many pkts as possible (could be 0) and then
- * if there are leftover packets reinsert the pkt in the scheduler.
- */
-static void
-ready_event(struct dn_flow_queue *q, struct mbuf **head, struct mbuf **tail)
-{
-	struct mbuf *pkt;
-	struct dn_pipe *p = q->fs->pipe;
-	int p_was_empty;
-
-	DUMMYNET_LOCK_ASSERT();
-
-	if (p == NULL) {
-		printf("dummynet: ready_event- pipe is gone\n");
-		return;
-	}
-	p_was_empty = (p->head == NULL);
-
-	/*
-	 * Schedule fixed-rate queues linked to this pipe:
-	 * account for the bw accumulated since last scheduling, then
-	 * drain as many pkts as allowed by q->numbytes and move to
-	 * the delay line (in p) computing output time.
-	 * bandwidth==0 (no limit) means we can drain the whole queue,
-	 * setting len_scaled = 0 does the job.
-	 */
-	q->numbytes += (curr_time - q->sched_time) * p->bandwidth;
-	while ((pkt = q->head) != NULL) {
-		int len = pkt->m_pkthdr.len;
-		dn_key len_scaled = p->bandwidth ? len*8*hz
-			+ q->extra_bits*hz
-			: 0;
-
-		if (DN_KEY_GT(len_scaled, q->numbytes))
-			break;
-		q->numbytes -= len_scaled;
-		move_pkt(pkt, q, p, len);
-		if (q->head)
-			q->extra_bits = compute_extra_bits(q->head, p);
-	}
-	/*
-	 * If we have more packets queued, schedule next ready event
-	 * (can only occur when bandwidth != 0, otherwise we would have
-	 * flushed the whole queue in the previous loop).
-	 * To this purpose we record the current time and compute how many
-	 * ticks to go for the finish time of the packet.
-	 */
-	if ((pkt = q->head) != NULL) {	/* this implies bandwidth != 0 */
-		dn_key t = set_ticks(pkt, q, p); /* ticks i have to wait */
-
-		q->sched_time = curr_time;
-		heap_insert(&ready_heap, curr_time + t, (void *)q);
-		/*
-		 * XXX Should check errors on heap_insert, and drain the whole
-		 * queue on error hoping next time we are luckier.
-		 */
-	} else		/* RED needs to know when the queue becomes empty. */
-		q->idle_time = curr_time;
-
-	/*
-	 * If the delay line was empty call transmit_event() now.
-	 * Otherwise, the scheduler will take care of it.
-	 */
-	if (p_was_empty)
-		transmit_event(p, head, tail);
-}
-
-/* callback to clean the idle heap */
-static int
-clean_fq(void *_q, uintptr_t arg)
-{
-	struct dn_flow_queue *q = _q;
-
-	q->F = 0;
-	q->S = q->F + 1;
-	return HEAP_SCAN_DEL;
+        d->tail->m_nextpkt = pkt;
+    d->tail = pkt;
+    d->tail->m_nextpkt = NULL;
 }
 
-/*
- * Called when we can transmit packets on WF2Q queues. Take pkts out of
- * the queues at their start time, and enqueue into the delay line.
- * Packets are drained until p->numbytes < 0. As long as
- * len_scaled >= p->numbytes, the packet goes into the delay line
- * with a deadline p->delay. For the last packet, if p->numbytes < 0,
- * there is an additional delay.
- */
-static void
-ready_event_wfq(struct dn_pipe *p, struct mbuf **head, struct mbuf **tail)
-{
-	int p_was_empty = (p->head == NULL);
-	struct dn_heap *sch = p->scheduler_heap;
-	struct dn_heap *neh = p->not_eligible_heap;
-	int64_t p_numbytes = p->numbytes;
-
-	/*
-	 * p->numbytes is only 32bits in FBSD7, but we might need 64 bits.
-	 * Use a local variable for the computations, and write back the
-	 * results when done, saturating if needed.
-	 * The local variable has no impact on performance and helps
-	 * reducing diffs between the various branches.
-	 */
-
-	DUMMYNET_LOCK_ASSERT();
-
-	if (p->if_name[0] == 0)		/* tx clock is simulated */
-		p_numbytes += (curr_time - p->sched_time) * p->bandwidth;
-	else {	/*
-		 * tx clock is for real,
-		 * the ifq must be empty or this is a NOP.
-		 */
-		if (p->ifp && p->ifp->if_snd.ifq_head != NULL)
-			return;
-		else {
-			DPRINTF(("dummynet: pipe %d ready from %s --\n",
-			    p->pipe_nr, p->if_name));
-		}
-	}
-
-	/*
-	 * While we have backlogged traffic AND credit, we need to do
-	 * something on the queue.
-	 */
-	while (p_numbytes >= 0 && (sch->elements > 0 || neh->elements > 0)) {
-		if (sch->elements > 0) {
-			/* Have some eligible pkts to send out. */
-			struct dn_flow_queue *q = HEAP_TOP(sch)->object;
-			struct mbuf *pkt = q->head;
-			struct dn_flow_set *fs = q->fs;
-			uint64_t len = pkt->m_pkthdr.len;
-			int len_scaled = p->bandwidth ? len * 8 * hz : 0;
-
-			heap_extract(sch, NULL); /* Remove queue from heap. */
-			p_numbytes -= len_scaled;
-			move_pkt(pkt, q, p, len);
-
-			p->V += div64((len << MY_M), p->sum);	/* Update V. */
-			q->S = q->F;			/* Update start time. */
-			if (q->len == 0) {
-				/* Flow not backlogged any more. */
-				fs->backlogged--;
-				heap_insert(p->idle_heap, q->F, q);
-			} else {
-				/* Still backlogged. */
-
-				/*
-				 * Update F and position in backlogged queue,
-				 * then put flow in not_eligible_heap
-				 * (we will fix this later).
-				 */
-				len = (q->head)->m_pkthdr.len;
-				q->F += div64((len << MY_M), fs->weight);
-				if (DN_KEY_LEQ(q->S, p->V))
-					heap_insert(neh, q->S, q);
-				else
-					heap_insert(sch, q->F, q);
-			}
-		}
-		/*
-		 * Now compute V = max(V, min(S_i)). Remember that all elements
-		 * in sch have by definition S_i <= V so if sch is not empty,
-		 * V is surely the max and we must not update it. Conversely,
-		 * if sch is empty we only need to look at neh.
-		 */
-		if (sch->elements == 0 && neh->elements > 0)
-			p->V = MAX64(p->V, HEAP_TOP(neh)->key);
-		/* Move from neh to sch any packets that have become eligible */
-		while (neh->elements > 0 && DN_KEY_LEQ(HEAP_TOP(neh)->key, p->V)) {
-			struct dn_flow_queue *q = HEAP_TOP(neh)->object;
-			heap_extract(neh, NULL);
-			heap_insert(sch, q->F, q);
-		}
-
-		if (p->if_name[0] != '\0') { /* Tx clock is from a real thing */
-			p_numbytes = -1;	/* Mark not ready for I/O. */
-			break;
-		}
-	}
-	if (sch->elements == 0 && neh->elements == 0 && p_numbytes >= 0) {
-		p->idle_time = curr_time;
-		/*
-		 * No traffic and no events scheduled.
-		 * We can get rid of idle-heap.
-		 */
-		if (p->idle_heap->elements > 0) {
-			heap_scan(p->idle_heap, clean_fq, 0);
-			p->sum = 0;
-			p->V = 0;
-			p->idle_heap->elements = 0;
-		}
-	}
-	/*
-	 * If we are getting clocks from dummynet (not a real interface) and
-	 * If we are under credit, schedule the next ready event.
-	 * Also fix the delivery time of the last packet.
-	 */
-	if (p->if_name[0]==0 && p_numbytes < 0) { /* This implies bw > 0. */
-		dn_key t = 0;		/* Number of ticks i have to wait. */
-
-		if (p->bandwidth > 0)
-			t = div64(p->bandwidth - 1 - p_numbytes, p->bandwidth);
-		dn_tag_get(p->tail)->output_time += t;
-		p->sched_time = curr_time;
-		heap_insert(&wfq_ready_heap, curr_time + t, (void *)p);
-		/*
-		 * XXX Should check errors on heap_insert, and drain the whole
-		 * queue on error hoping next time we are luckier.
-		 */
-	}
-
-	/* Write back p_numbytes (adjust 64->32bit if necessary). */
-	p->numbytes = p_numbytes;
-
-	/*
-	 * If the delay line was empty call transmit_event() now.
-	 * Otherwise, the scheduler will take care of it.
-	 */
-	if (p_was_empty)
-		transmit_event(p, head, tail);
-}
+struct new_sch_inst *
+find_scheduler(struct new_sch *sch_t, struct new_fs *fs,
+                struct ipfw_flow_id *id, dn_key l_curr_time);
 
 /*
  * The timer handler for dummynet. Time is computed in ticks, but
@@ -618,8 +380,9 @@ ready_event_wfq(struct dn_pipe *p, struc
 void
 dummynet_task(void *context, int pending)
 {
+#if 0
 	struct mbuf *head = NULL, *tail = NULL;
-	struct dn_pipe *pipe;
+	struct new_pipe *pipe;
 	struct dn_heap *heaps[3];
 	struct dn_heap *h;
 	void *p;	/* generic parameter to handler */
@@ -713,7 +476,7 @@ dummynet_task(void *context, int pending
 
 	if (head != NULL)
 		dummynet_send(head);
-
+#endif
 	dn_reschedule();
 }
 
@@ -800,6 +563,7 @@ dummynet_send(struct mbuf *m)
 	}
 }
 
+#if 0
 /*
  * Unconditionally expire empty queues in case of shortage.
  * Returns the number of queues freed.
@@ -1081,11 +845,12 @@ red_drops(struct dn_flow_set *fs, struct
 
 	return (0);	/* accept */
 }
+#endif
 
-struct dn_flow_set *
+struct new_fs *
 ipdn_locate_flowset(int fs_nr)
 {
-	struct dn_flow_set *fs;
+	struct new_fs *fs;
 
 	SLIST_FOREACH(fs, &flowsethash[HASH(fs_nr)], next)
 		if (fs->fs_nr == fs_nr)
@@ -1094,10 +859,10 @@ ipdn_locate_flowset(int fs_nr)
 	return (NULL);
 }
 
-struct dn_pipe *
+struct new_pipe *
 ipdn_locate_pipe(int pipe_nr)
 {
-	struct dn_pipe *pipe;
+	struct new_pipe *pipe;
 
 	SLIST_FOREACH(pipe, &pipehash[HASH(pipe_nr)], next)
 		if (pipe->pipe_nr == pipe_nr)
@@ -1106,6 +871,31 @@ ipdn_locate_pipe(int pipe_nr)
 	return (NULL);
 }
 
+struct ipfw_flow_id *
+do_mask(struct ipfw_flow_id *mask, struct ipfw_flow_id *id);
+/* Do masking depending of flow id */
+struct ipfw_flow_id *
+do_mask(struct ipfw_flow_id *mask, struct ipfw_flow_id *id)
+{
+    int is_v6 = IS_IP6_FLOW_ID(id);
+
+    id->dst_port &= mask->dst_port;
+    id->src_port &= mask->src_port;
+    id->proto &= mask->proto;
+    id->flags = 0; /* we don't care about this one */
+    if (is_v6) {
+        APPLY_MASK(&id->dst_ip6, &mask->dst_ip6);
+        APPLY_MASK(&id->src_ip6, &mask->src_ip6);
+        id->flow_id6 &= mask->flow_id6;
+    }
+    else {
+        id->dst_ip &= mask->dst_ip;
+        id->src_ip &= mask->src_ip;
+    }
+        
+    return id;
+}
+
 /*
  * dummynet hook for packets. Below 'pipe' is a pipe or a queue
  * depending on whether WF2Q or fixed bw is used.
@@ -1124,15 +914,19 @@ ipdn_locate_pipe(int pipe_nr)
 int
 dummynet_io(struct mbuf **m0, int dir, struct ip_fw_args *fwa)
 {
-	struct mbuf *m = *m0, *head = NULL, *tail = NULL;
+	struct mbuf *m = *m0, *head = NULL;
 	struct dn_pkt_tag *pkt;
 	struct m_tag *mtag;
-	struct dn_flow_set *fs = NULL;
-	struct dn_pipe *pipe = NULL;
-	uint64_t len = m->m_pkthdr.len;
-	struct dn_flow_queue *q = NULL;
+	struct new_fs *fs = NULL;
+	struct new_pipe *pipe = NULL;
+	struct new_queue *q = NULL;
 	int fs_id = fwa->rule.info & IPFW_INFO_MASK;
-	int is_pipe = 0;
+	struct new_sch *sch;
+	struct new_sch_inst *sch_inst;
+	struct delay_line *dline;
+	int ret;
+	dn_key l_curr_time; /* save a copy of curr_time */
+	int delay_line_idle;
 
 	if (fwa->rule.info & IPFW_IS_PIPE)
 		fs_id += DN_PIPEOFFSET;
@@ -1146,10 +940,10 @@ dummynet_io(struct mbuf **m0, int dir, s
 
 	if (fs == NULL)
 		goto dropit;	/* This queue/pipe does not exist! */
-#if 0
+
 	if (fs->sched_id != dn_cfg.id) {
 		/* configuration changed, update */
-		int ret = reconfigure(fs);
+		int ret = dn_fs_config(fs);
 		if (ret)
 			goto dropit;
 		/* find again, just in case things changed */
@@ -1160,25 +954,19 @@ dummynet_io(struct mbuf **m0, int dir, s
 	sch = fs->sched;
 	if (sch == NULL)
 		goto dropit;
-#endif
-	q = find_queue(fs, &(fwa->f_id));
-	if (q == NULL)
-		goto dropit;		/* Cannot allocate queue. */
-
-	/* Update statistics, then check reasons to drop pkt. */
-	q->tot_bytes += len;
-	q->tot_pkts++;
-	if (fs->plr && random() < fs->plr)
-		goto dropit;		/* Random pkt drop. */
-	if (fs->flags_fs & DN_QSIZE_IS_BYTES) {
-		if (q->len_bytes > fs->qsize)
-			goto dropit;	/* Queue size overflow. */
-	} else {
-		if (q->len >= fs->qsize)
-			goto dropit;	/* Queue count overflow. */
-	}
-	if (fs->flags_fs & DN_IS_RED && red_drops(fs, q, len))
+	pipe = sch->pipe;
+	if (pipe == NULL)	/* should not happen ? */
+		goto dropit;
+
+	l_curr_time = curr_time;
+	sch_inst = find_scheduler(sch, fs, &(fwa->f_id), l_curr_time);
+	if (sch_inst == NULL)
 		goto dropit;
+	dline = sch_inst->dline;
+	delay_line_idle = (dline->head == NULL);
+
+	/* Now do the masking */
+	do_mask(&fs->flow_mask, &(fwa->f_id));
 
 	/* tag the mbuf */
 	mtag = m_tag_get(PACKET_TAG_DUMMYNET,
@@ -1197,128 +985,96 @@ dummynet_io(struct mbuf **m0, int dir, s
 	pkt->dn_dir = dir;
 	pkt->ifp = fwa->oif;
 
-	if (q->head == NULL)
-		q->head = m;
-	else
-		q->tail->m_nextpkt = m;
-	q->tail = m;
-	q->len++;
-	q->len_bytes += len;
-
-	if (q->head != m)		/* Flow was not idle, we are done. */
-		goto done;
-
-	if (is_pipe) {			/* Fixed rate queues. */
-		if (q->idle_time < curr_time) {
-			/* Calculate available burst size. */
-			q->numbytes +=
-			    (curr_time - q->idle_time - 1) * pipe->bandwidth;
-			if (q->numbytes > pipe->burst)
-				q->numbytes = pipe->burst;
-			if (dn_cfg.io_fast)
-				q->numbytes += pipe->bandwidth;
-		}
-	} else {			/* WF2Q. */
-		if (pipe->idle_time < curr_time &&
-		    pipe->scheduler_heap->elements == 0 &&
-		    pipe->not_eligible_heap->elements == 0) {
-			/* Calculate available burst size. */
-			pipe->numbytes +=
-			    (curr_time - pipe->idle_time - 1) * pipe->bandwidth;
-			if (pipe->numbytes > 0 && pipe->numbytes > pipe->burst)
-				pipe->numbytes = pipe->burst;
-			if (dn_cfg.io_fast)
-				pipe->numbytes += pipe->bandwidth;
-		}
-		pipe->idle_time = curr_time;
-	}
-	/* Necessary for both: fixed rate & WF2Q queues. */
-	q->idle_time = curr_time;
-
 	/*
-	 * If we reach this point the flow was previously idle, so we need
-	 * to schedule it. This involves different actions for fixed-rate or
-	 * WF2Q queues.
+	 * - 'sch_inst + 1' is the pointer to scheduler instance's
+	 *   private data, 'fs->alg_fs' is the flowset's private data,
+	 *   'm' is the packet, 'id' is the masked flowid of the packet
+	 *
+	 * NOTE: If the scheduler function wants really enqueue the
+	 *       packet, it must call the queue_packet()
 	 */
-	if (is_pipe) {
-		/* Fixed-rate queue: just insert into the ready_heap. */
-		dn_key t = 0;
-
-		if (pipe->bandwidth) {
-			q->extra_bits = compute_extra_bits(m, pipe);
-			t = set_ticks(m, q, pipe);
-		}
-		q->sched_time = curr_time;
-		if (t == 0)		/* Must process it now. */
-			ready_event(q, &head, &tail);
-		else
-			heap_insert(&ready_heap, curr_time + t , q);
-	} else {
-		/*
-		 * WF2Q. First, compute start time S: if the flow was
-		 * idle (S = F + 1) set S to the virtual time V for the
-		 * controlling pipe, and update the sum of weights for the pipe;
-		 * otherwise, remove flow from idle_heap and set S to max(F,V).
-		 * Second, compute finish time F = S + len / weight.
-		 * Third, if pipe was idle, update V = max(S, V).
-		 * Fourth, count one more backlogged flow.
-		 */
-		if (DN_KEY_GT(q->S, q->F)) { /* Means timestamps are invalid. */
-			q->S = pipe->V;
-			pipe->sum += fs->weight; /* Add weight of new queue. */
-		} else {
-			heap_extract(pipe->idle_heap, q);
-			q->S = MAX64(q->F, pipe->V);
-		}
-		q->F = q->S + div64(len << MY_M, fs->weight);
 
-		if (pipe->not_eligible_heap->elements == 0 &&
-		    pipe->scheduler_heap->elements == 0)
-			pipe->V = MAX64(q->S, pipe->V);
-		fs->backlogged++;
-		/*
-		 * Look at eligibility. A flow is not eligibile if S>V (when
-		 * this happens, it means that there is some other flow already
-		 * scheduled for the same pipe, so the scheduler_heap cannot be
-		 * empty). If the flow is not eligible we just store it in the
-		 * not_eligible_heap. Otherwise, we store in the scheduler_heap
-		 * and possibly invoke ready_event_wfq() right now if there is
-		 * leftover credit.
-		 * Note that for all flows in scheduler_heap (SCH), S_i <= V,
-		 * and for all flows in not_eligible_heap (NEH), S_i > V.
-		 * So when we need to compute max(V, min(S_i)) forall i in
-		 * SCH+NEH, we only need to look into NEH.
-		 */
-		if (DN_KEY_GT(q->S, pipe->V)) {		/* Not eligible. */
-			if (pipe->scheduler_heap->elements == 0)
-				printf("dummynet: ++ ouch! not eligible but empty scheduler!\n");
-			heap_insert(pipe->not_eligible_heap, q->S, q);
-		} else {
-			heap_insert(pipe->scheduler_heap, q->F, q);
-			if (pipe->numbytes >= 0) {	 /* Pipe is idle. */
-				if (pipe->scheduler_heap->elements != 1)
-					printf("dummynet: OUCH! pipe should have been idle!\n");
-				DPRINTF(("dummynet: waking up pipe %d at %d\n",
-				    pipe->pipe_nr, (int)(q->F >> MY_M)));
-				pipe->sched_time = curr_time;
-				ready_event_wfq(pipe, &head, &tail);
-			}
-		}
+	ret = sch->fp->enqueue(
+		(sch_inst + 1), fs->alg_fs, m,
+			&(fwa->f_id));
+
+	if (ret) { /* packet was dropped by enqueue() */
+		*m0 = NULL;
+		goto dropit;
 	}
-done:
-	if (head == m && (dir & PROTO_LAYER2) == 0 ) {
-		/* Fast io. */
-		io_pkt_fast++;
-		if (m->m_nextpkt != NULL)
-			printf("dummynet: fast io: pkt chain detected!\n");
-		head = m->m_nextpkt = NULL;
-	} else
-		*m0 = NULL;		/* Normal io. */
 
-	DUMMYNET_UNLOCK();
-	if (head != NULL)
-		dummynet_send(head);
-	return (0);
+   /*
+     * Now check if the dequeue should be called now.
+     * If the instance is in the heap, the dequeue() will be called later,
+     * else if the instance has credit the dequeue() is called now.
+     */
+    if (!(sch_inst->flags & DN_SCH_ACTIVE)) {
+        /* If the instance is not in the heap, credit must be >= 0 */
+        struct mbuf *tosend;
+        dn_key len_scaled;
+
+        /* If the instance isn't in the heap, it is idle, so we can skip
+         * some checks XXX
+         */
+        if (sch->burst) {
+            sch_inst->numbytes = (l_curr_time - sch_inst->idle_time) *
+                                    pipe->bandwidth;
+            if (sch_inst->numbytes > sch->burst)
+                sch_inst->numbytes = sch->burst;
+            sch_inst->numbytes += dn_cfg.io_fast ? pipe->bandwidth : 0;
+        } else
+            sch_inst->numbytes = dn_cfg.io_fast ? pipe->bandwidth : 0;
+
+        sch_inst->idle_time = l_curr_time;
+
+        /* Doing an 'if' instead of 'while' because only the packet
+         * just enqueued can be returned by dequeue() */
+        tosend = sch->fp->dequeue(sch_inst + 1);
+        if (tosend) {
+            len_scaled = pipe->bandwidth ? tosend->m_pkthdr.len * 8 * hz +
+                            compute_extra_bits(tosend, pipe) * hz : 0;
+            sch_inst->numbytes -= len_scaled;
+            /* Move packet in the delay line XXX three parameters? */
+            move_pkt(tosend, pipe, sch_inst, l_curr_time);
+            if (sch_inst->numbytes < 0) {
+                /*
+                 * Credit became negative, so insert the instance in the
+                 * heap so that it will not be wake up until credit come
+                 * back positive
+                 * NOTE: numbytes < 0 implies bandwidth != 0.
+                 */
+                dn_key t = 0, tmp;
+                t = (pipe->bandwidth - 1 - sch_inst->numbytes) /
+                                                   pipe->bandwidth;
+                /* Delay the output time because under credit */
+                (dn_tag_get(dline->tail))->output_time += t;
+
+                sch_inst->ptr_sched->inst_counter++;
+                sch_inst->flags |= DN_SCH_ACTIVE;
+                tmp = l_curr_time + t;
+                //DN_HEAP_LOCK();
+                heap_insert(system_heap, (uint64_t)tmp, sch_inst);
+                //DN_HEAP_UNLOCK();
+            }
+            if (delay_line_idle)
+                head = transmit_event(dline, l_curr_time);
+        }
+    }
+
+    if (dn_cfg.io_fast && head == m && (dir & PROTO_LAYER2) == 0 ) {
+	/* fast io */
+        io_pkt_fast++;
+        printf("dummynet TEST: ** IOFAST **\n");
+        if (m->m_nextpkt != NULL)
+            printf("dummynet: fast io: pkt chain detected!\n");
+        head = m->m_nextpkt = NULL;
+    } else
+        *m0 = NULL;
+    DUMMYNET_UNLOCK();
+    if (head != NULL)
+        dummynet_send(head);
+
+    return 0;
 
 dropit:
 	io_pkt_drop++;
@@ -1327,5 +1083,5 @@ dropit:
 	DUMMYNET_UNLOCK();
 	FREE_PKT(m);
 	*m0 = NULL;
-	return ((fs && (fs->flags_fs & DN_NOERROR)) ? 0 : ENOBUFS);
+	return ((fs && (fs->flags & DN_NOERROR)) ? 0 : ENOBUFS);
 }

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Thu Jan  7 22:59:08 2010	(r201761)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Thu Jan  7 23:17:48 2010	(r201762)
@@ -107,7 +107,7 @@ static __inline void dn_free_pkts(struct
 }
 
 static void
-free_pipe(struct dn_pipe *p)
+free_pipe(struct new_pipe *p)
 {
         if (p->samples)
                 free(p->samples, M_DUMMYNET);
@@ -121,9 +121,10 @@ free_pipe(struct dn_pipe *p)
  * For the one in dn_pipe MUST also cleanup ready_heap...
  */
 static void
-purge_flow_set(struct dn_flow_set *fs, int all)
+purge_flow_set(struct new_fs *fs, int all)
 {
-	struct dn_flow_queue *q, *qn;
+#if 0
+	struct new_queue *q, *qn;
 	int i;
 
 	DUMMYNET_LOCK_ASSERT();
@@ -148,6 +149,7 @@ purge_flow_set(struct dn_flow_set *fs, i
 		if (fs->pipe == NULL || fs != &(fs->pipe->fs))
 			free(fs, M_DUMMYNET);
 	}
+#endif
 }
 
 /*
@@ -156,9 +158,9 @@ purge_flow_set(struct dn_flow_set *fs, i
  * to be deleted.
  */
 static void
-purge_pipe(struct dn_pipe *pipe)
+purge_pipe(struct new_pipe *pipe)
 {
-
+#if 0
     purge_flow_set( &(pipe->fs), 1 );
 
     dn_free_pkts(pipe->head);
@@ -166,6 +168,7 @@ purge_pipe(struct dn_pipe *pipe)
     heap_free( pipe->scheduler_heap );
     heap_free( pipe->not_eligible_heap );
     heap_free( pipe->idle_heap );
+#endif
 }
 
 /*
@@ -175,8 +178,8 @@ purge_pipe(struct dn_pipe *pipe)
 static void
 dummynet_flush(void)
 {
-	struct dn_pipe *pipe, *pipe1;
-	struct dn_flow_set *fs, *fs1;
+	struct new_pipe *pipe, *pipe1;
+	struct new_fs *fs, *fs1;
 	int i;
 
 	DUMMYNET_LOCK();
@@ -192,12 +195,12 @@ dummynet_flush(void)
 	 */
 	for (i = 0; i < DN_HASHSIZE; i++)
 		SLIST_FOREACH_SAFE(fs, &flowsethash[i], next, fs1) {
-			SLIST_REMOVE(&flowsethash[i], fs, dn_flow_set, next);
+			SLIST_REMOVE(&flowsethash[i], fs, new_fs, next);
 			purge_flow_set(fs, 1);
 		}
 	for (i = 0; i < DN_HASHSIZE; i++)
 		SLIST_FOREACH_SAFE(pipe, &pipehash[i], next, pipe1) {
-			SLIST_REMOVE(&pipehash[i], pipe, dn_pipe, next);
+			SLIST_REMOVE(&pipehash[i], pipe, new_pipe, next);
 			purge_pipe(pipe);
 			free_pipe(pipe);
 		}
@@ -263,7 +266,8 @@ config_red(struct dn_flow_set *p, struct
 	return (0);
 }
 
-static int
+int alloc_hash(struct dn_flow_set *x, struct dn_flow_set *pfs);
+int
 alloc_hash(struct dn_flow_set *x, struct dn_flow_set *pfs)
 {
     if (x->flags_fs & DN_HAVE_FLOW_MASK) {     /* allocate some slots */
@@ -288,7 +292,8 @@ alloc_hash(struct dn_flow_set *x, struct
     return 0 ;
 }
 
-static void
+void set_fs_parms(struct dn_flow_set *x, struct dn_flow_set *src);
+void
 set_fs_parms(struct dn_flow_set *x, struct dn_flow_set *src)
 {
 	x->flags_fs = src->flags_fs;
@@ -333,6 +338,7 @@ do_config(void *p, int l)
 static int
 config_pipe(struct dn_pipe *p)
 {
+#if 0
 	struct dn_flow_set *pfs = &(p->fs);

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***

From owner-svn-src-user@FreeBSD.ORG  Thu Jan  7 23:28:59 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 005B0106566C;
	Thu,  7 Jan 2010 23:28:59 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id E27048FC13;
	Thu,  7 Jan 2010 23:28:58 +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 o07NSwUx097158;
	Thu, 7 Jan 2010 23:28:58 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o07NSwnn097152;
	Thu, 7 Jan 2010 23:28:58 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001072328.o07NSwnn097152@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Thu, 7 Jan 2010 23:28:58 +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: r201763 - user/ed/utmpx/lib/libc/gen
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: Thu, 07 Jan 2010 23:28:59 -0000

Author: ed
Date: Thu Jan  7 23:28:58 2010
New Revision: 201763
URL: http://svn.freebsd.org/changeset/base/201763

Log:
  Put conversion between futx and utmpx in a separate file.
  
  This allows me to get the return value of pututxline() working without
  excessive code duplication.

Added:
  user/ed/utmpx/lib/libc/gen/utxdb.c   (contents, props changed)
Modified:
  user/ed/utmpx/lib/libc/gen/Makefile.inc
  user/ed/utmpx/lib/libc/gen/getutxent.c
  user/ed/utmpx/lib/libc/gen/pututxline.c
  user/ed/utmpx/lib/libc/gen/utxdb.h

Modified: user/ed/utmpx/lib/libc/gen/Makefile.inc
==============================================================================
--- user/ed/utmpx/lib/libc/gen/Makefile.inc	Thu Jan  7 23:17:48 2010	(r201762)
+++ user/ed/utmpx/lib/libc/gen/Makefile.inc	Thu Jan  7 23:28:58 2010	(r201763)
@@ -32,7 +32,7 @@ SRCS+=  __getosreldate.c __xuname.c \
 	sysconf.c sysctl.c sysctlbyname.c sysctlnametomib.c \
 	syslog.c telldir.c termios.c time.c times.c timezone.c tls.c \
 	ttyname.c ttyslot.c ualarm.c ulimit.c uname.c unvis.c \
-	usleep.c utime.c valloc.c vis.c wait.c wait3.c waitpid.c \
+	usleep.c utime.c utxdb.c valloc.c vis.c wait.c wait3.c waitpid.c \
 	wordexp.c
 
 SYM_MAPS+=${.CURDIR}/gen/Symbol.map

Modified: user/ed/utmpx/lib/libc/gen/getutxent.c
==============================================================================
--- user/ed/utmpx/lib/libc/gen/getutxent.c	Thu Jan  7 23:17:48 2010	(r201762)
+++ user/ed/utmpx/lib/libc/gen/getutxent.c	Thu Jan  7 23:28:58 2010	(r201763)
@@ -28,6 +28,9 @@
 __FBSDID("$FreeBSD$");
 
 #include "namespace.h"
+#include <sys/endian.h>
+#include <sys/param.h>
+#include <sys/stat.h>
 #include <errno.h>
 #include <stdio.h>
 #include <string.h>
@@ -42,6 +45,7 @@ static struct utmpx utx;
 int
 setutxdb(int db, const char *file)
 {
+	struct stat sb;
 
 	switch (db) {
 	case UTXDB_ACTIVE:
@@ -66,6 +70,16 @@ setutxdb(int db, const char *file)
 	uf = fopen(file, "r");
 	if (uf == NULL)
 		return (-1);
+
+	/* Safety check: never use broken files. */
+	if (db != UTXDB_LOG && _fstat(fileno(uf), &sb) != -1 &&
+	    sb.st_size % sizeof(struct futx) != 0) {
+		fclose(uf);
+		uf = NULL;
+		errno = EFTYPE;
+		return (-1);
+	}
+
 	udb = db;
 	return (0);
 }
@@ -87,49 +101,6 @@ endutxent(void)
 	}
 }
 
-static void
-futx_to_utx(const struct futx *fu, struct utmpx *ut)
-{
-
-	memset(ut, 0, sizeof *ut);
-
-	switch (fu->fu_type) {
-	case BOOT_TIME:
-	case OLD_TIME:
-	case NEW_TIME:
-	/* Extension: shutdown time. */
-	case SHUTDOWN_TIME:
-		break;
-	case USER_PROCESS:
-		FTOU_ID(fu, ut);
-		FTOU_STRING(fu, ut, user);
-		FTOU_STRING(fu, ut, line);
-		/* Extension: host name. */
-		FTOU_STRING(fu, ut, host);
-		FTOU_PID(fu, ut);
-		break;
-	case INIT_PROCESS:
-		FTOU_ID(fu, ut);
-		FTOU_PID(fu, ut);
-		break;
-	case LOGIN_PROCESS:
-		FTOU_ID(fu, ut);
-		FTOU_STRING(fu, ut, user);
-		FTOU_PID(fu, ut);
-		break;
-	case DEAD_PROCESS:
-		FTOU_ID(fu, ut);
-		FTOU_PID(fu, ut);
-		break;
-	default:
-		ut->ut_type = EMPTY;
-		return;
-	}
-
-	FTOU_TYPE(fu, ut);
-	FTOU_TV(fu, ut);
-}
-
 static struct futx *
 getfutxent(void)
 {

Modified: user/ed/utmpx/lib/libc/gen/pututxline.c
==============================================================================
--- user/ed/utmpx/lib/libc/gen/pututxline.c	Thu Jan  7 23:17:48 2010	(r201762)
+++ user/ed/utmpx/lib/libc/gen/pututxline.c	Thu Jan  7 23:28:58 2010	(r201763)
@@ -28,6 +28,7 @@
 __FBSDID("$FreeBSD$");
 
 #include "namespace.h"
+#include <sys/endian.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <string.h>
@@ -55,50 +56,6 @@ futx_open(const char *file)
 	return (fd);
 }
 
-static int
-utx_to_futx(const struct utmpx *ut, struct futx *fu)
-{
-
-	memset(fu, 0, sizeof *fu);
-
-	switch (ut->ut_type) {
-	case BOOT_TIME:
-	case OLD_TIME:
-	case NEW_TIME:
-	/* Extension: shutdown time. */
-	case SHUTDOWN_TIME:
-		break;
-	case USER_PROCESS:
-		UTOF_ID(ut, fu);
-		UTOF_STRING(ut, fu, user);
-		UTOF_STRING(ut, fu, line);
-		/* Extension: host name. */
-		UTOF_STRING(ut, fu, host);
-		UTOF_PID(ut, fu);
-		break;
-	case INIT_PROCESS:
-		UTOF_ID(ut, fu);
-		UTOF_PID(ut, fu);
-		break;
-	case LOGIN_PROCESS:
-		UTOF_ID(ut, fu);
-		UTOF_STRING(ut, fu, user);
-		UTOF_PID(ut, fu);
-		break;
-	case DEAD_PROCESS:
-		UTOF_ID(ut, fu);
-		UTOF_PID(ut, fu);
-		break;
-	default:
-		return (-1);
-	}
-
-	UTOF_TYPE(ut, fu);
-	UTOF_TV(ut, fu);
-
-	return (0);
-}
-
 static void
 utx_active_add(const struct futx *fu)
 {
@@ -254,9 +211,9 @@ struct utmpx *
 pututxline(const struct utmpx *utmpx)
 {
 	struct futx fu;
+	static struct utmpx ut;
 
-	if (utx_to_futx(utmpx, &fu) != 0)
-		return (NULL);
+	utx_to_futx(utmpx, &fu);
 	
 	switch (fu.fu_type) {
 	case BOOT_TIME:
@@ -285,6 +242,6 @@ pututxline(const struct utmpx *utmpx)
 	}
 
 	utx_log_add(&fu);
-	/* XXX: return an entry on success! */
-	return (NULL);
+	futx_to_utx(&fu, &ut);
+	return (&ut);
 }

Added: user/ed/utmpx/lib/libc/gen/utxdb.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/ed/utmpx/lib/libc/gen/utxdb.c	Thu Jan  7 23:28:58 2010	(r201763)
@@ -0,0 +1,162 @@
+/*-
+ * Copyright (c) 2010 Ed Schouten <ed@FreeBSD.org>
+ * 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 AND CONTRIBUTORS ``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>
+__FBSDID("$FreeBSD$");
+
+#include "namespace.h"
+#include <sys/endian.h>
+#include <sys/param.h>
+#include <string.h>
+#include <utmpx.h>
+#include "utxdb.h"
+#include "un-namespace.h"
+
+#define	UTOF_STRING(ut, fu, field) do { \
+	strncpy((fu)->fu_ ## field, (ut)->ut_ ## field,		\
+	    MIN(sizeof (fu)->fu_ ## field, sizeof (ut)->ut_ ## field));	\
+} while (0)
+#define	UTOF_ID(ut, fu) do { \
+	memcpy((fu)->fu_id, (ut)->ut_id,				\
+	    MIN(sizeof (fu)->fu_id, sizeof (ut)->ut_id));		\
+} while (0)
+#define	UTOF_PID(ut, fu) do { \
+	(fu)->fu_pid = htobe32((ut)->ut_pid);				\
+} while (0)
+#define	UTOF_TYPE(ut, fu) do { \
+	(fu)->fu_type = (ut)->ut_type;					\
+} while (0)
+#define	UTOF_TV(ut, fu) do { \
+	(fu)->fu_tv = htobe64((uint64_t)(ut)->ut_tv.tv_sec * 1000000 +	\
+	    (uint64_t)(ut)->ut_tv.tv_usec);				\
+} while (0)
+
+void
+utx_to_futx(const struct utmpx *ut, struct futx *fu)
+{
+
+	memset(fu, 0, sizeof *fu);
+
+	switch (ut->ut_type) {
+	case BOOT_TIME:
+	case OLD_TIME:
+	case NEW_TIME:
+	/* Extension: shutdown time. */
+	case SHUTDOWN_TIME:
+		break;
+	case USER_PROCESS:
+		UTOF_ID(ut, fu);
+		UTOF_STRING(ut, fu, user);
+		UTOF_STRING(ut, fu, line);
+		/* Extension: host name. */
+		UTOF_STRING(ut, fu, host);
+		UTOF_PID(ut, fu);
+		break;
+	case INIT_PROCESS:
+		UTOF_ID(ut, fu);
+		UTOF_PID(ut, fu);
+		break;
+	case LOGIN_PROCESS:
+		UTOF_ID(ut, fu);
+		UTOF_STRING(ut, fu, user);
+		UTOF_PID(ut, fu);
+		break;
+	case DEAD_PROCESS:
+		UTOF_ID(ut, fu);
+		UTOF_PID(ut, fu);
+		break;
+	default:
+		fu->fu_type = EMPTY;
+		return;
+	}
+
+	UTOF_TYPE(ut, fu);
+	UTOF_TV(ut, fu);
+}
+
+#define	FTOU_STRING(fu, ut, field) do { \
+	strncpy((ut)->ut_ ## field, (fu)->fu_ ## field,		\
+	    MIN(sizeof (ut)->ut_ ## field - 1, sizeof (fu)->fu_ ## field)); \
+} while (0)
+#define	FTOU_ID(fu, ut) do { \
+	memcpy((ut)->ut_id, (fu)->fu_id,				\
+	    MIN(sizeof (ut)->ut_id, sizeof (fu)->fu_id));		\
+} while (0)
+#define	FTOU_PID(fu, ut) do { \
+	(ut)->ut_pid = be32toh((fu)->fu_pid);				\
+} while (0)
+#define	FTOU_TYPE(fu, ut) do { \
+	(ut)->ut_type = (fu)->fu_type;					\
+} while (0)
+#define	FTOU_TV(fu, ut) do { \
+	uint64_t t;							\
+	t = be64toh((fu)->fu_tv);					\
+	(ut)->ut_tv.tv_sec = t / 1000000;				\
+	(ut)->ut_tv.tv_usec = t % 1000000;				\
+} while (0)
+
+void
+futx_to_utx(const struct futx *fu, struct utmpx *ut)
+{
+
+	memset(ut, 0, sizeof *ut);
+
+	switch (fu->fu_type) {
+	case BOOT_TIME:
+	case OLD_TIME:
+	case NEW_TIME:
+	/* Extension: shutdown time. */
+	case SHUTDOWN_TIME:
+		break;
+	case USER_PROCESS:
+		FTOU_ID(fu, ut);
+		FTOU_STRING(fu, ut, user);
+		FTOU_STRING(fu, ut, line);
+		/* Extension: host name. */
+		FTOU_STRING(fu, ut, host);
+		FTOU_PID(fu, ut);
+		break;
+	case INIT_PROCESS:
+		FTOU_ID(fu, ut);
+		FTOU_PID(fu, ut);
+		break;
+	case LOGIN_PROCESS:
+		FTOU_ID(fu, ut);
+		FTOU_STRING(fu, ut, user);
+		FTOU_PID(fu, ut);
+		break;
+	case DEAD_PROCESS:
+		FTOU_ID(fu, ut);
+		FTOU_PID(fu, ut);
+		break;
+	default:
+		ut->ut_type = EMPTY;
+		return;
+	}
+
+	FTOU_TYPE(fu, ut);
+	FTOU_TV(fu, ut);
+}

Modified: user/ed/utmpx/lib/libc/gen/utxdb.h
==============================================================================
--- user/ed/utmpx/lib/libc/gen/utxdb.h	Thu Jan  7 23:17:48 2010	(r201762)
+++ user/ed/utmpx/lib/libc/gen/utxdb.h	Thu Jan  7 23:28:58 2010	(r201763)
@@ -29,9 +29,6 @@
 #ifndef _UTXDB_H_
 #define	_UTXDB_H_
 
-#include <sys/cdefs.h>
-#include <sys/endian.h>
-#include <sys/param.h>
 #include <stdint.h>
 
 #define	_PATH_UTX_ACTIVE	"/var/run/utx.active"
@@ -46,6 +43,8 @@
  * those at the front.
  */
 
+struct utmpx;
+
 struct futx {
 	uint8_t		fu_type;
 	uint64_t	fu_tv;
@@ -56,44 +55,7 @@ struct futx {
 	char		fu_host[128];
 } __packed;
 
-#define	FTOU_STRING(fu, ut, field) do { \
-	strncpy((ut)->ut_ ## field, (fu)->fu_ ## field,		\
-	    MIN(sizeof (ut)->ut_ ## field - 1, sizeof (fu)->fu_ ## field)); \
-} while (0)
-#define	FTOU_ID(fu, ut) do { \
-	memcpy((ut)->ut_id, (fu)->fu_id,				\
-	    MIN(sizeof (ut)->ut_id, sizeof (fu)->fu_id));		\
-} while (0)
-#define	FTOU_PID(fu, ut) do { \
-	(ut)->ut_pid = be32toh((fu)->fu_pid);				\
-} while (0)
-#define	FTOU_TYPE(fu, ut) do { \
-	(ut)->ut_type = (fu)->fu_type;					\
-} while (0)
-#define	FTOU_TV(fu, ut) do { \
-	uint64_t t;							\
-	t = be64toh((fu)->fu_tv);					\
-	(ut)->ut_tv.tv_sec = t / 1000000;				\
-	(ut)->ut_tv.tv_usec = t % 1000000;				\
-} while (0)
-
-#define	UTOF_STRING(ut, fu, field) do { \
-	strncpy((fu)->fu_ ## field, (ut)->ut_ ## field,		\
-	    MIN(sizeof (fu)->fu_ ## field, sizeof (ut)->ut_ ## field));	\
-} while (0)
-#define	UTOF_ID(ut, fu) do { \
-	memcpy((fu)->fu_id, (ut)->ut_id,				\
-	    MIN(sizeof (fu)->fu_id, sizeof (ut)->ut_id));		\
-} while (0)
-#define	UTOF_PID(ut, fu) do { \
-	(fu)->fu_pid = htobe32((ut)->ut_pid);				\
-} while (0)
-#define	UTOF_TYPE(ut, fu) do { \
-	(fu)->fu_type = (ut)->ut_type;					\
-} while (0)
-#define	UTOF_TV(ut, fu) do { \
-	(fu)->fu_tv = htobe64((uint64_t)(ut)->ut_tv.tv_sec * 1000000 +	\
-	    (uint64_t)(ut)->ut_tv.tv_usec);				\
-} while (0)
+void	utx_to_futx(const struct utmpx *, struct futx *);
+void	futx_to_utx(const struct futx *, struct utmpx *);
 
 #endif /* !_UTXDB_H_ */

From owner-svn-src-user@FreeBSD.ORG  Fri Jan  8 07:29:52 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 0D27B1065692;
	Fri,  8 Jan 2010 07:29:52 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id F15488FC0A;
	Fri,  8 Jan 2010 07:29:51 +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 o087TpXK003656;
	Fri, 8 Jan 2010 07:29:51 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o087TpnS003654;
	Fri, 8 Jan 2010 07:29:51 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001080729.o087TpnS003654@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Fri, 8 Jan 2010 07:29:51 +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: r201771 - user/ed/utmpx/lib/libc/gen
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: Fri, 08 Jan 2010 07:29:52 -0000

Author: ed
Date: Fri Jan  8 07:29:51 2010
New Revision: 201771
URL: http://svn.freebsd.org/changeset/base/201771

Log:
  Also add an upgrade path for lastlogin.
  
  Right now we only have one version of the file format, so there's
  nothing to do here, except truncating it. Future versions of the
  implementation should have some conversion routines.

Modified:
  user/ed/utmpx/lib/libc/gen/pututxline.c

Modified: user/ed/utmpx/lib/libc/gen/pututxline.c
==============================================================================
--- user/ed/utmpx/lib/libc/gen/pututxline.c	Fri Jan  8 05:53:11 2010	(r201770)
+++ user/ed/utmpx/lib/libc/gen/pututxline.c	Fri Jan  8 07:29:51 2010	(r201771)
@@ -181,6 +181,26 @@ done:
 }
 
 static void
+utx_lastlogin_upgrade(void)
+{
+	int fd;
+	struct stat sb;
+
+	fd = _open(_PATH_UTX_LASTLOGIN, O_RDWR, 0644);
+	if (fd < 0)
+		return;
+
+	/*
+	 * Truncate broken lastlogin files.  In the future we should
+	 * check for older versions of the file format here and try to
+	 * upgrade it.
+	 */
+	if (_fstat(fd, &sb) != -1 && sb.st_size % sizeof(struct futx) != 0)
+		ftruncate(fd, 0);
+	_close(fd);
+}
+
+static void
 utx_log_add(const struct futx *fu)
 {
 	struct {
@@ -219,6 +239,7 @@ pututxline(const struct utmpx *utmpx)
 	case BOOT_TIME:
 	case SHUTDOWN_TIME:
 		utx_active_purge();
+		utx_lastlogin_upgrade();
 		break;
 	case OLD_TIME:
 	case NEW_TIME:

From owner-svn-src-user@FreeBSD.ORG  Fri Jan  8 07:42:02 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 22897106566C;
	Fri,  8 Jan 2010 07:42:02 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id ED1328FC08;
	Fri,  8 Jan 2010 07:42:01 +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 o087g1hl006368;
	Fri, 8 Jan 2010 07:42:01 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o087g1HD006364;
	Fri, 8 Jan 2010 07:42:01 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001080742.o087g1HD006364@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Fri, 8 Jan 2010 07:42:01 +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: r201772 - in user/ed/utmpx/etc: . periodic/monthly rc.d
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: Fri, 08 Jan 2010 07:42:02 -0000

Author: ed
Date: Fri Jan  8 07:42:01 2010
New Revision: 201772
URL: http://svn.freebsd.org/changeset/base/201772

Log:
  Let /etc use the proper utmpx files.

Modified:
  user/ed/utmpx/etc/newsyslog.conf
  user/ed/utmpx/etc/periodic/monthly/200.accounting
  user/ed/utmpx/etc/rc.d/var

Modified: user/ed/utmpx/etc/newsyslog.conf
==============================================================================
--- user/ed/utmpx/etc/newsyslog.conf	Fri Jan  8 07:29:51 2010	(r201771)
+++ user/ed/utmpx/etc/newsyslog.conf	Fri Jan  8 07:42:01 2010	(r201772)
@@ -33,6 +33,6 @@
 /var/log/ppp.log	root:network	640  3	   100	*     JC
 /var/log/security			600  10	   100	*     JC
 /var/log/sendmail.st			640  10	   *	168   B
+/var/log/utx.log			644  3	   *	@01T05 B
 /var/log/weekly.log			640  5	   1	$W6D0 JN
-/var/log/wtmp				644  3	   *	@01T05 B
 /var/log/xferlog			600  7	   100	*     JC

Modified: user/ed/utmpx/etc/periodic/monthly/200.accounting
==============================================================================
--- user/ed/utmpx/etc/periodic/monthly/200.accounting	Fri Jan  8 07:29:51 2010	(r201771)
+++ user/ed/utmpx/etc/periodic/monthly/200.accounting	Fri Jan  8 07:42:01 2010	(r201772)
@@ -15,7 +15,7 @@ oldmask=$(umask)
 umask 066
 case "$monthly_accounting_enable" in
     [Yy][Ee][Ss])
-	W=/var/log/wtmp
+	W=/var/log/utx.log
 	rc=0
 	remove=NO
 	if [ ! -f $W.0 ]

Modified: user/ed/utmpx/etc/rc.d/var
==============================================================================
--- user/ed/utmpx/etc/rc.d/var	Fri Jan  8 07:29:51 2010	(r201771)
+++ user/ed/utmpx/etc/rc.d/var	Fri Jan  8 07:42:01 2010	(r201772)
@@ -98,12 +98,12 @@ case "${populate_var}" in
 	;;
 esac
 
-# Make sure we have /var/log/lastlog and /var/log/wtmp files
-if [ ! -f /var/log/lastlog ]; then
-	cp /dev/null /var/log/lastlog
-	chmod 644 /var/log/lastlog
+# Make sure we have /var/log/utx.lastlogin and /var/log/utx.log files
+if [ ! -f /var/log/utx.lastlogin ]; then
+	cp /dev/null /var/log/utx.lastlogin
+	chmod 644 /var/log/utx.lastlogin
 fi
-if [ ! -f /var/log/wtmp ]; then
-	cp /dev/null /var/log/wtmp
-	chmod 644 /var/log/wtmp
+if [ ! -f /var/log/utx.log ]; then
+	cp /dev/null /var/log/utx.log
+	chmod 644 /var/log/utx.log
 fi

From owner-svn-src-user@FreeBSD.ORG  Fri Jan  8 09:31:20 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 2D302106566C;
	Fri,  8 Jan 2010 09:31:20 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 1C2958FC1C;
	Fri,  8 Jan 2010 09:31:20 +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 o089VKp4030345;
	Fri, 8 Jan 2010 09:31:20 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o089VKge030342;
	Fri, 8 Jan 2010 09:31:20 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001080931.o089VKge030342@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Fri, 8 Jan 2010 09:31:20 +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: r201776 - user/luigi/ipfw3-head/sys/netinet/ipfw
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: Fri, 08 Jan 2010 09:31:20 -0000

Author: luigi
Date: Fri Jan  8 09:31:19 2010
New Revision: 201776
URL: http://svn.freebsd.org/changeset/base/201776

Log:
  snapshot

Modified:
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c	Fri Jan  8 09:31:18 2010	(r201775)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c	Fri Jan  8 09:31:19 2010	(r201776)
@@ -1,4 +1,5 @@
 /*-
+ * Copyright (c) 2010 Riccardo Panicucci, Universita` di Pisa
  * Copyright (c) 2010 Luigi Rizzo, Universita` di Pisa
  * All rights reserved
  *
@@ -107,14 +108,6 @@ static unsigned long	io_pkt_drop;
 static struct dn_heap *system_heap;
 
 /*
- * Three heaps contain queues and pipes that the scheduler handles:
- *
- * ready_heap contains all dn_flow_queue related to fixed-rate pipes.
- *
- * wfq_ready_heap contains the pipes associated with WF2Q flows
- *
- * extract_heap contains pipes associated with delay lines.
- *
  * The key for the heap is used for two different values:
  *
  * 1. timer ticks- max 10K/second, so 32 bits are enough;
@@ -130,18 +123,14 @@ static struct dn_heap *system_heap;
  * MAX64 returns the largest of two key values.
  * MY_M is used as a shift count when doing fixed point arithmetic
  * (a better name would be useful...).
+ * XXX With this scaling, max 1000 flows, max weight 100, 1Gbit/s, the
+ * virtual time wraps every 15 days.
  */
 #define MAX64(x,y)  (( (int64_t) ( (y)-(x) )) > 0 ) ? (y) : (x)
 #define MY_M    16 /* shift for fixed point arithmetic */
   
-/*
- * XXX With this scaling, max 1000 flows, max weight 100, 1Gbit/s, the
- * virtual time wraps every 15 days.
- */
-
 MALLOC_DEFINE(M_DUMMYNET, "dummynet", "dummynet heap");
 
-struct dn_heap ready_heap, extract_heap, wfq_ready_heap ;
 struct new_pipe_head	pipehash[DN_HASHSIZE];	/* all pipes */
 struct new_fs_head	flowsethash[DN_HASHSIZE];	/* all flowsets */
 
@@ -158,10 +147,6 @@ SYSCTL_INT(_net_inet_ip_dummynet, OID_AU
 SYSCTL_LONG(_net_inet_ip_dummynet, OID_AUTO, curr_time,
     CTLFLAG_RD, &curr_time, 0, "Current tick");
 #endif
-SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, ready_heap,
-    CTLFLAG_RD, &ready_heap.size, 0, "Size of ready heap");
-SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, extract_heap,
-    CTLFLAG_RD, &extract_heap.size, 0, "Size of extract heap");
 SYSCTL_LONG(_net_inet_ip_dummynet, OID_AUTO, searches,
     CTLFLAG_RD, &searches, 0, "Number of queue searches");
 SYSCTL_LONG(_net_inet_ip_dummynet, OID_AUTO, search_steps,
@@ -234,14 +219,12 @@ static void	dummynet_send(struct mbuf *)
 
 /*
  * Packets processed by dummynet have an mbuf tag associated with
- * them that carries their dummynet state.  This is used within
- * the dummynet code as well as outside when checking for special
- * processing requirements.
- * Note that the first part is the reinject info and is common to
- * other forms of packet reinjection.
+ * them that carries their dummynet state.
+ * Outside dummynet, only the 'rule' field is relevant, and it must
+ * be at the beginning of the structure.
  */
 struct dn_pkt_tag {
-	struct ipfw_rule_ref rule;	/* matching rule		*/
+	struct ipfw_rule_ref rule;	/* matching rule	*/
 
 	/* second part, dummynet specific */
 	int dn_dir;		/* action when packet comes out.*/
@@ -255,6 +238,7 @@ struct dn_pkt_tag {
  * Return the mbuf tag holding the dummynet state.  As an optimization
  * this is assumed to be the first tag on the list.  If this turns out
  * wrong we'll need to search the list.
+ * XXX OK
  */
 static struct dn_pkt_tag *
 dn_tag_get(struct mbuf *m)
@@ -271,43 +255,44 @@ dn_tag_get(struct mbuf *m)
  * It is called when we have some packet from delay line to send.
  * If there are leftover packets, this delay line is reinserted into extract
  * heap
+ * XXX OK
  */
-static
-struct mbuf *
+static struct mbuf *
 transmit_event(struct delay_line *dline, dn_key l_curr_time)
 {
-    struct mbuf *m;
-    struct dn_pkt_tag *pkt;
+	struct mbuf *m;
+	struct dn_pkt_tag *pkt;
 
-    struct mbuf *head = NULL, *tail = NULL;
-    /* XXX scheduler lock */
-    while ((m = dline->head) != NULL) {
-        pkt = dn_tag_get(m);
-        if (!DN_KEY_LEQ(pkt->output_time, l_curr_time))
-            break;
-        dline->head = m->m_nextpkt;
-        if (tail != NULL)
-            tail->m_nextpkt = m;
-        else
-            head = m;
-        tail = m;
-    }
+	struct mbuf *head = NULL, *tail = NULL;
+	/* XXX scheduler lock */
+	while ((m = dline->head) != NULL) {
+		pkt = dn_tag_get(m);
+		if (!DN_KEY_LEQ(pkt->output_time, l_curr_time))
+			break;
+		dline->head = m->m_nextpkt;
+		if (tail != NULL)
+			tail->m_nextpkt = m;
+		else
+			head = m;
+		tail = m;
+	}
 
-    if (tail != NULL)
-        tail->m_nextpkt = NULL;
+	if (tail != NULL)
+		tail->m_nextpkt = NULL;
 
-    /* If there are leftover packets, put into the heap for next event. */
-    if ((m = dline->head) != NULL) {
-        pkt = dn_tag_get(m);
-        //DN_HEAP_LOCK();
-        heap_insert(system_heap, pkt->output_time, dline);
-        //DN_HEAP_UNLOCK();
-    }
-    /* XXX scheduler unlock */
-    return head;
+	/* If there are leftover packets, put into the heap for next event. */
+	if ((m = dline->head) != NULL) {
+		pkt = dn_tag_get(m);
+		//DN_HEAP_LOCK();
+		heap_insert(system_heap, pkt->output_time, dline);
+		//DN_HEAP_UNLOCK();
+	}
+	/* XXX scheduler unlock */
+	return head;
 }
 
 #define div64(a, b)	((int64_t)(a) / (int64_t)(b))
+
 /*
  * Compute how many ticks we have to wait before being able to send
  * a packet. This is computed as the "wire time" for the packet
@@ -350,27 +335,230 @@ compute_extra_bits(struct mbuf *pkt, str
 	return extra_bits;
 }
 
-/* Insert packet pkt into delay line of si. */
+/* Insert packet pkt into delay line */
 static void
-move_pkt(struct mbuf *pkt, struct new_pipe *p, struct new_sch_inst *si,
+move_pkt(struct mbuf *pkt, struct new_pipe *p, struct delay_line *d,
           dn_key l_curr_time)
 {
-    struct dn_pkt_tag *dt = dn_tag_get(pkt);
-    struct delay_line *d = si->dline;
- 
-    dt->output_time = l_curr_time + p->delay ;
+	struct dn_pkt_tag *dt = dn_tag_get(pkt);
+
+	dt->output_time = l_curr_time + p->delay ;
+
+	if (d->head == NULL)
+		d->head = pkt;
+	else
+		d->tail->m_nextpkt = pkt;
+	d->tail = pkt;
+	d->tail->m_nextpkt = NULL;
+}
+
+/* Do masking depending of flow id */
+static struct ipfw_flow_id *
+do_mask(struct ipfw_flow_id *mask, struct ipfw_flow_id *id)
+{
+	int is_v6 = IS_IP6_FLOW_ID(id);
+
+	id->dst_port &= mask->dst_port;
+	id->src_port &= mask->src_port;
+	id->proto &= mask->proto;
+	id->flags = 0; /* we don't care about this one */
+	if (is_v6) {
+		APPLY_MASK(&id->dst_ip6, &mask->dst_ip6);
+		APPLY_MASK(&id->src_ip6, &mask->src_ip6);
+		id->flow_id6 &= mask->flow_id6;
+	} else {
+		id->dst_ip &= mask->dst_ip;
+		id->src_ip &= mask->src_ip;
+	}
+
+	return id;
+}
+
+/*
+ * Calculate the hash of a flow id.
+ * XXX we may want a better hash function
+ */
+static int
+do_hash(struct ipfw_flow_id *id)
+{
+    int i;
+    int is_v6 = IS_IP6_FLOW_ID(id);
+        
+    if (is_v6) {
+        i = ((id->dst_ip6.__u6_addr.__u6_addr32[0]) & 0xffff)^
+            ((id->dst_ip6.__u6_addr.__u6_addr32[1]) & 0xffff)^
+            ((id->dst_ip6.__u6_addr.__u6_addr32[2]) & 0xffff)^
+            ((id->dst_ip6.__u6_addr.__u6_addr32[3]) & 0xffff)^
+       
+            ((id->dst_ip6.__u6_addr.__u6_addr32[0] >> 15) & 0xffff)^
+            ((id->dst_ip6.__u6_addr.__u6_addr32[1] >> 15) & 0xffff)^
+            ((id->dst_ip6.__u6_addr.__u6_addr32[2] >> 15) & 0xffff)^
+            ((id->dst_ip6.__u6_addr.__u6_addr32[3] >> 15) & 0xffff)^
+            
+            ((id->src_ip6.__u6_addr.__u6_addr32[0] << 1) & 0xfffff)^
+            ((id->src_ip6.__u6_addr.__u6_addr32[1] << 1) & 0xfffff)^
+            ((id->src_ip6.__u6_addr.__u6_addr32[2] << 1) & 0xfffff)^
+            ((id->src_ip6.__u6_addr.__u6_addr32[3] << 1) & 0xfffff)^
+   
+            ((id->src_ip6.__u6_addr.__u6_addr32[0] << 16) & 0xffff)^
+            ((id->src_ip6.__u6_addr.__u6_addr32[1] << 16) & 0xffff)^
+            ((id->src_ip6.__u6_addr.__u6_addr32[2] << 16) & 0xffff)^
+            ((id->src_ip6.__u6_addr.__u6_addr32[3] << 16) & 0xffff)^
+        
+            (id->dst_port << 1) ^ (id->src_port) ^
+            (id->proto ) ^
+            (id->flow_id6);
+    } else {
+        i = ( (id->dst_ip) & 0xffff ) ^
+            ( (id->dst_ip >> 15) & 0xffff ) ^
+            ( (id->src_ip << 1) & 0xffff ) ^
+            ( (id->src_ip >> 16 ) & 0xffff ) ^
+            (id->dst_port << 1) ^ (id->src_port) ^
+            (id->proto );
+    }
+    return i;
+}
+
+/*
+ * returns 0 masks match,
+ * returns 1 otherwise
+ */
+static int
+mask_are_equals (struct ipfw_flow_id *id1, struct ipfw_flow_id *id2)
+{
+	int is_v6 = IS_IP6_FLOW_ID(id1);
+	if (is_v6 != IS_IP6_FLOW_ID(id2))
+		return 1; /* a ipv4 and a ipv6 flow */
+	    
+	if (!is_v6 && id1->dst_ip == id2->dst_ip &&
+	    id1->src_ip == id2->src_ip &&
+	    id1->dst_port == id2->dst_port &&
+	    id1->src_port == id2->src_port &&
+	    id1->proto == id2->proto &&
+	    id1->flags == id2->flags)
+		return 0;
+	    
+	if (is_v6 &&
+	    IN6_ARE_ADDR_EQUAL(&id1->dst_ip6,&id2->dst_ip6) &&
+	    IN6_ARE_ADDR_EQUAL(&id1->src_ip6,&id2->src_ip6) &&
+	    id1->dst_port == id2->dst_port &&
+	    id1->src_port == id2->src_port &&
+	    id1->proto == id2->proto &&
+	    id1->flags == id2->flags &&
+	    id1->flow_id6 == id2->flow_id6)
+		return 0;
+     
+	/* Masks differ */
+	return 1;
+}
+
+/*
+ * Create a new scheduler instance for the scheduler 'sch_t'.
+ * Allocate memory for common and scheduler private data.
+ * XXX put the delay line within the instance ?
+ * XXX why do we need separate delay lines ?
+ */
+static struct new_sch_inst *
+create_scheduler_instance(struct new_sch *sch_t, dn_key l_curr_time)
+{
+	struct new_sch_inst *si;
+	int ret;
+	const char *msg = "malloc failure";
+	int l = sizeof(*si) + sch_t->fp->scheduler_i_size;
+
+	si = malloc(l, M_DUMMYNET, M_NOWAIT | M_ZERO);
+
+	if (si == NULL)
+		goto error;
+
+	si->dline = malloc(sizeof(struct delay_line), M_DUMMYNET, M_NOWAIT);
+	if (si->dline == NULL)
+		goto error;
+	si->dline->si = si;
+	set_oid(&si->dline->id, DN_DELAY_LINE, 0, sizeof(struct delay_line));
+	si->dline->head = si->dline->tail = NULL;
+
+	set_oid(&si->oid, DN_SCH_I, 0, l);
+
+	si->sched_nr = sch_t->sched_nr;
+	si->ptr_sched = sch_t;
+
+	/* XXX do we make assumption on this starting with dn_id ? */
+	ret = sch_t->fp->new_sched((void *)(si + 1));
+	if (ret) {
+		msg = "new_sched error";
+		goto error;
+	}
 
-    if (d->head == NULL)
-        d->head = pkt;
-    else
-        d->tail->m_nextpkt = pkt;
-    d->tail = pkt;
-    d->tail->m_nextpkt = NULL;
+	/* Initialize scheduler instance queues list */
+	SLIST_INIT(&si->ql_list);
+	     
+	si->oid.subtype = ((struct dn_id*)(si + 1))->subtype;
+	((struct dn_id*)(si + 1))->type = DN_SCH_I;
+	si->idle_time = l_curr_time;
+	return si;
+
+error:
+	printf("%s: %s\n", __FUNCTION__, msg);
+	if (si)
+		free(si, M_DUMMYNET);
+        return NULL;
 }
 
-struct new_sch_inst *
+static struct new_sch_inst *
 find_scheduler(struct new_sch *sch_t, struct new_fs *fs,
-                struct ipfw_flow_id *id, dn_key l_curr_time);
+                struct ipfw_flow_id *id, dn_key l_curr_time)
+{
+    struct new_sch_inst *prev, *s; /* returning scheduler instance */
+    struct ipfw_flow_id *id_t;
+    int i = 0;
+
+    id_t = malloc(sizeof(struct ipfw_flow_id), M_DUMMYNET, M_NOWAIT);
+    if (id_t == NULL) {
+        printf("dummynet: no memory for flowid\n");
+        return NULL;
+    }
+    /* XXX check return value */
+    *id_t = *id; /* The original id isn't modified */
+    do_mask(&sch_t->sched_mask, id_t);
+    if ( !(sch_t->flags & DN_SCH_HAVE_MASK) ) {
+        s = sch_t->sch_i[0];
+    } else {
+        /* first, do the masking, then hash */
+        i = do_hash(id_t);
+        i = i % sch_t->sch_i_size;
+        /* finally, scan the current hash bucket for a match */
+        searches++ ;
+        for (prev=NULL, s = sch_t->sch_i[i] ; s ; ) {
+            search_steps++;
+            if (!mask_are_equals(id_t, &s->id))
+                break; /* found */
+            prev = s ;
+            s = s->next ;
+        }
+        if (s && prev != NULL) { /* found and not in front */
+            prev->next = s->next ;
+            s->next = sch_t->sch_i[i] ;
+            sch_t->sch_i[i] = s ;
+        }
+    }
+   
+    if (s == NULL) { /* no match, need to allocate a new entry */
+        s = create_scheduler_instance(sch_t, l_curr_time);
+        if (s == NULL)
+            return NULL;
+        /* Link scheduler in front of array */
+        s->next = sch_t->sch_i[i];
+        sch_t->sch_i[i] = s;
+        sch_t->sch_i_elements++;
+        if (s != NULL) {
+            s->id = *id_t;
+            s->hash_slot = i;
+        }
+    }
+    return s;
+}
+
 
 /*
  * The timer handler for dummynet. Time is computed in ticks, but
@@ -871,30 +1059,6 @@ ipdn_locate_pipe(int pipe_nr)
 	return (NULL);
 }
 
-struct ipfw_flow_id *
-do_mask(struct ipfw_flow_id *mask, struct ipfw_flow_id *id);
-/* Do masking depending of flow id */
-struct ipfw_flow_id *
-do_mask(struct ipfw_flow_id *mask, struct ipfw_flow_id *id)
-{
-    int is_v6 = IS_IP6_FLOW_ID(id);
-
-    id->dst_port &= mask->dst_port;
-    id->src_port &= mask->src_port;
-    id->proto &= mask->proto;
-    id->flags = 0; /* we don't care about this one */
-    if (is_v6) {
-        APPLY_MASK(&id->dst_ip6, &mask->dst_ip6);
-        APPLY_MASK(&id->src_ip6, &mask->src_ip6);
-        id->flow_id6 &= mask->flow_id6;
-    }
-    else {
-        id->dst_ip &= mask->dst_ip;
-        id->src_ip &= mask->src_ip;
-    }
-        
-    return id;
-}
 
 /*
  * dummynet hook for packets. Below 'pipe' is a pipe or a queue
@@ -1035,7 +1199,7 @@ dummynet_io(struct mbuf **m0, int dir, s
                             compute_extra_bits(tosend, pipe) * hz : 0;
             sch_inst->numbytes -= len_scaled;
             /* Move packet in the delay line XXX three parameters? */
-            move_pkt(tosend, pipe, sch_inst, l_curr_time);
+            move_pkt(tosend, pipe, sch_inst->dline, l_curr_time);
             if (sch_inst->numbytes < 0) {
                 /*
                  * Credit became negative, so insert the instance in the

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Fri Jan  8 09:31:18 2010	(r201775)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Fri Jan  8 09:31:19 2010	(r201776)
@@ -183,10 +183,6 @@ dummynet_flush(void)
 	int i;
 
 	DUMMYNET_LOCK();
-	/* Free heaps so we don't have unwanted events. */
-	heap_free(&ready_heap);
-	heap_free(&wfq_ready_heap);
-	heap_free(&extract_heap);
 
 	/*
 	 * Now purge all queued pkts and delete all pipes.
@@ -824,9 +820,6 @@ ip_dn_init(void)
 		SLIST_INIT(&pipehash[i]);
 		SLIST_INIT(&flowsethash[i]);
 	}
-	bzero(&ready_heap, sizeof(ready_heap));
-	bzero(&wfq_ready_heap, sizeof(wfq_ready_heap));
-	bzero(&extract_heap, sizeof(extract_heap));
 
 	ip_dn_ctl_ptr = ip_dn_ctl;
 	ip_dn_io_ptr = dummynet_io;

From owner-svn-src-user@FreeBSD.ORG  Fri Jan  8 10:15:11 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 836FF1065694;
	Fri,  8 Jan 2010 10:15:11 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 73DAE8FC18;
	Fri,  8 Jan 2010 10:15:11 +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 o08AFBVr042161;
	Fri, 8 Jan 2010 10:15:11 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o08AFBgo042159;
	Fri, 8 Jan 2010 10:15:11 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001081015.o08AFBgo042159@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Fri, 8 Jan 2010 10:15:11 +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: r201780 - user/ed/utmpx/include
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: Fri, 08 Jan 2010 10:15:11 -0000

Author: ed
Date: Fri Jan  8 10:15:11 2010
New Revision: 201780
URL: http://svn.freebsd.org/changeset/base/201780

Log:
  Document the definitions in <utmpx.h>.

Modified:
  user/ed/utmpx/include/utmpx.h

Modified: user/ed/utmpx/include/utmpx.h
==============================================================================
--- user/ed/utmpx/include/utmpx.h	Fri Jan  8 10:14:27 2010	(r201779)
+++ user/ed/utmpx/include/utmpx.h	Fri Jan  8 10:15:11 2010	(r201780)
@@ -39,34 +39,35 @@ typedef	__pid_t		pid_t;
 #endif
 
 struct utmpx {
-	char		ut_user[32];
-	char		ut_id[8];
-	char		ut_line[32];
+	char		ut_user[32];	/* User login name. */
+	char		ut_id[8];	/* Process identifier. */
+	char		ut_line[32];	/* Device name. */
 #if __BSD_VISIBLE
-	char		ut_host[128];
+	char		ut_host[128];	/* Remote hostname. */
 #else
 	char		__ut_host[128];
 #endif
-	pid_t		ut_pid;
-	short		ut_type;
-#define	EMPTY		0
-#define	BOOT_TIME	1
-#define	OLD_TIME	2
-#define	NEW_TIME	3
-#define	USER_PROCESS	4
-#define	INIT_PROCESS	5
-#define	LOGIN_PROCESS	6
-#define	DEAD_PROCESS	7
+	pid_t		ut_pid;		/* Process ID. */
+	short		ut_type;	/* Type of entry. */
+	struct timeval	ut_tv;		/* Time entry was made. */
+};
+
+#define	EMPTY		0	/* No valid user accounting information. */
+#define	BOOT_TIME	1	/* Time of system boot. */
+#define	OLD_TIME	2	/* Time when system clock changed. */
+#define	NEW_TIME	3	/* Time after system clock changed. */
+#define	USER_PROCESS	4	/* A process. */
+#define	INIT_PROCESS	5	/* A process spawned by the init process. */
+#define	LOGIN_PROCESS	6	/* The session leader of a logged-in user. */
+#define	DEAD_PROCESS	7	/* A session leader who has exited. */
 #if __BSD_VISIBLE
-#define	SHUTDOWN_TIME	8
+#define	SHUTDOWN_TIME	8	/* Time of system shutdown. */
 #endif
-	struct timeval	ut_tv;
-};
 
 #if __BSD_VISIBLE
-#define	UTXDB_ACTIVE	0
-#define	UTXDB_LASTLOGIN	1
-#define	UTXDB_LOG	2
+#define	UTXDB_ACTIVE	0	/* Active login sessions. */
+#define	UTXDB_LASTLOGIN	1	/* Last login sessions. */
+#define	UTXDB_LOG	2	/* Log indexed by time. */
 #endif
 
 __BEGIN_DECLS

From owner-svn-src-user@FreeBSD.ORG  Fri Jan  8 12:08:41 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 69F0C1065679;
	Fri,  8 Jan 2010 12:08:41 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 59B7D8FC12;
	Fri,  8 Jan 2010 12:08:41 +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 o08C8fQI067356;
	Fri, 8 Jan 2010 12:08:41 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o08C8ftx067354;
	Fri, 8 Jan 2010 12:08:41 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001081208.o08C8ftx067354@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Fri, 8 Jan 2010 12:08:41 +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: r201786 - user/ed/utmpx/etc/rc.d
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: Fri, 08 Jan 2010 12:08:41 -0000

Author: ed
Date: Fri Jan  8 12:08:41 2010
New Revision: 201786
URL: http://svn.freebsd.org/changeset/base/201786

Log:
  Also use utx.active here.

Modified:
  user/ed/utmpx/etc/rc.d/cleanvar

Modified: user/ed/utmpx/etc/rc.d/cleanvar
==============================================================================
--- user/ed/utmpx/etc/rc.d/cleanvar	Fri Jan  8 11:45:47 2010	(r201785)
+++ user/ed/utmpx/etc/rc.d/cleanvar	Fri Jan  8 12:08:41 2010	(r201786)
@@ -59,7 +59,7 @@ cleanvar_start () 
 	if [ -d /var/run -a ! -f /var/run/clean_var ]; then
 		purgedir /var/run
 		# And an initial utmp file
-		(cd /var/run && cp /dev/null utmp && chmod 644 utmp)
+		(cd /var/run && cp /dev/null utx.active && chmod 644 utx.active)
 		>/var/run/clean_var
 	fi
 	if [ -d /var/spool/lock -a ! -f /var/spool/lock/clean_var ]; then

From owner-svn-src-user@FreeBSD.ORG  Fri Jan  8 14:55:10 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 ED4A2106566B;
	Fri,  8 Jan 2010 14:55:10 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id DA5DB8FC16;
	Fri,  8 Jan 2010 14:55:10 +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 o08EtADV004331;
	Fri, 8 Jan 2010 14:55:10 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o08EtAHn004324;
	Fri, 8 Jan 2010 14:55:10 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001081455.o08EtAHn004324@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Fri, 8 Jan 2010 14:55:10 +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: r201789 - in user/luigi/ipfw3-head: sbin/ipfw
	sys/netinet sys/netinet/ipfw
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: Fri, 08 Jan 2010 14:55:11 -0000

Author: luigi
Date: Fri Jan  8 14:55:10 2010
New Revision: 201789
URL: http://svn.freebsd.org/changeset/base/201789

Log:
  snapshot for today

Modified:
  user/luigi/ipfw3-head/sbin/ipfw/dummynet.c
  user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h
  user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched.h
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c

Modified: user/luigi/ipfw3-head/sbin/ipfw/dummynet.c
==============================================================================
--- user/luigi/ipfw3-head/sbin/ipfw/dummynet.c	Fri Jan  8 14:33:03 2010	(r201788)
+++ user/luigi/ipfw3-head/sbin/ipfw/dummynet.c	Fri Jan  8 14:55:10 2010	(r201789)
@@ -730,13 +730,13 @@ ipfw_config_pipe(int ac, char **av)
 	char *end;
 	void *par = NULL;
 	struct dn_id *buf, *base;
-	struct new_sch *sch = NULL, *sch2 = NULL;
+	struct new_sch *sch = NULL;
 	struct new_pipe *p = NULL;
 	struct new_fs *fs = NULL;
+	struct new_profile *pf = NULL;
 	struct ipfw_flow_id *mask = NULL;
-	int lmax = sizeof(*sch)*2 + sizeof(*p) + sizeof(*fs);
+	int lmax = sizeof(*sch) + sizeof(*p) + sizeof(*fs) + sizeof(*pf);
 
-fprintf(stderr, "configuring %d\n", co.do_pipe);
 	base = buf = calloc(1, lmax);
 	if (buf == NULL) {
 		errx(1, "no memory for pipe buffer");
@@ -752,27 +752,27 @@ fprintf(stderr, "configuring %d\n", co.d
 	switch (co.do_pipe) {
 	case 1:
 		sch = o_next(&buf, sizeof(*sch), DN_SCH);
-		sch2 = o_next(&buf, sizeof(*sch2), DN_SCH);
 		p = o_next(&buf, sizeof(*p), DN_PIPE);
 		fs = o_next(&buf, sizeof(*fs), DN_FS);
 		mask = &sch->sched_mask; // XXX or both ?
-		p->pipe_nr = i + DN_PIPEOFFSET;
-		fs->fs_nr = i;
-		fs->sched_nr = i;
-		sch->sched_nr = i;
-		sch2->sched_nr = i + DN_PIPEOFFSET;
+		sch->pipe_nr = p->pipe_nr = i;
+		fs->fs_nr = i + DN_PIPEOFFSET;
+		fs->sched_nr = sch->sched_nr = i + DN_PIPEOFFSET;
 		break;
+
 	case 2: /* flowset */
 		fs = o_next(&buf, sizeof(*fs), DN_FS);
 		fs->fs_nr = i;
 		mask = &fs->flow_mask;
 		break;
+
 	case 3: /* scheduler */
 		sch = o_next(&buf, sizeof(*sch), DN_SCH);
 		sch->sched_nr = i;
 		mask = &sch->sched_mask; // XXX or both ?
 		break;
 	}
+
 	while (ac > 0) {
 		double d;
 		int tok = match_token(dummynet_params, *av);
@@ -1003,7 +1003,10 @@ end_mask:
 
 #if 0
 		case TOK_PIPE_PROFILE:
+			NEED((!pf), "profile already set");
+			NEED(p, "profile");
 		    {
+			pf = o_next(&buf, sizeof(*pf));
 			int samples[ED_MAX_SAMPLES_NO];
 			if (co.do_pipe != 1)
 			    errx(EX_DATAERR, "extra delay only valid for pipes");
@@ -1015,14 +1018,14 @@ end_mask:
 			break;
 #endif
 		case TOK_BURST:
-			NEED(sch, "burst");
+			NEED(p, "burst");
 			NEED1("burst needs argument\n");
 			errno = 0;
-			if (expand_number(av[0], (int64_t *)&sch->burst) < 0)
+			if (expand_number(av[0], (int64_t *)&p->burst) < 0)
 				if (errno != ERANGE)
 					errx(EX_DATAERR,
 					    "burst: invalid argument");
-			if (errno || sch->burst > (1ULL << 48) - 1)
+			if (errno || p->burst > (1ULL << 48) - 1)
 				errx(EX_DATAERR,
 				    "burst: out of range (0..2^48-1)");
 			ac--; av++;

Modified: user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h	Fri Jan  8 14:33:03 2010	(r201788)
+++ user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h	Fri Jan  8 14:55:10 2010	(r201789)
@@ -47,6 +47,7 @@ struct dn_id {
 	uint8_t		type;
 	uint8_t		subtype;
 	uint32_t	id;	/* identifier in the sequence */
+	struct dn_id 	*next;	/* link field, for kernel */
 };
 
 /*
@@ -90,15 +91,25 @@ enum sched_flag {
     DN_SCH_DELETE_DELAY_LINE  = 0x0040, /* (k) */
 };
 
-SLIST_HEAD(new_queue_head, new_queue);
 typedef uint64_t dn_key;
 
+#define	ED_MAX_SAMPLES_NO	1024
+struct new_profile {
+	struct dn_id oid;
+	/* fields to simulate a delay profile */
+#define ED_MAX_NAME_LEN         32
+	char name[ED_MAX_NAME_LEN];
+	int loss_level;
+	int samples_no;
+	int samples[ED_MAX_SAMPLES_NO]; /* this has actually samples_no slots */
+};
+
 /* Pipe template
  * All pipe are linked in a list, there is a 1-1 mapping between
  * 'ipfw pipe XX ...' commands and pipe XX
  */
 struct new_pipe {
-	struct dn_id id;
+	struct dn_id oid;
 
 	/* these initial fields are set from the command line
 	 * pipe N config bw B delay D profile PRF (mask M1 plr P queue Q
@@ -112,6 +123,7 @@ struct new_pipe {
 	int32_t pipe_nr ;           /* N, number               */
 	int bandwidth;              /* B, really, bits/tick.   */
 	int delay ;                 /* D, really, ticks        */
+	uint64_t burst; /* burst size, scaled. bits*Hz  XXX */
 
 	/*
 	 * When the tx clock comes from an interface (if_name[0] != '\0'),
@@ -119,18 +131,12 @@ struct new_pipe {
 	 */
 	char if_name[IFNAMSIZ];
 
-	/* fields to simulate a delay profile */
-#define ED_MAX_NAME_LEN         32
-	char name[ED_MAX_NAME_LEN];
-	int loss_level;
-	int samples_no;
-	int user_samples[0]; /* this has actually samples_no slots */
+	struct new_profile *profile;
 
 	/*
 	 * The following parameters set at runtime and only valid
 	 * in the kernel. Userland should not look at these fields.
 	 */
-	int *samples; /* pointer to memory for user_samples[] */
 	struct ifnet *ifp;
 	int ready ; /* set if ifp != NULL and we got a signal from it */
 
@@ -141,7 +147,7 @@ struct new_pipe {
  * generic text string, in case we need one
  */
 struct new_text {
-	struct dn_id id;
+	struct dn_id oid;
 	int len;
 	char text[0];	/* len bytes, NUL terminated */
 };
@@ -153,7 +159,7 @@ struct new_text {
  * (plus there is a FIFO flowset for each pipe)
  */
 struct new_fs {
-	struct dn_id id;
+	struct dn_id oid;
 
 	/* these initial fields are set from the command line
 	 * queue N config mask M pipe P buckets B plr PLR queue QSZ ...
@@ -181,11 +187,11 @@ struct new_fs {
 	struct new_fs *confnext;
 
 	/* DN_FS_DELETE
-	* DN_FS_REENQUEUE
-	* DN_HAVE_FLOW_MASK
-	* DN_QSIZE_IS_BYTES
-	* DN_NOERROR
-	*/
+	 * DN_FS_REENQUEUE
+	 * DN_HAVE_FLOW_MASK
+	 * DN_QSIZE_IS_BYTES
+	 * DN_NOERROR
+	 */
 	int flags;
 
 	/* Number of queues attached to this flowset */
@@ -197,8 +203,8 @@ struct new_fs {
 	/* Scheduler associated with this flowset, set when the
 	* scheduler for the pipe P is defined.
 	*/
-	struct new_sch *ptr_sched;
-	int ptr_sched_val; /* to check if the pointer is correct */
+	struct new_sch *sched;
+	int sched_id; /* to check if the pointer is correct */
 
 	/*
 	* Pointer to scheduler-specific parameters for this flowset
@@ -206,9 +212,42 @@ struct new_fs {
 	*/
 	struct dn_id *alg_fs;
 	/* Pointer to scheduler functions */
-	struct scheduler *fp;
+	struct dn_sched *fp;
 };
 
+/* Implementation of the packets queue associated with a scheduler instance */
+struct new_queue {
+    struct dn_id oid;
+ 
+    /* Number and pointer to the parent flowset */
+    int fs_nr;
+    struct new_fs *fs;
+
+    u_int lenght; /* Queue lenght, in packets */
+    u_int len_bytes; /* Queue lenght, in bytes */
+
+    uint64_t tot_pkts; /* statistics counters  */
+    uint64_t tot_bytes;
+    uint32_t drops;
+ 
+    /* Used to print the id of the queue */
+    int hash_slot;
+
+    /* Pointer to the scheduler instance that the packet belongs */
+    void *sch_inst; /* Pointer to scheduler specific data */
+
+    /* packets queue */
+    struct mbuf *head, *tail;
+
+    /* flow id associated with this queue */
+    struct ipfw_flow_id id;
+
+    struct new_queue *next; /* Next queue in the bucket */
+
+    /* Pointer to scheduler functions */
+    struct dn_sched *fp;
+};
+SLIST_HEAD(new_queue_head, new_queue);
 /*
  * Scheduler instance.
  * Contains variables and all queues relative to a this instance.
@@ -221,7 +260,7 @@ struct new_sch_inst {
 
 	/* Parent scheduler */
 	int sched_nr;
-	struct new_sch * ptr_sched;
+	struct new_sch *sched;
 
 	int hash_slot; /* used to print the id of the scheduler instance */
 
@@ -250,14 +289,13 @@ struct new_sch_inst {
  * (plus there is a FIFO scheduler for each pipe)
  */
 struct new_sch {
-	struct dn_id id;
+	struct dn_id oid;
 
 	/* these initial fields are set from the command line
 	* sched N config mask M ...
 	*/
 
 	int sched_nr; /* N, scheduler number */
-	uint64_t burst; /* burst size, scaled. bits*Hz */
 	int bucket; /* number of buckets for the instances */
 
 	/* mask to select the appropriate scheduler instance */
@@ -281,7 +319,7 @@ struct new_sch {
 
 	/* Pointer to the parent pipe */
 	int pipe_nr;
-	struct new_pipe *ptr_pipe;
+	struct new_pipe *pipe;
 
 	/* Copy of command line  */
 	#define DN_MAX_COMMAND  256
@@ -304,7 +342,7 @@ struct new_sch {
 	int flags;
 
 	/* Pointer to scheduler functions */
-	struct scheduler *fp;
+	struct dn_sched *fp;
 
 	/* Counter of packets pending to entering in this scheduler.
 	* Used to avoid to delete the scheduler if some packets are in the mutex
@@ -507,7 +545,6 @@ struct dn_flow_set {
     int avg_pkt_size ;		/* medium packet size */
     int max_pkt_size ;		/* max packet size */
 };
-SLIST_HEAD(dn_flow_set_head, dn_flow_set);
 
 struct dn_heap;
 /*
@@ -567,15 +604,4 @@ struct dn_pipe {		/* a pipe */
     int *samples;
 };
 
-/* dn_pipe_max is used to pass pipe configuration from userland onto
- * kernel space and back
- */
-#define ED_MAX_SAMPLES_NO	1024
-struct dn_pipe_max {
-	struct dn_pipe pipe;
-	int samples[ED_MAX_SAMPLES_NO];
-};
-
-SLIST_HEAD(dn_pipe_head, dn_pipe);
-
 #endif /* _IP_DUMMYNET_H */

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched.h
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched.h	Fri Jan  8 14:33:03 2010	(r201788)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched.h	Fri Jan  8 14:55:10 2010	(r201789)
@@ -120,10 +120,10 @@ struct dn_sched {
 
 	int (*config)(char *command, void *sch, int reconfigure);
 	int (*destroy)(void* sch);
-	int (*new_sched)(void *v);
+	int (*new_sched)(void *sch_priv, void *sch_t_priv);
 	int (*free_sched)(void *s);
 
-	int (*new_fs)(char *command, struct dn_id *g, int reconfigure);
+	int (*new_fs)(void *command, struct dn_id *g, int reconfigure);
 	int (*free_fs)(struct dn_id *f);
 
 	int (*new_queue)(struct new_queue *q, struct dn_id *f);

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c	Fri Jan  8 14:33:03 2010	(r201788)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c	Fri Jan  8 14:55:10 2010	(r201789)
@@ -88,7 +88,7 @@ struct dn_parms dn_cfg = {
 	.red_max_pkt_size = 1500,     /* RED - default max packet size */
 };
 
-//static long tick_last;		/* Last tick duration (usec). */
+static long tick_last;		/* Last tick duration (usec). */
 static long tick_delta;		/* Last vs standard tick diff (usec). */
 static long tick_delta_sum;	/* Accumulated tick difference (usec).*/
 static long tick_adjustment;	/* Tick adjustments done. */
@@ -133,6 +133,9 @@ MALLOC_DEFINE(M_DUMMYNET, "dummynet", "d
 
 struct new_pipe_head	pipehash[DN_HASHSIZE];	/* all pipes */
 struct new_fs_head	flowsethash[DN_HASHSIZE];	/* all flowsets */
+struct new_sch_head    schedulerhash[DN_HASHSIZE];  /* all schedulers */
+struct new_fs_head     flowsetunlinked;      /* all unlinked flowsets */
+
 
 extern	void (*bridge_dn_p)(struct mbuf *, struct ifnet *);
 
@@ -322,12 +325,13 @@ compute_extra_bits(struct mbuf *pkt, str
 {
 	int index;
 	dn_key extra_bits;
+	struct new_profile *pf = p->profile;
 
-	if (!p->samples || p->samples_no == 0)
+	if (!pf || pf->samples_no == 0)
 		return 0;
-	index  = random() % p->samples_no;
-	extra_bits = div64((dn_key)p->samples[index] * p->bandwidth, 1000);
-	if (index >= p->loss_level) {
+	index  = random() % pf->samples_no;
+	extra_bits = div64((dn_key)pf->samples[index] * p->bandwidth, 1000);
+	if (index >= pf->loss_level) {
 		struct dn_pkt_tag *dt = dn_tag_get(pkt);
 		if (dt)
 			dt->dn_dir = DIR_DROP;
@@ -335,14 +339,14 @@ compute_extra_bits(struct mbuf *pkt, str
 	return extra_bits;
 }
 
-/* Insert packet pkt into delay line */
+/* Insert packet pkt into delay line, adding the delay.
+ * dt->output_time was already set */
 static void
-move_pkt(struct mbuf *pkt, struct new_pipe *p, struct delay_line *d,
-          dn_key l_curr_time)
+move_pkt(struct mbuf *pkt, struct new_pipe *p, struct delay_line *d)
 {
 	struct dn_pkt_tag *dt = dn_tag_get(pkt);
 
-	dt->output_time = l_curr_time + p->delay ;
+	dt->output_time += p->delay ;
 
 	if (d->head == NULL)
 		d->head = pkt;
@@ -459,7 +463,7 @@ mask_are_equals (struct ipfw_flow_id *id
  * XXX why do we need separate delay lines ?
  */
 static struct new_sch_inst *
-create_scheduler_instance(struct new_sch *sch_t, dn_key l_curr_time)
+create_scheduler_instance(struct new_sch *sch_t)
 {
 	struct new_sch_inst *si;
 	int ret;
@@ -471,20 +475,13 @@ create_scheduler_instance(struct new_sch
 	if (si == NULL)
 		goto error;
 
-	si->dline = malloc(sizeof(struct delay_line), M_DUMMYNET, M_NOWAIT);
-	if (si->dline == NULL)
-		goto error;
-	si->dline->si = si;
-	set_oid(&si->dline->id, DN_DELAY_LINE, 0, sizeof(struct delay_line));
-	si->dline->head = si->dline->tail = NULL;
-
 	set_oid(&si->oid, DN_SCH_I, 0, l);
 
 	si->sched_nr = sch_t->sched_nr;
-	si->ptr_sched = sch_t;
+	si->sched = sch_t;
 
 	/* XXX do we make assumption on this starting with dn_id ? */
-	ret = sch_t->fp->new_sched((void *)(si + 1));
+	ret = sch_t->fp->new_sched(si + 1, sch_t + 1);
 	if (ret) {
 		msg = "new_sched error";
 		goto error;
@@ -493,9 +490,7 @@ create_scheduler_instance(struct new_sch
 	/* Initialize scheduler instance queues list */
 	SLIST_INIT(&si->ql_list);
 	     
-	si->oid.subtype = ((struct dn_id*)(si + 1))->subtype;
-	((struct dn_id*)(si + 1))->type = DN_SCH_I;
-	si->idle_time = l_curr_time;
+	si->idle_time = 0;
 	return si;
 
 error:
@@ -507,7 +502,7 @@ error:
 
 static struct new_sch_inst *
 find_scheduler(struct new_sch *sch_t, struct new_fs *fs,
-                struct ipfw_flow_id *id, dn_key l_curr_time)
+                struct ipfw_flow_id *id)
 {
     struct new_sch_inst *prev, *s; /* returning scheduler instance */
     struct ipfw_flow_id *id_t;
@@ -544,7 +539,7 @@ find_scheduler(struct new_sch *sch_t, st
     }
    
     if (s == NULL) { /* no match, need to allocate a new entry */
-        s = create_scheduler_instance(sch_t, l_curr_time);
+        s = create_scheduler_instance(sch_t);
         if (s == NULL)
             return NULL;
         /* Link scheduler in front of array */
@@ -559,6 +554,63 @@ find_scheduler(struct new_sch *sch_t, st
     return s;
 }
 
+/*
+ * Send traffic from a scheduler instance.
+ */
+static struct mbuf *
+serve_sched(struct new_sch_inst *s, dn_key now)
+{
+	struct mbuf *head;
+	struct new_sch *sch_t = s->sched;
+	struct mbuf *tosend = NULL;
+	dn_key len_scaled;
+	struct new_pipe *pipe = sch_t->pipe;
+	int delay_line_idle = (s->dline->head == NULL);
+	int done;
+	s->flags &= ~DN_SCH_ACTIVE;
+
+	if (pipe->bandwidth > 0)
+		s->numbytes += (now - s->sched_time) * pipe->bandwidth;
+	else
+		s->numbytes = 0;
+	s->sched_time = now;
+	done = 0;
+	while (s->numbytes >= 0 && (tosend = sch_t->fp->dequeue(s + 1)) != NULL) {
+		done++;
+		len_scaled = pipe->bandwidth ? tosend->m_pkthdr.len * 8 * hz
+			+ compute_extra_bits(tosend, pipe) * hz : 0;
+		s->numbytes -= len_scaled;
+		/* Move packet in the delay line */
+		move_pkt(tosend, pipe, s->dline);
+	}
+	if (done > 0 && s->numbytes < 0) {
+		/* credit has become negative, so reinsert the
+		* instance in the heap for when credit will be
+		* positive again. Also update the output time
+		* of the last packet, which is 'tosend'
+		*/
+		dn_key t = 0;
+		if (pipe->bandwidth > 0)
+			t = (pipe->bandwidth - 1 - s->numbytes) / pipe->bandwidth;
+		/* Delay the output time because under credit */
+		dn_tag_get(tosend)->output_time += t;
+
+		s->sched->inst_counter++;
+		s->flags |= DN_SCH_ACTIVE;
+		DN_HEAP_LOCK();
+		heap_insert(system_heap, curr_time + t, s);
+		DN_HEAP_UNLOCK();
+	} else {
+		/* scheduler instance should be idle, because it
+		 * did not return packets while credit was available.
+		 */
+		s->idle_time = curr_time;
+	}
+
+	head = (delay_line_idle && done) ?
+		transmit_event(s->dline, curr_time) : NULL;
+	return head;
+}
 
 /*
  * The timer handler for dummynet. Time is computed in ticks, but
@@ -568,21 +620,13 @@ find_scheduler(struct new_sch *sch_t, st
 void
 dummynet_task(void *context, int pending)
 {
-#if 0
-	struct mbuf *head = NULL, *tail = NULL;
-	struct new_pipe *pipe;
-	struct dn_heap *heaps[3];
-	struct dn_heap *h;
-	void *p;	/* generic parameter to handler */
-	int i;
+	struct new_sch_inst *s;
+	struct new_sch *sch_t;
+	struct mbuf *head = NULL;
 	struct timeval t;
 
 	DUMMYNET_LOCK();
 
-	heaps[0] = &ready_heap;			/* fixed-rate queues */
-	heaps[1] = &wfq_ready_heap;		/* wfq queues */
-	heaps[2] = &extract_heap;		/* delay line */
-
  	/* Update number of lost(coalesced) ticks. */
  	tick_lost += pending - 1;
  
@@ -617,54 +661,82 @@ dummynet_task(void *context, int pending
  		tick_delta_sum += tick;
  		tick_adjustment++;
  	}
+	DUMMYNET_UNLOCK();
+	for (;;) {
+	    struct dn_id *p;    /* generic parameter to handler */
+	    DN_HEAP_LOCK();
+	    if (system_heap->elements > 0 &&
+		DN_KEY_LEQ(HEAP_TOP(system_heap)->key, curr_time)) {
+		    p = HEAP_TOP(system_heap)->object;
+		    heap_extract(system_heap, NULL);
+	    } else {
+		p = NULL;
+	    }
+	    DN_HEAP_UNLOCK();
+	    if (p == NULL)
+		break;
 
-	for (i = 0; i < 3; i++) {
-		h = heaps[i];
-		while (h->elements > 0 && DN_KEY_LEQ(HEAP_TOP(h)->key, curr_time)) {
-			// XXX can this happen ?
-			if (HEAP_TOP(h)->key > curr_time)
-				printf("dummynet: warning, "
-				    "heap %d is %d ticks late\n",
-				    i, (int)(curr_time - HEAP_TOP(h)->key));
-			/* store a copy before heap_extract */
-			p = HEAP_TOP(h)->object;
-			/* need to extract before processing */
-			heap_extract(h, NULL);
-			if (i == 0)
-				ready_event(p, &head, &tail);
-			else if (i == 1) {
-				struct dn_pipe *pipe = p;
-				if (pipe->if_name[0] != '\0')
-					printf("dummynet: bad ready_event_wfq "
-					    "for pipe %s\n", pipe->if_name);
-				else
-					ready_event_wfq(p, &head, &tail);
-			} else
-				transmit_event(p, &head, &tail);
+	    if (p->type == DN_SCH_I) {
+		/*
+		 * Working with scheduler instances:
+		 * - Remove a scheduler instance from the heap and decrement
+		 *   the scheduler counter.
+		 * - If the scheduler is deleting and no other scheduler
+		 *   instances (of this scheduler) are into the heap,
+		 *   it's now possible to delete scheduler and call the
+		 *   function to do this;
+		 * - If the scheduer is deleting and this isn't the last
+		 *   instance in the heap, don't call the dequeue() function
+		 *   so the instance isn't inserted in the heap
+		 * - Else, call the dequeue() function.
+		 */
+		s = (struct new_sch_inst *)p;
+		sch_t = s->sched;
+		DN_S_LOCK(sch_t);
+
+		sch_t->inst_counter--;
+		if (sch_t->flags & DN_SCH_DELETE) {
+		    /* Wait for scheduler->busy == 0 */
+		    while(sch_t->busy) { /* XXX check */
+			DN_S_UNLOCK(sch_t);
+			DN_S_LOCK(sch_t);
+		    }
+		    /* Scheduler is deleting, don't dequeue packets from
+		     * this instance
+		     */
+		    if (sch_t->inst_counter == 0) {
+			/* No other scheduler instance in the heap.
+			 * We can safely delete scheduler
+			 */
+			really_deletescheduler(sch_t);
+			DN_S_UNLOCK(sch_t); /* XXX */
+		    }
+		} else {
+		    head = serve_sched(s, curr_time);
+		    DN_S_UNLOCK(sch_t);
+		    if (head != NULL)
+			dummynet_send(head);
 		}
-	}
-
-	/* Sweep pipes trying to expire idle flow_queues. */
-	for (i = 0; i < DN_HASHSIZE; i++) {
-		SLIST_FOREACH(pipe, &pipehash[i], next) {
-			if (pipe->idle_heap->elements > 0 &&
-			    DN_KEY_LT(HEAP_TOP(pipe->idle_heap)->key, pipe->V)) {
-				struct dn_flow_queue *q =
-				    HEAP_TOP(pipe->idle_heap)->object;
-
-				heap_extract(pipe->idle_heap, NULL);
-				/* Mark timestamp as invalid. */
-				q->S = q->F + 1;
-				pipe->sum -= q->fs->weight;
-			}
+	    } else { /* extracted a delay line */
+		struct delay_line *dline = (struct delay_line *)p;
+		/*
+		 * Managing delay lines.
+		 * If the pointer to the scheduler instance is NULL, the delay
+		 * line should be deleted because pipe or scheduler was deleted,
+		 * else the transmit event is called to send out packets and
+		 * eventually reinsert the delay line into the heap.
+		 */
+		if (dline->si == NULL)
+		    delete_delay_line(dline);
+		else {
+		    DN_S_LOCK(dline->si->ptr_sched);
+		    head = transmit_event(dline, curr_time);
+		    DN_S_UNLOCK(dline->si->ptr_sched);
+		    if (head != NULL)
+			dummynet_send(head);
 		}
-	}
-
-	DUMMYNET_UNLOCK();
-
-	if (head != NULL)
-		dummynet_send(head);
-#endif
+	    }
+        }
 	dn_reschedule();
 }
 
@@ -1047,19 +1119,6 @@ ipdn_locate_flowset(int fs_nr)
 	return (NULL);
 }
 
-struct new_pipe *
-ipdn_locate_pipe(int pipe_nr)
-{
-	struct new_pipe *pipe;
-
-	SLIST_FOREACH(pipe, &pipehash[HASH(pipe_nr)], next)
-		if (pipe->pipe_nr == pipe_nr)
-			return (pipe);
-
-	return (NULL);
-}
-
-
 /*
  * dummynet hook for packets. Below 'pipe' is a pipe or a queue
  * depending on whether WF2Q or fixed bw is used.
@@ -1084,20 +1143,21 @@ dummynet_io(struct mbuf **m0, int dir, s
 	struct new_fs *fs = NULL;
 	struct new_pipe *pipe = NULL;
 	struct new_queue *q = NULL;
-	int fs_id = fwa->rule.info & IPFW_INFO_MASK;
 	struct new_sch *sch;
 	struct new_sch_inst *sch_inst;
 	struct delay_line *dline;
 	int ret;
-	dn_key l_curr_time; /* save a copy of curr_time */
+	dn_key now; /* save a copy of curr_time */
 	int delay_line_idle;
-
-	if (fwa->rule.info & IPFW_IS_PIPE)
-		fs_id += DN_PIPEOFFSET;
+	int fs_id = (fwa->rule.info & IPFW_INFO_MASK) +
+		(fwa->rule.info & IPFW_IS_PIPE) ? DN_PIPEOFFSET : 0;
 
 	KASSERT(m->m_nextpkt == NULL,
 	    ("dummynet_io: mbuf queue passed to dummynet"));
 
+	/*
+	 * find flowset and schedset, protected by the UH lock
+	 */
 	DUMMYNET_LOCK();
 	io_pkt++;
 	fs = ipdn_locate_flowset(fs_id);
@@ -1105,7 +1165,7 @@ dummynet_io(struct mbuf **m0, int dir, s
 	if (fs == NULL)
 		goto dropit;	/* This queue/pipe does not exist! */
 
-	if (fs->sched_id != dn_cfg.id) {
+	if (fs->sched_id != dn_cfg.id) { /* fs->sched invalid, update */
 		/* configuration changed, update */
 		int ret = dn_fs_config(fs);
 		if (ret)
@@ -1119,11 +1179,12 @@ dummynet_io(struct mbuf **m0, int dir, s
 	if (sch == NULL)
 		goto dropit;
 	pipe = sch->pipe;
-	if (pipe == NULL)	/* should not happen ? */
+	if (pipe == NULL) {	/* should not happen ? */
+		printf("%s strange, scheduler without a pipe\n", __FUNCTION__);
 		goto dropit;
+	}
 
-	l_curr_time = curr_time;
-	sch_inst = find_scheduler(sch, fs, &(fwa->f_id), l_curr_time);
+	sch_inst = find_scheduler(sch, fs, &(fwa->f_id));
 	if (sch_inst == NULL)
 		goto dropit;
 	dline = sch_inst->dline;
@@ -1148,6 +1209,8 @@ dummynet_io(struct mbuf **m0, int dir, s
 	pkt->rule.info &= IPFW_ONEPASS;	/* only keep this info */
 	pkt->dn_dir = dir;
 	pkt->ifp = fwa->oif;
+	now = curr_time; /* in case it changes, use the same value */
+	pkt->output_time = now; /* XXX rewritten when reaches head */
 
 	/*
 	 * - 'sch_inst + 1' is the pointer to scheduler instance's
@@ -1158,82 +1221,45 @@ dummynet_io(struct mbuf **m0, int dir, s
 	 *       packet, it must call the queue_packet()
 	 */
 
-	ret = sch->fp->enqueue(
-		(sch_inst + 1), fs->alg_fs, m,
-			&(fwa->f_id));
+	ret = sch->fp->enqueue(sch_inst + 1, fs->alg_fs, m, &(fwa->f_id));
 
 	if (ret) { /* packet was dropped by enqueue() */
 		*m0 = NULL;
 		goto dropit;
 	}
 
-   /*
-     * Now check if the dequeue should be called now.
-     * If the instance is in the heap, the dequeue() will be called later,
-     * else if the instance has credit the dequeue() is called now.
-     */
-    if (!(sch_inst->flags & DN_SCH_ACTIVE)) {
+	/*
+	 * Now check if the dequeue should be called now.
+	 * If the instance is in the heap, the dequeue() will be called later,
+	 * and we are done.
+	 */
+	if (sch_inst->flags & DN_SCH_ACTIVE)
+		goto done;
+	// XXX see if we can merge with dummynet task.
         /* If the instance is not in the heap, credit must be >= 0 */
-        struct mbuf *tosend;
-        dn_key len_scaled;
 
-        /* If the instance isn't in the heap, it is idle, so we can skip
-         * some checks XXX
-         */
-        if (sch->burst) {
-            sch_inst->numbytes = (l_curr_time - sch_inst->idle_time) *
+        sch_inst->numbytes = dn_cfg.io_fast ? pipe->bandwidth : 0;
+        if (pipe->burst) {
+		uint64_t burst = (now - sch_inst->idle_time) *
                                     pipe->bandwidth;
-            if (sch_inst->numbytes > sch->burst)
-                sch_inst->numbytes = sch->burst;
-            sch_inst->numbytes += dn_cfg.io_fast ? pipe->bandwidth : 0;
-        } else
-            sch_inst->numbytes = dn_cfg.io_fast ? pipe->bandwidth : 0;
-
-        sch_inst->idle_time = l_curr_time;
-
-        /* Doing an 'if' instead of 'while' because only the packet
-         * just enqueued can be returned by dequeue() */
-        tosend = sch->fp->dequeue(sch_inst + 1);
-        if (tosend) {
-            len_scaled = pipe->bandwidth ? tosend->m_pkthdr.len * 8 * hz +
-                            compute_extra_bits(tosend, pipe) * hz : 0;
-            sch_inst->numbytes -= len_scaled;
-            /* Move packet in the delay line XXX three parameters? */
-            move_pkt(tosend, pipe, sch_inst->dline, l_curr_time);
-            if (sch_inst->numbytes < 0) {
-                /*
-                 * Credit became negative, so insert the instance in the
-                 * heap so that it will not be wake up until credit come
-                 * back positive
-                 * NOTE: numbytes < 0 implies bandwidth != 0.
-                 */
-                dn_key t = 0, tmp;
-                t = (pipe->bandwidth - 1 - sch_inst->numbytes) /
-                                                   pipe->bandwidth;
-                /* Delay the output time because under credit */
-                (dn_tag_get(dline->tail))->output_time += t;
-
-                sch_inst->ptr_sched->inst_counter++;
-                sch_inst->flags |= DN_SCH_ACTIVE;
-                tmp = l_curr_time + t;
-                //DN_HEAP_LOCK();
-                heap_insert(system_heap, (uint64_t)tmp, sch_inst);
-                //DN_HEAP_UNLOCK();
-            }
-            if (delay_line_idle)
-                head = transmit_event(dline, l_curr_time);
+		if (burst > pipe->burst)
+			burst = pipe->burst;
+		sch_inst->numbytes += burst;
         }
-    }
+	head = serve_sched(sch_inst, now);
 
-    if (dn_cfg.io_fast && head == m && (dir & PROTO_LAYER2) == 0 ) {
-	/* fast io */
-        io_pkt_fast++;
-        printf("dummynet TEST: ** IOFAST **\n");
-        if (m->m_nextpkt != NULL)
-            printf("dummynet: fast io: pkt chain detected!\n");
-        head = m->m_nextpkt = NULL;
-    } else
-        *m0 = NULL;
+	/* optimization -- pass it back to ipfw for immediate send */
+	if (dn_cfg.io_fast && head == m && (dir & PROTO_LAYER2) == 0 ) {
+		/* fast io */
+		io_pkt_fast++;
+		printf("dummynet TEST: ** IOFAST **\n");
+		if (m->m_nextpkt != NULL)
+			printf("dummynet: fast io: pkt chain detected!\n");
+		head = m->m_nextpkt = NULL;
+	} else {
+		*m0 = NULL;
+	}
+done:
     DUMMYNET_UNLOCK();
     if (head != NULL)
         dummynet_send(head);

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Fri Jan  8 14:33:03 2010	(r201788)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Fri Jan  8 14:55:10 2010	(r201789)
@@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$");
 #include <netinet/ipfw/dn_heap.h>
 #include <netinet/ip_dummynet.h>
 #include <netinet/ipfw/ip_dn_private.h>
+#include <netinet/ipfw/dn_sched.h>
 
 //#include <netinet/if_ether.h> /* various ether_* routines */
 
@@ -72,6 +73,9 @@ static int	ip_dn_ctl(struct sockopt *sop
 static struct callout dn_timeout;
 static struct task	dn_task;
 static struct taskqueue	*dn_tq = NULL;
+
+static struct dn_sched_head    list_of_scheduler;
+
 /*
  * This is called one tick, after previous run. It is used to
  * schedule next run.
@@ -91,6 +95,23 @@ dn_reschedule(void)
 
 
 /*
+ * Return a scheduler descriptor given the type.
+ * If the descriptor isn't found, return NULL. This case shouldn't occur.
+ */
+static struct dn_sched *
+load_scheduler(int type)
+{
+    struct dn_sched *d = NULL;
+
+    SLIST_FOREACH(d, &list_of_scheduler, next) {
+        if (d->type == type)
+            return d;
+    }
+ 
+    return NULL; /* error */
+}
+
+/*
  * Dispose a list of packet. Use an inline functions so if we
  * need to free extra state associated to a packet, this is a
  * central point to do it.
@@ -106,11 +127,71 @@ static __inline void dn_free_pkts(struct
         }
 }
 
+int
+delete_delay_line(struct delay_line *dline)
+{
+    struct mbuf *m;
+                     
+    m = dline->head;
+    dn_free_pkts(m);
+    free(dline, M_DUMMYNET);
+    return 0;
+}
+
+static int
+delete_scheduler_instance(struct new_sch_inst *si)
+{
+    struct new_sch *sch_t = si->sched;
+ 
+    sch_t->fp->free_sched(si + 1);
+    /* XXX packet from delay line must be freed */
+    if (si->dline->head == NULL || sch_t->flags & DN_SCH_DELETE_DELAY_LINE) {
+        /* Delay line empty, or forced delete, so delete delay line now */
+        delete_delay_line(si->dline);
+    } else {
+        /* Packet in delay line, will be removed when extracted from heap */
+        si->dline->si = NULL;
+    }
+    free(si, M_DUMMYNET);
+    return 0;
+}
+
+/*
+ * Called when no scheduler instances are in the heap, so it's safe
+ * to remove the scheduler template, scheduler hash table and scheduler
+ * instances
+ */
+int
+really_deletescheduler(struct new_sch *sch_t)
+{
+    int i;
+    struct new_sch_inst *si, *sid;
+        
+    /* XXX checks, maybe all scheduler instance are deleted before */
+    for (i = 0; i < sch_t->sch_i_size; i++) {
+        si = sch_t->sch_i[i];
+        while (si) {
+            sid = si;
+            si = si->next;
+            /* remove scheduler instance */
+            delete_scheduler_instance(sid);
+        }
+    }
+    sch_t->fp->free_sched(sch_t + 1);
+    sch_t->fp->ref_count--;
+    DN_S_LOCK_DESTROY(sch_t);
+    if (sch_t->sch_i_size > 0)
+        free(sch_t->sch_i, M_DUMMYNET);
+    free(sch_t, M_DUMMYNET);
+    return 0;
+}
+
+
 static void
 free_pipe(struct new_pipe *p)
 {
-        if (p->samples)
-                free(p->samples, M_DUMMYNET);
+        if (p->profile)
+                free(p->profile, M_DUMMYNET);
         free(p, M_DUMMYNET);
 }
 
@@ -322,6 +403,242 @@ do_config(void *p, int l)
 	return 0;
 }
 
+static struct new_sch *
+locate_scheduler(int sch_nr)
+{
+    struct new_sch *sch;
+
+    SLIST_FOREACH(sch, &schedulerhash[HASH(sch_nr)], next)
+        if (sch->sched_nr == sch_nr)
+            return (sch);
+
+    return (NULL);
+}
+
+static struct new_pipe *
+locate_pipe(int pipe_nr)
+{
+        struct new_pipe *pipe;
+
+        SLIST_FOREACH(pipe, &pipehash[HASH(pipe_nr)], next)
+                if (pipe->pipe_nr == pipe_nr)
+                        return (pipe);
+
+        return (NULL);
+}
+
+/*
+ * Starting from a flow set, check if pointers are ok.
+ * First, check if the scheduler exist and eventually if the pipe exists.
+ * If the scheduler is NULL, the flowset should be inserted in the unlinked
+ * flowset list and removed from flowset list. So new packet are discarded
+ * when they arrives, and this flowset become of general type and can be

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***

From owner-svn-src-user@FreeBSD.ORG  Fri Jan  8 15:18:58 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 E4400106566B;
	Fri,  8 Jan 2010 15:18:57 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id D29BD8FC14;
	Fri,  8 Jan 2010 15:18:57 +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 o08FIvpv009601;
	Fri, 8 Jan 2010 15:18:57 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o08FIvhO009598;
	Fri, 8 Jan 2010 15:18:57 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001081518.o08FIvhO009598@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Fri, 8 Jan 2010 15:18:57 +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: r201791 - user/ed/utmpx/lib/libc/gen
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: Fri, 08 Jan 2010 15:18:58 -0000

Author: ed
Date: Fri Jan  8 15:18:57 2010
New Revision: 201791
URL: http://svn.freebsd.org/changeset/base/201791

Log:
  Already add a stub manpage to document utmpx.

Added:
  user/ed/utmpx/lib/libc/gen/getutxent.3   (contents, props changed)
Modified:
  user/ed/utmpx/lib/libc/gen/Makefile.inc

Modified: user/ed/utmpx/lib/libc/gen/Makefile.inc
==============================================================================
--- user/ed/utmpx/lib/libc/gen/Makefile.inc	Fri Jan  8 14:55:11 2010	(r201790)
+++ user/ed/utmpx/lib/libc/gen/Makefile.inc	Fri Jan  8 15:18:57 2010	(r201791)
@@ -54,7 +54,7 @@ MAN+=	alarm.3 arc4random.3 \
 	getgrent.3 getgrouplist.3 gethostname.3 getloadavg.3 \
 	getmntinfo.3 getnetgrent.3 getosreldate.3 getpagesize.3 \
 	getpagesizes.3 getpass.3 getpeereid.3 getprogname.3 getpwent.3 \
-	getttyent.3 getusershell.3 getvfsbyname.3 \
+	getttyent.3 getusershell.3 getutxent.3 getvfsbyname.3 \
 	glob.3 initgroups.3 isgreater.3 ldexp.3 lockf.3 makecontext.3 \
 	modf.3 \
 	nice.3 nlist.3 pause.3 popen.3 \
@@ -126,6 +126,10 @@ MLINKS+=getttyent.3 endttyent.3 getttyen
 	getttyent.3 isdialuptty.3 getttyent.3 isnettty.3 \
 	getttyent.3 setttyent.3
 MLINKS+=getusershell.3 endusershell.3 getusershell.3 setusershell.3
+MLINKS+=getutxent.3 endutxent.3 getutxent.3 getutxid.3 \
+	getutxent.3 getutxline.3 getutxent.3 getutxuser.3 \
+	getutxent.3 pututxline.3 getutxent.3 setutxdb.3 \
+	getutxent.3 setutxent.3
 MLINKS+=glob.3 globfree.3
 MLINKS+=isgreater.3 isgreaterequal.3 isgreater.3 isless.3 \
 	isgreater.3 islessequal.3 isgreater.3 islessgreater.3 \

Added: user/ed/utmpx/lib/libc/gen/getutxent.3
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/ed/utmpx/lib/libc/gen/getutxent.3	Fri Jan  8 15:18:57 2010	(r201791)
@@ -0,0 +1,66 @@
+.\" Copyright (c) 2010 Ed Schouten <ed@FreeBSD.org>
+.\" 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 AND CONTRIBUTORS ``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.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd January 8, 2010
+.Os
+.Dt GETUTXENT 3
+.Sh NAME
+.Nm endutxent ,
+.Nm getutxent ,
+.Nm getutxid ,
+.Nm getutxline ,
+.Nm getutxuser ,
+.Nm pututxline ,
+.Nm setutxdb ,
+.Nm setutxent
+.Nd user accounting database functions
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In utmpx.h
+.Ft void
+.Fn endutxent "void"
+.Ft struct utmpx *
+.Fn getutxent "void"
+.Ft struct utmpx *
+.Fn getutxid "const struct utmpx *id"
+.Ft struct utmpx *
+.Fn getutxline "const struct utmpx *line"
+.Ft struct utmpx *
+.Fn getutxuser "const char *user"
+.Ft struct utmpx *
+.Fn pututxline "const struct utmpx *utmpx"
+.Ft int
+.Fn setutxdb "int type" "const char *file"
+.Ft void
+.Fn setutxent "void"
+.Sh DESCRIPTION
+.Sh RETURN VALUES
+.Sh SEE ALSO
+.Sh STANDARDS
+.Sh HISTORY
+These functions appeared in
+.Fx 9.0 .

From owner-svn-src-user@FreeBSD.ORG  Fri Jan  8 16:07:39 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 996841065670;
	Fri,  8 Jan 2010 16:07:39 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 7D1F98FC15;
	Fri,  8 Jan 2010 16:07:39 +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 o08G7dsj020627;
	Fri, 8 Jan 2010 16:07:39 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o08G7dQj020625;
	Fri, 8 Jan 2010 16:07:39 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001081607.o08G7dQj020625@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Fri, 8 Jan 2010 16:07:39 +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: r201800 - user/ed/utmpx/lib/libc/gen
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: Fri, 08 Jan 2010 16:07:39 -0000

Author: ed
Date: Fri Jan  8 16:07:39 2010
New Revision: 201800
URL: http://svn.freebsd.org/changeset/base/201800

Log:
  Already add the first part of the manual page.

Modified:
  user/ed/utmpx/lib/libc/gen/getutxent.3

Modified: user/ed/utmpx/lib/libc/gen/getutxent.3
==============================================================================
--- user/ed/utmpx/lib/libc/gen/getutxent.3	Fri Jan  8 15:57:56 2010	(r201799)
+++ user/ed/utmpx/lib/libc/gen/getutxent.3	Fri Jan  8 16:07:39 2010	(r201800)
@@ -58,6 +58,120 @@
 .Ft void
 .Fn setutxent "void"
 .Sh DESCRIPTION
+These functions operate on the user accounting database which stores
+records of various system activities, such as user login and logouts,
+but also system startups and shutdowns and modifications to the system's
+clock.
+The system stores these records in three databases, each having a
+different purpose:
+.Bl -tag -width indent
+.It Pa /var/run/utx.active
+Log of currently active user login sessions.
+This file is similar to the traditional
+.Pa utmp
+file.
+This file only contains process related entries, such as user login and
+logout records.
+.It Pa /var/log/utx.lastlogin
+Log of last user login entries per user.
+This file is similar to the traditional
+.Pa lastlog
+file.
+This file only contains user login records for users who have at least
+logged in once.
+.It Pa /var/log/utx.log
+Log of all entries, sorted by date of addition.
+This file is similar to the traditional
+.Pa wtmp
+file.
+This file may contain any type of record described below.
+.El
+.Pp
+Each entry in these databases is defined by the structure
+.Vt utmpx
+found in the include file
+.In utmpx.h :
+.Bd -literal -offset indent
+struct utmpx {
+	char	ut_user[];	/* User login name. */
+	char	ut_id[];	/* Process identifier. */
+	char	ut_line[];	/* Device name. */
+	char	ut_host[];	/* Remote hostname. */
+	pid_t	ut_pid;		/* Process ID. */
+	short	ut_type;	/* Type of entry. */
+	struct timeval ut_tv;	/* Time entry was made. */
+};
+.Ed
+.Pp
+The
+.Fa ut_type
+field indicates the type of the log entry, which can have one of the
+following values:
+.Bl -tag -width LOGIN_PROCESS
+.It Dv EMPTY
+No valid user accounting information.
+.It Dv BOOT_TIME
+Identifies time of system boot.
+.It Dv SHUTDOWN_TIME
+Indentifies time of system shutdown.
+.It Dv OLD_TIME
+Identifies time when system clock changed.
+.It Dv NEW_TIME
+Identifies time after system clock changed.
+.It Dv USER_PROCESS
+Identifies a process.
+.It Dv INIT_PROCESS
+Identifies a process spawned by the init process.
+.It Dv LOGIN_PROCESS
+Identifies the session leader of a logged-in user.
+.It Dv DEAD_PROCESS
+Identifies a session leader who has exited.
+.El
+.Pp
+Entries of type
+.Dv INIT_PROCESS
+and
+.Dv LOGIN_PROCESS
+are not processed by this implementation.
+.Pp
+Other fields inside the structure are:
+.Bl -tag -width ut_user
+.It Fa ut_user
+The user login name corresponding with the login session.
+This field is only applicable to entries of type
+.Dv USER_PROCESS
+and
+.Dv INIT_PROCESS .
+For
+.Dv INIT_PROCESS
+entries this entry typically contains the name of the login process.
+.It Fa ut_id
+An identifier that is used to refer to the entry.
+This identifier can be used to remove or replace a login entry by
+writing a new entry to the database containing the same value for
+.Fa ut_id .
+This field is only applicable to entries of type
+.Dv USER_PROCESS ,
+.Dv INIT_PROCESS ,
+.Dv LOGIN_PROCESS
+and
+.Dv DEAD_PROCESS .
+.It Fa ut_line
+The name of the TTY character device, without the leading
+.Pa /dev/
+prefix, corresponding with the device used to facilitate the user login
+session.
+If no TTY character device is used, this field is left blank.
+This field is only applicable to entries of type
+.Dv USER_PROCESS .
+.It Fa ut_host
+The network hostname of the remote system, connecting to perform a user
+login.
+If the user login session is not performed across a network, this field
+is left blank.
+This field is only applicable to entries of type
+.Dv USER_PROCESS .
+.El
 .Sh RETURN VALUES
 .Sh SEE ALSO
 .Sh STANDARDS

From owner-svn-src-user@FreeBSD.ORG  Fri Jan  8 16:58:37 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 DCFE61065676;
	Fri,  8 Jan 2010 16:58:37 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id CA0B38FC12;
	Fri,  8 Jan 2010 16:58:37 +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 o08GwbVL032000;
	Fri, 8 Jan 2010 16:58:37 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o08GwbNI031998;
	Fri, 8 Jan 2010 16:58:37 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001081658.o08GwbNI031998@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Fri, 8 Jan 2010 16:58:37 +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: r201805 - user/luigi/ipfw3-head/sys/netinet/ipfw
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: Fri, 08 Jan 2010 16:58:38 -0000

Author: luigi
Date: Fri Jan  8 16:58:37 2010
New Revision: 201805
URL: http://svn.freebsd.org/changeset/base/201805

Log:
  add missing file

Added:
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h   (contents, props changed)

Added: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h	Fri Jan  8 16:58:37 2010	(r201805)
@@ -0,0 +1,127 @@
+/*-
+ * Copyright (c) 2010 Luigi Rizzo, Riccardo Panicucci, Universita` di Pisa
+ * 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 AND CONTRIBUTORS ``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 _IP_DN_PRIVATE_H
+#define _IP_DN_PRIVATE_H
+
+/*
+ * internal dummynet APIs.
+ */
+#define div64(a, b)     ((int64_t)(a) / (int64_t)(b))
+
+MALLOC_DECLARE(M_DUMMYNET);
+
+extern struct mtx dummynet_mtx;
+#define DUMMYNET_LOCK_INIT() \
+        mtx_init(&dummynet_mtx, "dummynet", NULL, MTX_DEF)
+#define DUMMYNET_LOCK_DESTROY() mtx_destroy(&dummynet_mtx)
+#define DUMMYNET_LOCK()         mtx_lock(&dummynet_mtx)
+#define DUMMYNET_UNLOCK()       mtx_unlock(&dummynet_mtx)
+#define DUMMYNET_LOCK_ASSERT()  mtx_assert(&dummynet_mtx, MA_OWNED)
+
+#define DN_S_LOCK(x)
+#define DN_S_UNLOCK(x)
+#define DN_S_LOCK_DESTROY(x)
+
+#define DN_HEAP_LOCK(x)
+#define DN_HEAP_UNLOCK(x)
+
+#define	DN_HASHSIZE	16
+#define HASH(num)       ((((num) >> 8) ^ ((num) >> 4) ^ (num)) & 0x0f)
+
+SLIST_HEAD(new_pipe_head, new_pipe);
+SLIST_HEAD(new_sch_head, new_sch);
+SLIST_HEAD(new_fs_head, new_fs);
+extern struct new_pipe_head      pipehash[DN_HASHSIZE];  /* all pipes */
+extern struct new_fs_head  flowsethash[DN_HASHSIZE]; /* all flowsets */
+extern struct new_sch_head    schedulerhash[DN_HASHSIZE];  /* all schedulers    */
+extern struct new_fs_head     flowsetunlinked;      /* all unlinked flowsets */
+
+
+/*
+ * global configuration parameters.
+ *
+ * When a configuration is modified from userland, 'id' is incremented
+ * so we can use the value to check for stale pointers.
+ */
+struct dn_parms {
+	uint32_t	id;		/* configuration version */
+	int	red_lookup_depth;
+	int	red_avg_pkt_size;
+	int	red_max_pkt_size;
+	int	hash_size;
+	long	pipe_byte_limit;
+	long	pipe_slot_limit;
+
+	int	io_fast;
+	struct timeval prev_t;
+};
+
+static inline void
+set_oid(struct dn_id *o, int type, int subtype, int len)
+{
+	o->type = type;
+	o->subtype = subtype;
+	o->len = len;
+};
+
+/*
+ * Delay line, contains all packets that will be send out at certain time.
+ * Every scheduler instance has a delay line
+ */
+struct delay_line {
+	struct dn_id oid;
+
+	/* Pointer to scheduler instance, NULL if the instance
+	 * has been deleted */
+	struct new_sch_inst *si;
+	struct mbuf *head, *tail; /* Packets queue */
+};
+
+/* These values are in the flag field of a flowset
+ * Some of them are used only by kernel (k)
+ */
+enum flowset_flag {
+    DN_FS_DELETE        = 0x0001, /* (k) */
+    DN_FS_REENQUEUE     = 0x0002, /* (k) */
+    DN_FS_HAVE_MASK     = 0x0004,
+    DN_FS_QSIZE_BYTES   = 0x0008,
+    DN_FS_NOERROR          = 0x0010, /* (k) do not report ENOBUFS on drops  */
+};
+
+extern struct dn_parms dn_cfg;
+
+struct new_pipe *ipdn_locate_pipe(int);
+struct new_fs *ipdn_locate_flowset(int);
+int     dummynet_io(struct mbuf **, int , struct ip_fw_args *);
+void dummynet_task(void *context, int pending);
+void dn_reschedule(void);
+int dn_fs_config(struct new_fs *);
+int delete_delay_line(struct delay_line *dline);
+int really_deletescheduler(struct new_sch *sch_t);
+
+
+#endif /* _IP_DN_PRIVATE_H */

From owner-svn-src-user@FreeBSD.ORG  Fri Jan  8 17:21:57 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 38E101065695;
	Fri,  8 Jan 2010 17:21:57 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 2795C8FC08;
	Fri,  8 Jan 2010 17:21:57 +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 o08HLvhF039065;
	Fri, 8 Jan 2010 17:21:57 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o08HLvgu039063;
	Fri, 8 Jan 2010 17:21:57 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001081721.o08HLvgu039063@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Fri, 8 Jan 2010 17:21:57 +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: r201808 - user/ed/utmpx/lib/libc/gen
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: Fri, 08 Jan 2010 17:21:57 -0000

Author: ed
Date: Fri Jan  8 17:21:56 2010
New Revision: 201808
URL: http://svn.freebsd.org/changeset/base/201808

Log:
  Document utmpx a little further.

Modified:
  user/ed/utmpx/lib/libc/gen/getutxent.3

Modified: user/ed/utmpx/lib/libc/gen/getutxent.3
==============================================================================
--- user/ed/utmpx/lib/libc/gen/getutxent.3	Fri Jan  8 17:20:41 2010	(r201807)
+++ user/ed/utmpx/lib/libc/gen/getutxent.3	Fri Jan  8 17:21:56 2010	(r201808)
@@ -171,7 +171,178 @@ If the user login session is not perform
 is left blank.
 This field is only applicable to entries of type
 .Dv USER_PROCESS .
+.It Fa ut_pid
+The process identifier of the session leader of the login session.
+This field is only applicable to entries of type
+.Dv USER_PROCESS ,
+.Dv INIT_PROCESS ,
+.Dv LOGIN_PROCESS
+and
+.Dv DEAD_PROCESS .
+.It Fa ut_tv
+The time the event occured.
+This field is used for all types of entries.
 .El
+.Pp
+This implementation guarantees all inapplicable fields to be discarded.
+The
+.Fa ut_user ,
+.Fa ut_line
+and
+.Fa ut_host
+fields of the structure returned by the library functions are also
+guaranteed to be null-terminated in this implementation.
+.Pp
+The
+.Fn getutxent
+function can be used to read the next entry from the user accounting
+database.
+.Pp
+The
+.Fn getutxid
+function searches for the next entry in the database of which the
+behaviour is based on the
+.Fa ut_type
+field of
+.Fa id .
+If
+.Fa ut_type
+has a value of
+.Dv BOOT_TIME ,
+.Dv SHUTDOWN_TIME ,
+.Dv OLD_TIME
+or
+.Dv NEW_TIME ,
+it will return the next entry whose
+.Fa ut_type
+has an equal value.
+If
+.Fa ut_type
+has a value of
+.Dv INIT_PROCESS ,
+.Dv LOGIN_PROCESS ,
+.Dv USER_PROCESS
+or
+.Dv DEAD_PROCESS ,
+it will return the next entry whose
+.Fa ut_type
+has one of the previously mentioned values and whose
+.Fa ut_id
+is equal.
+.Pp
+The
+.Fn getutxline
+function searches for the next entry in the database whose
+.Fa ut_type
+has a value of
+.Dv LOGIN_PROCESS
+or
+.Dv USER_PROCESS
+and whose
+.Fa ut_line
+is equal to the the same field in
+.Fa line .
+.Pp
+The
+.Fn getutxuser
+function searches for the next entry in the database whose
+.Fa ut_type
+has a value of
+.Dv USER_PROCESS
+and whose
+.Fa ut_user
+is equal to
+.Fa user .
+.Pp
+The previously mentioned functions will automatically try to open the
+user accounting database if not already done so.
+The
+.Fn setutxdb
+and
+.Fn setutxent
+functions allow the database to be opened manually, causing the offset
+within the user accounting database to be rewound.
+The
+.Fn endutxent
+function closes the database.
+.Pp
+The
+.Fn setutxent
+database always opens the active sessions database.
+The
+.Fn setutxdb
+function opens the database identified by
+.Fa type ,
+whose value is either
+.Dv UTXDB_ACTIVE ,
+.Dv UTXDB_LASTLOGIN
+or
+.Dv UTXDB_LOG .
+It will open a custom file with filename
+.Fa file
+instead of the system-default if
+.Fa file
+is not null.
+Care must be taken that when using a custom filename,
+.Fa type
+still has to match with the actual format, since each database may use
+its own file format.
+.Pp
+The
+.Fn pututxline
+function writes record
+.Fa utmpx
+to the system-default user accounting databases.
+The value of
+.Fa ut_type
+determines which databases are modified.
+.Pp
+Entries of type
+.Dv BOOT_TIME ,
+.Dv SHUTDOWN_TIME ,
+.Dv OLD_TIME
+and
+.Dv NEW_TIME
+will only be written to
+.Pa /var/log/utx.log .
+.Pp
+Entries of type
+.Dv USER_PROCESS
+will also be written to
+.Pa /var/run/utx.active .
+It will only be written to
+.Pa /var/log/utx.lastlogin
+if
+.Fa ut_tv
+for that user has a greater value than the existing entry or when no
+entry for the user has been found.
+.Pp
+Entries of type
+.Dv DEAD_PROCESS
+will only be written to
+.Pa /var/log/utx.log
+and
+.Pa /var/run/utx.active
+if a corresponding
+.Dv USER_PROCESS ,
+.Dv INIT_PROCESS
+or
+.Dv DEAD_PROCESS
+entry whose
+.Fa ut_id
+is equal has been found in the latter.
+.Pp
+In addition, entries of type
+.Dv BOOT_TIME
+and
+.Dv SHUTDOWN_TIME
+will cause all entries in
+.Pa /var/run/utx.active
+to be discarded.
+.Pp
+All entries whose type has not been previously mentioned, are discarded
+by this implementation of
+.Fn pututxline .
 .Sh RETURN VALUES
 .Sh SEE ALSO
 .Sh STANDARDS

From owner-svn-src-user@FreeBSD.ORG  Fri Jan  8 17:46:28 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 080761065676;
	Fri,  8 Jan 2010 17:46:28 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id EA24B8FC18;
	Fri,  8 Jan 2010 17:46:27 +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 o08HkRMr046065;
	Fri, 8 Jan 2010 17:46:27 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o08HkRAZ046062;
	Fri, 8 Jan 2010 17:46:27 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001081746.o08HkRAZ046062@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Fri, 8 Jan 2010 17:46:27 +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: r201809 - user/luigi/ipfw3-head/sys/netinet/ipfw
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: Fri, 08 Jan 2010 17:46:28 -0000

Author: luigi
Date: Fri Jan  8 17:46:27 2010
New Revision: 201809
URL: http://svn.freebsd.org/changeset/base/201809

Log:
  some more changes

Modified:
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c	Fri Jan  8 17:21:56 2010	(r201808)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c	Fri Jan  8 17:46:27 2010	(r201809)
@@ -105,7 +105,6 @@ static unsigned long	io_pkt_drop;
  * The heap is checked at every tick and all entities with expired events
  * are extracted.
  */
-static struct dn_heap *system_heap;
 
 /*
  * The key for the heap is used for two different values:
@@ -255,22 +254,19 @@ dn_tag_get(struct mbuf *m)
 }
 
 /*
- * It is called when we have some packet from delay line to send.
- * If there are leftover packets, this delay line is reinserted into extract
- * heap
- * XXX OK
+ * Fetch packets from the delay line which are due now. If there are
+ * leftover packets, reinsert the delay line in the heap.
  */
 static struct mbuf *
-transmit_event(struct delay_line *dline, dn_key l_curr_time)
+transmit_event(struct delay_line *dline, dn_key now)
 {
 	struct mbuf *m;
-	struct dn_pkt_tag *pkt;
-
 	struct mbuf *head = NULL, *tail = NULL;
-	/* XXX scheduler lock */
+
+	/* XXX we are under scheduler lock */
 	while ((m = dline->head) != NULL) {
 		pkt = dn_tag_get(m);
-		if (!DN_KEY_LEQ(pkt->output_time, l_curr_time))
+		if (!DN_KEY_LEQ(pkt->output_time, now))
 			break;
 		dline->head = m->m_nextpkt;
 		if (tail != NULL)
@@ -283,12 +279,11 @@ transmit_event(struct delay_line *dline,
 	if (tail != NULL)
 		tail->m_nextpkt = NULL;
 
-	/* If there are leftover packets, put into the heap for next event. */
 	if ((m = dline->head) != NULL) {
-		pkt = dn_tag_get(m);
-		//DN_HEAP_LOCK();
-		heap_insert(system_heap, pkt->output_time, dline);
-		//DN_HEAP_UNLOCK();
+		struct dn_pkt_tag *pkt = dn_tag_get(m);
+		DN_HEAP_LOCK();
+		heap_insert(&dn_cfg.system_heap, pkt->output_time, dline);
+		DN_HEAP_UNLOCK();
 	}
 	/* XXX scheduler unlock */
 	return head;
@@ -296,6 +291,7 @@ transmit_event(struct delay_line *dline,
 
 #define div64(a, b)	((int64_t)(a) / (int64_t)(b))
 
+#if 0
 /*
  * Compute how many ticks we have to wait before being able to send
  * a packet. This is computed as the "wire time" for the packet
@@ -314,23 +310,24 @@ set_ticks(struct mbuf *m, struct dn_flow
 		ret = 0;
 	return ret;
 }
+#endif
 
 /*
  * Convert the additional MAC overheads/delays into an equivalent
  * number of bits for the given data rate. The samples are in milliseconds
  * so we need to divide by 1000.
  */
-static dn_key
+static uint64_t
 compute_extra_bits(struct mbuf *pkt, struct new_pipe *p)
 {
 	int index;
-	dn_key extra_bits;
+	uint64_t extra_bits;
 	struct new_profile *pf = p->profile;
 
 	if (!pf || pf->samples_no == 0)
 		return 0;
 	index  = random() % pf->samples_no;
-	extra_bits = div64((dn_key)pf->samples[index] * p->bandwidth, 1000);
+	extra_bits = div64((uint64_t)pf->samples[index] * p->bandwidth, 1000);
 	if (index >= pf->loss_level) {
 		struct dn_pkt_tag *dt = dn_tag_get(pkt);
 		if (dt)
@@ -474,6 +471,9 @@ create_scheduler_instance(struct new_sch
 
 	if (si == NULL)
 		goto error;
+	si->dline = malloc(sizeof(*si->dline, M_DUMMYNET, M_NOWAIT | M_ZERO);
+	if (si->dline == NULL)
+		goto error;
 
 	set_oid(&si->oid, DN_SCH_I, 0, l);
 
@@ -505,37 +505,31 @@ find_scheduler(struct new_sch *sch_t, st
                 struct ipfw_flow_id *id)
 {
     struct new_sch_inst *prev, *s; /* returning scheduler instance */
-    struct ipfw_flow_id *id_t;
-    int i = 0;
-
-    id_t = malloc(sizeof(struct ipfw_flow_id), M_DUMMYNET, M_NOWAIT);
-    if (id_t == NULL) {
-        printf("dummynet: no memory for flowid\n");
-        return NULL;
-    }
-    /* XXX check return value */
-    *id_t = *id; /* The original id isn't modified */
-    do_mask(&sch_t->sched_mask, id_t);
+    int i;
+    struct ipfw_flow_id id_t;
+    
     if ( !(sch_t->flags & DN_SCH_HAVE_MASK) ) {
+	i = 0;
         s = sch_t->sch_i[0];
     } else {
-        /* first, do the masking, then hash */
-        i = do_hash(id_t);
+ 	id_t = *id;
+	do_mask(&sch_t->sched_mask, &id_t);
+        i = do_hash(&id_t);
         i = i % sch_t->sch_i_size;
         /* finally, scan the current hash bucket for a match */
-        searches++ ;
-        for (prev=NULL, s = sch_t->sch_i[i] ; s ; ) {
+        searches++; /* XXX stats */
+        for (prev=NULL, s=sch_t->sch_i[i] ; s ; prev=s, s=s->next) {
             search_steps++;
-            if (!mask_are_equals(id_t, &s->id))
+            if (!mask_are_equals(&id_t, &s->id))
                 break; /* found */
-            prev = s ;
-            s = s->next ;
         }
+#if 0 /* XXX we used to move to front, but what for ? */
         if (s && prev != NULL) { /* found and not in front */
             prev->next = s->next ;
             s->next = sch_t->sch_i[i] ;
             sch_t->sch_i[i] = s ;
         }
+#endif
     }
    
     if (s == NULL) { /* no match, need to allocate a new entry */
@@ -546,16 +540,17 @@ find_scheduler(struct new_sch *sch_t, st
         s->next = sch_t->sch_i[i];
         sch_t->sch_i[i] = s;
         sch_t->sch_i_elements++;
-        if (s != NULL) {
-            s->id = *id_t;
-            s->hash_slot = i;
-        }
+	s->hash_slot = i;
+        if (sch_t->flags & DN_SCH_HAVE_MASK)
+	    s->id = id_t;
     }
     return s;
 }
 
 /*
- * Send traffic from a scheduler instance.
+ * Send traffic from a scheduler instance due by 'now'
+ * XXX now we grab the lock at each insert, perhaps should
+ * batch entries to improve performance.
  */
 static struct mbuf *
 serve_sched(struct new_sch_inst *s, dn_key now)
@@ -563,52 +558,55 @@ serve_sched(struct new_sch_inst *s, dn_k
 	struct mbuf *head;
 	struct new_sch *sch_t = s->sched;
 	struct mbuf *tosend = NULL;
-	dn_key len_scaled;
 	struct new_pipe *pipe = sch_t->pipe;
 	int delay_line_idle = (s->dline->head == NULL);
-	int done;
+	int done, bw;
+
+	bw = pipe->bandwidth;
 	s->flags &= ~DN_SCH_ACTIVE;
 
-	if (pipe->bandwidth > 0)
-		s->numbytes += (now - s->sched_time) * pipe->bandwidth;
+	if (bw > 0)
+		s->numbytes += (now - s->sched_time) * bw;
 	else
 		s->numbytes = 0;
 	s->sched_time = now;
 	done = 0;
-	while (s->numbytes >= 0 && (tosend = sch_t->fp->dequeue(s + 1)) != NULL) {
+	while (s->numbytes >= 0 &&
+	    (tosend = sch_t->fp->dequeue(s + 1)) != NULL) {
+		uint64_t len_scaled;
 		done++;
-		len_scaled = pipe->bandwidth ? tosend->m_pkthdr.len * 8 * hz
+		len_scaled = bw ? tosend->m_pkthdr.len * 8 * hz
 			+ compute_extra_bits(tosend, pipe) * hz : 0;
 		s->numbytes -= len_scaled;
 		/* Move packet in the delay line */
 		move_pkt(tosend, pipe, s->dline);
 	}
-	if (done > 0 && s->numbytes < 0) {
-		/* credit has become negative, so reinsert the
-		* instance in the heap for when credit will be
-		* positive again. Also update the output time
-		* of the last packet, which is 'tosend'
-		*/
-		dn_key t = 0;
-		if (pipe->bandwidth > 0)
-			t = (pipe->bandwidth - 1 - s->numbytes) / pipe->bandwidth;
-		/* Delay the output time because under credit */
-		dn_tag_get(tosend)->output_time += t;
-
+	if (s->numbytes >= 0) {
+		/* Instance is idle, because it did not return
+		 * packets while credit was available.
+		 */
+		s->idle_time = curr_time;
+	} else {
+		/* Credit has become negative, so reinsert the
+		 * instance in the heap for when credit will be
+		 * positive again. Also update the output time
+		 * of the last packet, which is 'tosend'
+		 */
+		dn_key t;
+		KASSERT (bw > 0, "bw=0 and credit<0 ?");
+		t = (bw - 1 - s->numbytes) / bw;
+		/* Delay output time because under credit */
+		if (tosend)
+			dn_tag_get(tosend)->output_time += t;
 		s->sched->inst_counter++;
 		s->flags |= DN_SCH_ACTIVE;
 		DN_HEAP_LOCK();
-		heap_insert(system_heap, curr_time + t, s);
+		heap_insert(&dn_cfg.system_heap, curr_time + t, s);
 		DN_HEAP_UNLOCK();
-	} else {
-		/* scheduler instance should be idle, because it
-		 * did not return packets while credit was available.
-		 */
-		s->idle_time = curr_time;
 	}
 
 	head = (delay_line_idle && done) ?
-		transmit_event(s->dline, curr_time) : NULL;
+		transmit_event(s->dline, now) : NULL;
 	return head;
 }
 
@@ -620,124 +618,131 @@ serve_sched(struct new_sch_inst *s, dn_k
 void
 dummynet_task(void *context, int pending)
 {
-	struct new_sch_inst *s;
-	struct new_sch *sch_t;
-	struct mbuf *head = NULL;
-	struct timeval t;
+    struct new_sch *sch_t;
+    struct timeval t;
 
-	DUMMYNET_LOCK();
+    DUMMYNET_LOCK();
 
- 	/* Update number of lost(coalesced) ticks. */
- 	tick_lost += pending - 1;
+    /* Update number of lost(coalesced) ticks. */
+    tick_lost += pending - 1;
  
- 	getmicrouptime(&t);
- 	/* Last tick duration (usec). */
- 	tick_last = (t.tv_sec - dn_cfg.prev_t.tv_sec) * 1000000 +
- 	    (t.tv_usec - dn_cfg.prev_t.tv_usec);
- 	/* Last tick vs standard tick difference (usec). */
- 	tick_delta = (tick_last * hz - 1000000) / hz;
- 	/* Accumulated tick difference (usec). */
- 	tick_delta_sum += tick_delta;
+    getmicrouptime(&t);
+    /* Last tick duration (usec). */
+    tick_last = (t.tv_sec - dn_cfg.prev_t.tv_sec) * 1000000 +
+	(t.tv_usec - dn_cfg.prev_t.tv_usec);
+    /* Last tick vs standard tick difference (usec). */
+    tick_delta = (tick_last * hz - 1000000) / hz;
+    /* Accumulated tick difference (usec). */
+    tick_delta_sum += tick_delta;
  
- 	dn_cfg.prev_t = t;
+    dn_cfg.prev_t = t;
  
- 	/*
- 	 * Adjust curr_time if accumulated tick difference greater than
- 	 * 'standard' tick. Since curr_time should be monotonically increasing,
- 	 * we do positive adjustment as required and throttle curr_time in
- 	 * case of negative adjustment.
- 	 */
-  	curr_time++;
- 	if (tick_delta_sum - tick >= 0) {
- 		int diff = tick_delta_sum / tick;
+    /*
+     * Adjust curr_time if the accumulated tick difference is
+     * greater than the 'standard' tick. Since curr_time should
+     * be monotonically increasing, we do positive adjustments
+     * as required, and throttle curr_time in case of negative
+     * adjustment.
+     */
+    curr_time++;
+    if (tick_delta_sum - tick >= 0) {
+	int diff = tick_delta_sum / tick;
  
- 		curr_time += diff;
- 		tick_diff += diff;
- 		tick_delta_sum %= tick;
- 		tick_adjustment++;
- 	} else if (tick_delta_sum + tick <= 0) {
- 		curr_time--;
- 		tick_diff--;
- 		tick_delta_sum += tick;
- 		tick_adjustment++;
- 	}
-	DUMMYNET_UNLOCK();
-	for (;;) {
-	    struct dn_id *p;    /* generic parameter to handler */
-	    DN_HEAP_LOCK();
-	    if (system_heap->elements > 0 &&
-		DN_KEY_LEQ(HEAP_TOP(system_heap)->key, curr_time)) {
-		    p = HEAP_TOP(system_heap)->object;
-		    heap_extract(system_heap, NULL);
-	    } else {
-		p = NULL;
-	    }
-	    DN_HEAP_UNLOCK();
-	    if (p == NULL)
-		break;
+	curr_time += diff;
+	tick_diff += diff;
+	tick_delta_sum %= tick;
+	tick_adjustment++;
+    } else if (tick_delta_sum + tick <= 0) {
+	curr_time--;
+	tick_diff--;
+	tick_delta_sum += tick;
+	tick_adjustment++;
+    }
+    DUMMYNET_UNLOCK();
 
-	    if (p->type == DN_SCH_I) {
-		/*
-		 * Working with scheduler instances:
-		 * - Remove a scheduler instance from the heap and decrement
-		 *   the scheduler counter.
-		 * - If the scheduler is deleting and no other scheduler
-		 *   instances (of this scheduler) are into the heap,
-		 *   it's now possible to delete scheduler and call the
-		 *   function to do this;
-		 * - If the scheduer is deleting and this isn't the last
-		 *   instance in the heap, don't call the dequeue() function
-		 *   so the instance isn't inserted in the heap
-		 * - Else, call the dequeue() function.
-		 */
-		s = (struct new_sch_inst *)p;
-		sch_t = s->sched;
-		DN_S_LOCK(sch_t);
-
-		sch_t->inst_counter--;
-		if (sch_t->flags & DN_SCH_DELETE) {
-		    /* Wait for scheduler->busy == 0 */
-		    while(sch_t->busy) { /* XXX check */
-			DN_S_UNLOCK(sch_t);
-			DN_S_LOCK(sch_t);
-		    }
-		    /* Scheduler is deleting, don't dequeue packets from
-		     * this instance
-		     */
-		    if (sch_t->inst_counter == 0) {
-			/* No other scheduler instance in the heap.
-			 * We can safely delete scheduler
-			 */
-			really_deletescheduler(sch_t);
-			DN_S_UNLOCK(sch_t); /* XXX */
-		    }
-		} else {
-		    head = serve_sched(s, curr_time);
+/*
+ * XXX perhaps work in two passes ? First extract all
+ * eligible entries from the heap, then process them
+ * individually ?
+ */
+    for (;;) {
+	struct dn_id *p;    /* generic parameter to handler */
+	struct mbuf *head = NULL;
+
+	DN_HEAP_LOCK();
+	if (&dn_cfg.system_heap->elements > 0 &&
+		DN_KEY_LEQ(HEAP_TOP(&dn_cfg.system_heap)->key, curr_time)) {
+	    p = HEAP_TOP(&dn_cfg.system_heap)->object;
+	    heap_extract(&dn_cfg.system_heap, NULL);
+	} else {
+	    p = NULL;
+	}
+	DN_HEAP_UNLOCK();
+	if (p == NULL)
+	    break;
+
+	if (p->type == DN_SCH_I) {
+	    /*
+	     * Working with scheduler instances:
+	     * - decrement the scheduler counter.
+	     * - If the scheduler is deleting and no other
+	     *   instances (of this scheduler) are in the heap,
+	     *   we can now delete scheduler and call the
+	     *   function to do this. Otherwise,
+	     *   don't call the dequeue() function
+	     *   so the instance isn't inserted in the heap
+	     * - if the scheduler is not deleting, call the
+	     *   dequeue() function.
+	     */
+	    struct new_sch_inst *s = (struct new_sch_inst *)p;
+
+	    sch_t = s->sched;
+	    DN_S_LOCK(sch_t);
+	    sch_t->inst_counter--;
+	    if (sch_t->flags & DN_SCH_DELETE) {
+		/* Wait for scheduler->busy == 0 */
+		while (sch_t->busy) { /* XXX check */
 		    DN_S_UNLOCK(sch_t);
-		    if (head != NULL)
-			dummynet_send(head);
+		    DN_S_LOCK(sch_t);
 		}
-	    } else { /* extracted a delay line */
-		struct delay_line *dline = (struct delay_line *)p;
-		/*
-		 * Managing delay lines.
-		 * If the pointer to the scheduler instance is NULL, the delay
-		 * line should be deleted because pipe or scheduler was deleted,
-		 * else the transmit event is called to send out packets and
-		 * eventually reinsert the delay line into the heap.
+		/* Scheduler is deleting, do not dequeue
+		 * packets from this instance
 		 */
-		if (dline->si == NULL)
-		    delete_delay_line(dline);
-		else {
-		    DN_S_LOCK(dline->si->ptr_sched);
-		    head = transmit_event(dline, curr_time);
-		    DN_S_UNLOCK(dline->si->ptr_sched);
-		    if (head != NULL)
-			dummynet_send(head);
+		if (sch_t->inst_counter == 0) {
+		    /* No other instances in the heap.
+		     * We can safely delete the scheduler
+		     */
+		    really_deletescheduler(sch_t);
 		}
+	    } else {
+		head = serve_sched(s, curr_time);
 	    }
-        }
-	dn_reschedule();
+	    DN_S_UNLOCK(sch_t);
+	} else { /* extracted a delay line */
+	    /*
+	     * Managing delay lines.
+	     * If the pointer to the scheduler instance is NULL,
+	     * the delay line should be deleted because pipe or
+	     * scheduler was deleted.
+	     * Otherwise call transmit event to send out packets
+	     * due by now, and possibly reinsert the delay line
+	     * into the heap.
+	     */
+	    struct delay_line *dline = (struct delay_line *)p;
+	    if (dline->si == NULL)
+		delete_delay_line(dline);
+	    else {
+		DN_S_LOCK(dline->si->ptr_sched);
+		head = transmit_event(dline, curr_time);
+		DN_S_UNLOCK(dline->si->ptr_sched);
+		if (head != NULL)
+		    dummynet_send(head);
+	    }
+	}
+	if (head != NULL)
+	    dummynet_send(head);
+    }
+    dn_reschedule();
 }
 
 static void
@@ -1145,19 +1150,15 @@ dummynet_io(struct mbuf **m0, int dir, s
 	struct new_queue *q = NULL;
 	struct new_sch *sch;
 	struct new_sch_inst *sch_inst;
-	struct delay_line *dline;
 	int ret;
 	dn_key now; /* save a copy of curr_time */
-	int delay_line_idle;
 	int fs_id = (fwa->rule.info & IPFW_INFO_MASK) +
 		(fwa->rule.info & IPFW_IS_PIPE) ? DN_PIPEOFFSET : 0;
 
 	KASSERT(m->m_nextpkt == NULL,
 	    ("dummynet_io: mbuf queue passed to dummynet"));
 
-	/*
-	 * find flowset and schedset, protected by the UH lock
-	 */
+	/* find flowset and schedset, protected by the UH lock */
 	DUMMYNET_LOCK();
 	io_pkt++;
 	fs = ipdn_locate_flowset(fs_id);
@@ -1187,10 +1188,8 @@ dummynet_io(struct mbuf **m0, int dir, s
 	sch_inst = find_scheduler(sch, fs, &(fwa->f_id));
 	if (sch_inst == NULL)
 		goto dropit;
-	dline = sch_inst->dline;
-	delay_line_idle = (dline->head == NULL);
 
-	/* Now do the masking */
+	/* Apply the flow_mask */
 	do_mask(&fs->flow_mask, &(fwa->f_id));
 
 	/* tag the mbuf */
@@ -1229,15 +1228,12 @@ dummynet_io(struct mbuf **m0, int dir, s
 	}
 
 	/*
-	 * Now check if the dequeue should be called now.
-	 * If the instance is in the heap, the dequeue() will be called later,
-	 * and we are done.
+	 * If the instance is in the heap, dequeue() will be
+	 * called later, and we are done. Otherwise it is idle,
+	 * compute the initial allowance from io_fast and burst.
 	 */
 	if (sch_inst->flags & DN_SCH_ACTIVE)
 		goto done;
-	// XXX see if we can merge with dummynet task.
-        /* If the instance is not in the heap, credit must be >= 0 */
-
         sch_inst->numbytes = dn_cfg.io_fast ? pipe->bandwidth : 0;
         if (pipe->burst) {
 		uint64_t burst = (now - sch_inst->idle_time) *

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Fri Jan  8 17:21:56 2010	(r201808)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Fri Jan  8 17:46:27 2010	(r201809)
@@ -130,10 +130,7 @@ static __inline void dn_free_pkts(struct
 int
 delete_delay_line(struct delay_line *dline)
 {
-    struct mbuf *m;
-                     
-    m = dline->head;
-    dn_free_pkts(m);
+    dn_free_pkts(dline->head);
     free(dline, M_DUMMYNET);
     return 0;
 }
@@ -144,7 +141,7 @@ delete_scheduler_instance(struct new_sch
     struct new_sch *sch_t = si->sched;
  
     sch_t->fp->free_sched(si + 1);
-    /* XXX packet from delay line must be freed */
+    /* XXX packets in delay line must be freed */
     if (si->dline->head == NULL || sch_t->flags & DN_SCH_DELETE_DELAY_LINE) {
         /* Delay line empty, or forced delete, so delete delay line now */
         delete_delay_line(si->dline);
@@ -253,8 +250,7 @@ purge_pipe(struct new_pipe *pipe)
 }
 
 /*
- * Delete all pipes and heaps returning memory. Must also
- * remove references from all ipfw rules to all pipes.
+ * Deelete all objects.
  */
 static void
 dummynet_flush(void)
@@ -265,22 +261,50 @@ dummynet_flush(void)
 
 	DUMMYNET_LOCK();
 
-	/*
-	 * Now purge all queued pkts and delete all pipes.
-	 *
-	 * XXXGL: can we merge the for(;;) cycles into one or not?
-	 */
-	for (i = 0; i < DN_HASHSIZE; i++)
-		SLIST_FOREACH_SAFE(fs, &flowsethash[i], next, fs1) {
-			SLIST_REMOVE(&flowsethash[i], fs, new_fs, next);
-			purge_flow_set(fs, 1);
-		}
-	for (i = 0; i < DN_HASHSIZE; i++)
-		SLIST_FOREACH_SAFE(pipe, &pipehash[i], next, pipe1) {
-			SLIST_REMOVE(&pipehash[i], pipe, new_pipe, next);
-			purge_pipe(pipe);
-			free_pipe(pipe);
-		}
+    /* Clear heap so we don't have unwanted events. */
+    heap_free(&dn_cfg.system_heap);
+
+    /* Free all pipes */
+    for (i = 0; i < HASHSIZE; i++) {
+        SLIST_FOREACH_SAFE(pipe, &pipehash[i], next, pipe1) {
+            SLIST_REMOVE(&pipehash[i], pipe, new_pipe, next);
+            free_pipe(pipe);
+        }
+    }
+
+    /* Free flowsets in the flowset unlinked list*/
+    SLIST_FOREACH_SAFE(fs, &flowsetunlinked, next, fs1) {
+            SLIST_REMOVE(&flowsetunlinked, fs, new_fs, next);
+            free(fs, M_DUMMYNET);
+    }
+
+    /* Free all flowsets in the system */
+    for (i = 0; i < HASHSIZE; i++) {
+        SLIST_FOREACH_SAFE(fs, &flowsethash[i], next, fs1) {
+            SLIST_REMOVE(&flowsethash[i], fs, new_fs, next);
+            fs->fp->delete_alg_fs(fs->alg_fs);
+            fs->fp->ref_count--;
+            free(fs->alg_fs, M_DUMMYNET);
+            free(fs, M_DUMMYNET);
+        }
+    }
+
+    /* Free all schedulers */
+    for (i = 0; i < HASHSIZE; i++) {
+        SLIST_FOREACH_SAFE(sch_t, &schedulerhash[i], next, sch_t1) {
+            SLIST_REMOVE(&schedulerhash[i], sch_t, new_sch, next);
+            sch_t->flags |= DN_SCH_DELETE_DELAY_LINE;
+            really_deletescheduler(sch_t);
+        }
+    }
+
+    /* XXX flowset that are removed from list but not yet deleted?
+     *     delay line not linked with a schedler instance?
+     */
+
+    /* Reinitialize system heap... */
+    heap_init(&dn_cfg.system_heap, 16);
+
 	DUMMYNET_UNLOCK();
 }
 

From owner-svn-src-user@FreeBSD.ORG  Fri Jan  8 18:29:05 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 0EB871065670;
	Fri,  8 Jan 2010 18:29:05 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id F285E8FC13;
	Fri,  8 Jan 2010 18:29:04 +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 o08IT4GY055599;
	Fri, 8 Jan 2010 18:29:04 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o08IT4ZE055597;
	Fri, 8 Jan 2010 18:29:04 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001081829.o08IT4ZE055597@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Fri, 8 Jan 2010 18:29:04 +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: r201812 - user/ed/utmpx/lib/libc/gen
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: Fri, 08 Jan 2010 18:29:05 -0000

Author: ed
Date: Fri Jan  8 18:29:04 2010
New Revision: 201812
URL: http://svn.freebsd.org/changeset/base/201812

Log:
  Fix a small typo. Indentifies -> Identifies.
  
  Spotted by:	Alexander Schrijver <alexander schrijver gmail com>

Modified:
  user/ed/utmpx/lib/libc/gen/getutxent.3

Modified: user/ed/utmpx/lib/libc/gen/getutxent.3
==============================================================================
--- user/ed/utmpx/lib/libc/gen/getutxent.3	Fri Jan  8 17:49:24 2010	(r201811)
+++ user/ed/utmpx/lib/libc/gen/getutxent.3	Fri Jan  8 18:29:04 2010	(r201812)
@@ -113,7 +113,7 @@ No valid user accounting information.
 .It Dv BOOT_TIME
 Identifies time of system boot.
 .It Dv SHUTDOWN_TIME
-Indentifies time of system shutdown.
+Identifies time of system shutdown.
 .It Dv OLD_TIME
 Identifies time when system clock changed.
 .It Dv NEW_TIME

From owner-svn-src-user@FreeBSD.ORG  Fri Jan  8 19:10:40 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 37BB21065670;
	Fri,  8 Jan 2010 19:10:40 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 0E4CB8FC0C;
	Fri,  8 Jan 2010 19:10:40 +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 o08JAdxh064978;
	Fri, 8 Jan 2010 19:10:39 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o08JAd6Z064976;
	Fri, 8 Jan 2010 19:10:39 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001081910.o08JAd6Z064976@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Fri, 8 Jan 2010 19:10:39 +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: r201816 - user/ed/utmpx/lib/libc/gen
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: Fri, 08 Jan 2010 19:10:40 -0000

Author: ed
Date: Fri Jan  8 19:10:39 2010
New Revision: 201816
URL: http://svn.freebsd.org/changeset/base/201816

Log:
  Add the missing sections to the manpage.

Modified:
  user/ed/utmpx/lib/libc/gen/getutxent.3

Modified: user/ed/utmpx/lib/libc/gen/getutxent.3
==============================================================================
--- user/ed/utmpx/lib/libc/gen/getutxent.3	Fri Jan  8 19:01:50 2010	(r201815)
+++ user/ed/utmpx/lib/libc/gen/getutxent.3	Fri Jan  8 19:10:39 2010	(r201816)
@@ -344,8 +344,94 @@ All entries whose type has not been prev
 by this implementation of
 .Fn pututxline .
 .Sh RETURN VALUES
+The
+.Fn getutxent ,
+.Fn getutxid ,
+.Fn getutxline ,
+and
+.Fn getutxuser
+functions return a pointer to an
+.Vt utmpx
+structure that matches the mentioned constraints on success or
+.Dv NULL
+when reaching the end-of-file or when an error occurs.
+.Pp
+The
+.Fn pututxline
+function returns a pointer to an
+.Vt utmpx
+structure containing a copy of the structure written to disk upon
+success.
+It returns
+.Dv NULL
+when the provided
+.Vt utmpx
+is invalid.
+This may be because
+.Fa ut_type
+is invalid or
+.Fa ut_type
+has a value of
+.Dv DEAD_PROCESS
+and an entry with an identifier with a value equal to the field
+.Fa ut_id
+was not found.
+.Pp
+The
+.Fn setutxdb
+function returns 0 if the user accounting database was opened
+successfully.
+Otherwise, a -1 is returned and the global variable
+.Va errno
+is set to indicate the error.
+.Sh ERRORS
+In addition to the error conditions described in
+.Xr fopen 3 ,
+the
+.Fn setutxdb
+function can generate the following errors:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The
+.Fa type
+argument contains a value not supported by this implementation.
+.It Bq Er EFTYPE
+The file format is invalid.
+.El
 .Sh SEE ALSO
+.Xr ac 8 ,
+.Xr getpid 2 ,
+.Xr gettimeofday 2 ,
+.Xr last 1 ,
+.Xr newsyslog 8 ,
+.Xr tty 4 ,
+.Xr write 1
 .Sh STANDARDS
+The
+.Fn endutxent ,
+.Fn getutxent ,
+.Fn getutxid ,
+.Fn getutxline ,
+.Fn pututxline
+and
+.Fn setutxent
+functions are expected to conform to
+.St -p1003.1-2008 .
+.Pp
+The
+.Fn getutxuser
+and
+.Fn setutxdb
+functions and the
+.Fa ut_host
+field of the
+.Vt utmpx
+structure are extensions.
 .Sh HISTORY
 These functions appeared in
 .Fx 9.0 .
+They replaced the 
+.In utmp.h
+interface.
+.Sh AUTHORS
+.An Ed Schouten Aq ed@FreeBSD.org

From owner-svn-src-user@FreeBSD.ORG  Fri Jan  8 19:40:30 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 4ADC71065670;
	Fri,  8 Jan 2010 19:40:30 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 3AABA8FC0C;
	Fri,  8 Jan 2010 19:40:30 +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 o08JeUxg071635;
	Fri, 8 Jan 2010 19:40:30 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o08JeU33071632;
	Fri, 8 Jan 2010 19:40:30 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001081940.o08JeU33071632@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Fri, 8 Jan 2010 19:40:30 +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: r201817 - in user/ed/utmpx: . lib/libutil
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: Fri, 08 Jan 2010 19:40:30 -0000

Author: ed
Date: Fri Jan  8 19:40:29 2010
New Revision: 201817
URL: http://svn.freebsd.org/changeset/base/201817

Log:
  Bump the version of libutil, because we removed some functions there.
  
  Also update ObsoleteFiles to not remove our new manpages.

Modified:
  user/ed/utmpx/ObsoleteFiles.inc
  user/ed/utmpx/lib/libutil/Makefile

Modified: user/ed/utmpx/ObsoleteFiles.inc
==============================================================================
--- user/ed/utmpx/ObsoleteFiles.inc	Fri Jan  8 19:10:39 2010	(r201816)
+++ user/ed/utmpx/ObsoleteFiles.inc	Fri Jan  8 19:40:29 2010	(r201817)
@@ -15,14 +15,9 @@
 #
 
 # 20100104: utmp and utility functions replaced by utmpx
-OLD_FILES+=usr/share/man/man3/endutxent.3.gz
-OLD_FILES+=usr/share/man/man3/getutxent.3.gz
-OLD_FILES+=usr/share/man/man3/getutxline.3.gz
 OLD_FILES+=usr/share/man/man3/login.3.gz
 OLD_FILES+=usr/share/man/man3/logout.3.gz
 OLD_FILES+=usr/share/man/man3/logwtmp.3.gz
-OLD_FILES+=usr/share/man/man3/pututxline.3.gz
-OLD_FILES+=usr/share/man/man3/setutxent.3.gz
 OLD_FILES+=usr/share/man/man3/ulog_endutxent.3.gz
 OLD_FILES+=usr/share/man/man3/ulog_getutxent.3.gz
 OLD_FILES+=usr/share/man/man3/ulog_getutxline.3.gz
@@ -33,6 +28,7 @@ OLD_FILES+=usr/share/man/man3/ulog_setut
 OLD_FILES+=usr/share/man/man5/lastlog.5.gz
 OLD_FILES+=usr/share/man/man5/utmp.5.gz
 OLD_FILES+=usr/share/man/man5/wtmp.5.gz
+OLD_LIBS+=lib/libutil.so.8
 # 20100103: ntptrace(8) removed
 OLD_FILES+=usr/sbin/ntptrace
 OLD_FILES+=usr/share/man/man8/ntptrace.8.gz

Modified: user/ed/utmpx/lib/libutil/Makefile
==============================================================================
--- user/ed/utmpx/lib/libutil/Makefile	Fri Jan  8 19:10:39 2010	(r201816)
+++ user/ed/utmpx/lib/libutil/Makefile	Fri Jan  8 19:40:29 2010	(r201817)
@@ -6,7 +6,7 @@ SHLIBDIR?= /lib
 .include <bsd.own.mk>
 
 LIB=	util
-SHLIB_MAJOR= 8
+SHLIB_MAJOR= 9
 
 SRCS=	_secure_path.c auth.c expand_number.c flopen.c fparseln.c gr_util.c \
 	hexdump.c humanize_number.c kinfo_getfile.c kinfo_getvmmap.c kld.c \

From owner-svn-src-user@FreeBSD.ORG  Fri Jan  8 21:32:04 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 6F680106566B;
	Fri,  8 Jan 2010 21:32:04 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 605968FC14;
	Fri,  8 Jan 2010 21:32:04 +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 o08LW4gt097150;
	Fri, 8 Jan 2010 21:32:04 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o08LW4eN097148;
	Fri, 8 Jan 2010 21:32:04 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001082132.o08LW4eN097148@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Fri, 8 Jan 2010 21:32:04 +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: r201830 - user/ed/utmpx/lib/libc/gen
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: Fri, 08 Jan 2010 21:32:04 -0000

Author: ed
Date: Fri Jan  8 21:32:04 2010
New Revision: 201830
URL: http://svn.freebsd.org/changeset/base/201830

Log:
  Order SEE ALSO by category.
  
  Spotted by:	brueffer

Modified:
  user/ed/utmpx/lib/libc/gen/getutxent.3

Modified: user/ed/utmpx/lib/libc/gen/getutxent.3
==============================================================================
--- user/ed/utmpx/lib/libc/gen/getutxent.3	Fri Jan  8 21:28:20 2010	(r201829)
+++ user/ed/utmpx/lib/libc/gen/getutxent.3	Fri Jan  8 21:32:04 2010	(r201830)
@@ -399,13 +399,13 @@ argument contains a value not supported 
 The file format is invalid.
 .El
 .Sh SEE ALSO
-.Xr ac 8 ,
+.Xr last 1 ,
+.Xr write 1 ,
 .Xr getpid 2 ,
 .Xr gettimeofday 2 ,
-.Xr last 1 ,
-.Xr newsyslog 8 ,
 .Xr tty 4 ,
-.Xr write 1
+.Xr ac 8 ,
+.Xr newsyslog 8
 .Sh STANDARDS
 The
 .Fn endutxent ,

From owner-svn-src-user@FreeBSD.ORG  Fri Jan  8 21:35:03 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 664B9106568D;
	Fri,  8 Jan 2010 21:35:03 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 56F388FC08;
	Fri,  8 Jan 2010 21:35:03 +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 o08LZ331097875;
	Fri, 8 Jan 2010 21:35:03 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o08LZ3g1097873;
	Fri, 8 Jan 2010 21:35:03 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001082135.o08LZ3g1097873@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Fri, 8 Jan 2010 21:35:03 +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: r201831 - user/ed/utmpx/lib/libc/gen
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: Fri, 08 Jan 2010 21:35:03 -0000

Author: ed
Date: Fri Jan  8 21:35:03 2010
New Revision: 201831
URL: http://svn.freebsd.org/changeset/base/201831

Log:
  Make this sentence a bit easier to read.
  
  Spotted by:	Bram Geron <bgeron stack nl>

Modified:
  user/ed/utmpx/lib/libc/gen/getutxent.3

Modified: user/ed/utmpx/lib/libc/gen/getutxent.3
==============================================================================
--- user/ed/utmpx/lib/libc/gen/getutxent.3	Fri Jan  8 21:32:04 2010	(r201830)
+++ user/ed/utmpx/lib/libc/gen/getutxent.3	Fri Jan  8 21:35:03 2010	(r201831)
@@ -340,7 +340,7 @@ will cause all entries in
 .Pa /var/run/utx.active
 to be discarded.
 .Pp
-All entries whose type has not been previously mentioned, are discarded
+All entries whose type has not been mentioned previously, are discarded
 by this implementation of
 .Fn pututxline .
 .Sh RETURN VALUES

From owner-svn-src-user@FreeBSD.ORG  Fri Jan  8 21:42:00 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 AB91D106566B;
	Fri,  8 Jan 2010 21:42:00 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 9C4948FC13;
	Fri,  8 Jan 2010 21:42:00 +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 o08Lg0Tk099547;
	Fri, 8 Jan 2010 21:42:00 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o08Lg0GT099545;
	Fri, 8 Jan 2010 21:42:00 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001082142.o08Lg0GT099545@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Fri, 8 Jan 2010 21:42:00 +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: r201833 - user/ed/utmpx/lib/libc/gen
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: Fri, 08 Jan 2010 21:42:00 -0000

Author: ed
Date: Fri Jan  8 21:42:00 2010
New Revision: 201833
URL: http://svn.freebsd.org/changeset/base/201833

Log:
  Remove unneeded `a'.
  
  Spotted by:	brueffer

Modified:
  user/ed/utmpx/lib/libc/gen/getutxent.3

Modified: user/ed/utmpx/lib/libc/gen/getutxent.3
==============================================================================
--- user/ed/utmpx/lib/libc/gen/getutxent.3	Fri Jan  8 21:37:16 2010	(r201832)
+++ user/ed/utmpx/lib/libc/gen/getutxent.3	Fri Jan  8 21:42:00 2010	(r201833)
@@ -381,7 +381,7 @@ The
 .Fn setutxdb
 function returns 0 if the user accounting database was opened
 successfully.
-Otherwise, a -1 is returned and the global variable
+Otherwise, -1 is returned and the global variable
 .Va errno
 is set to indicate the error.
 .Sh ERRORS

From owner-svn-src-user@FreeBSD.ORG  Fri Jan  8 22:31:43 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 F2EC01065672;
	Fri,  8 Jan 2010 22:31:42 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id E271F8FC1B;
	Fri,  8 Jan 2010 22:31:42 +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 o08MVgVE011387;
	Fri, 8 Jan 2010 22:31:42 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o08MVgvg011385;
	Fri, 8 Jan 2010 22:31:42 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001082231.o08MVgvg011385@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Fri, 8 Jan 2010 22:31:42 +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: r201842 - user/luigi/ipfw3-head/sbin/ipfw
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: Fri, 08 Jan 2010 22:31:43 -0000

Author: luigi
Date: Fri Jan  8 22:31:42 2010
New Revision: 201842
URL: http://svn.freebsd.org/changeset/base/201842

Log:
  pass parameters for profile

Modified:
  user/luigi/ipfw3-head/sbin/ipfw/dummynet.c

Modified: user/luigi/ipfw3-head/sbin/ipfw/dummynet.c
==============================================================================
--- user/luigi/ipfw3-head/sbin/ipfw/dummynet.c	Fri Jan  8 22:28:54 2010	(r201841)
+++ user/luigi/ipfw3-head/sbin/ipfw/dummynet.c	Fri Jan  8 22:31:42 2010	(r201842)
@@ -570,10 +570,8 @@ compare_points(const void *vp1, const vo
 
 #define ED_EFMT(s) EX_DATAERR,"error in %s at line %d: "#s,filename,lineno
 
-void
-load_extra_delays(const char *filename, struct dn_pipe *p);
-void
-load_extra_delays(const char *filename, struct dn_pipe *p)
+static void
+load_extra_delays(const char *filename, struct new_profile *p)
 {
 	char    line[ED_MAX_LINE_LEN];
 	FILE    *f;
@@ -628,7 +626,8 @@ load_extra_delays(const char *filename, 
 				ED_MAX_SAMPLES_NO);
 		    do_points = 0;
 		} else if (!strcasecmp(name, ED_TOK_BW)) {
-		    read_bandwidth(arg, &p->bandwidth, p->if_name, sizeof(p->if_name));
+		    char buf[IFNAMSIZ];
+		    read_bandwidth(arg, &p->bandwidth, buf, sizeof(buf));
 		} else if (!strcasecmp(name, ED_TOK_LOSS)) {
 		    if (loss != -1.0)
 			errx(ED_EFMT("duplicated token: %s"), name);
@@ -734,13 +733,12 @@ ipfw_config_pipe(int ac, char **av)
 	struct new_pipe *p = NULL;
 	struct new_fs *fs = NULL;
 	struct new_profile *pf = NULL;
+	struct new_cmd *cmd = NULL;
 	struct ipfw_flow_id *mask = NULL;
-	int lmax = sizeof(*sch) + sizeof(*p) + sizeof(*fs) + sizeof(*pf);
+	int lmax = sizeof(*cmd);	/* always present */
 
-	base = buf = calloc(1, lmax);
-	if (buf == NULL) {
-		errx(1, "no memory for pipe buffer");
-	}
+	/* worst case: 2 schedulers, 1 profile, 1 pipe, 1 flowset */
+	lmax += 2*sizeof(*sch) + sizeof(*p) + sizeof(*fs) + sizeof(*pf);
 
 	av++; ac--;
 	/* Pipe number */
@@ -749,12 +747,19 @@ ipfw_config_pipe(int ac, char **av)
 	}
 	if (i <= 0)
 		errx(EX_USAGE, "need a pipe/flowset/sched number");
+	base = buf = calloc(1, lmax);
+	if (buf == NULL) {
+		errx(1, "no memory for pipe buffer");
+	}
+	cmd = o_next(&buf, sizeof(*cmd), DN_CMD_CONFIGURE);
+	cmd->entries = 0;	/* no explicit arguments */
+
 	switch (co.do_pipe) {
 	case 1:
 		sch = o_next(&buf, sizeof(*sch), DN_SCH);
 		p = o_next(&buf, sizeof(*p), DN_PIPE);
 		fs = o_next(&buf, sizeof(*fs), DN_FS);
-		mask = &sch->sched_mask; // XXX or both ?
+		mask = &sch->sched_mask;
 		sch->pipe_nr = p->pipe_nr = i;
 		fs->fs_nr = i + DN_PIPEOFFSET;
 		fs->sched_nr = sch->sched_nr = i + DN_PIPEOFFSET;
@@ -769,7 +774,7 @@ ipfw_config_pipe(int ac, char **av)
 	case 3: /* scheduler */
 		sch = o_next(&buf, sizeof(*sch), DN_SCH);
 		sch->sched_nr = i;
-		mask = &sch->sched_mask; // XXX or both ?
+		mask = &sch->sched_mask;
 		break;
 	}
 
@@ -1001,22 +1006,17 @@ end_mask:
 			ac--; av++;
 			break;
 
-#if 0
 		case TOK_PIPE_PROFILE:
 			NEED((!pf), "profile already set");
 			NEED(p, "profile");
 		    {
-			pf = o_next(&buf, sizeof(*pf));
-			int samples[ED_MAX_SAMPLES_NO];
-			if (co.do_pipe != 1)
-			    errx(EX_DATAERR, "extra delay only valid for pipes");
+			pf = o_next(&buf, sizeof(*pf), DN_PROFILE);
 			NEED1("extra delay needs the file name\n");
-			p.samples = &samples[0];
-			load_extra_delays(av[0], &p);
+			load_extra_delays(av[0], pf);
 			--ac; ++av;
 		    }
 			break;
-#endif
+
 		case TOK_BURST:
 			NEED(p, "burst");
 			NEED1("burst needs argument\n");

From owner-svn-src-user@FreeBSD.ORG  Fri Jan  8 22:37:53 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 3116D1065670;
	Fri,  8 Jan 2010 22:37:53 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 1F9718FC14;
	Fri,  8 Jan 2010 22:37:53 +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 o08MbrDQ012912;
	Fri, 8 Jan 2010 22:37:53 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o08MbrEY012907;
	Fri, 8 Jan 2010 22:37:53 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001082237.o08MbrEY012907@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Fri, 8 Jan 2010 22:37:53 +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: r201844 - in user/luigi/ipfw3-head/sys/netinet: . ipfw
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: Fri, 08 Jan 2010 22:37:53 -0000

Author: luigi
Date: Fri Jan  8 22:37:52 2010
New Revision: 201844
URL: http://svn.freebsd.org/changeset/base/201844

Log:
  partial processing of 'configure'

Modified:
  user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c

Modified: user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h	Fri Jan  8 22:34:17 2010	(r201843)
+++ user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h	Fri Jan  8 22:37:52 2010	(r201844)
@@ -66,13 +66,15 @@ enum {
 	DN_FS_EXT,
 	DN_QUEUE_EXT,
 	DN_UNKNOW,
-	DN_CMD_CONFIGURE,
-	DN_CMD_DELETE,
+	DN_CMD_CONFIGURE,	/* objects follow */
+	DN_CMD_DELETE,		/* subtype + list of entries */
+	DN_CMD_GET,		/* subtype + list of entries */
+	DN_CMD_FLUSH,
 	DN_LAST,
 };
  
 /* These values are in the subtype field of struct gen */
-enum dn_configure {
+enum {
 	DN_CONF_PIPE  = 1,
 	DN_CONF_QUEUE = 2,
 	DN_CONF_SCHED = 3,
@@ -93,13 +95,21 @@ enum sched_flag {
 
 typedef uint64_t dn_key;
 
+struct new_cmd {	/* header for all sockopt */
+	struct dn_id oid;
+	int entries;
+	uint32_t	data[0];	/* actually, entries elements */
+};
+
 #define	ED_MAX_SAMPLES_NO	1024
 struct new_profile {
 	struct dn_id oid;
 	/* fields to simulate a delay profile */
 #define ED_MAX_NAME_LEN         32
 	char name[ED_MAX_NAME_LEN];
+	int pipe_nr;
 	int loss_level;
+	int bandwidth;
 	int samples_no;
 	int samples[ED_MAX_SAMPLES_NO]; /* this has actually samples_no slots */
 };

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c	Fri Jan  8 22:34:17 2010	(r201843)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c	Fri Jan  8 22:37:52 2010	(r201844)
@@ -245,12 +245,12 @@ struct dn_pkt_tag {
 static struct dn_pkt_tag *
 dn_tag_get(struct mbuf *m)
 {
-    struct m_tag *mtag = m_tag_first(m);
-    KASSERT(mtag != NULL &&
+	struct m_tag *mtag = m_tag_first(m);
+	KASSERT(mtag != NULL &&
 	    mtag->m_tag_cookie == MTAG_ABI_COMPAT &&
 	    mtag->m_tag_id == PACKET_TAG_DUMMYNET,
 	    ("packet on dummynet queue w/o dummynet tag!"));
-    return (struct dn_pkt_tag *)(mtag+1);
+	return (struct dn_pkt_tag *)(mtag+1);
 }
 
 /*
@@ -262,6 +262,7 @@ transmit_event(struct delay_line *dline,
 {
 	struct mbuf *m;
 	struct mbuf *head = NULL, *tail = NULL;
+	struct dn_pkt_tag *pkt = NULL;
 
 	/* XXX we are under scheduler lock */
 	while ((m = dline->head) != NULL) {
@@ -280,7 +281,6 @@ transmit_event(struct delay_line *dline,
 		tail->m_nextpkt = NULL;
 
 	if ((m = dline->head) != NULL) {
-		struct dn_pkt_tag *pkt = dn_tag_get(m);
 		DN_HEAP_LOCK();
 		heap_insert(&dn_cfg.system_heap, pkt->output_time, dline);
 		DN_HEAP_UNLOCK();
@@ -471,7 +471,7 @@ create_scheduler_instance(struct new_sch
 
 	if (si == NULL)
 		goto error;
-	si->dline = malloc(sizeof(*si->dline, M_DUMMYNET, M_NOWAIT | M_ZERO);
+	si->dline = malloc(sizeof(*si->dline), M_DUMMYNET, M_NOWAIT | M_ZERO);
 	if (si->dline == NULL)
 		goto error;
 
@@ -670,7 +670,7 @@ dummynet_task(void *context, int pending
 	struct mbuf *head = NULL;
 
 	DN_HEAP_LOCK();
-	if (&dn_cfg.system_heap->elements > 0 &&
+	if (dn_cfg.system_heap.elements > 0 &&
 		DN_KEY_LEQ(HEAP_TOP(&dn_cfg.system_heap)->key, curr_time)) {
 	    p = HEAP_TOP(&dn_cfg.system_heap)->object;
 	    heap_extract(&dn_cfg.system_heap, NULL);
@@ -735,8 +735,6 @@ dummynet_task(void *context, int pending
 		DN_S_LOCK(dline->si->ptr_sched);
 		head = transmit_event(dline, curr_time);
 		DN_S_UNLOCK(dline->si->ptr_sched);
-		if (head != NULL)
-		    dummynet_send(head);
 	    }
 	}
 	if (head != NULL)
@@ -1256,11 +1254,10 @@ dummynet_io(struct mbuf **m0, int dir, s
 		*m0 = NULL;
 	}
 done:
-    DUMMYNET_UNLOCK();
-    if (head != NULL)
-        dummynet_send(head);
-
-    return 0;
+	DUMMYNET_UNLOCK();
+	if (head != NULL)
+		dummynet_send(head);
+	return 0;
 
 dropit:
 	io_pkt_drop++;

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h	Fri Jan  8 22:34:17 2010	(r201843)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h	Fri Jan  8 22:37:52 2010	(r201844)
@@ -78,6 +78,7 @@ struct dn_parms {
 
 	int	io_fast;
 	struct timeval prev_t;
+	struct dn_heap	system_heap;
 };
 
 static inline void

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Fri Jan  8 22:34:17 2010	(r201843)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Fri Jan  8 22:37:52 2010	(r201844)
@@ -76,6 +76,10 @@ static struct taskqueue	*dn_tq = NULL;
 
 static struct dn_sched_head    list_of_scheduler;
 
+static int config_pipe(struct new_pipe *p);
+static int config_profile(struct new_profile *p);
+static int config_fs(struct new_fs *p);
+static int config_sched(struct new_sch *p);
 /*
  * This is called one tick, after previous run. It is used to
  * schedule next run.
@@ -183,7 +187,7 @@ really_deletescheduler(struct new_sch *s
     return 0;
 }
 
-
+/* remove a pipe and attached objects */
 static void
 free_pipe(struct new_pipe *p)
 {
@@ -193,63 +197,6 @@ free_pipe(struct new_pipe *p)
 }
 
 /*
- * Dispose all packets and flow_queues on a flow_set.
- * If all=1, also remove red lookup table and other storage,
- * including the descriptor itself.
- * For the one in dn_pipe MUST also cleanup ready_heap...
- */
-static void
-purge_flow_set(struct new_fs *fs, int all)
-{
-#if 0
-	struct new_queue *q, *qn;
-	int i;
-
-	DUMMYNET_LOCK_ASSERT();
-
-	for (i = 0; i <= fs->rq_size; i++) {
-		for (q = fs->rq[i]; q != NULL; q = qn) {
-			dn_free_pkts(q->head);
-			qn = q->next;
-			free(q, M_DUMMYNET);
-		}
-		fs->rq[i] = NULL;
-	}
-
-	fs->rq_elements = 0;
-	if (all) {
-		/* RED - free lookup table. */
-		if (fs->w_q_lookup != NULL)
-			free(fs->w_q_lookup, M_DUMMYNET);
-		if (fs->rq != NULL)
-			free(fs->rq, M_DUMMYNET);
-		/* If this fs is not part of a pipe, free it. */
-		if (fs->pipe == NULL || fs != &(fs->pipe->fs))
-			free(fs, M_DUMMYNET);
-	}
-#endif
-}
-
-/*
- * Dispose all packets queued on a pipe (not a flow_set).
- * Also free all resources associated to a pipe, which is about
- * to be deleted.
- */
-static void
-purge_pipe(struct new_pipe *pipe)
-{
-#if 0
-    purge_flow_set( &(pipe->fs), 1 );
-
-    dn_free_pkts(pipe->head);
-
-    heap_free( pipe->scheduler_heap );
-    heap_free( pipe->not_eligible_heap );
-    heap_free( pipe->idle_heap );
-#endif
-}
-
-/*
  * Deelete all objects.
  */
 static void
@@ -257,6 +204,7 @@ dummynet_flush(void)
 {
 	struct new_pipe *pipe, *pipe1;
 	struct new_fs *fs, *fs1;
+	struct new_sch *sch_t, *sch_t1;
 	int i;
 
 	DUMMYNET_LOCK();
@@ -265,7 +213,7 @@ dummynet_flush(void)
     heap_free(&dn_cfg.system_heap);
 
     /* Free all pipes */
-    for (i = 0; i < HASHSIZE; i++) {
+    for (i = 0; i < DN_HASHSIZE; i++) {
         SLIST_FOREACH_SAFE(pipe, &pipehash[i], next, pipe1) {
             SLIST_REMOVE(&pipehash[i], pipe, new_pipe, next);
             free_pipe(pipe);
@@ -279,10 +227,10 @@ dummynet_flush(void)
     }
 
     /* Free all flowsets in the system */
-    for (i = 0; i < HASHSIZE; i++) {
+    for (i = 0; i < DN_HASHSIZE; i++) {
         SLIST_FOREACH_SAFE(fs, &flowsethash[i], next, fs1) {
             SLIST_REMOVE(&flowsethash[i], fs, new_fs, next);
-            fs->fp->delete_alg_fs(fs->alg_fs);
+            fs->fp->free_fs(fs->alg_fs);
             fs->fp->ref_count--;
             free(fs->alg_fs, M_DUMMYNET);
             free(fs, M_DUMMYNET);
@@ -290,7 +238,7 @@ dummynet_flush(void)
     }
 
     /* Free all schedulers */
-    for (i = 0; i < HASHSIZE; i++) {
+    for (i = 0; i < DN_HASHSIZE; i++) {
         SLIST_FOREACH_SAFE(sch_t, &schedulerhash[i], next, sch_t1) {
             SLIST_REMOVE(&schedulerhash[i], sch_t, new_sch, next);
             sch_t->flags |= DN_SCH_DELETE_DELAY_LINE;
@@ -418,13 +366,44 @@ set_fs_parms(struct dn_flow_set *x, stru
 static int
 do_config(void *p, int l)
 {
-	struct dn_id *o = p;
+	struct dn_id *next, *o;
+	int err = 0, cmd = 0;
 
-	while (l && o->len > 0) {
+	for (o = p; l >= sizeof(*o); o = next) {
+		err = EINVAL;
+		if (o->len < sizeof(*o) || l < o->len) {
+			printf("bad len o->len %d len %d\n", o->len, l);
+			break;
+		}
 		l -= o->len;
-		o = (struct dn_id *)((char *)o + l);
+		printf("%s cmd %d len %d left %d\n",
+			__FUNCTION__, o->type, o->len, l);
+		next = (struct dn_id *)((char *)o + o->len);
+		switch (o->type) {
+		case DN_CMD_CONFIGURE:
+		case DN_CMD_GET:
+		case DN_CMD_DELETE:
+		case DN_CMD_FLUSH:
+			cmd = o->type;
+			err = 0;
+			break;
+		case DN_PIPE:
+			err = config_pipe((struct new_pipe *)o);
+			break;
+		case DN_PROFILE:
+			err = config_profile((struct new_profile *)o);
+			break;
+		case DN_SCH:
+			err = config_sched((struct new_sch *)o);
+			break;
+		case DN_FS:
+			err = config_fs((struct new_fs *)o);
+			break;
+		}
+		if (err != 0)
+			break;
 	}
-	return 0;
+	return err;
 }
 
 static struct new_sch *
@@ -673,16 +652,17 @@ dn_fs_config(struct new_fs *fs)
  *	(re)configures the WFQ scheduler for the pipe.
  */
 static int
-config_pipe(struct dn_pipe *p)
+config_pipe(struct new_pipe *p)
 {
-#if 0
-	struct dn_flow_set *pfs = &(p->fs);
-	struct dn_flow_queue *q;
-	int i, error;
+	struct new_pipe *pipe;
 
+	if (p->oid.len < sizeof(*p)) {
+		printf("%s: short pipe\n", __FUNCTION__);
+		return EINVAL;
+	}
 	/* We need either a pipe number or a flow_set number. */
-	if (p->pipe_nr == 0 && pfs->fs_nr == 0)
-		return (EINVAL);
+	if (p->pipe_nr <= 0 || p->pipe_nr >= DN_PIPEOFFSET)
+		return EINVAL;
 	/*
 	 * The config program passes parameters as follows:
 	 * bw = bits/second (0 means no limits),
@@ -694,79 +674,103 @@ config_pipe(struct dn_pipe *p)
 	p->burst *= 8 * hz;
 
 	DUMMYNET_LOCK();
-	if (p->pipe_nr != 0) {			/* this is a pipe */
-		struct dn_pipe *pipe;
-
-		pipe = locate_pipe(p->pipe_nr);	/* locate pipe */
+	pipe = locate_pipe(p->pipe_nr);	/* locate pipe */
 
-		if (pipe == NULL) {		/* new pipe */
-			/* space for pipe + 3 heaps right after the pipe */
-			pipe = malloc(sizeof(struct dn_pipe) +
-				3 * sizeof(struct dn_heap), M_DUMMYNET,
-			    M_NOWAIT | M_ZERO);
-			if (pipe == NULL) {
-				DUMMYNET_UNLOCK();
-				printf("dummynet: no memory for new pipe\n");
-				return (ENOMEM);
-			}
+	if (pipe == NULL) { /* brand new pipe */
+		pipe = malloc(sizeof(*pipe), M_DUMMYNET, M_NOWAIT | M_ZERO);
+		if (pipe == NULL) {
+			DUMMYNET_UNLOCK();
+			printf("dummynet: no memory for new pipe\n");
+			return (ENOMEM);
+		}
+		bcopy(p, pipe, sizeof(*pipe));
+		/* XXX schedulers should attach to us... */
+	} else {
+	    /* pipe already exists, reconfigure it. */
+	    struct new_sch *sch;
+	    struct new_sch_inst *si;
+	    int i;
+
+	    sch = locate_scheduler(pipe->pipe_nr + DN_PIPEOFFSET);
+	    if (sch) {
+		/* Flush accumulated credit for all queues. */
+		for (i = 0; i < sch->sch_i_size; i++)
+		    for (si = sch->sch_i[i]; si; si = si->next)
+			si->numbytes = p->burst + dn_cfg.io_fast ?
+				    p->bandwidth : 0;
+	    }
+	    pipe->delay = p->delay;
+	    pipe->bandwidth = p->bandwidth;
+	    pipe->burst = p->burst;
+	    bcopy(p->if_name, pipe->if_name, sizeof(p->if_name));
+	    pipe->ifp = NULL;		/* reset interface ptr */
+	}
+	dn_cfg.id++;
+	DUMMYNET_UNLOCK();
+	return 0;
+}
 
-			pipe->scheduler_heap = (struct dn_heap *)(pipe + 1);
-			pipe->not_eligible_heap = pipe->scheduler_heap + 1;
-			pipe->idle_heap = pipe->scheduler_heap + 2;
+static int
+config_sched(struct new_sch *sch)
+{
+	return 0;
+}
 
-			pipe->pipe_nr = p->pipe_nr;
-			pipe->fs.pipe = pipe;
-			/*
-			 * idle_heap is the only one from which
-			 * we extract from the middle.
-			 */
-			pipe->idle_heap->ofs =
-			    offsetof(struct dn_flow_queue, heap_pos);
-		} else {
-			/* Flush accumulated credit for all queues. */
-			for (i = 0; i <= pipe->fs.rq_size; i++) {
-				for (q = pipe->fs.rq[i]; q; q = q->next) {
-					q->numbytes = p->burst +
-					    (dn_cfg.io_fast ? p->bandwidth : 0);
-				}
-			}
-		}
+static int
+config_fs(struct new_fs *fs)
+{
+	return 0;
+}
+/*
+ * attach a profile to a pipe
+ */
+static int
+config_profile(struct new_profile *pf)
+{
+	struct new_pipe *pipe;
 
-		pipe->bandwidth = p->bandwidth;
-		pipe->burst = p->burst;
-		pipe->numbytes = pipe->burst + (dn_cfg.io_fast ? pipe->bandwidth : 0);
-		bcopy(p->if_name, pipe->if_name, sizeof(p->if_name));
-		pipe->ifp = NULL;		/* reset interface ptr */
-		pipe->delay = p->delay;
-		set_fs_parms(&(pipe->fs), pfs);
+	if (pf->oid.len < sizeof(*pf)) {
+		printf("%s: short profile\n", __FUNCTION__);
+		return EINVAL;
+	}
+	/* We need a pipe number . */
+	if (pf->pipe_nr <= 0 || pf->pipe_nr >= DN_PIPEOFFSET)
+		return EINVAL;
+	/* XXX other sanity checks */
+	DUMMYNET_LOCK();
+	pipe = locate_pipe(pf->pipe_nr);	/* locate pipe */
 
-		/* Handle changes in the delay profile. */
-		if (p->samples_no > 0) {
-			if (pipe->samples_no != p->samples_no) {
-				if (pipe->samples != NULL)
-					free(pipe->samples, M_DUMMYNET);
-				pipe->samples =
-				    malloc(p->samples_no*sizeof(dn_key),
-					M_DUMMYNET, M_NOWAIT | M_ZERO);
-				if (pipe->samples == NULL) {
-					DUMMYNET_UNLOCK();
-					printf("dummynet: no memory "
-						"for new samples\n");
-					return (ENOMEM);
-				}
-				pipe->samples_no = p->samples_no;
-			}
+	if (pipe == NULL) { /* brand new pipe */
+		DUMMYNET_UNLOCK();
+		printf("%s: no pipe %d\n", __FUNCTION__, pf->pipe_nr);
+		return EINVAL;
+	}
 
-			strncpy(pipe->name,p->name,sizeof(pipe->name));
-			pipe->loss_level = p->loss_level;
-			for (i = 0; i<pipe->samples_no; ++i)
-				pipe->samples[i] = p->samples[i];
-		} else if (pipe->samples != NULL) {
-			free(pipe->samples, M_DUMMYNET);
-			pipe->samples = NULL;
-			pipe->samples_no = 0;
+	dn_cfg.id++;
+	/* see if we need to allocate memory */
+	if (pipe->profile && (pf->samples_no == 0 ||
+			pipe->profile->oid.len < pf->oid.len)) {
+		free(pipe->profile, M_DUMMYNET);
+		pipe->profile = NULL;
+	}
+	if (pf->samples_no > 0) {
+		if (pipe->profile == NULL)
+			pipe->profile = malloc(pf->oid.len,
+			    M_DUMMYNET, M_NOWAIT | M_ZERO);
+		if (pipe->profile == NULL) {
+			DUMMYNET_UNLOCK();
+			printf("%s: no memory\n", __FUNCTION__);
+			return ENOMEM;
 		}
-
+		bcopy(pf, pipe->profile, pf->oid.len);
+	}
+	DUMMYNET_UNLOCK();
+	return 0;
+}
+	
+#if 0
+	/* We need either a pipe number or a flow_set number. */
+		set_fs_parms(&(pipe->fs), pfs);
 		if (pipe->fs.rq == NULL) {	/* a new pipe */
 			error = alloc_hash(&(pipe->fs), pfs);
 			if (error) {
@@ -828,11 +832,9 @@ config_pipe(struct dn_pipe *p)
 		}
 	}
 	DUMMYNET_UNLOCK();
-#endif
 	return (0);
 }
 
-#if 0
 /*
  * Helper function to remove from a heap queues which are linked to
  * a flow_set about to be deleted.
@@ -860,16 +862,14 @@ scan_remove_pipe(void *_o, uintptr_t p)
 {
 	return (0 == (void *)p) ? HEAP_SCAN_DEL | HEAP_SCAN_END : 0;
 }
-#endif
 
 /*
  * Fully delete a pipe or a queue, cleaning up associated info.
  */
 static int
-delete_pipe(struct dn_pipe *p)
+delete_pipe(struct dn_id *p, int l)
 {
     int err = 0;
-#if 0
     struct dn_pipe *pipe;
     struct new_fs *fs;
     
@@ -931,11 +931,9 @@ done:
     DUMMYNET_UNLOCK();
     if (pipe)
 	free_pipe(pipe);
-#endif
     return err;
 }
 
-#if 0
 /*
  * helper function used to copy data from kernel in DUMMYNET_GET
  */
@@ -1088,65 +1086,54 @@ dummynet_get(struct sockopt *sopt)
 static int
 ip_dn_ctl(struct sockopt *sopt)
 {
-    int error;
-    struct dn_pipe *p = NULL;
-    int l;
-
-    error = priv_check(sopt->sopt_td, PRIV_NETINET_DUMMYNET);
-    if (error)
-	return (error);
-
-    /* Disallow sets in really-really secure mode. */
-    if (sopt->sopt_dir == SOPT_SET) {
-	error =  securelevel_ge(sopt->sopt_td->td_ucred, 3);
+	void *p = NULL;
+	int error, l;
+
+	error = priv_check(sopt->sopt_td, PRIV_NETINET_DUMMYNET);
 	if (error)
-	    return (error);
-    }
+		return (error);
 
-    switch (sopt->sopt_name) {
-    default :
-	printf("dummynet: -- unknown option %d", sopt->sopt_name);
-	error = EINVAL ;
-	break;
-
-    case IP_DUMMYNET_GET :
-	error = dummynet_get(sopt);
-	break ;
-
-    case IP_DUMMYNET_FLUSH :
-	dummynet_flush() ;
-	break ;
-
-    case IP_DUMMYNET_CONFIGURE :
-	l = (sopt->sopt_dir == SOPT_SET) ? sopt->sopt_valsize :
-		*(int *)(sopt->sopt_valsize);
-	if (l < 0 || l > 12000) {
-		printf("argument too large, %d\n", l);
-		break;
+	/* Disallow sets in really-really secure mode. */
+	if (sopt->sopt_dir == SOPT_SET) {
+		error =  securelevel_ge(sopt->sopt_td->td_ucred, 3);
+			if (error)
+		return (error);
 	}
-	printf("%s size %d\n", __FUNCTION__, l);
-	p = malloc(l, M_TEMP, M_WAITOK);
-	error = sooptcopyin(sopt, p, l, l);
-	if (error)
-	    break ;
 
-	error = do_config(p, l);
-	break;
-	error = config_pipe(p);
-	break ;
-
-    case IP_DUMMYNET_DEL :	/* remove a pipe or queue */
-	p = malloc(sizeof(struct dn_pipe), M_TEMP, M_WAITOK);
-	error = sooptcopyin(sopt, p, sizeof(struct dn_pipe), sizeof *p);
-	if (error)
-	    break ;
+	switch (sopt->sopt_name) {
+	default :
+		printf("dummynet: -- unknown option %d", sopt->sopt_name);
+		error = EINVAL;
+		break;
 
-	error = delete_pipe(p);
-	break ;
-    }
+	case IP_DUMMYNET_GET :
+		error = dummynet_get(sopt);
+		break;
+
+	case IP_DUMMYNET_FLUSH :
+		dummynet_flush();
+		break;
+
+	case IP_DUMMYNET_CONFIGURE :
+	case IP_DUMMYNET_DEL :	/* remove a pipe or queue */
+		l = (sopt->sopt_dir == SOPT_SET) ? sopt->sopt_valsize :
+			*(int *)(sopt->sopt_valsize);
+		if (l < 0 || l > 12000) {
+			printf("argument too large, %d\n", l);
+			break;
+		}
+		printf("%s size %d\n", __FUNCTION__, l);
+		p = malloc(l, M_TEMP, M_WAITOK);
+		error = sooptcopyin(sopt, p, l, l);
+		if (error)
+			break ;
+
+		error = do_config(p, l);
+		break;
+	}
 
-    if (p != NULL)
-	free(p, M_TEMP);
+	if (p != NULL)
+		free(p, M_TEMP);
 
     return error ;
 }

From owner-svn-src-user@FreeBSD.ORG  Fri Jan  8 22:56:47 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 526D7106566B;
	Fri,  8 Jan 2010 22:56:47 +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 41A798FC17;
	Fri,  8 Jan 2010 22:56:47 +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 o08MulDA017214;
	Fri, 8 Jan 2010 22:56:47 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o08MulNI017200;
	Fri, 8 Jan 2010 22:56:47 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001082256.o08MulNI017200@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Fri, 8 Jan 2010 22:56:47 +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: r201847 -
	user/kmacy/releng_8_rump/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
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: Fri, 08 Jan 2010 22:56:47 -0000

Author: kmacy
Date: Fri Jan  8 22:56:46 2010
New Revision: 201847
URL: http://svn.freebsd.org/changeset/base/201847

Log:
  fix ZFS build with ZIO_USE_UMA

Modified:
  user/kmacy/releng_8_rump/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c

Modified: user/kmacy/releng_8_rump/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
==============================================================================
--- user/kmacy/releng_8_rump/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c	Fri Jan  8 22:52:02 2010	(r201846)
+++ user/kmacy/releng_8_rump/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c	Fri Jan  8 22:56:46 2010	(r201847)
@@ -1886,6 +1886,11 @@ arc_reclaim_needed(void)
 	return (0);
 }
 
+#ifdef ZIO_USE_UMA
+	extern kmem_cache_t	*zio_buf_cache[];
+	extern kmem_cache_t	*zio_data_buf_cache[];
+#endif
+
 static void
 arc_kmem_reap_now(arc_reclaim_strategy_t strat)
 {
@@ -1893,8 +1898,6 @@ arc_kmem_reap_now(arc_reclaim_strategy_t
 	size_t			i;
 	kmem_cache_t		*prev_cache = NULL;
 	kmem_cache_t		*prev_data_cache = NULL;
-	extern kmem_cache_t	*zio_buf_cache[];
-	extern kmem_cache_t	*zio_data_buf_cache[];
 #endif
 
 #ifdef _KERNEL

From owner-svn-src-user@FreeBSD.ORG  Fri Jan  8 23:57:31 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 00FEB106566C;
	Fri,  8 Jan 2010 23:57:31 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id E435A8FC0A;
	Fri,  8 Jan 2010 23:57:30 +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 o08NvUPl030998;
	Fri, 8 Jan 2010 23:57:30 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o08NvUoA030995;
	Fri, 8 Jan 2010 23:57:30 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001082357.o08NvUoA030995@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Fri, 8 Jan 2010 23:57:30 +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: r201857 - in user/ed/utmpx: include lib/libc/gen
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: Fri, 08 Jan 2010 23:57:31 -0000

Author: ed
Date: Fri Jan  8 23:57:30 2010
New Revision: 201857
URL: http://svn.freebsd.org/changeset/base/201857

Log:
  Last-minute ABI change.
  
  I was thinking: if we use the same layout for struct utmpx as we do for
  the futx, it is a lot easier to retain ABI compatibility. ut_type is
  just stored at the beginning of the structure, which means we can always
  first read the value of ut_type and cast it to an entirely different
  structure.

Modified:
  user/ed/utmpx/include/utmpx.h
  user/ed/utmpx/lib/libc/gen/getutxent.3

Modified: user/ed/utmpx/include/utmpx.h
==============================================================================
--- user/ed/utmpx/include/utmpx.h	Fri Jan  8 23:50:39 2010	(r201856)
+++ user/ed/utmpx/include/utmpx.h	Fri Jan  8 23:57:30 2010	(r201857)
@@ -39,17 +39,17 @@ typedef	__pid_t		pid_t;
 #endif
 
 struct utmpx {
+	short		ut_type;	/* Type of entry. */
+	struct timeval	ut_tv;		/* Time entry was made. */
+	char		ut_id[8];	/* Record identifier. */
+	pid_t		ut_pid;		/* Process ID. */
 	char		ut_user[32];	/* User login name. */
-	char		ut_id[8];	/* Process identifier. */
 	char		ut_line[32];	/* Device name. */
 #if __BSD_VISIBLE
 	char		ut_host[128];	/* Remote hostname. */
 #else
 	char		__ut_host[128];
 #endif
-	pid_t		ut_pid;		/* Process ID. */
-	short		ut_type;	/* Type of entry. */
-	struct timeval	ut_tv;		/* Time entry was made. */
 };
 
 #define	EMPTY		0	/* No valid user accounting information. */

Modified: user/ed/utmpx/lib/libc/gen/getutxent.3
==============================================================================
--- user/ed/utmpx/lib/libc/gen/getutxent.3	Fri Jan  8 23:50:39 2010	(r201856)
+++ user/ed/utmpx/lib/libc/gen/getutxent.3	Fri Jan  8 23:57:30 2010	(r201857)
@@ -93,13 +93,13 @@ found in the include file
 .In utmpx.h :
 .Bd -literal -offset indent
 struct utmpx {
+	short	ut_type;	/* Type of entry. */
+	struct timeval ut_tv;	/* Time entry was made. */
+	char	ut_id[];	/* Record identifier. */
+	pid_t	ut_pid;		/* Process ID. */
 	char	ut_user[];	/* User login name. */
-	char	ut_id[];	/* Process identifier. */
 	char	ut_line[];	/* Device name. */
 	char	ut_host[];	/* Remote hostname. */
-	pid_t	ut_pid;		/* Process ID. */
-	short	ut_type;	/* Type of entry. */
-	struct timeval ut_tv;	/* Time entry was made. */
 };
 .Ed
 .Pp
@@ -136,15 +136,9 @@ are not processed by this implementation
 .Pp
 Other fields inside the structure are:
 .Bl -tag -width ut_user
-.It Fa ut_user
-The user login name corresponding with the login session.
-This field is only applicable to entries of type
-.Dv USER_PROCESS
-and
-.Dv INIT_PROCESS .
-For
-.Dv INIT_PROCESS
-entries this entry typically contains the name of the login process.
+.It Fa ut_tv
+The time the event occured.
+This field is used for all types of entries.
 .It Fa ut_id
 An identifier that is used to refer to the entry.
 This identifier can be used to remove or replace a login entry by
@@ -156,6 +150,23 @@ This field is only applicable to entries
 .Dv LOGIN_PROCESS
 and
 .Dv DEAD_PROCESS .
+.It Fa ut_pid
+The process identifier of the session leader of the login session.
+This field is only applicable to entries of type
+.Dv USER_PROCESS ,
+.Dv INIT_PROCESS ,
+.Dv LOGIN_PROCESS
+and
+.Dv DEAD_PROCESS .
+.It Fa ut_user
+The user login name corresponding with the login session.
+This field is only applicable to entries of type
+.Dv USER_PROCESS
+and
+.Dv INIT_PROCESS .
+For
+.Dv INIT_PROCESS
+entries this entry typically contains the name of the login process.
 .It Fa ut_line
 The name of the TTY character device, without the leading
 .Pa /dev/
@@ -171,17 +182,6 @@ If the user login session is not perform
 is left blank.
 This field is only applicable to entries of type
 .Dv USER_PROCESS .
-.It Fa ut_pid
-The process identifier of the session leader of the login session.
-This field is only applicable to entries of type
-.Dv USER_PROCESS ,
-.Dv INIT_PROCESS ,
-.Dv LOGIN_PROCESS
-and
-.Dv DEAD_PROCESS .
-.It Fa ut_tv
-The time the event occured.
-This field is used for all types of entries.
 .El
 .Pp
 This implementation guarantees all inapplicable fields to be discarded.

From owner-svn-src-user@FreeBSD.ORG  Sat Jan  9 00:07: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 829871065695;
	Sat,  9 Jan 2010 00:07:46 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 723C58FC1D;
	Sat,  9 Jan 2010 00:07: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 o0907k42033603;
	Sat, 9 Jan 2010 00:07:46 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o0907k8m033601;
	Sat, 9 Jan 2010 00:07:46 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001090007.o0907k8m033601@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Sat, 9 Jan 2010 00:07: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: r201863 - user/ed/utmpx/lib/libc/gen
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: Sat, 09 Jan 2010 00:07:46 -0000

Author: ed
Date: Sat Jan  9 00:07:46 2010
New Revision: 201863
URL: http://svn.freebsd.org/changeset/base/201863

Log:
  Make it a little easier to read the struct.

Modified:
  user/ed/utmpx/lib/libc/gen/getutxent.3

Modified: user/ed/utmpx/lib/libc/gen/getutxent.3
==============================================================================
--- user/ed/utmpx/lib/libc/gen/getutxent.3	Sat Jan  9 00:07:03 2010	(r201862)
+++ user/ed/utmpx/lib/libc/gen/getutxent.3	Sat Jan  9 00:07:46 2010	(r201863)
@@ -93,13 +93,13 @@ found in the include file
 .In utmpx.h :
 .Bd -literal -offset indent
 struct utmpx {
-	short	ut_type;	/* Type of entry. */
-	struct timeval ut_tv;	/* Time entry was made. */
-	char	ut_id[];	/* Record identifier. */
-	pid_t	ut_pid;		/* Process ID. */
-	char	ut_user[];	/* User login name. */
-	char	ut_line[];	/* Device name. */
-	char	ut_host[];	/* Remote hostname. */
+	short           ut_type;    /* Type of entry. */
+	struct timeval  ut_tv;      /* Time entry was made. */
+	char            ut_id[];    /* Record identifier. */
+	pid_t           ut_pid;     /* Process ID. */
+	char            ut_user[];  /* User login name. */
+	char            ut_line[];  /* Device name. */
+	char            ut_host[];  /* Remote hostname. */
 };
 .Ed
 .Pp

From owner-svn-src-user@FreeBSD.ORG  Sat Jan  9 12:28:42 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 D21011065692;
	Sat,  9 Jan 2010 12:28:42 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id C1E388FC0C;
	Sat,  9 Jan 2010 12:28:42 +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 o09CSgRn000207;
	Sat, 9 Jan 2010 12:28:42 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o09CSgFX000205;
	Sat, 9 Jan 2010 12:28:42 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001091228.o09CSgFX000205@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Sat, 9 Jan 2010 12:28:42 +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: r201891 - user/ed/utmpx/lib/libc/gen
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: Sat, 09 Jan 2010 12:28:42 -0000

Author: ed
Date: Sat Jan  9 12:28:42 2010
New Revision: 201891
URL: http://svn.freebsd.org/changeset/base/201891

Log:
  This should read LOGIN_PROCESS. Not DEAD_PROCESS.

Modified:
  user/ed/utmpx/lib/libc/gen/getutxent.3

Modified: user/ed/utmpx/lib/libc/gen/getutxent.3
==============================================================================
--- user/ed/utmpx/lib/libc/gen/getutxent.3	Sat Jan  9 11:28:01 2010	(r201890)
+++ user/ed/utmpx/lib/libc/gen/getutxent.3	Sat Jan  9 12:28:42 2010	(r201891)
@@ -327,7 +327,7 @@ if a corresponding
 .Dv USER_PROCESS ,
 .Dv INIT_PROCESS
 or
-.Dv DEAD_PROCESS
+.Dv LOGIN_PROCESS
 entry whose
 .Fa ut_id
 is equal has been found in the latter.

From owner-svn-src-user@FreeBSD.ORG  Sat Jan  9 12:32:07 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 94720106568D;
	Sat,  9 Jan 2010 12:32:07 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 842968FC14;
	Sat,  9 Jan 2010 12:32:07 +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 o09CW7Ua001066;
	Sat, 9 Jan 2010 12:32:07 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o09CW7qB001064;
	Sat, 9 Jan 2010 12:32:07 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001091232.o09CW7qB001064@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Sat, 9 Jan 2010 12:32:07 +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: r201893 - user/ed/utmpx/lib/libc/gen
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: Sat, 09 Jan 2010 12:32:07 -0000

Author: ed
Date: Sat Jan  9 12:32:07 2010
New Revision: 201893
URL: http://svn.freebsd.org/changeset/base/201893

Log:
  Use consistent ordering of _PROCESS types.

Modified:
  user/ed/utmpx/lib/libc/gen/getutxent.3

Modified: user/ed/utmpx/lib/libc/gen/getutxent.3
==============================================================================
--- user/ed/utmpx/lib/libc/gen/getutxent.3	Sat Jan  9 12:31:11 2010	(r201892)
+++ user/ed/utmpx/lib/libc/gen/getutxent.3	Sat Jan  9 12:32:07 2010	(r201893)
@@ -219,9 +219,9 @@ has an equal value.
 If
 .Fa ut_type
 has a value of
+.Dv USER_PROCESS ,
 .Dv INIT_PROCESS ,
-.Dv LOGIN_PROCESS ,
-.Dv USER_PROCESS
+.Dv LOGIN_PROCESS
 or
 .Dv DEAD_PROCESS ,
 it will return the next entry whose
@@ -235,9 +235,9 @@ The
 function searches for the next entry in the database whose
 .Fa ut_type
 has a value of
-.Dv LOGIN_PROCESS
-or
 .Dv USER_PROCESS
+or
+.Dv LOGIN_PROCESS
 and whose
 .Fa ut_line
 is equal to the the same field in

From owner-svn-src-user@FreeBSD.ORG  Sat Jan  9 16:15:11 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 3E992106566B;
	Sat,  9 Jan 2010 16:15:11 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 2E2A38FC1C;
	Sat,  9 Jan 2010 16:15:11 +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 o09GFBIN050253;
	Sat, 9 Jan 2010 16:15:11 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o09GFBBk050251;
	Sat, 9 Jan 2010 16:15:11 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001091615.o09GFBBk050251@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Sat, 9 Jan 2010 16:15:11 +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: r201900 - user/ed/utmpx/lib/libc/gen
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: Sat, 09 Jan 2010 16:15:11 -0000

Author: ed
Date: Sat Jan  9 16:15:10 2010
New Revision: 201900
URL: http://svn.freebsd.org/changeset/base/201900

Log:
  Use "are" instead of "to be" here.
  
  Spotted by:	gavin

Modified:
  user/ed/utmpx/lib/libc/gen/getutxent.3

Modified: user/ed/utmpx/lib/libc/gen/getutxent.3
==============================================================================
--- user/ed/utmpx/lib/libc/gen/getutxent.3	Sat Jan  9 15:59:15 2010	(r201899)
+++ user/ed/utmpx/lib/libc/gen/getutxent.3	Sat Jan  9 16:15:10 2010	(r201900)
@@ -184,7 +184,7 @@ This field is only applicable to entries
 .Dv USER_PROCESS .
 .El
 .Pp
-This implementation guarantees all inapplicable fields to be discarded.
+This implementation guarantees all inapplicable fields are discarded.
 The
 .Fa ut_user ,
 .Fa ut_line

From owner-svn-src-user@FreeBSD.ORG  Sat Jan  9 21:57:41 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 A1F42106566B;
	Sat,  9 Jan 2010 21:57:41 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 86AEE8FC19;
	Sat,  9 Jan 2010 21:57:41 +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 o09LvfAs027023;
	Sat, 9 Jan 2010 21:57:41 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o09LvfbH027018;
	Sat, 9 Jan 2010 21:57:41 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001092157.o09LvfbH027018@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Sat, 9 Jan 2010 21:57:41 +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: r201933 - in user/ed/utmpx/usr.sbin: . ppp
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: Sat, 09 Jan 2010 21:57:41 -0000

Author: ed
Date: Sat Jan  9 21:57:41 2010
New Revision: 201933
URL: http://svn.freebsd.org/changeset/base/201933

Log:
  Let ppp(8) use utmpx.
  
  This is a great example of what's so nice about utmpx. Because we use
  separate cookies to identify the entry instead of the TTY name, we don't
  need ugly hacks to perform any logging. We can just create entries
  without a TTY.

Modified:
  user/ed/utmpx/usr.sbin/Makefile
  user/ed/utmpx/usr.sbin/ppp/id.c
  user/ed/utmpx/usr.sbin/ppp/id.h
  user/ed/utmpx/usr.sbin/ppp/physical.c

Modified: user/ed/utmpx/usr.sbin/Makefile
==============================================================================
--- user/ed/utmpx/usr.sbin/Makefile	Sat Jan  9 21:23:39 2010	(r201932)
+++ user/ed/utmpx/usr.sbin/Makefile	Sat Jan  9 21:57:41 2010	(r201933)
@@ -135,6 +135,7 @@ SUBDIR=	${_ac} \
 	${_pnpinfo} \
 	${_portsnap} \
 	powerd \
+	${_ppp} \
 	${_pppctl} \
 	${_praliases} \
 	${_praudit} \

Modified: user/ed/utmpx/usr.sbin/ppp/id.c
==============================================================================
--- user/ed/utmpx/usr.sbin/ppp/id.c	Sat Jan  9 21:23:39 2010	(r201932)
+++ user/ed/utmpx/usr.sbin/ppp/id.c	Sat Jan  9 21:57:41 2010	(r201933)
@@ -49,7 +49,7 @@
 #else
 #include <libutil.h>
 #endif
-#include <utmp.h>
+#include <utmpx.h>
 
 #include "log.h"
 #include "main.h"
@@ -202,36 +202,25 @@ ID0uu_unlock(const char *basettyname)
 }
 
 void
-ID0login(struct utmp *ut)
+ID0login(const struct utmpx *ut)
 {
   ID0set0();
-  if (logout(ut->ut_line)) {
-    log_Printf(LogID0, "logout(\"%s\")\n", ut->ut_line);
-    logwtmp(ut->ut_line, "", "");
-    log_Printf(LogID0, "logwtmp(\"%s\", \"\", \"\")\n", ut->ut_line);
-  }
-  login(ut);
-  log_Printf(LogID0, "login(\"%s\", \"%.*s\")\n",
-            ut->ut_line, (int)(sizeof ut->ut_name), ut->ut_name);
+  pututxline(ut);
+  log_Printf(LogID0, "pututxline(\"%.*s\", \"%.*s\", \"%.*s\", \"%.*s\")\n",
+      (int)sizeof ut->ut_id, ut->ut_id,
+      (int)sizeof ut->ut_user, ut->ut_user,
+      (int)sizeof ut->ut_line, ut->ut_line,
+      (int)sizeof ut->ut_host, ut->ut_host);
   ID0setuser();
 }
 
 void
-ID0logout(const char *device, int nologout)
+ID0logout(const struct utmpx *ut)
 {
-  struct utmp ut;
-  char ut_line[sizeof ut.ut_line + 1];
-
-  strncpy(ut_line, device, sizeof ut_line - 1);
-  ut_line[sizeof ut_line - 1] = '\0';
-
   ID0set0();
-  if (nologout || logout(ut_line)) {
-    log_Printf(LogID0, "logout(\"%s\")\n", ut_line);
-    logwtmp(ut_line, "", "");
-    log_Printf(LogID0, "logwtmp(\"%s\", \"\", \"\")\n", ut_line);
-  } else
-    log_Printf(LogERROR, "ID0logout: No longer logged in on %s\n", ut_line);
+  pututxline(ut);
+  log_Printf(LogID0, "pututxline(\"%.*s\")\n",
+      (int)sizeof ut->ut_id, ut->ut_id);
   ID0setuser();
 }
 

Modified: user/ed/utmpx/usr.sbin/ppp/id.h
==============================================================================
--- user/ed/utmpx/usr.sbin/ppp/id.h	Sat Jan  9 21:23:39 2010	(r201932)
+++ user/ed/utmpx/usr.sbin/ppp/id.h	Sat Jan  9 21:57:41 2010	(r201933)
@@ -27,7 +27,7 @@
  */
 
 #ifndef NOSUID
-struct utmp;
+struct utmpx;
 struct sockaddr_un;
 
 extern void ID0init(void);
@@ -41,8 +41,8 @@ extern int ID0write(int, const void *, s
 extern int ID0uu_lock(const char *);
 extern int ID0uu_lock_txfr(const char *, pid_t);
 extern int ID0uu_unlock(const char *);
-extern void ID0login(struct utmp *);
-extern void ID0logout(const char *, int);
+extern void ID0login(const struct utmpx *);
+extern void ID0logout(const struct utmpx *);
 extern int ID0bind_un(int, const struct sockaddr_un *);
 extern int ID0connect_un(int, const struct sockaddr_un *);
 extern int ID0kill(pid_t, int);
@@ -64,20 +64,8 @@ extern int ID0NgMkSockNode(const char *,
 #define ID0uu_lock uu_lock
 #define ID0uu_lock_txfr uu_lock_txfr
 #define ID0uu_unlock uu_unlock
-#define ID0login(u)			\
-  do {					\
-    if (logout((u)->ut_line))		\
-      logwtmp((u)->ut_line, "", "");	\
-    login(u);				\
-  } while (0)
-#define ID0logout(dev, no)				\
-  do {							\
-    struct utmp ut;					\
-    strncpy(ut.ut_line, dev, sizeof ut.ut_line - 1);	\
-    ut.ut_line[sizeof ut.ut_line - 1] = '\0';		\
-    if (no || logout(ut.ut_line))			\
-      logwtmp(ut.ut_line, "", ""); 			\
-  } while (0)
+#define ID0login pututxline
+#define ID0logout pututxline
 #define ID0bind_un(s, n) bind(s, (const struct sockaddr *)(n), sizeof *(n))
 #define ID0connect_un(s, n) \
 	connect(s, (const struct sockaddr *)(n), sizeof *(n))

Modified: user/ed/utmpx/usr.sbin/ppp/physical.c
==============================================================================
--- user/ed/utmpx/usr.sbin/ppp/physical.c	Sat Jan  9 21:23:39 2010	(r201932)
+++ user/ed/utmpx/usr.sbin/ppp/physical.c	Sat Jan  9 21:57:41 2010	(r201933)
@@ -25,6 +25,7 @@
 #include <netinet/in_systm.h>
 #include <netinet/ip.h>
 #include <sys/socket.h>
+#include <sys/time.h>
 #include <sys/un.h>
 
 #include <errno.h>
@@ -42,7 +43,7 @@
 #include <termios.h>
 #include <time.h>
 #include <unistd.h>
-#include <utmp.h>
+#include <utmpx.h>
 #if defined(__OpenBSD__) || defined(__NetBSD__)
 #include <sys/ioctl.h>
 #include <util.h>
@@ -106,8 +107,6 @@
 #endif
 #include "tcpmss.h"
 
-#define PPPOTCPLINE "ppp"
-
 static int physical_DescriptorWrite(struct fdescriptor *, struct bundle *,
                                     const fd_set *);
 
@@ -333,6 +332,7 @@ physical_Close(struct physical *p)
 {
   int newsid;
   char fn[PATH_MAX];
+  struct utmpx ut;
 
   if (p->fd < 0)
     return;
@@ -344,12 +344,11 @@ physical_Close(struct physical *p)
 
   physical_StopDeviceTimer(p);
   if (p->Utmp) {
-    if (p->handler && (p->handler->type == TCP_DEVICE ||
-                       p->handler->type == UDP_DEVICE))
-      /* Careful - we logged in on line ``ppp'' with IP as our host */
-      ID0logout(PPPOTCPLINE, 1);
-    else
-      ID0logout(p->name.base, 0);
+    memset(&ut, 0, sizeof ut);
+    ut.ut_type = DEAD_PROCESS;
+    gettimeofday(&ut.ut_tv, NULL);
+    snprintf(ut.ut_id, sizeof ut.ut_id, "%dppp", (int)getpid());
+    ID0logout(&ut);
     p->Utmp = 0;
   }
   newsid = tcgetpgrp(p->fd) == getpgrp();
@@ -911,16 +910,17 @@ void
 physical_Login(struct physical *p, const char *name)
 {
   if (p->type == PHYS_DIRECT && *p->name.base && !p->Utmp) {
-    struct utmp ut;
+    struct utmpx ut;
     const char *connstr;
     char *colon;
 
     memset(&ut, 0, sizeof ut);
-    ut.ut_time = time(NULL);
-    strncpy(ut.ut_name, name, sizeof ut.ut_name);
+    ut.ut_type = USER_PROCESS;
+    gettimeofday(&ut.ut_tv, NULL);
+    snprintf(ut.ut_id, sizeof ut.ut_id, "%dppp", (int)getpid());
+    strncpy(ut.ut_user, name, sizeof ut.ut_user);
     if (p->handler && (p->handler->type == TCP_DEVICE ||
                        p->handler->type == UDP_DEVICE)) {
-      strncpy(ut.ut_line, PPPOTCPLINE, sizeof ut.ut_line);
       strncpy(ut.ut_host, p->name.base, sizeof ut.ut_host);
       colon = memchr(ut.ut_host, ':', sizeof ut.ut_host);
       if (colon)
@@ -931,7 +931,7 @@ physical_Login(struct physical *p, const
       /* mgetty sets this to the connection speed */
       strncpy(ut.ut_host, connstr, sizeof ut.ut_host);
     ID0login(&ut);
-    p->Utmp = ut.ut_time;
+    p->Utmp = 1;
   }
 }
 

From owner-svn-src-user@FreeBSD.ORG  Sat Jan  9 23:13:06 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 0E3691065695;
	Sat,  9 Jan 2010 23:13:06 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id F1A628FC1B;
	Sat,  9 Jan 2010 23:13:05 +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 o09ND5u8044190;
	Sat, 9 Jan 2010 23:13:05 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o09ND56F044188;
	Sat, 9 Jan 2010 23:13:05 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201001092313.o09ND56F044188@svn.freebsd.org>
From: Ed Schouten <ed@FreeBSD.org>
Date: Sat, 9 Jan 2010 23:13:05 +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: r201948 - user/ed/utmpx/usr.sbin/ppp
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: Sat, 09 Jan 2010 23:13:06 -0000

Author: ed
Date: Sat Jan  9 23:13:05 2010
New Revision: 201948
URL: http://svn.freebsd.org/changeset/base/201948

Log:
  Use hexadecimal strings for the process identifier.
  
  This makes it more likely for the number to fit in there, even if the
  implementation only reserves four bytes for ut_id.

Modified:
  user/ed/utmpx/usr.sbin/ppp/physical.c

Modified: user/ed/utmpx/usr.sbin/ppp/physical.c
==============================================================================
--- user/ed/utmpx/usr.sbin/ppp/physical.c	Sat Jan  9 23:07:10 2010	(r201947)
+++ user/ed/utmpx/usr.sbin/ppp/physical.c	Sat Jan  9 23:13:05 2010	(r201948)
@@ -347,7 +347,7 @@ physical_Close(struct physical *p)
     memset(&ut, 0, sizeof ut);
     ut.ut_type = DEAD_PROCESS;
     gettimeofday(&ut.ut_tv, NULL);
-    snprintf(ut.ut_id, sizeof ut.ut_id, "%dppp", (int)getpid());
+    snprintf(ut.ut_id, sizeof ut.ut_id, "%xppp", (int)getpid());
     ID0logout(&ut);
     p->Utmp = 0;
   }
@@ -917,7 +917,7 @@ physical_Login(struct physical *p, const
     memset(&ut, 0, sizeof ut);
     ut.ut_type = USER_PROCESS;
     gettimeofday(&ut.ut_tv, NULL);
-    snprintf(ut.ut_id, sizeof ut.ut_id, "%dppp", (int)getpid());
+    snprintf(ut.ut_id, sizeof ut.ut_id, "%xppp", (int)getpid());
     strncpy(ut.ut_user, name, sizeof ut.ut_user);
     if (p->handler && (p->handler->type == TCP_DEVICE ||
                        p->handler->type == UDP_DEVICE)) {

From owner-svn-src-user@FreeBSD.ORG  Sat Jan  9 23:34:41 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 293991065762;
	Sat,  9 Jan 2010 23:34:41 +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 16A198FC19;
	Sat,  9 Jan 2010 23:34:41 +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 o09NYeRq049264;
	Sat, 9 Jan 2010 23:34:40 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o09NYeWT049261;
	Sat, 9 Jan 2010 23:34:40 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001092334.o09NYeWT049261@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Sat, 9 Jan 2010 23:34:40 +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: r201956 - in
	user/kmacy/releng_8_fcs_buf_xen/sys/cddl/contrib/opensolaris/uts/common/fs/zfs:
	. sys
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: Sat, 09 Jan 2010 23:34:41 -0000

Author: kmacy
Date: Sat Jan  9 23:34:40 2010
New Revision: 201956
URL: http://svn.freebsd.org/changeset/base/201956

Log:
  - fix buildworld
  - add check for overlaps in on insert
  - add additional cases to evict overlap
  - cache pages that are part of freed buffers

Modified:
  user/kmacy/releng_8_fcs_buf_xen/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_bio.h
  user/kmacy/releng_8_fcs_buf_xen/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_bio.c

Modified: user/kmacy/releng_8_fcs_buf_xen/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_bio.h
==============================================================================
--- user/kmacy/releng_8_fcs_buf_xen/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_bio.h	Sat Jan  9 23:24:49 2010	(r201955)
+++ user/kmacy/releng_8_fcs_buf_xen/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_bio.h	Sat Jan  9 23:34:40 2010	(r201956)
@@ -47,10 +47,11 @@ zio_sync_cache(spa_t *spa, blkptr_t *bp,
 {
 	int io_bypass = 0;
 
+#ifdef	_KERNEL
 	if (!zfs_page_cache_disable && (vd == NULL) &&
 	    ((type == ZIO_TYPE_WRITE) || (type == ZIO_TYPE_READ)))
 		io_bypass = _zio_sync_cache(spa, bp, txg, data, size, type);
-
+#endif
 	return (io_bypass);
 }
 
@@ -58,17 +59,21 @@ static __inline void
 zio_cache_valid(void *data, uint64_t size, zio_type_t type, vdev_t *vd) 
 {
 
+#ifdef	_KERNEL
 	if (((vd == NULL) || (vd->vdev_spa->spa_root_vdev == vd)) &&
 	    (type == ZIO_TYPE_READ) && (size & PAGE_MASK) == 0)
 		_zio_cache_valid(data, size);
+#endif	
 }
 
+
 void *zio_getblk(uint64_t size, int flags);
 void zio_relse(void *data, size_t size);
 void *zio_spa_state_alloc(spa_t *spa);
-
-#ifdef _KERNEL
 void zfs_bio_init(void);
 void zfs_bio_fini(void);
+
+#ifndef _KERNEL
+#define GB_NODUMP	0
 #endif
 #endif

Modified: user/kmacy/releng_8_fcs_buf_xen/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_bio.c
==============================================================================
--- user/kmacy/releng_8_fcs_buf_xen/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_bio.c	Sat Jan  9 23:24:49 2010	(r201955)
+++ user/kmacy/releng_8_fcs_buf_xen/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_bio.c	Sat Jan  9 23:34:40 2010	(r201956)
@@ -100,13 +100,13 @@ __FBSDID("$FreeBSD$");
 #include <sys/kstat.h>
 #include <sys/sdt.h>
 
-#include <sys/sf_buf.h>
 #include <sys/zfs_bio.h>
 
+int zfs_page_cache_disable = 1;
 #ifdef _KERNEL
+#include <sys/sf_buf.h>
 
 SYSCTL_DECL(_vfs_zfs);
-int zfs_page_cache_disable = 1;
 TUNABLE_INT("vfs.zfs.page_cache_disable", &zfs_page_cache_disable);
 SYSCTL_INT(_vfs_zfs, OID_AUTO, page_cache_disable, CTLFLAG_RDTUN,
     &zfs_page_cache_disable, 0, "Disable backing ARC with page cache ");
@@ -198,7 +198,6 @@ buf_hash(caddr_t va, uint64_t size)
 	int i;
 
 	ASSERT(zfs_crc64_table[128] == ZFS_CRC64_POLY);
-
 	for (i = 0; i < sizeof (caddr_t); i++)
 		crc = (crc >> 8) ^ zfs_crc64_table[(crc ^ vav[i]) & 0xFF];
 
@@ -208,8 +207,6 @@ buf_hash(caddr_t va, uint64_t size)
 }
 
 const char *buf_lock = "ht_lock";
-
-
 void
 buf_init(void)
 {
@@ -376,6 +373,27 @@ zio_buf_va_remove(caddr_t va, uint64_t s
 	return (bp);
 }
 
+static void
+zio_buf_find_duplicates(zio_spa_state_t object)
+{
+	buf_t bp0, bp1;
+	
+	
+	TAILQ_FOREACH(bp0, &object->zss_blkno_memq, b_freelist) {		
+		TAILQ_FOREACH(bp1, &object->zss_blkno_memq, b_freelist) {
+			if (bp0 == bp1)
+				continue;
+			if (((bp0->b_blkno >= bp1->b_blkno) &&
+			    (bp0->b_blkno < bp1->b_blkno + btos(bp1->b_bcount))) ||
+			    ((bp0->b_blkno + btos(bp0->b_bcount) > bp1->b_blkno) &&
+				(bp0->b_blkno + btos(bp0->b_bcount) <=
+				    bp1->b_blkno + btos(bp1->b_bcount))))
+				panic("duplicate blkno mappings at %lld",
+				    bp0->b_blkno);
+		}
+	}
+}
+
 /*
  *	zio_buf_blkno_splay:		[ internal use only ]
  *
@@ -483,6 +501,7 @@ zio_buf_blkno_insert(buf_t bp, zio_spa_s
 	 * show that the object has one more resident buffer.
 	 */
 	object->zss_resident_count++;
+	zio_buf_find_duplicates(object);
 }
 
 /*
@@ -687,11 +706,25 @@ zio_buf_evict_overlap(vm_object_t object
 	if ((root = state->zss_blkno_root) == NULL)
 		goto done;
 
+	if (blkno >= root->b_blkno &&
+	    blkno_end <= root->b_blkno + btos(root->b_bcount)) {
+		tmpbp = root;
+		collisions = 1;
+		goto evict;
+	}
+	
 	collisions = 0;
 	blkno_end = blkno + btos(size);
 	if ((root = zio_buf_blkno_splay(blkno, root)) == NULL)
 		goto done;
 
+	if (blkno >= root->b_blkno &&
+	    blkno_end <= root->b_blkno + btos(root->b_bcount)) {
+		tmpbp = root;
+		collisions = 1;
+		goto evict;
+	}
+
 	if ((blkno >= root->b_blkno) ||
 	    (tmpbp = TAILQ_PREV(root, cluster_list_head, b_freelist)) == NULL ||
 	    (blkno >= tmpbp->b_blkno + btos(tmpbp->b_bcount)))
@@ -721,6 +754,7 @@ zio_buf_evict_overlap(vm_object_t object
 	while (!TAILQ_EMPTY(&clh)) {
 		tmpbp = TAILQ_FIRST(&clh);
 		TAILQ_REMOVE(&clh, tmpbp, b_cluster.cluster_entry);
+	evict:
 		zio_buf_vm_object_evict(tmpbp);
 		tmpbp->b_bufobj = NULL;
 		tmpbp->b_flags &= ~B_VMIO;
@@ -762,6 +796,8 @@ vm_object_reference_pages(vm_object_t ob
 	vm_page_lock_queues();
 	for (i = 0; i < bp->b_npages; i++) {
 		m = vm_page_lookup(object, start + i);
+		vm_pageq_remove(m);
+		m->flags |= PG_UNMANAGED;
 		vm_page_wire(m);
 		bp->b_pages[i] = m;
 	}
@@ -859,15 +895,20 @@ zio_relse(void *data, size_t size)
 	bp = zio_buf_va_remove(data, size);
 
 	if (bp->b_flags & B_VMIO) {
+		VM_OBJECT_LOCK(zio_buf_get_vm_object(bp));
 		vm_page_lock_queues();
 		for (i = 0; i < bp->b_npages; i++) {
 			m = bp->b_pages[i];
 			m->wire_count--;
 			m->flags &= ~PG_UNMANAGED;
-			vm_page_deactivate(m);
-			m->wire_count++; /* brelse assumes wire_count is set */
+			vm_page_cache(m);
+			bp->b_pages[i] = 0;
 		}
 		vm_page_unlock_queues();
+		VM_OBJECT_UNLOCK(zio_buf_get_vm_object(bp));
+		atomic_subtract_int(&cnt.v_wire_count, bp->b_npages);
+		pmap_qremove((vm_offset_t)bp->b_saveaddr, bp->b_npages);
+		bp->b_npages = 0;
 		zio_buf_blkno_remove(bp);
 	}
 	
@@ -882,7 +923,7 @@ zio_relse(void *data, size_t size)
 		    " size %ld blkno=%ld",
 		    bp, bp->b_flags, size, bp->b_blkno);
 		bp->b_flags |= (B_ZFS|B_INVAL);
-		bp->b_flags &= ~B_CACHE;
+		bp->b_flags &= ~(B_CACHE|B_VMIO);
 		brelse(bp);
 	}
 }
@@ -964,8 +1005,7 @@ _zio_sync_cache(spa_t *spa, blkptr_t *bl
 				m->wire_count--;
 				vm_page_free(m);
 			}
-
-		
+			atomic_subtract_int(&cnt.v_wire_count, bp->b_npages);
 			vm_object_reference_pages(object, bp);
 		} else
 			zio_buf_vm_object_insert(bp, vp, object, FALSE);
@@ -1055,13 +1095,13 @@ zfs_bio_fini(void)
 #else /* !_KERNEL */
 
 void *
-zio_getblk(uint64_t size)
+zio_getblk(uint64_t size, int flags)
 {
 	return (zio_buf_alloc(size));
 }
 
-void
-zio_data_getblk(uint64_t size)
+void *
+zio_data_getblk(uint64_t size, int flags)
 {
 
 	return (zio_data_buf_alloc(size));
@@ -1075,9 +1115,14 @@ zio_relse(void *data, size_t size)
 }
 
 void
-zio_sync_cache(spa_t *spa, blkptr_t *bp, uint64_t txg, uint64_t size)
+zfs_bio_init(void)
+{
+}
+
+void
+zfs_bio_fini(void)
 {
-	;
 }
+
 #endif
 

From owner-svn-src-user@FreeBSD.ORG  Sat Jan  9 23:36:16 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 EA002106568B;
	Sat,  9 Jan 2010 23:36:15 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id D768E8FC0C;
	Sat,  9 Jan 2010 23:36:15 +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 o09NaFux049706;
	Sat, 9 Jan 2010 23:36:15 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o09NaFsk049700;
	Sat, 9 Jan 2010 23:36:15 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001092336.o09NaFsk049700@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Sat, 9 Jan 2010 23:36:15 +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: r201958 - in user/luigi/ipfw3-head: sbin/ipfw
	sys/netinet sys/netinet/ipfw
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: Sat, 09 Jan 2010 23:36:16 -0000

Author: luigi
Date: Sat Jan  9 23:36:15 2010
New Revision: 201958
URL: http://svn.freebsd.org/changeset/base/201958

Log:
  snapshot

Modified:
  user/luigi/ipfw3-head/sbin/ipfw/dummynet.c
  user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c

Modified: user/luigi/ipfw3-head/sbin/ipfw/dummynet.c
==============================================================================
--- user/luigi/ipfw3-head/sbin/ipfw/dummynet.c	Sat Jan  9 23:34:45 2010	(r201957)
+++ user/luigi/ipfw3-head/sbin/ipfw/dummynet.c	Sat Jan  9 23:36:15 2010	(r201958)
@@ -321,9 +321,12 @@ ipfw_list_pipes(void *data, uint nbytes,
 		/*
 		 * Print rate (or clocking interface)
 		 */
+#if 0
 		if (p->if_name[0] != '\0')
 			sprintf(buf, "%s", p->if_name);
-		else if (b == 0)
+		else
+#endif
+		if (b == 0)
 			sprintf(buf, "unlimited");
 		else if (b >= 1000000)
 			sprintf(buf, "%7.3f Mbit/s", b/1000000);
@@ -513,6 +516,9 @@ read_bandwidth(char *arg, int *bandwidth
 		warn("duplicate token, override bandwidth value!");
 
 	if (arg[0] >= 'a' && arg[0] <= 'z') {
+		if (!if_name) {
+			errx(1, "no if support");
+		}
 		if (namelen >= IFNAMSIZ)
 			warn("interface name truncated");
 		namelen--;
@@ -717,9 +723,21 @@ load_extra_delays(const char *filename, 
 
 /*
  * configuration of pipes, schedulers, flowsets.
- * do_pipe = 1 -> pipe (1 pipe + 1 flowset + 1 FIFO + 1 WFQ)
- * do_pipe = 2 -> flowset
- * do_pipe = 3 -> sched
+ * When we configure a new scheduler, an empty pipe is created, so:
+ * 
+ * do_pipe = 1 -> "pipe N config ..." only for backward compatibility
+ *	sched N+Delta type fifo sched_mask ...
+ *	pipe N+Delta <parameters>
+ *	flowset N+Delta pipe N+Delta (no parameters)
+ *	sched N type wf2q+ sched_mask ...
+ *	pipe N <parameters>
+ *
+ * do_pipe = 2 -> flowset N config
+ *	flowset N parameters
+ *
+ * do_pipe = 3 -> sched N config
+ *	sched N parameters (default no pipe)
+ *	optional Pipe N config ...
  * pipe ==>
  */
 void
@@ -731,6 +749,8 @@ ipfw_config_pipe(int ac, char **av)
 	struct dn_id *buf, *base;
 	struct new_sch *sch = NULL;
 	struct new_pipe *p = NULL;
+	struct new_sch *sch2 = NULL; /* the fifo scheduler */
+	struct new_pipe *p2 = NULL; /* the fifo pipe */
 	struct new_fs *fs = NULL;
 	struct new_profile *pf = NULL;
 	struct new_cmd *cmd = NULL;
@@ -738,7 +758,7 @@ ipfw_config_pipe(int ac, char **av)
 	int lmax = sizeof(*cmd);	/* always present */
 
 	/* worst case: 2 schedulers, 1 profile, 1 pipe, 1 flowset */
-	lmax += 2*sizeof(*sch) + sizeof(*p) + sizeof(*fs) + sizeof(*pf);
+	lmax += 2*sizeof(*sch) + 2*sizeof(*p) + sizeof(*fs) + sizeof(*pf);
 
 	av++; ac--;
 	/* Pipe number */
@@ -757,12 +777,18 @@ ipfw_config_pipe(int ac, char **av)
 	switch (co.do_pipe) {
 	case 1:
 		sch = o_next(&buf, sizeof(*sch), DN_SCH);
+		sch->sched_nr = i + DN_PIPEOFFSET;
 		p = o_next(&buf, sizeof(*p), DN_PIPE);
-		fs = o_next(&buf, sizeof(*fs), DN_FS);
+		p->pipe_nr = i + DN_PIPEOFFSET;
 		mask = &sch->sched_mask;
-		sch->pipe_nr = p->pipe_nr = i;
+		fs = o_next(&buf, sizeof(*fs), DN_FS);
 		fs->fs_nr = i + DN_PIPEOFFSET;
-		fs->sched_nr = sch->sched_nr = i + DN_PIPEOFFSET;
+		fs->sched_nr = i + DN_PIPEOFFSET;
+
+		/* sch2 and p2 will be set later */
+		sch2 = o_next(&buf, sizeof(*sch2), DN_SCH);
+		p2 = o_next(&buf, sizeof(*p2), DN_PIPE);
+
 		break;
 
 	case 2: /* flowset */
@@ -978,7 +1004,7 @@ end_mask:
 		case TOK_BW:
 			NEED(p, "bw is only for pipe");
 			NEED1("bw needs bandwidth or interface\n");
-			read_bandwidth(av[0], &p->bandwidth, p->if_name, sizeof(p->if_name));
+			read_bandwidth(av[0], &p->bandwidth, NULL, 0);
 			ac--; av++;
 			break;
 
@@ -1142,10 +1168,16 @@ end_mask:
 		i = do_cmd(IP_DUMMYNET_CONFIGURE, prof, sizeof *prof);
 	} else
 #endif
-	{
-		i = do_cmd(IP_DUMMYNET_CONFIGURE, base,
-			(char *)buf - (char *)base);
+	if (sch2) {
+		*sch2 = *sch;
+		sch2->sched_nr = i;
+	}
+	if (p2) {
+		*p2 = *p;
+		p2->pipe_nr = i;
 	}
+	i = do_cmd(IP_DUMMYNET_CONFIGURE, base,
+		(char *)buf - (char *)base);
 
 	if (i)
 		err(1, "setsockopt(%s)", "IP_DUMMYNET_CONFIGURE");

Modified: user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h	Sat Jan  9 23:34:45 2010	(r201957)
+++ user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h	Sat Jan  9 23:36:15 2010	(r201958)
@@ -65,7 +65,7 @@ enum {
 	DN_PROFILE,
 	DN_FS_EXT,
 	DN_QUEUE_EXT,
-	DN_UNKNOW,
+	DN_TEXT,		/* subtype is the object */
 	DN_CMD_CONFIGURE,	/* objects follow */
 	DN_CMD_DELETE,		/* subtype + list of entries */
 	DN_CMD_GET,		/* subtype + list of entries */
@@ -73,22 +73,23 @@ enum {
 	DN_LAST,
 };
  
-/* These values are in the subtype field of struct gen */
-enum {
-	DN_CONF_PIPE  = 1,
-	DN_CONF_QUEUE = 2,
-	DN_CONF_SCHED = 3,
+enum { /* subtype for schedulers, flowset and the like */
+	DN_UNKNOWN = 0,
+	/* others are in individual modules */
 };
- 
-/* These values are in the flag field of a scheduler
- * Some of them are used only by kernel (k)
- */
-enum sched_flag {
-    DN_SCH_RECONFIGURE          = 0x0001, /* (k) */
-    DN_SCH_HAVE_MASK            = 0x0002,
-    DN_SCH_DELETE               = 0x0004, /* (k) */
-    DN_SCH_REENQUEUE            = 0x0008, /* (k) */
-    DN_SCH_ACTIVE               = 0x0010, /* (k) */
+
+enum {	/* user flags */
+	DN_HAVE_MASK	= 0x0001,
+	DN_QSIZE_BYTES	= 0x0008,
+	DN_NOERROR	= 0x0010,
+};
+
+/* kernel-side flags */
+enum {
+    DN_RECONFIGURE          = 0x0001, /* (k) */
+    DN_DELETE               = 0x0004, /* (k) */
+    DN_REENQUEUE            = 0x0008, /* (k) */
+    DN_ACTIVE               = 0x0010, /* (k) */
 //     DN_SCH_BUSY                 = 0x0020, /* (k) */
     DN_SCH_DELETE_DELAY_LINE  = 0x0040, /* (k) */
 };
@@ -101,6 +102,7 @@ struct new_cmd {	/* header for all socko
 	uint32_t	data[0];	/* actually, entries elements */
 };
 
+/* A delay profile is attached to a pipe */
 #define	ED_MAX_SAMPLES_NO	1024
 struct new_profile {
 	struct dn_id oid;
@@ -114,9 +116,8 @@ struct new_profile {
 	int samples[ED_MAX_SAMPLES_NO]; /* this has actually samples_no slots */
 };
 
-/* Pipe template
- * All pipe are linked in a list, there is a 1-1 mapping between
- * 'ipfw pipe XX ...' commands and pipe XX
+/*
+ * pipe template. In the kernel it is right after a scheduler.
  */
 struct new_pipe {
 	struct dn_id oid;
@@ -135,22 +136,7 @@ struct new_pipe {
 	int delay ;                 /* D, really, ticks        */
 	uint64_t burst; /* burst size, scaled. bits*Hz  XXX */
 
-	/*
-	 * When the tx clock comes from an interface (if_name[0] != '\0'),
-	 * its name is stored below.
-	 */
-	char if_name[IFNAMSIZ];
-
 	struct new_profile *profile;
-
-	/*
-	 * The following parameters set at runtime and only valid
-	 * in the kernel. Userland should not look at these fields.
-	 */
-	struct ifnet *ifp;
-	int ready ; /* set if ifp != NULL and we got a signal from it */
-
-	SLIST_ENTRY(new_pipe) next; /* Global list of all pipes */
 };
 
 /*
@@ -163,10 +149,7 @@ struct new_text {
 };
 
 /*
- * description of a flow set.
- * All flowset are linked in a list, there is a 1-1 mapping between
- * 'ipfw queue XX ...' commands and flowset XX
- * (plus there is a FIFO flowset for each pipe)
+ * A flowset, which is a template for queues.
  */
 struct new_fs {
 	struct dn_id oid;
@@ -178,121 +161,32 @@ struct new_fs {
 	/* The flowset implicitly created for pipe N is N+offset */
 
 	int qsize; /* QSZ, queue size in slots or bytes */
+	int flags;	/* userland flags */
 
 	/* Number of buckets used for the hash table in this fs. */
 	int bucket;     /* B */
 	int plr ;       /* PLR, pkt loss rate (2^31-1 means 100%) */
 
-	/* Copy of command line  */
-	struct new_text *cmdline;
-
 	/* mask to select the appropriate queue */
 	struct ipfw_flow_id flow_mask;  /* M */
-	int sched_nr;   /* P, the pipe we attach to */
-
-	/*--- parameters set at runtime */
-	SLIST_ENTRY(new_fs) next;   /* list of flow sets */
-
-	/* Used to link flowset to be configured */
-	struct new_fs *confnext;
-
-	/* DN_FS_DELETE
-	 * DN_FS_REENQUEUE
-	 * DN_HAVE_FLOW_MASK
-	 * DN_QSIZE_IS_BYTES
-	 * DN_NOERROR
-	 */
-	int flags;
-
-	/* Number of queues attached to this flowset */
-	int active_f;
-
-	/* Number of packets in the scheduler mutex queue */
-	int busy;
-
-	/* Scheduler associated with this flowset, set when the
-	* scheduler for the pipe P is defined.
-	*/
-	struct new_sch *sched;
-	int sched_id; /* to check if the pointer is correct */
-
-	/*
-	* Pointer to scheduler-specific parameters for this flowset
-	* (for examples, the weight parameter of wf2q+ algorithm goes here)
-	*/
-	struct dn_id *alg_fs;
-	/* Pointer to scheduler functions */
-	struct dn_sched *fp;
-};
-
-/* Implementation of the packets queue associated with a scheduler instance */
-struct new_queue {
-    struct dn_id oid;
- 
-    /* Number and pointer to the parent flowset */
-    int fs_nr;
-    struct new_fs *fs;
-
-    u_int lenght; /* Queue lenght, in packets */
-    u_int len_bytes; /* Queue lenght, in bytes */
-
-    uint64_t tot_pkts; /* statistics counters  */
-    uint64_t tot_bytes;
-    uint32_t drops;
- 
-    /* Used to print the id of the queue */
-    int hash_slot;
-
-    /* Pointer to the scheduler instance that the packet belongs */
-    void *sch_inst; /* Pointer to scheduler specific data */
-
-    /* packets queue */
-    struct mbuf *head, *tail;
-
-    /* flow id associated with this queue */
-    struct ipfw_flow_id id;
-
-    struct new_queue *next; /* Next queue in the bucket */
-
-    /* Pointer to scheduler functions */
-    struct dn_sched *fp;
+	int sched_nr;   /* the scheduler we attach to */
 };
-SLIST_HEAD(new_queue_head, new_queue);
+
 /*
- * Scheduler instance.
- * Contains variables and all queues relative to a this instance.
- * This struct is created a runtime.
+ * An instance descriptor has a type, a flow_id, flags and a few counters.
+ * so we used this to pass information up to userland.
  */
-struct new_sch_inst {
+struct new_inst {
 	struct dn_id oid;
-
-	struct new_sch_inst *next; /* next item in the bucket */
-
-	/* Parent scheduler */
-	int sched_nr;
-	struct new_sch *sched;
-
-	int hash_slot; /* used to print the id of the scheduler instance */
-
-	/* flow id associated with this scheduler instance */
-	struct ipfw_flow_id id;
-
-	int flags;    /* DN_SCHED_ACTIVE */
-
-	/* Pointer to the delay line for this scheduler instance */
-	struct delay_line *dline;
-
-	/* List of queues that will be returned when user type a command like
-	* 'ipfw pipe | queue list'.
-	* List is automatically update when a queue is created and destroyed
-	*/
-	struct new_queue_head ql_list;
-
-	int64_t numbytes;       /* bits I can transmit (more or less). */
-	dn_key sched_time ;     /* time pipe was scheduled in ready_heap */
-	dn_key idle_time;       /* start of scheduler instance idle time */
+	uint32_t	parent_nr; /* sched or flowset nr */
+	uint32_t	lenght; /* Queue lenght, in packets */
+	uint32_t	len_bytes; /* Queue lenght, in bytes */
+	uint32_t	drops;
+	uint64_t	tot_pkts; /* statistics counters  */
+	uint64_t	tot_bytes;
 };
 
+
 /* Scheduler template
  * All scheduler are linked in a list, there is a 1-1 mapping between
  * 'ipfw sched XX ...' commands and sched XX
@@ -300,70 +194,15 @@ struct new_sch_inst {
  */
 struct new_sch {
 	struct dn_id oid;
-
-	/* these initial fields are set from the command line
-	* sched N config mask M ...
-	*/
-
 	int sched_nr; /* N, scheduler number */
 	int bucket; /* number of buckets for the instances */
+	int flags;	/* have_mask, ... */
 
 	/* mask to select the appropriate scheduler instance */
 	struct ipfw_flow_id sched_mask; /* M */
-
-	/*--- parameters set at runtime */
-
-	/* This structure is in a list of schedulers where we do
-	* the lookup when necessary. 'next' is the link field.
-	* Also, all instances of this scheduler may be in a heap used
-	* to fetch them when they are ready. 'inst_counter' counts
-	* how many instances are in the heap and can be used
-	* as a reference count.
-	*/
-	SLIST_ENTRY(new_sch) next;  /* List of all templates */
-
-	/* number of scheduler instances for this scheduler in the ready_heap
-	* Used to check when we can delete a scheduler safely
-	*/
-	int inst_counter;
-
-	/* Pointer to the parent pipe */
-	int pipe_nr;
-	struct new_pipe *pipe;
-
-	/* Copy of command line  */
-	#define DN_MAX_COMMAND  256
-	char command_line[DN_MAX_COMMAND];
-
-	/* Hash table contains all scheduler instances associated with
-	* this scheduler
-	*/
-	int sch_i_size;
-	int sch_i_elements;
-	struct new_sch_inst **sch_i;
-
-	/*
-	* DN_HAVE_SCH_MASK
-	* DN_SCH_DELETE
-	* DN_SCH_REENQUEUE
-	* DN_SCH_REENQUEUE
-	* DN_FORCE_DELETE_DELAY_LINE
-	*/
-	int flags;
-
-	/* Pointer to scheduler functions */
-	struct dn_sched *fp;
-
-	/* Counter of packets pending to entering in this scheduler.
-	* Used to avoid to delete the scheduler if some packets are in the mutex
-	* queue
-	*/
-	int busy;
-
-	/* Mutex to protect a single scheduler */
-	// struct mtx sch_mtx;
 };
 
+
 /*
  * "queue N" and "pipe N" accept 1<=N<=65535. To map the values in
  * the same namespace (which we search through a hash table) we add

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c	Sat Jan  9 23:34:45 2010	(r201957)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c	Sat Jan  9 23:36:15 2010	(r201958)
@@ -86,6 +86,7 @@ struct dn_parms dn_cfg = {
 	.red_lookup_depth = 256,	/* RED - default lookup table depth */
 	.red_avg_pkt_size = 512,      /* RED - default medium packet size */
 	.red_max_pkt_size = 1500,     /* RED - default max packet size */
+	.hmask = (1<<4) - 1.
 };
 
 static long tick_last;		/* Last tick duration (usec). */
@@ -130,12 +131,6 @@ static unsigned long	io_pkt_drop;
   
 MALLOC_DEFINE(M_DUMMYNET, "dummynet", "dummynet heap");
 
-struct new_pipe_head	pipehash[DN_HASHSIZE];	/* all pipes */
-struct new_fs_head	flowsethash[DN_HASHSIZE];	/* all flowsets */
-struct new_sch_head    schedulerhash[DN_HASHSIZE];  /* all schedulers */
-struct new_fs_head     flowsetunlinked;      /* all unlinked flowsets */
-
-
 extern	void (*bridge_dn_p)(struct mbuf *, struct ifnet *);
 
 #ifdef SYSCTL_NODE
@@ -456,16 +451,17 @@ mask_are_equals (struct ipfw_flow_id *id
 /*
  * Create a new scheduler instance for the scheduler 'sch_t'.
  * Allocate memory for common and scheduler private data.
- * XXX put the delay line within the instance ?
- * XXX why do we need separate delay lines ?
+ * The delay line is per-instance and is allocated separately
+ * so we can remove it from the heap when due (XXX actually the
+ * heap supports random extraction, or we could link it back).
  */
 static struct new_sch_inst *
-create_scheduler_instance(struct new_sch *sch_t)
+create_scheduler_instance(struct new_schk *s)
 {
 	struct new_sch_inst *si;
 	int ret;
 	const char *msg = "malloc failure";
-	int l = sizeof(*si) + sch_t->fp->scheduler_i_size;
+	int l = sizeof(*si) + s->fp->scheduler_i_size;
 
 	si = malloc(l, M_DUMMYNET, M_NOWAIT | M_ZERO);
 
@@ -477,11 +473,11 @@ create_scheduler_instance(struct new_sch
 
 	set_oid(&si->oid, DN_SCH_I, 0, l);
 
-	si->sched_nr = sch_t->sched_nr;
-	si->sched = sch_t;
+	si->sched_nr = s->sch.sched_nr;
+	si->sched = s;
 
 	/* XXX do we make assumption on this starting with dn_id ? */
-	ret = sch_t->fp->new_sched(si + 1, sch_t + 1);
+	ret = s->fp->new_sched(si + 1, s + 1);
 	if (ret) {
 		msg = "new_sched error";
 		goto error;
@@ -501,19 +497,19 @@ error:
 }
 
 static struct new_sch_inst *
-find_scheduler(struct new_sch *sch_t, struct new_fs *fs,
+find_scheduler(struct new_schk *sch_t, struct new_fsk *fs,
                 struct ipfw_flow_id *id)
 {
     struct new_sch_inst *prev, *s; /* returning scheduler instance */
     int i;
     struct ipfw_flow_id id_t;
     
-    if ( !(sch_t->flags & DN_SCH_HAVE_MASK) ) {
+    if ( !(sch_t->flags & DN_HAVE_MASK) ) {
 	i = 0;
         s = sch_t->sch_i[0];
     } else {
  	id_t = *id;
-	do_mask(&sch_t->sched_mask, &id_t);
+	do_mask(&sch_t->sch.sched_mask, &id_t);
         i = do_hash(&id_t);
         i = i % sch_t->sch_i_size;
         /* finally, scan the current hash bucket for a match */
@@ -541,7 +537,7 @@ find_scheduler(struct new_sch *sch_t, st
         sch_t->sch_i[i] = s;
         sch_t->sch_i_elements++;
 	s->hash_slot = i;
-        if (sch_t->flags & DN_SCH_HAVE_MASK)
+        if (sch_t->flags & DN_HAVE_MASK)
 	    s->id = id_t;
     }
     return s;
@@ -556,14 +552,14 @@ static struct mbuf *
 serve_sched(struct new_sch_inst *s, dn_key now)
 {
 	struct mbuf *head;
-	struct new_sch *sch_t = s->sched;
+	struct new_schk *sch_t = s->sched;
 	struct mbuf *tosend = NULL;
 	struct new_pipe *pipe = sch_t->pipe;
 	int delay_line_idle = (s->dline->head == NULL);
 	int done, bw;
 
 	bw = pipe->bandwidth;
-	s->flags &= ~DN_SCH_ACTIVE;
+	s->flags &= ~DN_ACTIVE;
 
 	if (bw > 0)
 		s->numbytes += (now - s->sched_time) * bw;
@@ -599,7 +595,7 @@ serve_sched(struct new_sch_inst *s, dn_k
 		if (tosend)
 			dn_tag_get(tosend)->output_time += t;
 		s->sched->inst_counter++;
-		s->flags |= DN_SCH_ACTIVE;
+		s->flags |= DN_ACTIVE;
 		DN_HEAP_LOCK();
 		heap_insert(&dn_cfg.system_heap, curr_time + t, s);
 		DN_HEAP_UNLOCK();
@@ -618,7 +614,7 @@ serve_sched(struct new_sch_inst *s, dn_k
 void
 dummynet_task(void *context, int pending)
 {
-    struct new_sch *sch_t;
+    struct new_schk *sch_t;
     struct timeval t;
 
     DUMMYNET_LOCK();
@@ -699,7 +695,7 @@ dummynet_task(void *context, int pending
 	    sch_t = s->sched;
 	    DN_S_LOCK(sch_t);
 	    sch_t->inst_counter--;
-	    if (sch_t->flags & DN_SCH_DELETE) {
+	    if (sch_t->flags & DN_DELETE) {
 		/* Wait for scheduler->busy == 0 */
 		while (sch_t->busy) { /* XXX check */
 		    DN_S_UNLOCK(sch_t);
@@ -1110,13 +1106,13 @@ red_drops(struct dn_flow_set *fs, struct
 }
 #endif
 
-struct new_fs *
+struct new_fsk *
 ipdn_locate_flowset(int fs_nr)
 {
-	struct new_fs *fs;
+	struct new_fsk *fs;
 
-	SLIST_FOREACH(fs, &flowsethash[HASH(fs_nr)], next)
-		if (fs->fs_nr == fs_nr)
+	SLIST_FOREACH(fs, &dn_cfg.fshash[HASH(fs_nr)], next)
+		if (fs->fs.fs_nr == fs_nr)
 			return (fs);
 
 	return (NULL);
@@ -1143,10 +1139,10 @@ dummynet_io(struct mbuf **m0, int dir, s
 	struct mbuf *m = *m0, *head = NULL;
 	struct dn_pkt_tag *pkt;
 	struct m_tag *mtag;
-	struct new_fs *fs = NULL;
+	struct new_fsk *fs = NULL;
 	struct new_pipe *pipe = NULL;
 	struct new_queue *q = NULL;
-	struct new_sch *sch;
+	struct new_schk *sch;
 	struct new_sch_inst *sch_inst;
 	int ret;
 	dn_key now; /* save a copy of curr_time */
@@ -1188,7 +1184,7 @@ dummynet_io(struct mbuf **m0, int dir, s
 		goto dropit;
 
 	/* Apply the flow_mask */
-	do_mask(&fs->flow_mask, &(fwa->f_id));
+	do_mask(&fs->fs.flow_mask, &(fwa->f_id));
 
 	/* tag the mbuf */
 	mtag = m_tag_get(PACKET_TAG_DUMMYNET,
@@ -1230,7 +1226,7 @@ dummynet_io(struct mbuf **m0, int dir, s
 	 * called later, and we are done. Otherwise it is idle,
 	 * compute the initial allowance from io_fast and burst.
 	 */
-	if (sch_inst->flags & DN_SCH_ACTIVE)
+	if (sch_inst->flags & DN_ACTIVE)
 		goto done;
         sch_inst->numbytes = dn_cfg.io_fast ? pipe->bandwidth : 0;
         if (pipe->burst) {
@@ -1266,5 +1262,5 @@ dropit:
 	DUMMYNET_UNLOCK();
 	FREE_PKT(m);
 	*m0 = NULL;
-	return ((fs && (fs->flags & DN_NOERROR)) ? 0 : ENOBUFS);
+	return ((fs && (fs->fs.flags & DN_NOERROR)) ? 0 : ENOBUFS);
 }

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h	Sat Jan  9 23:34:45 2010	(r201957)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h	Sat Jan  9 23:36:15 2010	(r201958)
@@ -49,17 +49,10 @@ extern struct mtx dummynet_mtx;
 #define DN_HEAP_LOCK(x)
 #define DN_HEAP_UNLOCK(x)
 
-#define	DN_HASHSIZE	16
-#define HASH(num)       ((((num) >> 8) ^ ((num) >> 4) ^ (num)) & 0x0f)
-
-SLIST_HEAD(new_pipe_head, new_pipe);
-SLIST_HEAD(new_sch_head, new_sch);
-SLIST_HEAD(new_fs_head, new_fs);
-extern struct new_pipe_head      pipehash[DN_HASHSIZE];  /* all pipes */
-extern struct new_fs_head  flowsethash[DN_HASHSIZE]; /* all flowsets */
-extern struct new_sch_head    schedulerhash[DN_HASHSIZE];  /* all schedulers    */
-extern struct new_fs_head     flowsetunlinked;      /* all unlinked flowsets */
+#define HASH(num)	((((num) >> 8) ^ ((num) >> 4) ^ (num)) & dn_cfg.hmask)
 
+SLIST_HEAD(new_schk_head, new_schk);
+SLIST_HEAD(new_fsk_head, new_fsk);
 
 /*
  * global configuration parameters.
@@ -79,6 +72,11 @@ struct dn_parms {
 	int	io_fast;
 	struct timeval prev_t;
 	struct dn_heap	system_heap;
+	int	hmask;	/* mask for hashsize, must be 2^n-1 */
+	/* fhash and schedhash are hmask+1 entries */
+	struct new_fsk_head	*fshash;
+	struct new_fsk_head	fsunlinked;
+	struct new_schk_head	*schedhash;
 };
 
 static inline void
@@ -90,7 +88,8 @@ set_oid(struct dn_id *o, int type, int s
 };
 
 /*
- * Delay line, contains all packets that will be send out at certain time.
+ * Delay line, contains all packets that will be sent out
+ * at certain time.
  * Every scheduler instance has a delay line
  */
 struct delay_line {
@@ -102,6 +101,156 @@ struct delay_line {
 	struct mbuf *head, *tail; /* Packets queue */
 };
 
+struct new_fsk { /* kernel side of a flowset */
+	struct new_fs fs;
+	/* scheduler-specific commands for the flowset */
+	struct new_text *cmdline;
+
+	int kflags; /* kernel-side flags */
+	SLIST_ENTRY(new_fsk) next;   /* list of flow sets */
+	/*--- parameters set at runtime */
+
+	/* Used to link flowset to be configured XXX ? */
+	struct new_fsk *confnext;
+
+
+	/* Number of queues attached to this flowset */
+	int active_f;
+
+	/* Number of packets in the scheduler mutex queue */
+	int busy;
+
+	/* Scheduler associated with this flowset, set when the
+	* scheduler for the pipe P is defined.
+	*/
+	struct new_schk *sched;
+	int sched_id; /* to check if the pointer is correct */
+
+	/*
+	* Pointer to scheduler-specific parameters for this flowset
+	* (for examples, the weight parameter of wf2q+ algorithm goes here)
+	*/
+	struct dn_id *alg_fs;
+	/* Pointer to scheduler functions */
+	struct dn_sched *fp;
+};
+
+struct new_schk {
+	struct new_sch sch;
+
+	/* This structure is in a list of schedulers where we do
+	* the lookup when necessary. 'next' is the link field.
+	* Also, all instances of this scheduler may be in a heap used
+	* to fetch them when they are ready. 'inst_counter' counts
+	* how many instances are in the heap and can be used
+	* as a reference count.
+	*/
+	SLIST_ENTRY(new_schk) next;  /* List of all templates */
+
+	/* number of scheduler instances for this scheduler in the ready_heap
+	* Used to check when we can delete a scheduler safely
+	*/
+	int inst_counter;
+
+	/* Pointer to the parent pipe, and generation number */
+	int pipe_id;
+	struct new_pipe *pipe;
+
+	struct dn_id *cfg; /* extra config arguments */
+
+	/* Hash table contains all scheduler instances associated with
+	* this scheduler
+	*/
+	int sch_i_size;
+	int sch_i_elements;
+	struct new_sch_inst **sch_i;
+
+	/*
+	* DN_HAVE_SCH_MASK
+	* DN_SCH_DELETE
+	* DN_SCH_REENQUEUE
+	* DN_SCH_REENQUEUE
+	* DN_FORCE_DELETE_DELAY_LINE
+	*/
+	int flags;
+
+	/* Pointer to scheduler functions */
+	struct dn_sched *fp;
+
+	/* Counter of packets pending to entering in this scheduler.
+	* Used to avoid to delete the scheduler if some packets are in the mutex
+	* queue
+	*/
+	int busy;
+
+	/* Mutex to protect a single scheduler */
+	struct mtx sch_mtx;
+};
+
+/* Implementation of the packets queue associated with a scheduler instance */
+struct new_queue {
+    struct dn_id oid;
+    struct ipfw_flow_id id;
+ 
+    /* Number and pointer to the parent flowset */
+    int fs_nr;
+    struct new_fs *fs;
+
+    u_int lenght; /* Queue lenght, in packets */
+    u_int len_bytes; /* Queue lenght, in bytes */
+    uint64_t tot_pkts; /* statistics counters  */
+    uint64_t tot_bytes;
+    uint32_t drops;
+ 
+    /* Used to print the id of the queue */
+    int hash_slot;
+
+    /* Pointer to the scheduler instance that the packet belongs */
+    void *sch_inst; /* Pointer to scheduler specific data */
+
+    /* packets queue */
+    struct mbuf *head, *tail;
+
+    struct new_queue *next; /* Next queue in the bucket */
+
+    /* Pointer to scheduler functions */
+    struct dn_sched *fp;
+};
+SLIST_HEAD(new_queue_head, new_queue);
+/*
+ * Scheduler instance.
+ * Contains variables and all queues relative to a this instance.
+ * This struct is created a runtime.
+ */
+struct new_sch_inst {
+	struct dn_id oid;
+
+	struct new_sch_inst *next; /* next item in the bucket */
+
+	/* Parent scheduler */
+	int sched_nr;
+	struct new_schk *sched;
+
+	int hash_slot; /* used to print the id of the scheduler instance */
+
+	/* flow id associated with this scheduler instance */
+	struct ipfw_flow_id id;
+
+	int flags;    /* DN_SCHED_ACTIVE */
+
+	/* Pointer to the delay line for this scheduler instance */
+	struct delay_line *dline;
+
+	/* List of queues that will be returned when user type a command like
+	* 'ipfw pipe | queue list'.
+	* List is automatically update when a queue is created and destroyed
+	*/
+	struct new_queue_head ql_list;
+
+	int64_t numbytes;       /* bits I can transmit (more or less). */
+	dn_key sched_time ;     /* time pipe was scheduled in ready_heap */
+	dn_key idle_time;       /* start of scheduler instance idle time */
+};
 /* These values are in the flag field of a flowset
  * Some of them are used only by kernel (k)
  */
@@ -116,13 +265,13 @@ enum flowset_flag {
 extern struct dn_parms dn_cfg;
 
 struct new_pipe *ipdn_locate_pipe(int);
-struct new_fs *ipdn_locate_flowset(int);
+struct new_fsk *ipdn_locate_flowset(int);
 int     dummynet_io(struct mbuf **, int , struct ip_fw_args *);
 void dummynet_task(void *context, int pending);
 void dn_reschedule(void);
-int dn_fs_config(struct new_fs *);
+int dn_fs_config(struct new_fsk *);
 int delete_delay_line(struct delay_line *dline);
-int really_deletescheduler(struct new_sch *sch_t);
+int really_deletescheduler(struct new_schk *sch_t);
 
 
 #endif /* _IP_DN_PRIVATE_H */

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Sat Jan  9 23:34:45 2010	(r201957)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Sat Jan  9 23:36:15 2010	(r201958)
@@ -76,10 +76,10 @@ static struct taskqueue	*dn_tq = NULL;
 
 static struct dn_sched_head    list_of_scheduler;
 
-static int config_pipe(struct new_pipe *p);
-static int config_profile(struct new_profile *p);
-static int config_fs(struct new_fs *p);
-static int config_sched(struct new_sch *p);
+static int config_pipe(struct new_pipe *p, struct dn_id *arg);
+static int config_profile(struct new_profile *p, struct dn_id *arg);
+static int config_fs(struct new_fs *p, struct dn_id *arg);
+static int config_sched(struct new_sch *p, struct dn_id *arg);
 /*
  * This is called one tick, after previous run. It is used to
  * schedule next run.
@@ -105,14 +105,14 @@ dn_reschedule(void)
 static struct dn_sched *
 load_scheduler(int type)
 {
-    struct dn_sched *d = NULL;
+	struct dn_sched *d = NULL;
 
-    SLIST_FOREACH(d, &list_of_scheduler, next) {
-        if (d->type == type)
-            return d;
-    }
- 
-    return NULL; /* error */
+	SLIST_FOREACH(d, &list_of_scheduler, next) {
+		if (d->type == type)
+			return d;
+	}
+
+	return NULL; /* error */
 }
 
 /*
@@ -142,7 +142,7 @@ delete_delay_line(struct delay_line *dli
 static int
 delete_scheduler_instance(struct new_sch_inst *si)
 {
-    struct new_sch *sch_t = si->sched;
+    struct new_schk *sch_t = si->sched;
  
     sch_t->fp->free_sched(si + 1);
     /* XXX packets in delay line must be freed */
@@ -163,14 +163,14 @@ delete_scheduler_instance(struct new_sch
  * instances
  */
 int
-really_deletescheduler(struct new_sch *sch_t)
+really_deletescheduler(struct new_schk *s)
 {
     int i;
     struct new_sch_inst *si, *sid;
         
     /* XXX checks, maybe all scheduler instance are deleted before */
-    for (i = 0; i < sch_t->sch_i_size; i++) {
-        si = sch_t->sch_i[i];
+    for (i = 0; i < s->sch_i_size; i++) {
+        si = s->sch_i[i];
         while (si) {
             sid = si;
             si = si->next;
@@ -178,33 +178,23 @@ really_deletescheduler(struct new_sch *s
             delete_scheduler_instance(sid);
         }
     }
-    sch_t->fp->free_sched(sch_t + 1);
-    sch_t->fp->ref_count--;
-    DN_S_LOCK_DESTROY(sch_t);
-    if (sch_t->sch_i_size > 0)
-        free(sch_t->sch_i, M_DUMMYNET);
-    free(sch_t, M_DUMMYNET);
+    s->fp->free_sched(s + 1);
+    s->fp->ref_count--;
+    DN_S_LOCK_DESTROY(s);
+    if (s->sch_i_size > 0)
+        free(s->sch_i, M_DUMMYNET);
+    free(s, M_DUMMYNET);
     return 0;
 }
 
-/* remove a pipe and attached objects */
-static void
-free_pipe(struct new_pipe *p)
-{
-        if (p->profile)
-                free(p->profile, M_DUMMYNET);
-        free(p, M_DUMMYNET);
-}
-
 /*
  * Deelete all objects.
  */
 static void
 dummynet_flush(void)
 {
-	struct new_pipe *pipe, *pipe1;
-	struct new_fs *fs, *fs1;
-	struct new_sch *sch_t, *sch_t1;
+	struct new_fsk *fs, *fs1;
+	struct new_schk *sch_t, *sch_t1;
 	int i;
 
 	DUMMYNET_LOCK();
@@ -212,24 +202,16 @@ dummynet_flush(void)
     /* Clear heap so we don't have unwanted events. */
     heap_free(&dn_cfg.system_heap);
 
-    /* Free all pipes */
-    for (i = 0; i < DN_HASHSIZE; i++) {
-        SLIST_FOREACH_SAFE(pipe, &pipehash[i], next, pipe1) {
-            SLIST_REMOVE(&pipehash[i], pipe, new_pipe, next);
-            free_pipe(pipe);
-        }
-    }
-
     /* Free flowsets in the flowset unlinked list*/
-    SLIST_FOREACH_SAFE(fs, &flowsetunlinked, next, fs1) {
-            SLIST_REMOVE(&flowsetunlinked, fs, new_fs, next);
+    SLIST_FOREACH_SAFE(fs, &dn_cfg.fsunlinked, next, fs1) {
+            SLIST_REMOVE(&dn_cfg.fsunlinked, fs, new_fsk, next);
             free(fs, M_DUMMYNET);
     }
 
     /* Free all flowsets in the system */
-    for (i = 0; i < DN_HASHSIZE; i++) {
-        SLIST_FOREACH_SAFE(fs, &flowsethash[i], next, fs1) {
-            SLIST_REMOVE(&flowsethash[i], fs, new_fs, next);
+    for (i = 0; i < dn_cfg.hmask+1; i++) {
+        SLIST_FOREACH_SAFE(fs, &dn_cfg.fshash[i], next, fs1) {
+            SLIST_REMOVE(&dn_cfg.fshash[i], fs, new_fsk, next);
             fs->fp->free_fs(fs->alg_fs);
             fs->fp->ref_count--;
             free(fs->alg_fs, M_DUMMYNET);
@@ -238,9 +220,9 @@ dummynet_flush(void)
     }
 
     /* Free all schedulers */
-    for (i = 0; i < DN_HASHSIZE; i++) {
-        SLIST_FOREACH_SAFE(sch_t, &schedulerhash[i], next, sch_t1) {
-            SLIST_REMOVE(&schedulerhash[i], sch_t, new_sch, next);
+    for (i = 0; i < dn_cfg.hmask+1; i++) {
+        SLIST_FOREACH_SAFE(sch_t, &dn_cfg.schedhash[i], next, sch_t1) {
+            SLIST_REMOVE(&dn_cfg.schedhash[i], sch_t, new_schk, next);
             sch_t->flags |= DN_SCH_DELETE_DELAY_LINE;
             really_deletescheduler(sch_t);
         }
@@ -363,13 +345,22 @@ set_fs_parms(struct dn_flow_set *x, stru
 		config_red(src, x);	/* XXX should check errors */
 }
 
+/*

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***

From owner-svn-src-user@FreeBSD.ORG  Sat Jan  9 23:40: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 1DBAC106566B;
	Sat,  9 Jan 2010 23:40: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 0C7128FC08;
	Sat,  9 Jan 2010 23:40: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 o09Nejg9050803;
	Sat, 9 Jan 2010 23:40:45 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o09NejSX050800;
	Sat, 9 Jan 2010 23:40:45 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001092340.o09NejSX050800@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Sat, 9 Jan 2010 23:40:45 +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: r201961 - in user/kmacy/releng_8_fcs_buf_xen/sys/i386:
	include xen
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: Sat, 09 Jan 2010 23:40:46 -0000

Author: kmacy
Date: Sat Jan  9 23:40:45 2010
New Revision: 201961
URL: http://svn.freebsd.org/changeset/base/201961

Log:
  make QUEUE_MACRO_DEBUG work with Peter's PV chunk changes

Modified:
  user/kmacy/releng_8_fcs_buf_xen/sys/i386/include/pmap.h
  user/kmacy/releng_8_fcs_buf_xen/sys/i386/xen/pmap.c

Modified: user/kmacy/releng_8_fcs_buf_xen/sys/i386/include/pmap.h
==============================================================================
--- user/kmacy/releng_8_fcs_buf_xen/sys/i386/include/pmap.h	Sat Jan  9 23:37:29 2010	(r201960)
+++ user/kmacy/releng_8_fcs_buf_xen/sys/i386/include/pmap.h	Sat Jan  9 23:40:45 2010	(r201961)
@@ -441,14 +441,21 @@ typedef struct pv_entry {
  * pv_entries are allocated in chunks per-process.  This avoids the
  * need to track per-pmap assignments.
  */
+#ifdef QUEUE_MACRO_DEBUG
+#define	_NPCM	5
+#define	_NPCPV	144
+#define _NSPARE	((PAGE_SIZE - (4 + 24 + _NPCM*4 + _NPCPV*28))>>2)
+#else
 #define	_NPCM	11
 #define	_NPCPV	336
+#define _NSPARE 2
+#endif
 struct pv_chunk {
-	pmap_t			pc_pmap;
-	TAILQ_ENTRY(pv_chunk)	pc_list;
-	uint32_t		pc_map[_NPCM];	/* bitmap; 1 = free */
-	uint32_t		pc_spare[2];
-	struct pv_entry		pc_pventry[_NPCPV];
+	pmap_t			pc_pmap; 	/* 4 */
+	TAILQ_ENTRY(pv_chunk)	pc_list;	/* 8 | 24 */ 
+	uint32_t		pc_map[_NPCM];	/* _NPCM*4 - bitmap; 1 = free */
+	uint32_t		pc_spare[_NSPARE]; /* _NSPARE*4 */
+	struct pv_entry		pc_pventry[_NPCPV]; /* _NPCPV * 12 | 28 */
 };
 
 #ifdef	_KERNEL

Modified: user/kmacy/releng_8_fcs_buf_xen/sys/i386/xen/pmap.c
==============================================================================
--- user/kmacy/releng_8_fcs_buf_xen/sys/i386/xen/pmap.c	Sat Jan  9 23:37:29 2010	(r201960)
+++ user/kmacy/releng_8_fcs_buf_xen/sys/i386/xen/pmap.c	Sat Jan  9 23:40:45 2010	(r201961)
@@ -1339,15 +1339,16 @@ pmap_qenter_prot(vm_offset_t sva, vm_pag
 #else
 	uint32_t flags = 0;
 #endif
-
 	if (prot & VM_PROT_WRITE)
 		flags |= PG_RW;
+	if (prot & VM_PROT_READ)
+		flags |= PG_V;
 
 	CTR2(KTR_PMAP, "pmap_qenter:sva=0x%x count=%d", va, count);
 	pte = vtopte(sva);
 	endpte = pte + count;
 	while (pte < endpte) {
-		pa = xpmap_ptom(VM_PAGE_TO_PHYS(*ma)) | pgeflag | flags | PG_V | PG_M | PG_A;
+		pa = xpmap_ptom(VM_PAGE_TO_PHYS(*ma)) | pgeflag | flags;
 
 		mclp->op = __HYPERVISOR_update_va_mapping;
 		mclp->args[0] = va;
@@ -1980,16 +1981,19 @@ pmap_growkernel(vm_offset_t addr)
  ***************************************************/
 
 CTASSERT(sizeof(struct pv_chunk) == PAGE_SIZE);
-CTASSERT(_NPCM == 11);
+#ifdef QUEUE_MACRO_DEBUG
+CTASSERT(_NPCM == 5);
 
-static __inline struct pv_chunk *
-pv_to_chunk(pv_entry_t pv)
-{
+#define	PC_FREE0_3	0xfffffffful	/* Free values for index 0 through 9 */
+#define	PC_FREE5	0x0000fffful	/* Free values for index 10 */
 
-	return (struct pv_chunk *)((uintptr_t)pv & ~(uintptr_t)PAGE_MASK);
-}
+static uint32_t pc_freemask[5] = {
+	PC_FREE0_3, PC_FREE0_3, PC_FREE0_3,
+	PC_FREE0_3, PC_FREE5
+};
 
-#define PV_PMAP(pv) (pv_to_chunk(pv)->pc_pmap)
+#else
+CTASSERT(_NPCM == 11);
 
 #define	PC_FREE0_9	0xfffffffful	/* Free values for index 0 through 9 */
 #define	PC_FREE10	0x0000fffful	/* Free values for index 10 */
@@ -2001,6 +2005,18 @@ static uint32_t pc_freemask[11] = {
 	PC_FREE0_9, PC_FREE10
 };
 
+#endif
+static __inline struct pv_chunk *
+pv_to_chunk(pv_entry_t pv)
+{
+
+	return (struct pv_chunk *)((uintptr_t)pv & ~(uintptr_t)PAGE_MASK);
+}
+
+#define PV_PMAP(pv) (pv_to_chunk(pv)->pc_pmap)
+
+
+
 SYSCTL_INT(_vm_pmap, OID_AUTO, pv_entry_count, CTLFLAG_RD, &pv_entry_count, 0,
 	"Current number of pv entries");
 

From owner-svn-src-user@FreeBSD.ORG  Sat Jan  9 23:42:32 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 23AA31065679;
	Sat,  9 Jan 2010 23:42:32 +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 12DC18FC14;
	Sat,  9 Jan 2010 23:42:32 +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 o09NgV2g051233;
	Sat, 9 Jan 2010 23:42:31 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o09NgVKN051231;
	Sat, 9 Jan 2010 23:42:31 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001092342.o09NgVKN051231@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Sat, 9 Jan 2010 23:42:31 +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: r201962 - user/kmacy/releng_8_fcs_buf_xen/sys/conf
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: Sat, 09 Jan 2010 23:42:32 -0000

Author: kmacy
Date: Sat Jan  9 23:42:31 2010
New Revision: 201962
URL: http://svn.freebsd.org/changeset/base/201962

Log:
  add zfs_bio.c to static ZFS build

Modified:
  user/kmacy/releng_8_fcs_buf_xen/sys/conf/files

Modified: user/kmacy/releng_8_fcs_buf_xen/sys/conf/files
==============================================================================
--- user/kmacy/releng_8_fcs_buf_xen/sys/conf/files	Sat Jan  9 23:40:45 2010	(r201961)
+++ user/kmacy/releng_8_fcs_buf_xen/sys/conf/files	Sat Jan  9 23:42:31 2010	(r201962)
@@ -3005,6 +3005,8 @@ cddl/contrib/opensolaris/uts/common/fs/z
 	compile-with "${ZFS_C} ${OPENSOLARIS_INC} ${ZFS_INC} ${ZFS_CFLAGS}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c	optional zfs \
 	compile-with "${ZFS_C} ${OPENSOLARIS_INC} ${ZFS_INC} ${ZFS_CFLAGS}"
+cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_bio.c	optional zfs \
+	compile-with "${ZFS_C} ${OPENSOLARIS_INC} ${ZFS_INC} ${ZFS_CFLAGS}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_byteswap.c	optional zfs \
 	compile-with "${ZFS_C} ${OPENSOLARIS_INC} ${ZFS_INC} ${ZFS_CFLAGS}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_fm.c	optional zfs \

From owner-svn-src-user@FreeBSD.ORG  Sat Jan  9 23:43:22 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 9EE6E106566C;
	Sat,  9 Jan 2010 23:43:22 +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 8E2758FC14;
	Sat,  9 Jan 2010 23:43:22 +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 o09NhMVq051445;
	Sat, 9 Jan 2010 23:43:22 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o09NhMfP051443;
	Sat, 9 Jan 2010 23:43:22 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001092343.o09NhMfP051443@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Sat, 9 Jan 2010 23:43:22 +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: r201963 -
	user/kmacy/releng_8_fcs_buf_xen/sys/i386/include
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: Sat, 09 Jan 2010 23:43:22 -0000

Author: kmacy
Date: Sat Jan  9 23:43:22 2010
New Revision: 201963
URL: http://svn.freebsd.org/changeset/base/201963

Log:
  increase kstack pages to compensate for reduced optimization and witness on debug kernels

Modified:
  user/kmacy/releng_8_fcs_buf_xen/sys/i386/include/param.h

Modified: user/kmacy/releng_8_fcs_buf_xen/sys/i386/include/param.h
==============================================================================
--- user/kmacy/releng_8_fcs_buf_xen/sys/i386/include/param.h	Sat Jan  9 23:42:31 2010	(r201962)
+++ user/kmacy/releng_8_fcs_buf_xen/sys/i386/include/param.h	Sat Jan  9 23:43:22 2010	(r201963)
@@ -114,7 +114,11 @@
 #define IOPAGES	2		/* pages of i/o permission bitmap */
 
 #ifndef KSTACK_PAGES
+#if !defined(WITNESS) && !defined(DEBUG)
 #define KSTACK_PAGES 2		/* Includes pcb! */
+#else
+#define KSTACK_PAGES 3		/* Includes pcb! */
+#endif
 #endif
 #define KSTACK_GUARD_PAGES 1	/* pages of kstack guard; 0 disables */
 

From owner-svn-src-user@FreeBSD.ORG  Sat Jan  9 23:50:47 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 77E97106566C;
	Sat,  9 Jan 2010 23:50:47 +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 66F558FC19;
	Sat,  9 Jan 2010 23:50:47 +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 o09Nolr3053101;
	Sat, 9 Jan 2010 23:50:47 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o09NolPd053099;
	Sat, 9 Jan 2010 23:50:47 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201001092350.o09NolPd053099@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Sat, 9 Jan 2010 23:50:47 +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: r201964 - user/kmacy/releng_8_fcs_buf_xen/sys/kern
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: Sat, 09 Jan 2010 23:50:47 -0000

Author: kmacy
Date: Sat Jan  9 23:50:47 2010
New Revision: 201964
URL: http://svn.freebsd.org/changeset/base/201964

Log:
  repeatedly invoke lowmem handler if buffer request can't be satisfied

Modified:
  user/kmacy/releng_8_fcs_buf_xen/sys/kern/vfs_bio.c

Modified: user/kmacy/releng_8_fcs_buf_xen/sys/kern/vfs_bio.c
==============================================================================
--- user/kmacy/releng_8_fcs_buf_xen/sys/kern/vfs_bio.c	Sat Jan  9 23:43:22 2010	(r201963)
+++ user/kmacy/releng_8_fcs_buf_xen/sys/kern/vfs_bio.c	Sat Jan  9 23:50:47 2010	(r201964)
@@ -1268,6 +1268,7 @@ brelse(struct buf *bp)
 	 * background write.
 	 */
 	if ((bp->b_flags & B_VMIO)
+	    && (bp->b_vp != NULL)
 	    && !(bp->b_vp->v_mount != NULL &&
 		 (bp->b_vp->v_mount->mnt_vfc->vfc_flags & VFCF_NETWORK) != 0 &&
 		 !vn_isdisk(bp->b_vp, NULL) &&
@@ -1730,7 +1731,7 @@ getnewbuf(struct vnode *vp, int slpflag,
 	struct thread *td;
 	struct buf *bp;
 	struct buf *nbp;
-	int defrag = 0;
+	int defrag = 0, retrying = 0;
 	int nqindex;
 	static int flushingbufs;
 
@@ -1995,10 +1996,16 @@ restart:
 		if (gbflags & GB_NOWAIT_BD)
 			return (NULL);
 
+		EVENTHANDLER_INVOKE(vm_lowmem, 0);
+		if (!retrying) {
+			retrying = 1;
+			goto restart;
+		}
 		mtx_lock(&nblock);
 		while (needsbuffer & flags) {
 			if (vp != NULL && (td->td_pflags & TDP_BUFNEED) == 0) {
 				mtx_unlock(&nblock);
+				EVENTHANDLER_INVOKE(vm_lowmem, 0);
 				/*
 				 * getblk() is called with a vnode
 				 * locked, and some majority of the