diff options
author | bz <bz@FreeBSD.org> | 2008-08-17 23:27:27 +0000 |
---|---|---|
committer | bz <bz@FreeBSD.org> | 2008-08-17 23:27:27 +0000 |
commit | 1021d43b569bfc8d2c5544bde2f540fa432b011f (patch) | |
tree | 1496da534aec03cf2f9d2d0735d80e4c1e3b5715 /sys/netinet6/nd6.c | |
parent | 7fc341305a3e341fca7f202fc1219358f8d9dbbd (diff) | |
download | FreeBSD-src-1021d43b569bfc8d2c5544bde2f540fa432b011f.zip FreeBSD-src-1021d43b569bfc8d2c5544bde2f540fa432b011f.tar.gz |
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
Diffstat (limited to 'sys/netinet6/nd6.c')
-rw-r--r-- | sys/netinet6/nd6.c | 109 |
1 files changed, 55 insertions, 54 deletions
diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index 5964570..e02ceab 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -69,6 +69,7 @@ __FBSDID("$FreeBSD$"); #include <netinet/icmp6.h> #include <sys/limits.h> +#include <sys/vimage.h> #include <security/mac/mac_framework.h> @@ -138,13 +139,13 @@ nd6_init(void) all1_sa.sin6_addr.s6_addr[i] = 0xff; /* initialization of the default router list */ - TAILQ_INIT(&nd_defrouter); + TAILQ_INIT(&V_nd_defrouter); nd6_init_done = 1; /* start timer */ - callout_init(&nd6_slowtimo_ch, 0); - callout_reset(&nd6_slowtimo_ch, ND6_SLOWTIMER_INTERVAL * hz, + callout_init(&V_nd6_slowtimo_ch, 0); + callout_reset(&V_nd6_slowtimo_ch, ND6_SLOWTIMER_INTERVAL * hz, nd6_slowtimo, NULL); } @@ -228,7 +229,7 @@ nd6_setmtu0(struct ifnet *ifp, struct nd_ifinfo *ndi) if_name(ifp), (unsigned long)ndi->maxmtu); } - if (ndi->maxmtu > in6_maxmtu) + if (ndi->maxmtu > V_in6_maxmtu) in6_setmaxmtu(); /* check all interfaces just in case */ #undef MIN @@ -323,7 +324,7 @@ nd6_options(union nd_opts *ndopts) * Message validation requires that all included * options have a length that is greater than zero. */ - icmp6stat.icp6s_nd_badopt++; + V_icmp6stat.icp6s_nd_badopt++; bzero(ndopts, sizeof(*ndopts)); return -1; } @@ -366,8 +367,8 @@ nd6_options(union nd_opts *ndopts) skip1: i++; - if (i > nd6_maxndopt) { - icmp6stat.icp6s_nd_toomanyopt++; + if (i > V_nd6_maxndopt) { + V_icmp6stat.icp6s_nd_toomanyopt++; nd6log((LOG_INFO, "too many loop in nd opt\n")); break; } @@ -442,7 +443,7 @@ nd6_llinfo_timer(void *arg) switch (ln->ln_state) { case ND6_LLINFO_INCOMPLETE: - if (ln->ln_asked < nd6_mmaxtries) { + if (ln->ln_asked < V_nd6_mmaxtries) { ln->ln_asked++; nd6_llinfo_settimer(ln, (long)ndi->retrans * hz / 1000); nd6_ns_output(ifp, NULL, dst, ln, 0); @@ -471,7 +472,7 @@ nd6_llinfo_timer(void *arg) case ND6_LLINFO_REACHABLE: if (!ND6_LLINFO_PERMANENT(ln)) { ln->ln_state = ND6_LLINFO_STALE; - nd6_llinfo_settimer(ln, (long)nd6_gctimer * hz); + nd6_llinfo_settimer(ln, (long)V_nd6_gctimer * hz); } break; @@ -493,11 +494,11 @@ nd6_llinfo_timer(void *arg) nd6_ns_output(ifp, dst, dst, ln, 0); } else { ln->ln_state = ND6_LLINFO_STALE; /* XXX */ - nd6_llinfo_settimer(ln, (long)nd6_gctimer * hz); + nd6_llinfo_settimer(ln, (long)V_nd6_gctimer * hz); } break; case ND6_LLINFO_PROBE: - if (ln->ln_asked < nd6_umaxtries) { + if (ln->ln_asked < V_nd6_umaxtries) { ln->ln_asked++; nd6_llinfo_settimer(ln, (long)ndi->retrans * hz / 1000); nd6_ns_output(ifp, dst, dst, ln, 0); @@ -536,12 +537,12 @@ nd6_timer(void *ignored_arg) struct in6_ifaddr *ia6, *nia6; struct in6_addrlifetime *lt6; - callout_reset(&nd6_timer_ch, nd6_prune * hz, + callout_reset(&V_nd6_timer_ch, V_nd6_prune * hz, nd6_timer, NULL); /* expire default router list */ s = splnet(); - dr = TAILQ_FIRST(&nd_defrouter); + dr = TAILQ_FIRST(&V_nd_defrouter); while (dr) { if (dr->expire && dr->expire < time_second) { struct nd_defrouter *t; @@ -560,7 +561,7 @@ nd6_timer(void *ignored_arg) * rather separate address lifetimes and prefix lifetimes. */ addrloop: - for (ia6 = in6_ifaddr; ia6; ia6 = nia6) { + for (ia6 = V_in6_ifaddr; ia6; ia6 = nia6) { nia6 = ia6->ia_next; /* check address lifetime */ lt6 = &ia6->ia6_lifetime; @@ -577,7 +578,7 @@ nd6_timer(void *ignored_arg) * address. Otherwise, we'd see an infinite loop of * regeneration. */ - if (ip6_use_tempaddr && + if (V_ip6_use_tempaddr && (ia6->ia6_flags & IN6_IFF_TEMPORARY) != 0) { if (regen_tmpaddr(ia6) == 0) regen = 1; @@ -596,7 +597,7 @@ nd6_timer(void *ignored_arg) * If a temporary address has just become deprecated, * regenerate a new one if possible. */ - if (ip6_use_tempaddr && + if (V_ip6_use_tempaddr && (ia6->ia6_flags & IN6_IFF_TEMPORARY) != 0 && (oldflags & IN6_IFF_DEPRECATED) == 0) { @@ -626,7 +627,7 @@ nd6_timer(void *ignored_arg) } /* expire prefix list */ - pr = nd_prefix.lh_first; + pr = V_nd_prefix.lh_first; while (pr) { /* * check prefix lifetime. @@ -733,7 +734,7 @@ nd6_purge(struct ifnet *ifp) * in the routing table, in order to keep additional side effects as * small as possible. */ - for (dr = TAILQ_FIRST(&nd_defrouter); dr; dr = ndr) { + for (dr = TAILQ_FIRST(&V_nd_defrouter); dr; dr = ndr) { ndr = TAILQ_NEXT(dr, dr_entry); if (dr->installed) continue; @@ -742,7 +743,7 @@ nd6_purge(struct ifnet *ifp) defrtrlist_del(dr); } - for (dr = TAILQ_FIRST(&nd_defrouter); dr; dr = ndr) { + for (dr = TAILQ_FIRST(&V_nd_defrouter); dr; dr = ndr) { ndr = TAILQ_NEXT(dr, dr_entry); if (!dr->installed) continue; @@ -752,7 +753,7 @@ nd6_purge(struct ifnet *ifp) } /* Nuke prefix list entries toward ifp */ - for (pr = nd_prefix.lh_first; pr; pr = npr) { + for (pr = V_nd_prefix.lh_first; pr; pr = npr) { npr = pr->ndpr_next; if (pr->ndpr_ifp == ifp) { /* @@ -776,10 +777,10 @@ nd6_purge(struct ifnet *ifp) } /* cancel default outgoing interface setting */ - if (nd6_defifindex == ifp->if_index) + if (V_nd6_defifindex == ifp->if_index) nd6_setdefaultiface(0); - if (!ip6_forwarding && ip6_accept_rtadv) { /* XXX: too restrictive? */ + if (!V_ip6_forwarding && V_ip6_accept_rtadv) { /* XXX: too restrictive? */ /* refresh default router list */ defrouter_select(); } @@ -790,8 +791,8 @@ nd6_purge(struct ifnet *ifp) * due to KAME goto ours hack. See RTM_RESOLVE case in * nd6_rtrequest(), and ip6_input(). */ - ln = llinfo_nd6.ln_next; - while (ln && ln != &llinfo_nd6) { + ln = V_llinfo_nd6.ln_next; + while (ln && ln != &V_llinfo_nd6) { struct rtentry *rt; struct sockaddr_dl *sdl; @@ -947,7 +948,7 @@ nd6_is_new_addr_neighbor(struct sockaddr_in6 *addr, struct ifnet *ifp) * If the address matches one of our on-link prefixes, it should be a * neighbor. */ - for (pr = nd_prefix.lh_first; pr; pr = pr->ndpr_next) { + for (pr = V_nd_prefix.lh_first; pr; pr = pr->ndpr_next) { if (pr->ndpr_ifp != ifp) continue; @@ -973,8 +974,8 @@ nd6_is_new_addr_neighbor(struct sockaddr_in6 *addr, struct ifnet *ifp) * XXX: we restrict the condition to hosts, because routers usually do * not have the "default router list". */ - if (!ip6_forwarding && TAILQ_FIRST(&nd_defrouter) == NULL && - nd6_defifindex == ifp->if_index) { + if (!V_ip6_forwarding && TAILQ_FIRST(&V_nd_defrouter) == NULL && + V_nd6_defifindex == ifp->if_index) { return (1); } @@ -1024,7 +1025,7 @@ nd6_free(struct rtentry *rt, int gc) /* cancel timer */ nd6_llinfo_settimer(ln, -1); - if (!ip6_forwarding) { + if (!V_ip6_forwarding) { int s; s = splnet(); dr = defrouter_lookup(&((struct sockaddr_in6 *)rt_key(rt))->sin6_addr, @@ -1048,7 +1049,7 @@ nd6_free(struct rtentry *rt, int gc) nd6_llinfo_settimer(ln, (dr->expire - time_second) * hz); else - nd6_llinfo_settimer(ln, (long)nd6_gctimer * hz); + nd6_llinfo_settimer(ln, (long)V_nd6_gctimer * hz); splx(s); return (ln->ln_next); } @@ -1152,7 +1153,7 @@ nd6_nud_hint(struct rtentry *rt, struct in6_addr *dst6, int force) */ if (!force) { ln->ln_byhint++; - if (ln->ln_byhint > nd6_maxnudhint) + if (ln->ln_byhint > V_nd6_maxnudhint) return; } @@ -1287,8 +1288,8 @@ nd6_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info) log(LOG_DEBUG, "nd6_rtrequest: malloc failed\n"); break; } - nd6_inuse++; - nd6_allocated++; + V_nd6_inuse++; + V_nd6_allocated++; bzero(ln, sizeof(*ln)); RT_ADDREF(rt); ln->ln_rt = rt; @@ -1312,9 +1313,9 @@ nd6_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info) nd6_llinfo_settimer(ln, 0); } rt->rt_flags |= RTF_LLINFO; - ln->ln_next = llinfo_nd6.ln_next; - llinfo_nd6.ln_next = ln; - ln->ln_prev = &llinfo_nd6; + ln->ln_next = V_llinfo_nd6.ln_next; + V_llinfo_nd6.ln_next = ln; + ln->ln_prev = &V_llinfo_nd6; ln->ln_next->ln_prev = ln; /* @@ -1332,8 +1333,8 @@ nd6_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info) bcopy(macp, LLADDR(SDL(gate)), ifp->if_addrlen); SDL(gate)->sdl_alen = ifp->if_addrlen; } - if (nd6_useloopback) { - rt->rt_ifp = &loif[0]; /* XXX */ + if (V_nd6_useloopback) { + rt->rt_ifp = &V_loif[0]; /* XXX */ /* * Make sure rt_ifa be equal to the ifaddr * corresponding to the address. @@ -1398,7 +1399,7 @@ nd6_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info) } else ; /* XXX: should not happen. bark here? */ } - nd6_inuse--; + V_nd6_inuse--; ln->ln_next->ln_prev = ln->ln_prev; ln->ln_prev->ln_next = ln->ln_next; ln->ln_prev = NULL; @@ -1432,7 +1433,7 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp) */ bzero(drl, sizeof(*drl)); s = splnet(); - dr = TAILQ_FIRST(&nd_defrouter); + dr = TAILQ_FIRST(&V_nd_defrouter); while (dr && i < DRLSTSIZ) { drl->defrouter[i].rtaddr = dr->rtaddr; in6_clearscope(&drl->defrouter[i].rtaddr); @@ -1461,7 +1462,7 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp) */ bzero(oprl, sizeof(*oprl)); s = splnet(); - pr = nd_prefix.lh_first; + pr = V_nd_prefix.lh_first; while (pr && i < PRLSTSIZ) { struct nd_pfxrouter *pfr; int j; @@ -1570,7 +1571,7 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp) struct nd_prefix *pr, *next; s = splnet(); - for (pr = nd_prefix.lh_first; pr; pr = next) { + for (pr = V_nd_prefix.lh_first; pr; pr = next) { struct in6_ifaddr *ia, *ia_next; next = pr->ndpr_next; @@ -1579,7 +1580,7 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp) continue; /* XXX */ /* do we really have to remove addresses as well? */ - for (ia = in6_ifaddr; ia; ia = ia_next) { + for (ia = V_in6_ifaddr; ia; ia = ia_next) { /* ia might be removed. keep the next ptr. */ ia_next = ia->ia_next; @@ -1601,7 +1602,7 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp) s = splnet(); defrouter_reset(); - for (dr = TAILQ_FIRST(&nd_defrouter); dr; dr = next) { + for (dr = TAILQ_FIRST(&V_nd_defrouter); dr; dr = next) { next = TAILQ_NEXT(dr, dr_entry); defrtrlist_del(dr); } @@ -1633,7 +1634,7 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp) break; } case SIOCGDEFIFACE_IN6: /* XXX: should be implemented as a sysctl? */ - ndif->ifindex = nd6_defifindex; + ndif->ifindex = V_nd6_defifindex; break; case SIOCSDEFIFACE_IN6: /* XXX: should be implemented as a sysctl? */ return (nd6_setdefaultiface(ndif->ifindex)); @@ -1764,7 +1765,7 @@ fail: * we must set the timer now, although it is actually * meaningless. */ - nd6_llinfo_settimer(ln, (long)nd6_gctimer * hz); + nd6_llinfo_settimer(ln, (long)V_nd6_gctimer * hz); if (ln->ln_hold) { struct mbuf *m_hold, *m_hold_next; @@ -1875,7 +1876,7 @@ fail: * for those are not autoconfigured hosts, we explicitly avoid such * cases for safety. */ - if (do_update && ln->ln_router && !ip6_forwarding && ip6_accept_rtadv) + if (do_update && ln->ln_router && !V_ip6_forwarding && V_ip6_accept_rtadv) defrouter_select(); return rt; @@ -1887,10 +1888,10 @@ nd6_slowtimo(void *ignored_arg) struct nd_ifinfo *nd6if; struct ifnet *ifp; - callout_reset(&nd6_slowtimo_ch, ND6_SLOWTIMER_INTERVAL * hz, + callout_reset(&V_nd6_slowtimo_ch, ND6_SLOWTIMER_INTERVAL * hz, nd6_slowtimo, NULL); IFNET_RLOCK(); - for (ifp = TAILQ_FIRST(&ifnet); ifp; ifp = TAILQ_NEXT(ifp, if_list)) { + for (ifp = TAILQ_FIRST(&V_ifnet); ifp; ifp = TAILQ_NEXT(ifp, if_list)) { nd6if = ND_IFINFO(ifp); if (nd6if->basereachable && /* already initialized */ (nd6if->recalctm -= ND6_SLOWTIMER_INTERVAL) <= 0) { @@ -1900,7 +1901,7 @@ nd6_slowtimo(void *ignored_arg) * value gets recomputed at least once every few hours. * (RFC 2461, 6.3.4) */ - nd6if->recalctm = nd6_recalc_reachtm_interval; + nd6if->recalctm = V_nd6_recalc_reachtm_interval; nd6if->reachable = ND_COMPUTE_RTIME(nd6if->basereachable); } } @@ -2041,7 +2042,7 @@ again: if ((ifp->if_flags & IFF_POINTOPOINT) != 0 && ln->ln_state < ND6_LLINFO_REACHABLE) { ln->ln_state = ND6_LLINFO_STALE; - nd6_llinfo_settimer(ln, (long)nd6_gctimer * hz); + nd6_llinfo_settimer(ln, (long)V_nd6_gctimer * hz); } /* @@ -2054,7 +2055,7 @@ again: if (ln->ln_state == ND6_LLINFO_STALE) { ln->ln_asked = 0; ln->ln_state = ND6_LLINFO_DELAY; - nd6_llinfo_settimer(ln, (long)nd6_delay * hz); + nd6_llinfo_settimer(ln, (long)V_nd6_delay * hz); } /* @@ -2086,7 +2087,7 @@ again: break; } } - while (i >= nd6_maxqueuelen) { + while (i >= V_nd6_maxqueuelen) { m_hold = ln->ln_hold; ln->ln_hold = ln->ln_hold->m_nextpkt; m_freem(m_hold); @@ -2277,7 +2278,7 @@ nd6_sysctl_drlist(SYSCTL_HANDLER_ARGS) return EPERM; error = 0; - for (dr = TAILQ_FIRST(&nd_defrouter); dr; + for (dr = TAILQ_FIRST(&V_nd_defrouter); dr; dr = TAILQ_NEXT(dr, dr_entry)) { d = (struct in6_defrouter *)buf; de = (struct in6_defrouter *)(buf + sizeof(buf)); @@ -2318,7 +2319,7 @@ nd6_sysctl_prlist(SYSCTL_HANDLER_ARGS) return EPERM; error = 0; - for (pr = nd_prefix.lh_first; pr; pr = pr->ndpr_next) { + for (pr = V_nd_prefix.lh_first; pr; pr = pr->ndpr_next) { u_short advrtrs; size_t advance; struct sockaddr_in6 *sin6, *s6; |