Date: Tue, 16 Oct 2007 11:48:51 GMT From: Marko Zec <zec@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 127598 for review Message-ID: <200710161148.l9GBmp6l015898@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200710161148.l9GBmp6l015898>