svn commit: r203416 - in projects/tcp_cc_head/sys: conf modules/ertt net netinet

Lawrence Stewart lstewart at FreeBSD.org
Wed Feb 3 04:58:09 UTC 2010


Author: lstewart
Date: Wed Feb  3 04:58:08 2010
New Revision: 203416
URL: http://svn.freebsd.org/changeset/base/203416

Log:
  Extremely rough proof of concept work to create a framework for allowing
  arbitrary helper functions to do "things" e.g. calculate a better RTT estimate
  (ertt = enhanced rtt) and store their data per TCP connection. Current approach
  using pfil is unsatisfactory, but wanted to commit it for posterity's sake.

Added:
  projects/tcp_cc_head/sys/modules/ertt/
  projects/tcp_cc_head/sys/modules/ertt/Makefile   (contents, props changed)
  projects/tcp_cc_head/sys/netinet/ertt.c   (contents, props changed)
  projects/tcp_cc_head/sys/netinet/tcp_helper.c   (contents, props changed)
  projects/tcp_cc_head/sys/netinet/tcp_helper.h   (contents, props changed)
  projects/tcp_cc_head/sys/netinet/tcp_helper_module.h   (contents, props changed)
Modified:
  projects/tcp_cc_head/sys/conf/files
  projects/tcp_cc_head/sys/net/pfil.h
  projects/tcp_cc_head/sys/netinet/tcp_input.c
  projects/tcp_cc_head/sys/netinet/tcp_subr.c
  projects/tcp_cc_head/sys/netinet/tcp_var.h

Modified: projects/tcp_cc_head/sys/conf/files
==============================================================================
--- projects/tcp_cc_head/sys/conf/files	Wed Feb  3 04:09:36 2010	(r203415)
+++ projects/tcp_cc_head/sys/conf/files	Wed Feb  3 04:58:08 2010	(r203416)
@@ -2485,6 +2485,7 @@ netinet/sctp_timer.c		optional inet sctp
 netinet/sctp_usrreq.c		optional inet sctp
 netinet/sctputil.c		optional inet sctp
 netinet/tcp_debug.c		optional tcpdebug
+netinet/tcp_helper.c		optional inet
 netinet/tcp_hostcache.c		optional inet
 netinet/tcp_input.c		optional inet
 netinet/tcp_lro.c		optional inet

Added: projects/tcp_cc_head/sys/modules/ertt/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/tcp_cc_head/sys/modules/ertt/Makefile	Wed Feb  3 04:58:08 2010	(r203416)
@@ -0,0 +1,10 @@
+# $FreeBSD$
+
+.include <bsd.own.mk>
+
+.PATH:  ${.CURDIR}/../../netinet
+KMOD=hlpr_ertt
+SRCS=ertt.c
+
+.include <bsd.kmod.mk> 
+

