diff options
author | Bjoern A. Zeeb <bz@FreeBSD.org> | 2008-08-17 23:27:27 +0000 |
---|---|---|
committer | Bjoern A. Zeeb <bz@FreeBSD.org> | 2008-08-17 23:27:27 +0000 |
commit | 603724d3abed34351087e20b8cb363d8e02072c1 (patch) | |
tree | 1496da534aec03cf2f9d2d0735d80e4c1e3b5715 /sys/netipsec/keysock.c | |
parent | ac2dcb729fc5b54bc829c23d239dec65a057bf49 (diff) | |
download | src-603724d3abed34351087e20b8cb363d8e02072c1.tar.gz src-603724d3abed34351087e20b8cb363d8e02072c1.zip |
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
Notes
Notes:
svn path=/head/; revision=181803
Diffstat (limited to 'sys/netipsec/keysock.c')
-rw-r--r-- | sys/netipsec/keysock.c | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/sys/netipsec/keysock.c b/sys/netipsec/keysock.c index 5b26b2e86025..c86791e245d0 100644 --- a/sys/netipsec/keysock.c +++ b/sys/netipsec/keysock.c @@ -50,6 +50,7 @@ #include <sys/socketvar.h> #include <sys/sysctl.h> #include <sys/systm.h> +#include <sys/vimage.h> #include <net/raw_cb.h> #include <net/route.h> @@ -85,19 +86,19 @@ key_output(struct mbuf *m, struct socket *so) if (m == 0) panic("%s: NULL pointer was passed.\n", __func__); - pfkeystat.out_total++; - pfkeystat.out_bytes += m->m_pkthdr.len; + V_pfkeystat.out_total++; + V_pfkeystat.out_bytes += m->m_pkthdr.len; len = m->m_pkthdr.len; if (len < sizeof(struct sadb_msg)) { - pfkeystat.out_tooshort++; + V_pfkeystat.out_tooshort++; error = EINVAL; goto end; } if (m->m_len < sizeof(struct sadb_msg)) { if ((m = m_pullup(m, sizeof(struct sadb_msg))) == 0) { - pfkeystat.out_nomem++; + V_pfkeystat.out_nomem++; error = ENOBUFS; goto end; } @@ -108,9 +109,9 @@ key_output(struct mbuf *m, struct socket *so) KEYDEBUG(KEYDEBUG_KEY_DUMP, kdebug_mbuf(m)); msg = mtod(m, struct sadb_msg *); - pfkeystat.out_msgtype[msg->sadb_msg_type]++; + V_pfkeystat.out_msgtype[msg->sadb_msg_type]++; if (len != PFKEY_UNUNIT64(msg->sadb_msg_len)) { - pfkeystat.out_invlen++; + V_pfkeystat.out_invlen++; error = EINVAL; goto end; } @@ -141,7 +142,7 @@ key_sendup0(rp, m, promisc) if (m && m->m_len < sizeof(struct sadb_msg)) m = m_pullup(m, sizeof(struct sadb_msg)); if (!m) { - pfkeystat.in_nomem++; + V_pfkeystat.in_nomem++; m_freem(m); return ENOBUFS; } @@ -154,12 +155,12 @@ key_sendup0(rp, m, promisc) pmsg->sadb_msg_len = PFKEY_UNIT64(m->m_pkthdr.len); /* pid and seq? */ - pfkeystat.in_msgtype[pmsg->sadb_msg_type]++; + V_pfkeystat.in_msgtype[pmsg->sadb_msg_type]++; } - if (!sbappendaddr(&rp->rcb_socket->so_rcv, (struct sockaddr *)&key_src, + if (!sbappendaddr(&rp->rcb_socket->so_rcv, (struct sockaddr *)&V_key_src, m, NULL)) { - pfkeystat.in_nomem++; + V_pfkeystat.in_nomem++; m_freem(m); error = ENOBUFS; } else @@ -191,9 +192,9 @@ key_sendup(so, msg, len, target) * we increment statistics here, just in case we have ENOBUFS * in this function. */ - pfkeystat.in_total++; - pfkeystat.in_bytes += len; - pfkeystat.in_msgtype[msg->sadb_msg_type]++; + V_pfkeystat.in_total++; + V_pfkeystat.in_bytes += len; + V_pfkeystat.in_msgtype[msg->sadb_msg_type]++; /* * Get mbuf chain whenever possible (not clusters), @@ -210,14 +211,14 @@ key_sendup(so, msg, len, target) if (tlen == len) { MGETHDR(n, M_DONTWAIT, MT_DATA); if (n == NULL) { - pfkeystat.in_nomem++; + V_pfkeystat.in_nomem++; return ENOBUFS; } n->m_len = MHLEN; } else { MGET(n, M_DONTWAIT, MT_DATA); if (n == NULL) { - pfkeystat.in_nomem++; + V_pfkeystat.in_nomem++; return ENOBUFS; } n->m_len = MLEN; @@ -227,7 +228,7 @@ key_sendup(so, msg, len, target) if ((n->m_flags & M_EXT) == 0) { m_free(n); m_freem(m); - pfkeystat.in_nomem++; + V_pfkeystat.in_nomem++; return ENOBUFS; } n->m_len = MCLBYTES; @@ -250,9 +251,9 @@ key_sendup(so, msg, len, target) m_copyback(m, 0, len, (caddr_t)msg); /* avoid duplicated statistics */ - pfkeystat.in_total--; - pfkeystat.in_bytes -= len; - pfkeystat.in_msgtype[msg->sadb_msg_type]--; + V_pfkeystat.in_total--; + V_pfkeystat.in_bytes -= len; + V_pfkeystat.in_msgtype[msg->sadb_msg_type]--; return key_sendup_mbuf(so, m, target); } @@ -275,22 +276,22 @@ key_sendup_mbuf(so, m, target) if (so == NULL && target == KEY_SENDUP_ONE) panic("%s: NULL pointer was passed.\n", __func__); - pfkeystat.in_total++; - pfkeystat.in_bytes += m->m_pkthdr.len; + V_pfkeystat.in_total++; + V_pfkeystat.in_bytes += m->m_pkthdr.len; if (m->m_len < sizeof(struct sadb_msg)) { m = m_pullup(m, sizeof(struct sadb_msg)); if (m == NULL) { - pfkeystat.in_nomem++; + V_pfkeystat.in_nomem++; return ENOBUFS; } } if (m->m_len >= sizeof(struct sadb_msg)) { struct sadb_msg *msg; msg = mtod(m, struct sadb_msg *); - pfkeystat.in_msgtype[msg->sadb_msg_type]++; + V_pfkeystat.in_msgtype[msg->sadb_msg_type]++; } mtx_lock(&rawcb_mtx); - LIST_FOREACH(rp, &rawcb_list, list) + LIST_FOREACH(rp, &V_rawcb_list, list) { if (rp->rcb_proto.sp_family != PF_KEY) continue; @@ -332,14 +333,14 @@ key_sendup_mbuf(so, m, target) sendup++; break; } - pfkeystat.in_msgtarget[target]++; + V_pfkeystat.in_msgtarget[target]++; if (!sendup) continue; if ((n = m_copy(m, 0, (int)M_COPYALL)) == NULL) { m_freem(m); - pfkeystat.in_nomem++; + V_pfkeystat.in_nomem++; mtx_unlock(&rawcb_mtx); return ENOBUFS; } @@ -409,8 +410,8 @@ key_attach(struct socket *so, int proto, struct thread *td) kp->kp_promisc = kp->kp_registered = 0; if (kp->kp_raw.rcb_proto.sp_protocol == PF_KEY) /* XXX: AF_KEY */ - key_cb.key_count++; - key_cb.any_count++; + V_key_cb.key_count++; + V_key_cb.any_count++; soisconnected(so); so->so_options |= SO_USELOOPBACK; @@ -460,8 +461,8 @@ key_detach(struct socket *so) KASSERT(kp != NULL, ("key_detach: kp == NULL")); if (kp->kp_raw.rcb_proto.sp_protocol == PF_KEY) /* XXX: AF_KEY */ - key_cb.key_count--; - key_cb.any_count--; + V_key_cb.key_count--; + V_key_cb.any_count--; key_freereg(so); raw_usrreqs.pru_detach(so); @@ -557,7 +558,7 @@ struct protosw keysw[] = { static void key_init0(void) { - bzero((caddr_t)&key_cb, sizeof(key_cb)); + bzero((caddr_t)&V_key_cb, sizeof(V_key_cb)); key_init(); } |