Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Feb 2010 14:11:15 +0000 (UTC)
From:      Lawrence Stewart <lstewart@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r203488 - in projects/tcp_cc_head/sys: conf netinet
Message-ID:  <201002041411.o14EBFnJ038571@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: lstewart
Date: Thu Feb  4 14:11:15 2010
New Revision: 203488
URL: http://svn.freebsd.org/changeset/base/203488

Log:
  WIP snapshot of helper framework. Added a helper hooks interface modelled on
  PFIL to allow creation of more generic hooks than is capable with PFIL. Still
  need to integrate helper data blocks with the helper hooks KPI.

Added:
  projects/tcp_cc_head/sys/netinet/hhooks.c   (contents, props changed)
  projects/tcp_cc_head/sys/netinet/hhooks.h   (contents, props changed)
Modified:
  projects/tcp_cc_head/sys/conf/files
  projects/tcp_cc_head/sys/netinet/ertt.c
  projects/tcp_cc_head/sys/netinet/helper.c
  projects/tcp_cc_head/sys/netinet/helper.h
  projects/tcp_cc_head/sys/netinet/helper_module.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	Thu Feb  4 12:50:23 2010	(r203487)
+++ projects/tcp_cc_head/sys/conf/files	Thu Feb  4 14:11:15 2010	(r203488)
@@ -2436,6 +2436,7 @@ netinet/accf_data.c		optional accept_fil
 netinet/accf_dns.c		optional accept_filter_dns inet
 netinet/accf_http.c		optional accept_filter_http inet
 netinet/helper.c		optional inet
+netinet/hhooks.c		optional inet
 netinet/if_atm.c		optional atm
 netinet/if_ether.c		optional inet ether
 netinet/igmp.c			optional inet

Modified: projects/tcp_cc_head/sys/netinet/ertt.c
==============================================================================
--- projects/tcp_cc_head/sys/netinet/ertt.c	Thu Feb  4 12:50:23 2010	(r203487)
+++ projects/tcp_cc_head/sys/netinet/ertt.c	Thu Feb  4 14:11:15 2010	(r203488)
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
 
 #include <netinet/helper.h>
 #include <netinet/helper_module.h>
+#include <netinet/hhooks.h>
 #include <netinet/in.h>
 #include <netinet/in_pcb.h>
 #include <netinet/in_var.h>
@@ -55,41 +56,40 @@ struct ertt {
 	int test;
 };
 
-int ertt_tcpest_hook(void *arg, struct mbuf **m, struct ifnet *ifp, int dir,
-    struct inpcb *inp);
+void ertt_tcpest_hook(void *udata, void *ctx_data);
 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)
+void
+ertt_tcpest_hook(void *udata, void *ctx_data)
 {
-	struct ertt *e = (struct ertt *)(((struct tcpcb *)inp->inp_ppcb)->helper_data[0]);
+	//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);
+	printf("In the hook with ctx_data: %p, curack = %d\n", ctx_data,
+	((struct tcp_hhook_data *)ctx_data)->curack);
 }
 
 
 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));
+	return register_hhook(HHOOK_TYPE_TCP, HHOOK_TCP_ESTABLISHED,
+	&ertt_tcpest_hook, NULL, HHOOK_WAITOK);
 }
 
 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));