Modified: projects/tcp_cc_head/sys/net/pfil.h
==============================================================================
--- projects/tcp_cc_head/sys/net/pfil.h	Wed Feb  3 04:09:36 2010	(r203415)
+++ projects/tcp_cc_head/sys/net/pfil.h	Wed Feb  3 04:58:08 2010	(r203416)
@@ -63,6 +63,7 @@ typedef	TAILQ_HEAD(pfil_list, packet_fil
 
 #define	PFIL_TYPE_AF		1	/* key is AF_* type */
 #define	PFIL_TYPE_IFNET		2	/* key is ifnet pointer */
+#define	PFIL_TYPE_TCP		3	/* see PFIL_TCP_* in netinet/tcp.h */
 
 struct pfil_head {
 	pfil_list_t	ph_in;

Added: projects/tcp_cc_head/sys/netinet/ertt.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/tcp_cc_head/sys/netinet/ertt.c	Wed Feb  3 04:58:08 2010	(r203416)
@@ -0,0 +1,119 @@
+/*-
+ * Copyright (c) 2009-2010
+ * 	Swinburne University of Technology, Melbourne, Australia
+ * Copyright (c) 2010 Lawrence Stewart <lstewart at freebsd.org>
+ * All rights reserved.
+ *
+ * This software was developed at the Centre for Advanced Internet
+ * Architectures, Swinburne University, by David Hayes and Lawrence Stewart,
+ * made possible in part by a grant from the FreeBSD Foundation and
+ * Cisco University Research Program Fund at Community Foundation
+ * Silicon Valley.
+ *
+ * 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 <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/mbuf.h>
+#include <sys/module.h>
+#include <sys/socket.h>
+
+#include <net/if.h>
+#include <net/pfil.h>
+
+#include <netinet/in.h>
+#include <netinet/in_pcb.h>
+#include <netinet/in_var.h>
+#include <netinet/tcp_var.h>
+#include <netinet/tcp_helper.h>
+#include <netinet/tcp_helper_module.h>
+
+struct ertt {
+	int test;
+};
+
+int ertt_tcpest_hook(void *arg, struct mbuf **m, struct ifnet *ifp, int dir,
+    struct inpcb *inp);
+int ertt_mod_init(void);
+int ertt_mod_destroy(void);
+int ertt_block_init(uintptr_t *block);
+int ertt_block_destroy(uintptr_t *block);
+
+int
+ertt_tcpest_hook(void *arg, struct mbuf **m, struct ifnet *ifp, int dir, struct inpcb *inp)
+{
+	struct ertt *e = (struct ertt *)(((struct tcpcb *)inp->inp_ppcb)->helper_data[0]);
+	//struct ertt *e = (struct ertt *)arg;
+	printf("In the hook with pkt: 0x%p, ertt->test = %d\n", *m, e->test++);
+	return (0);
+}
+
+
+int
+ertt_mod_init(void)
+{
+	return pfil_add_hook(&ertt_tcpest_hook, NULL, PFIL_IN | PFIL_WAITOK,
+	    pfil_head_get(PFIL_TYPE_TCP, PFIL_TCP_ESTABLISHED));
+}
+
+int
+ertt_mod_destroy(void)
+{
+	return pfil_remove_hook(&ertt_tcpest_hook, NULL, PFIL_IN | PFIL_WAITOK,
+	    pfil_head_get(PFIL_TYPE_TCP, PFIL_TCP_ESTABLISHED));
+}
+
+int
+ertt_block_init(uintptr_t *block)
+{
+	*block = (uintptr_t)malloc(sizeof(struct ertt), M_HLPR, M_NOWAIT);
+
+	((struct ertt *)*block)->test = 5;
+
+	printf("Malloced %ld bytes for ertt and set the value to %d\n",
+	sizeof(struct ertt), ((struct ertt *)*block)->test);
+
+	return (0);
+}
+
+int
+ertt_block_destroy(uintptr_t *block)
+{
+	KASSERT(block != NULL, ("Block is NULL!"));
+	free((void *)*block, M_HLPR);
+
+	return (0);
+}
+
+struct helper ertt_helper = {
+	.mod_init = ertt_mod_init,
+	.mod_destroy = ertt_mod_destroy,
+	.block_init = ertt_block_init,
+	.block_destroy = ertt_block_destroy,
+	.flags = HLPR_NEEDS_DATABLOCK
+};
+
+DECLARE_HELPER(ertt, &ertt_helper);

Added: projects/tcp_cc_head/sys/netinet/tcp_helper.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/tcp_cc_head/sys/netinet/tcp_helper.c	Wed Feb  3 04:58:08 2010	(r203416)
@@ -0,0 +1,161 @@
+/*-
+ * Copyright (c) 2010 Lawrence Stewart <lstewart at freebsd.org>
+ * All rights reserved.
+ *
+ * This software was developed at the Centre for Advanced Internet
+ * Architectures, Swinburne University, by Lawrence Stewart,
+ * made possible in part by a grant from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/module.h>
+#include <sys/queue.h>
+#include <sys/systm.h>
+
+#include <netinet/tcp_helper.h>
+#include <netinet/tcp_helper_module.h>
+
+
+struct hlpr_head helpers = STAILQ_HEAD_INITIALIZER(helpers);
+static int num_datablocks = 0;
+
+
+int
+init_datablocks(uintptr_t **array_head, int *nblocks)
+{
+	struct helper *h;
+	int i = 0;
+
+	if(num_datablocks <= 0)
+		return (0);
+
+
+	*array_head = malloc(num_datablocks * sizeof(uintptr_t), M_HLPR, M_NOWAIT
+	| M_ZERO);
+
+	printf("Malloced ptr %p for %d data blocks\n", *array_head, num_datablocks);
+	STAILQ_FOREACH(h, &helpers, entries) {
+		KASSERT(i < num_datablocks, ("Badness!\n"));
+		if (h->block_init != NULL) {
+			printf("Calling block_init(%p) for helper: %p\n",
+			(*array_head)+i, h);
+			h->block_init((*array_head)+i);
+		}
+		i++;
+	}
+
+	*nblocks = num_datablocks;
+
+	return (0);
+}
+
+int
+destroy_datablocks(uintptr_t **array_head, int nblocks)
+{
+	struct helper *h;
+	int i = 0;
+	//for (; nblocks >= 0; nblocks--)
+	//	h->block_destroy();
+
+	STAILQ_FOREACH(h, &helpers, entries) {
+		if (h->block_destroy != NULL) {
+			printf("Calling block_destroy(%p) for helper: %p\n",
+			array_head[i], h);
+			h->block_destroy(array_head[i++]);
+		}
+	}
+
+	return (0);
+}
+
+int
+register_helper(struct helper *h)
+{
+	/*for hooks in hlpr
+		register hlpr_callback for hook
+
+	if !errorgt
+		h->dynamic_id = X
+	*/
+	printf("Register helper 0x%p\n", h);
+
+	if (h->flags | HLPR_NEEDS_DATABLOCK)
+		num_datablocks++;
+
+	STAILQ_INSERT_TAIL(&helpers, h, entries);
+
+	return (0);
+}
+
+int
+deregister_helper(struct helper *h)
+{
+	printf("Deregister helper 0x%p\n", h);
+
+	STAILQ_REMOVE(&helpers, h, helper, entries);
+	num_datablocks--;
+	return (0);
+}
+
+
+
+/*
+ * Handles kld related events. Returns 0 on success, non-zero on failure.
+ */
+int
+hlpr_modevent(module_t mod, int event_type, void *data)
+{
+	int error = 0;
+	struct helper *h = (struct helper *)data;
+
+	switch(event_type) {
+		case MOD_LOAD:
+			if (h->mod_init != NULL)
+				error = h->mod_init();
+			if (!error)
+				error = register_helper(h);
+			break;
+
+		case MOD_QUIESCE:
+			error = deregister_helper(h);
+			if (!error && h->mod_destroy != NULL)
+				h->mod_destroy();
+			break;
+
+		case MOD_SHUTDOWN:
+		case MOD_UNLOAD:
+			break;
+
+		default:
+			return EINVAL;
+			break;
+	}
+
+	return (error);
+}

Added: projects/tcp_cc_head/sys/netinet/tcp_helper.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/tcp_cc_head/sys/netinet/tcp_helper.h	Wed Feb  3 04:58:08 2010	(r203416)
@@ -0,0 +1,68 @@
+/*-
+ * Copyright (c) 2010 Lawrence Stewart <lstewart at freebsd.org>
+ * All rights reserved.
+ *
+ * This software was developed at the Centre for Advanced Internet
+ * Architectures, Swinburne University, by Lawrence Stewart,
+ * made possible in part by a grant from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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	_TCP_HELPER_H
+#define	_TCP_HELPER_H
+
+
+struct helper {
+	/* Init global module state on kldload. */
+	int (*mod_init) (void);
+
+	/* Cleanup global module state on kldunload. */
+	int (*mod_destroy) (void);
+
+	int (*block_init) (uintptr_t *data);
+	int (*block_destroy) (uintptr_t *data);
+
+	uint16_t	flags;
+
+	//STAILQ hooks; /* which hooks does this helper want to be called from */
+	//STAILQ struct helper_data;
+	int dynamic_id; /* ID assigned by system to this hlpr's data in the
+	dynamic array */
+
+
+	STAILQ_ENTRY(helper) entries;
+};
+
+/* Helper flags */
+#define HLPR_NEEDS_DATABLOCK	0x0001
+
+extern	STAILQ_HEAD(hlpr_head, helper) helpers;
+
+int	init_datablocks(uintptr_t **array_head, int *nblocks);
+int	destroy_datablocks(uintptr_t **array_head, int nblocks);
+int	register_helper(struct helper *h);
+int	deregister_helper(struct helper *h);
+
+#endif /* _TCP_HELPER_H */

