summaryrefslogtreecommitdiffstats
path: root/sys/netinet6/icmp6.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/netinet6/icmp6.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/netinet6/icmp6.c')
-rw-r--r--sys/netinet6/icmp6.c43
1 files changed, 15 insertions, 28 deletions
diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c
index 3ecf386..f65aec8 100644
--- a/sys/netinet6/icmp6.c
+++ b/sys/netinet6/icmp6.c
@@ -97,7 +97,6 @@ __FBSDID("$FreeBSD$");
#include <netinet/ip6.h>
#include <netinet/icmp6.h>
#include <netinet/tcp_var.h>
-#include <netinet/vinet.h>
#include <netinet6/in6_ifattach.h>
#include <netinet6/in6_pcb.h>
@@ -106,7 +105,6 @@ __FBSDID("$FreeBSD$");
#include <netinet6/scope6_var.h>
#include <netinet6/mld6_var.h>
#include <netinet6/nd6.h>
-#include <netinet6/vinet6.h>
#ifdef IPSEC
#include <netipsec/ipsec.h>
@@ -115,16 +113,22 @@ __FBSDID("$FreeBSD$");
extern struct domain inet6domain;
-#ifdef VIMAGE_GLOBALS
-extern struct inpcbinfo ripcbinfo;
-extern struct inpcbhead ripcb;
-extern int icmp6errppslim;
-extern int icmp6_nodeinfo;
+VNET_DECLARE(struct inpcbinfo, ripcbinfo);
+VNET_DECLARE(struct inpcbhead, ripcb);
+VNET_DECLARE(int, icmp6errppslim);
+VNET_DECLARE(int, icmp6_nodeinfo);
-struct icmp6stat icmp6stat;
-static int icmp6errpps_count;
-static struct timeval icmp6errppslim_last;
-#endif
+#define V_ripcbinfo VNET_GET(ripcbinfo)
+#define V_ripcb VNET_GET(ripcb)
+#define V_icmp6errppslim VNET_GET(icmp6errppslim)
+#define V_icmp6_nodeinfo VNET_GET(icmp6_nodeinfo)
+
+VNET_DEFINE(struct icmp6stat, icmp6stat);
+static VNET_DEFINE(int, icmp6errpps_count);
+static VNET_DEFINE(struct timeval, icmp6errppslim_last);
+
+#define V_icmp6errpps_count VNET_GET(icmp6errpps_count)
+#define V_icmp6errppslim_last VNET_GET(icmp6errppslim_last)
static void icmp6_errcount(struct icmp6errstat *, int, int);
static int icmp6_rip6_input(struct mbuf **, int);
@@ -144,7 +148,6 @@ static int icmp6_notify_error(struct mbuf **, int, int, int);
void
icmp6_init(void)
{
- INIT_VNET_INET6(curvnet);
V_icmp6errpps_count = 0;
}
@@ -213,7 +216,6 @@ void
icmp6_error2(struct mbuf *m, int type, int code, int param,
struct ifnet *ifp)
{
- INIT_VNET_INET6(curvnet);
struct ip6_hdr *ip6;
if (ifp == NULL)
@@ -245,7 +247,6 @@ icmp6_error2(struct mbuf *m, int type, int code, int param,
void
icmp6_error(struct mbuf *m, int type, int code, int param)
{
- INIT_VNET_INET6(curvnet);
struct ip6_hdr *oip6, *nip6;
struct icmp6_hdr *icmp6;
u_int preplen;
@@ -400,7 +401,6 @@ icmp6_error(struct mbuf *m, int type, int code, int param)
int
icmp6_input(struct mbuf **mp, int *offp, int proto)
{
- INIT_VNET_INET6(curvnet);
struct mbuf *m = *mp, *n;
struct ifnet *ifp;
struct ip6_hdr *ip6, *nip6;
@@ -884,7 +884,6 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
static int
icmp6_notify_error(struct mbuf **mp, int off, int icmp6len, int code)
{
- INIT_VNET_INET6(curvnet);
struct mbuf *m = *mp;
struct icmp6_hdr *icmp6;
struct ip6_hdr *eip6;
@@ -1116,7 +1115,6 @@ icmp6_notify_error(struct mbuf **mp, int off, int icmp6len, int code)
void
icmp6_mtudisc_update(struct ip6ctlparam *ip6cp, int validated)
{
- INIT_VNET_INET6(curvnet);
struct in6_addr *dst = ip6cp->ip6c_finaldst;
struct icmp6_hdr *icmp6 = ip6cp->ip6c_icmp6;
struct mbuf *m = ip6cp->ip6c_m; /* will be necessary for scope issue */
@@ -1181,7 +1179,6 @@ icmp6_mtudisc_update(struct ip6ctlparam *ip6cp, int validated)
static struct mbuf *
ni6_input(struct mbuf *m, int off)
{
- INIT_VNET_INET6(curvnet);
struct icmp6_nodeinfo *ni6, *nni6;
struct mbuf *n = NULL;
struct prison *pr;
@@ -1673,8 +1670,6 @@ static int
ni6_addrs(struct icmp6_nodeinfo *ni6, struct mbuf *m, struct ifnet **ifpp,
struct in6_addr *subj)
{
- INIT_VNET_NET(curvnet);
- INIT_VNET_INET6(curvnet);
struct ifnet *ifp;
struct in6_ifaddr *ifa6;
struct ifaddr *ifa;
@@ -1768,8 +1763,6 @@ static int
ni6_store_addrs(struct icmp6_nodeinfo *ni6, struct icmp6_nodeinfo *nni6,
struct ifnet *ifp0, int resid)
{
- INIT_VNET_NET(curvnet);
- INIT_VNET_INET6(curvnet);
struct ifnet *ifp = ifp0 ? ifp0 : TAILQ_FIRST(&V_ifnet);
struct in6_ifaddr *ifa6;
struct ifaddr *ifa;
@@ -1911,8 +1904,6 @@ ni6_store_addrs(struct icmp6_nodeinfo *ni6, struct icmp6_nodeinfo *nni6,
static int
icmp6_rip6_input(struct mbuf **mp, int off)
{
- INIT_VNET_INET(curvnet);
- INIT_VNET_INET6(curvnet);
struct mbuf *m = *mp;
struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
struct inpcb *in6p;
@@ -2073,7 +2064,6 @@ icmp6_rip6_input(struct mbuf **mp, int off)
void
icmp6_reflect(struct mbuf *m, size_t off)
{
- INIT_VNET_INET6(curvnet);
struct ip6_hdr *ip6;
struct icmp6_hdr *icmp6;
struct in6_ifaddr *ia = NULL;
@@ -2265,7 +2255,6 @@ icmp6_redirect_diag(struct in6_addr *src6, struct in6_addr *dst6,
void
icmp6_redirect_input(struct mbuf *m, int off)
{
- INIT_VNET_INET6(curvnet);
struct ifnet *ifp;
struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
struct nd_redirect *nd_rd;
@@ -2473,7 +2462,6 @@ icmp6_redirect_input(struct mbuf *m, int off)
void
icmp6_redirect_output(struct mbuf *m0, struct rtentry *rt)
{
- INIT_VNET_INET6(curvnet);
struct ifnet *ifp; /* my outgoing interface */
struct in6_addr *ifp_ll6;
struct in6_addr *router_ll6;
@@ -2843,7 +2831,6 @@ static int
icmp6_ratelimit(const struct in6_addr *dst, const int type,
const int code)
{
- INIT_VNET_INET6(curvnet);
int ret;
ret = 0; /* okay to send */
OpenPOWER on IntegriCloud