summaryrefslogtreecommitdiffstats
path: root/sys/netinet/raw_ip.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2009-07-14 22:48:30 +0000
committerrwatson <rwatson@FreeBSD.org>2009-07-14 22:48:30 +0000
commit57ca4583e728cab422fba8f15de10bd0b637b3dd (patch)
tree13848f891fb2f7a396281b31633563d0f764ff65 /sys/netinet/raw_ip.c
parentef443476d9706035ac219f0280ef0b817dda7a6d (diff)
downloadFreeBSD-src-57ca4583e728cab422fba8f15de10bd0b637b3dd.zip
FreeBSD-src-57ca4583e728cab422fba8f15de10bd0b637b3dd.tar.gz
Build on Jeff Roberson's linker-set based dynamic per-CPU allocator
(DPCPU), as suggested by Peter Wemm, and implement a new per-virtual network stack memory allocator. Modify vnet to use the allocator instead of monolithic global container structures (vinet, ...). This change solves many binary compatibility problems associated with VIMAGE, and restores ELF symbols for virtualized global variables. Each virtualized global variable exists as a "reference copy", and also once per virtual network stack. Virtualized global variables are tagged at compile-time, placing the in a special linker set, which is loaded into a contiguous region of kernel memory. Virtualized global variables in the base kernel are linked as normal, but those in modules are copied and relocated to a reserved portion of the kernel's vnet region with the help of a the kernel linker. Virtualized global variables exist in per-vnet memory set up when the network stack instance is created, and are initialized statically from the reference copy. Run-time access occurs via an accessor macro, which converts from the current vnet and requested symbol to a per-vnet address. When "options VIMAGE" is not compiled into the kernel, normal global ELF symbols will be used instead and indirection is avoided. This change restores static initialization for network stack global variables, restores support for non-global symbols and types, eliminates the need for many subsystem constructors, eliminates large per-subsystem structures that caused many binary compatibility issues both for monitoring applications (netstat) and kernel modules, removes the per-function INIT_VNET_*() macros throughout the stack, eliminates the need for vnet_symmap ksym(2) munging, and eliminates duplicate definitions of virtualized globals under VIMAGE_GLOBALS. Bump __FreeBSD_version and update UPDATING. Portions submitted by: bz Reviewed by: bz, zec Discussed with: gnn, jamie, jeff, jhb, julian, sam Suggested by: peter Approved by: re (kensmith)
Diffstat (limited to 'sys/netinet/raw_ip.c')
-rw-r--r--sys/netinet/raw_ip.c31
1 files changed, 6 insertions, 25 deletions
diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c
index 00ec423..c3a0a74 100644
--- a/sys/netinet/raw_ip.c
+++ b/sys/netinet/raw_ip.c
@@ -68,18 +68,17 @@ __FBSDID("$FreeBSD$");
#include <netinet/ip_var.h>
#include <netinet/ip_mroute.h>
-#include <netinet/vinet.h>
-
#ifdef IPSEC
#include <netipsec/ipsec.h>
#endif /*IPSEC*/
#include <security/mac/mac_framework.h>
-#ifdef VIMAGE_GLOBALS
-struct inpcbhead ripcb;
-struct inpcbinfo ripcbinfo;
-#endif
+VNET_DEFINE(struct inpcbhead, ripcb);
+VNET_DEFINE(struct inpcbinfo, ripcbinfo);
+
+#define V_ripcb VNET_GET(ripcb)
+#define V_ripcbinfo VNET_GET(ripcbinfo)
/*
* Control and data hooks for ipfw and dummynet.
@@ -99,9 +98,7 @@ int (*ip_dn_io_ptr)(struct mbuf **m, int dir, struct ip_fw_args *fwa) = NULL;
/*
* The socket used to communicate with the multicast routing daemon.
*/
-#ifdef VIMAGE_GLOBALS
-struct socket *ip_mrouter;
-#endif
+VNET_DEFINE(struct socket *, ip_mrouter);
/*
* The various mrouter and rsvp functions.
@@ -168,7 +165,6 @@ rip_delhash(struct inpcb *inp)
static void
rip_zone_change(void *tag)
{
- INIT_VNET_INET(curvnet);
uma_zone_set_max(V_ripcbinfo.ipi_zone, maxsockets);
}
@@ -185,7 +181,6 @@ rip_inpcb_init(void *mem, int size, int flags)
void
rip_init(void)
{
- INIT_VNET_INET(curvnet);
INP_INFO_LOCK_INIT(&V_ripcbinfo, "rip");
LIST_INIT(&V_ripcb);
@@ -208,7 +203,6 @@ rip_init(void)
void
rip_destroy(void)
{
- INIT_VNET_INET(curvnet);
hashdestroy(V_ripcbinfo.ipi_hashbase, M_PCB,
V_ripcbinfo.ipi_hashmask);
@@ -268,7 +262,6 @@ rip_append(struct inpcb *last, struct ip *ip, struct mbuf *n,
void
rip_input(struct mbuf *m, int off)
{
- INIT_VNET_INET(curvnet);
struct ifnet *ifp;
struct ip *ip = mtod(m, struct ip *);
int proto = ip->ip_p;
@@ -398,7 +391,6 @@ rip_input(struct mbuf *m, int off)
int
rip_output(struct mbuf *m, struct socket *so, u_long dst)
{
- INIT_VNET_INET(so->so_vnet);
struct ip *ip;
int error;
struct inpcb *inp = sotoinpcb(so);
@@ -670,7 +662,6 @@ rip_ctloutput(struct socket *so, struct sockopt *sopt)
void
rip_ctlinput(int cmd, struct sockaddr *sa, void *vip)
{
- INIT_VNET_INET(curvnet);
struct in_ifaddr *ia;
struct ifnet *ifp;
int err;
@@ -741,7 +732,6 @@ SYSCTL_ULONG(_net_inet_raw, OID_AUTO, recvspace, CTLFLAG_RW,
static int
rip_attach(struct socket *so, int proto, struct thread *td)
{
- INIT_VNET_INET(so->so_vnet);
struct inpcb *inp;
int error;
@@ -775,7 +765,6 @@ rip_attach(struct socket *so, int proto, struct thread *td)
static void
rip_detach(struct socket *so)
{
- INIT_VNET_INET(so->so_vnet);
struct inpcb *inp;
inp = sotoinpcb(so);
@@ -815,7 +804,6 @@ rip_dodisconnect(struct socket *so, struct inpcb *inp)
static void
rip_abort(struct socket *so)
{
- INIT_VNET_INET(so->so_vnet);
struct inpcb *inp;
inp = sotoinpcb(so);
@@ -831,7 +819,6 @@ rip_abort(struct socket *so)
static void
rip_close(struct socket *so)
{
- INIT_VNET_INET(so->so_vnet);
struct inpcb *inp;
inp = sotoinpcb(so);
@@ -847,7 +834,6 @@ rip_close(struct socket *so)
static int
rip_disconnect(struct socket *so)
{
- INIT_VNET_INET(so->so_vnet);
struct inpcb *inp;
if ((so->so_state & SS_ISCONNECTED) == 0)
@@ -867,8 +853,6 @@ rip_disconnect(struct socket *so)
static int
rip_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
{
- INIT_VNET_NET(so->so_vnet);
- INIT_VNET_INET(so->so_vnet);
struct sockaddr_in *addr = (struct sockaddr_in *)nam;
struct inpcb *inp;
int error;
@@ -903,8 +887,6 @@ rip_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
static int
rip_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
{
- INIT_VNET_NET(so->so_vnet);
- INIT_VNET_INET(so->so_vnet);
struct sockaddr_in *addr = (struct sockaddr_in *)nam;
struct inpcb *inp;
@@ -975,7 +957,6 @@ rip_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam,
static int
rip_pcblist(SYSCTL_HANDLER_ARGS)
{
- INIT_VNET_INET(curvnet);
int error, i, n;
struct inpcb *inp, **inp_list;
inp_gen_t gencnt;
OpenPOWER on IntegriCloud