Added: projects/tcp_cc_head/sys/netinet/tcp_helper_module.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/tcp_cc_head/sys/netinet/tcp_helper_module.h	Wed Feb  3 04:58:08 2010	(r203416)
@@ -0,0 +1,51 @@
+/*-
+ * Copyright (c) 2010 Lawrence Stewart <lstewart at freebsd.org>
+ * All rights reserved.
+ *
+ * This software was developed at the Centre for Advanced Internet
+ * Architectures, Swinburne University, by Lawrence Stewart,
+ * made possible in part by a grant from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 _NETINET_TCP_HELPER_MODULE_H_
+#define _NETINET_TCP_HELPER_MODULE_H_
+
+#define	DECLARE_HELPER(hlprname, hlpr_data) 				\
+	static moduledata_t hlpr_##hlprname = {				\
+		#hlprname,						\
+		hlpr_modevent,						\
+		hlpr_data						\
+	};								\
+	DECLARE_MODULE(hlprname, hlpr_##hlprname, SI_SUB_PROTO_IFATTACHDOMAIN, \
+	    SI_ORDER_ANY)
+
+int	hlpr_modevent(module_t mod, int type, void *data);
+
+MALLOC_DECLARE(M_HLPR);
+MALLOC_DEFINE(M_HLPR, "helper data", "Blah");
+
+
+#endif

Modified: projects/tcp_cc_head/sys/netinet/tcp_input.c
==============================================================================
--- projects/tcp_cc_head/sys/netinet/tcp_input.c	Wed Feb  3 04:09:36 2010	(r203415)
+++ projects/tcp_cc_head/sys/netinet/tcp_input.c	Wed Feb  3 04:58:08 2010	(r203416)
@@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$");
 #include <vm/uma.h>
 
 #include <net/if.h>
+#include <net/pfil.h>
 #include <net/route.h>
 #include <net/vnet.h>
 
@@ -2121,6 +2122,11 @@ tcp_do_segment(struct mbuf *m, struct tc
 		    ((to.to_flags & TOF_SACK) ||
 		     !TAILQ_EMPTY(&tp->snd_holes)))
 			tcp_sack_doack(tp, &to, th->th_ack);
+
+		if (tp->nhelpers > 0 && PFIL_HOOKED(&V_tcpest_pfil_hook))
+			pfil_run_hooks(&V_tcpest_pfil_hook, &m, NULL, PFIL_IN,
+			    tp->t_inpcb);
+
 		if (SEQ_LEQ(th->th_ack, tp->snd_una)) {
 			if (tlen == 0 && tiwin == tp->snd_wnd) {
 				TCPSTAT_INC(tcps_rcvdupack);

Modified: projects/tcp_cc_head/sys/netinet/tcp_subr.c
==============================================================================
--- projects/tcp_cc_head/sys/netinet/tcp_subr.c	Wed Feb  3 04:09:36 2010	(r203415)
+++ projects/tcp_cc_head/sys/netinet/tcp_subr.c	Wed Feb  3 04:58:08 2010	(r203416)
@@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$");
 
 #include <net/route.h>
 #include <net/if.h>
+#include <net/pfil.h>
 #include <net/vnet.h>
 
 #include <netinet/cc.h>
@@ -84,6 +85,7 @@ __FBSDID("$FreeBSD$");
 #endif
 #include <netinet/ip_icmp.h>
 #include <netinet/tcp_fsm.h>
+#include <netinet/tcp_helper.h>
 #include <netinet/tcp_seq.h>
 #include <netinet/tcp_timer.h>
 #include <netinet/tcp_var.h>
@@ -119,6 +121,7 @@ VNET_DEFINE(int, tcp_v6mssdflt);
 #endif
 VNET_DEFINE(int, tcp_minmss);
 VNET_DEFINE(int, tcp_do_rfc1323);
+VNET_DEFINE(struct pfil_head, tcpest_pfil_hook);
 
 static VNET_DEFINE(int, icmp_may_rst);
 static VNET_DEFINE(int, tcp_isn_reseed_interval);
@@ -376,6 +379,12 @@ tcp_init(void)
 
 	V_tcp_inflight_rttthresh = TCPTV_INFLIGHT_RTTTHRESH;
 
+	V_tcpest_pfil_hook.ph_type = PFIL_TYPE_TCP;
+	V_tcpest_pfil_hook.ph_af = PFIL_TCP_ESTABLISHED;
+
+	if(pfil_head_register(&V_tcpest_pfil_hook) != 0)
+		printf("%s: WARNING: unable to register pfil hook\n", __func__);
+
 	cc_init();
 
 	TUNABLE_INT_FETCH("net.inet.tcp.sack.enable", &V_tcp_do_sack);
@@ -768,6 +777,11 @@ tcp_newtcpcb(struct inpcb *inp)
 			return NULL;
 		}
 
+	KASSERT(tp->helper_data == NULL, ("tp->hlpr_data NOT NULL!"));
+	init_datablocks(&tp->helper_data, &tp->nhelpers);
+	printf("tp->helper_data = %p, tp->nhelpers = %d\n", tp->helper_data,
+	tp->nhelpers);
+
 #ifdef VIMAGE
 	tp->t_vnet = inp->inp_vnet;
 #endif
@@ -937,6 +951,8 @@ tcp_discardcb(struct tcpcb *tp)
 	if (CC_ALGO(tp)->cb_destroy != NULL)
 		CC_ALGO(tp)->cb_destroy(tp);
 
+	destroy_datablocks(&tp->helper_data, tp->nhelpers);
+
 	CC_ALGO(tp) = NULL;
 	inp->inp_ppcb = NULL;
 	tp->t_inpcb = NULL;

Modified: projects/tcp_cc_head/sys/netinet/tcp_var.h
==============================================================================
--- projects/tcp_cc_head/sys/netinet/tcp_var.h	Wed Feb  3 04:09:36 2010	(r203415)
+++ projects/tcp_cc_head/sys/netinet/tcp_var.h	Wed Feb  3 04:58:08 2010	(r203416)
@@ -44,9 +44,11 @@
 VNET_DECLARE(int, tcp_do_rfc1323);
 VNET_DECLARE(int, tcp_reass_qsize);
 VNET_DECLARE(struct uma_zone *, tcp_reass_zone);
+VNET_DECLARE(struct pfil_head, tcpest_pfil_hook);
 #define	V_tcp_do_rfc1323	VNET(tcp_do_rfc1323)
 #define	V_tcp_reass_qsize	VNET(tcp_reass_qsize)
 #define	V_tcp_reass_zone	VNET(tcp_reass_zone)
+#define	V_tcpest_pfil_hook	VNET(tcpest_pfil_hook)
 
 #endif /* _KERNEL */
 
@@ -204,6 +206,8 @@ struct tcpcb {
 	uint64_t _pad[12];		/* 7 UTO, 5 TBD (1-2 CC/RTT?) */
 	struct cc_algo	*cc_algo;	/* the algorithm that will manage congestion control*/
 	void	*cc_data;		/* pointer to a struct containing data required for the cc algorithm in use */
+	uintptr_t	*helper_data;		/* */
+	int		nhelpers;
 };
 
 /*
@@ -243,6 +247,12 @@ struct tcpcb {
 #define BYTES_ACKED(tp, th)	(th->th_ack - tp->snd_una)
 
 /*
+ * TCP specific PFIL hook point identifiers
+ */
+#define	PFIL_TCP_ALL		0
+#define	PFIL_TCP_ESTABLISHED	1
+
+/*
  * Flags for the t_oobflags field.
  */
 #define	TCPOOB_HAVEDATA	0x01


More information about the svn-src-projects mailing list