summaryrefslogtreecommitdiff
path: root/sys/netinet
diff options
context:
space:
mode:
authorMarko Zec <zec@FreeBSD.org>2009-06-08 17:15:40 +0000
committerMarko Zec <zec@FreeBSD.org>2009-06-08 17:15:40 +0000
commitbc29160df3d0b3a65d9b85a63a4589f1f9652e6b (patch)
tree7c00057a3f90cc6cfd121e2a6594d254fc72cba3 /sys/netinet
parent389cff511328e788e1a71dbb78154dd7d21b5fcc (diff)
Notes
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/in_proto.c13
-rw-r--r--sys/netinet/in_rmx.c14
-rw-r--r--sys/netinet/ip_var.h3
-rw-r--r--sys/netinet/raw_ip.c13
-rw-r--r--sys/netinet/tcp_hostcache.c12
-rw-r--r--sys/netinet/tcp_subr.c19
-rw-r--r--sys/netinet/tcp_syncache.c13
-rw-r--r--sys/netinet/tcp_syncache.h3
-rw-r--r--sys/netinet/tcp_timewait.c14
-rw-r--r--sys/netinet/tcp_var.h9
-rw-r--r--sys/netinet/udp_usrreq.c14
-rw-r--r--sys/netinet/udp_var.h3
12 files changed, 130 insertions, 0 deletions
diff --git a/sys/netinet/in_proto.c b/sys/netinet/in_proto.c
index c25f6eba857f..7d811f7a5814 100644
--- a/sys/netinet/in_proto.c
+++ b/sys/netinet/in_proto.c
@@ -127,6 +127,9 @@ struct protosw inetsw[] = {
.pr_ctlinput = udp_ctlinput,
.pr_ctloutput = ip_ctloutput,
.pr_init = udp_init,
+#ifdef VIMAGE
+ .pr_destroy = udp_destroy,
+#endif
.pr_usrreqs = &udp_usrreqs
},
{
@@ -138,6 +141,9 @@ struct protosw inetsw[] = {
.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
@@ -348,11 +354,15 @@ IPPROTOSPACER,
.pr_input = rip_input,
.pr_ctloutput = rip_ctloutput,
.pr_init = rip_init,
+#ifdef VIMAGE
+ .pr_destroy = rip_destroy,
+#endif
.pr_usrreqs = &rip_usrreqs
},
};
extern int in_inithead(void **, int);
+extern int in_detachhead(void **, int);
struct domain inetdomain = {
.dom_family = AF_INET,
@@ -364,6 +374,9 @@ struct domain inetdomain = {
#else
.dom_rtattach = in_inithead,
#endif
+#ifdef VIMAGE
+ .dom_rtdetach = in_detachhead,
+#endif
.dom_rtoffset = 32,
.dom_maxrtkey = sizeof(struct sockaddr_in),
.dom_ifattach = in_domifattach,
diff --git a/sys/netinet/in_rmx.c b/sys/netinet/in_rmx.c
index 8fc60ae886a4..f798f9c6866e 100644
--- a/sys/netinet/in_rmx.c
+++ b/sys/netinet/in_rmx.c
@@ -65,6 +65,9 @@ __FBSDID("$FreeBSD$");
#include <netinet/vinet.h>
extern int in_inithead(void **head, int off);
+#ifdef VIMAGE
+extern int in_detachhead(void **head, int off);
+#endif
#define RTPRF_OURS RTF_PROTO3 /* set on routes we manage */
@@ -382,6 +385,17 @@ in_inithead(void **head, int off)
return 1;
}
+#ifdef VIMAGE
+int
+in_detachhead(void **head, int off)
+{
+ INIT_VNET_INET(curvnet);
+
+ callout_drain(&V_rtq_timer);
+ return (1);
+}
+#endif
+
/*
* This zaps old routes when the interface goes down or interface
* address is deleted. In the latter case, it deletes static routes
diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h
index aa9beb148b8f..1e5e693012c2 100644
--- a/sys/netinet/ip_var.h
+++ b/sys/netinet/ip_var.h
@@ -210,6 +210,9 @@ u_int16_t ip_randomid(void);
int rip_ctloutput(struct socket *, struct sockopt *);
void rip_ctlinput(int, struct sockaddr *, void *);
void rip_init(void);
+#ifdef VIMAGE
+void rip_destroy(void);
+#endif
void rip_input(struct mbuf *, int);
int rip_output(struct mbuf *, struct socket *, u_long);
void ipip_input(struct mbuf *, int);
diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c
index 806fc1d01357..8063da134c30 100644
--- a/sys/netinet/raw_ip.c
+++ b/sys/netinet/raw_ip.c
@@ -205,6 +205,19 @@ rip_init(void)
EVENTHANDLER_PRI_ANY);
}
+#ifdef VIMAGE
+void
+rip_destroy(void)
+{
+ INIT_VNET_INET(curvnet);
+
+ hashdestroy(V_ripcbinfo.ipi_hashbase, M_PCB,
+ V_ripcbinfo.ipi_hashmask);
+ hashdestroy(V_ripcbinfo.ipi_porthashbase, M_PCB,
+ V_ripcbinfo.ipi_porthashmask);
+}
+#endif
+
static int
rip_append(struct inpcb *last, struct ip *ip, struct mbuf *n,
struct sockaddr_in *ripsrc)
diff --git a/sys/netinet/tcp_hostcache.c b/sys/netinet/tcp_hostcache.c
index 93367c5e16a1..e04499d7224f 100644
--- a/sys/netinet/tcp_hostcache.c
+++ b/sys/netinet/tcp_hostcache.c
@@ -230,6 +230,18 @@ tcp_hc_init(void)
tcp_hc_purge, curvnet);
}
+#ifdef VIMAGE
+void
+tcp_hc_destroy(void)
+{
+ INIT_VNET_INET(curvnet);
+
+ /* XXX TODO walk the hashtable and free all entries */
+
+ callout_drain(&V_tcp_hc_callout);
+}
+#endif
+
/*
* Internal function: look up an entry in the hostcache or return NULL.
*
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index 489617b5228c..fc49344e0bb5 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -426,6 +426,25 @@ tcp_init(void)
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)
{
diff --git a/sys/netinet/tcp_syncache.c b/sys/netinet/tcp_syncache.c
index 033e506c0c8b..dc05f46c3686 100644
--- a/sys/netinet/tcp_syncache.c
+++ b/sys/netinet/tcp_syncache.c
@@ -275,6 +275,19 @@ syncache_init(void)
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.
diff --git a/sys/netinet/tcp_syncache.h b/sys/netinet/tcp_syncache.h
index e488039dcd03..5ed0c9ef8a75 100644
--- a/sys/netinet/tcp_syncache.h
+++ b/sys/netinet/tcp_syncache.h
@@ -35,6 +35,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 *);
diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c
index 4c0fe947aa67..32108c74af3e 100644
--- a/sys/netinet/tcp_timewait.c
+++ b/sys/netinet/tcp_timewait.c
@@ -179,6 +179,20 @@ tcp_tw_init(void)
TAILQ_INIT(&V_twq_2msl);
}
+#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.
diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h
index 5dc840eee5cd..5568d4a893b4 100644
--- a/sys/netinet/tcp_var.h
+++ b/sys/netinet/tcp_var.h
@@ -584,6 +584,9 @@ struct tcpcb *
void tcp_drain(void);
void tcp_fasttimo(void);
void tcp_init(void);
+#ifdef VIMAGE
+void tcp_destroy(void);
+#endif
void tcp_fini(void *);
char *tcp_log_addrs(struct in_conninfo *, struct tcphdr *, void *,
const void *);
@@ -605,6 +608,9 @@ int tcp_output(struct tcpcb *);
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);
@@ -625,6 +631,9 @@ void tcp_xmit_bandwidth_limit(struct tcpcb *tp, tcp_seq ack_seq);
* All tcp_hc_* functions are IPv4 and IPv6 (via in_conninfo)
*/
void tcp_hc_init(void);
+#ifdef VIMAGE
+void tcp_hc_destroy(void);
+#endif
void tcp_hc_get(struct in_conninfo *, struct hc_metrics_lite *);
u_long tcp_hc_getmtu(struct in_conninfo *);
void tcp_hc_updatemtu(struct in_conninfo *, u_long);
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index 33be911b0781..fdc96f4501ec 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -221,6 +221,20 @@ udp_discardcb(struct udpcb *up)
uma_zfree(V_udpcb_zone, up);
}
+#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
diff --git a/sys/netinet/udp_var.h b/sys/netinet/udp_var.h
index e4298191e090..8b045ad1f568 100644
--- a/sys/netinet/udp_var.h
+++ b/sys/netinet/udp_var.h
@@ -128,6 +128,9 @@ void udp_discardcb(struct udpcb *);
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);