From owner-p4-projects@FreeBSD.ORG Tue Oct 16 11:48:52 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5290E16A475; Tue, 16 Oct 2007 11:48:52 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EF40916A468 for ; Tue, 16 Oct 2007 11:48:51 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 07B1313C4A6 for ; Tue, 16 Oct 2007 11:48:52 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l9GBmpxc015903 for ; Tue, 16 Oct 2007 11:48:51 GMT (envelope-from zec@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l9GBmp6l015898 for perforce@freebsd.org; Tue, 16 Oct 2007 11:48:51 GMT (envelope-from zec@FreeBSD.org) Date: Tue, 16 Oct 2007 11:48:51 GMT Message-Id: <200710161148.l9GBmp6l015898@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to zec@FreeBSD.org using -f From: Marko Zec To: Perforce Change Reviews Cc: Subject: PERFORCE change 127598 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Oct 2007 11:48:52 -0000 http://perforce.freebsd.org/chv.cgi?CH=127598 Change 127598 by zec@zec_tpx32 on 2007/10/16 11:48:38 Introduce hooks for cleaning up TCP/UDP state. The hooks are largely disfunctional and have yet to be populated with useful code. Affected files ... .. //depot/projects/vimage/src/sys/netinet/in_proto.c#9 edit .. //depot/projects/vimage/src/sys/netinet/tcp_subr.c#34 edit .. //depot/projects/vimage/src/sys/netinet/tcp_syncache.c#20 edit .. //depot/projects/vimage/src/sys/netinet/tcp_syncache.h#7 edit .. //depot/projects/vimage/src/sys/netinet/tcp_timewait.c#10 edit .. //depot/projects/vimage/src/sys/netinet/tcp_var.h#18 edit .. //depot/projects/vimage/src/sys/netinet/udp_usrreq.c#19 edit .. //depot/projects/vimage/src/sys/netinet/udp_var.h#6 edit Differences ... ==== //depot/projects/vimage/src/sys/netinet/in_proto.c#9 (text+ko) ==== @@ -119,6 +119,9 @@ .pr_ctlinput = udp_ctlinput, .pr_ctloutput = ip_ctloutput, .pr_init = udp_init, +#ifdef VIMAGE + .pr_destroy = udp_destroy, +#endif .pr_usrreqs = &udp_usrreqs }, { @@ -130,7 +133,9 @@ .pr_ctlinput = tcp_ctlinput, .pr_ctloutput = tcp_ctloutput, .pr_init = tcp_init, +#ifdef VIMAGE .pr_destroy = tcp_destroy, +#endif .pr_slowtimo = tcp_slowtimo, .pr_drain = tcp_drain, .pr_usrreqs = &tcp_usrreqs ==== //depot/projects/vimage/src/sys/netinet/tcp_subr.c#34 (text+ko) ==== @@ -290,6 +290,7 @@ #ifdef VIMAGE } #endif + tcp_tw_init(); int hashsize = TCBHASHSIZE; @@ -385,11 +386,24 @@ EVENTHANDLER_PRI_ANY); } +#ifdef VIMAGE void tcp_destroy(void) { + INIT_VNET_INET(curvnet); + + tcp_tw_destroy(); tcp_hc_destroy(); + syncache_destroy(); + + /* XXX check that hashes are empty! */ + hashdestroy(V_tcbinfo.ipi_hashbase, M_PCB, + V_tcbinfo.ipi_hashmask); + hashdestroy(V_tcbinfo.ipi_porthashbase, M_PCB, + V_tcbinfo.ipi_porthashmask); + INP_INFO_LOCK_DESTROY(&V_tcbinfo); } +#endif void tcp_fini(void *xtp) ==== //depot/projects/vimage/src/sys/netinet/tcp_syncache.c#20 (text+ko) ==== @@ -265,6 +265,19 @@ uma_zone_set_max(V_tcp_syncache.zone, V_tcp_syncache.cache_limit); } +#ifdef VIMAGE +void +syncache_destroy(void) +{ + INIT_VNET_INET(curvnet); + + /* XXX walk the cache, free remaining objects, stop timers */ + + uma_zdestroy(V_tcp_syncache.zone); + FREE(V_tcp_syncache.hashbase, M_SYNCACHE); +} +#endif + /* * Inserts a syncache entry into the specified bucket row. * Locks and unlocks the syncache_head autonomously. ==== //depot/projects/vimage/src/sys/netinet/tcp_syncache.h#7 (text+ko) ==== @@ -37,6 +37,9 @@ #ifdef _KERNEL void syncache_init(void); +#ifdef VIMAGE +void syncache_destroy(void); +#endif void syncache_unreach(struct in_conninfo *, struct tcphdr *); int syncache_expand(struct in_conninfo *, struct tcpopt *, struct tcphdr *, struct socket **, struct mbuf *); ==== //depot/projects/vimage/src/sys/netinet/tcp_timewait.c#10 (text+ko) ==== @@ -183,6 +183,20 @@ uma_zone_set_max(tcptw_zone, maxtcptw); } +#ifdef VIMAGE +void +tcp_tw_destroy(void) +{ + INIT_VNET_INET(curvnet); + struct tcptw *tw; + + INP_INFO_WLOCK(&V_tcbinfo); + while((tw = TAILQ_FIRST(&V_twq_2msl)) != NULL) + tcp_twclose(tw, 0); + INP_INFO_WUNLOCK(&V_tcbinfo); +} +#endif + /* * Move a TCP connection into TIME_WAIT state. * tcbinfo is locked. ==== //depot/projects/vimage/src/sys/netinet/tcp_var.h#18 (text+ko) ==== @@ -564,6 +564,9 @@ void tcp_respond(struct tcpcb *, void *, struct tcphdr *, struct mbuf *, tcp_seq, tcp_seq, int); void tcp_tw_init(void); +#ifdef VIMAGE +void tcp_tw_destroy(void); +#endif void tcp_tw_zone_change(void); int tcp_twcheck(struct inpcb *, struct tcpopt *, struct tcphdr *, struct mbuf *, int); ==== //depot/projects/vimage/src/sys/netinet/udp_usrreq.c#19 (text+ko) ==== @@ -196,6 +196,20 @@ V_udbinfo.vnet = curvnet; } +#ifdef VIMAGE +void +udp_destroy(void) +{ + INIT_VNET_INET(curvnet); + + hashdestroy(V_udbinfo.ipi_hashbase, M_PCB, + V_udbinfo.ipi_hashmask); + hashdestroy(V_udbinfo.ipi_porthashbase, M_PCB, + V_udbinfo.ipi_porthashmask); + INP_INFO_LOCK_DESTROY(&V_udbinfo); +} +#endif + /* * Subroutine of udp_input(), which appends the provided mbuf chain to the * passed pcb/socket. The caller must provide a sockaddr_in via udp_in that ==== //depot/projects/vimage/src/sys/netinet/udp_var.h#6 (text+ko) ==== @@ -107,6 +107,9 @@ void udp_ctlinput(int, struct sockaddr *, void *); void udp_init(void); +#ifdef VIMAGE +void udp_destroy(void); +#endif void udp_input(struct mbuf *, int); struct inpcb *udp_notify(struct inpcb *inp, int errno); int udp_shutdown(struct socket *so);