+	return deregister_hhook(HHOOK_TYPE_TCP, HHOOK_TCP_ESTABLISHED,
+	    &ertt_tcpest_hook, NULL, 0);
 }
 
 int
 ertt_block_init(uintptr_t *block)
 {
-	*block = (uintptr_t)malloc(sizeof(struct ertt), M_HLPR, M_NOWAIT);
+	*block = (uintptr_t)malloc(sizeof(struct ertt), M_HELPER, M_NOWAIT);
 
 	((struct ertt *)*block)->test = 5;
 
@@ -103,7 +103,7 @@ int
 ertt_block_destroy(uintptr_t *block)
 {
 	KASSERT(block != NULL, ("Block is NULL!"));
-	free((void *)*block, M_HLPR);
+	free((void *)*block, M_HELPER);
 
 	return (0);
 }

Modified: projects/tcp_cc_head/sys/netinet/helper.c
==============================================================================
--- projects/tcp_cc_head/sys/netinet/helper.c	Thu Feb  4 12:50:23 2010	(r203487)
+++ projects/tcp_cc_head/sys/netinet/helper.c	Thu Feb  4 14:11:15 2010	(r203488)
@@ -56,7 +56,7 @@ init_datablocks(uintptr_t **array_head, 
 		return (0);
 
 
-	*array_head = malloc(num_datablocks * sizeof(uintptr_t), M_HLPR, M_NOWAIT
+	*array_head = malloc(num_datablocks * sizeof(uintptr_t), M_HELPER, M_NOWAIT
 	| M_ZERO);
 
 	printf("Malloced ptr %p for %d data blocks\n", *array_head, num_datablocks);

Modified: projects/tcp_cc_head/sys/netinet/helper.h
==============================================================================
--- projects/tcp_cc_head/sys/netinet/helper.h	Thu Feb  4 12:50:23 2010	(r203487)
+++ projects/tcp_cc_head/sys/netinet/helper.h	Thu Feb  4 14:11:15 2010	(r203488)
@@ -30,8 +30,8 @@
  * $FreeBSD$
  */
 
-#ifndef	_TCP_HELPER_H
-#define	_TCP_HELPER_H
+#ifndef	_NETINET_HELPER_H_
+#define	_NETINET_HELPER_H_
 
 
 struct helper {
@@ -65,4 +65,4 @@ int	destroy_datablocks(uintptr_t **array
 int	register_helper(struct helper *h);
 int	deregister_helper(struct helper *h);
 
-#endif /* _TCP_HELPER_H */
+#endif /* _NETINET_HELPER_H_ */

Modified: projects/tcp_cc_head/sys/netinet/helper_module.h
==============================================================================
--- projects/tcp_cc_head/sys/netinet/helper_module.h	Thu Feb  4 12:50:23 2010	(r203487)
+++ projects/tcp_cc_head/sys/netinet/helper_module.h	Thu Feb  4 14:11:15 2010	(r203488)
@@ -44,8 +44,8 @@
 
 int	hlpr_modevent(module_t mod, int type, void *data);
 
-MALLOC_DECLARE(M_HLPR);
-MALLOC_DEFINE(M_HLPR, "helper data", "Blah");
+MALLOC_DECLARE(M_HELPER);
+MALLOC_DEFINE(M_HELPER, "helper data", "Blah");
 
 
 #endif

Added: projects/tcp_cc_head/sys/netinet/hhooks.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/tcp_cc_head/sys/netinet/hhooks.c	Thu Feb  4 14:11:15 2010	(r203488)
@@ -0,0 +1,289 @@
+/*-
+ * Copyright (c) 2010 Lawrence Stewart <lstewart@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/lock.h>
+#include <sys/malloc.h>
+#include <sys/queue.h>
+#include <sys/rmlock.h>
+#include <sys/systm.h>
+
+#include <net/vnet.h>
+
+#include <netinet/helper.h>
+#include <netinet/hhooks.h>
+
+#define	RLOCK_HHOOK_HEAD	0x01
+#define	WLOCK_HHOOK_HEAD	0x02
+
+MALLOC_DECLARE(M_HHOOK);
+MALLOC_DEFINE(M_HHOOK, "helper hook related memory", "Blah");
+
+struct hhook {
+	hhook_func_t h_func;
+	void	*h_udata;
+        STAILQ_ENTRY(hhook) h_next;
+};
+
+typedef	STAILQ_HEAD(hhook_list, hhook) hhook_list_t;
+
+struct hhook_head {
+	int	hh_type;
+	int	hh_id;
+	int	hh_nhooks;
+	hhook_list_t	hh_hooks;
+	struct rmlock	hh_lock;
+	LIST_ENTRY(hhook_head) hh_next;
+};
+
+LIST_HEAD(hhookheadhead, hhook_head);
+VNET_DEFINE(struct hhookheadhead, hhook_head_list);
+#define	V_hhook_head_list	VNET(hhook_head_list)
+
+static struct mtx hhook_head_list_lock;
+MTX_SYSINIT(hhookheadlistlock, &hhook_head_list_lock, "hhook_head list lock",
+    MTX_DEF);
+
+static struct	hhook_head *	get_hhook_head(int hhook_type, int hhook_id,
+    struct rm_priotracker* rmpt, int flags);
+
+
+/*
+ * Public KPI functions
+ */
+int
+register_hhook_head(int hhook_type, int hhook_id, int flags)
+{
+	struct hhook_head *hh;
+
+	HHOOK_HEAD_LIST_LOCK();
+	hh = get_hhook_head(hhook_type, hhook_id, NULL, 0);
+
+	if (hh != NULL)
+		return (EEXIST);
+
+	hh = malloc(sizeof(struct hhook_head), M_HHOOK,
+	    M_ZERO | ((flags & HHOOK_WAITOK) ? M_WAITOK : M_NOWAIT));
+
+	if (hh == NULL)
+		return (ENOMEM);
+
+	printf("About to register hhook_head %p with type: %d and id: %d\n", hh,
+	hhook_type, hhook_id);
+
+	hh->hh_type = hhook_type;
+	hh->hh_id = hhook_id;
+	hh->hh_nhooks = 0;
+	STAILQ_INIT(&hh->hh_hooks);
+	HHOOK_HEAD_LOCK_INIT(hh);
+
+	LIST_INSERT_HEAD(&V_hhook_head_list, hh, hh_next);
+	HHOOK_HEAD_LIST_UNLOCK();
+	return (0);
+}
+
+int
+deregister_hhook_head(int hhook_type, int hhook_id)
+{
+	struct hhook_head *hh;
+	struct hhook *tmp, *tmp2;
+	int error = 0;
+
+	HHOOK_HEAD_LIST_LOCK();
+	hh = get_hhook_head(hhook_type, hhook_id, NULL, WLOCK_HHOOK_HEAD);
+
+	if (hh == NULL)
+		error = ENOENT;
+	else {
+		LIST_REMOVE(hh, hh_next);
+
+		STAILQ_FOREACH_SAFE(tmp, &hh->hh_hooks, h_next, tmp2) {
+			free(tmp, M_HHOOK);
+		}
+
+		HHOOK_HEAD_WUNLOCK(hh);
+		HHOOK_HEAD_LOCK_DESTROY(hh);
+		free(hh, M_HHOOK);
+	}
+
+	HHOOK_HEAD_LIST_UNLOCK();
+
+	/*
+	TAILQ_FOREACH_SAFE(pfh, &ph->ph_in, pfil_link, pfnext)
+		free(pfh, M_IFADDR);
+	TAILQ_FOREACH_SAFE(pfh, &ph->ph_out, pfil_link, pfnext)
+		free(pfh, M_IFADDR);
+	*/
+
+	return (error);
+}
+
+int
+register_hhook(int hhook_type, int hhook_id, hhook_func_t hook, void *udata,
+    int flags)
+{
+	struct hhook *h, *tmp;
+	struct hhook_head *hh;
+	int error = 0;
+
+	h = malloc(sizeof(struct hhook), M_HHOOK, (flags & HHOOK_WAITOK) ?
+	    M_WAITOK : M_NOWAIT);
+
+	if (h == NULL)
+		return (ENOMEM);
+
+	h->h_func = hook;
+	h->h_udata = udata;
+
+	hh = get_hhook_head(hhook_type, hhook_id, NULL, WLOCK_HHOOK_HEAD);
+
+	if (hh == NULL) {
+		free(h, M_HHOOK);
+		return (ENOENT);
+	}
+
+	STAILQ_FOREACH(tmp, &hh->hh_hooks, h_next) {
+		if (tmp->h_func == hook && tmp->h_udata == udata) {
+			error = EEXIST;
+			break;
+		}
+	}
+
+	if (!error) {
+		STAILQ_INSERT_HEAD(&hh->hh_hooks, h, h_next);
+		hh->hh_nhooks++;
+	}
+	else
+		free(h, M_HHOOK);
+
+	HHOOK_HEAD_WUNLOCK(hh);
+
+	return (error);
+}
+
+int
+deregister_hhook(int hhook_type, int hhook_id, hhook_func_t hook, void *udata,
+    int flags)
+{
+	struct hhook *tmp;
+	struct hhook_head *hh;
+
+	hh = get_hhook_head(hhook_type, hhook_id, NULL, WLOCK_HHOOK_HEAD);
+
+	if (hh == NULL)
+		return (ENOENT);
+
+	STAILQ_FOREACH(tmp, &hh->hh_hooks, h_next) {
+		if (tmp->h_func == hook && tmp->h_udata == udata) {
+			STAILQ_REMOVE(&hh->hh_hooks, tmp, hhook, h_next);
+			free(tmp, M_HHOOK);
+			hh->hh_nhooks--;
+			break;
+		}
+	}
+
+	HHOOK_HEAD_WUNLOCK(hh);
+	return (0);
+}
+
+void
+run_hhooks(int hhook_type, int hhook_id, void *ctx_data)
+{
+	struct hhook_head *hh;
+	struct hhook *tmp;
+	struct rm_priotracker rmpt;
+
+	hh = get_hhook_head(hhook_type, hhook_id, &rmpt, RLOCK_HHOOK_HEAD);
+
+	if (hh == NULL)
+		return;
+
+	STAILQ_FOREACH(tmp, &hh->hh_hooks, h_next)
+		tmp->h_func(tmp->h_udata, ctx_data);
+
+	HHOOK_HEAD_RUNLOCK(hh, &rmpt);
+}
+
+
+/*
+ * Private KPI functions
+ */
+static struct hhook_head *
+get_hhook_head(int hhook_type, int hhook_id, struct rm_priotracker *rmpt,
+    int flags)
+{
+	struct hhook_head *tmp, *ret = NULL;
+
+	/*KASSERT(HHOOK_HEAD_LIST_LOCK_ASSERT(), ("hhook_head_list_lock not
+	 * locked"));*/
+
+	LIST_FOREACH(tmp, &V_hhook_head_list, hh_next) {
+		if (tmp->hh_type == hhook_type && tmp->hh_id == hhook_id) {
+			ret = tmp;
+			if (flags & RLOCK_HHOOK_HEAD)
+				HHOOK_HEAD_RLOCK(ret, rmpt);
+			else if (flags & WLOCK_HHOOK_HEAD)
+				HHOOK_HEAD_WLOCK(ret);
+			break;
+		}
+	}
+
+	return (ret);
+}
+
+static int
+vnet_hhook_init(const void *unused)
+{
+
+	LIST_INIT(&V_hhook_head_list);
+	return (0);
+}
+
+static int
+vnet_hhook_uninit(const void *unused)
+{
+
+	return (0);
+}
+
+#define	HHOOK_SYSINIT_ORDER	SI_SUB_PROTO_BEGIN
+#define	HHOOK_MODEVENT_ORDER	(SI_ORDER_FIRST) 
+#define	HHOOK_VNET_ORDER	(HHOOK_MODEVENT_ORDER + 2) 
+
+VNET_SYSINIT(vnet_hhook_init, HHOOK_SYSINIT_ORDER, HHOOK_VNET_ORDER,
+    vnet_hhook_init, NULL);
+ 
+VNET_SYSUNINIT(vnet_hhook_uninit, HHOOK_SYSINIT_ORDER, HHOOK_VNET_ORDER,
+    vnet_hhook_uninit, NULL);
+

Added: projects/tcp_cc_head/sys/netinet/hhooks.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/tcp_cc_head/sys/netinet/hhooks.h	Thu Feb  4 14:11:15 2010	(r203488)
@@ -0,0 +1,68 @@
+/*-
+ * Copyright (c) 2010 Lawrence Stewart <lstewart@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_HHOOKS_H_
+#define _NETINET_HHOOKS_H_
+
+#define	HHOOK_WAITOK	0x01
+#define	HHOOK_NOWAIT	0x02
+
+#define	HHOOK_TYPE_TCP		1
+
+typedef void (*hhook_func_t)(void *udata, void *ctx_data);
+
+struct hhook_head;
+
+int	register_hhook_head(int hhook_type, int hhook_id, int flags);
+int	deregister_hhook_head(int hhook_type, int hhook_id);
+int	register_hhook(int hhook_type, int hhook_id, hhook_func_t hook,
+    void *udata, int flags);
+int	deregister_hhook(int hhook_type, int hhook_id, hhook_func_t hook,
+    void *udata, int flags);
+void	run_hhooks(int hhook_type, int hhook_id, void *ctx_data);
+
+
+#define	HHOOKED(hh) ((hh)->hh_nhooks > 0)
+
+#define	HHOOK_HEAD_LIST_LOCK() mtx_lock(&hhook_head_list_lock)
+#define	HHOOK_HEAD_LIST_UNLOCK() mtx_unlock(&hhook_head_list_lock)
+#define	HHOOK_HEAD_LIST_LOCK_ASSERT() mtx_assert(&hhook_head_list_lock, MA_OWNED)
+
+#define	HHOOK_HEAD_LOCK_INIT(hh) rm_init(&(hh)->hh_lock, "hhook_head rm lock")
+#define	HHOOK_HEAD_LOCK_DESTROY(hh) rm_destroy(&(hh)->hh_lock)
+#define	HHOOK_HEAD_WLOCK(hh) rm_wlock(&(hh)->hh_lock)
+#define	HHOOK_HEAD_WUNLOCK(hh) rm_wunlock(&(hh)->hh_lock)
+#define	HHOOK_HEAD_RLOCK(hh,rmpt) rm_rlock(&(hh)->hh_lock, (rmpt))
+#define	HHOOK_HEAD_RUNLOCK(hh,rmpt) rm_runlock(&(hh)->hh_lock, (rmpt))
+
+#endif /* _NETINET_HHOOKS_H_ */
+

Modified: projects/tcp_cc_head/sys/netinet/tcp_input.c
==============================================================================
--- projects/tcp_cc_head/sys/netinet/tcp_input.c	Thu Feb  4 12:50:23 2010	(r203487)
+++ projects/tcp_cc_head/sys/netinet/tcp_input.c	Thu Feb  4 14:11:15 2010	(r203488)
@@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$");
 #define TCPSTATES		/* for logging */
 
 #include <netinet/cc.h>
+#include <netinet/hhooks.h>
 #include <netinet/in.h>
 #include <netinet/in_pcb.h>
 #include <netinet/in_systm.h>
@@ -1174,7 +1175,7 @@ tcp_do_segment(struct mbuf *m, struct tc
 	int rstreason, todrop, win;
 	u_long tiwin;
 	struct tcpopt to;
-
+	struct tcp_hhook_data hhook_data;
 #ifdef TCPDEBUG
 	/*
 	 * The size of tcp_saveipgen must be the size of the max ip header,
@@ -2123,9 +2124,8 @@ tcp_do_segment(struct mbuf *m, struct tc
 		     !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);
+		hhook_data.curack = th->th_ack;
+		run_hhooks(HHOOK_TYPE_TCP, HHOOK_TCP_ESTABLISHED, &hhook_data);
 
 		if (SEQ_LEQ(th->th_ack, tp->snd_una)) {
 			if (tlen == 0 && tiwin == tp->snd_wnd) {

Modified: projects/tcp_cc_head/sys/netinet/tcp_subr.c
==============================================================================
--- projects/tcp_cc_head/sys/netinet/tcp_subr.c	Thu Feb  4 12:50:23 2010	(r203487)
+++ projects/tcp_cc_head/sys/netinet/tcp_subr.c	Thu Feb  4 14:11:15 2010	(r203488)
@@ -62,11 +62,11 @@ __FBSDID("$FreeBSD$");
 
 #include <net/route.h>
 #include <net/if.h>
-#include <net/pfil.h>
 #include <net/vnet.h>
 
 #include <netinet/cc.h>
 #include <netinet/helper.h>
+#include <netinet/hhooks.h>
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
 #include <netinet/ip.h>
@@ -121,7 +121,6 @@ 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);
@@ -379,11 +378,9 @@ 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__);
+	if (register_hhook_head(HHOOK_TYPE_TCP, HHOOK_TCP_ESTABLISHED,
+	    HHOOK_NOWAIT) != 0)
+		printf("%s: WARNING: unable to register helper hook\n", __func__);
 
 	cc_init();
 

Modified: projects/tcp_cc_head/sys/netinet/tcp_var.h
==============================================================================
--- projects/tcp_cc_head/sys/netinet/tcp_var.h	Thu Feb  4 12:50:23 2010	(r203487)
+++ projects/tcp_cc_head/sys/netinet/tcp_var.h	Thu Feb  4 14:11:15 2010	(r203488)
@@ -44,11 +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);
+VNET_DECLARE(struct hhook_head, tcpest_hhook);
 #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)
+#define	V_tcpest_hhook		VNET(tcpest_hhook)
 
 #endif /* _KERNEL */
 
@@ -247,10 +247,13 @@ struct tcpcb {
 #define BYTES_ACKED(tp, th)	(th->th_ack - tp->snd_una)
 
 /*
- * TCP specific PFIL hook point identifiers
+ * TCP specific helper hook point identifiers
  */
-#define	PFIL_TCP_ALL		0
-#define	PFIL_TCP_ESTABLISHED	1
+#define	HHOOK_TCP_ESTABLISHED	1
+
+struct tcp_hhook_data {
+	tcp_seq		curack;
+};
 
 /*
  * Flags for the t_oobflags field.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201002041411.o14EBFnJ038571>