summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/amd64/amd64/dump_machdep.c3
-rw-r--r--sys/amd64/amd64/minidump_machdep.c3
-rw-r--r--sys/arm/arm/dump_machdep.c3
-rw-r--r--sys/compat/linprocfs/linprocfs.c3
-rw-r--r--sys/compat/linux/linux_ioctl.c10
-rw-r--r--sys/compat/linux/linux_misc.c3
-rw-r--r--sys/compat/linux/linux_socket.c3
-rw-r--r--sys/compat/svr4/svr4_sockio.c3
-rw-r--r--sys/compat/svr4/svr4_stat.c5
-rw-r--r--sys/conf/options3
-rw-r--r--sys/contrib/altq/altq/altq_subr.c3
-rw-r--r--sys/contrib/ipfilter/netinet/fil.c3
-rw-r--r--sys/contrib/ipfilter/netinet/ip_fil_freebsd.c14
-rw-r--r--sys/contrib/pf/net/pf.c45
-rw-r--r--sys/contrib/pf/net/pf_if.c5
-rw-r--r--sys/contrib/pf/net/pf_ioctl.c3
-rw-r--r--sys/contrib/pf/net/pf_subr.c29
-rw-r--r--sys/contrib/rdma/rdma_cma.c17
-rw-r--r--sys/ddb/db_textdump.c3
-rw-r--r--sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c13
-rw-r--r--sys/dev/firewire/firewire.c3
-rw-r--r--sys/dev/syscons/daemon/daemon_saver.c5
-rw-r--r--sys/fs/cd9660/cd9660_rrip.c9
-rw-r--r--sys/geom/vinum/geom_vinum_drive.c3
-rw-r--r--sys/i386/i386/dump_machdep.c3
-rw-r--r--sys/i386/i386/minidump_machdep.c3
-rw-r--r--sys/i386/ibcs2/ibcs2_socksys.c5
-rw-r--r--sys/ia64/ia64/dump_machdep.c3
-rw-r--r--sys/kern/kern_jail.c3
-rw-r--r--sys/kern/kern_mib.c5
-rw-r--r--sys/kern/kern_poll.c3
-rw-r--r--sys/kern/kern_uuid.c3
-rw-r--r--sys/kern/kern_xxx.c5
-rw-r--r--sys/net/bridgestp.c3
-rw-r--r--sys/net/if.c79
-rw-r--r--sys/net/if_bridge.c27
-rw-r--r--sys/net/if_ef.c3
-rw-r--r--sys/net/if_ethersubr.c7
-rw-r--r--sys/net/if_faith.c3
-rw-r--r--sys/net/if_gif.c15
-rw-r--r--sys/net/if_loop.c13
-rw-r--r--sys/net/if_mib.c3
-rw-r--r--sys/net/if_spppsubr.c1
-rw-r--r--sys/net/if_stf.c3
-rw-r--r--sys/net/if_vlan.c3
-rw-r--r--sys/net/raw_cb.c3
-rw-r--r--sys/net/raw_usrreq.c5
-rw-r--r--sys/net/route.c31
-rw-r--r--sys/net/rtsock.c9
-rw-r--r--sys/netgraph/atm/ng_atm.c5
-rw-r--r--sys/netgraph/ng_base.c17
-rw-r--r--sys/netgraph/ng_bridge.c3
-rw-r--r--sys/netgraph/ng_eiface.c9
-rw-r--r--sys/netgraph/ng_ether.c3
-rw-r--r--sys/netgraph/ng_gif.c3
-rw-r--r--sys/netgraph/ng_iface.c9
-rw-r--r--sys/netgraph/ng_source.c3
-rw-r--r--sys/netinet/if_ether.c21
-rw-r--r--sys/netinet/igmp.c35
-rw-r--r--sys/netinet/in.c23
-rw-r--r--sys/netinet/in_gif.c11
-rw-r--r--sys/netinet/in_mcast.c17
-rw-r--r--sys/netinet/in_pcb.c67
-rw-r--r--sys/netinet/in_rmx.c39
-rw-r--r--sys/netinet/in_var.h6
-rw-r--r--sys/netinet/ip6.h8
-rw-r--r--sys/netinet/ip_carp.c5
-rw-r--r--sys/netinet/ip_divert.c91
-rw-r--r--sys/netinet/ip_fastfwd.c39
-rw-r--r--sys/netinet/ip_fw2.c279
-rw-r--r--sys/netinet/ip_fw_nat.c71
-rw-r--r--sys/netinet/ip_fw_pfil.c5
-rw-r--r--sys/netinet/ip_icmp.c39
-rw-r--r--sys/netinet/ip_input.c197
-rw-r--r--sys/netinet/ip_ipsec.c3
-rw-r--r--sys/netinet/ip_mroute.c35
-rw-r--r--sys/netinet/ip_options.c17
-rw-r--r--sys/netinet/ip_output.c35
-rw-r--r--sys/netinet/ip_var.h5
-rw-r--r--sys/netinet/raw_ip.c109
-rw-r--r--sys/netinet/sctp_os_bsd.h13
-rw-r--r--sys/netinet/sctp_pcb.c4
-rw-r--r--sys/netinet/tcp_hostcache.c133
-rw-r--r--sys/netinet/tcp_input.c231
-rw-r--r--sys/netinet/tcp_offload.c13
-rw-r--r--sys/netinet/tcp_output.c55
-rw-r--r--sys/netinet/tcp_reass.c37
-rw-r--r--sys/netinet/tcp_sack.c13
-rw-r--r--sys/netinet/tcp_subr.c197
-rw-r--r--sys/netinet/tcp_syncache.c157
-rw-r--r--sys/netinet/tcp_timer.c65
-rw-r--r--sys/netinet/tcp_timewait.c43
-rw-r--r--sys/netinet/tcp_usrreq.c91
-rw-r--r--sys/netinet/udp_usrreq.c161
-rw-r--r--sys/netinet6/dest6.c3
-rw-r--r--sys/netinet6/frag6.c77
-rw-r--r--sys/netinet6/icmp6.c109
-rw-r--r--sys/netinet6/in6.c31
-rw-r--r--sys/netinet6/in6_gif.c9
-rw-r--r--sys/netinet6/in6_ifattach.c35
-rw-r--r--sys/netinet6/in6_pcb.c15
-rw-r--r--sys/netinet6/in6_proto.c15
-rw-r--r--sys/netinet6/in6_rmx.c35
-rw-r--r--sys/netinet6/in6_src.c63
-rw-r--r--sys/netinet6/ip6_forward.c85
-rw-r--r--sys/netinet6/ip6_input.c153
-rw-r--r--sys/netinet6/ip6_ipsec.c3
-rw-r--r--sys/netinet6/ip6_mroute.c91
-rw-r--r--sys/netinet6/ip6_output.c53
-rw-r--r--sys/netinet6/mld6.c11
-rw-r--r--sys/netinet6/nd6.c109
-rw-r--r--sys/netinet6/nd6.h2
-rw-r--r--sys/netinet6/nd6_nbr.c51
-rw-r--r--sys/netinet6/nd6_rtr.c121
-rw-r--r--sys/netinet6/raw_ip6.c73
-rw-r--r--sys/netinet6/route6.c19
-rw-r--r--sys/netinet6/scope6.c21
-rw-r--r--sys/netinet6/udp6_usrreq.c101
-rw-r--r--sys/netipsec/ipsec.c31
-rw-r--r--sys/netipsec/ipsec.h4
-rw-r--r--sys/netipsec/ipsec_input.c115
-rw-r--r--sys/netipsec/ipsec_mbuf.c11
-rw-r--r--sys/netipsec/ipsec_output.c35
-rw-r--r--sys/netipsec/key.c197
-rw-r--r--sys/netipsec/key_debug.h2
-rw-r--r--sys/netipsec/keysock.c63
-rw-r--r--sys/netipsec/xform_ah.c63
-rw-r--r--sys/netipsec/xform_esp.c75
-rw-r--r--sys/netipsec/xform_ipcomp.c45
-rw-r--r--sys/netipsec/xform_ipip.c57
-rw-r--r--sys/nfsclient/bootp_subr.c17
-rw-r--r--sys/nfsclient/nfs_diskless.c3
-rw-r--r--sys/nfsclient/nfs_vfsops.c7
-rw-r--r--sys/nfsclient/nfs_vnops.c5
-rw-r--r--sys/rpc/authunix_prot.c5
-rw-r--r--sys/sparc64/sparc64/dump_machdep.c3
-rw-r--r--sys/sun4v/sun4v/dump_machdep.c3
-rw-r--r--sys/sys/param.h2
-rw-r--r--sys/sys/vimage.h344
139 files changed, 2859 insertions, 2370 deletions
diff --git a/sys/amd64/amd64/dump_machdep.c b/sys/amd64/amd64/dump_machdep.c
index e80489f..08d32d5 100644
--- a/sys/amd64/amd64/dump_machdep.c
+++ b/sys/amd64/amd64/dump_machdep.c
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sysctl.h>
#include <sys/kernel.h>
#include <sys/kerneldump.h>
+#include <sys/vimage.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <machine/elf.h>
@@ -118,7 +119,7 @@ mkdumpheader(struct kerneldumpheader *kdh, uint32_t archver, uint64_t dumplen,
kdh->dumplength = htod64(dumplen);
kdh->dumptime = htod64(time_second);
kdh->blocksize = htod32(blksz);
- strncpy(kdh->hostname, hostname, sizeof(kdh->hostname));
+ strncpy(kdh->hostname, G_hostname, sizeof(kdh->hostname));
strncpy(kdh->versionstring, version, sizeof(kdh->versionstring));
if (panicstr != NULL)
strncpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring));
diff --git a/sys/amd64/amd64/minidump_machdep.c b/sys/amd64/amd64/minidump_machdep.c
index 192b121..d3c4309 100644
--- a/sys/amd64/amd64/minidump_machdep.c
+++ b/sys/amd64/amd64/minidump_machdep.c
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/kerneldump.h>
#include <sys/msgbuf.h>
+#include <sys/vimage.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <machine/atomic.h>
@@ -94,7 +95,7 @@ mkdumpheader(struct kerneldumpheader *kdh, uint32_t archver, uint64_t dumplen,
kdh->dumplength = htod64(dumplen);
kdh->dumptime = htod64(time_second);
kdh->blocksize = htod32(blksz);
- strncpy(kdh->hostname, hostname, sizeof(kdh->hostname));
+ strncpy(kdh->hostname, G_hostname, sizeof(kdh->hostname));
strncpy(kdh->versionstring, version, sizeof(kdh->versionstring));
if (panicstr != NULL)
strncpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring));
diff --git a/sys/arm/arm/dump_machdep.c b/sys/arm/arm/dump_machdep.c
index 50c92b5..391bc40 100644
--- a/sys/arm/arm/dump_machdep.c
+++ b/sys/arm/arm/dump_machdep.c
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/kerneldump.h>
+#include <sys/vimage.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <machine/elf.h>
@@ -116,7 +117,7 @@ mkdumpheader(struct kerneldumpheader *kdh, uint32_t archver, uint64_t dumplen,
kdh->dumplength = htod64(dumplen);
kdh->dumptime = htod64(time_second);
kdh->blocksize = htod32(blksz);
- strncpy(kdh->hostname, hostname, sizeof(kdh->hostname));
+ strncpy(kdh->hostname, G_hostname, sizeof(kdh->hostname));
strncpy(kdh->versionstring, version, sizeof(kdh->versionstring));
if (panicstr != NULL)
strncpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring));
diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c
index 7d8e2b6..f5055b1 100644
--- a/sys/compat/linprocfs/linprocfs.c
+++ b/sys/compat/linprocfs/linprocfs.c
@@ -71,6 +71,7 @@ __FBSDID("$FreeBSD$");
#include <sys/user.h>
#include <sys/vmmeter.h>
#include <sys/vnode.h>
+#include <sys/vimage.h>
#include <net/if.h>
@@ -1008,7 +1009,7 @@ linprocfs_donetdev(PFS_FILL_ARGS)
"bytes packets errs drop fifo frame compressed");
IFNET_RLOCK();
- TAILQ_FOREACH(ifp, &ifnet, if_link) {
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
linux_ifname(ifp, ifname, sizeof ifname);
sbuf_printf(sb, "%6.6s:", ifname);
sbuf_printf(sb, "%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu ",
diff --git a/sys/compat/linux/linux_ioctl.c b/sys/compat/linux/linux_ioctl.c
index 9364c41..b166535 100644
--- a/sys/compat/linux/linux_ioctl.c
+++ b/sys/compat/linux/linux_ioctl.c
@@ -56,6 +56,8 @@ __FBSDID("$FreeBSD$");
#include <sys/sx.h>
#include <sys/tty.h>
#include <sys/uio.h>
+#include <sys/vimage.h>
+
#include <net/if.h>
#include <net/if_dl.h>
#include <net/if_types.h>
@@ -2054,7 +2056,7 @@ linux_ifname(struct ifnet *ifp, char *buffer, size_t buflen)
/* Determine the (relative) unit number for ethernet interfaces */
ethno = 0;
IFNET_RLOCK();
- TAILQ_FOREACH(ifscan, &ifnet, if_link) {
+ TAILQ_FOREACH(ifscan, &V_ifnet, if_link) {
if (ifscan == ifp) {
IFNET_RUNLOCK();
return (snprintf(buffer, buflen, "eth%d", ethno));
@@ -2093,7 +2095,7 @@ ifname_linux_to_bsd(const char *lxname, char *bsdname)
index = 0;
is_eth = (len == 3 && !strncmp(lxname, "eth", len)) ? 1 : 0;
IFNET_RLOCK();
- TAILQ_FOREACH(ifp, &ifnet, if_link) {
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
/*
* Allow Linux programs to use FreeBSD names. Don't presume
* we never have an interface named "eth", so don't make
@@ -2137,7 +2139,7 @@ linux_ifconf(struct thread *td, struct ifconf *uifc)
/* handle the 'request buffer size' case */
if (ifc.ifc_buf == PTROUT(NULL)) {
ifc.ifc_len = 0;
- TAILQ_FOREACH(ifp, &ifnet, if_link) {
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
struct sockaddr *sa = ifa->ifa_addr;
if (sa->sa_family == AF_INET)
@@ -2164,7 +2166,7 @@ again:
/* Return all AF_INET addresses of all interfaces */
IFNET_RLOCK(); /* could sleep XXX */
- TAILQ_FOREACH(ifp, &ifnet, if_link) {
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
int addrs = 0;
bzero(&ifr, sizeof(ifr));
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c
index 57d315f..8a983cb 100644
--- a/sys/compat/linux/linux_misc.c
+++ b/sys/compat/linux/linux_misc.c
@@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$");
#include <sys/vnode.h>
#include <sys/wait.h>
#include <sys/cpuset.h>
+#include <sys/vimage.h>
#include <security/mac/mac_framework.h>
@@ -765,7 +766,7 @@ linux_newuname(struct thread *td, struct linux_newuname_args *args)
strlcpy(utsname.machine, machine, LINUX_MAX_UTSNAME);
#endif /* __i386__ */
mtx_lock(&hostname_mtx);
- strlcpy(utsname.domainname, domainname, LINUX_MAX_UTSNAME);
+ strlcpy(utsname.domainname, V_domainname, LINUX_MAX_UTSNAME);
mtx_unlock(&hostname_mtx);
return (copyout(&utsname, args->buf, sizeof(utsname)));
diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c
index e6ac278..09e88bb 100644
--- a/sys/compat/linux/linux_socket.c
+++ b/sys/compat/linux/linux_socket.c
@@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$");
#include <sys/uio.h>
#include <sys/syslog.h>
#include <sys/un.h>
+#include <sys/vimage.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
@@ -588,7 +589,7 @@ linux_socket(struct thread *td, struct linux_socket_args *args)
* XXX: Avoid undefined symbol error with an IPv4 only
* kernel.
*/
- && ip6_v6only
+ && V_ip6_v6only
#endif
) {
int v6only;
diff --git a/sys/compat/svr4/svr4_sockio.c b/sys/compat/svr4/svr4_sockio.c
index 7fd2885..41a1621 100644
--- a/sys/compat/svr4/svr4_sockio.c
+++ b/sys/compat/svr4/svr4_sockio.c
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
#include <sys/filedesc.h>
#include <sys/sockio.h>
#include <sys/socket.h>
+#include <sys/vimage.h>
#include <net/if.h>
@@ -103,7 +104,7 @@ svr4_sock_ioctl(fp, td, retval, fd, cmd, data)
* entry per physical interface?
*/
IFNET_RLOCK();
- TAILQ_FOREACH(ifp, &ifnet, if_link)
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link)
if (TAILQ_EMPTY(&ifp->if_addrhead))
ifnum++;
else
diff --git a/sys/compat/svr4/svr4_stat.c b/sys/compat/svr4/svr4_stat.c
index 7b6f200..3492aa8 100644
--- a/sys/compat/svr4/svr4_stat.c
+++ b/sys/compat/svr4/svr4_stat.c
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sysctl.h>
#include <sys/sysproto.h>
#include <sys/un.h>
+#include <sys/vimage.h>
#include <vm/vm.h>
@@ -426,7 +427,7 @@ svr4_sys_systeminfo(td, uap)
break;
case SVR4_SI_HOSTNAME:
- str = hostname;
+ str = V_hostname;
break;
case SVR4_SI_RELEASE:
@@ -455,7 +456,7 @@ svr4_sys_systeminfo(td, uap)
case SVR4_SI_SRPC_DOMAIN:
/* XXXRW: locking? */
- str = domainname;
+ str = V_domainname;
break;
case SVR4_SI_PLATFORM:
diff --git a/sys/conf/options b/sys/conf/options
index b58ba7e..58a3dc7 100644
--- a/sys/conf/options
+++ b/sys/conf/options
@@ -766,3 +766,6 @@ IEEE80211_AMPDU_AGE opt_wlan.h
#Disable code to dispatch tcp offloading
TCP_OFFLOAD_DISABLE opt_inet.h
+
+# Virtualize the network stack
+VIMAGE
diff --git a/sys/contrib/altq/altq/altq_subr.c b/sys/contrib/altq/altq/altq_subr.c
index c7c2f4a..af006a6 100644
--- a/sys/contrib/altq/altq/altq_subr.c
+++ b/sys/contrib/altq/altq/altq_subr.c
@@ -77,6 +77,7 @@
#include <sys/bus.h>
#include <sys/cpu.h>
#include <sys/eventhandler.h>
+#include <sys/vimage.h>
#include <machine/clock.h>
#endif
#if defined(__i386__)
@@ -460,7 +461,7 @@ tbr_timeout(arg)
#if defined(__FreeBSD__) && (__FreeBSD_version >= 500000)
IFNET_RLOCK();
#endif
- 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)) {
/* read from if_snd unlocked */
if (!TBR_IS_ENABLED(&ifp->if_snd))
continue;
diff --git a/sys/contrib/ipfilter/netinet/fil.c b/sys/contrib/ipfilter/netinet/fil.c
index ea19254..3cd09d1 100644
--- a/sys/contrib/ipfilter/netinet/fil.c
+++ b/sys/contrib/ipfilter/netinet/fil.c
@@ -33,6 +33,9 @@
# if (__FreeBSD_version == 400019)
# define CSUM_DELAY_DATA
# endif
+# if (__FreeBSD_version >= 800044)
+# include <sys/vimage.h>
+# endif
# endif
# include <sys/filio.h>
#else
diff --git a/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c b/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
index 0eb2632..7bfd1de 100644
--- a/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
+++ b/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
@@ -62,6 +62,12 @@ static const char rcsid[] = "@(#)$Id: ip_fil_freebsd.c,v 2.53.2.50 2007/09/20 12
#else
# include <sys/select.h>
#endif
+#if __FreeBSD_version >= 800044
+# include <sys/vimage.h>
+#else
+#define V_path_mtu_discovery path_mtu_discovery
+#define V_ipforwarding ipforwarding
+#endif
#include <net/if.h>
#if __FreeBSD_version >= 300000
@@ -234,7 +240,7 @@ int ipfattach()
fr_running = 1;
if (fr_control_forwarding & 1)
- ipforwarding = 1;
+ V_ipforwarding = 1;
SPL_X(s);
#if (__FreeBSD_version >= 300000)
@@ -257,7 +263,7 @@ int ipfdetach()
int s;
#endif
if (fr_control_forwarding & 2)
- ipforwarding = 0;
+ V_ipforwarding = 0;
SPL_NET(s);
@@ -652,11 +658,11 @@ mb_t *m, **mpp;
ip->ip_tos = oip->ip_tos;
ip->ip_id = fin->fin_ip->ip_id;
#if (__FreeBSD_version > 460000)
- ip->ip_off = path_mtu_discovery ? IP_DF : 0;
+ ip->ip_off = V_path_mtu_discovery ? IP_DF : 0;
#else
ip->ip_off = 0;
#endif
- ip->ip_ttl = ip_defttl;
+ ip->ip_ttl = V_ip_defttl;
ip->ip_sum = 0;
hlen = sizeof(*oip);
break;
diff --git a/sys/contrib/pf/net/pf.c b/sys/contrib/pf/net/pf.c
index 8289c99..35488ea 100644
--- a/sys/contrib/pf/net/pf.c
+++ b/sys/contrib/pf/net/pf.c
@@ -92,6 +92,7 @@ __FBSDID("$FreeBSD$");
#include <sys/kthread.h>
#include <sys/lock.h>
#include <sys/sx.h>
+#include <sys/vimage.h>
#else
#include <sys/rwlock.h>
#endif
@@ -1917,13 +1918,13 @@ pf_send_tcp(const struct pf_rule *r, sa_family_t af,
h->ip_hl = sizeof(*h) >> 2;
h->ip_tos = IPTOS_LOWDELAY;
#ifdef __FreeBSD__
- h->ip_off = path_mtu_discovery ? IP_DF : 0;
+ h->ip_off = V_path_mtu_discovery ? IP_DF : 0;
h->ip_len = len;
#else
h->ip_off = htons(ip_mtudisc ? IP_DF : 0);
h->ip_len = htons(len);
#endif
- h->ip_ttl = ttl ? ttl : ip_defttl;
+ h->ip_ttl = ttl ? ttl : V_ip_defttl;
h->ip_sum = 0;
if (eh == NULL) {
#ifdef __FreeBSD__
@@ -2954,7 +2955,7 @@ pf_socket_lookup(int direction, struct pf_pdesc *pd)
sport = pd->hdr.tcp->th_sport;
dport = pd->hdr.tcp->th_dport;
#ifdef __FreeBSD__
- pi = &tcbinfo;
+ pi = &V_tcbinfo;
#else
tb = &tcbtable;
#endif
@@ -2965,7 +2966,7 @@ pf_socket_lookup(int direction, struct pf_pdesc *pd)
sport = pd->hdr.udp->uh_sport;
dport = pd->hdr.udp->uh_dport;
#ifdef __FreeBSD__
- pi = &udbinfo;
+ pi = &V_udbinfo;
#else
tb = &udbtable;
#endif
@@ -3103,7 +3104,7 @@ pf_get_mss(struct mbuf *m, int off, u_int16_t th_off, sa_family_t af)
int hlen;
u_int8_t hdr[60];
u_int8_t *opt, optlen;
- u_int16_t mss = tcp_mssdflt;
+ u_int16_t mss = V_tcp_mssdflt;
hlen = th_off << 2; /* hlen <= sizeof(hdr) */
if (hlen <= sizeof(struct tcphdr))
@@ -3148,7 +3149,7 @@ pf_calc_mss(struct pf_addr *addr, sa_family_t af, u_int16_t offer)
#endif /* INET6 */
struct rtentry *rt = NULL;
int hlen = 0; /* make the compiler happy */
- u_int16_t mss = tcp_mssdflt;
+ u_int16_t mss = V_tcp_mssdflt;
switch (af) {
#ifdef INET
@@ -3196,7 +3197,7 @@ pf_calc_mss(struct pf_addr *addr, sa_family_t af, u_int16_t offer)
if (rt && rt->rt_ifp) {
mss = rt->rt_ifp->if_mtu - hlen - sizeof(struct tcphdr);
- mss = max(tcp_mssdflt, mss);
+ mss = max(V_tcp_mssdflt, mss);
RTFREE(rt);
}
mss = min(mss, offer);
@@ -3252,7 +3253,7 @@ pf_test_tcp(struct pf_rule **rm, struct pf_state **sm, int direction,
u_short reason;
int rewrite = 0;
int tag = -1, rtableid = -1;
- u_int16_t mss = tcp_mssdflt;
+ u_int16_t mss = V_tcp_mssdflt;
int asd = 0;
int match = 0;
@@ -6152,7 +6153,7 @@ pf_route(struct mbuf **m, struct pf_rule *r, int dir, struct ifnet *oifp,
if (r->rt == PF_FASTROUTE) {
in_rtalloc(ro, 0);
if (ro->ro_rt == 0) {
- ipstat.ips_noroute++;
+ V_ipstat.ips_noroute++;
goto bad;
}
@@ -6283,16 +6284,16 @@ pf_route(struct mbuf **m, struct pf_rule *r, int dir, struct ifnet *oifp,
if ((ifp->if_capabilities & IFCAP_CSUM_IPv4) &&
ifp->if_bridge == NULL) {
m0->m_pkthdr.csum_flags |= M_IPV4_CSUM_OUT;
- ipstat.ips_outhwcsum++;
+ V_ipstat.ips_outhwcsum++;
} else {
ip->ip_sum = 0;
ip->ip_sum = in_cksum(m0, ip->ip_hl << 2);
}
/* Update relevant hardware checksum stats for TCP/UDP */
if (m0->m_pkthdr.csum_flags & M_TCPV4_CSUM_OUT)
- tcpstat.tcps_outhwcsum++;
+ V_tcpstat.tcps_outhwcsum++;
else if (m0->m_pkthdr.csum_flags & M_UDPV4_CSUM_OUT)
- udpstat.udps_outhwcsum++;
+ V_udpstat.udps_outhwcsum++;
error = (*ifp->if_output)(ifp, m0, sintosa(dst), NULL);
goto done;
}
@@ -6302,7 +6303,7 @@ pf_route(struct mbuf **m, struct pf_rule *r, int dir, struct ifnet *oifp,
* Must be able to put at least 8 bytes per fragment.
*/
if (ip->ip_off & htons(IP_DF)) {
- ipstat.ips_cantfrag++;
+ V_ipstat.ips_cantfrag++;
if (r->rt != PF_DUPTO) {
#ifdef __FreeBSD__
/* icmp_error() expects host byte ordering */
@@ -6359,7 +6360,7 @@ pf_route(struct mbuf **m, struct pf_rule *r, int dir, struct ifnet *oifp,
}
if (error == 0)
- ipstat.ips_fragmented++;
+ V_ipstat.ips_fragmented++;
done:
if (r->rt != PF_DUPTO)
@@ -6632,17 +6633,17 @@ pf_check_proto_cksum(struct mbuf *m, int off, int len, u_int8_t p, sa_family_t a
if (sum) {
switch (p) {
case IPPROTO_TCP:
- tcpstat.tcps_rcvbadsum++;
+ V_tcpstat.tcps_rcvbadsum++;
break;
case IPPROTO_UDP:
- udpstat.udps_badsum++;
+ V_udpstat.udps_badsum++;
break;
case IPPROTO_ICMP:
- icmpstat.icps_checksum++;
+ V_icmpstat.icps_checksum++;
break;
#ifdef INET6
case IPPROTO_ICMPV6:
- icmp6stat.icp6s_checksum++;
+ V_icmp6stat.icp6s_checksum++;
break;
#endif /* INET6 */
}
@@ -6728,17 +6729,17 @@ pf_check_proto_cksum(struct mbuf *m, int off, int len, u_int8_t p,
m->m_pkthdr.csum_flags |= flag_bad;
switch (p) {
case IPPROTO_TCP:
- tcpstat.tcps_rcvbadsum++;
+ V_tcpstat.tcps_rcvbadsum++;
break;
case IPPROTO_UDP:
- udpstat.udps_badsum++;
+ V_udpstat.udps_badsum++;
break;
case IPPROTO_ICMP:
- icmpstat.icps_checksum++;
+ V_icmpstat.icps_checksum++;
break;
#ifdef INET6
case IPPROTO_ICMPV6:
- icmp6stat.icp6s_checksum++;
+ V_icmp6stat.icp6s_checksum++;
break;
#endif /* INET6 */
}
diff --git a/sys/contrib/pf/net/pf_if.c b/sys/contrib/pf/net/pf_if.c
index 2b82375..fd42dc7 100644
--- a/sys/contrib/pf/net/pf_if.c
+++ b/sys/contrib/pf/net/pf_if.c
@@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$");
#include <sys/device.h>
#endif
#include <sys/time.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_types.h>
@@ -141,9 +142,9 @@ pfi_initialize(void)
struct ifnet *ifp;
IFNET_RLOCK();
- TAILQ_FOREACH(ifg, &ifg_head, ifg_next)
+ TAILQ_FOREACH(ifg, &V_ifg_head, ifg_next)
pfi_attach_ifgroup(ifg);
- TAILQ_FOREACH(ifp, &ifnet, if_link)
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link)
pfi_attach_ifnet(ifp);
IFNET_RUNLOCK();
diff --git a/sys/contrib/pf/net/pf_ioctl.c b/sys/contrib/pf/net/pf_ioctl.c
index 83a92df..3e99a99 100644
--- a/sys/contrib/pf/net/pf_ioctl.c
+++ b/sys/contrib/pf/net/pf_ioctl.c
@@ -86,6 +86,7 @@ __FBSDID("$FreeBSD$");
#include <sys/conf.h>
#include <sys/proc.h>
#include <sys/sysctl.h>
+#include <sys/vimage.h>
#else
#include <sys/timeout.h>
#include <sys/pool.h>
@@ -3713,7 +3714,7 @@ pf_check6_in(void *arg, struct mbuf **m, struct ifnet *ifp, int dir,
* order to support scoped addresses. In order to support stateful
* filtering we have change this to lo0 as it is the case in IPv4.
*/
- chk = pf_test6(PF_IN, (*m)->m_flags & M_LOOP ? &loif[0] : ifp, m,
+ chk = pf_test6(PF_IN, (*m)->m_flags & M_LOOP ? &V_loif[0] : ifp, m,
NULL, inp);
if (chk && *m) {
m_freem(*m);
diff --git a/sys/contrib/pf/net/pf_subr.c b/sys/contrib/pf/net/pf_subr.c
index 7d87833..f8550c7 100644
--- a/sys/contrib/pf/net/pf_subr.c
+++ b/sys/contrib/pf/net/pf_subr.c
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
#include <sys/socketvar.h>
#include <sys/systm.h>
#include <sys/time.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_types.h>
@@ -127,9 +128,9 @@ pf_new_isn(struct pf_state *s)
struct pf_state_host *src, *dst;
/* Seed if this is the first use, reseed if requested. */
- if (isn_last_reseed == 0) {
- read_random(&isn_secret, sizeof(isn_secret));
- isn_last_reseed = ticks;
+ if (V_isn_last_reseed == 0) {
+ read_random(&V_isn_secret, sizeof(V_isn_secret));
+ V_isn_last_reseed = ticks;
}
if (s->direction == PF_IN) {
@@ -141,28 +142,28 @@ pf_new_isn(struct pf_state *s)
}
/* Compute the md5 hash and return the ISN. */
- MD5Init(&isn_ctx);
- MD5Update(&isn_ctx, (u_char *) &dst->port, sizeof(u_short));
- MD5Update(&isn_ctx, (u_char *) &src->port, sizeof(u_short));
+ MD5Init(&V_isn_ctx);
+ MD5Update(&V_isn_ctx, (u_char *) &dst->port, sizeof(u_short));
+ MD5Update(&V_isn_ctx, (u_char *) &src->port, sizeof(u_short));
#ifdef INET6
if (s->af == AF_INET6) {
- MD5Update(&isn_ctx, (u_char *) &dst->addr,
+ MD5Update(&V_isn_ctx, (u_char *) &dst->addr,
sizeof(struct in6_addr));
- MD5Update(&isn_ctx, (u_char *) &src->addr,
+ MD5Update(&V_isn_ctx, (u_char *) &src->addr,
sizeof(struct in6_addr));
} else
#endif
{
- MD5Update(&isn_ctx, (u_char *) &dst->addr,
+ MD5Update(&V_isn_ctx, (u_char *) &dst->addr,
sizeof(struct in_addr));
- MD5Update(&isn_ctx, (u_char *) &src->addr,
+ MD5Update(&V_isn_ctx, (u_char *) &src->addr,
sizeof(struct in_addr));
}
- MD5Update(&isn_ctx, (u_char *) &isn_secret, sizeof(isn_secret));
- MD5Final((u_char *) &md5_buffer, &isn_ctx);
+ MD5Update(&V_isn_ctx, (u_char *) &V_isn_secret, sizeof(V_isn_secret));
+ MD5Final((u_char *) &md5_buffer, &V_isn_ctx);
new_isn = (tcp_seq) md5_buffer[0];
- isn_offset += ISN_STATIC_INCREMENT +
+ V_isn_offset += ISN_STATIC_INCREMENT +
(arc4random() & ISN_RANDOM_INCREMENT);
- new_isn += isn_offset;
+ new_isn += V_isn_offset;
return (new_isn);
}
diff --git a/sys/contrib/rdma/rdma_cma.c b/sys/contrib/rdma/rdma_cma.c
index 8dddf6c..fa93816 100644
--- a/sys/contrib/rdma/rdma_cma.c
+++ b/sys/contrib/rdma/rdma_cma.c
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
#include <sys/taskqueue.h>
#include <sys/priv.h>
#include <sys/syslog.h>
+#include <sys/vimage.h>
#include <netinet/in.h>
#include <netinet/in_pcb.h>
@@ -1962,18 +1963,18 @@ retry:
if (ret)
goto err1;
- if (port > ipport_lastauto) {
- if (next_port != ipport_firstauto) {
+ if (port > V_ipport_lastauto) {
+ if (next_port != V_ipport_firstauto) {
kvl_delete(ps, port);
- next_port = ipport_firstauto;
+ next_port = V_ipport_firstauto;
goto retry;
}
ret = EADDRNOTAVAIL;
goto err2;
}
- if (port == ipport_lastauto)
- next_port = ipport_firstauto;
+ if (port == V_ipport_lastauto)
+ next_port = V_ipport_firstauto;
else
next_port = port + 1;
@@ -1997,7 +1998,7 @@ static int cma_use_port(struct kvl *ps, struct rdma_id_private *id_priv)
sin = (struct sockaddr_in *) &id_priv->id.route.addr.src_addr;
snum = ntohs(sin->sin_port);
- if (snum <= ipport_reservedhigh && snum >= ipport_reservedlow &&
+ if (snum <= V_ipport_reservedhigh && snum >= V_ipport_reservedlow &&
priv_check(curthread, PRIV_NETINET_RESERVEDPORT))
return (EACCES);
@@ -2917,8 +2918,8 @@ static int cma_init(void)
arc4rand(&next_port, sizeof next_port, 0);
next_port = ((unsigned int) next_port %
- (ipport_lastauto - ipport_firstauto)) +
- ipport_firstauto;
+ (V_ipport_lastauto - V_ipport_firstauto)) +
+ V_ipport_firstauto;
cma_wq = taskqueue_create("rdma_cm", M_NOWAIT, taskqueue_thread_enqueue,
&cma_wq);
diff --git a/sys/ddb/db_textdump.c b/sys/ddb/db_textdump.c
index fbfc18f..dd48acc 100644
--- a/sys/ddb/db_textdump.c
+++ b/sys/ddb/db_textdump.c
@@ -68,6 +68,7 @@ __FBSDID("$FreeBSD$");
#include <sys/msgbuf.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
+#include <sys/vimage.h>
#include <ddb/ddb.h>
#include <ddb/db_lex.h>
@@ -192,7 +193,7 @@ mkdumpheader(struct kerneldumpheader *kdh, uint32_t archver,
kdh->dumplength = htod64(dumplen);
kdh->dumptime = htod64(time_second);
kdh->blocksize = htod32(blksz);
- strncpy(kdh->hostname, hostname, sizeof(kdh->hostname));
+ strncpy(kdh->hostname, G_hostname, sizeof(kdh->hostname));
strncpy(kdh->versionstring, version, sizeof(kdh->versionstring));
if (panicstr != NULL)
strncpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring));
diff --git a/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c b/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c
index 5b7248d..36ea35f 100644
--- a/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c
+++ b/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c
@@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
#include <sys/syslog.h>
#include <sys/protosw.h>
#include <sys/priv.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/route.h>
@@ -293,8 +294,8 @@ make_tx_data_wr(struct socket *so, struct mbuf *m, int len, struct mbuf *tail)
/* Sendbuffer is in units of 32KB.
*/
- if (tcp_do_autosndbuf && snd->sb_flags & SB_AUTOSIZE)
- req->param |= htonl(V_TX_SNDBUF(tcp_autosndbuf_max >> 15));
+ if (V_tcp_do_autosndbuf && snd->sb_flags & SB_AUTOSIZE)
+ req->param |= htonl(V_TX_SNDBUF(V_tcp_autosndbuf_max >> 15));
else {
req->param |= htonl(V_TX_SNDBUF(snd->sb_hiwat >> 15));
}
@@ -1215,7 +1216,7 @@ select_rcv_wscale(int space)
if (space > MAX_RCV_WND)
space = MAX_RCV_WND;
- if (tcp_do_rfc1323)
+ if (V_tcp_do_rfc1323)
for (; space > 65535 && wscale < 14; space >>= 1, ++wscale) ;
return (wscale);
@@ -1234,8 +1235,8 @@ select_rcv_wnd(struct toedev *dev, struct socket *so)
rcv = so_sockbuf_rcv(so);
- if (tcp_do_autorcvbuf)
- wnd = tcp_autorcvbuf_max;
+ if (V_tcp_do_autorcvbuf)
+ wnd = V_tcp_autorcvbuf_max;
else
wnd = rcv->sb_hiwat;
@@ -3821,7 +3822,7 @@ socket_act_establish(struct socket *so, struct mbuf *m)
#endif
toep->tp_state = tp->t_state;
- tcpstat.tcps_connects++;
+ V_tcpstat.tcps_connects++;
}
diff --git a/sys/dev/firewire/firewire.c b/sys/dev/firewire/firewire.c
index 25e0ed2..2c48ff3 100644
--- a/sys/dev/firewire/firewire.c
+++ b/sys/dev/firewire/firewire.c
@@ -45,6 +45,7 @@
#include <sys/conf.h>
#include <sys/sysctl.h>
#include <sys/kthread.h>
+#include <sys/vimage.h>
#include <sys/kdb.h>
@@ -702,7 +703,7 @@ fw_reset_crom(struct firewire_comm *fc)
crom_add_simple_text(src, root, &buf->vendor, "FreeBSD Project");
crom_add_entry(root, CSRKEY_HW, __FreeBSD_version);
#endif
- crom_add_simple_text(src, root, &buf->hw, hostname);
+ crom_add_simple_text(src, root, &buf->hw, V_hostname);
}
/*
diff --git a/sys/dev/syscons/daemon/daemon_saver.c b/sys/dev/syscons/daemon/daemon_saver.c
index 2afc4c0..ac91313 100644
--- a/sys/dev/syscons/daemon/daemon_saver.c
+++ b/sys/dev/syscons/daemon/daemon_saver.c
@@ -36,6 +36,7 @@
#include <sys/sysctl.h>
#include <sys/consio.h>
#include <sys/fbio.h>
+#include <sys/vimage.h>
#include <machine/pc/display.h>
@@ -352,10 +353,10 @@ daemon_init(video_adapter_t *adp)
{
/* XXXRW: Locking -- these can change! */
- messagelen = strlen(hostname) + 3 + strlen(ostype) + 1 +
+ messagelen = strlen(G_hostname) + 3 + strlen(ostype) + 1 +
strlen(osrelease);
message = malloc(messagelen + 1, M_DEVBUF, M_WAITOK);
- sprintf(message, "%s - %s %s", hostname, ostype, osrelease);
+ sprintf(message, "%s - %s %s", G_hostname, ostype, osrelease);
blanked = 0;
switch (adp->va_mode) {
case M_PC98_80x25:
diff --git a/sys/fs/cd9660/cd9660_rrip.c b/sys/fs/cd9660/cd9660_rrip.c
index fd28218..2b540d8 100644
--- a/sys/fs/cd9660/cd9660_rrip.c
+++ b/sys/fs/cd9660/cd9660_rrip.c
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
#include <sys/vnode.h>
#include <sys/mount.h>
#include <sys/kernel.h>
+#include <sys/vimage.h>
#include <fs/cd9660/iso.h>
#include <fs/cd9660/cd9660_node.h>
@@ -172,8 +173,8 @@ cd9660_rrip_slink(p,ana)
case ISO_SUSP_CFLAG_HOST:
/* XXXRW: locking. */
/* Inserting hostname i.e. "kurt.tools.de" */
- inbuf = hostname;
- wlen = strlen(hostname);
+ inbuf = V_hostname;
+ wlen = strlen(V_hostname);
break;
case ISO_SUSP_CFLAG_CONTINUE:
@@ -245,8 +246,8 @@ cd9660_rrip_altname(p,ana)
case ISO_SUSP_CFLAG_HOST:
/* XXXRW: locking. */
/* Inserting hostname i.e. "kurt.tools.de" */
- inbuf = hostname;
- wlen = strlen(hostname);
+ inbuf = V_hostname;
+ wlen = strlen(V_hostname);
break;
case ISO_SUSP_CFLAG_CONTINUE:
diff --git a/sys/geom/vinum/geom_vinum_drive.c b/sys/geom/vinum/geom_vinum_drive.c
index a72937c..efa53f6 100644
--- a/sys/geom/vinum/geom_vinum_drive.c
+++ b/sys/geom/vinum/geom_vinum_drive.c
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sbuf.h>
#include <sys/systm.h>
#include <sys/time.h>
+#include <sys/vimage.h>
#include <geom/geom.h>
#include <geom/vinum/geom_vinum_var.h>
@@ -63,7 +64,7 @@ gv_config_new_drive(struct gv_drive *d)
vhdr->config_length = GV_CFG_LEN;
mtx_lock(&hostname_mtx);
- bcopy(hostname, vhdr->label.sysname, GV_HOSTNAME_LEN);
+ bcopy(G_hostname, vhdr->label.sysname, GV_HOSTNAME_LEN);
mtx_unlock(&hostname_mtx);
strncpy(vhdr->label.name, d->name, GV_MAXDRIVENAME);
microtime(&vhdr->label.date_of_birth);
diff --git a/sys/i386/i386/dump_machdep.c b/sys/i386/i386/dump_machdep.c
index e7cf38c..b9a18e3 100644
--- a/sys/i386/i386/dump_machdep.c
+++ b/sys/i386/i386/dump_machdep.c
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sysctl.h>
#include <sys/kernel.h>
#include <sys/kerneldump.h>
+#include <sys/vimage.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <machine/elf.h>
@@ -118,7 +119,7 @@ mkdumpheader(struct kerneldumpheader *kdh, uint32_t archver, uint64_t dumplen,
kdh->dumplength = htod64(dumplen);
kdh->dumptime = htod64(time_second);
kdh->blocksize = htod32(blksz);
- strncpy(kdh->hostname, hostname, sizeof(kdh->hostname));
+ strncpy(kdh->hostname, G_hostname, sizeof(kdh->hostname));
strncpy(kdh->versionstring, version, sizeof(kdh->versionstring));
if (panicstr != NULL)
strncpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring));
diff --git a/sys/i386/i386/minidump_machdep.c b/sys/i386/i386/minidump_machdep.c
index 0fc6ba8..61d28d3 100644
--- a/sys/i386/i386/minidump_machdep.c
+++ b/sys/i386/i386/minidump_machdep.c
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/kerneldump.h>
#include <sys/msgbuf.h>
+#include <sys/vimage.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <machine/atomic.h>
@@ -92,7 +93,7 @@ mkdumpheader(struct kerneldumpheader *kdh, uint32_t archver, uint64_t dumplen,
kdh->dumplength = htod64(dumplen);
kdh->dumptime = htod64(time_second);
kdh->blocksize = htod32(blksz);
- strncpy(kdh->hostname, hostname, sizeof(kdh->hostname));
+ strncpy(kdh->hostname, G_hostname, sizeof(kdh->hostname));
strncpy(kdh->versionstring, version, sizeof(kdh->versionstring));
if (panicstr != NULL)
strncpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring));
diff --git a/sys/i386/ibcs2/ibcs2_socksys.c b/sys/i386/ibcs2/ibcs2_socksys.c
index 62d300f..f4eb97c 100644
--- a/sys/i386/ibcs2/ibcs2_socksys.c
+++ b/sys/i386/ibcs2/ibcs2_socksys.c
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/sysctl.h>
+#include <sys/vimage.h>
#include <i386/ibcs2/ibcs2_socksys.h>
#include <i386/ibcs2/ibcs2_util.h>
@@ -178,13 +179,13 @@ ibcs2_setipdomainname(td, uap)
/* W/out a hostname a domain-name is nonsense */
mtx_lock(&hostname_mtx);
- if ( strlen(hostname) == 0 ) {
+ if ( strlen(V_hostname) == 0 ) {
mtx_unlock(&hostname_mtx);
return EINVAL;
}
/* Get the host's unqualified name (strip off the domain) */
- snprintf(hname, sizeof(hname), "%s", hostname);
+ snprintf(hname, sizeof(hname), "%s", V_hostname);
mtx_unlock(&hostname_mtx);
ptr = index(hname, '.');
if ( ptr != NULL ) {
diff --git a/sys/ia64/ia64/dump_machdep.c b/sys/ia64/ia64/dump_machdep.c
index bc84c49..a2dfe45 100644
--- a/sys/ia64/ia64/dump_machdep.c
+++ b/sys/ia64/ia64/dump_machdep.c
@@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$");
#include <sys/cons.h>
#include <sys/kernel.h>
#include <sys/kerneldump.h>
+#include <sys/vimage.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <machine/efi.h>
@@ -73,7 +74,7 @@ mkdumpheader(struct kerneldumpheader *kdh, uint32_t archver, uint64_t dumplen,
kdh->dumplength = htod64(dumplen);
kdh->dumptime = htod64(time_second);
kdh->blocksize = htod32(blksz);
- strncpy(kdh->hostname, hostname, sizeof(kdh->hostname));
+ strncpy(kdh->hostname, G_hostname, sizeof(kdh->hostname));
strncpy(kdh->versionstring, version, sizeof(kdh->versionstring));
if (panicstr != NULL)
strncpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring));
diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c
index b9efe24..a1ba436 100644
--- a/sys/kern/kern_jail.c
+++ b/sys/kern/kern_jail.c
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
#include <sys/syscallsubr.h>
#include <sys/sysctl.h>
#include <sys/vnode.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <netinet/in.h>
@@ -481,7 +482,7 @@ getcredhostname(struct ucred *cred, char *buf, size_t size)
mtx_unlock(&cred->cr_prison->pr_mtx);
} else {
mtx_lock(&hostname_mtx);
- strlcpy(buf, hostname, size);
+ strlcpy(buf, V_hostname, size);
mtx_unlock(&hostname_mtx);
}
}
diff --git a/sys/kern/kern_mib.c b/sys/kern/kern_mib.c
index e178ce6..e7a1333 100644
--- a/sys/kern/kern_mib.c
+++ b/sys/kern/kern_mib.c
@@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
#include <sys/jail.h>
#include <sys/smp.h>
#include <sys/unistd.h>
+#include <sys/vimage.h>
SYSCTL_NODE(, 0, sysctl, CTLFLAG_RW, 0,
"Sysctl internal magic");
@@ -249,13 +250,13 @@ sysctl_hostname(SYSCTL_HANDLER_ARGS)
}
} else {
mtx_lock(&hostname_mtx);
- bcopy(hostname, tmphostname, MAXHOSTNAMELEN);
+ bcopy(V_hostname, tmphostname, MAXHOSTNAMELEN);
mtx_unlock(&hostname_mtx);
error = sysctl_handle_string(oidp, tmphostname,
sizeof tmphostname, req);
if (req->newptr != NULL && error == 0) {
mtx_lock(&hostname_mtx);
- bcopy(tmphostname, hostname, MAXHOSTNAMELEN);
+ bcopy(tmphostname, V_hostname, MAXHOSTNAMELEN);
mtx_unlock(&hostname_mtx);
}
}
diff --git a/sys/kern/kern_poll.c b/sys/kern/kern_poll.c
index 64fa7af..2bd1550 100644
--- a/sys/kern/kern_poll.c
+++ b/sys/kern/kern_poll.c
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
#include <sys/proc.h>
#include <sys/resourcevar.h>
#include <sys/kthread.h>
+#include <sys/vimage.h>
static void netisr_poll(void); /* the two netisr handlers */
static void netisr_pollmore(void);
@@ -537,7 +538,7 @@ poll_switch(SYSCTL_HANDLER_ARGS)
polling = val;
IFNET_RLOCK();
- TAILQ_FOREACH(ifp, &ifnet, if_link) {
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
if (ifp->if_capabilities & IFCAP_POLLING) {
struct ifreq ifr;
diff --git a/sys/kern/kern_uuid.c b/sys/kern/kern_uuid.c
index 8613b18..61e9ce9 100644
--- a/sys/kern/kern_uuid.c
+++ b/sys/kern/kern_uuid.c
@@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sysproto.h>
#include <sys/systm.h>
#include <sys/uuid.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_dl.h>
@@ -93,7 +94,7 @@ uuid_node(uint16_t *node)
int i;
IFNET_RLOCK();
- TAILQ_FOREACH(ifp, &ifnet, if_link) {
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
/* Walk the address list */
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
sdl = (struct sockaddr_dl*)ifa->ifa_addr;
diff --git a/sys/kern/kern_xxx.c b/sys/kern/kern_xxx.c
index 0a4f42d..9a30d17 100644
--- a/sys/kern/kern_xxx.c
+++ b/sys/kern/kern_xxx.c
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
#include <sys/mutex.h>
#include <sys/sysctl.h>
#include <sys/utsname.h>
+#include <sys/vimage.h>
#if defined(COMPAT_43)
@@ -249,7 +250,7 @@ getdomainname(td, uap)
int domainnamelen;
mtx_lock(&hostname_mtx);
- bcopy(domainname, tmpdomainname, sizeof(tmpdomainname));
+ bcopy(V_domainname, tmpdomainname, sizeof(tmpdomainname));
mtx_unlock(&hostname_mtx);
domainnamelen = strlen(tmpdomainname) + 1;
@@ -283,7 +284,7 @@ setdomainname(td, uap)
if (error == 0) {
tmpdomainname[domainnamelen] = 0;
mtx_lock(&hostname_mtx);
- bcopy(tmpdomainname, domainname, sizeof(domainname));
+ bcopy(tmpdomainname, V_domainname, sizeof(domainname));
mtx_unlock(&hostname_mtx);
}
return (error);
diff --git a/sys/net/bridgestp.c b/sys/net/bridgestp.c
index 993318a..aa9671e 100644
--- a/sys/net/bridgestp.c
+++ b/sys/net/bridgestp.c
@@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$");
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/taskqueue.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_dl.h>
@@ -2031,7 +2032,7 @@ bstp_reinit(struct bstp_state *bs)
* value.
*/
IFNET_RLOCK();
- TAILQ_FOREACH(ifp, &ifnet, if_link) {
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
if (ifp->if_type != IFT_ETHER)
continue;
diff --git a/sys/net/if.c b/sys/net/if.c
index afc8243..a3ef17d 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -56,6 +56,7 @@
#include <sys/taskqueue.h>
#include <sys/domain.h>
#include <sys/jail.h>
+#include <sys/vimage.h>
#include <machine/stdarg.h>
#include <net/if.h>
@@ -170,7 +171,7 @@ ifnet_byindex(u_short idx)
struct ifnet *ifp;
IFNET_RLOCK();
- ifp = ifindex_table[idx].ife_ifnet;
+ ifp = V_ifindex_table[idx].ife_ifnet;
IFNET_RUNLOCK();
return (ifp);
}
@@ -181,7 +182,7 @@ ifnet_setbyindex(u_short idx, struct ifnet *ifp)
IFNET_WLOCK_ASSERT();
- ifindex_table[idx].ife_ifnet = ifp;
+ V_ifindex_table[idx].ife_ifnet = ifp;
}
struct ifaddr *
@@ -201,7 +202,7 @@ ifdev_byindex(u_short idx)
struct cdev *cdev;
IFNET_RLOCK();
- cdev = ifindex_table[idx].ife_dev;
+ cdev = V_ifindex_table[idx].ife_dev;
IFNET_RUNLOCK();
return (cdev);
}
@@ -211,7 +212,7 @@ ifdev_setbyindex(u_short idx, struct cdev *cdev)
{
IFNET_WLOCK();
- ifindex_table[idx].ife_dev = cdev;
+ V_ifindex_table[idx].ife_dev = cdev;
IFNET_WUNLOCK();
}
@@ -292,7 +293,7 @@ netkqfilter(struct cdev *dev, struct knote *kn)
idx = minor(dev);
if (idx == 0) {
- klist = &ifklist;
+ klist = &V_ifklist;
} else {
ifp = ifnet_byindex(idx);
if (ifp == NULL)
@@ -349,9 +350,9 @@ if_init(void *dummy __unused)
{
IFNET_LOCK_INIT();
- TAILQ_INIT(&ifnet);
- TAILQ_INIT(&ifg_head);
- knlist_init(&ifklist, NULL, NULL, NULL, NULL);
+ TAILQ_INIT(&V_ifnet);
+ TAILQ_INIT(&V_ifg_head);
+ knlist_init(&V_ifklist, NULL, NULL, NULL, NULL);
if_grow(); /* create initial table */
ifdev_setbyindex(0, make_dev(&net_cdevsw, 0, UID_ROOT, GID_WHEEL,
0600, "network"));
@@ -364,14 +365,14 @@ if_grow(void)
u_int n;
struct ifindex_entry *e;
- if_indexlim <<= 1;
- n = if_indexlim * sizeof(*e);
+ V_if_indexlim <<= 1;
+ n = V_if_indexlim * sizeof(*e);
e = malloc(n, M_IFNET, M_WAITOK | M_ZERO);
- if (ifindex_table != NULL) {
- memcpy((caddr_t)e, (caddr_t)ifindex_table, n/2);
- free((caddr_t)ifindex_table, M_IFNET);
+ if (V_ifindex_table != NULL) {
+ memcpy((caddr_t)e, (caddr_t)V_ifindex_table, n/2);
+ free((caddr_t)V_ifindex_table, M_IFNET);
}
- ifindex_table = e;
+ V_ifindex_table = e;
}
/*
@@ -392,7 +393,7 @@ if_alloc(u_char type)
*
* XXX: should be locked!
*/
- for (ifp->if_index = 1; ifp->if_index <= if_index; ifp->if_index++) {
+ for (ifp->if_index = 1; ifp->if_index <= V_if_index; ifp->if_index++) {
if (ifnet_byindex(ifp->if_index) == NULL)
break;
}
@@ -401,9 +402,9 @@ if_alloc(u_char type)
free(ifp, M_IFNET);
return (NULL);
}
- if (ifp->if_index > if_index)
- if_index = ifp->if_index;
- if (if_index >= if_indexlim)
+ if (ifp->if_index > V_if_index)
+ V_if_index = ifp->if_index;
+ if (V_if_index >= V_if_indexlim)
if_grow();
ifp->if_type = type;
@@ -455,8 +456,8 @@ if_free_type(struct ifnet *ifp, u_char type)
ifnet_setbyindex(ifp->if_index, NULL);
/* XXX: should be locked with if_findindex() */
- while (if_index > 0 && ifnet_byindex(if_index) == NULL)
- if_index--;
+ while (V_if_index > 0 && ifnet_byindex(V_if_index) == NULL)
+ V_if_index--;
IFNET_WUNLOCK();
if (if_com_free[type] != NULL)
@@ -571,7 +572,7 @@ if_attach(struct ifnet *ifp)
ifp->if_snd.altq_ifp = ifp;
IFNET_WLOCK();
- TAILQ_INSERT_TAIL(&ifnet, ifp, if_link);
+ TAILQ_INSERT_TAIL(&V_ifnet, ifp, if_link);
IFNET_WUNLOCK();
if (domain_init_status >= 2)
@@ -598,7 +599,7 @@ if_attachdomain(void *dummy)
int s;
s = splnet();
- TAILQ_FOREACH(ifp, &ifnet, if_link)
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link)
if_attachdomain1(ifp);
splx(s);
}
@@ -713,9 +714,9 @@ if_detach(struct ifnet *ifp)
int found = 0;
IFNET_WLOCK();
- TAILQ_FOREACH(iter, &ifnet, if_link)
+ TAILQ_FOREACH(iter, &V_ifnet, if_link)
if (iter == ifp) {
- TAILQ_REMOVE(&ifnet, ifp, if_link);
+ TAILQ_REMOVE(&V_ifnet, ifp, if_link);
found = 1;
break;
}
@@ -781,7 +782,7 @@ if_detach(struct ifnet *ifp)
for (i = 1; i <= AF_MAX; i++) {
int j;
for (j = 0; j < rt_numfibs; j++) {
- if ((rnh = rt_tables[j][i]) == NULL)
+ if ((rnh = V_rt_tables[j][i]) == NULL)
continue;
RADIX_NODE_HEAD_LOCK(rnh);
(void) rnh->rnh_walktree(rnh, if_rtdel, ifp);
@@ -847,7 +848,7 @@ if_addgroup(struct ifnet *ifp, const char *groupname)
return (ENOMEM);
}
- TAILQ_FOREACH(ifg, &ifg_head, ifg_next)
+ TAILQ_FOREACH(ifg, &V_ifg_head, ifg_next)
if (!strcmp(ifg->ifg_group, groupname))
break;
@@ -863,7 +864,7 @@ if_addgroup(struct ifnet *ifp, const char *groupname)
ifg->ifg_refcnt = 0;
TAILQ_INIT(&ifg->ifg_members);
EVENTHANDLER_INVOKE(group_attach_event, ifg);
- TAILQ_INSERT_TAIL(&ifg_head, ifg, ifg_next);
+ TAILQ_INSERT_TAIL(&V_ifg_head, ifg, ifg_next);
}
ifg->ifg_refcnt++;
@@ -914,7 +915,7 @@ if_delgroup(struct ifnet *ifp, const char *groupname)
}
if (--ifgl->ifgl_group->ifg_refcnt == 0) {
- TAILQ_REMOVE(&ifg_head, ifgl->ifgl_group, ifg_next);
+ TAILQ_REMOVE(&V_ifg_head, ifgl->ifgl_group, ifg_next);
EVENTHANDLER_INVOKE(group_detach_event, ifgl->ifgl_group);
free(ifgl->ifgl_group, M_TEMP);
}
@@ -984,7 +985,7 @@ if_getgroupmembers(struct ifgroupreq *data)
int len, error;
IFNET_RLOCK();
- TAILQ_FOREACH(ifg, &ifg_head, ifg_next)
+ TAILQ_FOREACH(ifg, &V_ifg_head, ifg_next)
if (!strcmp(ifg->ifg_group, ifgr->ifgr_name))
break;
if (ifg == NULL) {
@@ -1090,7 +1091,7 @@ ifa_ifwithaddr(struct sockaddr *addr)
struct ifaddr *ifa;
IFNET_RLOCK();
- TAILQ_FOREACH(ifp, &ifnet, if_link)
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link)
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
if (ifa->ifa_addr->sa_family != addr->sa_family)
continue;
@@ -1120,7 +1121,7 @@ ifa_ifwithbroadaddr(struct sockaddr *addr)
struct ifaddr *ifa;
IFNET_RLOCK();
- TAILQ_FOREACH(ifp, &ifnet, if_link)
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link)
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
if (ifa->ifa_addr->sa_family != addr->sa_family)
continue;
@@ -1147,7 +1148,7 @@ ifa_ifwithdstaddr(struct sockaddr *addr)
struct ifaddr *ifa;
IFNET_RLOCK();
- TAILQ_FOREACH(ifp, &ifnet, if_link) {
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
if ((ifp->if_flags & IFF_POINTOPOINT) == 0)
continue;
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
@@ -1183,7 +1184,7 @@ ifa_ifwithnet(struct sockaddr *addr)
*/
if (af == AF_LINK) {
struct sockaddr_dl *sdl = (struct sockaddr_dl *)addr;
- if (sdl->sdl_index && sdl->sdl_index <= if_index)
+ if (sdl->sdl_index && sdl->sdl_index <= V_if_index)
return (ifaddr_byindex(sdl->sdl_index));
}
@@ -1192,7 +1193,7 @@ ifa_ifwithnet(struct sockaddr *addr)
* addresses in this address family.
*/
IFNET_RLOCK();
- TAILQ_FOREACH(ifp, &ifnet, if_link) {
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
char *cp, *cp2, *cp3;
@@ -1516,7 +1517,7 @@ if_slowtimo(void *arg)
int s = splimp();
IFNET_RLOCK();
- TAILQ_FOREACH(ifp, &ifnet, if_link) {
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
if (ifp->if_timer == 0 || --ifp->if_timer)
continue;
if (ifp->if_watchdog)
@@ -1537,7 +1538,7 @@ ifunit(const char *name)
struct ifnet *ifp;
IFNET_RLOCK();
- TAILQ_FOREACH(ifp, &ifnet, if_link) {
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
if (strncmp(name, ifp->if_xname, IFNAMSIZ) == 0)
break;
}
@@ -2141,7 +2142,7 @@ again:
valid_len = 0;
IFNET_RLOCK(); /* could sleep XXX */
- TAILQ_FOREACH(ifp, &ifnet, if_link) {
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
int addrs;
/*
@@ -2467,7 +2468,7 @@ if_delmulti(struct ifnet *ifp, struct sockaddr *sa)
struct ifnet *oifp;
IFNET_RLOCK();
- TAILQ_FOREACH(oifp, &ifnet, if_link)
+ TAILQ_FOREACH(oifp, &V_ifnet, if_link)
if (ifp == oifp)
break;
if (ifp != oifp)
@@ -2520,7 +2521,7 @@ if_delmulti_ifma(struct ifmultiaddr *ifma)
struct ifnet *oifp;
IFNET_RLOCK();
- TAILQ_FOREACH(oifp, &ifnet, if_link)
+ TAILQ_FOREACH(oifp, &V_ifnet, if_link)
if (ifp == oifp)
break;
if (ifp != oifp) {
diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c
index 35e019a..88eda1d 100644
--- a/sys/net/if_bridge.c
+++ b/sys/net/if_bridge.c
@@ -100,6 +100,7 @@ __FBSDID("$FreeBSD$");
#include <sys/proc.h>
#include <sys/lock.h>
#include <sys/mutex.h>
+#include <sys/vimage.h>
#include <net/bpf.h>
#include <net/if.h>
@@ -3035,7 +3036,7 @@ bridge_pfil(struct mbuf **mp, struct ifnet *bifp, struct ifnet *ifp, int dir)
if (IPFW_LOADED && pfil_ipfw != 0 && dir == PFIL_OUT && ifp != NULL) {
error = -1;
args.rule = ip_dn_claim_rule(*mp);
- if (args.rule != NULL && fw_one_pass)
+ if (args.rule != NULL && V_fw_one_pass)
goto ipfwpass; /* packet already partially processed */
args.m = *mp;
@@ -3229,12 +3230,12 @@ bridge_ip_checkbasic(struct mbuf **mp)
if ((m = m_copyup(m, sizeof(struct ip),
(max_linkhdr + 3) & ~3)) == NULL) {
/* XXXJRT new stat, please */
- ipstat.ips_toosmall++;
+ V_ipstat.ips_toosmall++;
goto bad;
}
} else if (__predict_false(m->m_len < sizeof (struct ip))) {
if ((m = m_pullup(m, sizeof (struct ip))) == NULL) {
- ipstat.ips_toosmall++;
+ V_ipstat.ips_toosmall++;
goto bad;
}
}
@@ -3242,17 +3243,17 @@ bridge_ip_checkbasic(struct mbuf **mp)
if (ip == NULL) goto bad;
if (ip->ip_v != IPVERSION) {
- ipstat.ips_badvers++;
+ V_ipstat.ips_badvers++;
goto bad;
}
hlen = ip->ip_hl << 2;
if (hlen < sizeof(struct ip)) { /* minimum header length */
- ipstat.ips_badhlen++;
+ V_ipstat.ips_badhlen++;
goto bad;
}
if (hlen > m->m_len) {
if ((m = m_pullup(m, hlen)) == 0) {
- ipstat.ips_badhlen++;
+ V_ipstat.ips_badhlen++;
goto bad;
}
ip = mtod(m, struct ip *);
@@ -3269,7 +3270,7 @@ bridge_ip_checkbasic(struct mbuf **mp)
}
}
if (sum) {
- ipstat.ips_badsum++;
+ V_ipstat.ips_badsum++;
goto bad;
}
@@ -3280,7 +3281,7 @@ bridge_ip_checkbasic(struct mbuf **mp)
* Check for additional length bogosity
*/
if (len < hlen) {
- ipstat.ips_badlen++;
+ V_ipstat.ips_badlen++;
goto bad;
}
@@ -3290,7 +3291,7 @@ bridge_ip_checkbasic(struct mbuf **mp)
* Drop packet if shorter than we expect.
*/
if (m->m_pkthdr.len < len) {
- ipstat.ips_tooshort++;
+ V_ipstat.ips_tooshort++;
goto bad;
}
@@ -3326,14 +3327,14 @@ bridge_ip6_checkbasic(struct mbuf **mp)
if ((m = m_copyup(m, sizeof(struct ip6_hdr),
(max_linkhdr + 3) & ~3)) == NULL) {
/* XXXJRT new stat, please */
- ip6stat.ip6s_toosmall++;
+ V_ip6stat.ip6s_toosmall++;
in6_ifstat_inc(inifp, ifs6_in_hdrerr);
goto bad;
}
} else if (__predict_false(m->m_len < sizeof(struct ip6_hdr))) {
struct ifnet *inifp = m->m_pkthdr.rcvif;
if ((m = m_pullup(m, sizeof(struct ip6_hdr))) == NULL) {
- ip6stat.ip6s_toosmall++;
+ V_ip6stat.ip6s_toosmall++;
in6_ifstat_inc(inifp, ifs6_in_hdrerr);
goto bad;
}
@@ -3342,7 +3343,7 @@ bridge_ip6_checkbasic(struct mbuf **mp)
ip6 = mtod(m, struct ip6_hdr *);
if ((ip6->ip6_vfc & IPV6_VERSION_MASK) != IPV6_VERSION) {
- ip6stat.ip6s_badvers++;
+ V_ip6stat.ip6s_badvers++;
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_hdrerr);
goto bad;
}
@@ -3403,7 +3404,7 @@ bridge_fragment(struct ifnet *ifp, struct mbuf *m, struct ether_header *eh,
}
if (error == 0)
- ipstat.ips_fragmented++;
+ V_ipstat.ips_fragmented++;
return (error);
diff --git a/sys/net/if_ef.c b/sys/net/if_ef.c
index cf12fab..c60e615 100644
--- a/sys/net/if_ef.c
+++ b/sys/net/if_ef.c
@@ -39,6 +39,7 @@
#include <sys/syslog.h>
#include <sys/kernel.h>
#include <sys/module.h>
+#include <sys/vimage.h>
#include <net/ethernet.h>
#include <net/if_llc.h>
@@ -489,7 +490,7 @@ ef_load(void)
int error = 0, d;
IFNET_RLOCK();
- TAILQ_FOREACH(ifp, &ifnet, if_link) {
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
if (ifp->if_type != IFT_ETHER) continue;
EFDEBUG("Found interface %s\n", ifp->if_xname);
efl = (struct ef_link*)malloc(sizeof(struct ef_link),
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index c4edca6..25004b4 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -49,6 +49,7 @@
#include <sys/socket.h>
#include <sys/sockio.h>
#include <sys/sysctl.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_arp.h>
@@ -389,7 +390,7 @@ ether_output_frame(struct ifnet *ifp, struct mbuf *m)
#if defined(INET) || defined(INET6)
struct ip_fw *rule = ip_dn_claim_rule(m);
- if (IPFW_LOADED && ether_ipfw != 0) {
+ if (IPFW_LOADED && V_ether_ipfw != 0) {
if (ether_ipfw_chk(&m, ifp, &rule, 0) == 0) {
if (m) {
m_freem(m);
@@ -424,7 +425,7 @@ ether_ipfw_chk(struct mbuf **m0, struct ifnet *dst,
int i;
struct ip_fw_args args;
- if (*rule != NULL && fw_one_pass)
+ if (*rule != NULL && V_fw_one_pass)
return 1; /* dummynet packet, already partially processed */
/*
@@ -714,7 +715,7 @@ ether_demux(struct ifnet *ifp, struct mbuf *m)
* Allow dummynet and/or ipfw to claim the frame.
* Do not do this for PROMISC frames in case we are re-entered.
*/
- if (IPFW_LOADED && ether_ipfw != 0 && !(m->m_flags & M_PROMISC)) {
+ if (IPFW_LOADED && V_ether_ipfw != 0 && !(m->m_flags & M_PROMISC)) {
struct ip_fw *rule = ip_dn_claim_rule(m);
if (ether_ipfw_chk(&m, NULL, &rule, 0) == 0) {
diff --git a/sys/net/if_faith.c b/sys/net/if_faith.c
index 2b0f30e..6388820 100644
--- a/sys/net/if_faith.c
+++ b/sys/net/if_faith.c
@@ -54,6 +54,7 @@
#include <sys/queue.h>
#include <sys/types.h>
#include <sys/malloc.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_clone.h>
@@ -327,7 +328,7 @@ faithprefix(in6)
struct sockaddr_in6 sin6;
int ret;
- if (ip6_keepfaith == 0)
+ if (V_ip6_keepfaith == 0)
return 0;
bzero(&sin6, sizeof(sin6));
diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c
index 8310881..685f282 100644
--- a/sys/net/if_gif.c
+++ b/sys/net/if_gif.c
@@ -49,6 +49,7 @@
#include <sys/proc.h>
#include <sys/protosw.h>
#include <sys/conf.h>
+#include <sys/vimage.h>
#include <machine/cpu.h>
#include <net/if.h>
@@ -187,7 +188,7 @@ gif_clone_create(ifc, unit, params)
(*ng_gif_attach_p)(GIF2IFP(sc));
mtx_lock(&gif_mtx);
- LIST_INSERT_HEAD(&gif_softc_list, sc, gif_list);
+ LIST_INSERT_HEAD(&V_gif_softc_list, sc, gif_list);
mtx_unlock(&gif_mtx);
return (0);
@@ -239,11 +240,11 @@ gifmodevent(mod, type, data)
switch (type) {
case MOD_LOAD:
mtx_init(&gif_mtx, "gif_mtx", NULL, MTX_DEF);
- LIST_INIT(&gif_softc_list);
+ LIST_INIT(&V_gif_softc_list);
if_clone_attach(&gif_cloner);
#ifdef INET6
- ip6_gif_hlim = GIF_HLIM;
+ V_ip6_gif_hlim = GIF_HLIM;
#endif
break;
@@ -251,7 +252,7 @@ gifmodevent(mod, type, data)
if_clone_detach(&gif_cloner);
mtx_destroy(&gif_mtx);
#ifdef INET6
- ip6_gif_hlim = 0;
+ V_ip6_gif_hlim = 0;
#endif
break;
default:
@@ -398,7 +399,7 @@ gif_output(ifp, m, dst, rt)
mtag = m_tag_locate(m, MTAG_GIF, MTAG_GIF_CALLED, mtag);
gif_called++;
}
- if (gif_called > max_gif_nesting) {
+ if (gif_called > V_max_gif_nesting) {
log(LOG_NOTICE,
"gif_output: recursively called too many times(%d)\n",
gif_called);
@@ -859,7 +860,7 @@ gif_set_tunnel(ifp, src, dst)
int error = 0;
mtx_lock(&gif_mtx);
- LIST_FOREACH(sc2, &gif_softc_list, gif_list) {
+ LIST_FOREACH(sc2, &V_gif_softc_list, gif_list) {
if (sc2 == sc)
continue;
if (!sc2->gif_pdst || !sc2->gif_psrc)
@@ -874,7 +875,7 @@ gif_set_tunnel(ifp, src, dst)
* Disallow parallel tunnels unless instructed
* otherwise.
*/
- if (!parallel_tunnels &&
+ if (!V_parallel_tunnels &&
bcmp(sc2->gif_pdst, dst, dst->sa_len) == 0 &&
bcmp(sc2->gif_psrc, src, src->sa_len) == 0) {
error = EADDRNOTAVAIL;
diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c
index ea41517..eebae0c 100644
--- a/sys/net/if_loop.c
+++ b/sys/net/if_loop.c
@@ -49,6 +49,7 @@
#include <sys/socket.h>
#include <sys/sockio.h>
#include <sys/sysctl.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_clone.h>
@@ -104,7 +105,7 @@ lo_clone_destroy(struct ifnet *ifp)
{
/* XXX: destroying lo0 will lead to panics. */
- KASSERT(loif != ifp, ("%s: destroying lo0", __func__));
+ KASSERT(V_loif != ifp, ("%s: destroying lo0", __func__));
bpfdetach(ifp);
if_detach(ifp);
@@ -128,8 +129,8 @@ lo_clone_create(struct if_clone *ifc, int unit, caddr_t params)
ifp->if_snd.ifq_maxlen = ifqmaxlen;
if_attach(ifp);
bpfattach(ifp, DLT_NULL, sizeof(u_int32_t));
- if (loif == NULL)
- loif = ifp;
+ if (V_loif == NULL)
+ V_loif = ifp;
return (0);
}
@@ -234,15 +235,15 @@ if_simloop(struct ifnet *ifp, struct mbuf *m, int af, int hlen)
bpf_mtap(ifp->if_bpf, m);
}
} else {
- if (bpf_peers_present(loif->if_bpf)) {
- if ((m->m_flags & M_MCAST) == 0 || loif == ifp) {
+ if (bpf_peers_present(V_loif->if_bpf)) {
+ if ((m->m_flags & M_MCAST) == 0 || V_loif == ifp) {
/* XXX beware sizeof(af) != 4 */
u_int32_t af1 = af;
/*
* We need to prepend the address family.
*/
- bpf_mtap2(loif->if_bpf, &af1, sizeof(af1), m);
+ bpf_mtap2(V_loif->if_bpf, &af1, sizeof(af1), m);
}
}
}
diff --git a/sys/net/if_mib.c b/sys/net/if_mib.c
index dc2b8e1..8c472c1 100644
--- a/sys/net/if_mib.c
+++ b/sys/net/if_mib.c
@@ -34,6 +34,7 @@
#include <sys/kernel.h>
#include <sys/socket.h>
#include <sys/sysctl.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_mib.h>
@@ -81,7 +82,7 @@ sysctl_ifdata(SYSCTL_HANDLER_ARGS) /* XXX bad syntax! */
if (namelen != 2)
return EINVAL;
- if (name[0] <= 0 || name[0] > if_index ||
+ if (name[0] <= 0 || name[0] > V_if_index ||
ifnet_byindex(name[0]) == NULL)
return ENOENT;
diff --git a/sys/net/if_spppsubr.c b/sys/net/if_spppsubr.c
index 9d82399..cde005c 100644
--- a/sys/net/if_spppsubr.c
+++ b/sys/net/if_spppsubr.c
@@ -48,6 +48,7 @@
#endif
#include <sys/malloc.h>
#include <sys/mbuf.h>
+#include <sys/vimage.h>
#if defined (__OpenBSD__)
#include <sys/md5k.h>
diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c
index f373eaa..bc644e9 100644
--- a/sys/net/if_stf.c
+++ b/sys/net/if_stf.c
@@ -92,6 +92,7 @@
#include <machine/cpu.h>
#include <sys/malloc.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_clone.h>
@@ -582,7 +583,7 @@ stf_checkaddr4(sc, in, inifp)
/*
* reject packets with broadcast
*/
- for (ia4 = TAILQ_FIRST(&in_ifaddrhead);
+ for (ia4 = TAILQ_FIRST(&V_in_ifaddrhead);
ia4;
ia4 = TAILQ_NEXT(ia4, ia_link))
{
diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c
index d3bf622..439d14a 100644
--- a/sys/net/if_vlan.c
+++ b/sys/net/if_vlan.c
@@ -55,6 +55,7 @@
#include <sys/sockio.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
+#include <sys/vimage.h>
#include <net/bpf.h>
#include <net/ethernet.h>
@@ -578,7 +579,7 @@ vlan_clone_match_ethertag(struct if_clone *ifc, const char *name, int *tag)
/* Check for <etherif>.<vlan> style interface names. */
IFNET_RLOCK();
- TAILQ_FOREACH(ifp, &ifnet, if_link) {
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
if (ifp->if_type != IFT_ETHER)
continue;
if (strncmp(ifp->if_xname, name, strlen(ifp->if_xname)) != 0)
diff --git a/sys/net/raw_cb.c b/sys/net/raw_cb.c
index 38d090c..ee8628c 100644
--- a/sys/net/raw_cb.c
+++ b/sys/net/raw_cb.c
@@ -42,6 +42,7 @@
#include <sys/socketvar.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
+#include <sys/vimage.h>
#include <net/raw_cb.h>
@@ -92,7 +93,7 @@ raw_attach(struct socket *so, int proto)
rp->rcb_proto.sp_family = so->so_proto->pr_domain->dom_family;
rp->rcb_proto.sp_protocol = proto;
mtx_lock(&rawcb_mtx);
- LIST_INSERT_HEAD(&rawcb_list, rp, list);
+ LIST_INSERT_HEAD(&V_rawcb_list, rp, list);
mtx_unlock(&rawcb_mtx);
return (0);
}
diff --git a/sys/net/raw_usrreq.c b/sys/net/raw_usrreq.c
index 47afb4f..09752fc 100644
--- a/sys/net/raw_usrreq.c
+++ b/sys/net/raw_usrreq.c
@@ -44,6 +44,7 @@
#include <sys/socketvar.h>
#include <sys/sx.h>
#include <sys/systm.h>
+#include <sys/vimage.h>
#include <net/raw_cb.h>
@@ -56,7 +57,7 @@ void
raw_init(void)
{
- LIST_INIT(&rawcb_list);
+ LIST_INIT(&V_rawcb_list);
}
/*
@@ -75,7 +76,7 @@ raw_input(struct mbuf *m0, struct sockproto *proto, struct sockaddr *src)
last = 0;
mtx_lock(&rawcb_mtx);
- LIST_FOREACH(rp, &rawcb_list, list) {
+ LIST_FOREACH(rp, &V_rawcb_list, list) {
if (rp->rcb_proto.sp_family != proto->sp_family)
continue;
if (rp->rcb_proto.sp_protocol &&
diff --git a/sys/net/route.c b/sys/net/route.c
index 08a70c5..70f218b 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -49,6 +49,7 @@
#include <sys/proc.h>
#include <sys/domain.h>
#include <sys/kernel.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/route.h>
@@ -189,7 +190,7 @@ route_init(void)
* which don't need it anyhow)
*/
dom->dom_rtattach(
- (void **)&rt_tables[table][fam],
+ (void **)&V_rt_tables[table][fam],
dom->dom_rtoffset);
} else {
break;
@@ -287,13 +288,13 @@ rtalloc1_fib(struct sockaddr *dst, int report, u_long ignflags,
KASSERT((fibnum < rt_numfibs), ("rtalloc1_fib: bad fibnum"));
if (dst->sa_family != AF_INET) /* Only INET supports > 1 fib now */
fibnum = 0;
- rnh = rt_tables[fibnum][dst->sa_family];
+ rnh = V_rt_tables[fibnum][dst->sa_family];
newrt = NULL;
/*
* Look up the address in the table for that Address Family
*/
if (rnh == NULL) {
- rtstat.rts_unreach++;
+ V_rtstat.rts_unreach++;
goto miss2;
}
RADIX_NODE_HEAD_LOCK(rnh);
@@ -355,7 +356,7 @@ rtalloc1_fib(struct sockaddr *dst, int report, u_long ignflags,
* Which basically means
* "caint get there frm here"
*/
- rtstat.rts_unreach++;
+ V_rtstat.rts_unreach++;
miss:
RADIX_NODE_HEAD_UNLOCK(rnh);
miss2: if (report) {
@@ -384,7 +385,7 @@ rtfree(struct rtentry *rt)
struct radix_node_head *rnh;
KASSERT(rt != NULL,("%s: NULL rt", __func__));
- rnh = rt_tables[rt->rt_fibnum][rt_key(rt)->sa_family];
+ rnh = V_rt_tables[rt->rt_fibnum][rt_key(rt)->sa_family];
KASSERT(rnh != NULL,("%s: NULL rnh", __func__));
RT_LOCK_ASSERT(rt);
@@ -423,7 +424,7 @@ rtfree(struct rtentry *rt)
* the rtentry must have been removed from the routing table
* so it is represented in rttrash.. remove that now.
*/
- rttrash--;
+ V_rttrash--;
#ifdef DIAGNOSTIC
if (rt->rt_refcnt < 0) {
printf("rtfree: %p not freed (neg refs)\n", rt);
@@ -544,7 +545,7 @@ rtredirect_fib(struct sockaddr *dst,
if (rt0)
RTFREE_LOCKED(rt0);
- stat = &rtstat.rts_dynamic;
+ stat = &V_rtstat.rts_dynamic;
} else {
struct rtentry *gwrt;
@@ -554,7 +555,7 @@ rtredirect_fib(struct sockaddr *dst,
*/
rt->rt_flags |= RTF_MODIFIED;
flags |= RTF_MODIFIED;
- stat = &rtstat.rts_newgateway;
+ stat = &V_rtstat.rts_newgateway;
/*
* add the key and gateway (in one malloc'd chunk).
*/
@@ -570,7 +571,7 @@ done:
RTFREE_LOCKED(rt);
out:
if (error)
- rtstat.rts_badredirect++;
+ V_rtstat.rts_badredirect++;
else if (stat != NULL)
(*stat)++;
bzero((caddr_t)&info, sizeof(info));
@@ -804,7 +805,7 @@ rtexpunge(struct rtentry *rt)
/*
* Find the correct routing tree to use for this Address Family
*/
- rnh = rt_tables[rt->rt_fibnum][rt_key(rt)->sa_family];
+ rnh = V_rt_tables[rt->rt_fibnum][rt_key(rt)->sa_family];
if (rnh == NULL)
return (EAFNOSUPPORT);
@@ -862,7 +863,7 @@ rtexpunge(struct rtentry *rt)
* one more rtentry floating around that is not
* linked to the routing table.
*/
- rttrash++;
+ V_rttrash++;
bad:
RADIX_NODE_HEAD_UNLOCK(rnh);
return (error);
@@ -892,7 +893,7 @@ rtrequest1_fib(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt,
/*
* Find the correct routing tree to use for this Address Family
*/
- rnh = rt_tables[fibnum][dst->sa_family];
+ rnh = V_rt_tables[fibnum][dst->sa_family];
if (rnh == NULL)
return (EAFNOSUPPORT);
RADIX_NODE_HEAD_LOCK(rnh);
@@ -1015,7 +1016,7 @@ deldone:
* linked to the routing table. rttrash will be decremented
* when RTFREE(rt) is eventually called.
*/
- rttrash++;
+ V_rttrash++;
/*
* If the caller wants it, then it can have it,
@@ -1309,7 +1310,7 @@ int
rt_setgate(struct rtentry *rt, struct sockaddr *dst, struct sockaddr *gate)
{
/* XXX dst may be overwritten, can we move this to below */
- struct radix_node_head *rnh = rt_tables[rt->rt_fibnum][dst->sa_family];
+ struct radix_node_head *rnh = V_rt_tables[rt->rt_fibnum][dst->sa_family];
int dlen = SA_SIZE(dst), glen = SA_SIZE(gate);
again:
@@ -1517,7 +1518,7 @@ rtinit1(struct ifaddr *ifa, int cmd, int flags, int fibnum)
* Look up an rtentry that is in the routing tree and
* contains the correct info.
*/
- if ((rnh = rt_tables[fibnum][dst->sa_family]) == NULL)
+ if ((rnh = V_rt_tables[fibnum][dst->sa_family]) == NULL)
/* this table doesn't exist but others might */
continue;
RADIX_NODE_HEAD_LOCK(rnh);
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index 2f2f7cb..34db369 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -46,6 +46,7 @@
#include <sys/socketvar.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/netisr.h>
@@ -413,7 +414,7 @@ route_output(struct mbuf *m, struct socket *so)
case RTM_GET:
case RTM_CHANGE:
case RTM_LOCK:
- rnh = rt_tables[so->so_fibnum][info.rti_info[RTAX_DST]->sa_family];
+ rnh = V_rt_tables[so->so_fibnum][info.rti_info[RTAX_DST]->sa_family];
if (rnh == NULL)
senderr(EAFNOSUPPORT);
RADIX_NODE_HEAD_LOCK(rnh);
@@ -1144,7 +1145,7 @@ sysctl_iflist(int af, struct walkarg *w)
bzero((caddr_t)&info, sizeof(info));
IFNET_RLOCK();
- TAILQ_FOREACH(ifp, &ifnet, if_link) {
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
if (w->w_arg && w->w_arg != ifp->if_index)
continue;
ifa = ifp->if_addr;
@@ -1205,7 +1206,7 @@ sysctl_ifmalist(int af, struct walkarg *w)
bzero((caddr_t)&info, sizeof(info));
IFNET_RLOCK();
- TAILQ_FOREACH(ifp, &ifnet, if_link) {
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
if (w->w_arg && w->w_arg != ifp->if_index)
continue;
ifa = ifp->if_addr;
@@ -1280,7 +1281,7 @@ sysctl_rtsock(SYSCTL_HANDLER_ARGS)
} else /* dump only one table */
i = lim = af;
for (error = 0; error == 0 && i <= lim; i++)
- if ((rnh = rt_tables[curthread->td_proc->p_fibnum][i]) != NULL) {
+ if ((rnh = V_rt_tables[curthread->td_proc->p_fibnum][i]) != NULL) {
RADIX_NODE_HEAD_LOCK(rnh);
error = rnh->rnh_walktree(rnh,
sysctl_dumpentry, &w);
diff --git a/sys/netgraph/atm/ng_atm.c b/sys/netgraph/atm/ng_atm.c
index b8a489e..1378eec 100644
--- a/sys/netgraph/atm/ng_atm.c
+++ b/sys/netgraph/atm/ng_atm.c
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sbuf.h>
#include <sys/ioccom.h>
#include <sys/sysctl.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_types.h>
@@ -1401,7 +1402,7 @@ ng_atm_mod_event(module_t mod, int event, void *data)
ng_atm_event_p = ng_atm_event;
/* Create nodes for existing ATM interfaces */
- TAILQ_FOREACH(ifp, &ifnet, if_link) {
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
if (ifp->if_type == IFT_ATM)
ng_atm_attach(ifp);
}
@@ -1418,7 +1419,7 @@ ng_atm_mod_event(module_t mod, int event, void *data)
ng_atm_input_orphan_p = NULL;
ng_atm_event_p = NULL;
- TAILQ_FOREACH(ifp, &ifnet, if_link) {
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
if (ifp->if_type == IFT_ATM)
ng_atm_detach(ifp);
}
diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c
index 1213273..487fd25 100644
--- a/sys/netgraph/ng_base.c
+++ b/sys/netgraph/ng_base.c
@@ -61,6 +61,7 @@
#include <sys/syslog.h>
#include <sys/refcount.h>
#include <sys/proc.h>
+#include <sys/vimage.h>
#include <machine/cpu.h>
#include <net/netisr.h>
@@ -174,7 +175,7 @@ static struct mtx ng_idhash_mtx;
#define NG_IDHASH_FIND(ID, node) \
do { \
mtx_assert(&ng_idhash_mtx, MA_OWNED); \
- LIST_FOREACH(node, &ng_ID_hash[NG_IDHASH_FN(ID)], \
+ LIST_FOREACH(node, &V_ng_ID_hash[NG_IDHASH_FN(ID)], \
nd_idnodes) { \
if (NG_NODE_IS_VALID(node) \
&& (NG_NODE_ID(node) == ID)) { \
@@ -638,14 +639,14 @@ ng_make_node_common(struct ng_type *type, node_p *nodepp)
/* Link us into the name hash. */
mtx_lock(&ng_namehash_mtx);
- LIST_INSERT_HEAD(&ng_name_hash[0], node, nd_nodes);
+ LIST_INSERT_HEAD(&V_ng_name_hash[0], node, nd_nodes);
mtx_unlock(&ng_namehash_mtx);
/* get an ID and put us in the hash chain */
mtx_lock(&ng_idhash_mtx);
for (;;) { /* wrap protection, even if silly */
node_p node2 = NULL;
- node->nd_ID = nextID++; /* 137/second for 1 year before wrap */
+ node->nd_ID = V_nextID++; /* 137/second for 1 year before wrap */
/* Is there a problem with the new number? */
NG_IDHASH_FIND(node->nd_ID, node2); /* already taken? */
@@ -653,7 +654,7 @@ ng_make_node_common(struct ng_type *type, node_p *nodepp)
break;
}
}
- LIST_INSERT_HEAD(&ng_ID_hash[NG_IDHASH_FN(node->nd_ID)],
+ LIST_INSERT_HEAD(&V_ng_ID_hash[NG_IDHASH_FN(node->nd_ID)],
node, nd_idnodes);
mtx_unlock(&ng_idhash_mtx);
@@ -848,7 +849,7 @@ ng_name_node(node_p node, const char *name)
NG_NAMEHASH(name, hash);
mtx_lock(&ng_namehash_mtx);
LIST_REMOVE(node, nd_nodes);
- LIST_INSERT_HEAD(&ng_name_hash[hash], node, nd_nodes);
+ LIST_INSERT_HEAD(&V_ng_name_hash[hash], node, nd_nodes);
mtx_unlock(&ng_namehash_mtx);
return (0);
@@ -885,7 +886,7 @@ ng_name2noderef(node_p here, const char *name)
/* Find node by name */
NG_NAMEHASH(name, hash);
mtx_lock(&ng_namehash_mtx);
- LIST_FOREACH(node, &ng_name_hash[hash], nd_nodes) {
+ LIST_FOREACH(node, &V_ng_name_hash[hash], nd_nodes) {
if (NG_NODE_IS_VALID(node) &&
(strcmp(NG_NODE_NAME(node), name) == 0)) {
break;
@@ -2574,7 +2575,7 @@ ng_generic_msg(node_p here, item_p item, hook_p lasthook)
mtx_lock(&ng_namehash_mtx);
/* Count number of nodes */
for (i = 0; i < NG_NAME_HASH_SIZE; i++) {
- LIST_FOREACH(node, &ng_name_hash[i], nd_nodes) {
+ LIST_FOREACH(node, &V_ng_name_hash[i], nd_nodes) {
if (NG_NODE_IS_VALID(node) &&
(unnamed || NG_NODE_HAS_NAME(node))) {
num++;
@@ -2596,7 +2597,7 @@ ng_generic_msg(node_p here, item_p item, hook_p lasthook)
nl->numnames = 0;
mtx_lock(&ng_namehash_mtx);
for (i = 0; i < NG_NAME_HASH_SIZE; i++) {
- LIST_FOREACH(node, &ng_name_hash[i], nd_nodes) {
+ LIST_FOREACH(node, &V_ng_name_hash[i], nd_nodes) {
struct nodeinfo *const np =
&nl->nodeinfo[nl->numnames];
diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c
index bc36172..5f9c835 100644
--- a/sys/netgraph/ng_bridge.c
+++ b/sys/netgraph/ng_bridge.c
@@ -67,6 +67,7 @@
#include <sys/syslog.h>
#include <sys/socket.h>
#include <sys/ctype.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/ethernet.h>
@@ -631,7 +632,7 @@ ng_bridge_rcvdata(hook_p hook, item_p item)
/* Run packet through ipfw processing, if enabled */
#if 0
- if (priv->conf.ipfw[linkNum] && fw_enable && ip_fw_chk_ptr != NULL) {
+ if (priv->conf.ipfw[linkNum] && V_fw_enable && ip_fw_chk_ptr != NULL) {
/* XXX not implemented yet */
}
#endif
diff --git a/sys/netgraph/ng_eiface.c b/sys/netgraph/ng_eiface.c
index a47aadd..ae47c75 100644
--- a/sys/netgraph/ng_eiface.c
+++ b/sys/netgraph/ng_eiface.c
@@ -38,6 +38,7 @@
#include <sys/sockio.h>
#include <sys/socket.h>
#include <sys/syslog.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_types.h>
@@ -351,7 +352,7 @@ ng_eiface_constructor(node_p node)
ifp->if_softc = priv;
/* Get an interface unit number */
- priv->unit = alloc_unr(ng_eiface_unit);
+ priv->unit = alloc_unr(V_ng_eiface_unit);
/* Link together node and private info */
NG_NODE_SET_PRIVATE(node, priv);
@@ -549,7 +550,7 @@ ng_eiface_rmnode(node_p node)
ether_ifdetach(ifp);
if_free(ifp);
- free_unr(ng_eiface_unit, priv->unit);
+ free_unr(V_ng_eiface_unit, priv->unit);
FREE(priv, M_NETGRAPH);
NG_NODE_SET_PRIVATE(node, NULL);
NG_NODE_UNREF(node);
@@ -578,10 +579,10 @@ ng_eiface_mod_event(module_t mod, int event, void *data)
switch (event) {
case MOD_LOAD:
- ng_eiface_unit = new_unrhdr(0, 0xffff, NULL);
+ V_ng_eiface_unit = new_unrhdr(0, 0xffff, NULL);
break;
case MOD_UNLOAD:
- delete_unrhdr(ng_eiface_unit);
+ delete_unrhdr(V_ng_eiface_unit);
break;
default:
error = EOPNOTSUPP;
diff --git a/sys/netgraph/ng_ether.c b/sys/netgraph/ng_ether.c
index 8c13c8f..115f3cf 100644
--- a/sys/netgraph/ng_ether.c
+++ b/sys/netgraph/ng_ether.c
@@ -54,6 +54,7 @@
#include <sys/errno.h>
#include <sys/syslog.h>
#include <sys/socket.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_dl.h>
@@ -752,7 +753,7 @@ ng_ether_mod_event(module_t mod, int event, void *data)
/* Create nodes for any already-existing Ethernet interfaces */
IFNET_RLOCK();
- TAILQ_FOREACH(ifp, &ifnet, if_link) {
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
if (ifp->if_type == IFT_ETHER
|| ifp->if_type == IFT_L2VLAN)
ng_ether_attach(ifp);
diff --git a/sys/netgraph/ng_gif.c b/sys/netgraph/ng_gif.c
index 5d948bd..139a50b 100644
--- a/sys/netgraph/ng_gif.c
+++ b/sys/netgraph/ng_gif.c
@@ -77,6 +77,7 @@
#include <sys/errno.h>
#include <sys/syslog.h>
#include <sys/socket.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/route.h>
@@ -560,7 +561,7 @@ ng_gif_mod_event(module_t mod, int event, void *data)
/* Create nodes for any already-existing gif interfaces */
IFNET_RLOCK();
- TAILQ_FOREACH(ifp, &ifnet, if_link) {
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
if (ifp->if_type == IFT_GIF)
ng_gif_attach(ifp);
}
diff --git a/sys/netgraph/ng_iface.c b/sys/netgraph/ng_iface.c
index fec2432..3753adb 100644
--- a/sys/netgraph/ng_iface.c
+++ b/sys/netgraph/ng_iface.c
@@ -69,6 +69,7 @@
#include <sys/socket.h>
#include <sys/syslog.h>
#include <sys/libkern.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_types.h>
@@ -523,7 +524,7 @@ ng_iface_constructor(node_p node)
priv->ifp = ifp;
/* Get an interface unit number */
- priv->unit = alloc_unr(ng_iface_unit);
+ priv->unit = alloc_unr(V_ng_iface_unit);
/* Link together node and private info */
NG_NODE_SET_PRIVATE(node, priv);
@@ -771,7 +772,7 @@ ng_iface_shutdown(node_p node)
if_detach(priv->ifp);
if_free(priv->ifp);
priv->ifp = NULL;
- free_unr(ng_iface_unit, priv->unit);
+ free_unr(V_ng_iface_unit, priv->unit);
FREE(priv, M_NETGRAPH_IFACE);
NG_NODE_SET_PRIVATE(node, NULL);
NG_NODE_UNREF(node);
@@ -804,10 +805,10 @@ ng_iface_mod_event(module_t mod, int event, void *data)
switch (event) {
case MOD_LOAD:
- ng_iface_unit = new_unrhdr(0, 0xffff, NULL);
+ V_ng_iface_unit = new_unrhdr(0, 0xffff, NULL);
break;
case MOD_UNLOAD:
- delete_unrhdr(ng_iface_unit);
+ delete_unrhdr(V_ng_iface_unit);
break;
default:
error = EOPNOTSUPP;
diff --git a/sys/netgraph/ng_source.c b/sys/netgraph/ng_source.c
index dad819a..e27a199 100644
--- a/sys/netgraph/ng_source.c
+++ b/sys/netgraph/ng_source.c
@@ -66,6 +66,7 @@ __FBSDID("$FreeBSD$");
#include <sys/mbuf.h>
#include <sys/socket.h>
#include <sys/syslog.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_var.h>
#include <netgraph/ng_message.h>
@@ -615,7 +616,7 @@ ng_source_store_output_ifp(sc_p sc, char *ifname)
ifp = ifunit(ifname);
if (ifp == NULL) {
- printf("%s: can't find interface %d\n", __func__, if_index);
+ printf("%s: can't find interface %d\n", __func__, V_if_index);
return (EINVAL);
}
sc->output_ifp = ifp;
diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c
index 206cf37..6f489a2 100644
--- a/sys/netinet/if_ether.c
+++ b/sys/netinet/if_ether.c
@@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
#include <sys/malloc.h>
#include <sys/socket.h>
#include <sys/syslog.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_dl.h>
@@ -249,7 +250,7 @@ arp_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info)
}
#endif
- TAILQ_FOREACH(ia, &in_ifaddrhead, ia_link) {
+ TAILQ_FOREACH(ia, &V_in_ifaddrhead, ia_link) {
if (ia->ia_ifp == rt->rt_ifp &&
SIN(rt_key(rt))->sin_addr.s_addr ==
(IA_SIN(ia))->sin_addr.s_addr)
@@ -269,9 +270,9 @@ arp_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info)
rt->rt_expire = 0;
bcopy(IF_LLADDR(rt->rt_ifp), LLADDR(SDL(gate)),
SDL(gate)->sdl_alen = rt->rt_ifp->if_addrlen);
- if (useloopback) {
- rt->rt_ifp = loif;
- rt->rt_rmx.rmx_mtu = loif->if_mtu;
+ if (V_useloopback) {
+ rt->rt_ifp = V_loif;
+ rt->rt_rmx.rmx_mtu = V_loif->if_mtu;
}
/*
@@ -478,7 +479,7 @@ arpresolve(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m,
* if we have already sent arp_maxtries ARP requests. Retransmit the
* ARP request, but not faster than one request per second.
*/
- if (la->la_asked < arp_maxtries)
+ if (la->la_asked < V_arp_maxtries)
error = EWOULDBLOCK; /* First request. */
else
error = (rt == rt0) ? EHOSTDOWN : EHOSTUNREACH;
@@ -657,7 +658,7 @@ in_arpinput(struct mbuf *m)
/*
* If bridging, fall back to using any inet address.
*/
- if (!bridged || (ia = TAILQ_FIRST(&in_ifaddrhead)) == NULL)
+ if (!bridged || (ia = TAILQ_FIRST(&V_in_ifaddrhead)) == NULL)
goto drop;
match:
if (!enaddr)
@@ -826,12 +827,12 @@ match:
}
if (rt->rt_expire) {
- rt->rt_expire = time_uptime + arpt_keep;
- callout_reset(&la->la_timer, hz * arpt_keep,
+ rt->rt_expire = time_uptime + V_arpt_keep;
+ callout_reset(&la->la_timer, hz * V_arpt_keep,
arptimer, rt);
}
la->la_asked = 0;
- la->la_preempt = arp_maxtries;
+ la->la_preempt = V_arp_maxtries;
hold = la->la_hold;
la->la_hold = NULL;
RT_UNLOCK(rt);
@@ -864,7 +865,7 @@ reply:
/* Nope, only intersted now if proxying everything. */
struct sockaddr_in sin;
- if (!arp_proxyall)
+ if (!V_arp_proxyall)
goto drop;
bzero(&sin, sizeof sin);
diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c
index 811307c..54dd41d 100644
--- a/sys/netinet/igmp.c
+++ b/sys/netinet/igmp.c
@@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$");
#include <sys/protosw.h>
#include <sys/kernel.h>
#include <sys/sysctl.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/route.h>
@@ -138,7 +139,7 @@ igmp_init(void)
router_alert->m_len = sizeof(ra->ipopt_dst) + ra->ipopt_list[1];
mtx_init(&igmp_mtx, "igmp_mtx", NULL, MTX_DEF);
- SLIST_INIT(&router_info_head);
+ SLIST_INIT(&V_router_info_head);
}
static struct router_info *
@@ -148,7 +149,7 @@ find_rti(struct ifnet *ifp)
mtx_assert(&igmp_mtx, MA_OWNED);
IGMP_PRINTF("[igmp.c, _find_rti] --> entering \n");
- SLIST_FOREACH(rti, &router_info_head, rti_list) {
+ SLIST_FOREACH(rti, &V_router_info_head, rti_list) {
if (rti->rti_ifp == ifp) {
IGMP_PRINTF(
"[igmp.c, _find_rti] --> found old entry \n");
@@ -163,7 +164,7 @@ find_rti(struct ifnet *ifp)
rti->rti_ifp = ifp;
rti->rti_type = IGMP_V2_ROUTER;
rti->rti_time = 0;
- SLIST_INSERT_HEAD(&router_info_head, rti, rti_list);
+ SLIST_INSERT_HEAD(&V_router_info_head, rti, rti_list);
IGMP_PRINTF("[igmp.c, _find_rti] --> created an entry \n");
return (rti);
}
@@ -183,7 +184,7 @@ igmp_input(register struct mbuf *m, int off)
struct router_info *rti;
int timer; /** timer value in the igmp query header **/
- ++igmpstat.igps_rcv_total;
+ ++V_igmpstat.igps_rcv_total;
ip = mtod(m, struct ip *);
igmplen = ip->ip_len;
@@ -192,14 +193,14 @@ igmp_input(register struct mbuf *m, int off)
* Validate lengths.
*/
if (igmplen < IGMP_MINLEN) {
- ++igmpstat.igps_rcv_tooshort;
+ ++V_igmpstat.igps_rcv_tooshort;
m_freem(m);
return;
}
minlen = iphlen + IGMP_MINLEN;
if ((m->m_flags & M_EXT || m->m_len < minlen) &&
(m = m_pullup(m, minlen)) == 0) {
- ++igmpstat.igps_rcv_tooshort;
+ ++V_igmpstat.igps_rcv_tooshort;
return;
}
@@ -210,7 +211,7 @@ igmp_input(register struct mbuf *m, int off)
m->m_len -= iphlen;
igmp = mtod(m, struct igmp *);
if (in_cksum(m, igmplen)) {
- ++igmpstat.igps_rcv_badsum;
+ ++V_igmpstat.igps_rcv_badsum;
m_freem(m);
return;
}
@@ -235,7 +236,7 @@ igmp_input(register struct mbuf *m, int off)
*/
switch (igmp->igmp_type) {
case IGMP_MEMBERSHIP_QUERY:
- ++igmpstat.igps_rcv_queries;
+ ++V_igmpstat.igps_rcv_queries;
if (ifp->if_flags & IFF_LOOPBACK)
break;
@@ -262,7 +263,7 @@ igmp_input(register struct mbuf *m, int off)
if (ip->ip_dst.s_addr != igmp_all_hosts_group ||
igmp->igmp_group.s_addr != 0) {
- ++igmpstat.igps_rcv_badqueries;
+ ++V_igmpstat.igps_rcv_badqueries;
m_freem(m);
return;
}
@@ -273,7 +274,7 @@ igmp_input(register struct mbuf *m, int off)
if (igmp->igmp_group.s_addr != 0 &&
!IN_MULTICAST(ntohl(igmp->igmp_group.s_addr))) {
- ++igmpstat.igps_rcv_badqueries;
+ ++V_igmpstat.igps_rcv_badqueries;
m_freem(m);
return;
}
@@ -321,13 +322,13 @@ igmp_input(register struct mbuf *m, int off)
ip->ip_src.s_addr == IA_SIN(ia)->sin_addr.s_addr)
break;
- ++igmpstat.igps_rcv_reports;
+ ++V_igmpstat.igps_rcv_reports;
if (ifp->if_flags & IFF_LOOPBACK)
break;
if (!IN_MULTICAST(ntohl(igmp->igmp_group.s_addr))) {
- ++igmpstat.igps_rcv_badreports;
+ ++V_igmpstat.igps_rcv_badreports;
m_freem(m);
return;
}
@@ -354,7 +355,7 @@ igmp_input(register struct mbuf *m, int off)
IN_LOOKUP_MULTI(igmp->igmp_group, ifp, inm);
if (inm != NULL) {
inm->inm_timer = 0;
- ++igmpstat.igps_rcv_ourreports;
+ ++V_igmpstat.igps_rcv_ourreports;
inm->inm_state = IGMP_OTHERMEMBER;
}
IN_MULTI_UNLOCK();
@@ -444,7 +445,7 @@ igmp_slowtimo(void)
IGMP_PRINTF("[igmp.c,_slowtimo] -- > entering \n");
mtx_lock(&igmp_mtx);
- SLIST_FOREACH(rti, &router_info_head, rti_list) {
+ SLIST_FOREACH(rti, &V_router_info_head, rti_list) {
if (rti->rti_type == IGMP_V1_ROUTER) {
rti->rti_time++;
if (rti->rti_time >= IGMP_AGE_THRESHOLD)
@@ -469,7 +470,7 @@ igmp_sendpkt(struct in_multi *inm, int type, unsigned long addr)
if (m == NULL)
return;
- m->m_pkthdr.rcvif = loif;
+ m->m_pkthdr.rcvif = V_loif;
#ifdef MAC
mac_netinet_igmp_send(inm->inm_ifp, m);
#endif
@@ -501,12 +502,12 @@ igmp_sendpkt(struct in_multi *inm, int type, unsigned long addr)
* Request loopback of the report if we are acting as a multicast
* router, so that the process-level routing daemon can hear it.
*/
- imo.imo_multicast_loop = (ip_mrouter != NULL);
+ imo.imo_multicast_loop = (V_ip_mrouter != NULL);
/*
* XXX: Do we have to worry about reentrancy here? Don't think so.
*/
ip_output(m, router_alert, &igmprt, 0, &imo, NULL);
- ++igmpstat.igps_snd_reports;
+ ++V_igmpstat.igps_snd_reports;
}
diff --git a/sys/netinet/in.c b/sys/netinet/in.c
index 4c74b07..1952fff 100644
--- a/sys/netinet/in.c
+++ b/sys/netinet/in.c
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
#include <sys/socket.h>
#include <sys/kernel.h>
#include <sys/sysctl.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_types.h>
@@ -88,12 +89,12 @@ in_localaddr(struct in_addr in)
register u_long i = ntohl(in.s_addr);
register struct in_ifaddr *ia;
- if (subnetsarelocal) {
- TAILQ_FOREACH(ia, &in_ifaddrhead, ia_link)
+ if (V_subnetsarelocal) {
+ TAILQ_FOREACH(ia, &V_in_ifaddrhead, ia_link)
if ((i & ia->ia_netmask) == ia->ia_net)
return (1);
} else {
- TAILQ_FOREACH(ia, &in_ifaddrhead, ia_link)
+ TAILQ_FOREACH(ia, &V_in_ifaddrhead, ia_link)
if ((i & ia->ia_subnetmask) == ia->ia_subnet)
return (1);
}
@@ -328,7 +329,7 @@ in_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp,
}
ia->ia_ifp = ifp;
- TAILQ_INSERT_TAIL(&in_ifaddrhead, ia, ia_link);
+ TAILQ_INSERT_TAIL(&V_in_ifaddrhead, ia, ia_link);
splx(s);
iaIsNew = 1;
}
@@ -492,7 +493,7 @@ in_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp,
*/
s = splnet();
TAILQ_REMOVE(&ifp->if_addrhead, &ia->ia_ifa, ifa_link);
- TAILQ_REMOVE(&in_ifaddrhead, ia, ia_link);
+ TAILQ_REMOVE(&V_in_ifaddrhead, ia, ia_link);
if (ia->ia_addr.sin_family == AF_INET) {
LIST_REMOVE(ia, ia_hash);
/*
@@ -822,7 +823,7 @@ in_addprefix(struct in_ifaddr *target, int flags)
prefix.s_addr &= mask.s_addr;
}
- TAILQ_FOREACH(ia, &in_ifaddrhead, ia_link) {
+ TAILQ_FOREACH(ia, &V_in_ifaddrhead, ia_link) {
if (rtinitflags(ia)) {
p = ia->ia_addr.sin_addr;
@@ -843,7 +844,7 @@ in_addprefix(struct in_ifaddr *target, int flags)
* interface address, we are done here.
*/
if (ia->ia_flags & IFA_ROUTE) {
- if (sameprefixcarponly &&
+ if (V_sameprefixcarponly &&
target->ia_ifp->if_type != IFT_CARP &&
ia->ia_ifp->if_type != IFT_CARP)
return (EEXIST);
@@ -884,7 +885,7 @@ in_scrubprefix(struct in_ifaddr *target)
prefix.s_addr &= mask.s_addr;
}
- TAILQ_FOREACH(ia, &in_ifaddrhead, ia_link) {
+ TAILQ_FOREACH(ia, &V_in_ifaddrhead, ia_link) {
if (rtinitflags(ia))
p = ia->ia_dstaddr.sin_addr;
else {
@@ -983,7 +984,7 @@ in_purgemaddrs(struct ifnet *ifp)
#endif
IFF_LOCKGIANT(ifp);
IN_MULTI_LOCK();
- LIST_FOREACH_SAFE(inm, &in_multihead, inm_link, oinm) {
+ LIST_FOREACH_SAFE(inm, &V_in_multihead, inm_link, oinm) {
if (inm->inm_ifp == ifp)
in_delmulti_locked(inm);
}
@@ -998,7 +999,7 @@ void
in_ifdetach(struct ifnet *ifp)
{
- in_pcbpurgeif0(&ripcbinfo, ifp);
- in_pcbpurgeif0(&udbinfo, ifp);
+ in_pcbpurgeif0(&V_ripcbinfo, ifp);
+ in_pcbpurgeif0(&V_udbinfo, ifp);
in_purgemaddrs(ifp);
}
diff --git a/sys/netinet/in_gif.c b/sys/netinet/in_gif.c
index 55b4ec7..cbbde54 100644
--- a/sys/netinet/in_gif.c
+++ b/sys/netinet/in_gif.c
@@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
#include <sys/protosw.h>
#include <sys/malloc.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/route.h>
@@ -176,7 +177,7 @@ in_gif_output(struct ifnet *ifp, int family, struct mbuf *m)
}
iphdr.ip_p = proto;
/* version will be set in ip_output() */
- iphdr.ip_ttl = ip_gif_ttl;
+ iphdr.ip_ttl = V_ip_gif_ttl;
iphdr.ip_len = m->m_pkthdr.len + sizeof(struct ip);
ip_ecn_ingress((ifp->if_flags & IFF_LINK1) ? ECN_ALLOWED : ECN_NOCARE,
&iphdr.ip_tos, &tos);
@@ -254,14 +255,14 @@ in_gif_input(struct mbuf *m, int off)
sc = (struct gif_softc *)encap_getarg(m);
if (sc == NULL) {
m_freem(m);
- ipstat.ips_nogif++;
+ V_ipstat.ips_nogif++;
return;
}
gifp = GIF2IFP(sc);
if (gifp == NULL || (gifp->if_flags & IFF_UP) == 0) {
m_freem(m);
- ipstat.ips_nogif++;
+ V_ipstat.ips_nogif++;
return;
}
@@ -321,7 +322,7 @@ in_gif_input(struct mbuf *m, int off)
break;
default:
- ipstat.ips_nogif++;
+ V_ipstat.ips_nogif++;
m_freem(m);
return;
}
@@ -354,7 +355,7 @@ gif_validate4(const struct ip *ip, struct gif_softc *sc, struct ifnet *ifp)
return 0;
}
/* reject packets with broadcast on source */
- TAILQ_FOREACH(ia4, &in_ifaddrhead, ia_link) {
+ TAILQ_FOREACH(ia4, &V_in_ifaddrhead, ia_link) {
if ((ia4->ia_ifa.ifa_ifp->if_flags & IFF_BROADCAST) == 0)
continue;
if (ip->ip_src.s_addr == ia4->ia_broadaddr.sin_addr.s_addr)
diff --git a/sys/netinet/in_mcast.c b/sys/netinet/in_mcast.c
index 9f37f33..0aa19a3 100644
--- a/sys/netinet/in_mcast.c
+++ b/sys/netinet/in_mcast.c
@@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/sysctl.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_dl.h>
@@ -371,7 +372,7 @@ in_addmulti(struct in_addr *ap, struct ifnet *ifp)
ninm->inm_ifma = ifma;
ninm->inm_refcount = 1;
ifma->ifma_protospec = ninm;
- LIST_INSERT_HEAD(&in_multihead, ninm, inm_link);
+ LIST_INSERT_HEAD(&V_in_multihead, ninm, inm_link);
igmp_joingroup(ninm);
@@ -530,7 +531,7 @@ inp_change_source_filter(struct inpcb *inp, struct sockopt *sopt)
ssa->sin.sin_len != sizeof(struct sockaddr_in))
return (EINVAL);
- if (gsr.gsr_interface == 0 || if_index < gsr.gsr_interface)
+ if (gsr.gsr_interface == 0 || V_if_index < gsr.gsr_interface)
return (EADDRNOTAVAIL);
ifp = ifnet_byindex(gsr.gsr_interface);
@@ -774,7 +775,7 @@ inp_get_source_filters(struct inpcb *inp, struct sockopt *sopt)
if (error)
return (error);
- if (msfr.msfr_ifindex == 0 || if_index < msfr.msfr_ifindex)
+ if (msfr.msfr_ifindex == 0 || V_if_index < msfr.msfr_ifindex)
return (EINVAL);
ifp = ifnet_byindex(msfr.msfr_ifindex);
@@ -1035,7 +1036,7 @@ inp_join_group(struct inpcb *inp, struct sockopt *sopt)
} else {
struct in_ifaddr *ia;
struct ifnet *mfp = NULL;
- TAILQ_FOREACH(ia, &in_ifaddrhead, ia_link) {
+ TAILQ_FOREACH(ia, &V_in_ifaddrhead, ia_link) {
mfp = ia->ia_ifp;
if (!(mfp->if_flags & IFF_LOOPBACK) &&
(mfp->if_flags & IFF_MULTICAST)) {
@@ -1088,7 +1089,7 @@ inp_join_group(struct inpcb *inp, struct sockopt *sopt)
/*
* Obtain the ifp.
*/
- if (gsr.gsr_interface == 0 || if_index < gsr.gsr_interface)
+ if (gsr.gsr_interface == 0 || V_if_index < gsr.gsr_interface)
return (EADDRNOTAVAIL);
ifp = ifnet_byindex(gsr.gsr_interface);
@@ -1297,7 +1298,7 @@ inp_leave_group(struct inpcb *inp, struct sockopt *sopt)
return (EINVAL);
}
- if (gsr.gsr_interface == 0 || if_index < gsr.gsr_interface)
+ if (gsr.gsr_interface == 0 || V_if_index < gsr.gsr_interface)
return (EADDRNOTAVAIL);
ifp = ifnet_byindex(gsr.gsr_interface);
@@ -1414,7 +1415,7 @@ inp_set_multicast_if(struct inpcb *inp, struct sockopt *sopt)
if (error)
return (error);
- if (mreqn.imr_ifindex < 0 || if_index < mreqn.imr_ifindex)
+ if (mreqn.imr_ifindex < 0 || V_if_index < mreqn.imr_ifindex)
return (EINVAL);
if (mreqn.imr_ifindex == 0) {
@@ -1495,7 +1496,7 @@ inp_set_source_filters(struct inpcb *inp, struct sockopt *sopt)
gsa->sin.sin_port = 0; /* ignore port */
- if (msfr.msfr_ifindex == 0 || if_index < msfr.msfr_ifindex)
+ if (msfr.msfr_ifindex == 0 || V_if_index < msfr.msfr_ifindex)
return (EADDRNOTAVAIL);
ifp = ifnet_byindex(msfr.msfr_ifindex);
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index 88f86fb..135182c 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$");
#include <sys/jail.h>
#include <sys/kernel.h>
#include <sys/sysctl.h>
+#include <sys/vimage.h>
#ifdef DDB
#include <ddb/ddb.h>
@@ -121,12 +122,12 @@ sysctl_net_ipport_check(SYSCTL_HANDLER_ARGS)
error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2, req);
if (error == 0) {
- RANGECHK(ipport_lowfirstauto, 1, IPPORT_RESERVED - 1);
- RANGECHK(ipport_lowlastauto, 1, IPPORT_RESERVED - 1);
- RANGECHK(ipport_firstauto, IPPORT_RESERVED, IPPORT_MAX);
- RANGECHK(ipport_lastauto, IPPORT_RESERVED, IPPORT_MAX);
- RANGECHK(ipport_hifirstauto, IPPORT_RESERVED, IPPORT_MAX);
- RANGECHK(ipport_hilastauto, IPPORT_RESERVED, IPPORT_MAX);
+ RANGECHK(V_ipport_lowfirstauto, 1, IPPORT_RESERVED - 1);
+ RANGECHK(V_ipport_lowlastauto, 1, IPPORT_RESERVED - 1);
+ RANGECHK(V_ipport_firstauto, IPPORT_RESERVED, IPPORT_MAX);
+ RANGECHK(V_ipport_lastauto, IPPORT_RESERVED, IPPORT_MAX);
+ RANGECHK(V_ipport_hifirstauto, IPPORT_RESERVED, IPPORT_MAX);
+ RANGECHK(V_ipport_hilastauto, IPPORT_RESERVED, IPPORT_MAX);
}
return (error);
}
@@ -208,7 +209,7 @@ in_pcballoc(struct socket *so, struct inpcbinfo *pcbinfo)
#ifdef INET6
if (INP_SOCKAF(so) == AF_INET6) {
inp->inp_vflag |= INP_IPV6PROTO;
- if (ip6_v6only)
+ if (V_ip6_v6only)
inp->inp_flags |= IN6P_IPV6_V6ONLY;
}
#endif
@@ -216,7 +217,7 @@ in_pcballoc(struct socket *so, struct inpcbinfo *pcbinfo)
pcbinfo->ipi_count++;
so->so_pcb = (caddr_t)inp;
#ifdef INET6
- if (ip6_auto_flowlabel)
+ if (V_ip6_auto_flowlabel)
inp->inp_flags |= IN6P_AUTOFLOWLABEL;
#endif
INP_WLOCK(inp);
@@ -286,7 +287,7 @@ in_pcbbind_setup(struct inpcb *inp, struct sockaddr *nam, in_addr_t *laddrp,
INP_INFO_LOCK_ASSERT(pcbinfo);
INP_LOCK_ASSERT(inp);
- if (TAILQ_EMPTY(&in_ifaddrhead)) /* XXX broken! */
+ if (TAILQ_EMPTY(&V_in_ifaddrhead)) /* XXX broken! */
return (EADDRNOTAVAIL);
laddr.s_addr = *laddrp;
if (nam != NULL && laddr.s_addr != INADDR_ANY)
@@ -337,8 +338,8 @@ in_pcbbind_setup(struct inpcb *inp, struct sockaddr *nam, in_addr_t *laddrp,
struct tcptw *tw;
/* GROSS */
- if (ntohs(lport) <= ipport_reservedhigh &&
- ntohs(lport) >= ipport_reservedlow &&
+ if (ntohs(lport) <= V_ipport_reservedhigh &&
+ ntohs(lport) >= V_ipport_reservedlow &&
priv_check_cred(cred, PRIV_NETINET_RESERVEDPORT,
0))
return (EACCES);
@@ -406,20 +407,20 @@ in_pcbbind_setup(struct inpcb *inp, struct sockaddr *nam, in_addr_t *laddrp,
return (EINVAL);
if (inp->inp_flags & INP_HIGHPORT) {
- first = ipport_hifirstauto; /* sysctl */
- last = ipport_hilastauto;
+ first = V_ipport_hifirstauto; /* sysctl */
+ last = V_ipport_hilastauto;
lastport = &pcbinfo->ipi_lasthi;
} else if (inp->inp_flags & INP_LOWPORT) {
error = priv_check_cred(cred,
PRIV_NETINET_RESERVEDPORT, 0);
if (error)
return error;
- first = ipport_lowfirstauto; /* 1023 */
- last = ipport_lowlastauto; /* 600 */
+ first = V_ipport_lowfirstauto; /* 1023 */
+ last = V_ipport_lowlastauto; /* 600 */
lastport = &pcbinfo->ipi_lastlow;
} else {
- first = ipport_firstauto; /* sysctl */
- last = ipport_lastauto;
+ first = V_ipport_firstauto; /* sysctl */
+ last = V_ipport_lastauto;
lastport = &pcbinfo->ipi_lastport;
}
/*
@@ -428,8 +429,8 @@ in_pcbbind_setup(struct inpcb *inp, struct sockaddr *nam, in_addr_t *laddrp,
* use random port allocation only if the user allows it AND
* ipport_tick() allows it.
*/
- if (ipport_randomized &&
- (!ipport_stoprandom || pcbinfo == &udbinfo))
+ if (V_ipport_randomized &&
+ (!V_ipport_stoprandom || pcbinfo == &V_udbinfo))
dorandom = 1;
else
dorandom = 0;
@@ -440,8 +441,8 @@ in_pcbbind_setup(struct inpcb *inp, struct sockaddr *nam, in_addr_t *laddrp,
if (first == last)
dorandom = 0;
/* Make sure to not include UDP packets in the count. */
- if (pcbinfo != &udbinfo)
- ipport_tcpallocs++;
+ if (pcbinfo != &V_udbinfo)
+ V_ipport_tcpallocs++;
/*
* Simple check to ensure all ports are not used up causing
* a deadlock here.
@@ -581,7 +582,7 @@ in_pcbconnect_setup(struct inpcb *inp, struct sockaddr *nam,
if (error)
return (error);
}
- if (!TAILQ_EMPTY(&in_ifaddrhead)) {
+ if (!TAILQ_EMPTY(&V_in_ifaddrhead)) {
/*
* If the destination address is INADDR_ANY,
* use the primary local address.
@@ -590,12 +591,12 @@ in_pcbconnect_setup(struct inpcb *inp, struct sockaddr *nam,
* choose the broadcast address for that interface.
*/
if (faddr.s_addr == INADDR_ANY)
- faddr = IA_SIN(TAILQ_FIRST(&in_ifaddrhead))->sin_addr;
+ faddr = IA_SIN(TAILQ_FIRST(&V_in_ifaddrhead))->sin_addr;
else if (faddr.s_addr == (u_long)INADDR_BROADCAST &&
- (TAILQ_FIRST(&in_ifaddrhead)->ia_ifp->if_flags &
+ (TAILQ_FIRST(&V_in_ifaddrhead)->ia_ifp->if_flags &
IFF_BROADCAST))
faddr = satosin(&TAILQ_FIRST(
- &in_ifaddrhead)->ia_broadaddr)->sin_addr;
+ &V_in_ifaddrhead)->ia_broadaddr)->sin_addr;
}
if (laddr.s_addr == INADDR_ANY) {
ia = NULL;
@@ -640,7 +641,7 @@ in_pcbconnect_setup(struct inpcb *inp, struct sockaddr *nam,
imo = inp->inp_moptions;
if (imo->imo_multicast_ifp != NULL) {
ifp = imo->imo_multicast_ifp;
- TAILQ_FOREACH(ia, &in_ifaddrhead, ia_link)
+ TAILQ_FOREACH(ia, &V_in_ifaddrhead, ia_link)
if (ia->ia_ifp == ifp)
break;
if (ia == NULL)
@@ -1201,12 +1202,12 @@ void
ipport_tick(void *xtp)
{
- if (ipport_tcpallocs <= ipport_tcplastcount + ipport_randomcps) {
- if (ipport_stoprandom > 0)
- ipport_stoprandom--;
+ if (V_ipport_tcpallocs <= V_ipport_tcplastcount + V_ipport_randomcps) {
+ if (V_ipport_stoprandom > 0)
+ V_ipport_stoprandom--;
} else
- ipport_stoprandom = ipport_randomtime;
- ipport_tcplastcount = ipport_tcpallocs;
+ V_ipport_stoprandom = V_ipport_randomtime;
+ V_ipport_tcplastcount = V_ipport_tcpallocs;
callout_reset(&ipport_tick_callout, hz, ipport_tick, NULL);
}
@@ -1259,13 +1260,13 @@ inp_apply_all(void (*func)(struct inpcb *, void *), void *arg)
{
struct inpcb *inp;
- INP_INFO_RLOCK(&tcbinfo);
+ INP_INFO_RLOCK(&V_tcbinfo);
LIST_FOREACH(inp, tcbinfo.ipi_listhead, inp_list) {
INP_WLOCK(inp);
func(inp, arg);
INP_WUNLOCK(inp);
}
- INP_INFO_RUNLOCK(&tcbinfo);
+ INP_INFO_RUNLOCK(&V_tcbinfo);
}
struct socket *
diff --git a/sys/netinet/in_rmx.c b/sys/netinet/in_rmx.c
index aabf57e..d8a90d4 100644
--- a/sys/netinet/in_rmx.c
+++ b/sys/netinet/in_rmx.c
@@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
#include <sys/mbuf.h>
#include <sys/syslog.h>
#include <sys/callout.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/route.h>
@@ -190,9 +191,9 @@ in_clsroute(struct radix_node *rn, struct radix_node_head *head)
* If rtq_reallyold is 0, just delete the route without
* waiting for a timeout cycle to kill it.
*/
- if (rtq_reallyold != 0) {
+ if (V_rtq_reallyold != 0) {
rt->rt_flags |= RTPRF_OURS;
- rt->rt_rmx.rmx_expire = time_uptime + rtq_reallyold;
+ rt->rt_rmx.rmx_expire = time_uptime + V_rtq_reallyold;
} else {
rtexpunge(rt);
}
@@ -238,9 +239,9 @@ in_rtqkill(struct radix_node *rn, void *rock)
} else {
if (ap->updating &&
(rt->rt_rmx.rmx_expire - time_uptime >
- rtq_reallyold)) {
+ V_rtq_reallyold)) {
rt->rt_rmx.rmx_expire =
- time_uptime + rtq_reallyold;
+ time_uptime + V_rtq_reallyold;
}
ap->nextstop = lmin(ap->nextstop,
rt->rt_rmx.rmx_expire);
@@ -263,15 +264,15 @@ in_rtqtimo(void *rock)
void *newrock;
struct timeval atv;
- KASSERT((rock == (void *)rt_tables[0][AF_INET]),
+ KASSERT((rock == (void *)V_rt_tables[0][AF_INET]),
("in_rtqtimo: unexpected arg"));
for (fibnum = 0; fibnum < rt_numfibs; fibnum++) {
- if ((newrock = rt_tables[fibnum][AF_INET]) != NULL)
+ if ((newrock = V_rt_tables[fibnum][AF_INET]) != NULL)
in_rtqtimo_one(newrock);
}
atv.tv_usec = 0;
- atv.tv_sec = rtq_timeout;
- callout_reset(&rtq_timer, tvtohz(&atv), in_rtqtimo, rock);
+ atv.tv_sec = V_rtq_timeout;
+ callout_reset(&V_rtq_timer, tvtohz(&atv), in_rtqtimo, rock);
}
static void
@@ -283,7 +284,7 @@ in_rtqtimo_one(void *rock)
arg.found = arg.killed = 0;
arg.rnh = rnh;
- arg.nextstop = time_uptime + rtq_timeout;
+ arg.nextstop = time_uptime + V_rtq_timeout;
arg.draining = arg.updating = 0;
RADIX_NODE_HEAD_LOCK(rnh);
rnh->rnh_walktree(rnh, in_rtqkill, &arg);
@@ -297,18 +298,18 @@ in_rtqtimo_one(void *rock)
* than once in rtq_timeout seconds, to keep from cranking down too
* hard.
*/
- if ((arg.found - arg.killed > rtq_toomany) &&
- (time_uptime - last_adjusted_timeout >= rtq_timeout) &&
- rtq_reallyold > rtq_minreallyold) {
- rtq_reallyold = 2 * rtq_reallyold / 3;
- if (rtq_reallyold < rtq_minreallyold) {
- rtq_reallyold = rtq_minreallyold;
+ if ((arg.found - arg.killed > V_rtq_toomany) &&
+ (time_uptime - last_adjusted_timeout >= V_rtq_timeout) &&
+ V_rtq_reallyold > V_rtq_minreallyold) {
+ V_rtq_reallyold = 2 * V_rtq_reallyold / 3;
+ if (V_rtq_reallyold < V_rtq_minreallyold) {
+ V_rtq_reallyold = V_rtq_minreallyold;
}
last_adjusted_timeout = time_uptime;
#ifdef DIAGNOSTIC
log(LOG_DEBUG, "in_rtqtimo: adjusted rtq_reallyold to %d\n",
- rtq_reallyold);
+ V_rtq_reallyold);
#endif
arg.found = arg.killed = 0;
arg.updating = 1;
@@ -327,7 +328,7 @@ in_rtqdrain(void)
int fibnum;
for ( fibnum = 0; fibnum < rt_numfibs; fibnum++) {
- rnh = rt_tables[fibnum][AF_INET];
+ rnh = V_rt_tables[fibnum][AF_INET];
arg.found = arg.killed = 0;
arg.rnh = rnh;
arg.nextstop = 0;
@@ -367,7 +368,7 @@ in_inithead(void **head, int off)
rnh->rnh_matchaddr = in_matroute;
rnh->rnh_close = in_clsroute;
if (_in_rt_was_here == 0 ) {
- callout_init(&rtq_timer, CALLOUT_MPSAFE);
+ callout_init(&V_rtq_timer, CALLOUT_MPSAFE);
in_rtqtimo(rnh); /* kick off timeout first time */
_in_rt_was_here = 1;
}
@@ -423,7 +424,7 @@ in_ifadown(struct ifaddr *ifa, int delete)
return 1;
for ( fibnum = 0; fibnum < rt_numfibs; fibnum++) {
- rnh = rt_tables[fibnum][AF_INET];
+ rnh = V_rt_tables[fibnum][AF_INET];
arg.ifa = ifa;
arg.del = delete;
RADIX_NODE_HEAD_LOCK(rnh);
diff --git a/sys/netinet/in_var.h b/sys/netinet/in_var.h
index d7f1e28..01ff7b3 100644
--- a/sys/netinet/in_var.h
+++ b/sys/netinet/in_var.h
@@ -92,7 +92,7 @@ extern u_long in_ifaddrhmask; /* mask for hash table */
#define INADDR_NHASH (1 << INADDR_NHASH_LOG2)
#define INADDR_HASHVAL(x) fnv_32_buf((&(x)), sizeof(x), FNV1_32_INIT)
#define INADDR_HASH(x) \
- (&in_ifaddrhashtbl[INADDR_HASHVAL(x) & in_ifaddrhmask])
+ (&V_in_ifaddrhashtbl[INADDR_HASHVAL(x) & V_in_ifaddrhmask])
/*
* Macro for finding the internet address structure (in_ifaddr)
@@ -130,7 +130,7 @@ do { \
/* struct ifnet *ifp; */ \
/* struct in_ifaddr *ia; */ \
{ \
- for ((ia) = TAILQ_FIRST(&in_ifaddrhead); \
+ for ((ia) = TAILQ_FIRST(&V_in_ifaddrhead); \
(ia) != NULL && (ia)->ia_ifp != (ifp); \
(ia) = TAILQ_NEXT((ia), ia_link)) \
continue; \
@@ -283,7 +283,7 @@ do { \
/* struct in_multi *inm; */ \
do { \
IN_MULTI_LOCK_ASSERT(); \
- (step).i_inm = LIST_FIRST(&in_multihead); \
+ (step).i_inm = LIST_FIRST(&V_in_multihead); \
IN_NEXT_MULTI((step), (inm)); \
} while(0)
diff --git a/sys/netinet/ip6.h b/sys/netinet/ip6.h
index 883b65a..09692d9 100644
--- a/sys/netinet/ip6.h
+++ b/sys/netinet/ip6.h
@@ -275,24 +275,24 @@ do { \
if (((m)->m_flags & M_LOOP) && \
((m)->m_len < (off) + (hlen)) && \
(((m) = m_pullup((m), (off) + (hlen))) == NULL)) { \
- ip6stat.ip6s_exthdrtoolong++; \
+ V_ip6stat.ip6s_exthdrtoolong++; \
return ret; \
} else if ((m)->m_flags & M_EXT) { \
if ((m)->m_len < (off) + (hlen)) { \
- ip6stat.ip6s_exthdrtoolong++; \
+ V_ip6stat.ip6s_exthdrtoolong++; \
m_freem(m); \
return ret; \
} \
} else { \
if ((m)->m_len < (off) + (hlen)) { \
- ip6stat.ip6s_exthdrtoolong++; \
+ V_ip6stat.ip6s_exthdrtoolong++; \
m_freem(m); \
return ret; \
} \
} \
} else { \
if ((m)->m_len < (off) + (hlen)) { \
- ip6stat.ip6s_tooshort++; \
+ V_ip6stat.ip6s_tooshort++; \
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_truncated); \
m_freem(m); \
return ret; \
diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c
index 69fea3f..1a07a97 100644
--- a/sys/netinet/ip_carp.c
+++ b/sys/netinet/ip_carp.c
@@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$");
#include <sys/socket.h>
#include <sys/vnode.h>
+#include <sys/vimage.h>
#include <machine/stdarg.h>
@@ -1474,7 +1475,7 @@ carp_set_addr(struct carp_softc *sc, struct sockaddr_in *sin)
/* we have to do it by hands to check we won't match on us */
ia_if = NULL; own = 0;
- TAILQ_FOREACH(ia, &in_ifaddrhead, ia_link) {
+ TAILQ_FOREACH(ia, &V_in_ifaddrhead, ia_link) {
/* and, yeah, we need a multicast-capable iface too */
if (ia->ia_ifp != SC2IFP(sc) &&
(ia->ia_ifp->if_flags & IFF_MULTICAST) &&
@@ -1639,7 +1640,7 @@ carp_set_addr6(struct carp_softc *sc, struct sockaddr_in6 *sin6)
/* we have to do it by hands to check we won't match on us */
ia_if = NULL; own = 0;
- for (ia = in6_ifaddr; ia; ia = ia->ia_next) {
+ for (ia = V_in6_ifaddr; ia; ia = ia->ia_next) {
int i;
for (i = 0; i < 4; i++) {
diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c
index a509151..1bba15a 100644
--- a/sys/netinet/ip_divert.c
+++ b/sys/netinet/ip_divert.c
@@ -58,6 +58,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sx.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
+#include <sys/vimage.h>
#include <vm/uma.h>
@@ -124,7 +125,7 @@ static void
div_zone_change(void *tag)
{
- uma_zone_set_max(divcbinfo.ipi_zone, maxsockets);
+ uma_zone_set_max(V_divcbinfo.ipi_zone, maxsockets);
}
static int
@@ -148,18 +149,18 @@ void
div_init(void)
{
- INP_INFO_LOCK_INIT(&divcbinfo, "div");
- LIST_INIT(&divcb);
- divcbinfo.ipi_listhead = &divcb;
+ INP_INFO_LOCK_INIT(&V_divcbinfo, "div");
+ LIST_INIT(&V_divcb);
+ V_divcbinfo.ipi_listhead = &V_divcb;
/*
* XXX We don't use the hash list for divert IP, but it's easier
* to allocate a one entry hash list than it is to check all
* over the place for hashbase == NULL.
*/
- divcbinfo.ipi_hashbase = hashinit(1, M_PCB, &divcbinfo.ipi_hashmask);
- divcbinfo.ipi_porthashbase = hashinit(1, M_PCB,
- &divcbinfo.ipi_porthashmask);
- divcbinfo.ipi_zone = uma_zcreate("divcb", sizeof(struct inpcb),
+ V_divcbinfo.ipi_hashbase = hashinit(1, M_PCB, &V_divcbinfo.ipi_hashmask);
+ V_divcbinfo.ipi_porthashbase = hashinit(1, M_PCB,
+ &V_divcbinfo.ipi_porthashmask);
+ V_divcbinfo.ipi_zone = uma_zcreate("divcb", sizeof(struct inpcb),
NULL, NULL, div_inpcb_init, div_inpcb_fini, UMA_ALIGN_PTR,
UMA_ZONE_NOFREE);
uma_zone_set_max(divcbinfo.ipi_zone, maxsockets);
@@ -174,7 +175,7 @@ div_init(void)
void
div_input(struct mbuf *m, int off)
{
- ipstat.ips_noproto++;
+ V_ipstat.ips_noproto++;
m_freem(m);
}
@@ -266,8 +267,8 @@ divert_packet(struct mbuf *m, int incoming)
/* Put packet on socket queue, if any */
sa = NULL;
nport = htons((u_int16_t)divert_info(mtag));
- INP_INFO_RLOCK(&divcbinfo);
- LIST_FOREACH(inp, &divcb, inp_list) {
+ INP_INFO_RLOCK(&V_divcbinfo);
+ LIST_FOREACH(inp, &V_divcb, inp_list) {
/* XXX why does only one socket match? */
if (inp->inp_lport == nport) {
INP_RLOCK(inp);
@@ -284,11 +285,11 @@ divert_packet(struct mbuf *m, int incoming)
break;
}
}
- INP_INFO_RUNLOCK(&divcbinfo);
+ INP_INFO_RUNLOCK(&V_divcbinfo);
if (sa == NULL) {
m_freem(m);
- ipstat.ips_noproto++;
- ipstat.ips_delivered--;
+ V_ipstat.ips_noproto++;
+ V_ipstat.ips_delivered--;
}
}
@@ -353,7 +354,7 @@ div_output(struct socket *so, struct mbuf *m, struct sockaddr_in *sin,
struct inpcb *inp;
dt->info |= IP_FW_DIVERT_OUTPUT_FLAG;
- INP_INFO_WLOCK(&divcbinfo);
+ INP_INFO_WLOCK(&V_divcbinfo);
inp = sotoinpcb(so);
INP_RLOCK(inp);
/*
@@ -364,7 +365,7 @@ div_output(struct socket *so, struct mbuf *m, struct sockaddr_in *sin,
((u_short)ntohs(ip->ip_len) > m->m_pkthdr.len)) {
error = EINVAL;
INP_RUNLOCK(inp);
- INP_INFO_WUNLOCK(&divcbinfo);
+ INP_INFO_WUNLOCK(&V_divcbinfo);
m_freem(m);
} else {
/* Convert fields to host order for ip_output() */
@@ -372,7 +373,7 @@ div_output(struct socket *so, struct mbuf *m, struct sockaddr_in *sin,
ip->ip_off = ntohs(ip->ip_off);
/* Send packet to output processing */
- ipstat.ips_rawout++; /* XXX */
+ V_ipstat.ips_rawout++; /* XXX */
#ifdef MAC
mac_inpcb_create_mbuf(inp, m);
@@ -405,7 +406,7 @@ div_output(struct socket *so, struct mbuf *m, struct sockaddr_in *sin,
error = ENOBUFS;
}
INP_RUNLOCK(inp);
- INP_INFO_WUNLOCK(&divcbinfo);
+ INP_INFO_WUNLOCK(&V_divcbinfo);
if (error == ENOBUFS) {
m_freem(m);
return (error);
@@ -468,14 +469,14 @@ div_attach(struct socket *so, int proto, struct thread *td)
error = soreserve(so, div_sendspace, div_recvspace);
if (error)
return error;
- INP_INFO_WLOCK(&divcbinfo);
- error = in_pcballoc(so, &divcbinfo);
+ INP_INFO_WLOCK(&V_divcbinfo);
+ error = in_pcballoc(so, &V_divcbinfo);
if (error) {
- INP_INFO_WUNLOCK(&divcbinfo);
+ INP_INFO_WUNLOCK(&V_divcbinfo);
return error;
}
inp = (struct inpcb *)so->so_pcb;
- INP_INFO_WUNLOCK(&divcbinfo);
+ INP_INFO_WUNLOCK(&V_divcbinfo);
inp->inp_ip_p = proto;
inp->inp_vflag |= INP_IPV4;
inp->inp_flags |= INP_HDRINCL;
@@ -490,11 +491,11 @@ div_detach(struct socket *so)
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("div_detach: inp == NULL"));
- INP_INFO_WLOCK(&divcbinfo);
+ INP_INFO_WLOCK(&V_divcbinfo);
INP_WLOCK(inp);
in_pcbdetach(inp);
in_pcbfree(inp);
- INP_INFO_WUNLOCK(&divcbinfo);
+ INP_INFO_WUNLOCK(&V_divcbinfo);
}
static int
@@ -515,11 +516,11 @@ div_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
if (nam->sa_family != AF_INET)
return EAFNOSUPPORT;
((struct sockaddr_in *)nam)->sin_addr.s_addr = INADDR_ANY;
- INP_INFO_WLOCK(&divcbinfo);
+ INP_INFO_WLOCK(&V_divcbinfo);
INP_WLOCK(inp);
error = in_pcbbind(inp, nam, td->td_ucred);
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&divcbinfo);
+ INP_INFO_WUNLOCK(&V_divcbinfo);
return error;
}
@@ -543,7 +544,7 @@ div_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam,
/* Packet must have a header (but that's about it) */
if (m->m_len < sizeof (struct ip) &&
(m = m_pullup(m, sizeof (struct ip))) == 0) {
- ipstat.ips_toosmall++;
+ V_ipstat.ips_toosmall++;
m_freem(m);
return EINVAL;
}
@@ -577,7 +578,7 @@ div_pcblist(SYSCTL_HANDLER_ARGS)
* resource-intensive to repeat twice on every request.
*/
if (req->oldptr == 0) {
- n = divcbinfo.ipi_count;
+ n = V_divcbinfo.ipi_count;
req->oldidx = 2 * (sizeof xig)
+ (n + n/8) * sizeof(struct xinpcb);
return 0;
@@ -589,10 +590,10 @@ div_pcblist(SYSCTL_HANDLER_ARGS)
/*
* OK, now we're committed to doing something.
*/
- INP_INFO_RLOCK(&divcbinfo);
- gencnt = divcbinfo.ipi_gencnt;
- n = divcbinfo.ipi_count;
- INP_INFO_RUNLOCK(&divcbinfo);
+ INP_INFO_RLOCK(&V_divcbinfo);
+ gencnt = V_divcbinfo.ipi_gencnt;
+ n = V_divcbinfo.ipi_count;
+ INP_INFO_RUNLOCK(&V_divcbinfo);
error = sysctl_wire_old_buffer(req,
2 * sizeof(xig) + n*sizeof(struct xinpcb));
@@ -611,8 +612,8 @@ div_pcblist(SYSCTL_HANDLER_ARGS)
if (inp_list == 0)
return ENOMEM;
- INP_INFO_RLOCK(&divcbinfo);
- for (inp = LIST_FIRST(divcbinfo.ipi_listhead), i = 0; inp && i < n;
+ INP_INFO_RLOCK(&V_divcbinfo);
+ for (inp = LIST_FIRST(V_divcbinfo.ipi_listhead), i = 0; inp && i < n;
inp = LIST_NEXT(inp, inp_list)) {
INP_RLOCK(inp);
if (inp->inp_gencnt <= gencnt &&
@@ -620,7 +621,7 @@ div_pcblist(SYSCTL_HANDLER_ARGS)
inp_list[i++] = inp;
INP_RUNLOCK(inp);
}
- INP_INFO_RUNLOCK(&divcbinfo);
+ INP_INFO_RUNLOCK(&V_divcbinfo);
n = i;
error = 0;
@@ -648,11 +649,11 @@ div_pcblist(SYSCTL_HANDLER_ARGS)
* while we were processing this request, and it
* might be necessary to retry.
*/
- INP_INFO_RLOCK(&divcbinfo);
- xig.xig_gen = divcbinfo.ipi_gencnt;
+ INP_INFO_RLOCK(&V_divcbinfo);
+ xig.xig_gen = V_divcbinfo.ipi_gencnt;
xig.xig_sogen = so_gencnt;
- xig.xig_count = divcbinfo.ipi_count;
- INP_INFO_RUNLOCK(&divcbinfo);
+ xig.xig_count = V_divcbinfo.ipi_count;
+ INP_INFO_RUNLOCK(&V_divcbinfo);
error = SYSCTL_OUT(req, &xig, sizeof xig);
}
free(inp_list, M_TEMP);
@@ -724,18 +725,18 @@ div_modevent(module_t mod, int type, void *unused)
* socket open request could be spinning on the lock and then
* we destroy the lock.
*/
- INP_INFO_WLOCK(&divcbinfo);
- n = divcbinfo.ipi_count;
+ INP_INFO_WLOCK(&V_divcbinfo);
+ n = V_divcbinfo.ipi_count;
if (n != 0) {
err = EBUSY;
- INP_INFO_WUNLOCK(&divcbinfo);
+ INP_INFO_WUNLOCK(&V_divcbinfo);
break;
}
ip_divert_ptr = NULL;
err = pf_proto_unregister(PF_INET, IPPROTO_DIVERT, SOCK_RAW);
- INP_INFO_WUNLOCK(&divcbinfo);
- INP_INFO_LOCK_DESTROY(&divcbinfo);
- uma_zdestroy(divcbinfo.ipi_zone);
+ INP_INFO_WUNLOCK(&V_divcbinfo);
+ INP_INFO_LOCK_DESTROY(&V_divcbinfo);
+ uma_zdestroy(V_divcbinfo.ipi_zone);
break;
default:
err = EOPNOTSUPP;
diff --git a/sys/netinet/ip_fastfwd.c b/sys/netinet/ip_fastfwd.c
index bb8c74a..b38dfc0 100644
--- a/sys/netinet/ip_fastfwd.c
+++ b/sys/netinet/ip_fastfwd.c
@@ -87,6 +87,7 @@ __FBSDID("$FreeBSD$");
#include <sys/protosw.h>
#include <sys/socket.h>
#include <sys/sysctl.h>
+#include <sys/vimage.h>
#include <net/pfil.h>
#include <net/if.h>
@@ -135,8 +136,8 @@ ip_findroute(struct route *ro, struct in_addr dest, struct mbuf *m)
if (rt->rt_flags & RTF_GATEWAY)
dst = (struct sockaddr_in *)rt->rt_gateway;
} else {
- ipstat.ips_noroute++;
- ipstat.ips_cantforward++;
+ V_ipstat.ips_noroute++;
+ V_ipstat.ips_cantforward++;
if (rt)
RTFREE(rt);
icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, 0, 0);
@@ -171,7 +172,7 @@ ip_fastforward(struct mbuf *m)
/*
* Are we active and forwarding packets?
*/
- if (!ipfastforward_active || !ipforwarding)
+ if (!V_ipfastforward_active || !V_ipforwarding)
return m;
M_ASSERTVALID(m);
@@ -187,7 +188,7 @@ ip_fastforward(struct mbuf *m)
* Is entire packet big enough?
*/
if (m->m_pkthdr.len < sizeof(struct ip)) {
- ipstat.ips_tooshort++;
+ V_ipstat.ips_tooshort++;
goto drop;
}
@@ -196,7 +197,7 @@ ip_fastforward(struct mbuf *m)
*/
if (m->m_len < sizeof (struct ip) &&
(m = m_pullup(m, sizeof (struct ip))) == NULL) {
- ipstat.ips_toosmall++;
+ V_ipstat.ips_toosmall++;
return NULL; /* mbuf already free'd */
}
@@ -206,7 +207,7 @@ ip_fastforward(struct mbuf *m)
* Is it IPv4?
*/
if (ip->ip_v != IPVERSION) {
- ipstat.ips_badvers++;
+ V_ipstat.ips_badvers++;
goto drop;
}
@@ -215,12 +216,12 @@ ip_fastforward(struct mbuf *m)
*/
hlen = ip->ip_hl << 2;
if (hlen < sizeof(struct ip)) { /* minimum header length */
- ipstat.ips_badlen++;
+ V_ipstat.ips_badlen++;
goto drop;
}
if (hlen > m->m_len) {
if ((m = m_pullup(m, hlen)) == NULL) {
- ipstat.ips_badhlen++;
+ V_ipstat.ips_badhlen++;
return NULL; /* mbuf already free'd */
}
ip = mtod(m, struct ip *);
@@ -238,7 +239,7 @@ ip_fastforward(struct mbuf *m)
sum = in_cksum(m, hlen);
}
if (sum) {
- ipstat.ips_badsum++;
+ V_ipstat.ips_badsum++;
goto drop;
}
@@ -253,7 +254,7 @@ ip_fastforward(struct mbuf *m)
* Is IP length longer than packet we have got?
*/
if (m->m_pkthdr.len < ip_len) {
- ipstat.ips_tooshort++;
+ V_ipstat.ips_tooshort++;
goto drop;
}
@@ -273,7 +274,7 @@ ip_fastforward(struct mbuf *m)
*/
if ((ntohl(ip->ip_dst.s_addr) >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET ||
(ntohl(ip->ip_src.s_addr) >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET) {
- ipstat.ips_badaddr++;
+ V_ipstat.ips_badaddr++;
goto drop;
}
@@ -331,7 +332,7 @@ ip_fastforward(struct mbuf *m)
if (in_localip(ip->ip_dst))
return m;
- ipstat.ips_total++;
+ V_ipstat.ips_total++;
/*
* Step 3: incoming packet firewall processing
@@ -392,7 +393,7 @@ passin:
* Check TTL
*/
#ifdef IPSTEALTH
- if (!ipstealth) {
+ if (!V_ipstealth) {
#endif
if (ip->ip_ttl <= IPTTLDEC) {
icmp_error(m, ICMP_TIMXCEED, ICMP_TIMXCEED_INTRANS, 0, 0);
@@ -513,7 +514,7 @@ passout:
*/
if ((ifp->if_snd.ifq_len + ip->ip_len / ifp->if_mtu + 1) >=
ifp->if_snd.ifq_maxlen) {
- ipstat.ips_odropped++;
+ V_ipstat.ips_odropped++;
/* would send source quench here but that is depreciated */
goto drop;
}
@@ -552,7 +553,7 @@ passout:
* Handle EMSGSIZE with icmp reply needfrag for TCP MTU discovery
*/
if (ip->ip_off & IP_DF) {
- ipstat.ips_cantfrag++;
+ V_ipstat.ips_cantfrag++;
icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_NEEDFRAG,
0, mtu);
goto consumed;
@@ -590,16 +591,16 @@ passout:
m_freem(m);
}
} else
- ipstat.ips_fragmented++;
+ V_ipstat.ips_fragmented++;
}
}
if (error != 0)
- ipstat.ips_odropped++;
+ V_ipstat.ips_odropped++;
else {
ro.ro_rt->rt_rmx.rmx_pksent++;
- ipstat.ips_forward++;
- ipstat.ips_fastforward++;
+ V_ipstat.ips_forward++;
+ V_ipstat.ips_fastforward++;
}
consumed:
RTFREE(ro.ro_rt);
diff --git a/sys/netinet/ip_fw2.c b/sys/netinet/ip_fw2.c
index 650ed1a..7cfe653 100644
--- a/sys/netinet/ip_fw2.c
+++ b/sys/netinet/ip_fw2.c
@@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sysctl.h>
#include <sys/syslog.h>
#include <sys/ucred.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/radix.h>
#include <net/route.h>
@@ -567,7 +568,7 @@ search_ip6_addr_net (struct in6_addr * ip6_addr)
struct in6_ifaddr *fdm;
struct in6_addr copia;
- TAILQ_FOREACH(mdc, &ifnet, if_link)
+ TAILQ_FOREACH(mdc, &V_ifnet, if_link)
TAILQ_FOREACH(mdc2, &mdc->if_addrlist, ifa_list) {
if (mdc2->ifa_addr->sa_family == AF_INET6) {
fdm = (struct in6_ifaddr *)mdc2;
@@ -762,11 +763,11 @@ ipfw_log(struct ip_fw *f, u_int hlen, struct ip_fw_args *args,
proto[0] = '\0';
if (f == NULL) { /* bogus pkt */
- if (verbose_limit != 0 && norule_counter >= verbose_limit)
+ if (V_verbose_limit != 0 && V_norule_counter >= V_verbose_limit)
return;
- norule_counter++;
- if (norule_counter == verbose_limit)
- limit_reached = verbose_limit;
+ V_norule_counter++;
+ if (V_norule_counter == V_verbose_limit)
+ limit_reached = V_verbose_limit;
action = "Refuse";
} else { /* O_LOG is the first action, find the real one */
ipfw_insn *cmd = ACTION_PTR(f);
@@ -1031,7 +1032,7 @@ hash_packet(struct ipfw_flow_id *id)
else
#endif /* INET6 */
i = (id->dst_ip) ^ (id->src_ip) ^ (id->dst_port) ^ (id->src_port);
- i &= (curr_dyn_buckets - 1);
+ i &= (V_curr_dyn_buckets - 1);
return i;
}
@@ -1049,12 +1050,12 @@ hash_packet(struct ipfw_flow_id *id)
q->parent->count--; \
DEB(printf("ipfw: unlink entry 0x%08x %d -> 0x%08x %d, %d left\n",\
(q->id.src_ip), (q->id.src_port), \
- (q->id.dst_ip), (q->id.dst_port), dyn_count-1 ); ) \
+ (q->id.dst_ip), (q->id.dst_port), V_dyn_count-1 ); ) \
if (prev != NULL) \
prev->next = q = q->next; \
else \
head = q = q->next; \
- dyn_count--; \
+ V_dyn_count--; \
uma_zfree(ipfw_dyn_rule_zone, old_q); }
#define TIME_LEQ(a,b) ((int)((a)-(b)) <= 0)
@@ -1083,7 +1084,7 @@ remove_dyn_rule(struct ip_fw *rule, ipfw_dyn_rule *keep_me)
IPFW_DYN_LOCK_ASSERT();
- if (ipfw_dyn_v == NULL || dyn_count == 0)
+ if (V_ipfw_dyn_v == NULL || V_dyn_count == 0)
return;
/* do not expire more than once per second, it is useless */
if (!FORCE && last_remove == time_uptime)
@@ -1096,8 +1097,8 @@ remove_dyn_rule(struct ip_fw *rule, ipfw_dyn_rule *keep_me)
* them in a second pass.
*/
next_pass:
- for (i = 0 ; i < curr_dyn_buckets ; i++) {
- for (prev=NULL, q = ipfw_dyn_v[i] ; q ; ) {
+ for (i = 0 ; i < V_curr_dyn_buckets ; i++) {
+ for (prev=NULL, q = V_ipfw_dyn_v[i] ; q ; ) {
/*
* Logic can become complex here, so we split tests.
*/
@@ -1124,7 +1125,7 @@ next_pass:
goto next;
}
if (q->dyn_type != O_LIMIT_PARENT || !q->count) {
- UNLINK_DYN_RULE(prev, ipfw_dyn_v[i], q);
+ UNLINK_DYN_RULE(prev, V_ipfw_dyn_v[i], q);
continue;
}
next:
@@ -1157,14 +1158,14 @@ lookup_dyn_rule_locked(struct ipfw_flow_id *pkt, int *match_direction,
IPFW_DYN_LOCK_ASSERT();
- if (ipfw_dyn_v == NULL)
+ if (V_ipfw_dyn_v == NULL)
goto done; /* not found */
i = hash_packet( pkt );
- for (prev=NULL, q = ipfw_dyn_v[i] ; q != NULL ; ) {
+ for (prev=NULL, q = V_ipfw_dyn_v[i] ; q != NULL ; ) {
if (q->dyn_type == O_LIMIT_PARENT && q->count)
goto next;
if (TIME_LEQ( q->expire, time_uptime)) { /* expire entry */
- UNLINK_DYN_RULE(prev, ipfw_dyn_v[i], q);
+ UNLINK_DYN_RULE(prev, V_ipfw_dyn_v[i], q);
continue;
}
if (pkt->proto == q->id.proto &&
@@ -1214,8 +1215,8 @@ next:
if ( prev != NULL) { /* found and not in front */
prev->next = q->next;
- q->next = ipfw_dyn_v[i];
- ipfw_dyn_v[i] = q;
+ q->next = V_ipfw_dyn_v[i];
+ V_ipfw_dyn_v[i] = q;
}
if (pkt->proto == IPPROTO_TCP) { /* update state according to flags */
u_char flags = pkt->flags & (TH_FIN|TH_SYN|TH_RST);
@@ -1225,7 +1226,7 @@ next:
q->state |= (dir == MATCH_FORWARD ) ? flags : (flags << 8);
switch (q->state) {
case TH_SYN: /* opening */
- q->expire = time_uptime + dyn_syn_lifetime;
+ q->expire = time_uptime + V_dyn_syn_lifetime;
break;
case BOTH_SYN: /* move to established */
@@ -1248,13 +1249,13 @@ next:
}
}
}
- q->expire = time_uptime + dyn_ack_lifetime;
+ q->expire = time_uptime + V_dyn_ack_lifetime;
break;
case BOTH_SYN | BOTH_FIN: /* both sides closed */
- if (dyn_fin_lifetime >= dyn_keepalive_period)
- dyn_fin_lifetime = dyn_keepalive_period - 1;
- q->expire = time_uptime + dyn_fin_lifetime;
+ if (V_dyn_fin_lifetime >= V_dyn_keepalive_period)
+ V_dyn_fin_lifetime = V_dyn_keepalive_period - 1;
+ q->expire = time_uptime + V_dyn_fin_lifetime;
break;
default:
@@ -1266,16 +1267,16 @@ next:
if ( (q->state & ((TH_RST << 8)|TH_RST)) == 0)
printf("invalid state: 0x%x\n", q->state);
#endif
- if (dyn_rst_lifetime >= dyn_keepalive_period)
- dyn_rst_lifetime = dyn_keepalive_period - 1;
- q->expire = time_uptime + dyn_rst_lifetime;
+ if (V_dyn_rst_lifetime >= V_dyn_keepalive_period)
+ V_dyn_rst_lifetime = V_dyn_keepalive_period - 1;
+ q->expire = time_uptime + V_dyn_rst_lifetime;
break;
}
} else if (pkt->proto == IPPROTO_UDP) {
- q->expire = time_uptime + dyn_udp_lifetime;
+ q->expire = time_uptime + V_dyn_udp_lifetime;
} else {
/* other protocols */
- q->expire = time_uptime + dyn_short_lifetime;
+ q->expire = time_uptime + V_dyn_short_lifetime;
}
done:
if (match_direction)
@@ -1308,21 +1309,21 @@ realloc_dynamic_table(void)
* default to 1024.
*/
- if (dyn_buckets > 65536)
- dyn_buckets = 1024;
- if ((dyn_buckets & (dyn_buckets-1)) != 0) { /* not a power of 2 */
- dyn_buckets = curr_dyn_buckets; /* reset */
+ if (V_dyn_buckets > 65536)
+ V_dyn_buckets = 1024;
+ if ((V_dyn_buckets & (V_dyn_buckets-1)) != 0) { /* not a power of 2 */
+ V_dyn_buckets = V_curr_dyn_buckets; /* reset */
return;
}
- curr_dyn_buckets = dyn_buckets;
- if (ipfw_dyn_v != NULL)
- free(ipfw_dyn_v, M_IPFW);
+ V_curr_dyn_buckets = V_dyn_buckets;
+ if (V_ipfw_dyn_v != NULL)
+ free(V_ipfw_dyn_v, M_IPFW);
for (;;) {
- ipfw_dyn_v = malloc(curr_dyn_buckets * sizeof(ipfw_dyn_rule *),
+ V_ipfw_dyn_v = malloc(V_curr_dyn_buckets * sizeof(ipfw_dyn_rule *),
M_IPFW, M_NOWAIT | M_ZERO);
- if (ipfw_dyn_v != NULL || curr_dyn_buckets <= 2)
+ if (V_ipfw_dyn_v != NULL || V_curr_dyn_buckets <= 2)
break;
- curr_dyn_buckets /= 2;
+ V_curr_dyn_buckets /= 2;
}
}
@@ -1344,10 +1345,10 @@ add_dyn_rule(struct ipfw_flow_id *id, u_int8_t dyn_type, struct ip_fw *rule)
IPFW_DYN_LOCK_ASSERT();
- if (ipfw_dyn_v == NULL ||
- (dyn_count == 0 && dyn_buckets != curr_dyn_buckets)) {
+ if (V_ipfw_dyn_v == NULL ||
+ (V_dyn_count == 0 && V_dyn_buckets != V_curr_dyn_buckets)) {
realloc_dynamic_table();
- if (ipfw_dyn_v == NULL)
+ if (V_ipfw_dyn_v == NULL)
return NULL; /* failed ! */
}
i = hash_packet(id);
@@ -1369,21 +1370,21 @@ add_dyn_rule(struct ipfw_flow_id *id, u_int8_t dyn_type, struct ip_fw *rule)
}
r->id = *id;
- r->expire = time_uptime + dyn_syn_lifetime;
+ r->expire = time_uptime + V_dyn_syn_lifetime;
r->rule = rule;
r->dyn_type = dyn_type;
r->pcnt = r->bcnt = 0;
r->count = 0;
r->bucket = i;
- r->next = ipfw_dyn_v[i];
- ipfw_dyn_v[i] = r;
- dyn_count++;
+ r->next = V_ipfw_dyn_v[i];
+ V_ipfw_dyn_v[i] = r;
+ V_dyn_count++;
DEB(printf("ipfw: add dyn entry ty %d 0x%08x %d -> 0x%08x %d, total %d\n",
dyn_type,
(r->id.src_ip), (r->id.src_port),
(r->id.dst_ip), (r->id.dst_port),
- dyn_count ); )
+ V_dyn_count ); )
return r;
}
@@ -1399,10 +1400,10 @@ lookup_dyn_parent(struct ipfw_flow_id *pkt, struct ip_fw *rule)
IPFW_DYN_LOCK_ASSERT();
- if (ipfw_dyn_v) {
+ if (V_ipfw_dyn_v) {
int is_v6 = IS_IP6_FLOW_ID(pkt);
i = hash_packet( pkt );
- for (q = ipfw_dyn_v[i] ; q != NULL ; q=q->next)
+ for (q = V_ipfw_dyn_v[i] ; q != NULL ; q=q->next)
if (q->dyn_type == O_LIMIT_PARENT &&
rule== q->rule &&
pkt->proto == q->id.proto &&
@@ -1419,7 +1420,7 @@ lookup_dyn_parent(struct ipfw_flow_id *pkt, struct ip_fw *rule)
pkt->dst_ip == q->id.dst_ip)
)
) {
- q->expire = time_uptime + dyn_short_lifetime;
+ q->expire = time_uptime + V_dyn_short_lifetime;
DEB(printf("ipfw: lookup_dyn_parent found 0x%p\n",q);)
return q;
}
@@ -1466,11 +1467,11 @@ install_state(struct ip_fw *rule, ipfw_insn_limit *cmd,
return (0);
}
- if (dyn_count >= dyn_max)
+ if (V_dyn_count >= V_dyn_max)
/* Run out of slots, try to remove any expired rule. */
remove_dyn_rule(NULL, (ipfw_dyn_rule *)1);
- if (dyn_count >= dyn_max) {
+ if (V_dyn_count >= V_dyn_max) {
if (last_log != time_uptime) {
last_log = time_uptime;
printf("ipfw: %s: Too many dynamic rules\n", __func__);
@@ -1532,7 +1533,7 @@ install_state(struct ip_fw *rule, ipfw_insn_limit *cmd,
/* See if we can remove some expired rule. */
remove_dyn_rule(rule, parent);
if (parent->count >= conn_limit) {
- if (fw_verbose && last_log != time_uptime) {
+ if (V_fw_verbose && last_log != time_uptime) {
last_log = time_uptime;
#ifdef INET6
/*
@@ -1675,7 +1676,7 @@ send_pkt(struct mbuf *replyto, struct ipfw_flow_id *id, u_int32_t seq,
/*
* now fill fields left out earlier
*/
- ip->ip_ttl = ip_defttl;
+ ip->ip_ttl = V_ip_defttl;
ip->ip_len = m->m_pkthdr.len;
m->m_flags |= M_SKIP_FIREWALL;
return (m);
@@ -1787,14 +1788,14 @@ add_table_entry(struct ip_fw_chain *ch, uint16_t tbl, in_addr_t addr,
ent->addr.sin_len = ent->mask.sin_len = 8;
ent->mask.sin_addr.s_addr = htonl(mlen ? ~((1 << (32 - mlen)) - 1) : 0);
ent->addr.sin_addr.s_addr = addr & ent->mask.sin_addr.s_addr;
- IPFW_WLOCK(&layer3_chain);
+ IPFW_WLOCK(&V_layer3_chain);
if (rnh->rnh_addaddr(&ent->addr, &ent->mask, rnh, (void *)ent) ==
NULL) {
- IPFW_WUNLOCK(&layer3_chain);
+ IPFW_WUNLOCK(&V_layer3_chain);
free(ent, M_IPFW_TBL);
return (EEXIST);
}
- IPFW_WUNLOCK(&layer3_chain);
+ IPFW_WUNLOCK(&V_layer3_chain);
return (0);
}
@@ -2005,10 +2006,10 @@ check_uidgid(ipfw_insn_u32 *insn, int proto, struct ifnet *oif,
return (0);
if (proto == IPPROTO_TCP) {
wildcard = 0;
- pi = &tcbinfo;
+ pi = &V_tcbinfo;
} else if (proto == IPPROTO_UDP) {
wildcard = INPLOOKUP_WILDCARD;
- pi = &udbinfo;
+ pi = &V_udbinfo;
} else
return 0;
match = 0;
@@ -2196,7 +2197,7 @@ ipfw_chk(struct ip_fw_args *args)
*/
int dyn_dir = MATCH_UNKNOWN;
ipfw_dyn_rule *q = NULL;
- struct ip_fw_chain *chain = &layer3_chain;
+ struct ip_fw_chain *chain = &V_layer3_chain;
struct m_tag *mtag;
/*
@@ -2300,7 +2301,7 @@ do { \
printf("IPFW2: IPV6 - Unknown Routing "
"Header type(%d)\n",
((struct ip6_rthdr *)ulp)->ip6r_type);
- if (fw_deny_unknown_exthdrs)
+ if (V_fw_deny_unknown_exthdrs)
return (IP_FW_DENY);
break;
}
@@ -2324,7 +2325,7 @@ do { \
if (offset == 0) {
printf("IPFW2: IPV6 - Invalid Fragment "
"Header\n");
- if (fw_deny_unknown_exthdrs)
+ if (V_fw_deny_unknown_exthdrs)
return (IP_FW_DENY);
break;
}
@@ -2396,7 +2397,7 @@ do { \
default:
printf("IPFW2: IPV6 - Unknown Extension "
"Header(%d), ext_hd=%x\n", proto, ext_hd);
- if (fw_deny_unknown_exthdrs)
+ if (V_fw_deny_unknown_exthdrs)
return (IP_FW_DENY);
PULLUP_TO(hlen, ulp, struct ip6_ext);
break;
@@ -2477,7 +2478,7 @@ do { \
* XXX should not happen here, but optimized out in
* the caller.
*/
- if (fw_one_pass) {
+ if (V_fw_one_pass) {
IPFW_RUNLOCK(chain);
return (IP_FW_PASS);
}
@@ -2522,7 +2523,7 @@ do { \
int l, cmdlen, skip_or; /* skip rest of OR block */
again:
- if (set_disable & (1 << f->set) )
+ if (V_set_disable & (1 << f->set) )
continue;
skip_or = 0;
@@ -2908,7 +2909,7 @@ check_body:
}
case O_LOG:
- if (fw_verbose)
+ if (V_fw_verbose)
ipfw_log(f, hlen, args, m,
oif, offset, tablearg, ip);
match = 1;
@@ -3328,7 +3329,7 @@ check_body:
if (t == NULL) {
nat_id = (cmd->arg1 == IP_FW_TABLEARG) ?
tablearg : cmd->arg1;
- LOOKUP_NAT(layer3_chain, nat_id, t);
+ LOOKUP_NAT(V_layer3_chain, nat_id, t);
if (t == NULL) {
retval = IP_FW_DENY;
goto done;
@@ -3375,7 +3376,7 @@ done:
return (retval);
pullup_failed:
- if (fw_verbose)
+ if (V_fw_verbose)
printf("ipfw: pullup failed\n");
return (IP_FW_DENY);
}
@@ -3433,10 +3434,10 @@ add_rule(struct ip_fw_chain *chain, struct ip_fw *input_rule)
* If rulenum is 0, find highest numbered rule before the
* default rule, and add autoinc_step
*/
- if (autoinc_step < 1)
- autoinc_step = 1;
- else if (autoinc_step > 1000)
- autoinc_step = 1000;
+ if (V_autoinc_step < 1)
+ V_autoinc_step = 1;
+ else if (V_autoinc_step > 1000)
+ V_autoinc_step = 1000;
if (rule->rulenum == 0) {
/*
* locate the highest numbered rule before default
@@ -3446,8 +3447,8 @@ add_rule(struct ip_fw_chain *chain, struct ip_fw *input_rule)
break;
rule->rulenum = f->rulenum;
}
- if (rule->rulenum < IPFW_DEFAULT_RULE - autoinc_step)
- rule->rulenum += autoinc_step;
+ if (rule->rulenum < IPFW_DEFAULT_RULE - V_autoinc_step)
+ rule->rulenum += V_autoinc_step;
input_rule->rulenum = rule->rulenum;
}
@@ -3468,11 +3469,11 @@ add_rule(struct ip_fw_chain *chain, struct ip_fw *input_rule)
}
flush_rule_ptrs(chain);
done:
- static_count++;
+ V_static_count++;
static_len += l;
IPFW_WUNLOCK(chain);
DEB(printf("ipfw: installed rule %d, static count now %d\n",
- rule->rulenum, static_count);)
+ rule->rulenum, V_static_count);)
return (0);
}
@@ -3501,7 +3502,7 @@ remove_rule(struct ip_fw_chain *chain, struct ip_fw *rule,
chain->rules = n;
else
prev->next = n;
- static_count--;
+ V_static_count--;
static_len -= l;
rule->next = chain->reap;
@@ -3716,7 +3717,7 @@ zero_entry(struct ip_fw_chain *chain, u_int32_t arg, int log_only)
IPFW_WLOCK(chain);
if (rulenum == 0) {
- norule_counter = 0;
+ V_norule_counter = 0;
for (rule = chain->rules; rule; rule = rule->next) {
/* Skip rules from another set. */
if (cmd == 1 && rule->set != set)
@@ -3750,7 +3751,7 @@ zero_entry(struct ip_fw_chain *chain, u_int32_t arg, int log_only)
}
IPFW_WUNLOCK(chain);
- if (fw_verbose)
+ if (V_fw_verbose)
log(LOG_SECURITY | LOG_NOTICE, msg, rulenum);
return (0);
}
@@ -4093,20 +4094,20 @@ ipfw_getrules(struct ip_fw_chain *chain, void *buf, size_t space)
* in a wild attempt to keep the ABI the same.
* Why do we do this on EVERY rule?
*/
- bcopy(&set_disable, &(((struct ip_fw *)bp)->next_rule),
- sizeof(set_disable));
+ bcopy(&V_set_disable, &(((struct ip_fw *)bp)->next_rule),
+ sizeof(V_set_disable));
if (((struct ip_fw *)bp)->timestamp)
((struct ip_fw *)bp)->timestamp += boot_seconds;
bp += i;
}
}
IPFW_RUNLOCK(chain);
- if (ipfw_dyn_v) {
+ if (V_ipfw_dyn_v) {
ipfw_dyn_rule *p, *last = NULL;
IPFW_DYN_LOCK();
- for (i = 0 ; i < curr_dyn_buckets; i++)
- for (p = ipfw_dyn_v[i] ; p != NULL; p = p->next) {
+ for (i = 0 ; i < V_curr_dyn_buckets; i++)
+ for (p = V_ipfw_dyn_v[i] ; p != NULL; p = p->next) {
if (bp + sizeof *p <= ep) {
ipfw_dyn_rule *dst =
(ipfw_dyn_rule *)bp;
@@ -4186,8 +4187,8 @@ ipfw_ctl(struct sockopt *sopt)
* data in which case we'll just return what fits.
*/
size = static_len; /* size of static rules */
- if (ipfw_dyn_v) /* add size of dyn.rules */
- size += (dyn_count * sizeof(ipfw_dyn_rule));
+ if (V_ipfw_dyn_v) /* add size of dyn.rules */
+ size += (V_dyn_count * sizeof(ipfw_dyn_rule));
/*
* XXX todo: if the user passes a short length just to know
@@ -4196,7 +4197,7 @@ ipfw_ctl(struct sockopt *sopt)
*/
buf = malloc(size, M_TEMP, M_WAITOK);
error = sooptcopyout(sopt, buf,
- ipfw_getrules(&layer3_chain, buf, size));
+ ipfw_getrules(&V_layer3_chain, buf, size));
free(buf, M_TEMP);
break;
@@ -4214,12 +4215,12 @@ ipfw_ctl(struct sockopt *sopt)
* the old list without the need for a lock.
*/
- IPFW_WLOCK(&layer3_chain);
- layer3_chain.reap = NULL;
- free_chain(&layer3_chain, 0 /* keep default rule */);
- rule = layer3_chain.reap;
- layer3_chain.reap = NULL;
- IPFW_WUNLOCK(&layer3_chain);
+ IPFW_WLOCK(&V_layer3_chain);
+ V_layer3_chain.reap = NULL;
+ free_chain(&V_layer3_chain, 0 /* keep default rule */);
+ rule = V_layer3_chain.reap;
+ V_layer3_chain.reap = NULL;
+ IPFW_WUNLOCK(&V_layer3_chain);
if (rule != NULL)
reap_rules(rule);
break;
@@ -4231,7 +4232,7 @@ ipfw_ctl(struct sockopt *sopt)
if (error == 0)
error = check_ipfw_struct(rule, sopt->sopt_valsize);
if (error == 0) {
- error = add_rule(&layer3_chain, rule);
+ error = add_rule(&V_layer3_chain, rule);
size = RULESIZE(rule);
if (!error && sopt->sopt_dir == SOPT_GET)
error = sooptcopyout(sopt, rule, size);
@@ -4258,10 +4259,10 @@ ipfw_ctl(struct sockopt *sopt)
break;
size = sopt->sopt_valsize;
if (size == sizeof(u_int32_t)) /* delete or reassign */
- error = del_entry(&layer3_chain, rulenum[0]);
+ error = del_entry(&V_layer3_chain, rulenum[0]);
else if (size == 2*sizeof(u_int32_t)) /* set enable/disable */
- set_disable =
- (set_disable | rulenum[0]) & ~rulenum[1] &
+ V_set_disable =
+ (V_set_disable | rulenum[0]) & ~rulenum[1] &
~(1<<RESVD_SET); /* set RESVD_SET always enabled */
else
error = EINVAL;
@@ -4276,7 +4277,7 @@ ipfw_ctl(struct sockopt *sopt)
if (error)
break;
}
- error = zero_entry(&layer3_chain, rulenum[0],
+ error = zero_entry(&V_layer3_chain, rulenum[0],
sopt->sopt_name == IP_FW_RESETLOG);
break;
@@ -4288,7 +4289,7 @@ ipfw_ctl(struct sockopt *sopt)
sizeof(ent), sizeof(ent));
if (error)
break;
- error = add_table_entry(&layer3_chain, ent.tbl,
+ error = add_table_entry(&V_layer3_chain, ent.tbl,
ent.addr, ent.masklen, ent.value);
}
break;
@@ -4301,7 +4302,7 @@ ipfw_ctl(struct sockopt *sopt)
sizeof(ent), sizeof(ent));
if (error)
break;
- error = del_table_entry(&layer3_chain, ent.tbl,
+ error = del_table_entry(&V_layer3_chain, ent.tbl,
ent.addr, ent.masklen);
}
break;
@@ -4314,9 +4315,9 @@ ipfw_ctl(struct sockopt *sopt)
sizeof(tbl), sizeof(tbl));
if (error)
break;
- IPFW_WLOCK(&layer3_chain);
- error = flush_table(&layer3_chain, tbl);
- IPFW_WUNLOCK(&layer3_chain);
+ IPFW_WLOCK(&V_layer3_chain);
+ error = flush_table(&V_layer3_chain, tbl);
+ IPFW_WUNLOCK(&V_layer3_chain);
}
break;
@@ -4327,9 +4328,9 @@ ipfw_ctl(struct sockopt *sopt)
if ((error = sooptcopyin(sopt, &tbl, sizeof(tbl),
sizeof(tbl))))
break;
- IPFW_RLOCK(&layer3_chain);
- error = count_table(&layer3_chain, tbl, &cnt);
- IPFW_RUNLOCK(&layer3_chain);
+ IPFW_RLOCK(&V_layer3_chain);
+ error = count_table(&V_layer3_chain, tbl, &cnt);
+ IPFW_RUNLOCK(&V_layer3_chain);
if (error)
break;
error = sooptcopyout(sopt, &cnt, sizeof(cnt));
@@ -4353,9 +4354,9 @@ ipfw_ctl(struct sockopt *sopt)
}
tbl->size = (size - sizeof(*tbl)) /
sizeof(ipfw_table_entry);
- IPFW_RLOCK(&layer3_chain);
- error = dump_table(&layer3_chain, tbl);
- IPFW_RUNLOCK(&layer3_chain);
+ IPFW_RLOCK(&V_layer3_chain);
+ error = dump_table(&V_layer3_chain, tbl);
+ IPFW_RUNLOCK(&V_layer3_chain);
if (error) {
free(tbl, M_TEMP);
break;
@@ -4439,7 +4440,7 @@ ipfw_tick(void * __unused unused)
int i;
ipfw_dyn_rule *q;
- if (dyn_keepalive == 0 || ipfw_dyn_v == NULL || dyn_count == 0)
+ if (V_dyn_keepalive == 0 || V_ipfw_dyn_v == NULL || V_dyn_count == 0)
goto done;
/*
@@ -4451,15 +4452,15 @@ ipfw_tick(void * __unused unused)
m0 = NULL;
mtailp = &m0;
IPFW_DYN_LOCK();
- for (i = 0 ; i < curr_dyn_buckets ; i++) {
- for (q = ipfw_dyn_v[i] ; q ; q = q->next ) {
+ for (i = 0 ; i < V_curr_dyn_buckets ; i++) {
+ for (q = V_ipfw_dyn_v[i] ; q ; q = q->next ) {
if (q->dyn_type == O_LIMIT_PARENT)
continue;
if (q->id.proto != IPPROTO_TCP)
continue;
if ( (q->state & BOTH_SYN) != BOTH_SYN)
continue;
- if (TIME_LEQ( time_uptime+dyn_keepalive_interval,
+ if (TIME_LEQ( time_uptime+V_dyn_keepalive_interval,
q->expire))
continue; /* too early */
if (TIME_LEQ(q->expire, time_uptime))
@@ -4482,7 +4483,7 @@ ipfw_tick(void * __unused unused)
ip_output(m, NULL, NULL, 0, NULL, NULL);
}
done:
- callout_reset(&ipfw_timeout, dyn_keepalive_period*hz, ipfw_tick, NULL);
+ callout_reset(&V_ipfw_timeout, V_dyn_keepalive_period*hz, ipfw_tick, NULL);
}
int
@@ -4499,20 +4500,20 @@ ipfw_init(void)
CTLFLAG_RW | CTLFLAG_SECURE, 0, "Firewall");
SYSCTL_ADD_PROC(&ip6_fw_sysctl_ctx, SYSCTL_CHILDREN(ip6_fw_sysctl_tree),
OID_AUTO, "enable", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_SECURE3,
- &fw6_enable, 0, ipfw_chg_hook, "I", "Enable ipfw+6");
+ &V_fw6_enable, 0, ipfw_chg_hook, "I", "Enable ipfw+6");
SYSCTL_ADD_INT(&ip6_fw_sysctl_ctx, SYSCTL_CHILDREN(ip6_fw_sysctl_tree),
OID_AUTO, "deny_unknown_exthdrs", CTLFLAG_RW | CTLFLAG_SECURE,
- &fw_deny_unknown_exthdrs, 0,
+ &V_fw_deny_unknown_exthdrs, 0,
"Deny packets with unknown IPv6 Extension Headers");
#endif
- layer3_chain.rules = NULL;
- IPFW_LOCK_INIT(&layer3_chain);
+ V_layer3_chain.rules = NULL;
+ IPFW_LOCK_INIT(&V_layer3_chain);
ipfw_dyn_rule_zone = uma_zcreate("IPFW dynamic rule",
sizeof(ipfw_dyn_rule), NULL, NULL, NULL, NULL,
UMA_ALIGN_PTR, 0);
IPFW_DYN_LOCK_INIT();
- callout_init(&ipfw_timeout, CALLOUT_MPSAFE);
+ callout_init(&V_ipfw_timeout, CALLOUT_MPSAFE);
bzero(&default_rule, sizeof default_rule);
@@ -4528,17 +4529,17 @@ ipfw_init(void)
#endif
O_DENY;
- error = add_rule(&layer3_chain, &default_rule);
+ error = add_rule(&V_layer3_chain, &default_rule);
if (error != 0) {
printf("ipfw2: error %u initializing default rule "
"(support disabled)\n", error);
IPFW_DYN_LOCK_DESTROY();
- IPFW_LOCK_DESTROY(&layer3_chain);
+ IPFW_LOCK_DESTROY(&V_layer3_chain);
uma_zdestroy(ipfw_dyn_rule_zone);
return (error);
}
- ip_fw_default_rule = layer3_chain.rules;
+ ip_fw_default_rule = V_layer3_chain.rules;
printf("ipfw2 "
#ifdef INET6
"(+ipv6) "
@@ -4565,30 +4566,30 @@ ipfw_init(void)
default_rule.cmd[0].opcode == O_ACCEPT ? "accept" : "deny");
#ifdef IPFIREWALL_VERBOSE
- fw_verbose = 1;
+ V_fw_verbose = 1;
#endif
#ifdef IPFIREWALL_VERBOSE_LIMIT
- verbose_limit = IPFIREWALL_VERBOSE_LIMIT;
+ V_verbose_limit = IPFIREWALL_VERBOSE_LIMIT;
#endif
- if (fw_verbose == 0)
+ if (V_fw_verbose == 0)
printf("disabled\n");
- else if (verbose_limit == 0)
+ else if (V_verbose_limit == 0)
printf("unlimited\n");
else
printf("limited to %d packets/entry by default\n",
- verbose_limit);
+ V_verbose_limit);
- error = init_tables(&layer3_chain);
+ error = init_tables(&V_layer3_chain);
if (error) {
IPFW_DYN_LOCK_DESTROY();
- IPFW_LOCK_DESTROY(&layer3_chain);
+ IPFW_LOCK_DESTROY(&V_layer3_chain);
uma_zdestroy(ipfw_dyn_rule_zone);
return (error);
}
ip_fw_ctl_ptr = ipfw_ctl;
ip_fw_chk_ptr = ipfw_chk;
- callout_reset(&ipfw_timeout, hz, ipfw_tick, NULL);
- LIST_INIT(&layer3_chain.nat);
+ callout_reset(&V_ipfw_timeout, hz, ipfw_tick, NULL);
+ LIST_INIT(&V_layer3_chain.nat);
return (0);
}
@@ -4599,20 +4600,20 @@ ipfw_destroy(void)
ip_fw_chk_ptr = NULL;
ip_fw_ctl_ptr = NULL;
- callout_drain(&ipfw_timeout);
- IPFW_WLOCK(&layer3_chain);
- flush_tables(&layer3_chain);
- layer3_chain.reap = NULL;
- free_chain(&layer3_chain, 1 /* kill default rule */);
- reap = layer3_chain.reap, layer3_chain.reap = NULL;
- IPFW_WUNLOCK(&layer3_chain);
+ callout_drain(&V_ipfw_timeout);
+ IPFW_WLOCK(&V_layer3_chain);
+ flush_tables(&V_layer3_chain);
+ V_layer3_chain.reap = NULL;
+ free_chain(&V_layer3_chain, 1 /* kill default rule */);
+ reap = V_layer3_chain.reap, V_layer3_chain.reap = NULL;
+ IPFW_WUNLOCK(&V_layer3_chain);
if (reap != NULL)
reap_rules(reap);
IPFW_DYN_LOCK_DESTROY();
uma_zdestroy(ipfw_dyn_rule_zone);
- if (ipfw_dyn_v != NULL)
- free(ipfw_dyn_v, M_IPFW);
- IPFW_LOCK_DESTROY(&layer3_chain);
+ if (V_ipfw_dyn_v != NULL)
+ free(V_ipfw_dyn_v, M_IPFW);
+ IPFW_LOCK_DESTROY(&V_layer3_chain);
#ifdef INET6
/* Free IPv6 fw sysctl tree. */
diff --git a/sys/netinet/ip_fw_nat.c b/sys/netinet/ip_fw_nat.c
index 3a4f4a1..688a181 100644
--- a/sys/netinet/ip_fw_nat.c
+++ b/sys/netinet/ip_fw_nat.c
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sysctl.h>
#include <sys/syslog.h>
#include <sys/ucred.h>
+#include <sys/vimage.h>
#include <netinet/libalias/alias.h>
#include <netinet/libalias/alias_local.h>
@@ -84,9 +85,9 @@ ifaddr_change(void *arg __unused, struct ifnet *ifp)
struct cfg_nat *ptr;
struct ifaddr *ifa;
- IPFW_WLOCK(&layer3_chain);
+ IPFW_WLOCK(&V_layer3_chain);
/* Check every nat entry... */
- LIST_FOREACH(ptr, &layer3_chain.nat, _next) {
+ LIST_FOREACH(ptr, &V_layer3_chain.nat, _next) {
/* ...using nic 'ifp->if_xname' as dynamic alias address. */
if (strncmp(ptr->if_name, ifp->if_xname, IF_NAMESIZE) == 0) {
mtx_lock(&ifp->if_addr_mtx);
@@ -102,7 +103,7 @@ ifaddr_change(void *arg __unused, struct ifnet *ifp)
mtx_unlock(&ifp->if_addr_mtx);
}
}
- IPFW_WUNLOCK(&layer3_chain);
+ IPFW_WUNLOCK(&V_layer3_chain);
}
static void
@@ -110,8 +111,8 @@ flush_nat_ptrs(const int i)
{
struct ip_fw *rule;
- IPFW_WLOCK_ASSERT(&layer3_chain);
- for (rule = layer3_chain.rules; rule; rule = rule->next) {
+ IPFW_WLOCK_ASSERT(&V_layer3_chain);
+ for (rule = V_layer3_chain.rules; rule; rule = rule->next) {
ipfw_insn_nat *cmd = (ipfw_insn_nat *)ACTION_PTR(rule);
if (cmd->o.opcode != O_NAT)
continue;
@@ -121,12 +122,12 @@ flush_nat_ptrs(const int i)
}
#define HOOK_NAT(b, p) do { \
- IPFW_WLOCK_ASSERT(&layer3_chain); \
+ IPFW_WLOCK_ASSERT(&V_layer3_chain); \
LIST_INSERT_HEAD(b, p, _next); \
} while (0)
#define UNHOOK_NAT(p) do { \
- IPFW_WLOCK_ASSERT(&layer3_chain); \
+ IPFW_WLOCK_ASSERT(&V_layer3_chain); \
LIST_REMOVE(p, _next); \
} while (0)
@@ -414,20 +415,20 @@ ipfw_nat_cfg(struct sockopt *sopt)
/*
* Find/create nat rule.
*/
- IPFW_WLOCK(&layer3_chain);
- LOOKUP_NAT(layer3_chain, ser_n->id, ptr);
+ IPFW_WLOCK(&V_layer3_chain);
+ LOOKUP_NAT(V_layer3_chain, ser_n->id, ptr);
if (ptr == NULL) {
/* New rule: allocate and init new instance. */
ptr = malloc(sizeof(struct cfg_nat),
M_IPFW, M_NOWAIT | M_ZERO);
if (ptr == NULL) {
- IPFW_WUNLOCK(&layer3_chain);
+ IPFW_WUNLOCK(&V_layer3_chain);
free(buf, M_IPFW);
return (ENOSPC);
}
ptr->lib = LibAliasInit(NULL);
if (ptr->lib == NULL) {
- IPFW_WUNLOCK(&layer3_chain);
+ IPFW_WUNLOCK(&V_layer3_chain);
free(ptr, M_IPFW);
free(buf, M_IPFW);
return (EINVAL);
@@ -438,7 +439,7 @@ ipfw_nat_cfg(struct sockopt *sopt)
UNHOOK_NAT(ptr);
flush_nat_ptrs(ser_n->id);
}
- IPFW_WUNLOCK(&layer3_chain);
+ IPFW_WUNLOCK(&V_layer3_chain);
/*
* Basic nat configuration.
@@ -464,9 +465,9 @@ ipfw_nat_cfg(struct sockopt *sopt)
/* Add new entries. */
add_redir_spool_cfg(&buf[(sizeof(struct cfg_nat))], ptr);
free(buf, M_IPFW);
- IPFW_WLOCK(&layer3_chain);
- HOOK_NAT(&layer3_chain.nat, ptr);
- IPFW_WUNLOCK(&layer3_chain);
+ IPFW_WLOCK(&V_layer3_chain);
+ HOOK_NAT(&V_layer3_chain.nat, ptr);
+ IPFW_WUNLOCK(&V_layer3_chain);
return (0);
}
@@ -477,15 +478,15 @@ ipfw_nat_del(struct sockopt *sopt)
int i;
sooptcopyin(sopt, &i, sizeof i, sizeof i);
- IPFW_WLOCK(&layer3_chain);
- LOOKUP_NAT(layer3_chain, i, ptr);
+ IPFW_WLOCK(&V_layer3_chain);
+ LOOKUP_NAT(V_layer3_chain, i, ptr);
if (ptr == NULL) {
- IPFW_WUNLOCK(&layer3_chain);
+ IPFW_WUNLOCK(&V_layer3_chain);
return (EINVAL);
}
UNHOOK_NAT(ptr);
flush_nat_ptrs(i);
- IPFW_WUNLOCK(&layer3_chain);
+ IPFW_WUNLOCK(&V_layer3_chain);
del_redir_spool_cfg(ptr, &ptr->redir_chain);
LibAliasUninit(ptr->lib);
free(ptr, M_IPFW);
@@ -505,9 +506,9 @@ ipfw_nat_get_cfg(struct sockopt *sopt)
off = sizeof(nat_cnt);
data = malloc(NAT_BUF_LEN, M_IPFW, M_WAITOK | M_ZERO);
- IPFW_RLOCK(&layer3_chain);
+ IPFW_RLOCK(&V_layer3_chain);
/* Serialize all the data. */
- LIST_FOREACH(n, &layer3_chain.nat, _next) {
+ LIST_FOREACH(n, &V_layer3_chain.nat, _next) {
nat_cnt++;
if (off + SOF_NAT < NAT_BUF_LEN) {
bcopy(n, &data[off], SOF_NAT);
@@ -534,12 +535,12 @@ ipfw_nat_get_cfg(struct sockopt *sopt)
goto nospace;
}
bcopy(&nat_cnt, data, sizeof(nat_cnt));
- IPFW_RUNLOCK(&layer3_chain);
+ IPFW_RUNLOCK(&V_layer3_chain);
sooptcopyout(sopt, data, NAT_BUF_LEN);
free(data, M_IPFW);
return (0);
nospace:
- IPFW_RUNLOCK(&layer3_chain);
+ IPFW_RUNLOCK(&V_layer3_chain);
printf("serialized data buffer not big enough:"
"please increase NAT_BUF_LEN\n");
free(data, M_IPFW);
@@ -557,16 +558,16 @@ ipfw_nat_get_log(struct sockopt *sopt)
sof = LIBALIAS_BUF_SIZE;
cnt = 0;
- IPFW_RLOCK(&layer3_chain);
+ IPFW_RLOCK(&V_layer3_chain);
size = i = 0;
- LIST_FOREACH(ptr, &layer3_chain.nat, _next) {
+ LIST_FOREACH(ptr, &V_layer3_chain.nat, _next) {
if (ptr->lib->logDesc == NULL)
continue;
cnt++;
size = cnt * (sof + sizeof(int));
data = realloc(data, size, M_IPFW, M_NOWAIT | M_ZERO);
if (data == NULL) {
- IPFW_RUNLOCK(&layer3_chain);
+ IPFW_RUNLOCK(&V_layer3_chain);
return (ENOSPC);
}
bcopy(&ptr->id, &data[i], sizeof(int));
@@ -574,7 +575,7 @@ ipfw_nat_get_log(struct sockopt *sopt)
bcopy(ptr->lib->logDesc, &data[i], sof);
i += sof;
}
- IPFW_RUNLOCK(&layer3_chain);
+ IPFW_RUNLOCK(&V_layer3_chain);
sooptcopyout(sopt, data, size);
free(data, M_IPFW);
return(0);
@@ -584,15 +585,15 @@ static void
ipfw_nat_init(void)
{
- IPFW_WLOCK(&layer3_chain);
+ IPFW_WLOCK(&V_layer3_chain);
/* init ipfw hooks */
ipfw_nat_ptr = ipfw_nat;
ipfw_nat_cfg_ptr = ipfw_nat_cfg;
ipfw_nat_del_ptr = ipfw_nat_del;
ipfw_nat_get_cfg_ptr = ipfw_nat_get_cfg;
ipfw_nat_get_log_ptr = ipfw_nat_get_log;
- IPFW_WUNLOCK(&layer3_chain);
- ifaddr_event_tag = EVENTHANDLER_REGISTER(ifaddr_event, ifaddr_change,
+ IPFW_WUNLOCK(&V_layer3_chain);
+ V_ifaddr_event_tag = EVENTHANDLER_REGISTER(ifaddr_event, ifaddr_change,
NULL, EVENTHANDLER_PRI_ANY);
}
@@ -602,23 +603,23 @@ ipfw_nat_destroy(void)
struct ip_fw *rule;
struct cfg_nat *ptr, *ptr_temp;
- IPFW_WLOCK(&layer3_chain);
- LIST_FOREACH_SAFE(ptr, &layer3_chain.nat, _next, ptr_temp) {
+ IPFW_WLOCK(&V_layer3_chain);
+ LIST_FOREACH_SAFE(ptr, &V_layer3_chain.nat, _next, ptr_temp) {
LIST_REMOVE(ptr, _next);
del_redir_spool_cfg(ptr, &ptr->redir_chain);
LibAliasUninit(ptr->lib);
free(ptr, M_IPFW);
}
- EVENTHANDLER_DEREGISTER(ifaddr_event, ifaddr_event_tag);
+ EVENTHANDLER_DEREGISTER(ifaddr_event, V_ifaddr_event_tag);
/* flush all nat ptrs */
- for (rule = layer3_chain.rules; rule; rule = rule->next) {
+ for (rule = V_layer3_chain.rules; rule; rule = rule->next) {
ipfw_insn_nat *cmd = (ipfw_insn_nat *)ACTION_PTR(rule);
if (cmd->o.opcode == O_NAT)
cmd->nat = NULL;
}
/* deregister ipfw_nat */
ipfw_nat_ptr = NULL;
- IPFW_WUNLOCK(&layer3_chain);
+ IPFW_WUNLOCK(&V_layer3_chain);
}
static int
diff --git a/sys/netinet/ip_fw_pfil.c b/sys/netinet/ip_fw_pfil.c
index 896194c..64a1752 100644
--- a/sys/netinet/ip_fw_pfil.c
+++ b/sys/netinet/ip_fw_pfil.c
@@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
#include <sys/socketvar.h>
#include <sys/sysctl.h>
#include <sys/ucred.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/route.h>
@@ -498,14 +499,14 @@ ipfw_chg_hook(SYSCTL_HANDLER_ARGS)
if (enable == *(int *)arg1)
return (0);
- if (arg1 == &fw_enable) {
+ if (arg1 == &V_fw_enable) {
if (enable)
error = ipfw_hook();
else
error = ipfw_unhook();
}
#ifdef INET6
- if (arg1 == &fw6_enable) {
+ if (arg1 == &V_fw6_enable) {
if (enable)
error = ipfw6_hook();
else
diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c
index 153a815..bd8ac70 100644
--- a/sys/netinet/ip_icmp.c
+++ b/sys/netinet/ip_icmp.c
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
#include <sys/time.h>
#include <sys/kernel.h>
#include <sys/sysctl.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_types.h>
@@ -155,7 +156,7 @@ icmp_error(struct mbuf *n, int type, int code, n_long dest, int mtu)
printf("icmp_error(%p, %x, %d)\n", oip, type, code);
#endif
if (type != ICMP_REDIRECT)
- icmpstat.icps_error++;
+ V_icmpstat.icps_error++;
/*
* Don't send error:
* if the original packet was encrypted.
@@ -172,7 +173,7 @@ icmp_error(struct mbuf *n, int type, int code, n_long dest, int mtu)
if (oip->ip_p == IPPROTO_ICMP && type != ICMP_REDIRECT &&
n->m_len >= oiphlen + ICMP_MINLEN &&
!ICMP_INFOTYPE(((struct icmp *)((caddr_t)oip + oiphlen))->icmp_type)) {
- icmpstat.icps_oldicmp++;
+ V_icmpstat.icps_oldicmp++;
goto freeit;
}
/* Drop if IP header plus 8 bytes is not contignous in first mbuf. */
@@ -232,7 +233,7 @@ stdreply: icmpelen = max(8, min(icmp_quotelen, oip->ip_len - oiphlen));
*/
M_SETFIB(m, M_GETFIB(n));
icp = mtod(m, struct icmp *);
- icmpstat.icps_outhist[type]++;
+ V_icmpstat.icps_outhist[type]++;
icp->icmp_type = type;
if (type == ICMP_REDIRECT)
icp->icmp_gwaddr.s_addr = dest;
@@ -314,12 +315,12 @@ icmp_input(struct mbuf *m, int off)
}
#endif
if (icmplen < ICMP_MINLEN) {
- icmpstat.icps_tooshort++;
+ V_icmpstat.icps_tooshort++;
goto freeit;
}
i = hlen + min(icmplen, ICMP_ADVLENMIN);
if (m->m_len < i && (m = m_pullup(m, i)) == 0) {
- icmpstat.icps_tooshort++;
+ V_icmpstat.icps_tooshort++;
return;
}
ip = mtod(m, struct ip *);
@@ -327,7 +328,7 @@ icmp_input(struct mbuf *m, int off)
m->m_data += hlen;
icp = mtod(m, struct icmp *);
if (in_cksum(m, icmplen)) {
- icmpstat.icps_checksum++;
+ V_icmpstat.icps_checksum++;
goto freeit;
}
m->m_len += hlen;
@@ -369,7 +370,7 @@ icmp_input(struct mbuf *m, int off)
icmpgw.sin_len = sizeof(struct sockaddr_in);
icmpgw.sin_family = AF_INET;
- icmpstat.icps_inhist[icp->icmp_type]++;
+ V_icmpstat.icps_inhist[icp->icmp_type]++;
code = icp->icmp_code;
switch (icp->icmp_type) {
@@ -434,7 +435,7 @@ icmp_input(struct mbuf *m, int off)
*/
if (icmplen < ICMP_ADVLENMIN || icmplen < ICMP_ADVLEN(icp) ||
icp->icmp_ip.ip_hl < (sizeof(struct ip) >> 2)) {
- icmpstat.icps_badlen++;
+ V_icmpstat.icps_badlen++;
goto freeit;
}
icp->icmp_ip.ip_len = ntohs(icp->icmp_ip.ip_len);
@@ -457,13 +458,13 @@ icmp_input(struct mbuf *m, int off)
break;
badcode:
- icmpstat.icps_badcode++;
+ V_icmpstat.icps_badcode++;
break;
case ICMP_ECHO:
if (!icmpbmcastecho
&& (m->m_flags & (M_MCAST | M_BCAST)) != 0) {
- icmpstat.icps_bmcastecho++;
+ V_icmpstat.icps_bmcastecho++;
break;
}
icp->icmp_type = ICMP_ECHOREPLY;
@@ -475,11 +476,11 @@ icmp_input(struct mbuf *m, int off)
case ICMP_TSTAMP:
if (!icmpbmcastecho
&& (m->m_flags & (M_MCAST | M_BCAST)) != 0) {
- icmpstat.icps_bmcasttstamp++;
+ V_icmpstat.icps_bmcasttstamp++;
break;
}
if (icmplen < ICMP_TSLEN) {
- icmpstat.icps_badlen++;
+ V_icmpstat.icps_badlen++;
break;
}
icp->icmp_type = ICMP_TSTAMPREPLY;
@@ -528,8 +529,8 @@ icmp_input(struct mbuf *m, int off)
}
reflect:
ip->ip_len += hlen; /* since ip_input deducts this */
- icmpstat.icps_reflect++;
- icmpstat.icps_outhist[icp->icmp_type]++;
+ V_icmpstat.icps_reflect++;
+ V_icmpstat.icps_outhist[icp->icmp_type]++;
icmp_reflect(m);
return;
@@ -553,13 +554,13 @@ reflect:
* RFC1812 says we must ignore ICMP redirects if we
* are acting as router.
*/
- if (drop_redirect || ipforwarding)
+ if (drop_redirect || V_ipforwarding)
break;
if (code > 3)
goto badcode;
if (icmplen < ICMP_ADVLENMIN || icmplen < ICMP_ADVLEN(icp) ||
icp->icmp_ip.ip_hl < (sizeof(struct ip) >> 2)) {
- icmpstat.icps_badlen++;
+ V_icmpstat.icps_badlen++;
break;
}
/*
@@ -633,7 +634,7 @@ icmp_reflect(struct mbuf *m)
IN_EXPERIMENTAL(ntohl(ip->ip_src.s_addr)) ||
IN_ZERONET(ntohl(ip->ip_src.s_addr)) ) {
m_freem(m); /* Bad return address */
- icmpstat.icps_badaddr++;
+ V_icmpstat.icps_badaddr++;
goto done; /* Ip_output() will check for broadcast */
}
@@ -702,7 +703,7 @@ icmp_reflect(struct mbuf *m)
ia = ip_rtaddr(ip->ip_dst, M_GETFIB(m));
if (ia == NULL) {
m_freem(m);
- icmpstat.icps_noroute++;
+ V_icmpstat.icps_noroute++;
goto done;
}
match:
@@ -711,7 +712,7 @@ match:
#endif
t = IA_SIN(ia)->sin_addr;
ip->ip_src = t;
- ip->ip_ttl = ip_defttl;
+ ip->ip_ttl = V_ip_defttl;
if (optlen > 0) {
register u_char *cp;
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index 7abb4e4..4ab975e6 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/syslog.h>
#include <sys/sysctl.h>
+#include <sys/vimage.h>
#include <net/pfil.h>
#include <net/if.h>
@@ -216,8 +217,8 @@ ip_init(void)
struct protosw *pr;
int i;
- TAILQ_INIT(&in_ifaddrhead);
- in_ifaddrhashtbl = hashinit(INADDR_NHASH, M_IFADDR, &in_ifaddrhmask);
+ TAILQ_INIT(&V_in_ifaddrhead);
+ V_in_ifaddrhashtbl = hashinit(INADDR_NHASH, M_IFADDR, &V_in_ifaddrhmask);
pr = pffindproto(PF_INET, IPPROTO_RAW, SOCK_RAW);
if (pr == NULL)
panic("ip_init: PF_INET not found");
@@ -248,10 +249,10 @@ ip_init(void)
/* Initialize IP reassembly queue. */
IPQ_LOCK_INIT();
for (i = 0; i < IPREASS_NHASH; i++)
- TAILQ_INIT(&ipq[i]);
- maxnipq = nmbclusters / 32;
- maxfragsperpacket = 16;
- ipq_zone = uma_zcreate("ipq", sizeof(struct ipq), NULL, NULL, NULL,
+ TAILQ_INIT(&V_ipq[i]);
+ V_maxnipq = nmbclusters / 32;
+ V_maxfragsperpacket = 16;
+ V_ipq_zone = uma_zcreate("ipq", sizeof(struct ipq), NULL, NULL, NULL,
NULL, UMA_ALIGN_PTR, 0);
maxnipq_update();
@@ -306,31 +307,31 @@ ip_input(struct mbuf *m)
goto ours;
}
- ipstat.ips_total++;
+ V_ipstat.ips_total++;
if (m->m_pkthdr.len < sizeof(struct ip))
goto tooshort;
if (m->m_len < sizeof (struct ip) &&
(m = m_pullup(m, sizeof (struct ip))) == NULL) {
- ipstat.ips_toosmall++;
+ V_ipstat.ips_toosmall++;
return;
}
ip = mtod(m, struct ip *);
if (ip->ip_v != IPVERSION) {
- ipstat.ips_badvers++;
+ V_ipstat.ips_badvers++;
goto bad;
}
hlen = ip->ip_hl << 2;
if (hlen < sizeof(struct ip)) { /* minimum header length */
- ipstat.ips_badhlen++;
+ V_ipstat.ips_badhlen++;
goto bad;
}
if (hlen > m->m_len) {
if ((m = m_pullup(m, hlen)) == NULL) {
- ipstat.ips_badhlen++;
+ V_ipstat.ips_badhlen++;
return;
}
ip = mtod(m, struct ip *);
@@ -340,7 +341,7 @@ ip_input(struct mbuf *m)
if ((ntohl(ip->ip_dst.s_addr) >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET ||
(ntohl(ip->ip_src.s_addr) >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET) {
if ((m->m_pkthdr.rcvif->if_flags & IFF_LOOPBACK) == 0) {
- ipstat.ips_badaddr++;
+ V_ipstat.ips_badaddr++;
goto bad;
}
}
@@ -355,7 +356,7 @@ ip_input(struct mbuf *m)
}
}
if (sum) {
- ipstat.ips_badsum++;
+ V_ipstat.ips_badsum++;
goto bad;
}
@@ -370,7 +371,7 @@ ip_input(struct mbuf *m)
*/
ip->ip_len = ntohs(ip->ip_len);
if (ip->ip_len < hlen) {
- ipstat.ips_badlen++;
+ V_ipstat.ips_badlen++;
goto bad;
}
ip->ip_off = ntohs(ip->ip_off);
@@ -383,7 +384,7 @@ ip_input(struct mbuf *m)
*/
if (m->m_pkthdr.len < ip->ip_len) {
tooshort:
- ipstat.ips_tooshort++;
+ V_ipstat.ips_tooshort++;
goto bad;
}
if (m->m_pkthdr.len > ip->ip_len) {
@@ -455,7 +456,7 @@ passin:
* anywhere else. Also checks if the rsvp daemon is running before
* grabbing the packet.
*/
- if (rsvp_on && ip->ip_p==IPPROTO_RSVP)
+ if (V_rsvp_on && ip->ip_p==IPPROTO_RSVP)
goto ours;
/*
@@ -464,7 +465,7 @@ passin:
* we receive might be for us (and let the upper layers deal
* with it).
*/
- if (TAILQ_EMPTY(&in_ifaddrhead) &&
+ if (TAILQ_EMPTY(&V_in_ifaddrhead) &&
(m->m_flags & (M_MCAST|M_BCAST)) == 0)
goto ours;
@@ -486,7 +487,7 @@ passin:
* insert a workaround. If the packet got here, we already
* checked with carp_iamatch() and carp_forus().
*/
- checkif = ip_checkinterface && (ipforwarding == 0) &&
+ checkif = V_ip_checkinterface && (V_ipforwarding == 0) &&
m->m_pkthdr.rcvif != NULL &&
((m->m_pkthdr.rcvif->if_flags & IFF_LOOPBACK) == 0) &&
#ifdef DEV_CARP
@@ -534,13 +535,13 @@ passin:
}
/* RFC 3927 2.7: Do not forward datagrams for 169.254.0.0/16. */
if (IN_LINKLOCAL(ntohl(ip->ip_dst.s_addr))) {
- ipstat.ips_cantforward++;
+ V_ipstat.ips_cantforward++;
m_freem(m);
return;
}
if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) {
struct in_multi *inm;
- if (ip_mrouter) {
+ if (V_ip_mrouter) {
/*
* If we are acting as a multicast router, all
* incoming multicast packets are passed to the
@@ -551,7 +552,7 @@ passin:
*/
if (ip_mforward &&
ip_mforward(ip, m->m_pkthdr.rcvif, m, 0) != 0) {
- ipstat.ips_cantforward++;
+ V_ipstat.ips_cantforward++;
m_freem(m);
return;
}
@@ -563,7 +564,7 @@ passin:
*/
if (ip->ip_p == IPPROTO_IGMP)
goto ours;
- ipstat.ips_forward++;
+ V_ipstat.ips_forward++;
}
/*
* See if we belong to the destination multicast group on the
@@ -573,7 +574,7 @@ passin:
IN_LOOKUP_MULTI(ip->ip_dst, m->m_pkthdr.rcvif, inm);
IN_MULTI_UNLOCK();
if (inm == NULL) {
- ipstat.ips_notmember++;
+ V_ipstat.ips_notmember++;
m_freem(m);
return;
}
@@ -588,7 +589,7 @@ passin:
* FAITH(Firewall Aided Internet Translator)
*/
if (m->m_pkthdr.rcvif && m->m_pkthdr.rcvif->if_type == IFT_FAITH) {
- if (ip_keepfaith) {
+ if (V_ip_keepfaith) {
if (ip->ip_p == IPPROTO_TCP || ip->ip_p == IPPROTO_ICMP)
goto ours;
}
@@ -599,8 +600,8 @@ passin:
/*
* Not for us; forward if possible and desirable.
*/
- if (ipforwarding == 0) {
- ipstat.ips_cantforward++;
+ if (V_ipforwarding == 0) {
+ V_ipstat.ips_cantforward++;
m_freem(m);
} else {
#ifdef IPSEC
@@ -617,7 +618,7 @@ ours:
* IPSTEALTH: Process non-routing options only
* if the packet is destined for us.
*/
- if (ipstealth && hlen > sizeof (struct ip) &&
+ if (V_ipstealth && hlen > sizeof (struct ip) &&
ip_dooptions(m, 1))
return;
#endif /* IPSTEALTH */
@@ -660,7 +661,7 @@ ours:
/*
* Switch out to protocol's input routine.
*/
- ipstat.ips_delivered++;
+ V_ipstat.ips_delivered++;
(*inetsw[ip_protox[ip->ip_p]].pr_input)(m, hlen);
return;
@@ -680,28 +681,28 @@ maxnipq_update(void)
/*
* -1 for unlimited allocation.
*/
- if (maxnipq < 0)
- uma_zone_set_max(ipq_zone, 0);
+ if (V_maxnipq < 0)
+ uma_zone_set_max(V_ipq_zone, 0);
/*
* Positive number for specific bound.
*/
- if (maxnipq > 0)
- uma_zone_set_max(ipq_zone, maxnipq);
+ if (V_maxnipq > 0)
+ uma_zone_set_max(V_ipq_zone, V_maxnipq);
/*
* Zero specifies no further fragment queue allocation -- set the
* bound very low, but rely on implementation elsewhere to actually
* prevent allocation and reclaim current queues.
*/
- if (maxnipq == 0)
- uma_zone_set_max(ipq_zone, 1);
+ if (V_maxnipq == 0)
+ uma_zone_set_max(V_ipq_zone, 1);
}
static void
ipq_zone_change(void *tag)
{
- if (maxnipq > 0 && maxnipq < (nmbclusters / 32)) {
- maxnipq = nmbclusters / 32;
+ if (V_maxnipq > 0 && V_maxnipq < (nmbclusters / 32)) {
+ V_maxnipq = nmbclusters / 32;
maxnipq_update();
}
}
@@ -711,7 +712,7 @@ sysctl_maxnipq(SYSCTL_HANDLER_ARGS)
{
int error, i;
- i = maxnipq;
+ i = V_maxnipq;
error = sysctl_handle_int(oidp, &i, 0, req);
if (error || !req->newptr)
return (error);
@@ -722,7 +723,7 @@ sysctl_maxnipq(SYSCTL_HANDLER_ARGS)
*/
if (i < -1)
return (EINVAL);
- maxnipq = i;
+ V_maxnipq = i;
maxnipq_update();
return (0);
}
@@ -753,9 +754,9 @@ ip_reass(struct mbuf *m)
u_short hash;
/* If maxnipq or maxfragsperpacket are 0, never accept fragments. */
- if (maxnipq == 0 || maxfragsperpacket == 0) {
- ipstat.ips_fragments++;
- ipstat.ips_fragdropped++;
+ if (V_maxnipq == 0 || V_maxfragsperpacket == 0) {
+ V_ipstat.ips_fragments++;
+ V_ipstat.ips_fragdropped++;
m_freem(m);
return (NULL);
}
@@ -764,7 +765,7 @@ ip_reass(struct mbuf *m)
hlen = ip->ip_hl << 2;
hash = IPREASS_HASH(ip->ip_src.s_addr, ip->ip_id);
- head = &ipq[hash];
+ head = &V_ipq[hash];
IPQ_LOCK();
/*
@@ -787,7 +788,7 @@ ip_reass(struct mbuf *m)
* Attempt to trim the number of allocated fragment queues if it
* exceeds the administrative limit.
*/
- if ((nipq > maxnipq) && (maxnipq > 0)) {
+ if ((V_nipq > V_maxnipq) && (V_maxnipq > 0)) {
/*
* drop something from the tail of the current queue
* before proceeding further
@@ -795,15 +796,15 @@ ip_reass(struct mbuf *m)
struct ipq *q = TAILQ_LAST(head, ipqhead);
if (q == NULL) { /* gak */
for (i = 0; i < IPREASS_NHASH; i++) {
- struct ipq *r = TAILQ_LAST(&ipq[i], ipqhead);
+ struct ipq *r = TAILQ_LAST(&V_ipq[i], ipqhead);
if (r) {
- ipstat.ips_fragtimeout += r->ipq_nfrags;
- ip_freef(&ipq[i], r);
+ V_ipstat.ips_fragtimeout += r->ipq_nfrags;
+ ip_freef(&V_ipq[i], r);
break;
}
}
} else {
- ipstat.ips_fragtimeout += q->ipq_nfrags;
+ V_ipstat.ips_fragtimeout += q->ipq_nfrags;
ip_freef(head, q);
}
}
@@ -820,7 +821,7 @@ found:
* that's a non-zero multiple of 8 bytes.
*/
if (ip->ip_len == 0 || (ip->ip_len & 0x7) != 0) {
- ipstat.ips_toosmall++; /* XXX */
+ V_ipstat.ips_toosmall++; /* XXX */
goto dropfrag;
}
m->m_flags |= M_FRAG;
@@ -833,7 +834,7 @@ found:
* Attempt reassembly; if it succeeds, proceed.
* ip_reass() will return a different mbuf.
*/
- ipstat.ips_fragments++;
+ V_ipstat.ips_fragments++;
m->m_pkthdr.header = ip;
/* Previous ip_reass() started here. */
@@ -848,19 +849,19 @@ found:
* If first fragment to arrive, create a reassembly queue.
*/
if (fp == NULL) {
- fp = uma_zalloc(ipq_zone, M_NOWAIT);
+ fp = uma_zalloc(V_ipq_zone, M_NOWAIT);
if (fp == NULL)
goto dropfrag;
#ifdef MAC
if (mac_ipq_init(fp, M_NOWAIT) != 0) {
- uma_zfree(ipq_zone, fp);
+ uma_zfree(V_ipq_zone, fp);
fp = NULL;
goto dropfrag;
}
mac_ipq_create(m, fp);
#endif
TAILQ_INSERT_HEAD(head, fp, ipq_list);
- nipq++;
+ V_nipq++;
fp->ipq_nfrags = 1;
fp->ipq_ttl = IPFRAGTTL;
fp->ipq_p = ip->ip_p;
@@ -944,7 +945,7 @@ found:
}
nq = q->m_nextpkt;
m->m_nextpkt = nq;
- ipstat.ips_fragdropped++;
+ V_ipstat.ips_fragdropped++;
fp->ipq_nfrags--;
m_freem(q);
}
@@ -962,8 +963,8 @@ found:
next = 0;
for (p = NULL, q = fp->ipq_frags; q; p = q, q = q->m_nextpkt) {
if (GETIP(q)->ip_off != next) {
- if (fp->ipq_nfrags > maxfragsperpacket) {
- ipstat.ips_fragdropped += fp->ipq_nfrags;
+ if (fp->ipq_nfrags > V_maxfragsperpacket) {
+ V_ipstat.ips_fragdropped += fp->ipq_nfrags;
ip_freef(head, fp);
}
goto done;
@@ -972,8 +973,8 @@ found:
}
/* Make sure the last packet didn't have the IP_MF flag */
if (p->m_flags & M_FRAG) {
- if (fp->ipq_nfrags > maxfragsperpacket) {
- ipstat.ips_fragdropped += fp->ipq_nfrags;
+ if (fp->ipq_nfrags > V_maxfragsperpacket) {
+ V_ipstat.ips_fragdropped += fp->ipq_nfrags;
ip_freef(head, fp);
}
goto done;
@@ -985,8 +986,8 @@ found:
q = fp->ipq_frags;
ip = GETIP(q);
if (next + (ip->ip_hl << 2) > IP_MAXPACKET) {
- ipstat.ips_toolong++;
- ipstat.ips_fragdropped += fp->ipq_nfrags;
+ V_ipstat.ips_toolong++;
+ V_ipstat.ips_fragdropped += fp->ipq_nfrags;
ip_freef(head, fp);
goto done;
}
@@ -1028,19 +1029,19 @@ found:
ip->ip_src = fp->ipq_src;
ip->ip_dst = fp->ipq_dst;
TAILQ_REMOVE(head, fp, ipq_list);
- nipq--;
- uma_zfree(ipq_zone, fp);
+ V_nipq--;
+ uma_zfree(V_ipq_zone, fp);
m->m_len += (ip->ip_hl << 2);
m->m_data -= (ip->ip_hl << 2);
/* some debugging cruft by sklower, below, will go away soon */
if (m->m_flags & M_PKTHDR) /* XXX this should be done elsewhere */
m_fixhdr(m);
- ipstat.ips_reassembled++;
+ V_ipstat.ips_reassembled++;
IPQ_UNLOCK();
return (m);
dropfrag:
- ipstat.ips_fragdropped++;
+ V_ipstat.ips_fragdropped++;
if (fp != NULL)
fp->ipq_nfrags--;
m_freem(m);
@@ -1068,8 +1069,8 @@ ip_freef(struct ipqhead *fhp, struct ipq *fp)
m_freem(q);
}
TAILQ_REMOVE(fhp, fp, ipq_list);
- uma_zfree(ipq_zone, fp);
- nipq--;
+ uma_zfree(V_ipq_zone, fp);
+ V_nipq--;
}
/*
@@ -1085,14 +1086,14 @@ ip_slowtimo(void)
IPQ_LOCK();
for (i = 0; i < IPREASS_NHASH; i++) {
- for(fp = TAILQ_FIRST(&ipq[i]); fp;) {
+ for(fp = TAILQ_FIRST(&V_ipq[i]); fp;) {
struct ipq *fpp;
fpp = fp;
fp = TAILQ_NEXT(fp, ipq_list);
if(--fpp->ipq_ttl == 0) {
- ipstat.ips_fragtimeout += fpp->ipq_nfrags;
- ip_freef(&ipq[i], fpp);
+ V_ipstat.ips_fragtimeout += fpp->ipq_nfrags;
+ ip_freef(&V_ipq[i], fpp);
}
}
}
@@ -1101,12 +1102,12 @@ ip_slowtimo(void)
* (due to the limit being lowered), drain off
* enough to get down to the new limit.
*/
- if (maxnipq >= 0 && nipq > maxnipq) {
+ if (V_maxnipq >= 0 && V_nipq > V_maxnipq) {
for (i = 0; i < IPREASS_NHASH; i++) {
- while (nipq > maxnipq && !TAILQ_EMPTY(&ipq[i])) {
- ipstat.ips_fragdropped +=
- TAILQ_FIRST(&ipq[i])->ipq_nfrags;
- ip_freef(&ipq[i], TAILQ_FIRST(&ipq[i]));
+ while (V_nipq > V_maxnipq && !TAILQ_EMPTY(&V_ipq[i])) {
+ V_ipstat.ips_fragdropped +=
+ TAILQ_FIRST(&V_ipq[i])->ipq_nfrags;
+ ip_freef(&V_ipq[i], TAILQ_FIRST(&V_ipq[i]));
}
}
}
@@ -1123,10 +1124,10 @@ ip_drain(void)
IPQ_LOCK();
for (i = 0; i < IPREASS_NHASH; i++) {
- while(!TAILQ_EMPTY(&ipq[i])) {
- ipstat.ips_fragdropped +=
- TAILQ_FIRST(&ipq[i])->ipq_nfrags;
- ip_freef(&ipq[i], TAILQ_FIRST(&ipq[i]));
+ while(!TAILQ_EMPTY(&V_ipq[i])) {
+ V_ipstat.ips_fragdropped +=
+ TAILQ_FIRST(&V_ipq[i])->ipq_nfrags;
+ ip_freef(&V_ipq[i], TAILQ_FIRST(&V_ipq[i]));
}
}
IPQ_UNLOCK();
@@ -1253,12 +1254,12 @@ ip_forward(struct mbuf *m, int srcrt)
int error, type = 0, code = 0, mtu = 0;
if (m->m_flags & (M_BCAST|M_MCAST) || in_canforward(ip->ip_dst) == 0) {
- ipstat.ips_cantforward++;
+ V_ipstat.ips_cantforward++;
m_freem(m);
return;
}
#ifdef IPSTEALTH
- if (!ipstealth) {
+ if (!V_ipstealth) {
#endif
if (ip->ip_ttl <= IPTTLDEC) {
icmp_error(m, ICMP_TIMXCEED, ICMP_TIMXCEED_INTRANS,
@@ -1309,7 +1310,7 @@ ip_forward(struct mbuf *m, int srcrt)
}
#ifdef IPSTEALTH
- if (!ipstealth) {
+ if (!V_ipstealth) {
#endif
ip->ip_ttl -= IPTTLDEC;
#ifdef IPSTEALTH
@@ -1325,7 +1326,7 @@ ip_forward(struct mbuf *m, int srcrt)
* or a route modified by a redirect.
*/
dest.s_addr = 0;
- if (!srcrt && ipsendredirects && ia->ia_ifp == m->m_pkthdr.rcvif) {
+ if (!srcrt && V_ipsendredirects && ia->ia_ifp == m->m_pkthdr.rcvif) {
struct sockaddr_in *sin;
struct rtentry *rt;
@@ -1372,11 +1373,11 @@ ip_forward(struct mbuf *m, int srcrt)
RTFREE(ro.ro_rt);
if (error)
- ipstat.ips_cantforward++;
+ V_ipstat.ips_cantforward++;
else {
- ipstat.ips_forward++;
+ V_ipstat.ips_forward++;
if (type)
- ipstat.ips_redirectsent++;
+ V_ipstat.ips_redirectsent++;
else {
if (mcopy)
m_freem(mcopy);
@@ -1428,7 +1429,7 @@ ip_forward(struct mbuf *m, int srcrt)
else
mtu = ip_next_mtu(ip->ip_len, 0);
}
- ipstat.ips_cantfrag++;
+ V_ipstat.ips_cantfrag++;
break;
case ENOBUFS:
@@ -1440,7 +1441,7 @@ ip_forward(struct mbuf *m, int srcrt)
* Those who need source quench packets may re-enable them
* via the net.inet.ip.sendsourcequench sysctl.
*/
- if (ip_sendsourcequench == 0) {
+ if (V_ip_sendsourcequench == 0) {
m_freem(mcopy);
return;
} else {
@@ -1522,7 +1523,7 @@ ip_savecontrol(struct inpcb *inp, struct mbuf **mp, struct ip *ip,
struct sockaddr_dl *sdl2 = &sdlbuf.sdl;
if (((ifp = m->m_pkthdr.rcvif))
- && ( ifp->if_index && (ifp->if_index <= if_index))) {
+ && ( ifp->if_index && (ifp->if_index <= V_if_index))) {
sdp = (struct sockaddr_dl *)ifp->if_addr->ifa_addr;
/*
* Change our mind and don't try copy.
@@ -1562,17 +1563,17 @@ ip_rsvp_init(struct socket *so)
so->so_proto->pr_protocol != IPPROTO_RSVP)
return EOPNOTSUPP;
- if (ip_rsvpd != NULL)
+ if (V_ip_rsvpd != NULL)
return EADDRINUSE;
- ip_rsvpd = so;
+ V_ip_rsvpd = so;
/*
* This may seem silly, but we need to be sure we don't over-increment
* the RSVP counter, in case something slips up.
*/
- if (!ip_rsvp_on) {
- ip_rsvp_on = 1;
- rsvp_on++;
+ if (!V_ip_rsvp_on) {
+ V_ip_rsvp_on = 1;
+ V_rsvp_on++;
}
return 0;
@@ -1581,14 +1582,14 @@ ip_rsvp_init(struct socket *so)
int
ip_rsvp_done(void)
{
- ip_rsvpd = NULL;
+ V_ip_rsvpd = NULL;
/*
* This may seem silly, but we need to be sure we don't over-decrement
* the RSVP counter, in case something slips up.
*/
- if (ip_rsvp_on) {
- ip_rsvp_on = 0;
- rsvp_on--;
+ if (V_ip_rsvp_on) {
+ V_ip_rsvp_on = 0;
+ V_rsvp_on--;
}
return 0;
}
@@ -1606,12 +1607,12 @@ rsvp_input(struct mbuf *m, int off) /* XXX must fixup manually */
* case we want to throw the packet away.
*/
- if (!rsvp_on) {
+ if (!V_rsvp_on) {
m_freem(m);
return;
}
- if (ip_rsvpd != NULL) {
+ if (V_ip_rsvpd != NULL) {
rip_input(m, off);
return;
}
diff --git a/sys/netinet/ip_ipsec.c b/sys/netinet/ip_ipsec.c
index fbe7430..3e8e826 100644
--- a/sys/netinet/ip_ipsec.c
+++ b/sys/netinet/ip_ipsec.c
@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/sysctl.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/route.h>
@@ -121,7 +122,7 @@ ip_ipsec_fwd(struct mbuf *m)
KEY_FREESP(&sp);
splx(s);
if (error) {
- ipstat.ips_cantforward++;
+ V_ipstat.ips_cantforward++;
return 1;
}
#endif /* IPSEC */
diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c
index d60e8bd..0476a36 100644
--- a/sys/netinet/ip_mroute.c
+++ b/sys/netinet/ip_mroute.c
@@ -80,6 +80,7 @@ __FBSDID("$FreeBSD$");
#include <sys/syslog.h>
#include <sys/systm.h>
#include <sys/time.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/netisr.h>
#include <net/route.h>
@@ -428,7 +429,7 @@ X_ip_mrouter_set(struct socket *so, struct sockopt *sopt)
struct bw_upcall bw_upcall;
uint32_t i;
- if (so != ip_mrouter && sopt->sopt_name != MRT_INIT)
+ if (so != V_ip_mrouter && sopt->sopt_name != MRT_INIT)
return EPERM;
error = 0;
@@ -654,7 +655,7 @@ if_detached_event(void *arg __unused, struct ifnet *ifp)
struct rtdetq *npq;
MROUTER_LOCK();
- if (ip_mrouter == NULL) {
+ if (V_ip_mrouter == NULL) {
MROUTER_UNLOCK();
}
@@ -720,7 +721,7 @@ ip_mrouter_init(struct socket *so, int version)
MROUTER_LOCK();
- if (ip_mrouter != NULL) {
+ if (V_ip_mrouter != NULL) {
MROUTER_UNLOCK();
return EADDRINUSE;
}
@@ -738,7 +739,7 @@ ip_mrouter_init(struct socket *so, int version)
expire_bw_upcalls_send, NULL);
callout_reset(&bw_meter_ch, BW_METER_PERIOD, expire_bw_meter_process, NULL);
- ip_mrouter = so;
+ V_ip_mrouter = so;
MROUTER_UNLOCK();
@@ -763,7 +764,7 @@ X_ip_mrouter_done(void)
MROUTER_LOCK();
- if (ip_mrouter == NULL) {
+ if (V_ip_mrouter == NULL) {
MROUTER_UNLOCK();
return EINVAL;
}
@@ -771,7 +772,7 @@ X_ip_mrouter_done(void)
/*
* Detach/disable hooks to the reset of the system.
*/
- ip_mrouter = NULL;
+ V_ip_mrouter = NULL;
mrt_api_config = 0;
VIF_LOCK();
@@ -1449,7 +1450,7 @@ X_ip_mforward(struct ip *ip, struct ifnet *ifp, struct mbuf *m,
mrtstat.mrts_upcalls++;
k_igmpsrc.sin_addr = ip->ip_src;
- if (socket_send(ip_mrouter, mm, &k_igmpsrc) < 0) {
+ if (socket_send(V_ip_mrouter, mm, &k_igmpsrc) < 0) {
log(LOG_WARNING, "ip_mforward: ip_mrouter socket queue full\n");
++mrtstat.mrts_upq_sockfull;
fail1:
@@ -1668,7 +1669,7 @@ ip_mdq(struct mbuf *m, struct ifnet *ifp, struct mfc *rt, vifi_t xmt_vif)
mrtstat.mrts_upcalls++;
k_igmpsrc.sin_addr = im->im_src;
- if (socket_send(ip_mrouter, mm, &k_igmpsrc) < 0) {
+ if (socket_send(V_ip_mrouter, mm, &k_igmpsrc) < 0) {
log(LOG_WARNING,
"ip_mforward: ip_mrouter socket queue full\n");
++mrtstat.mrts_upq_sockfull;
@@ -1829,7 +1830,7 @@ X_ip_rsvp_vif(struct socket *so, struct sockopt *sopt)
*/
if (!viftable[vifi].v_rsvp_on) {
viftable[vifi].v_rsvp_on = 1;
- rsvp_on++;
+ V_rsvp_on++;
}
} else { /* must be VIF_OFF */
/*
@@ -1844,7 +1845,7 @@ X_ip_rsvp_vif(struct socket *so, struct sockopt *sopt)
*/
if (viftable[vifi].v_rsvp_on) {
viftable[vifi].v_rsvp_on = 0;
- rsvp_on--;
+ V_rsvp_on--;
}
}
VIF_UNLOCK();
@@ -1873,7 +1874,7 @@ X_ip_rsvp_force_done(struct socket *so)
*/
if (viftable[vifi].v_rsvp_on) {
viftable[vifi].v_rsvp_on = 0;
- rsvp_on--;
+ V_rsvp_on--;
}
}
}
@@ -1890,13 +1891,13 @@ X_rsvp_input(struct mbuf *m, int off)
struct ifnet *ifp;
if (rsvpdebug)
- printf("rsvp_input: rsvp_on %d\n",rsvp_on);
+ printf("rsvp_input: rsvp_on %d\n",V_rsvp_on);
/* Can still get packets with rsvp_on = 0 if there is a local member
* of the group to which the RSVP packet is addressed. But in this
* case we want to throw the packet away.
*/
- if (!rsvp_on) {
+ if (!V_rsvp_on) {
m_freem(m);
return;
}
@@ -1928,7 +1929,7 @@ X_rsvp_input(struct mbuf *m, int off)
* then use it. Otherwise, drop packet since there
* is no specific socket for this vif.
*/
- if (ip_rsvpd != NULL) {
+ if (V_ip_rsvpd != NULL) {
if (rsvpdebug)
printf("rsvp_input: Sending packet up old-style socket\n");
rip_input(m, off); /* xxx */
@@ -2323,7 +2324,7 @@ bw_upcalls_send(void)
* XXX do we need to set the address in k_igmpsrc ?
*/
mrtstat.mrts_upcalls++;
- if (socket_send(ip_mrouter, m, &k_igmpsrc) < 0) {
+ if (socket_send(V_ip_mrouter, m, &k_igmpsrc) < 0) {
log(LOG_WARNING, "bw_upcalls_send: ip_mrouter socket queue full\n");
++mrtstat.mrts_upq_sockfull;
}
@@ -2677,7 +2678,7 @@ pim_register_send_upcall(struct ip *ip, struct vif *vifp,
mrtstat.mrts_upcalls++;
- if (socket_send(ip_mrouter, mb_first, &k_igmpsrc) < 0) {
+ if (socket_send(V_ip_mrouter, mb_first, &k_igmpsrc) < 0) {
if (mrtdebug & DEBUG_PIM)
log(LOG_WARNING,
"mcast: pim_register_send_upcall: ip_mrouter socket queue full");
@@ -3094,7 +3095,7 @@ ip_mroute_modevent(module_t mod, int type, void *unused)
* just loaded and then unloaded w/o starting up a user
* process we still need to cleanup.
*/
- if (ip_mrouter
+ if (V_ip_mrouter
#ifdef INET6
|| ip6_mrouter
#endif
diff --git a/sys/netinet/ip_options.c b/sys/netinet/ip_options.c
index 0019f7a..b58dbee 100644
--- a/sys/netinet/ip_options.c
+++ b/sys/netinet/ip_options.c
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/syslog.h>
#include <sys/sysctl.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_types.h>
@@ -150,7 +151,7 @@ ip_dooptions(struct mbuf *m, int pass)
case IPOPT_LSRR:
case IPOPT_SSRR:
#ifdef IPSTEALTH
- if (ipstealth && pass > 0)
+ if (V_ipstealth && pass > 0)
break;
#endif
if (optlen < IPOPT_OFFSET + sizeof(*cp)) {
@@ -189,11 +190,11 @@ ip_dooptions(struct mbuf *m, int pass)
break;
}
#ifdef IPSTEALTH
- if (ipstealth)
+ if (V_ipstealth)
goto dropit;
#endif
if (!ip_dosourceroute) {
- if (ipforwarding) {
+ if (V_ipforwarding) {
char buf[16]; /* aaa.bbb.ccc.ddd\0 */
/*
* Acting as a router, so generate
@@ -215,7 +216,7 @@ nosourcerouting:
#ifdef IPSTEALTH
dropit:
#endif
- ipstat.ips_cantforward++;
+ V_ipstat.ips_cantforward++;
m_freem(m);
return (1);
}
@@ -252,7 +253,7 @@ dropit:
case IPOPT_RR:
#ifdef IPSTEALTH
- if (ipstealth && pass == 0)
+ if (V_ipstealth && pass == 0)
break;
#endif
if (optlen < IPOPT_OFFSET + sizeof(*cp)) {
@@ -289,7 +290,7 @@ dropit:
case IPOPT_TS:
#ifdef IPSTEALTH
- if (ipstealth && pass == 0)
+ if (V_ipstealth && pass == 0)
break;
#endif
code = cp - (u_char *)ip;
@@ -356,14 +357,14 @@ dropit:
cp[IPOPT_OFFSET] += sizeof(n_time);
}
}
- if (forward && ipforwarding) {
+ if (forward && V_ipforwarding) {
ip_forward(m, 1);
return (1);
}
return (0);
bad:
icmp_error(m, type, code, 0, 0);
- ipstat.ips_badoptions++;
+ V_ipstat.ips_badoptions++;
return (1);
}
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c
index 231510a..946626a 100644
--- a/sys/netinet/ip_output.c
+++ b/sys/netinet/ip_output.c
@@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$");
#include <sys/socketvar.h>
#include <sys/sysctl.h>
#include <sys/ucred.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/netisr.h>
@@ -155,7 +156,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags,
ip->ip_v = IPVERSION;
ip->ip_hl = hlen >> 2;
ip->ip_id = ip_newid();
- ipstat.ips_localout++;
+ V_ipstat.ips_localout++;
} else {
hlen = ip->ip_hl << 2;
}
@@ -194,7 +195,7 @@ again:
if (flags & IP_SENDONES) {
if ((ia = ifatoia(ifa_ifwithbroadaddr(sintosa(dst)))) == NULL &&
(ia = ifatoia(ifa_ifwithdstaddr(sintosa(dst)))) == NULL) {
- ipstat.ips_noroute++;
+ V_ipstat.ips_noroute++;
error = ENETUNREACH;
goto bad;
}
@@ -206,7 +207,7 @@ again:
} else if (flags & IP_ROUTETOIF) {
if ((ia = ifatoia(ifa_ifwithdstaddr(sintosa(dst)))) == NULL &&
(ia = ifatoia(ifa_ifwithnet(sintosa(dst)))) == NULL) {
- ipstat.ips_noroute++;
+ V_ipstat.ips_noroute++;
error = ENETUNREACH;
goto bad;
}
@@ -238,7 +239,7 @@ again:
inp ? inp->inp_inc.inc_fibnum : M_GETFIB(m));
#endif
if (ro->ro_rt == NULL) {
- ipstat.ips_noroute++;
+ V_ipstat.ips_noroute++;
error = EHOSTUNREACH;
goto bad;
}
@@ -297,7 +298,7 @@ again:
*/
if ((imo == NULL) || (imo->imo_multicast_vif == -1)) {
if ((ifp->if_flags & IFF_MULTICAST) == 0) {
- ipstat.ips_noroute++;
+ V_ipstat.ips_noroute++;
error = ENETUNREACH;
goto bad;
}
@@ -338,14 +339,14 @@ again:
* above, will be forwarded by the ip_input() routine,
* if necessary.
*/
- if (ip_mrouter && (flags & IP_FORWARDING) == 0) {
+ if (V_ip_mrouter && (flags & IP_FORWARDING) == 0) {
/*
* If rsvp daemon is not running, do not
* set ip_moptions. This ensures that the packet
* is multicast and not just sent down one link
* as prescribed by rsvpd.
*/
- if (!rsvp_on)
+ if (!V_rsvp_on)
imo = NULL;
if (ip_mforward &&
ip_mforward(ip, ifp, m, imo) != 0) {
@@ -397,7 +398,7 @@ again:
#endif /* ALTQ */
{
error = ENOBUFS;
- ipstat.ips_odropped++;
+ V_ipstat.ips_odropped++;
ifp->if_snd.ifq_drops += (ip->ip_len / ifp->if_mtu + 1);
goto bad;
}
@@ -461,7 +462,7 @@ sendit:
if (in_localip(ip->ip_dst)) {
m->m_flags |= M_FASTFWD_OURS;
if (m->m_pkthdr.rcvif == NULL)
- m->m_pkthdr.rcvif = loif;
+ m->m_pkthdr.rcvif = V_loif;
if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) {
m->m_pkthdr.csum_flags |=
CSUM_DATA_VALID | CSUM_PSEUDO_HDR;
@@ -480,7 +481,7 @@ sendit:
/* See if local, if yes, send it to netisr with IP_FASTFWD_OURS. */
if (m->m_flags & M_FASTFWD_OURS) {
if (m->m_pkthdr.rcvif == NULL)
- m->m_pkthdr.rcvif = loif;
+ m->m_pkthdr.rcvif = V_loif;
if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) {
m->m_pkthdr.csum_flags |=
CSUM_DATA_VALID | CSUM_PSEUDO_HDR;
@@ -508,7 +509,7 @@ passout:
if ((ntohl(ip->ip_dst.s_addr) >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET ||
(ntohl(ip->ip_src.s_addr) >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET) {
if ((ifp->if_flags & IFF_LOOPBACK) == 0) {
- ipstat.ips_badaddr++;
+ V_ipstat.ips_badaddr++;
error = EADDRNOTAVAIL;
goto bad;
}
@@ -567,7 +568,7 @@ passout:
/* Balk when DF bit is set or the interface didn't support TSO. */
if ((ip->ip_off & IP_DF) || (m->m_pkthdr.csum_flags & CSUM_TSO)) {
error = EMSGSIZE;
- ipstat.ips_cantfrag++;
+ V_ipstat.ips_cantfrag++;
goto bad;
}
@@ -600,7 +601,7 @@ passout:
}
if (error == 0)
- ipstat.ips_fragmented++;
+ V_ipstat.ips_fragmented++;
done:
if (ro == &iproute && ro->ro_rt) {
@@ -635,7 +636,7 @@ ip_fragment(struct ip *ip, struct mbuf **m_frag, int mtu,
int nfrags;
if (ip->ip_off & IP_DF) { /* Fragmentation not allowed */
- ipstat.ips_cantfrag++;
+ V_ipstat.ips_cantfrag++;
return EMSGSIZE;
}
@@ -710,7 +711,7 @@ smart_frag_failure:
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == NULL) {
error = ENOBUFS;
- ipstat.ips_odropped++;
+ V_ipstat.ips_odropped++;
goto done;
}
m->m_flags |= (m0->m_flags & M_MCAST) | M_FRAG;
@@ -740,7 +741,7 @@ smart_frag_failure:
if (m->m_next == NULL) { /* copy failed */
m_free(m);
error = ENOBUFS; /* ??? */
- ipstat.ips_odropped++;
+ V_ipstat.ips_odropped++;
goto done;
}
m->m_pkthdr.len = mhlen + len;
@@ -756,7 +757,7 @@ smart_frag_failure:
*mnext = m;
mnext = &m->m_nextpkt;
}
- ipstat.ips_ofragments += nfrags;
+ V_ipstat.ips_ofragments += nfrags;
/* set first marker for fragment chain */
m0->m_flags |= M_FIRSTFRAG | M_FRAG;
diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h
index 436a4a0..75d5f7f 100644
--- a/sys/netinet/ip_var.h
+++ b/sys/netinet/ip_var.h
@@ -34,6 +34,9 @@
#define _NETINET_IP_VAR_H_
#include <sys/queue.h>
+#ifdef _KERNEL
+#include <sys/vimage.h>
+#endif
/*
* Overlay for ip header used by other protocols (tcp, udp).
@@ -237,7 +240,7 @@ extern int ip_do_randomid;
static __inline uint16_t
ip_newid(void)
{
- if (ip_do_randomid)
+ if (V_ip_do_randomid)
return ip_randomid();
return htons(ip_id++);
diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c
index 26718ef..7ea0113 100644
--- a/sys/netinet/raw_ip.c
+++ b/sys/netinet/raw_ip.c
@@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sx.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
+#include <sys/vimage.h>
#include <vm/uma.h>
@@ -158,7 +159,7 @@ static void
rip_zone_change(void *tag)
{
- uma_zone_set_max(ripcbinfo.ipi_zone, maxsockets);
+ uma_zone_set_max(V_ripcbinfo.ipi_zone, maxsockets);
}
static int
@@ -174,16 +175,16 @@ void
rip_init(void)
{
- INP_INFO_LOCK_INIT(&ripcbinfo, "rip");
- LIST_INIT(&ripcb);
- ripcbinfo.ipi_listhead = &ripcb;
- ripcbinfo.ipi_hashbase = hashinit(INP_PCBHASH_RAW_SIZE, M_PCB,
- &ripcbinfo.ipi_hashmask);
- ripcbinfo.ipi_porthashbase = hashinit(1, M_PCB,
- &ripcbinfo.ipi_porthashmask);
- ripcbinfo.ipi_zone = uma_zcreate("ripcb", sizeof(struct inpcb),
+ INP_INFO_LOCK_INIT(&V_ripcbinfo, "rip");
+ LIST_INIT(&V_ripcb);
+ V_ripcbinfo.ipi_listhead = &V_ripcb;
+ V_ripcbinfo.ipi_hashbase = hashinit(INP_PCBHASH_RAW_SIZE, M_PCB,
+ &V_ripcbinfo.ipi_hashmask);
+ V_ripcbinfo.ipi_porthashbase = hashinit(1, M_PCB,
+ &V_ripcbinfo.ipi_porthashmask);
+ V_ripcbinfo.ipi_zone = uma_zcreate("ripcb", sizeof(struct inpcb),
NULL, NULL, rip_inpcb_init, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE);
- uma_zone_set_max(ripcbinfo.ipi_zone, maxsockets);
+ uma_zone_set_max(V_ripcbinfo.ipi_zone, maxsockets);
EVENTHANDLER_REGISTER(maxsockets_change, rip_zone_change, NULL,
EVENTHANDLER_PRI_ANY);
}
@@ -251,9 +252,9 @@ rip_input(struct mbuf *m, int off)
ripsrc.sin_addr = ip->ip_src;
last = NULL;
hash = INP_PCBHASH_RAW(proto, ip->ip_src.s_addr,
- ip->ip_dst.s_addr, ripcbinfo.ipi_hashmask);
- INP_INFO_RLOCK(&ripcbinfo);
- LIST_FOREACH(inp, &ripcbinfo.ipi_hashbase[hash], inp_hash) {
+ ip->ip_dst.s_addr, V_ripcbinfo.ipi_hashmask);
+ INP_INFO_RLOCK(&V_ripcbinfo);
+ LIST_FOREACH(inp, &V_ripcbinfo.ipi_hashbase[hash], inp_hash) {
if (inp->inp_ip_p != proto)
continue;
#ifdef INET6
@@ -282,7 +283,7 @@ rip_input(struct mbuf *m, int off)
}
last = inp;
}
- LIST_FOREACH(inp, &ripcbinfo.ipi_hashbase[0], inp_hash) {
+ LIST_FOREACH(inp, &V_ripcbinfo.ipi_hashbase[0], inp_hash) {
if (inp->inp_ip_p && inp->inp_ip_p != proto)
continue;
#ifdef INET6
@@ -313,15 +314,15 @@ rip_input(struct mbuf *m, int off)
}
last = inp;
}
- INP_INFO_RUNLOCK(&ripcbinfo);
+ INP_INFO_RUNLOCK(&V_ripcbinfo);
if (last != NULL) {
if (rip_append(last, ip, m, &ripsrc) != 0)
- ipstat.ips_delivered--;
+ V_ipstat.ips_delivered--;
INP_RUNLOCK(last);
} else {
m_freem(m);
- ipstat.ips_noproto++;
- ipstat.ips_delivered--;
+ V_ipstat.ips_noproto++;
+ V_ipstat.ips_delivered--;
}
}
@@ -401,7 +402,7 @@ rip_output(struct mbuf *m, struct socket *so, u_long dst)
* XXX prevent ip_output from overwriting header fields.
*/
flags |= IP_RAWOUTPUT;
- ipstat.ips_rawout++;
+ V_ipstat.ips_rawout++;
}
if (inp->inp_flags & INP_ONESBCAST)
@@ -604,7 +605,7 @@ rip_ctlinput(int cmd, struct sockaddr *sa, void *vip)
switch (cmd) {
case PRC_IFDOWN:
- TAILQ_FOREACH(ia, &in_ifaddrhead, ia_link) {
+ TAILQ_FOREACH(ia, &V_in_ifaddrhead, ia_link) {
if (ia->ia_ifa.ifa_addr == sa
&& (ia->ia_flags & IFA_ROUTE)) {
/*
@@ -624,7 +625,7 @@ rip_ctlinput(int cmd, struct sockaddr *sa, void *vip)
break;
case PRC_IFUP:
- TAILQ_FOREACH(ia, &in_ifaddrhead, ia_link) {
+ TAILQ_FOREACH(ia, &V_in_ifaddrhead, ia_link) {
if (ia->ia_ifa.ifa_addr == sa)
break;
}
@@ -669,18 +670,18 @@ rip_attach(struct socket *so, int proto, struct thread *td)
error = soreserve(so, rip_sendspace, rip_recvspace);
if (error)
return (error);
- INP_INFO_WLOCK(&ripcbinfo);
- error = in_pcballoc(so, &ripcbinfo);
+ INP_INFO_WLOCK(&V_ripcbinfo);
+ error = in_pcballoc(so, &V_ripcbinfo);
if (error) {
- INP_INFO_WUNLOCK(&ripcbinfo);
+ INP_INFO_WUNLOCK(&V_ripcbinfo);
return (error);
}
inp = (struct inpcb *)so->so_pcb;
inp->inp_vflag |= INP_IPV4;
inp->inp_ip_p = proto;
- inp->inp_ip_ttl = ip_defttl;
+ inp->inp_ip_ttl = V_ip_defttl;
rip_inshash(inp);
- INP_INFO_WUNLOCK(&ripcbinfo);
+ INP_INFO_WUNLOCK(&V_ripcbinfo);
INP_WUNLOCK(inp);
return (0);
}
@@ -695,18 +696,18 @@ rip_detach(struct socket *so)
KASSERT(inp->inp_faddr.s_addr == INADDR_ANY,
("rip_detach: not closed"));
- INP_INFO_WLOCK(&ripcbinfo);
+ INP_INFO_WLOCK(&V_ripcbinfo);
INP_WLOCK(inp);
rip_delhash(inp);
- if (so == ip_mrouter && ip_mrouter_done)
+ if (so == V_ip_mrouter && ip_mrouter_done)
ip_mrouter_done();
if (ip_rsvp_force_done)
ip_rsvp_force_done(so);
- if (so == ip_rsvpd)
+ if (so == V_ip_rsvpd)
ip_rsvp_done();
in_pcbdetach(inp);
in_pcbfree(inp);
- INP_INFO_WUNLOCK(&ripcbinfo);
+ INP_INFO_WUNLOCK(&V_ripcbinfo);
}
static void
@@ -732,11 +733,11 @@ rip_abort(struct socket *so)
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("rip_abort: inp == NULL"));
- INP_INFO_WLOCK(&ripcbinfo);
+ INP_INFO_WLOCK(&V_ripcbinfo);
INP_WLOCK(inp);
rip_dodisconnect(so, inp);
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&ripcbinfo);
+ INP_INFO_WUNLOCK(&V_ripcbinfo);
}
static void
@@ -747,11 +748,11 @@ rip_close(struct socket *so)
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("rip_close: inp == NULL"));
- INP_INFO_WLOCK(&ripcbinfo);
+ INP_INFO_WLOCK(&V_ripcbinfo);
INP_WLOCK(inp);
rip_dodisconnect(so, inp);
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&ripcbinfo);
+ INP_INFO_WUNLOCK(&V_ripcbinfo);
}
static int
@@ -765,11 +766,11 @@ rip_disconnect(struct socket *so)
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("rip_disconnect: inp == NULL"));
- INP_INFO_WLOCK(&ripcbinfo);
+ INP_INFO_WLOCK(&V_ripcbinfo);
INP_WLOCK(inp);
rip_dodisconnect(so, inp);
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&ripcbinfo);
+ INP_INFO_WUNLOCK(&V_ripcbinfo);
return (0);
}
@@ -790,7 +791,7 @@ rip_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
return (EADDRNOTAVAIL);
}
- if (TAILQ_EMPTY(&ifnet) ||
+ if (TAILQ_EMPTY(&V_ifnet) ||
(addr->sin_family != AF_INET && addr->sin_family != AF_IMPLINK) ||
(addr->sin_addr.s_addr &&
ifa_ifwithaddr((struct sockaddr *)addr) == 0))
@@ -799,13 +800,13 @@ rip_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("rip_bind: inp == NULL"));
- INP_INFO_WLOCK(&ripcbinfo);
+ INP_INFO_WLOCK(&V_ripcbinfo);
INP_WLOCK(inp);
rip_delhash(inp);
inp->inp_laddr = addr->sin_addr;
rip_inshash(inp);
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&ripcbinfo);
+ INP_INFO_WUNLOCK(&V_ripcbinfo);
return (0);
}
@@ -817,7 +818,7 @@ rip_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
if (nam->sa_len != sizeof(*addr))
return (EINVAL);
- if (TAILQ_EMPTY(&ifnet))
+ if (TAILQ_EMPTY(&V_ifnet))
return (EADDRNOTAVAIL);
if (addr->sin_family != AF_INET && addr->sin_family != AF_IMPLINK)
return (EAFNOSUPPORT);
@@ -825,14 +826,14 @@ rip_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("rip_connect: inp == NULL"));
- INP_INFO_WLOCK(&ripcbinfo);
+ INP_INFO_WLOCK(&V_ripcbinfo);
INP_WLOCK(inp);
rip_delhash(inp);
inp->inp_faddr = addr->sin_addr;
rip_inshash(inp);
soisconnected(so);
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&ripcbinfo);
+ INP_INFO_WUNLOCK(&V_ripcbinfo);
return (0);
}
@@ -892,7 +893,7 @@ rip_pcblist(SYSCTL_HANDLER_ARGS)
* resource-intensive to repeat twice on every request.
*/
if (req->oldptr == 0) {
- n = ripcbinfo.ipi_count;
+ n = V_ripcbinfo.ipi_count;
req->oldidx = 2 * (sizeof xig)
+ (n + n/8) * sizeof(struct xinpcb);
return (0);
@@ -904,10 +905,10 @@ rip_pcblist(SYSCTL_HANDLER_ARGS)
/*
* OK, now we're committed to doing something.
*/
- INP_INFO_RLOCK(&ripcbinfo);
- gencnt = ripcbinfo.ipi_gencnt;
- n = ripcbinfo.ipi_count;
- INP_INFO_RUNLOCK(&ripcbinfo);
+ INP_INFO_RLOCK(&V_ripcbinfo);
+ gencnt = V_ripcbinfo.ipi_gencnt;
+ n = V_ripcbinfo.ipi_count;
+ INP_INFO_RUNLOCK(&V_ripcbinfo);
xig.xig_len = sizeof xig;
xig.xig_count = n;
@@ -921,8 +922,8 @@ rip_pcblist(SYSCTL_HANDLER_ARGS)
if (inp_list == 0)
return (ENOMEM);
- INP_INFO_RLOCK(&ripcbinfo);
- for (inp = LIST_FIRST(ripcbinfo.ipi_listhead), i = 0; inp && i < n;
+ INP_INFO_RLOCK(&V_ripcbinfo);
+ for (inp = LIST_FIRST(V_ripcbinfo.ipi_listhead), i = 0; inp && i < n;
inp = LIST_NEXT(inp, inp_list)) {
INP_RLOCK(inp);
if (inp->inp_gencnt <= gencnt &&
@@ -932,7 +933,7 @@ rip_pcblist(SYSCTL_HANDLER_ARGS)
}
INP_RUNLOCK(inp);
}
- INP_INFO_RUNLOCK(&ripcbinfo);
+ INP_INFO_RUNLOCK(&V_ripcbinfo);
n = i;
error = 0;
@@ -959,11 +960,11 @@ rip_pcblist(SYSCTL_HANDLER_ARGS)
* that something happened while we were processing this
* request, and it might be necessary to retry.
*/
- INP_INFO_RLOCK(&ripcbinfo);
- xig.xig_gen = ripcbinfo.ipi_gencnt;
+ INP_INFO_RLOCK(&V_ripcbinfo);
+ xig.xig_gen = V_ripcbinfo.ipi_gencnt;
xig.xig_sogen = so_gencnt;
- xig.xig_count = ripcbinfo.ipi_count;
- INP_INFO_RUNLOCK(&ripcbinfo);
+ xig.xig_count = V_ripcbinfo.ipi_count;
+ INP_INFO_RUNLOCK(&V_ripcbinfo);
error = SYSCTL_OUT(req, &xig, sizeof xig);
}
free(inp_list, M_TEMP);
diff --git a/sys/netinet/sctp_os_bsd.h b/sys/netinet/sctp_os_bsd.h
index a1795d2..9514f7a 100644
--- a/sys/netinet/sctp_os_bsd.h
+++ b/sys/netinet/sctp_os_bsd.h
@@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
#include "opt_inet6.h"
#include "opt_inet.h"
#include "opt_sctp.h"
+
#include <sys/param.h>
#include <sys/ktr.h>
#include <sys/systm.h>
@@ -60,7 +61,7 @@ __FBSDID("$FreeBSD$");
#include <sys/random.h>
#include <sys/limits.h>
#include <sys/queue.h>
-#if defined(__FreeBSD__) && __FreeBSD_version > 800000 && defined(VIMAGE)
+#if defined(__FreeBSD__) && __FreeBSD_version >= 800044
#include <sys/vimage.h>
#endif
#include <machine/cpu.h>
@@ -144,9 +145,7 @@ MALLOC_DECLARE(SCTP_M_SOCKOPT);
/*
* Macros to expand out globals defined by various modules
* to either a real global or a virtualized instance of one,
- * depending on whether VIMAGE is defined in opt_vimage.h
- * XXX opt_vimage.h not yet present, more framework to come.
- * XXX so will always evaluate to the global for now (VIMAGE not defined)
+ * depending on whether VIMAGE is defined.
*/
/* first define modules that supply us information */
#define MOD_NET net
@@ -155,10 +154,14 @@ MALLOC_DECLARE(SCTP_M_SOCKOPT);
#define MOD_IPSEC ipsec
/* then define the macro(s) that hook into the vimage macros */
-#if defined(__FreeBSD__) && __FreeBSD_version > 800000 && defined(VIMAGE)
+#if defined(__FreeBSD__) && __FreeBSD_version >= 800044 && defined(VIMAGE)
+#if 0
#define VSYMNAME(__MODULE) vnet_ ## __MODULE
#define MODULE_GLOBAL(__MODULE, __SYMBOL) VSYM(VSYMNAME(__MODULE), __SYMBOL)
#else
+#define MODULE_GLOBAL(__MODULE, __SYMBOL) V_ ## __SYMBOL
+#endif
+#else
#define MODULE_GLOBAL(__MODULE, __SYMBOL) (__SYMBOL)
#endif
/*
diff --git a/sys/netinet/sctp_pcb.c b/sys/netinet/sctp_pcb.c
index 55be58b..ceca8bd 100644
--- a/sys/netinet/sctp_pcb.c
+++ b/sys/netinet/sctp_pcb.c
@@ -2784,8 +2784,8 @@ continue_anyway:
first = MODULE_GLOBAL(MOD_INET, ipport_lowfirstauto);
last = MODULE_GLOBAL(MOD_INET, ipport_lowlastauto);
} else {
- first = ipport_firstauto;
- last = ipport_lastauto;
+ first = MODULE_GLOBAL(MOD_INET, ipport_firstauto);
+ last = MODULE_GLOBAL(MOD_INET, ipport_lastauto);
}
if (first > last) {
uint16_t temp;
diff --git a/sys/netinet/tcp_hostcache.c b/sys/netinet/tcp_hostcache.c
index 3a68607..bf8f616 100644
--- a/sys/netinet/tcp_hostcache.c
+++ b/sys/netinet/tcp_hostcache.c
@@ -76,6 +76,7 @@ __FBSDID("$FreeBSD$");
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/sysctl.h>
+#include <sys/vimage.h>
#include <net/if.h>
@@ -186,7 +187,7 @@ static MALLOC_DEFINE(M_HOSTCACHE, "hostcache", "TCP hostcache");
#define HOSTCACHE_HASH(ip) \
(((ip)->s_addr ^ ((ip)->s_addr >> 7) ^ ((ip)->s_addr >> 17)) & \
- tcp_hostcache.hashmask)
+ V_tcp_hostcache.hashmask)
/* XXX: What is the recommended hash to get good entropy for IPv6 addresses? */
#define HOSTCACHE_HASH6(ip6) \
@@ -194,7 +195,7 @@ static MALLOC_DEFINE(M_HOSTCACHE, "hostcache", "TCP hostcache");
(ip6)->s6_addr32[1] ^ \
(ip6)->s6_addr32[2] ^ \
(ip6)->s6_addr32[3]) & \
- tcp_hostcache.hashmask)
+ V_tcp_hostcache.hashmask)
#define THC_LOCK(lp) mtx_lock(lp)
#define THC_UNLOCK(lp) mtx_unlock(lp)
@@ -207,55 +208,55 @@ tcp_hc_init(void)
/*
* Initialize hostcache structures.
*/
- tcp_hostcache.cache_count = 0;
- tcp_hostcache.hashsize = TCP_HOSTCACHE_HASHSIZE;
- tcp_hostcache.bucket_limit = TCP_HOSTCACHE_BUCKETLIMIT;
- tcp_hostcache.cache_limit =
- tcp_hostcache.hashsize * tcp_hostcache.bucket_limit;
- tcp_hostcache.expire = TCP_HOSTCACHE_EXPIRE;
- tcp_hostcache.prune = TCP_HOSTCACHE_PRUNE;
+ V_tcp_hostcache.cache_count = 0;
+ V_tcp_hostcache.hashsize = TCP_HOSTCACHE_HASHSIZE;
+ V_tcp_hostcache.bucket_limit = TCP_HOSTCACHE_BUCKETLIMIT;
+ V_tcp_hostcache.cache_limit =
+ V_tcp_hostcache.hashsize * V_tcp_hostcache.bucket_limit;
+ V_tcp_hostcache.expire = TCP_HOSTCACHE_EXPIRE;
+ V_tcp_hostcache.prune = TCP_HOSTCACHE_PRUNE;
TUNABLE_INT_FETCH("net.inet.tcp.hostcache.hashsize",
- &tcp_hostcache.hashsize);
+ &V_tcp_hostcache.hashsize);
TUNABLE_INT_FETCH("net.inet.tcp.hostcache.cachelimit",
- &tcp_hostcache.cache_limit);
+ &V_tcp_hostcache.cache_limit);
TUNABLE_INT_FETCH("net.inet.tcp.hostcache.bucketlimit",
- &tcp_hostcache.bucket_limit);
- if (!powerof2(tcp_hostcache.hashsize)) {
+ &V_tcp_hostcache.bucket_limit);
+ if (!powerof2(V_tcp_hostcache.hashsize)) {
printf("WARNING: hostcache hash size is not a power of 2.\n");
- tcp_hostcache.hashsize = TCP_HOSTCACHE_HASHSIZE; /* default */
+ V_tcp_hostcache.hashsize = TCP_HOSTCACHE_HASHSIZE; /* default */
}
- tcp_hostcache.hashmask = tcp_hostcache.hashsize - 1;
+ V_tcp_hostcache.hashmask = V_tcp_hostcache.hashsize - 1;
/*
* Allocate the hash table.
*/
- tcp_hostcache.hashbase = (struct hc_head *)
- malloc(tcp_hostcache.hashsize * sizeof(struct hc_head),
+ V_tcp_hostcache.hashbase = (struct hc_head *)
+ malloc(V_tcp_hostcache.hashsize * sizeof(struct hc_head),
M_HOSTCACHE, M_WAITOK | M_ZERO);
/*
* Initialize the hash buckets.
*/
- for (i = 0; i < tcp_hostcache.hashsize; i++) {
- TAILQ_INIT(&tcp_hostcache.hashbase[i].hch_bucket);
- tcp_hostcache.hashbase[i].hch_length = 0;
- mtx_init(&tcp_hostcache.hashbase[i].hch_mtx, "tcp_hc_entry",
+ for (i = 0; i < V_tcp_hostcache.hashsize; i++) {
+ TAILQ_INIT(&V_tcp_hostcache.hashbase[i].hch_bucket);
+ V_tcp_hostcache.hashbase[i].hch_length = 0;
+ mtx_init(&V_tcp_hostcache.hashbase[i].hch_mtx, "tcp_hc_entry",
NULL, MTX_DEF);
}
/*
* Allocate the hostcache entries.
*/
- tcp_hostcache.zone = uma_zcreate("hostcache", sizeof(struct hc_metrics),
+ V_tcp_hostcache.zone = uma_zcreate("hostcache", sizeof(struct hc_metrics),
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
- uma_zone_set_max(tcp_hostcache.zone, tcp_hostcache.cache_limit);
+ uma_zone_set_max(V_tcp_hostcache.zone, V_tcp_hostcache.cache_limit);
/*
* Set up periodic cache cleanup.
*/
- callout_init(&tcp_hc_callout, CALLOUT_MPSAFE);
- callout_reset(&tcp_hc_callout, tcp_hostcache.prune * hz, tcp_hc_purge, 0);
+ callout_init(&V_tcp_hc_callout, CALLOUT_MPSAFE);
+ callout_reset(&V_tcp_hc_callout, V_tcp_hostcache.prune * hz, tcp_hc_purge, 0);
}
/*
@@ -281,7 +282,7 @@ tcp_hc_lookup(struct in_conninfo *inc)
else
hash = HOSTCACHE_HASH(&inc->inc_faddr);
- hc_head = &tcp_hostcache.hashbase[hash];
+ hc_head = &V_tcp_hostcache.hashbase[hash];
/*
* Acquire lock for this bucket row; we release the lock if we don't
@@ -336,7 +337,7 @@ tcp_hc_insert(struct in_conninfo *inc)
else
hash = HOSTCACHE_HASH(&inc->inc_faddr);
- hc_head = &tcp_hostcache.hashbase[hash];
+ hc_head = &V_tcp_hostcache.hashbase[hash];
/*
* Acquire lock for this bucket row; we release the lock if we don't
@@ -348,8 +349,8 @@ tcp_hc_insert(struct in_conninfo *inc)
/*
* If the bucket limit is reached, reuse the least-used element.
*/
- if (hc_head->hch_length >= tcp_hostcache.bucket_limit ||
- tcp_hostcache.cache_count >= tcp_hostcache.cache_limit) {
+ if (hc_head->hch_length >= V_tcp_hostcache.bucket_limit ||
+ V_tcp_hostcache.cache_count >= V_tcp_hostcache.cache_limit) {
hc_entry = TAILQ_LAST(&hc_head->hch_bucket, hc_qhead);
/*
* At first we were dropping the last element, just to
@@ -365,17 +366,17 @@ tcp_hc_insert(struct in_conninfo *inc)
return NULL;
}
TAILQ_REMOVE(&hc_head->hch_bucket, hc_entry, rmx_q);
- tcp_hostcache.hashbase[hash].hch_length--;
- tcp_hostcache.cache_count--;
- tcpstat.tcps_hc_bucketoverflow++;
+ V_tcp_hostcache.hashbase[hash].hch_length--;
+ V_tcp_hostcache.cache_count--;
+ V_tcpstat.tcps_hc_bucketoverflow++;
#if 0
- uma_zfree(tcp_hostcache.zone, hc_entry);
+ uma_zfree(V_tcp_hostcache.zone, hc_entry);
#endif
} else {
/*
* Allocate a new entry, or balk if not possible.
*/
- hc_entry = uma_zalloc(tcp_hostcache.zone, M_NOWAIT);
+ hc_entry = uma_zalloc(V_tcp_hostcache.zone, M_NOWAIT);
if (hc_entry == NULL) {
THC_UNLOCK(&hc_head->hch_mtx);
return NULL;
@@ -391,15 +392,15 @@ tcp_hc_insert(struct in_conninfo *inc)
else
hc_entry->ip4 = inc->inc_faddr;
hc_entry->rmx_head = hc_head;
- hc_entry->rmx_expire = tcp_hostcache.expire;
+ hc_entry->rmx_expire = V_tcp_hostcache.expire;
/*
* Put it upfront.
*/
TAILQ_INSERT_HEAD(&hc_head->hch_bucket, hc_entry, rmx_q);
- tcp_hostcache.hashbase[hash].hch_length++;
- tcp_hostcache.cache_count++;
- tcpstat.tcps_hc_added++;
+ V_tcp_hostcache.hashbase[hash].hch_length++;
+ V_tcp_hostcache.cache_count++;
+ V_tcpstat.tcps_hc_added++;
return hc_entry;
}
@@ -427,7 +428,7 @@ tcp_hc_get(struct in_conninfo *inc, struct hc_metrics_lite *hc_metrics_lite)
return;
}
hc_entry->rmx_hits++;
- hc_entry->rmx_expire = tcp_hostcache.expire; /* start over again */
+ hc_entry->rmx_expire = V_tcp_hostcache.expire; /* start over again */
hc_metrics_lite->rmx_mtu = hc_entry->rmx_mtu;
hc_metrics_lite->rmx_ssthresh = hc_entry->rmx_ssthresh;
@@ -460,7 +461,7 @@ tcp_hc_getmtu(struct in_conninfo *inc)
return 0;
}
hc_entry->rmx_hits++;
- hc_entry->rmx_expire = tcp_hostcache.expire; /* start over again */
+ hc_entry->rmx_expire = V_tcp_hostcache.expire; /* start over again */
mtu = hc_entry->rmx_mtu;
THC_UNLOCK(&hc_entry->rmx_head->hch_mtx);
@@ -490,7 +491,7 @@ tcp_hc_updatemtu(struct in_conninfo *inc, u_long mtu)
return;
}
hc_entry->rmx_updates++;
- hc_entry->rmx_expire = tcp_hostcache.expire; /* start over again */
+ hc_entry->rmx_expire = V_tcp_hostcache.expire; /* start over again */
hc_entry->rmx_mtu = mtu;
@@ -522,7 +523,7 @@ tcp_hc_update(struct in_conninfo *inc, struct hc_metrics_lite *hcml)
return;
}
hc_entry->rmx_updates++;
- hc_entry->rmx_expire = tcp_hostcache.expire; /* start over again */
+ hc_entry->rmx_expire = V_tcp_hostcache.expire; /* start over again */
if (hcml->rmx_rtt != 0) {
if (hc_entry->rmx_rtt == 0)
@@ -530,7 +531,7 @@ tcp_hc_update(struct in_conninfo *inc, struct hc_metrics_lite *hcml)
else
hc_entry->rmx_rtt =
(hc_entry->rmx_rtt + hcml->rmx_rtt) / 2;
- tcpstat.tcps_cachedrtt++;
+ V_tcpstat.tcps_cachedrtt++;
}
if (hcml->rmx_rttvar != 0) {
if (hc_entry->rmx_rttvar == 0)
@@ -538,7 +539,7 @@ tcp_hc_update(struct in_conninfo *inc, struct hc_metrics_lite *hcml)
else
hc_entry->rmx_rttvar =
(hc_entry->rmx_rttvar + hcml->rmx_rttvar) / 2;
- tcpstat.tcps_cachedrttvar++;
+ V_tcpstat.tcps_cachedrttvar++;
}
if (hcml->rmx_ssthresh != 0) {
if (hc_entry->rmx_ssthresh == 0)
@@ -546,7 +547,7 @@ tcp_hc_update(struct in_conninfo *inc, struct hc_metrics_lite *hcml)
else
hc_entry->rmx_ssthresh =
(hc_entry->rmx_ssthresh + hcml->rmx_ssthresh) / 2;
- tcpstat.tcps_cachedssthresh++;
+ V_tcpstat.tcps_cachedssthresh++;
}
if (hcml->rmx_bandwidth != 0) {
if (hc_entry->rmx_bandwidth == 0)
@@ -554,7 +555,7 @@ tcp_hc_update(struct in_conninfo *inc, struct hc_metrics_lite *hcml)
else
hc_entry->rmx_bandwidth =
(hc_entry->rmx_bandwidth + hcml->rmx_bandwidth) / 2;
- /* tcpstat.tcps_cachedbandwidth++; */
+ /* V_tcpstat.tcps_cachedbandwidth++; */
}
if (hcml->rmx_cwnd != 0) {
if (hc_entry->rmx_cwnd == 0)
@@ -562,7 +563,7 @@ tcp_hc_update(struct in_conninfo *inc, struct hc_metrics_lite *hcml)
else
hc_entry->rmx_cwnd =
(hc_entry->rmx_cwnd + hcml->rmx_cwnd) / 2;
- /* tcpstat.tcps_cachedcwnd++; */
+ /* V_tcpstat.tcps_cachedcwnd++; */
}
if (hcml->rmx_sendpipe != 0) {
if (hc_entry->rmx_sendpipe == 0)
@@ -570,7 +571,7 @@ tcp_hc_update(struct in_conninfo *inc, struct hc_metrics_lite *hcml)
else
hc_entry->rmx_sendpipe =
(hc_entry->rmx_sendpipe + hcml->rmx_sendpipe) /2;
- /* tcpstat.tcps_cachedsendpipe++; */
+ /* V_tcpstat.tcps_cachedsendpipe++; */
}
if (hcml->rmx_recvpipe != 0) {
if (hc_entry->rmx_recvpipe == 0)
@@ -578,7 +579,7 @@ tcp_hc_update(struct in_conninfo *inc, struct hc_metrics_lite *hcml)
else
hc_entry->rmx_recvpipe =
(hc_entry->rmx_recvpipe + hcml->rmx_recvpipe) /2;
- /* tcpstat.tcps_cachedrecvpipe++; */
+ /* V_tcpstat.tcps_cachedrecvpipe++; */
}
TAILQ_REMOVE(&hc_entry->rmx_head->hch_bucket, hc_entry, rmx_q);
@@ -602,7 +603,7 @@ sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS)
char ip6buf[INET6_ADDRSTRLEN];
#endif
- bufsize = linesize * (tcp_hostcache.cache_count + 1);
+ bufsize = linesize * (V_tcp_hostcache.cache_count + 1);
p = buf = (char *)malloc(bufsize, M_TEMP, M_WAITOK|M_ZERO);
@@ -612,9 +613,9 @@ sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS)
p += len;
#define msec(u) (((u) + 500) / 1000)
- for (i = 0; i < tcp_hostcache.hashsize; i++) {
- THC_LOCK(&tcp_hostcache.hashbase[i].hch_mtx);
- TAILQ_FOREACH(hc_entry, &tcp_hostcache.hashbase[i].hch_bucket,
+ for (i = 0; i < V_tcp_hostcache.hashsize; i++) {
+ THC_LOCK(&V_tcp_hostcache.hashbase[i].hch_mtx);
+ TAILQ_FOREACH(hc_entry, &V_tcp_hostcache.hashbase[i].hch_bucket,
rmx_q) {
len = snprintf(p, linesize,
"%-15s %5lu %8lu %6lums %6lums %9lu %8lu %8lu %8lu "
@@ -640,7 +641,7 @@ sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS)
hc_entry->rmx_expire);
p += len;
}
- THC_UNLOCK(&tcp_hostcache.hashbase[i].hch_mtx);
+ THC_UNLOCK(&V_tcp_hostcache.hashbase[i].hch_mtx);
}
#undef msec
error = SYSCTL_OUT(req, buf, p - buf);
@@ -659,25 +660,25 @@ tcp_hc_purge(void *arg)
int all = (intptr_t)arg;
int i;
- if (tcp_hostcache.purgeall) {
+ if (V_tcp_hostcache.purgeall) {
all = 1;
- tcp_hostcache.purgeall = 0;
+ V_tcp_hostcache.purgeall = 0;
}
- for (i = 0; i < tcp_hostcache.hashsize; i++) {
- THC_LOCK(&tcp_hostcache.hashbase[i].hch_mtx);
- TAILQ_FOREACH_SAFE(hc_entry, &tcp_hostcache.hashbase[i].hch_bucket,
+ for (i = 0; i < V_tcp_hostcache.hashsize; i++) {
+ THC_LOCK(&V_tcp_hostcache.hashbase[i].hch_mtx);
+ TAILQ_FOREACH_SAFE(hc_entry, &V_tcp_hostcache.hashbase[i].hch_bucket,
rmx_q, hc_next) {
if (all || hc_entry->rmx_expire <= 0) {
- TAILQ_REMOVE(&tcp_hostcache.hashbase[i].hch_bucket,
+ TAILQ_REMOVE(&V_tcp_hostcache.hashbase[i].hch_bucket,
hc_entry, rmx_q);
- uma_zfree(tcp_hostcache.zone, hc_entry);
- tcp_hostcache.hashbase[i].hch_length--;
- tcp_hostcache.cache_count--;
+ uma_zfree(V_tcp_hostcache.zone, hc_entry);
+ V_tcp_hostcache.hashbase[i].hch_length--;
+ V_tcp_hostcache.cache_count--;
} else
- hc_entry->rmx_expire -= tcp_hostcache.prune;
+ hc_entry->rmx_expire -= V_tcp_hostcache.prune;
}
- THC_UNLOCK(&tcp_hostcache.hashbase[i].hch_mtx);
+ THC_UNLOCK(&V_tcp_hostcache.hashbase[i].hch_mtx);
}
- callout_reset(&tcp_hc_callout, tcp_hostcache.prune * hz, tcp_hc_purge, 0);
+ callout_reset(&V_tcp_hc_callout, V_tcp_hostcache.prune * hz, tcp_hc_purge, 0);
}
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c
index 097c40b..fae2ba6 100644
--- a/sys/netinet/tcp_input.c
+++ b/sys/netinet/tcp_input.c
@@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sysctl.h>
#include <sys/syslog.h>
#include <sys/systm.h>
+#include <sys/vimage.h>
#include <machine/cpu.h> /* before tcp_seq.h, for tcp_random18() */
@@ -209,7 +210,7 @@ do { \
#define DELAY_ACK(tp) \
((!tcp_timer_active(tp, TT_DELACK) && \
(tp->t_flags & TF_RXWIN0SENT) == 0) && \
- (tcp_delack_enabled || (tp->t_flags & TF_NEEDSYN)))
+ (V_tcp_delack_enabled || (tp->t_flags & TF_NEEDSYN)))
/*
@@ -293,7 +294,7 @@ tcp_input(struct mbuf *m, int off0)
#endif
to.to_flags = 0;
- tcpstat.tcps_rcvtotal++;
+ V_tcpstat.tcps_rcvtotal++;
if (isipv6) {
#ifdef INET6
@@ -301,7 +302,7 @@ tcp_input(struct mbuf *m, int off0)
ip6 = mtod(m, struct ip6_hdr *);
tlen = sizeof(*ip6) + ntohs(ip6->ip6_plen) - off0;
if (in6_cksum(m, IPPROTO_TCP, off0, tlen)) {
- tcpstat.tcps_rcvbadsum++;
+ V_tcpstat.tcps_rcvbadsum++;
goto drop;
}
th = (struct tcphdr *)((caddr_t)ip6 + off0);
@@ -333,7 +334,7 @@ tcp_input(struct mbuf *m, int off0)
if (m->m_len < sizeof (struct tcpiphdr)) {
if ((m = m_pullup(m, sizeof (struct tcpiphdr)))
== NULL) {
- tcpstat.tcps_rcvshort++;
+ V_tcpstat.tcps_rcvshort++;
return;
}
}
@@ -367,7 +368,7 @@ tcp_input(struct mbuf *m, int off0)
th->th_sum = in_cksum(m, len);
}
if (th->th_sum) {
- tcpstat.tcps_rcvbadsum++;
+ V_tcpstat.tcps_rcvbadsum++;
goto drop;
}
/* Re-initialization for later version check */
@@ -387,7 +388,7 @@ tcp_input(struct mbuf *m, int off0)
*/
off = th->th_off << 2;
if (off < sizeof (struct tcphdr) || off > tlen) {
- tcpstat.tcps_rcvbadoff++;
+ V_tcpstat.tcps_rcvbadoff++;
goto drop;
}
tlen -= off; /* tlen is used instead of ti->ti_len */
@@ -402,7 +403,7 @@ tcp_input(struct mbuf *m, int off0)
if (m->m_len < sizeof(struct ip) + off) {
if ((m = m_pullup(m, sizeof (struct ip) + off))
== NULL) {
- tcpstat.tcps_rcvshort++;
+ V_tcpstat.tcps_rcvshort++;
return;
}
ip = mtod(m, struct ip *);
@@ -431,9 +432,9 @@ tcp_input(struct mbuf *m, int off0)
/*
* Locate pcb for segment.
*/
- INP_INFO_WLOCK(&tcbinfo);
+ INP_INFO_WLOCK(&V_tcbinfo);
findpcb:
- INP_INFO_WLOCK_ASSERT(&tcbinfo);
+ INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
#ifdef IPFIREWALL_FORWARD
/*
* Grab info from PACKET_TAG_IPFORWARD tag prepended to the chain.
@@ -448,13 +449,13 @@ findpcb:
* Transparently forwarded. Pretend to be the destination.
* already got one like this?
*/
- inp = in_pcblookup_hash(&tcbinfo,
+ inp = in_pcblookup_hash(&V_tcbinfo,
ip->ip_src, th->th_sport,
ip->ip_dst, th->th_dport,
0, m->m_pkthdr.rcvif);
if (!inp) {
/* It's new. Try to find the ambushing socket. */
- inp = in_pcblookup_hash(&tcbinfo,
+ inp = in_pcblookup_hash(&V_tcbinfo,
ip->ip_src, th->th_sport,
next_hop->sin_addr,
next_hop->sin_port ?
@@ -470,14 +471,14 @@ findpcb:
{
if (isipv6) {
#ifdef INET6
- inp = in6_pcblookup_hash(&tcbinfo,
+ inp = in6_pcblookup_hash(&V_tcbinfo,
&ip6->ip6_src, th->th_sport,
&ip6->ip6_dst, th->th_dport,
INPLOOKUP_WILDCARD,
m->m_pkthdr.rcvif);
#endif
} else
- inp = in_pcblookup_hash(&tcbinfo,
+ inp = in_pcblookup_hash(&V_tcbinfo,
ip->ip_src, th->th_sport,
ip->ip_dst, th->th_dport,
INPLOOKUP_WILDCARD,
@@ -504,8 +505,8 @@ findpcb:
* When blackholing do not respond with a RST but
* completely ignore the segment and drop it.
*/
- if ((blackhole == 1 && (thflags & TH_SYN)) ||
- blackhole == 2)
+ if ((V_blackhole == 1 && (thflags & TH_SYN)) ||
+ V_blackhole == 2)
goto dropunlock;
rstreason = BANDLIM_RST_CLOSEDPORT;
@@ -516,12 +517,12 @@ findpcb:
#ifdef IPSEC
#ifdef INET6
if (isipv6 && ipsec6_in_reject(m, inp)) {
- ipsec6stat.in_polvio++;
+ V_ipsec6stat.in_polvio++;
goto dropunlock;
} else
#endif /* INET6 */
if (ipsec4_in_reject(m, inp) != 0) {
- ipsec4stat.in_polvio++;
+ V_ipsec4stat.in_polvio++;
goto dropunlock;
}
#endif /* IPSEC */
@@ -553,7 +554,7 @@ findpcb:
*/
if (tcp_twcheck(inp, &to, th, m, tlen))
goto findpcb;
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
return;
}
/*
@@ -653,9 +654,9 @@ findpcb:
log(LOG_DEBUG, "%s; %s: Listen socket: "
"Socket allocation failed due to "
"limits or memory shortage, %s\n",
- s, __func__, (tcp_sc_rst_sock_fail ?
+ s, __func__, (V_tcp_sc_rst_sock_fail ?
"sending RST" : "try again"));
- if (tcp_sc_rst_sock_fail) {
+ if (V_tcp_sc_rst_sock_fail) {
rstreason = BANDLIM_UNLIMITED;
goto dropwithreset;
} else
@@ -679,7 +680,7 @@ findpcb:
*/
tcp_do_segment(m, th, so, tp, drop_hdrlen, tlen,
iptos);
- INP_INFO_UNLOCK_ASSERT(&tcbinfo);
+ INP_INFO_UNLOCK_ASSERT(&V_tcbinfo);
return;
}
/*
@@ -704,7 +705,7 @@ findpcb:
log(LOG_DEBUG, "%s; %s: Listen socket: "
"SYN is missing, segment ignored\n",
s, __func__);
- tcpstat.tcps_badsyn++;
+ V_tcpstat.tcps_badsyn++;
goto dropunlock;
}
/*
@@ -716,7 +717,7 @@ findpcb:
"SYN|ACK invalid, segment rejected\n",
s, __func__);
syncache_badack(&inc); /* XXX: Not needed! */
- tcpstat.tcps_badsyn++;
+ V_tcpstat.tcps_badsyn++;
rstreason = BANDLIM_RST_OPENPORT;
goto dropwithreset;
}
@@ -731,12 +732,12 @@ findpcb:
* XXX: This is a violation of the TCP specification
* and was used by RFC1644.
*/
- if ((thflags & TH_FIN) && drop_synfin) {
+ if ((thflags & TH_FIN) && V_drop_synfin) {
if ((s = tcp_log_addrs(&inc, th, NULL, NULL)))
log(LOG_DEBUG, "%s; %s: Listen socket: "
"SYN|FIN segment ignored (based on "
"sysctl setting)\n", s, __func__);
- tcpstat.tcps_badsyn++;
+ V_tcpstat.tcps_badsyn++;
goto dropunlock;
}
/*
@@ -781,7 +782,7 @@ findpcb:
* handling - worse, they are not exactly the same.
* I believe 5.5.4 is the best one, so we follow 5.5.4.
*/
- if (isipv6 && !ip6_use_deprecated) {
+ if (isipv6 && !V_ip6_use_deprecated) {
struct in6_ifaddr *ia6;
if ((ia6 = ip6_getdstifaddr(m)) &&
@@ -869,7 +870,7 @@ findpcb:
* Entry added to syncache and mbuf consumed.
* Everything already unlocked by syncache_add().
*/
- INP_INFO_UNLOCK_ASSERT(&tcbinfo);
+ INP_INFO_UNLOCK_ASSERT(&V_tcbinfo);
return;
}
@@ -879,20 +880,20 @@ findpcb:
* the inpcb, and unlocks pcbinfo.
*/
tcp_do_segment(m, th, so, tp, drop_hdrlen, tlen, iptos);
- INP_INFO_UNLOCK_ASSERT(&tcbinfo);
+ INP_INFO_UNLOCK_ASSERT(&V_tcbinfo);
return;
dropwithreset:
- INP_INFO_WLOCK_ASSERT(&tcbinfo);
+ INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
tcp_dropwithreset(m, th, tp, tlen, rstreason);
m = NULL; /* mbuf chain got consumed. */
dropunlock:
- INP_INFO_WLOCK_ASSERT(&tcbinfo);
+ INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
if (inp != NULL)
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
drop:
- INP_INFO_UNLOCK_ASSERT(&tcbinfo);
+ INP_INFO_UNLOCK_ASSERT(&V_tcbinfo);
if (s != NULL)
free(s, M_TCPLOG);
if (m != NULL)
@@ -921,7 +922,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
#endif
thflags = th->th_flags;
- INP_INFO_WLOCK_ASSERT(&tcbinfo);
+ INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
INP_WLOCK_ASSERT(tp->t_inpcb);
KASSERT(tp->t_state > TCPS_LISTEN, ("%s: TCPS_LISTEN",
__func__));
@@ -951,13 +952,13 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
switch (iptos & IPTOS_ECN_MASK) {
case IPTOS_ECN_CE:
tp->t_flags |= TF_ECN_SND_ECE;
- tcpstat.tcps_ecn_ce++;
+ V_tcpstat.tcps_ecn_ce++;
break;
case IPTOS_ECN_ECT0:
- tcpstat.tcps_ecn_ect0++;
+ V_tcpstat.tcps_ecn_ect0++;
break;
case IPTOS_ECN_ECT1:
- tcpstat.tcps_ecn_ect1++;
+ V_tcpstat.tcps_ecn_ect1++;
break;
}
@@ -970,7 +971,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
*/
if ((thflags & TH_ECE) &&
SEQ_LEQ(th->th_ack, tp->snd_recover)) {
- tcpstat.tcps_ecn_rcwnd++;
+ V_tcpstat.tcps_ecn_rcwnd++;
tcp_congestion_exp(tp);
}
}
@@ -1067,28 +1068,28 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
if (SEQ_GT(th->th_ack, tp->snd_una) &&
SEQ_LEQ(th->th_ack, tp->snd_max) &&
tp->snd_cwnd >= tp->snd_wnd &&
- ((!tcp_do_newreno &&
+ ((!V_tcp_do_newreno &&
!(tp->t_flags & TF_SACK_PERMIT) &&
tp->t_dupacks < tcprexmtthresh) ||
- ((tcp_do_newreno ||
+ ((V_tcp_do_newreno ||
(tp->t_flags & TF_SACK_PERMIT)) &&
!IN_FASTRECOVERY(tp) &&
(to.to_flags & TOF_SACK) == 0 &&
TAILQ_EMPTY(&tp->snd_holes)))) {
KASSERT(headlocked,
("%s: headlocked", __func__));
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
headlocked = 0;
/*
* This is a pure ack for outstanding data.
*/
- ++tcpstat.tcps_predack;
+ ++V_tcpstat.tcps_predack;
/*
* "bad retransmit" recovery.
*/
if (tp->t_rxtshift == 1 &&
ticks < tp->t_badrxtwin) {
- ++tcpstat.tcps_sndrexmitbad;
+ ++V_tcpstat.tcps_sndrexmitbad;
tp->snd_cwnd = tp->snd_cwnd_prev;
tp->snd_ssthresh =
tp->snd_ssthresh_prev;
@@ -1124,8 +1125,8 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
}
tcp_xmit_bandwidth_limit(tp, th->th_ack);
acked = th->th_ack - tp->snd_una;
- tcpstat.tcps_rcvackpack++;
- tcpstat.tcps_rcvackbyte += acked;
+ V_tcpstat.tcps_rcvackpack++;
+ V_tcpstat.tcps_rcvackbyte += acked;
sbdrop(&so->so_snd, acked);
if (SEQ_GT(tp->snd_una, tp->snd_recover) &&
SEQ_LEQ(th->th_ack, tp->snd_recover))
@@ -1170,7 +1171,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
int newsize = 0; /* automatic sockbuf scaling */
KASSERT(headlocked, ("%s: headlocked", __func__));
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
headlocked = 0;
/*
* This is a pure, in-sequence data packet
@@ -1180,7 +1181,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
/* Clean receiver SACK report if present */
if ((tp->t_flags & TF_SACK_PERMIT) && tp->rcv_numsacks)
tcp_clean_sackreport(tp);
- ++tcpstat.tcps_preddat;
+ ++V_tcpstat.tcps_preddat;
tp->rcv_nxt += tlen;
/*
* Pull snd_wl1 up to prevent seq wrap relative to
@@ -1192,8 +1193,8 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
* rcv_nxt.
*/
tp->rcv_up = tp->rcv_nxt;
- tcpstat.tcps_rcvpack++;
- tcpstat.tcps_rcvbyte += tlen;
+ V_tcpstat.tcps_rcvpack++;
+ V_tcpstat.tcps_rcvbyte += tlen;
ND6_HINT(tp); /* Some progress has been made */
#ifdef TCPDEBUG
if (so->so_options & SO_DEBUG)
@@ -1233,7 +1234,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
* TODO: Only step up if the application is actually serving
* the buffer to better manage the socket buffer resources.
*/
- if (tcp_do_autorcvbuf &&
+ if (V_tcp_do_autorcvbuf &&
to.to_tsecr &&
(so->so_rcv.sb_flags & SB_AUTOSIZE)) {
if (to.to_tsecr > tp->rfbuf_ts &&
@@ -1241,11 +1242,11 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
if (tp->rfbuf_cnt >
(so->so_rcv.sb_hiwat / 8 * 7) &&
so->so_rcv.sb_hiwat <
- tcp_autorcvbuf_max) {
+ V_tcp_autorcvbuf_max) {
newsize =
min(so->so_rcv.sb_hiwat +
- tcp_autorcvbuf_inc,
- tcp_autorcvbuf_max);
+ V_tcp_autorcvbuf_inc,
+ V_tcp_autorcvbuf_max);
}
/* Start over with next RTT. */
tp->rfbuf_ts = 0;
@@ -1343,7 +1344,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
tp->irs = th->th_seq;
tcp_rcvseqinit(tp);
if (thflags & TH_ACK) {
- tcpstat.tcps_connects++;
+ V_tcpstat.tcps_connects++;
soisconnected(so);
#ifdef MAC
SOCK_LOCK(so);
@@ -1367,9 +1368,9 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
else
tp->t_flags |= TF_ACKNOW;
- if ((thflags & TH_ECE) && tcp_do_ecn) {
+ if ((thflags & TH_ECE) && V_tcp_do_ecn) {
tp->t_flags |= TF_ECN_PERMIT;
- tcpstat.tcps_ecn_shs++;
+ V_tcpstat.tcps_ecn_shs++;
}
/*
@@ -1418,8 +1419,8 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
m_adj(m, -todrop);
tlen = tp->rcv_wnd;
thflags &= ~TH_FIN;
- tcpstat.tcps_rcvpackafterwin++;
- tcpstat.tcps_rcvbyteafterwin += todrop;
+ V_tcpstat.tcps_rcvpackafterwin++;
+ V_tcpstat.tcps_rcvbyteafterwin += todrop;
}
tp->snd_wl1 = th->th_seq - 1;
tp->rcv_up = th->th_seq;
@@ -1518,12 +1519,12 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
goto close;
case TCPS_ESTABLISHED:
- if (tcp_insecure_rst == 0 &&
+ if (V_tcp_insecure_rst == 0 &&
!(SEQ_GEQ(th->th_seq, tp->rcv_nxt - 1) &&
SEQ_LEQ(th->th_seq, tp->rcv_nxt + 1)) &&
!(SEQ_GEQ(th->th_seq, tp->last_ack_sent - 1) &&
SEQ_LEQ(th->th_seq, tp->last_ack_sent + 1))) {
- tcpstat.tcps_badrst++;
+ V_tcpstat.tcps_badrst++;
goto drop;
}
/* FALLTHROUGH */
@@ -1533,7 +1534,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
so->so_error = ECONNRESET;
close:
tp->t_state = TCPS_CLOSED;
- tcpstat.tcps_drops++;
+ V_tcpstat.tcps_drops++;
KASSERT(headlocked, ("%s: trimthenstep6: "
"tcp_close: head not locked", __func__));
tp = tcp_close(tp);
@@ -1572,9 +1573,9 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
*/
tp->ts_recent = 0;
} else {
- tcpstat.tcps_rcvduppack++;
- tcpstat.tcps_rcvdupbyte += tlen;
- tcpstat.tcps_pawsdrop++;
+ V_tcpstat.tcps_rcvduppack++;
+ V_tcpstat.tcps_rcvdupbyte += tlen;
+ V_tcpstat.tcps_pawsdrop++;
if (tlen)
goto dropafterack;
goto drop;
@@ -1622,11 +1623,11 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
*/
tp->t_flags |= TF_ACKNOW;
todrop = tlen;
- tcpstat.tcps_rcvduppack++;
- tcpstat.tcps_rcvdupbyte += todrop;
+ V_tcpstat.tcps_rcvduppack++;
+ V_tcpstat.tcps_rcvdupbyte += todrop;
} else {
- tcpstat.tcps_rcvpartduppack++;
- tcpstat.tcps_rcvpartdupbyte += todrop;
+ V_tcpstat.tcps_rcvpartduppack++;
+ V_tcpstat.tcps_rcvpartdupbyte += todrop;
}
drop_hdrlen += todrop; /* drop from the top afterwards */
th->th_seq += todrop;
@@ -1656,7 +1657,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
free(s, M_TCPLOG);
}
tp = tcp_close(tp);
- tcpstat.tcps_rcvafterclose++;
+ V_tcpstat.tcps_rcvafterclose++;
rstreason = BANDLIM_UNLIMITED;
goto dropwithreset;
}
@@ -1667,9 +1668,9 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
*/
todrop = (th->th_seq + tlen) - (tp->rcv_nxt + tp->rcv_wnd);
if (todrop > 0) {
- tcpstat.tcps_rcvpackafterwin++;
+ V_tcpstat.tcps_rcvpackafterwin++;
if (todrop >= tlen) {
- tcpstat.tcps_rcvbyteafterwin += tlen;
+ V_tcpstat.tcps_rcvbyteafterwin += tlen;
/*
* If window is closed can only take segments at
* window edge, and have to drop data and PUSH from
@@ -1679,11 +1680,11 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
*/
if (tp->rcv_wnd == 0 && th->th_seq == tp->rcv_nxt) {
tp->t_flags |= TF_ACKNOW;
- tcpstat.tcps_rcvwinprobe++;
+ V_tcpstat.tcps_rcvwinprobe++;
} else
goto dropafterack;
} else
- tcpstat.tcps_rcvbyteafterwin += todrop;
+ V_tcpstat.tcps_rcvbyteafterwin += todrop;
m_adj(m, -todrop);
tlen -= todrop;
thflags &= ~(TH_PUSH|TH_FIN);
@@ -1754,7 +1755,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
*/
case TCPS_SYN_RECEIVED:
- tcpstat.tcps_connects++;
+ V_tcpstat.tcps_connects++;
soisconnected(so);
/* Do window scaling? */
if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) ==
@@ -1800,7 +1801,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
case TCPS_CLOSING:
case TCPS_LAST_ACK:
if (SEQ_GT(th->th_ack, tp->snd_max)) {
- tcpstat.tcps_rcvacktoomuch++;
+ V_tcpstat.tcps_rcvacktoomuch++;
goto dropafterack;
}
if ((tp->t_flags & TF_SACK_PERMIT) &&
@@ -1809,7 +1810,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
tcp_sack_doack(tp, &to, th->th_ack);
if (SEQ_LEQ(th->th_ack, tp->snd_una)) {
if (tlen == 0 && tiwin == tp->snd_wnd) {
- tcpstat.tcps_rcvdupack++;
+ V_tcpstat.tcps_rcvdupack++;
/*
* If we have outstanding data (other than
* a window probe), this is a completely
@@ -1841,7 +1842,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
th->th_ack != tp->snd_una)
tp->t_dupacks = 0;
else if (++tp->t_dupacks > tcprexmtthresh ||
- ((tcp_do_newreno ||
+ ((V_tcp_do_newreno ||
(tp->t_flags & TF_SACK_PERMIT)) &&
IN_FASTRECOVERY(tp))) {
if ((tp->t_flags & TF_SACK_PERMIT) &&
@@ -1880,8 +1881,8 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
tp->t_dupacks = 0;
break;
}
- } else if (tcp_do_newreno ||
- tcp_do_ecn) {
+ } else if (V_tcp_do_newreno ||
+ V_tcp_do_ecn) {
if (SEQ_LEQ(th->th_ack,
tp->snd_recover)) {
tp->t_dupacks = 0;
@@ -1892,7 +1893,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
tcp_timer_activate(tp, TT_REXMT, 0);
tp->t_rtttime = 0;
if (tp->t_flags & TF_SACK_PERMIT) {
- tcpstat.tcps_sack_recovery_episode++;
+ V_tcpstat.tcps_sack_recovery_episode++;
tp->sack_newdata = tp->snd_nxt;
tp->snd_cwnd = tp->t_maxseg;
(void) tcp_output(tp);
@@ -1910,7 +1911,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
if (SEQ_GT(onxt, tp->snd_nxt))
tp->snd_nxt = onxt;
goto drop;
- } else if (tcp_do_rfc3042) {
+ } else if (V_tcp_do_rfc3042) {
u_long oldcwnd = tp->snd_cwnd;
tcp_seq oldsndmax = tp->snd_max;
u_int sent;
@@ -1952,7 +1953,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
* If the congestion window was inflated to account
* for the other side's cached packets, retract it.
*/
- if (tcp_do_newreno || (tp->t_flags & TF_SACK_PERMIT)) {
+ if (V_tcp_do_newreno || (tp->t_flags & TF_SACK_PERMIT)) {
if (IN_FASTRECOVERY(tp)) {
if (SEQ_LT(th->th_ack, tp->snd_recover)) {
if (tp->t_flags & TF_SACK_PERMIT)
@@ -2013,8 +2014,8 @@ process_ACK:
INP_WLOCK_ASSERT(tp->t_inpcb);
acked = th->th_ack - tp->snd_una;
- tcpstat.tcps_rcvackpack++;
- tcpstat.tcps_rcvackbyte += acked;
+ V_tcpstat.tcps_rcvackpack++;
+ V_tcpstat.tcps_rcvackbyte += acked;
/*
* If we just performed our first retransmit, and the ACK
@@ -2024,7 +2025,7 @@ process_ACK:
* we left off.
*/
if (tp->t_rxtshift == 1 && ticks < tp->t_badrxtwin) {
- ++tcpstat.tcps_sndrexmitbad;
+ ++V_tcpstat.tcps_sndrexmitbad;
tp->snd_cwnd = tp->snd_cwnd_prev;
tp->snd_ssthresh = tp->snd_ssthresh_prev;
tp->snd_recover = tp->snd_recover_prev;
@@ -2086,7 +2087,7 @@ process_ACK:
* Otherwise open linearly: maxseg per window
* (maxseg^2 / cwnd per packet).
*/
- if ((!tcp_do_newreno && !(tp->t_flags & TF_SACK_PERMIT)) ||
+ if ((!V_tcp_do_newreno && !(tp->t_flags & TF_SACK_PERMIT)) ||
!IN_FASTRECOVERY(tp)) {
u_int cw = tp->snd_cwnd;
u_int incr = tp->t_maxseg;
@@ -2107,12 +2108,12 @@ process_ACK:
/* NB: sowwakeup_locked() does an implicit unlock. */
sowwakeup_locked(so);
/* Detect una wraparound. */
- if ((tcp_do_newreno || (tp->t_flags & TF_SACK_PERMIT)) &&
+ if ((V_tcp_do_newreno || (tp->t_flags & TF_SACK_PERMIT)) &&
!IN_FASTRECOVERY(tp) &&
SEQ_GT(tp->snd_una, tp->snd_recover) &&
SEQ_LEQ(th->th_ack, tp->snd_recover))
tp->snd_recover = th->th_ack - 1;
- if ((tcp_do_newreno || (tp->t_flags & TF_SACK_PERMIT)) &&
+ if ((V_tcp_do_newreno || (tp->t_flags & TF_SACK_PERMIT)) &&
IN_FASTRECOVERY(tp) &&
SEQ_GEQ(th->th_ack, tp->snd_recover))
EXIT_FASTRECOVERY(tp);
@@ -2167,7 +2168,7 @@ process_ACK:
KASSERT(headlocked, ("%s: process_ACK: "
"head not locked", __func__));
tcp_twstart(tp);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
headlocked = 0;
m_freem(m);
return;
@@ -2206,7 +2207,7 @@ step6:
/* keep track of pure window updates */
if (tlen == 0 &&
tp->snd_wl2 == th->th_ack && tiwin > tp->snd_wnd)
- tcpstat.tcps_rcvwinupd++;
+ V_tcpstat.tcps_rcvwinupd++;
tp->snd_wnd = tiwin;
tp->snd_wl1 = th->th_seq;
tp->snd_wl2 = th->th_ack;
@@ -2314,8 +2315,8 @@ dodata: /* XXX */
tp->t_flags |= TF_ACKNOW;
tp->rcv_nxt += tlen;
thflags = th->th_flags & TH_FIN;
- tcpstat.tcps_rcvpack++;
- tcpstat.tcps_rcvbyte += tlen;
+ V_tcpstat.tcps_rcvpack++;
+ V_tcpstat.tcps_rcvbyte += tlen;
ND6_HINT(tp);
SOCKBUF_LOCK(&so->so_rcv);
if (so->so_rcv.sb_state & SBS_CANTRCVMORE)
@@ -2400,11 +2401,11 @@ dodata: /* XXX */
KASSERT(headlocked == 1, ("%s: dodata: "
"TCP_FIN_WAIT_2: head not locked", __func__));
tcp_twstart(tp);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
return;
}
}
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
headlocked = 0;
#ifdef TCPDEBUG
if (so->so_options & SO_DEBUG)
@@ -2421,7 +2422,7 @@ dodata: /* XXX */
check_delack:
KASSERT(headlocked == 0, ("%s: check_delack: head locked",
__func__));
- INP_INFO_UNLOCK_ASSERT(&tcbinfo);
+ INP_INFO_UNLOCK_ASSERT(&V_tcbinfo);
INP_WLOCK_ASSERT(tp->t_inpcb);
if (tp->t_flags & TF_DELACK) {
tp->t_flags &= ~TF_DELACK;
@@ -2459,7 +2460,7 @@ dropafterack:
&tcp_savetcp, 0);
#endif
KASSERT(headlocked, ("%s: headlocked should be 1", __func__));
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
tp->t_flags |= TF_ACKNOW;
(void) tcp_output(tp);
INP_WUNLOCK(tp->t_inpcb);
@@ -2474,7 +2475,7 @@ dropwithreset:
if (tp != NULL)
INP_WUNLOCK(tp->t_inpcb);
if (headlocked)
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
return;
drop:
@@ -2489,7 +2490,7 @@ drop:
if (tp != NULL)
INP_WUNLOCK(tp->t_inpcb);
if (headlocked)
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
m_freem(m);
return;
}
@@ -2624,7 +2625,7 @@ tcp_dooptions(struct tcpopt *to, u_char *cp, int cnt, int flags)
continue;
if (!(flags & TO_SYN))
continue;
- if (!tcp_do_sack)
+ if (!V_tcp_do_sack)
continue;
to->to_flags |= TOF_SACKPERM;
break;
@@ -2636,7 +2637,7 @@ tcp_dooptions(struct tcpopt *to, u_char *cp, int cnt, int flags)
to->to_flags |= TOF_SACK;
to->to_nsacks = (optlen - 2) / TCPOLEN_SACK;
to->to_sacks = cp + 2;
- tcpstat.tcps_sack_rcv_blocks++;
+ V_tcpstat.tcps_sack_rcv_blocks++;
break;
default:
continue;
@@ -2690,7 +2691,7 @@ tcp_xmit_timer(struct tcpcb *tp, int rtt)
INP_WLOCK_ASSERT(tp->t_inpcb);
- tcpstat.tcps_rttupdated++;
+ V_tcpstat.tcps_rttupdated++;
tp->t_rttupdated++;
if (tp->t_srtt != 0) {
/*
@@ -2814,12 +2815,12 @@ tcp_mss(struct tcpcb *tp, int offer)
#ifdef INET6
if (isipv6) {
maxmtu = tcp_maxmtu6(&inp->inp_inc, &mtuflags);
- tp->t_maxopd = tp->t_maxseg = tcp_v6mssdflt;
+ tp->t_maxopd = tp->t_maxseg = V_tcp_v6mssdflt;
} else
#endif
{
maxmtu = tcp_maxmtu(&inp->inp_inc, &mtuflags);
- tp->t_maxopd = tp->t_maxseg = tcp_mssdflt;
+ tp->t_maxopd = tp->t_maxseg = V_tcp_mssdflt;
}
/*
@@ -2850,7 +2851,7 @@ tcp_mss(struct tcpcb *tp, int offer)
* Prevent DoS attack with too small MSS. Round up
* to at least minmss.
*/
- offer = max(offer, tcp_minmss);
+ offer = max(offer, V_tcp_minmss);
/*
* Sanity check: make sure that maxopd will be large
* enough to allow some data on segments even if the
@@ -2875,16 +2876,16 @@ tcp_mss(struct tcpcb *tp, int offer)
#ifdef INET6
if (isipv6) {
mss = maxmtu - min_protoh;
- if (!path_mtu_discovery &&
+ if (!V_path_mtu_discovery &&
!in6_localaddr(&inp->in6p_faddr))
- mss = min(mss, tcp_v6mssdflt);
+ mss = min(mss, V_tcp_v6mssdflt);
} else
#endif
{
mss = maxmtu - min_protoh;
- if (!path_mtu_discovery &&
+ if (!V_path_mtu_discovery &&
!in_localaddr(inp->inp_faddr))
- mss = min(mss, tcp_mssdflt);
+ mss = min(mss, V_tcp_mssdflt);
}
}
mss = min(mss, offer);
@@ -2960,10 +2961,10 @@ tcp_mss(struct tcpcb *tp, int offer)
if (tp->t_srtt == 0 && (rtt = metrics.rmx_rtt)) {
tp->t_srtt = rtt;
tp->t_rttbest = tp->t_srtt + TCP_RTT_SCALE;
- tcpstat.tcps_usedrtt++;
+ V_tcpstat.tcps_usedrtt++;
if (metrics.rmx_rttvar) {
tp->t_rttvar = metrics.rmx_rttvar;
- tcpstat.tcps_usedrttvar++;
+ V_tcpstat.tcps_usedrttvar++;
} else {
/* default variation is +- 1 rtt */
tp->t_rttvar =
@@ -2981,7 +2982,7 @@ tcp_mss(struct tcpcb *tp, int offer)
* threshold to no less than 2*mss.
*/
tp->snd_ssthresh = max(2 * mss, metrics.rmx_ssthresh);
- tcpstat.tcps_usedssthresh++;
+ V_tcpstat.tcps_usedssthresh++;
}
if (metrics.rmx_bandwidth)
tp->snd_bandwidth = metrics.rmx_bandwidth;
@@ -3010,7 +3011,7 @@ tcp_mss(struct tcpcb *tp, int offer)
min(tp->snd_wnd, so->so_snd.sb_hiwat)));
else
#endif
- if (tcp_do_rfc3390)
+ if (V_tcp_do_rfc3390)
tp->snd_cwnd = min(4 * mss, max(2 * mss, 4380));
#ifdef INET6
else if ((isipv6 && in6_localaddr(&inp->in6p_faddr)) ||
@@ -3018,9 +3019,9 @@ tcp_mss(struct tcpcb *tp, int offer)
#else
else if (in_localaddr(inp->inp_faddr))
#endif
- tp->snd_cwnd = mss * ss_fltsz_local;
+ tp->snd_cwnd = mss * V_ss_fltsz_local;
else
- tp->snd_cwnd = mss * ss_fltsz;
+ tp->snd_cwnd = mss * V_ss_fltsz;
/* Check the interface for TSO capabilities. */
if (mtuflags & CSUM_TSO)
@@ -3045,14 +3046,14 @@ tcp_mssopt(struct in_conninfo *inc)
#ifdef INET6
if (isipv6) {
- mss = tcp_v6mssdflt;
+ mss = V_tcp_v6mssdflt;
maxmtu = tcp_maxmtu6(inc, NULL);
thcmtu = tcp_hc_getmtu(inc); /* IPv4 and IPv6 */
min_protoh = sizeof(struct ip6_hdr) + sizeof(struct tcphdr);
} else
#endif
{
- mss = tcp_mssdflt;
+ mss = V_tcp_mssdflt;
maxmtu = tcp_maxmtu(inc, NULL);
thcmtu = tcp_hc_getmtu(inc); /* IPv4 and IPv6 */
min_protoh = sizeof(struct tcpiphdr);
diff --git a/sys/netinet/tcp_offload.c b/sys/netinet/tcp_offload.c
index d64805f..ec1fe23 100644
--- a/sys/netinet/tcp_offload.c
+++ b/sys/netinet/tcp_offload.c
@@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
#include <sys/mbuf.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_types.h>
@@ -102,20 +103,20 @@ void
tcp_offload_twstart(struct tcpcb *tp)
{
- INP_INFO_WLOCK(&tcbinfo);
+ INP_INFO_WLOCK(&V_tcbinfo);
INP_WLOCK(tp->t_inpcb);
tcp_twstart(tp);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
}
struct tcpcb *
tcp_offload_close(struct tcpcb *tp)
{
- INP_INFO_WLOCK(&tcbinfo);
+ INP_INFO_WLOCK(&V_tcbinfo);
INP_WLOCK(tp->t_inpcb);
tp = tcp_close(tp);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
if (tp)
INP_WUNLOCK(tp->t_inpcb);
@@ -126,10 +127,10 @@ struct tcpcb *
tcp_offload_drop(struct tcpcb *tp, int error)
{
- INP_INFO_WLOCK(&tcbinfo);
+ INP_INFO_WLOCK(&V_tcbinfo);
INP_WLOCK(tp->t_inpcb);
tp = tcp_drop(tp, error);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
if (tp)
INP_WUNLOCK(tp->t_inpcb);
diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c
index ac8b9e0..1e6e53e 100644
--- a/sys/netinet/tcp_output.c
+++ b/sys/netinet/tcp_output.c
@@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$");
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/sysctl.h>
+#include <sys/vimage.h>
#include <net/route.h>
@@ -170,15 +171,15 @@ tcp_output(struct tcpcb *tp)
* Set the slow-start flight size depending on whether
* this is a local network or not.
*/
- int ss = ss_fltsz;
+ int ss = V_ss_fltsz;
#ifdef INET6
if (isipv6) {
if (in6_localaddr(&tp->t_inpcb->in6p_faddr))
- ss = ss_fltsz_local;
+ ss = V_ss_fltsz_local;
} else
#endif /* INET6 */
if (in_localaddr(tp->t_inpcb->inp_faddr))
- ss = ss_fltsz_local;
+ ss = V_ss_fltsz_local;
tp->snd_cwnd = tp->t_maxseg * ss;
}
tp->t_flags &= ~TF_LASTIDLE;
@@ -252,8 +253,8 @@ again:
if (len > 0) {
sack_rxmit = 1;
sendalot = 1;
- tcpstat.tcps_sack_rexmits++;
- tcpstat.tcps_sack_rexmit_bytes +=
+ V_tcpstat.tcps_sack_rexmits++;
+ V_tcpstat.tcps_sack_rexmit_bytes +=
min(len, tp->t_maxseg);
}
}
@@ -428,14 +429,14 @@ after_sack_rexmit:
* with congestion window. Requires another timer. Has to
* wait for upcoming tcp timer rewrite.
*/
- if (tcp_do_autosndbuf && so->so_snd.sb_flags & SB_AUTOSIZE) {
+ if (V_tcp_do_autosndbuf && so->so_snd.sb_flags & SB_AUTOSIZE) {
if ((tp->snd_wnd / 4 * 5) >= so->so_snd.sb_hiwat &&
so->so_snd.sb_cc >= (so->so_snd.sb_hiwat / 8 * 7) &&
- so->so_snd.sb_cc < tcp_autosndbuf_max &&
+ so->so_snd.sb_cc < V_tcp_autosndbuf_max &&
sendwin >= (so->so_snd.sb_cc - (tp->snd_nxt - tp->snd_una))) {
if (!sbreserve_locked(&so->so_snd,
- min(so->so_snd.sb_hiwat + tcp_autosndbuf_inc,
- tcp_autosndbuf_max), so, curthread))
+ min(so->so_snd.sb_hiwat + V_tcp_autosndbuf_inc,
+ V_tcp_autosndbuf_max), so, curthread))
so->so_snd.sb_flags &= ~SB_AUTOSIZE;
}
}
@@ -464,7 +465,7 @@ after_sack_rexmit:
ipsec_optlen = ipsec_hdrsiz_tcp(tp);
#endif
if (len > tp->t_maxseg) {
- if ((tp->t_flags & TF_TSO) && tcp_do_tso &&
+ if ((tp->t_flags & TF_TSO) && V_tcp_do_tso &&
((tp->t_flags & TF_SIGNATURE) == 0) &&
tp->rcv_numsacks == 0 && sack_rxmit == 0 &&
tp->t_inpcb->inp_options == NULL &&
@@ -754,13 +755,13 @@ send:
u_int moff;
if ((tp->t_flags & TF_FORCEDATA) && len == 1)
- tcpstat.tcps_sndprobe++;
+ V_tcpstat.tcps_sndprobe++;
else if (SEQ_LT(tp->snd_nxt, tp->snd_max) || sack_rxmit) {
- tcpstat.tcps_sndrexmitpack++;
- tcpstat.tcps_sndrexmitbyte += len;
+ V_tcpstat.tcps_sndrexmitpack++;
+ V_tcpstat.tcps_sndrexmitbyte += len;
} else {
- tcpstat.tcps_sndpack++;
- tcpstat.tcps_sndbyte += len;
+ V_tcpstat.tcps_sndpack++;
+ V_tcpstat.tcps_sndbyte += len;
}
#ifdef notyet
if ((m = m_copypack(so->so_snd.sb_mb, off,
@@ -827,13 +828,13 @@ send:
} else {
SOCKBUF_UNLOCK(&so->so_snd);
if (tp->t_flags & TF_ACKNOW)
- tcpstat.tcps_sndacks++;
+ V_tcpstat.tcps_sndacks++;
else if (flags & (TH_SYN|TH_FIN|TH_RST))
- tcpstat.tcps_sndctrl++;
+ V_tcpstat.tcps_sndctrl++;
else if (SEQ_GT(tp->snd_up, tp->snd_una))
- tcpstat.tcps_sndurg++;
+ V_tcpstat.tcps_sndurg++;
else
- tcpstat.tcps_sndwinup++;
+ V_tcpstat.tcps_sndwinup++;
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == NULL) {
@@ -882,9 +883,9 @@ send:
* resend those bits a number of times as per
* RFC 3168.
*/
- if (tp->t_state == TCPS_SYN_SENT && tcp_do_ecn) {
+ if (tp->t_state == TCPS_SYN_SENT && V_tcp_do_ecn) {
if (tp->t_rxtshift >= 1) {
- if (tp->t_rxtshift <= tcp_ecn_maxretries)
+ if (tp->t_rxtshift <= V_tcp_ecn_maxretries)
flags |= TH_ECE|TH_CWR;
} else
flags |= TH_ECE|TH_CWR;
@@ -905,7 +906,7 @@ send:
else
#endif
ip->ip_tos |= IPTOS_ECN_ECT0;
- tcpstat.tcps_ecn_ect0++;
+ V_tcpstat.tcps_ecn_ect0++;
}
/*
@@ -1074,7 +1075,7 @@ send:
if (tp->t_rtttime == 0) {
tp->t_rtttime = ticks;
tp->t_rtseq = startseq;
- tcpstat.tcps_segstimed++;
+ V_tcpstat.tcps_segstimed++;
}
}
@@ -1172,7 +1173,7 @@ timer:
* Section 2. However the tcp hostcache migitates the problem
* so it affects only the first tcp connection with a host.
*/
- if (path_mtu_discovery)
+ if (V_path_mtu_discovery)
ip->ip_off |= IP_DF;
error = ip_output(m, tp->t_inpcb->inp_options, NULL,
@@ -1251,7 +1252,7 @@ out:
return (error);
}
}
- tcpstat.tcps_sndtotal++;
+ V_tcpstat.tcps_sndtotal++;
/*
* Data sent (as far as we can tell).
@@ -1272,7 +1273,7 @@ out:
* on the transmitter effectively destroys the TCP window, forcing
* it to four packets (1.5Kx4 = 6K window).
*/
- if (sendalot && (!tcp_do_newreno || --maxburst))
+ if (sendalot && (!V_tcp_do_newreno || --maxburst))
goto again;
#endif
if (sendalot)
@@ -1425,7 +1426,7 @@ tcp_addoptions(struct tcpopt *to, u_char *optp)
optlen += TCPOLEN_SACK;
sack++;
}
- tcpstat.tcps_sack_send_blocks++;
+ V_tcpstat.tcps_sack_send_blocks++;
break;
}
default:
diff --git a/sys/netinet/tcp_reass.c b/sys/netinet/tcp_reass.c
index 1502242..cf83bc2 100644
--- a/sys/netinet/tcp_reass.c
+++ b/sys/netinet/tcp_reass.c
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sysctl.h>
#include <sys/syslog.h>
#include <sys/systm.h>
+#include <sys/vimage.h>
#include <vm/uma.h>
@@ -101,8 +102,8 @@ static void
tcp_reass_zone_change(void *tag)
{
- tcp_reass_maxseg = nmbclusters / 16;
- uma_zone_set_max(tcp_reass_zone, tcp_reass_maxseg);
+ V_tcp_reass_maxseg = nmbclusters / 16;
+ uma_zone_set_max(tcp_reass_zone, V_tcp_reass_maxseg);
}
uma_zone_t tcp_reass_zone;
@@ -111,12 +112,12 @@ void
tcp_reass_init(void)
{
- tcp_reass_maxseg = nmbclusters / 16;
+ V_tcp_reass_maxseg = nmbclusters / 16;
TUNABLE_INT_FETCH("net.inet.tcp.reass.maxsegments",
- &tcp_reass_maxseg);
+ &V_tcp_reass_maxseg);
tcp_reass_zone = uma_zcreate("tcpreass", sizeof (struct tseg_qent),
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE);
- uma_zone_set_max(tcp_reass_zone, tcp_reass_maxseg);
+ uma_zone_set_max(tcp_reass_zone, V_tcp_reass_maxseg);
EVENTHANDLER_REGISTER(nmbclusters_change,
tcp_reass_zone_change, NULL, EVENTHANDLER_PRI_ANY);
}
@@ -154,10 +155,10 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, int *tlenp, struct mbuf *m)
* process the missing segment.
*/
if (th->th_seq != tp->rcv_nxt &&
- (tcp_reass_qsize + 1 >= tcp_reass_maxseg ||
- tp->t_segqlen >= tcp_reass_maxqlen)) {
- tcp_reass_overflows++;
- tcpstat.tcps_rcvmemdrop++;
+ (V_tcp_reass_qsize + 1 >= V_tcp_reass_maxseg ||
+ tp->t_segqlen >= V_tcp_reass_maxqlen)) {
+ V_tcp_reass_overflows++;
+ V_tcpstat.tcps_rcvmemdrop++;
m_freem(m);
*tlenp = 0;
return (0);
@@ -169,13 +170,13 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, int *tlenp, struct mbuf *m)
*/
te = uma_zalloc(tcp_reass_zone, M_NOWAIT);
if (te == NULL) {
- tcpstat.tcps_rcvmemdrop++;
+ V_tcpstat.tcps_rcvmemdrop++;
m_freem(m);
*tlenp = 0;
return (0);
}
tp->t_segqlen++;
- tcp_reass_qsize++;
+ V_tcp_reass_qsize++;
/*
* Find a segment which begins after this one does.
@@ -197,12 +198,12 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, int *tlenp, struct mbuf *m)
i = p->tqe_th->th_seq + p->tqe_len - th->th_seq;
if (i > 0) {
if (i >= *tlenp) {
- tcpstat.tcps_rcvduppack++;
- tcpstat.tcps_rcvdupbyte += *tlenp;
+ V_tcpstat.tcps_rcvduppack++;
+ V_tcpstat.tcps_rcvdupbyte += *tlenp;
m_freem(m);
uma_zfree(tcp_reass_zone, te);
tp->t_segqlen--;
- tcp_reass_qsize--;
+ V_tcp_reass_qsize--;
/*
* Try to present any queued data
* at the left window edge to the user.
@@ -216,8 +217,8 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, int *tlenp, struct mbuf *m)
th->th_seq += i;
}
}
- tcpstat.tcps_rcvoopack++;
- tcpstat.tcps_rcvoobyte += *tlenp;
+ V_tcpstat.tcps_rcvoopack++;
+ V_tcpstat.tcps_rcvoobyte += *tlenp;
/*
* While we overlap succeeding segments trim them or,
@@ -239,7 +240,7 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, int *tlenp, struct mbuf *m)
m_freem(q->tqe_m);
uma_zfree(tcp_reass_zone, q);
tp->t_segqlen--;
- tcp_reass_qsize--;
+ V_tcp_reass_qsize--;
q = nq;
}
@@ -276,7 +277,7 @@ present:
sbappendstream_locked(&so->so_rcv, q->tqe_m);
uma_zfree(tcp_reass_zone, q);
tp->t_segqlen--;
- tcp_reass_qsize--;
+ V_tcp_reass_qsize--;
q = nq;
} while (q && q->tqe_th->th_seq == tp->rcv_nxt);
ND6_HINT(tp);
diff --git a/sys/netinet/tcp_sack.c b/sys/netinet/tcp_sack.c
index 0b55a04..961cb78 100644
--- a/sys/netinet/tcp_sack.c
+++ b/sys/netinet/tcp_sack.c
@@ -89,6 +89,7 @@ __FBSDID("$FreeBSD$");
#include <sys/socketvar.h>
#include <sys/syslog.h>
#include <sys/systm.h>
+#include <sys/vimage.h>
#include <machine/cpu.h> /* before tcp_seq.h, for tcp_random18() */
@@ -254,9 +255,9 @@ tcp_sackhole_alloc(struct tcpcb *tp, tcp_seq start, tcp_seq end)
{
struct sackhole *hole;
- if (tp->snd_numholes >= tcp_sack_maxholes ||
- tcp_sack_globalholes >= tcp_sack_globalmaxholes) {
- tcpstat.tcps_sack_sboverflow++;
+ if (tp->snd_numholes >= V_tcp_sack_maxholes ||
+ V_tcp_sack_globalholes >= V_tcp_sack_globalmaxholes) {
+ V_tcpstat.tcps_sack_sboverflow++;
return NULL;
}
@@ -269,7 +270,7 @@ tcp_sackhole_alloc(struct tcpcb *tp, tcp_seq start, tcp_seq end)
hole->rxmit = start;
tp->snd_numholes++;
- tcp_sack_globalholes++;
+ V_tcp_sack_globalholes++;
return hole;
}
@@ -284,10 +285,10 @@ tcp_sackhole_free(struct tcpcb *tp, struct sackhole *hole)
uma_zfree(sack_hole_zone, hole);
tp->snd_numholes--;
- tcp_sack_globalholes--;
+ V_tcp_sack_globalholes--;
KASSERT(tp->snd_numholes >= 0, ("tp->snd_numholes >= 0"));
- KASSERT(tcp_sack_globalholes >= 0, ("tcp_sack_globalholes >= 0"));
+ KASSERT(V_tcp_sack_globalholes >= 0, ("tcp_sack_globalholes >= 0"));
}
/*
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index 4de3e59..659626c 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$");
#include <sys/socketvar.h>
#include <sys/protosw.h>
#include <sys/random.h>
+#include <sys/vimage.h>
#include <vm/uma.h>
@@ -236,7 +237,7 @@ static void
tcp_zone_change(void *tag)
{
- uma_zone_set_max(tcbinfo.ipi_zone, maxsockets);
+ uma_zone_set_max(V_tcbinfo.ipi_zone, maxsockets);
uma_zone_set_max(tcpcb_zone, maxsockets);
tcp_tw_zone_change();
}
@@ -265,25 +266,25 @@ tcp_init(void)
if (tcp_rexmit_min < 1)
tcp_rexmit_min = 1;
tcp_rexmit_slop = TCPTV_CPU_VAR;
- tcp_inflight_rttthresh = TCPTV_INFLIGHT_RTTTHRESH;
+ V_tcp_inflight_rttthresh = TCPTV_INFLIGHT_RTTTHRESH;
tcp_finwait2_timeout = TCPTV_FINWAIT2_TIMEOUT;
- INP_INFO_LOCK_INIT(&tcbinfo, "tcp");
- LIST_INIT(&tcb);
- tcbinfo.ipi_listhead = &tcb;
+ INP_INFO_LOCK_INIT(&V_tcbinfo, "tcp");
+ LIST_INIT(&V_tcb);
+ V_tcbinfo.ipi_listhead = &V_tcb;
TUNABLE_INT_FETCH("net.inet.tcp.tcbhashsize", &hashsize);
if (!powerof2(hashsize)) {
printf("WARNING: TCB hash size not a power of 2\n");
hashsize = 512; /* safe default */
}
tcp_tcbhashsize = hashsize;
- tcbinfo.ipi_hashbase = hashinit(hashsize, M_PCB,
- &tcbinfo.ipi_hashmask);
- tcbinfo.ipi_porthashbase = hashinit(hashsize, M_PCB,
- &tcbinfo.ipi_porthashmask);
- tcbinfo.ipi_zone = uma_zcreate("inpcb", sizeof(struct inpcb),
+ V_tcbinfo.ipi_hashbase = hashinit(hashsize, M_PCB,
+ &V_tcbinfo.ipi_hashmask);
+ V_tcbinfo.ipi_porthashbase = hashinit(hashsize, M_PCB,
+ &V_tcbinfo.ipi_porthashmask);
+ V_tcbinfo.ipi_zone = uma_zcreate("inpcb", sizeof(struct inpcb),
NULL, NULL, tcp_inpcb_init, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE);
- uma_zone_set_max(tcbinfo.ipi_zone, maxsockets);
+ uma_zone_set_max(V_tcbinfo.ipi_zone, maxsockets);
#ifdef INET6
#define TCP_MINPROTOHDR (sizeof(struct ip6_hdr) + sizeof(struct tcphdr))
#else /* INET6 */
@@ -512,8 +513,8 @@ tcp_respond(struct tcpcb *tp, void *ipgen, struct tcphdr *th, struct mbuf *m,
{
tlen += sizeof (struct tcpiphdr);
ip->ip_len = tlen;
- ip->ip_ttl = ip_defttl;
- if (path_mtu_discovery)
+ ip->ip_ttl = V_ip_defttl;
+ if (V_path_mtu_discovery)
ip->ip_off |= IP_DF;
}
m->m_len = tlen;
@@ -596,9 +597,9 @@ tcp_newtcpcb(struct inpcb *inp)
/* LIST_INIT(&tp->t_segq); */ /* XXX covered by M_ZERO */
tp->t_maxseg = tp->t_maxopd =
#ifdef INET6
- isipv6 ? tcp_v6mssdflt :
+ isipv6 ? V_tcp_v6mssdflt :
#endif /* INET6 */
- tcp_mssdflt;
+ V_tcp_mssdflt;
/* Set up our timeouts. */
callout_init(&tp->t_timers->tt_rexmt, CALLOUT_MPSAFE);
@@ -607,9 +608,9 @@ tcp_newtcpcb(struct inpcb *inp)
callout_init(&tp->t_timers->tt_2msl, CALLOUT_MPSAFE);
callout_init(&tp->t_timers->tt_delack, CALLOUT_MPSAFE);
- if (tcp_do_rfc1323)
+ if (V_tcp_do_rfc1323)
tp->t_flags = (TF_REQ_SCALE|TF_REQ_TSTMP);
- if (tcp_do_sack)
+ if (V_tcp_do_sack)
tp->t_flags |= TF_SACK_PERMIT;
TAILQ_INIT(&tp->snd_holes);
tp->t_inpcb = inp; /* XXX */
@@ -632,7 +633,7 @@ tcp_newtcpcb(struct inpcb *inp)
* because the socket may be bound to an IPv6 wildcard address,
* which may match an IPv4-mapped IPv6 address.
*/
- inp->inp_ip_ttl = ip_defttl;
+ inp->inp_ip_ttl = V_ip_defttl;
inp->inp_ppcb = tp;
return (tp); /* XXX */
}
@@ -647,15 +648,15 @@ tcp_drop(struct tcpcb *tp, int errno)
{
struct socket *so = tp->t_inpcb->inp_socket;
- INP_INFO_WLOCK_ASSERT(&tcbinfo);
+ INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
INP_WLOCK_ASSERT(tp->t_inpcb);
if (TCPS_HAVERCVDSYN(tp->t_state)) {
tp->t_state = TCPS_CLOSED;
(void) tcp_output_reset(tp);
- tcpstat.tcps_drops++;
+ V_tcpstat.tcps_drops++;
} else
- tcpstat.tcps_conndrops++;
+ V_tcpstat.tcps_conndrops++;
if (errno == ETIMEDOUT && tp->t_softerror)
errno = tp->t_softerror;
so->so_error = errno;
@@ -748,7 +749,7 @@ tcp_discardcb(struct tcpcb *tp)
m_freem(q->tqe_m);
uma_zfree(tcp_reass_zone, q);
tp->t_segqlen--;
- tcp_reass_qsize--;
+ V_tcp_reass_qsize--;
}
/* Disconnect offload device, if any. */
tcp_offload_detach(tp);
@@ -769,14 +770,14 @@ tcp_close(struct tcpcb *tp)
struct inpcb *inp = tp->t_inpcb;
struct socket *so;
- INP_INFO_WLOCK_ASSERT(&tcbinfo);
+ INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
INP_WLOCK_ASSERT(inp);
/* Notify any offload devices of listener close */
if (tp->t_state == TCPS_LISTEN)
tcp_offload_listen_close(tp);
in_pcbdrop(inp);
- tcpstat.tcps_closed++;
+ V_tcpstat.tcps_closed++;
KASSERT(inp->inp_socket != NULL, ("tcp_close: inp_socket NULL"));
so = inp->inp_socket;
soisdisconnected(so);
@@ -811,8 +812,8 @@ tcp_drain(void)
* where we're really low on mbufs, this is potentially
* usefull.
*/
- INP_INFO_RLOCK(&tcbinfo);
- LIST_FOREACH(inpb, tcbinfo.ipi_listhead, inp_list) {
+ INP_INFO_RLOCK(&V_tcbinfo);
+ LIST_FOREACH(inpb, V_tcbinfo.ipi_listhead, inp_list) {
if (inpb->inp_vflag & INP_TIMEWAIT)
continue;
INP_WLOCK(inpb);
@@ -823,13 +824,13 @@ tcp_drain(void)
m_freem(te->tqe_m);
uma_zfree(tcp_reass_zone, te);
tcpb->t_segqlen--;
- tcp_reass_qsize--;
+ V_tcp_reass_qsize--;
}
tcp_clean_sackreport(tcpb);
}
INP_WUNLOCK(inpb);
}
- INP_INFO_RUNLOCK(&tcbinfo);
+ INP_INFO_RUNLOCK(&V_tcbinfo);
}
}
@@ -846,7 +847,7 @@ tcp_notify(struct inpcb *inp, int error)
{
struct tcpcb *tp;
- INP_INFO_WLOCK_ASSERT(&tcbinfo);
+ INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
INP_WLOCK_ASSERT(inp);
if ((inp->inp_vflag & INP_TIMEWAIT) ||
@@ -899,7 +900,7 @@ tcp_pcblist(SYSCTL_HANDLER_ARGS)
*/
if (req->oldptr == NULL) {
m = syncache_pcbcount();
- n = tcbinfo.ipi_count;
+ n = V_tcbinfo.ipi_count;
req->oldidx = 2 * (sizeof xig)
+ ((m + n) + n/8) * sizeof(struct xtcpcb);
return (0);
@@ -911,10 +912,10 @@ tcp_pcblist(SYSCTL_HANDLER_ARGS)
/*
* OK, now we're committed to doing something.
*/
- INP_INFO_RLOCK(&tcbinfo);
- gencnt = tcbinfo.ipi_gencnt;
- n = tcbinfo.ipi_count;
- INP_INFO_RUNLOCK(&tcbinfo);
+ INP_INFO_RLOCK(&V_tcbinfo);
+ gencnt = V_tcbinfo.ipi_gencnt;
+ n = V_tcbinfo.ipi_count;
+ INP_INFO_RUNLOCK(&V_tcbinfo);
m = syncache_pcbcount();
@@ -939,8 +940,8 @@ tcp_pcblist(SYSCTL_HANDLER_ARGS)
if (inp_list == NULL)
return (ENOMEM);
- INP_INFO_RLOCK(&tcbinfo);
- for (inp = LIST_FIRST(tcbinfo.ipi_listhead), i = 0; inp != NULL && i
+ INP_INFO_RLOCK(&V_tcbinfo);
+ for (inp = LIST_FIRST(V_tcbinfo.ipi_listhead), i = 0; inp != NULL && i
< n; inp = LIST_NEXT(inp, inp_list)) {
INP_RLOCK(inp);
if (inp->inp_gencnt <= gencnt) {
@@ -963,7 +964,7 @@ tcp_pcblist(SYSCTL_HANDLER_ARGS)
}
INP_RUNLOCK(inp);
}
- INP_INFO_RUNLOCK(&tcbinfo);
+ INP_INFO_RUNLOCK(&V_tcbinfo);
n = i;
error = 0;
@@ -1007,11 +1008,11 @@ tcp_pcblist(SYSCTL_HANDLER_ARGS)
* while we were processing this request, and it
* might be necessary to retry.
*/
- INP_INFO_RLOCK(&tcbinfo);
- xig.xig_gen = tcbinfo.ipi_gencnt;
+ INP_INFO_RLOCK(&V_tcbinfo);
+ xig.xig_gen = V_tcbinfo.ipi_gencnt;
xig.xig_sogen = so_gencnt;
- xig.xig_count = tcbinfo.ipi_count + pcb_count;
- INP_INFO_RUNLOCK(&tcbinfo);
+ xig.xig_count = V_tcbinfo.ipi_count + pcb_count;
+ INP_INFO_RUNLOCK(&V_tcbinfo);
error = SYSCTL_OUT(req, &xig, sizeof xig);
}
free(inp_list, M_TEMP);
@@ -1035,12 +1036,12 @@ tcp_getcred(SYSCTL_HANDLER_ARGS)
error = SYSCTL_IN(req, addrs, sizeof(addrs));
if (error)
return (error);
- INP_INFO_RLOCK(&tcbinfo);
- inp = in_pcblookup_hash(&tcbinfo, addrs[1].sin_addr, addrs[1].sin_port,
+ INP_INFO_RLOCK(&V_tcbinfo);
+ inp = in_pcblookup_hash(&V_tcbinfo, addrs[1].sin_addr, addrs[1].sin_port,
addrs[0].sin_addr, addrs[0].sin_port, 0, NULL);
if (inp != NULL) {
INP_RLOCK(inp);
- INP_INFO_RUNLOCK(&tcbinfo);
+ INP_INFO_RUNLOCK(&V_tcbinfo);
if (inp->inp_socket == NULL)
error = ENOENT;
if (error == 0)
@@ -1050,7 +1051,7 @@ tcp_getcred(SYSCTL_HANDLER_ARGS)
cru2x(inp->inp_socket->so_cred, &xuc);
INP_RUNLOCK(inp);
} else {
- INP_INFO_RUNLOCK(&tcbinfo);
+ INP_INFO_RUNLOCK(&V_tcbinfo);
error = ENOENT;
}
if (error == 0)
@@ -1077,8 +1078,8 @@ tcp6_getcred(SYSCTL_HANDLER_ARGS)
error = SYSCTL_IN(req, addrs, sizeof(addrs));
if (error)
return (error);
- if ((error = sa6_embedscope(&addrs[0], ip6_use_defzone)) != 0 ||
- (error = sa6_embedscope(&addrs[1], ip6_use_defzone)) != 0) {
+ if ((error = sa6_embedscope(&addrs[0], V_ip6_use_defzone)) != 0 ||
+ (error = sa6_embedscope(&addrs[1], V_ip6_use_defzone)) != 0) {
return (error);
}
if (IN6_IS_ADDR_V4MAPPED(&addrs[0].sin6_addr)) {
@@ -1088,21 +1089,21 @@ tcp6_getcred(SYSCTL_HANDLER_ARGS)
return (EINVAL);
}
- INP_INFO_RLOCK(&tcbinfo);
+ INP_INFO_RLOCK(&V_tcbinfo);
if (mapped == 1)
- inp = in_pcblookup_hash(&tcbinfo,
+ inp = in_pcblookup_hash(&V_tcbinfo,
*(struct in_addr *)&addrs[1].sin6_addr.s6_addr[12],
addrs[1].sin6_port,
*(struct in_addr *)&addrs[0].sin6_addr.s6_addr[12],
addrs[0].sin6_port,
0, NULL);
else
- inp = in6_pcblookup_hash(&tcbinfo,
+ inp = in6_pcblookup_hash(&V_tcbinfo,
&addrs[1].sin6_addr, addrs[1].sin6_port,
&addrs[0].sin6_addr, addrs[0].sin6_port, 0, NULL);
if (inp != NULL) {
INP_RLOCK(inp);
- INP_INFO_RUNLOCK(&tcbinfo);
+ INP_INFO_RUNLOCK(&V_tcbinfo);
if (inp->inp_socket == NULL)
error = ENOENT;
if (error == 0)
@@ -1112,7 +1113,7 @@ tcp6_getcred(SYSCTL_HANDLER_ARGS)
cru2x(inp->inp_socket->so_cred, &xuc);
INP_RUNLOCK(inp);
} else {
- INP_INFO_RUNLOCK(&tcbinfo);
+ INP_INFO_RUNLOCK(&V_tcbinfo);
error = ENOENT;
}
if (error == 0)
@@ -1146,7 +1147,7 @@ tcp_ctlinput(int cmd, struct sockaddr *sa, void *vip)
if (cmd == PRC_MSGSIZE)
notify = tcp_mtudisc;
- else if (icmp_may_rst && (cmd == PRC_UNREACH_ADMIN_PROHIB ||
+ else if (V_icmp_may_rst && (cmd == PRC_UNREACH_ADMIN_PROHIB ||
cmd == PRC_UNREACH_PORT || cmd == PRC_TIMXCEED_INTRANS) && ip)
notify = tcp_drop_syn_sent;
/*
@@ -1173,8 +1174,8 @@ tcp_ctlinput(int cmd, struct sockaddr *sa, void *vip)
- offsetof(struct icmp, icmp_ip));
th = (struct tcphdr *)((caddr_t)ip
+ (ip->ip_hl << 2));
- INP_INFO_WLOCK(&tcbinfo);
- inp = in_pcblookup_hash(&tcbinfo, faddr, th->th_dport,
+ INP_INFO_WLOCK(&V_tcbinfo);
+ inp = in_pcblookup_hash(&V_tcbinfo, faddr, th->th_dport,
ip->ip_src, th->th_sport, 0, NULL);
if (inp != NULL) {
INP_WLOCK(inp);
@@ -1208,11 +1209,11 @@ tcp_ctlinput(int cmd, struct sockaddr *sa, void *vip)
if (!mtu)
mtu = ip_next_mtu(ip->ip_len,
1);
- if (mtu < max(296, (tcp_minmss)
+ if (mtu < max(296, (V_tcp_minmss)
+ sizeof(struct tcpiphdr)))
mtu = 0;
if (!mtu)
- mtu = tcp_mssdflt
+ mtu = V_tcp_mssdflt
+ sizeof(struct tcpiphdr);
/*
* Only cache the the MTU if it
@@ -1239,9 +1240,9 @@ tcp_ctlinput(int cmd, struct sockaddr *sa, void *vip)
#endif
syncache_unreach(&inc, th);
}
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
} else
- in_pcbnotifyall(&tcbinfo, faddr, inetctlerrmap[cmd], notify);
+ in_pcbnotifyall(&V_tcbinfo, faddr, inetctlerrmap[cmd], notify);
}
#ifdef INET6
@@ -1301,7 +1302,7 @@ tcp6_ctlinput(int cmd, struct sockaddr *sa, void *d)
bzero(&th, sizeof(th));
m_copydata(m, off, sizeof(*thp), (caddr_t)&th);
- in6_pcbnotify(&tcbinfo, sa, th.th_dport,
+ in6_pcbnotify(&V_tcbinfo, sa, th.th_dport,
(struct sockaddr *)ip6cp->ip6c_src,
th.th_sport, cmd, NULL, notify);
@@ -1310,11 +1311,11 @@ tcp6_ctlinput(int cmd, struct sockaddr *sa, void *d)
inc.inc6_faddr = ((struct sockaddr_in6 *)sa)->sin6_addr;
inc.inc6_laddr = ip6cp->ip6c_src->sin6_addr;
inc.inc_isipv6 = 1;
- INP_INFO_WLOCK(&tcbinfo);
+ INP_INFO_WLOCK(&V_tcbinfo);
syncache_unreach(&inc, &th);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
} else
- in6_pcbnotify(&tcbinfo, sa, 0, (const struct sockaddr *)sa6_src,
+ in6_pcbnotify(&V_tcbinfo, sa, 0, (const struct sockaddr *)sa6_src,
0, cmd, NULL, notify);
}
#endif /* INET6 */
@@ -1383,37 +1384,37 @@ tcp_new_isn(struct tcpcb *tp)
ISN_LOCK();
/* Seed if this is the first use, reseed if requested. */
- if ((isn_last_reseed == 0) || ((tcp_isn_reseed_interval > 0) &&
- (((u_int)isn_last_reseed + (u_int)tcp_isn_reseed_interval*hz)
+ if ((V_isn_last_reseed == 0) || ((V_tcp_isn_reseed_interval > 0) &&
+ (((u_int)V_isn_last_reseed + (u_int)V_tcp_isn_reseed_interval*hz)
< (u_int)ticks))) {
- read_random(&isn_secret, sizeof(isn_secret));
- isn_last_reseed = ticks;
+ read_random(&V_isn_secret, sizeof(V_isn_secret));
+ V_isn_last_reseed = ticks;
}
/* Compute the md5 hash and return the ISN. */
- MD5Init(&isn_ctx);
- MD5Update(&isn_ctx, (u_char *) &tp->t_inpcb->inp_fport, sizeof(u_short));
- MD5Update(&isn_ctx, (u_char *) &tp->t_inpcb->inp_lport, sizeof(u_short));
+ MD5Init(&V_isn_ctx);
+ MD5Update(&V_isn_ctx, (u_char *) &tp->t_inpcb->inp_fport, sizeof(u_short));
+ MD5Update(&V_isn_ctx, (u_char *) &tp->t_inpcb->inp_lport, sizeof(u_short));
#ifdef INET6
if ((tp->t_inpcb->inp_vflag & INP_IPV6) != 0) {
- MD5Update(&isn_ctx, (u_char *) &tp->t_inpcb->in6p_faddr,
+ MD5Update(&V_isn_ctx, (u_char *) &tp->t_inpcb->in6p_faddr,
sizeof(struct in6_addr));
- MD5Update(&isn_ctx, (u_char *) &tp->t_inpcb->in6p_laddr,
+ MD5Update(&V_isn_ctx, (u_char *) &tp->t_inpcb->in6p_laddr,
sizeof(struct in6_addr));
} else
#endif
{
- MD5Update(&isn_ctx, (u_char *) &tp->t_inpcb->inp_faddr,
+ MD5Update(&V_isn_ctx, (u_char *) &tp->t_inpcb->inp_faddr,
sizeof(struct in_addr));
- MD5Update(&isn_ctx, (u_char *) &tp->t_inpcb->inp_laddr,
+ MD5Update(&V_isn_ctx, (u_char *) &tp->t_inpcb->inp_laddr,
sizeof(struct in_addr));
}
- MD5Update(&isn_ctx, (u_char *) &isn_secret, sizeof(isn_secret));
- MD5Final((u_char *) &md5_buffer, &isn_ctx);
+ MD5Update(&V_isn_ctx, (u_char *) &V_isn_secret, sizeof(V_isn_secret));
+ MD5Final((u_char *) &md5_buffer, &V_isn_ctx);
new_isn = (tcp_seq) md5_buffer[0];
- isn_offset += ISN_STATIC_INCREMENT +
+ V_isn_offset += ISN_STATIC_INCREMENT +
(arc4random() & ISN_RANDOM_INCREMENT);
- new_isn += isn_offset;
+ new_isn += V_isn_offset;
ISN_UNLOCK();
return (new_isn);
}
@@ -1429,12 +1430,12 @@ tcp_isn_tick(void *xtp)
u_int32_t projected_offset;
ISN_LOCK();
- projected_offset = isn_offset_old + ISN_BYTES_PER_SECOND / 100;
+ projected_offset = V_isn_offset_old + ISN_BYTES_PER_SECOND / 100;
- if (SEQ_GT(projected_offset, isn_offset))
- isn_offset = projected_offset;
+ if (SEQ_GT(projected_offset, V_isn_offset))
+ V_isn_offset = projected_offset;
- isn_offset_old = isn_offset;
+ V_isn_offset_old = V_isn_offset;
callout_reset(&isn_callout, hz/100, tcp_isn_tick, NULL);
ISN_UNLOCK();
}
@@ -1449,7 +1450,7 @@ tcp_drop_syn_sent(struct inpcb *inp, int errno)
{
struct tcpcb *tp;
- INP_INFO_WLOCK_ASSERT(&tcbinfo);
+ INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
INP_WLOCK_ASSERT(inp);
if ((inp->inp_vflag & INP_TIMEWAIT) ||
@@ -1509,9 +1510,9 @@ tcp_mtudisc(struct inpcb *inp, int errno)
if (!maxmtu) {
tp->t_maxopd = tp->t_maxseg =
#ifdef INET6
- isipv6 ? tcp_v6mssdflt :
+ isipv6 ? V_tcp_v6mssdflt :
#endif /* INET6 */
- tcp_mssdflt;
+ V_tcp_mssdflt;
return (inp);
}
mss = maxmtu -
@@ -1560,7 +1561,7 @@ tcp_mtudisc(struct inpcb *inp, int errno)
tp->t_maxseg = mss;
- tcpstat.tcps_mturesent++;
+ V_tcpstat.tcps_mturesent++;
tp->t_rtttime = 0;
tp->snd_nxt = tp->snd_una;
tcp_free_sackholes(tp);
@@ -1756,7 +1757,7 @@ tcp_xmit_bandwidth_limit(struct tcpcb *tp, tcp_seq ack_seq)
* If inflight_enable is disabled in the middle of a tcp connection,
* make sure snd_bwnd is effectively disabled.
*/
- if (tcp_inflight_enable == 0 || tp->t_rttlow < tcp_inflight_rttthresh) {
+ if (V_tcp_inflight_enable == 0 || tp->t_rttlow < V_tcp_inflight_rttthresh) {
tp->snd_bwnd = TCP_MAXWIN << TCP_MAX_WINSHIFT;
tp->snd_bandwidth = 0;
return;
@@ -1816,7 +1817,7 @@ tcp_xmit_bandwidth_limit(struct tcpcb *tp, tcp_seq ack_seq)
* no other choice.
*/
#define USERTT ((tp->t_srtt + tp->t_rttbest) / 2)
- bwnd = (int64_t)bw * USERTT / (hz << TCP_RTT_SHIFT) + tcp_inflight_stab * tp->t_maxseg / 10;
+ bwnd = (int64_t)bw * USERTT / (hz << TCP_RTT_SHIFT) + V_tcp_inflight_stab * tp->t_maxseg / 10;
#undef USERTT
if (tcp_inflight_debug > 0) {
@@ -1832,10 +1833,10 @@ tcp_xmit_bandwidth_limit(struct tcpcb *tp, tcp_seq ack_seq)
);
}
}
- if ((long)bwnd < tcp_inflight_min)
- bwnd = tcp_inflight_min;
- if (bwnd > tcp_inflight_max)
- bwnd = tcp_inflight_max;
+ if ((long)bwnd < V_tcp_inflight_min)
+ bwnd = V_tcp_inflight_min;
+ if (bwnd > V_tcp_inflight_max)
+ bwnd = V_tcp_inflight_max;
if ((long)bwnd < tp->t_maxseg * 2)
bwnd = tp->t_maxseg * 2;
tp->snd_bwnd = bwnd;
@@ -2011,10 +2012,10 @@ sysctl_drop(SYSCTL_HANDLER_ARGS)
lin = (struct sockaddr_in *)&addrs[1];
break;
}
- error = sa6_embedscope(fin6, ip6_use_defzone);
+ error = sa6_embedscope(fin6, V_ip6_use_defzone);
if (error)
return (error);
- error = sa6_embedscope(lin6, ip6_use_defzone);
+ error = sa6_embedscope(lin6, V_ip6_use_defzone);
if (error)
return (error);
break;
@@ -2029,16 +2030,16 @@ sysctl_drop(SYSCTL_HANDLER_ARGS)
default:
return (EINVAL);
}
- INP_INFO_WLOCK(&tcbinfo);
+ INP_INFO_WLOCK(&V_tcbinfo);
switch (addrs[0].ss_family) {
#ifdef INET6
case AF_INET6:
- inp = in6_pcblookup_hash(&tcbinfo, &f6, fin6->sin6_port,
+ inp = in6_pcblookup_hash(&V_tcbinfo, &f6, fin6->sin6_port,
&l6, lin6->sin6_port, 0, NULL);
break;
#endif
case AF_INET:
- inp = in_pcblookup_hash(&tcbinfo, fin->sin_addr, fin->sin_port,
+ inp = in_pcblookup_hash(&V_tcbinfo, fin->sin_addr, fin->sin_port,
lin->sin_addr, lin->sin_port, 0, NULL);
break;
}
@@ -2066,7 +2067,7 @@ sysctl_drop(SYSCTL_HANDLER_ARGS)
INP_WUNLOCK(inp);
} else
error = ESRCH;
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
return (error);
}
diff --git a/sys/netinet/tcp_syncache.c b/sys/netinet/tcp_syncache.c
index 3f7a9bc..fd580d2 100644
--- a/sys/netinet/tcp_syncache.c
+++ b/sys/netinet/tcp_syncache.c
@@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/syslog.h>
+#include <sys/vimage.h>
#include <vm/uma.h>
@@ -231,13 +232,13 @@ SYSCTL_INT(_net_inet_tcp_syncache, OID_AUTO, rst_on_sock_fail, CTLFLAG_RW,
static MALLOC_DEFINE(M_SYNCACHE, "syncache", "TCP syncache");
#define SYNCACHE_HASH(inc, mask) \
- ((tcp_syncache.hash_secret ^ \
+ ((V_tcp_syncache.hash_secret ^ \
(inc)->inc_faddr.s_addr ^ \
((inc)->inc_faddr.s_addr >> 16) ^ \
(inc)->inc_fport ^ (inc)->inc_lport) & mask)
#define SYNCACHE_HASH6(inc, mask) \
- ((tcp_syncache.hash_secret ^ \
+ ((V_tcp_syncache.hash_secret ^ \
(inc)->inc6_faddr.s6_addr32[0] ^ \
(inc)->inc6_faddr.s6_addr32[3] ^ \
(inc)->inc_fport ^ (inc)->inc_lport) & mask)
@@ -267,7 +268,7 @@ syncache_free(struct syncache *sc)
mac_syncache_destroy(&sc->sc_label);
#endif
- uma_zfree(tcp_syncache.zone, sc);
+ uma_zfree(V_tcp_syncache.zone, sc);
}
void
@@ -275,47 +276,47 @@ syncache_init(void)
{
int i;
- tcp_syncache.cache_count = 0;
- tcp_syncache.hashsize = TCP_SYNCACHE_HASHSIZE;
- tcp_syncache.bucket_limit = TCP_SYNCACHE_BUCKETLIMIT;
- tcp_syncache.rexmt_limit = SYNCACHE_MAXREXMTS;
- tcp_syncache.hash_secret = arc4random();
+ V_tcp_syncache.cache_count = 0;
+ V_tcp_syncache.hashsize = TCP_SYNCACHE_HASHSIZE;
+ V_tcp_syncache.bucket_limit = TCP_SYNCACHE_BUCKETLIMIT;
+ V_tcp_syncache.rexmt_limit = SYNCACHE_MAXREXMTS;
+ V_tcp_syncache.hash_secret = arc4random();
TUNABLE_INT_FETCH("net.inet.tcp.syncache.hashsize",
- &tcp_syncache.hashsize);
+ &V_tcp_syncache.hashsize);
TUNABLE_INT_FETCH("net.inet.tcp.syncache.bucketlimit",
- &tcp_syncache.bucket_limit);
- if (!powerof2(tcp_syncache.hashsize) || tcp_syncache.hashsize == 0) {
+ &V_tcp_syncache.bucket_limit);
+ if (!powerof2(V_tcp_syncache.hashsize) || V_tcp_syncache.hashsize == 0) {
printf("WARNING: syncache hash size is not a power of 2.\n");
- tcp_syncache.hashsize = TCP_SYNCACHE_HASHSIZE;
+ V_tcp_syncache.hashsize = TCP_SYNCACHE_HASHSIZE;
}
- tcp_syncache.hashmask = tcp_syncache.hashsize - 1;
+ V_tcp_syncache.hashmask = V_tcp_syncache.hashsize - 1;
/* Set limits. */
- tcp_syncache.cache_limit =
- tcp_syncache.hashsize * tcp_syncache.bucket_limit;
+ V_tcp_syncache.cache_limit =
+ V_tcp_syncache.hashsize * V_tcp_syncache.bucket_limit;
TUNABLE_INT_FETCH("net.inet.tcp.syncache.cachelimit",
- &tcp_syncache.cache_limit);
+ &V_tcp_syncache.cache_limit);
/* Allocate the hash table. */
- MALLOC(tcp_syncache.hashbase, struct syncache_head *,
- tcp_syncache.hashsize * sizeof(struct syncache_head),
+ MALLOC(V_tcp_syncache.hashbase, struct syncache_head *,
+ V_tcp_syncache.hashsize * sizeof(struct syncache_head),
M_SYNCACHE, M_WAITOK | M_ZERO);
/* Initialize the hash buckets. */
- for (i = 0; i < tcp_syncache.hashsize; i++) {
- TAILQ_INIT(&tcp_syncache.hashbase[i].sch_bucket);
- mtx_init(&tcp_syncache.hashbase[i].sch_mtx, "tcp_sc_head",
+ for (i = 0; i < V_tcp_syncache.hashsize; i++) {
+ TAILQ_INIT(&V_tcp_syncache.hashbase[i].sch_bucket);
+ mtx_init(&V_tcp_syncache.hashbase[i].sch_mtx, "tcp_sc_head",
NULL, MTX_DEF);
- callout_init_mtx(&tcp_syncache.hashbase[i].sch_timer,
- &tcp_syncache.hashbase[i].sch_mtx, 0);
- tcp_syncache.hashbase[i].sch_length = 0;
+ callout_init_mtx(&V_tcp_syncache.hashbase[i].sch_timer,
+ &V_tcp_syncache.hashbase[i].sch_mtx, 0);
+ V_tcp_syncache.hashbase[i].sch_length = 0;
}
/* Create the syncache entry zone. */
- tcp_syncache.zone = uma_zcreate("syncache", sizeof(struct syncache),
+ V_tcp_syncache.zone = uma_zcreate("syncache", sizeof(struct syncache),
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
- uma_zone_set_max(tcp_syncache.zone, tcp_syncache.cache_limit);
+ uma_zone_set_max(V_tcp_syncache.zone, V_tcp_syncache.cache_limit);
}
/*
@@ -333,12 +334,12 @@ syncache_insert(struct syncache *sc, struct syncache_head *sch)
* Make sure that we don't overflow the per-bucket limit.
* If the bucket is full, toss the oldest element.
*/
- if (sch->sch_length >= tcp_syncache.bucket_limit) {
+ if (sch->sch_length >= V_tcp_syncache.bucket_limit) {
KASSERT(!TAILQ_EMPTY(&sch->sch_bucket),
("sch->sch_length incorrect"));
sc2 = TAILQ_LAST(&sch->sch_bucket, sch_head);
syncache_drop(sc2, sch);
- tcpstat.tcps_sc_bucketoverflow++;
+ V_tcpstat.tcps_sc_bucketoverflow++;
}
/* Put it into the bucket. */
@@ -352,8 +353,8 @@ syncache_insert(struct syncache *sc, struct syncache_head *sch)
SCH_UNLOCK(sch);
- tcp_syncache.cache_count++;
- tcpstat.tcps_sc_added++;
+ V_tcp_syncache.cache_count++;
+ V_tcpstat.tcps_sc_added++;
}
/*
@@ -374,7 +375,7 @@ syncache_drop(struct syncache *sc, struct syncache_head *sch)
sc->sc_tu->tu_syncache_event(TOE_SC_DROP, sc->sc_toepcb);
#endif
syncache_free(sc);
- tcp_syncache.cache_count--;
+ V_tcp_syncache.cache_count--;
}
/*
@@ -430,7 +431,7 @@ syncache_timer(void *xsch)
sch->sch_nextc = sc->sc_rxttime;
continue;
}
- if (sc->sc_rxmits > tcp_syncache.rexmt_limit) {
+ if (sc->sc_rxmits > V_tcp_syncache.rexmt_limit) {
if ((s = tcp_log_addrs(&sc->sc_inc, NULL, NULL, NULL))) {
log(LOG_DEBUG, "%s; %s: Retransmits exhausted, "
"giving up and removing syncache entry\n",
@@ -438,7 +439,7 @@ syncache_timer(void *xsch)
free(s, M_TCPLOG);
}
syncache_drop(sc, sch);
- tcpstat.tcps_sc_stale++;
+ V_tcpstat.tcps_sc_stale++;
continue;
}
if ((s = tcp_log_addrs(&sc->sc_inc, NULL, NULL, NULL))) {
@@ -449,7 +450,7 @@ syncache_timer(void *xsch)
}
(void) syncache_respond(sc);
- tcpstat.tcps_sc_retransmitted++;
+ V_tcpstat.tcps_sc_retransmitted++;
syncache_timeout(sc, sch, 0);
}
if (!TAILQ_EMPTY(&(sch)->sch_bucket))
@@ -469,8 +470,8 @@ syncache_lookup(struct in_conninfo *inc, struct syncache_head **schp)
#ifdef INET6
if (inc->inc_isipv6) {
- sch = &tcp_syncache.hashbase[
- SYNCACHE_HASH6(inc, tcp_syncache.hashmask)];
+ sch = &V_tcp_syncache.hashbase[
+ SYNCACHE_HASH6(inc, V_tcp_syncache.hashmask)];
*schp = sch;
SCH_LOCK(sch);
@@ -483,8 +484,8 @@ syncache_lookup(struct in_conninfo *inc, struct syncache_head **schp)
} else
#endif
{
- sch = &tcp_syncache.hashbase[
- SYNCACHE_HASH(inc, tcp_syncache.hashmask)];
+ sch = &V_tcp_syncache.hashbase[
+ SYNCACHE_HASH(inc, V_tcp_syncache.hashmask)];
*schp = sch;
SCH_LOCK(sch);
@@ -526,7 +527,7 @@ syncache_chkrst(struct in_conninfo *inc, struct tcphdr *th)
if ((s = tcp_log_addrs(inc, th, NULL, NULL)))
log(LOG_DEBUG, "%s; %s: Spurious RST with ACK, SYN or "
"FIN flag set, segment ignored\n", s, __func__);
- tcpstat.tcps_badrst++;
+ V_tcpstat.tcps_badrst++;
goto done;
}
@@ -543,7 +544,7 @@ syncache_chkrst(struct in_conninfo *inc, struct tcphdr *th)
log(LOG_DEBUG, "%s; %s: Spurious RST without matching "
"syncache entry (possibly syncookie only), "
"segment ignored\n", s, __func__);
- tcpstat.tcps_badrst++;
+ V_tcpstat.tcps_badrst++;
goto done;
}
@@ -567,13 +568,13 @@ syncache_chkrst(struct in_conninfo *inc, struct tcphdr *th)
log(LOG_DEBUG, "%s; %s: Our SYN|ACK was rejected, "
"connection attempt aborted by remote endpoint\n",
s, __func__);
- tcpstat.tcps_sc_reset++;
+ V_tcpstat.tcps_sc_reset++;
} else {
if ((s = tcp_log_addrs(inc, th, NULL, NULL)))
log(LOG_DEBUG, "%s; %s: RST with invalid SEQ %u != "
"IRS %u (+WND %u), segment ignored\n",
s, __func__, th->th_seq, sc->sc_irs, sc->sc_wnd);
- tcpstat.tcps_badrst++;
+ V_tcpstat.tcps_badrst++;
}
done:
@@ -592,7 +593,7 @@ syncache_badack(struct in_conninfo *inc)
SCH_LOCK_ASSERT(sch);
if (sc != NULL) {
syncache_drop(sc, sch);
- tcpstat.tcps_sc_badack++;
+ V_tcpstat.tcps_sc_badack++;
}
SCH_UNLOCK(sch);
}
@@ -625,7 +626,7 @@ syncache_unreach(struct in_conninfo *inc, struct tcphdr *th)
goto done;
}
syncache_drop(sc, sch);
- tcpstat.tcps_sc_unreach++;
+ V_tcpstat.tcps_sc_unreach++;
done:
SCH_UNLOCK(sch);
}
@@ -641,7 +642,7 @@ syncache_socket(struct syncache *sc, struct socket *lso, struct mbuf *m)
struct tcpcb *tp;
char *s;
- INP_INFO_WLOCK_ASSERT(&tcbinfo);
+ INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
/*
* Ok, create the full blown connection, and set things up
@@ -656,7 +657,7 @@ syncache_socket(struct syncache *sc, struct socket *lso, struct mbuf *m)
* have the peer retransmit its SYN again after its
* RTO and try again.
*/
- tcpstat.tcps_listendrop++;
+ V_tcpstat.tcps_listendrop++;
if ((s = tcp_log_addrs(&sc->sc_inc, NULL, NULL, NULL))) {
log(LOG_DEBUG, "%s; %s: Socket create failed "
"due to limits or memory shortage\n",
@@ -826,7 +827,7 @@ syncache_socket(struct syncache *sc, struct socket *lso, struct mbuf *m)
INP_WUNLOCK(inp);
- tcpstat.tcps_accepts++;
+ V_tcpstat.tcps_accepts++;
return (so);
abort:
@@ -857,7 +858,7 @@ syncache_expand(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
* Global TCP locks are held because we manipulate the PCB lists
* and create a new socket.
*/
- INP_INFO_WLOCK_ASSERT(&tcbinfo);
+ INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
KASSERT((th->th_flags & (TH_RST|TH_ACK|TH_SYN)) == TH_ACK,
("%s: can handle only ACK", __func__));
@@ -895,7 +896,7 @@ syncache_expand(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
/* Pull out the entry to unlock the bucket row. */
TAILQ_REMOVE(&sch->sch_bucket, sc, sc_hash);
sch->sch_length--;
- tcp_syncache.cache_count--;
+ V_tcp_syncache.cache_count--;
SCH_UNLOCK(sch);
}
@@ -945,9 +946,9 @@ syncache_expand(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
*lsop = syncache_socket(sc, *lsop, m);
if (*lsop == NULL)
- tcpstat.tcps_sc_aborted++;
+ V_tcpstat.tcps_sc_aborted++;
else
- tcpstat.tcps_sc_completed++;
+ V_tcpstat.tcps_sc_completed++;
/* how do we find the inp for the new socket? */
if (sc != &scs)
@@ -968,9 +969,9 @@ tcp_offload_syncache_expand(struct in_conninfo *inc, struct tcpopt *to,
{
int rc;
- INP_INFO_WLOCK(&tcbinfo);
+ INP_INFO_WLOCK(&V_tcbinfo);
rc = syncache_expand(inc, to, th, lsop, m);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
return (rc);
}
@@ -1009,7 +1010,7 @@ _syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
#endif
struct syncache scs;
- INP_INFO_WLOCK_ASSERT(&tcbinfo);
+ INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
INP_WLOCK_ASSERT(inp); /* listen socket */
KASSERT((th->th_flags & (TH_RST|TH_ACK|TH_SYN)) == TH_SYN,
("%s: unexpected tcp flags", __func__));
@@ -1038,13 +1039,13 @@ _syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
#ifdef MAC
if (mac_syncache_init(&maclabel) != 0) {
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
goto done;
} else
mac_syncache_create(maclabel, inp);
#endif
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
/*
* Remember the IP options, if any.
@@ -1074,7 +1075,7 @@ _syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
sc->sc_tu->tu_syncache_event(TOE_SC_ENTRY_PRESENT,
sc->sc_toepcb);
#endif
- tcpstat.tcps_sc_dupsyn++;
+ V_tcpstat.tcps_sc_dupsyn++;
if (ipopts) {
/*
* If we were remembering a previous source route,
@@ -1111,24 +1112,24 @@ _syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
if (!TOEPCB_ISSET(sc) && syncache_respond(sc) == 0) {
sc->sc_rxmits = 0;
syncache_timeout(sc, sch, 1);
- tcpstat.tcps_sndacks++;
- tcpstat.tcps_sndtotal++;
+ V_tcpstat.tcps_sndacks++;
+ V_tcpstat.tcps_sndtotal++;
}
SCH_UNLOCK(sch);
goto done;
}
- sc = uma_zalloc(tcp_syncache.zone, M_NOWAIT | M_ZERO);
+ sc = uma_zalloc(V_tcp_syncache.zone, M_NOWAIT | M_ZERO);
if (sc == NULL) {
/*
* The zone allocator couldn't provide more entries.
* Treat this as if the cache was full; drop the oldest
* entry and insert the new one.
*/
- tcpstat.tcps_sc_zonefail++;
+ V_tcpstat.tcps_sc_zonefail++;
if ((sc = TAILQ_LAST(&sch->sch_bucket, sch_head)) != NULL)
syncache_drop(sc, sch);
- sc = uma_zalloc(tcp_syncache.zone, M_NOWAIT | M_ZERO);
+ sc = uma_zalloc(V_tcp_syncache.zone, M_NOWAIT | M_ZERO);
if (sc == NULL) {
if (tcp_syncookies) {
bzero(&scs, sizeof(scs));
@@ -1175,7 +1176,7 @@ _syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
win = imin(win, TCP_MAXWIN);
sc->sc_wnd = win;
- if (tcp_do_rfc1323) {
+ if (V_tcp_do_rfc1323) {
/*
* A timestamp received in a SYN makes
* it ok to send timestamp requests and replies.
@@ -1234,7 +1235,7 @@ _syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
sc->sc_peer_mss = to->to_mss; /* peer mss may be zero */
if (noopt)
sc->sc_flags |= SCF_NOOPT;
- if ((th->th_flags & (TH_ECE|TH_CWR)) && tcp_do_ecn)
+ if ((th->th_flags & (TH_ECE|TH_CWR)) && V_tcp_do_ecn)
sc->sc_flags |= SCF_ECN;
if (tcp_syncookies) {
@@ -1260,12 +1261,12 @@ _syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
syncache_free(sc);
else if (sc != &scs)
syncache_insert(sc, sch); /* locks and unlocks sch */
- tcpstat.tcps_sndacks++;
- tcpstat.tcps_sndtotal++;
+ V_tcpstat.tcps_sndacks++;
+ V_tcpstat.tcps_sndtotal++;
} else {
if (sc != &scs)
syncache_free(sc);
- tcpstat.tcps_sc_dropped++;
+ V_tcpstat.tcps_sc_dropped++;
}
done:
@@ -1304,7 +1305,7 @@ syncache_respond(struct syncache *sc)
/* Determine MSS we advertize to other end of connection. */
mssopt = tcp_mssopt(&sc->sc_inc);
if (sc->sc_peer_mss)
- mssopt = max( min(sc->sc_peer_mss, mssopt), tcp_minmss);
+ mssopt = max( min(sc->sc_peer_mss, mssopt), V_tcp_minmss);
/* XXX: Assume that the entire packet will fit in a header mbuf. */
KASSERT(max_linkhdr + tlen + TCP_MAXOLEN <= MHLEN,
@@ -1358,7 +1359,7 @@ syncache_respond(struct syncache *sc)
* 1) path_mtu_discovery is disabled
* 2) the SCF_UNREACH flag has been set
*/
- if (path_mtu_discovery && ((sc->sc_flags & SCF_UNREACH) == 0))
+ if (V_path_mtu_discovery && ((sc->sc_flags & SCF_UNREACH) == 0))
ip->ip_off |= IP_DF;
th = (struct tcphdr *)(ip + 1);
@@ -1376,7 +1377,7 @@ syncache_respond(struct syncache *sc)
if (sc->sc_flags & SCF_ECN) {
th->th_flags |= TH_ECE;
- tcpstat.tcps_ecn_shs++;
+ V_tcpstat.tcps_ecn_shs++;
}
/* Tack on the TCP options. */
@@ -1454,7 +1455,7 @@ tcp_offload_syncache_add(struct in_conninfo *inc, struct tcpopt *to,
struct toe_usrreqs *tu, void *toepcb)
{
- INP_INFO_WLOCK(&tcbinfo);
+ INP_INFO_WLOCK(&V_tcbinfo);
INP_WLOCK(inp);
_syncache_add(inc, to, th, inp, lsop, NULL, tu, toepcb);
}
@@ -1568,7 +1569,7 @@ syncookie_generate(struct syncache_head *sch, struct syncache *sc,
off = sc->sc_iss & 0x7; /* iss was randomized before */
/* Maximum segment size calculation. */
- pmss = max( min(sc->sc_peer_mss, tcp_mssopt(&sc->sc_inc)), tcp_minmss);
+ pmss = max( min(sc->sc_peer_mss, tcp_mssopt(&sc->sc_inc)), V_tcp_minmss);
for (mss = sizeof(tcp_sc_msstab) / sizeof(int) - 1; mss > 0; mss--)
if (tcp_sc_msstab[mss] <= pmss)
break;
@@ -1606,7 +1607,7 @@ syncookie_generate(struct syncache_head *sch, struct syncache *sc,
sc->sc_tsoff = data - ticks; /* after XOR */
}
- tcpstat.tcps_sc_sendcookie++;
+ V_tcpstat.tcps_sc_sendcookie++;
return;
}
@@ -1709,7 +1710,7 @@ syncookie_lookup(struct in_conninfo *inc, struct syncache_head *sch,
sc->sc_rxmits = 0;
sc->sc_peer_mss = tcp_sc_msstab[mss];
- tcpstat.tcps_sc_recvcookie++;
+ V_tcpstat.tcps_sc_recvcookie++;
return (sc);
}
@@ -1725,9 +1726,9 @@ syncache_pcbcount(void)
struct syncache_head *sch;
int count, i;
- for (count = 0, i = 0; i < tcp_syncache.hashsize; i++) {
+ for (count = 0, i = 0; i < V_tcp_syncache.hashsize; i++) {
/* No need to lock for a read. */
- sch = &tcp_syncache.hashbase[i];
+ sch = &V_tcp_syncache.hashbase[i];
count += sch->sch_length;
}
return count;
@@ -1750,8 +1751,8 @@ syncache_pcblist(struct sysctl_req *req, int max_pcbs, int *pcbs_exported)
struct syncache_head *sch;
int count, error, i;
- for (count = 0, error = 0, i = 0; i < tcp_syncache.hashsize; i++) {
- sch = &tcp_syncache.hashbase[i];
+ for (count = 0, error = 0, i = 0; i < V_tcp_syncache.hashsize; i++) {
+ sch = &V_tcp_syncache.hashbase[i];
SCH_LOCK(sch);
TAILQ_FOREACH(sc, &sch->sch_bucket, sc_hash) {
if (count >= max_pcbs) {
diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c
index 3cb74e1..db156ec 100644
--- a/sys/netinet/tcp_timer.c
+++ b/sys/netinet/tcp_timer.c
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
#include <sys/socketvar.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
+#include <sys/vimage.h>
#include <net/route.h>
@@ -125,9 +126,9 @@ tcp_slowtimo(void)
{
tcp_maxidle = tcp_keepcnt * tcp_keepintvl;
- INP_INFO_WLOCK(&tcbinfo);
+ INP_INFO_WLOCK(&V_tcbinfo);
(void) tcp_tw_2msl_scan(0);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
}
int tcp_syn_backoff[TCP_MAXRXTSHIFT + 1] =
@@ -152,7 +153,7 @@ tcp_timer_delack(void *xtp)
struct tcpcb *tp = xtp;
struct inpcb *inp;
- INP_INFO_RLOCK(&tcbinfo);
+ INP_INFO_RLOCK(&V_tcbinfo);
inp = tp->t_inpcb;
/*
* XXXRW: While this assert is in fact correct, bugs in the tcpcb
@@ -163,11 +164,11 @@ tcp_timer_delack(void *xtp)
*/
if (inp == NULL) {
tcp_timer_race++;
- INP_INFO_RUNLOCK(&tcbinfo);
+ INP_INFO_RUNLOCK(&V_tcbinfo);
return;
}
INP_WLOCK(inp);
- INP_INFO_RUNLOCK(&tcbinfo);
+ INP_INFO_RUNLOCK(&V_tcbinfo);
if ((inp->inp_vflag & INP_DROPPED) || callout_pending(&tp->t_timers->tt_delack)
|| !callout_active(&tp->t_timers->tt_delack)) {
INP_WUNLOCK(inp);
@@ -176,7 +177,7 @@ tcp_timer_delack(void *xtp)
callout_deactivate(&tp->t_timers->tt_delack);
tp->t_flags |= TF_ACKNOW;
- tcpstat.tcps_delack++;
+ V_tcpstat.tcps_delack++;
(void) tcp_output(tp);
INP_WUNLOCK(inp);
}
@@ -194,7 +195,7 @@ tcp_timer_2msl(void *xtp)
/*
* XXXRW: Does this actually happen?
*/
- INP_INFO_WLOCK(&tcbinfo);
+ INP_INFO_WLOCK(&V_tcbinfo);
inp = tp->t_inpcb;
/*
* XXXRW: While this assert is in fact correct, bugs in the tcpcb
@@ -205,7 +206,7 @@ tcp_timer_2msl(void *xtp)
*/
if (inp == NULL) {
tcp_timer_race++;
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
return;
}
INP_WLOCK(inp);
@@ -213,7 +214,7 @@ tcp_timer_2msl(void *xtp)
if ((inp->inp_vflag & INP_DROPPED) || callout_pending(&tp->t_timers->tt_2msl) ||
!callout_active(&tp->t_timers->tt_2msl)) {
INP_WUNLOCK(tp->t_inpcb);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
return;
}
callout_deactivate(&tp->t_timers->tt_2msl);
@@ -230,7 +231,7 @@ tcp_timer_2msl(void *xtp)
if (tcp_fast_finwait2_recycle && tp->t_state == TCPS_FIN_WAIT_2 &&
tp->t_inpcb && tp->t_inpcb->inp_socket &&
(tp->t_inpcb->inp_socket->so_rcv.sb_state & SBS_CANTRCVMORE)) {
- tcpstat.tcps_finwait2_drops++;
+ V_tcpstat.tcps_finwait2_drops++;
tp = tcp_close(tp);
} else {
if (tp->t_state != TCPS_TIME_WAIT &&
@@ -248,7 +249,7 @@ tcp_timer_2msl(void *xtp)
#endif
if (tp != NULL)
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
}
void
@@ -262,7 +263,7 @@ tcp_timer_keep(void *xtp)
ostate = tp->t_state;
#endif
- INP_INFO_WLOCK(&tcbinfo);
+ INP_INFO_WLOCK(&V_tcbinfo);
inp = tp->t_inpcb;
/*
* XXXRW: While this assert is in fact correct, bugs in the tcpcb
@@ -273,14 +274,14 @@ tcp_timer_keep(void *xtp)
*/
if (inp == NULL) {
tcp_timer_race++;
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
return;
}
INP_WLOCK(inp);
if ((inp->inp_vflag & INP_DROPPED) || callout_pending(&tp->t_timers->tt_keep)
|| !callout_active(&tp->t_timers->tt_keep)) {
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
return;
}
callout_deactivate(&tp->t_timers->tt_keep);
@@ -288,7 +289,7 @@ tcp_timer_keep(void *xtp)
* Keep-alive timer went off; send something
* or drop connection if idle for too long.
*/
- tcpstat.tcps_keeptimeo++;
+ V_tcpstat.tcps_keeptimeo++;
if (tp->t_state < TCPS_ESTABLISHED)
goto dropit;
if ((always_keepalive || inp->inp_socket->so_options & SO_KEEPALIVE) &&
@@ -307,7 +308,7 @@ tcp_timer_keep(void *xtp)
* by the protocol spec, this requires the
* correspondent TCP to respond.
*/
- tcpstat.tcps_keepprobe++;
+ V_tcpstat.tcps_keepprobe++;
t_template = tcpip_maketemplate(inp);
if (t_template) {
tcp_respond(tp, t_template->tt_ipgen,
@@ -325,11 +326,11 @@ tcp_timer_keep(void *xtp)
PRU_SLOWTIMO);
#endif
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
return;
dropit:
- tcpstat.tcps_keepdrops++;
+ V_tcpstat.tcps_keepdrops++;
tp = tcp_drop(tp, ETIMEDOUT);
#ifdef TCPDEBUG
@@ -339,7 +340,7 @@ dropit:
#endif
if (tp != NULL)
INP_WUNLOCK(tp->t_inpcb);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
}
void
@@ -352,7 +353,7 @@ tcp_timer_persist(void *xtp)
ostate = tp->t_state;
#endif
- INP_INFO_WLOCK(&tcbinfo);
+ INP_INFO_WLOCK(&V_tcbinfo);
inp = tp->t_inpcb;
/*
* XXXRW: While this assert is in fact correct, bugs in the tcpcb
@@ -363,14 +364,14 @@ tcp_timer_persist(void *xtp)
*/
if (inp == NULL) {
tcp_timer_race++;
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
return;
}
INP_WLOCK(inp);
if ((inp->inp_vflag & INP_DROPPED) || callout_pending(&tp->t_timers->tt_persist)
|| !callout_active(&tp->t_timers->tt_persist)) {
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
return;
}
callout_deactivate(&tp->t_timers->tt_persist);
@@ -378,7 +379,7 @@ tcp_timer_persist(void *xtp)
* Persistance timer into zero window.
* Force a byte to be output, if possible.
*/
- tcpstat.tcps_persisttimeo++;
+ V_tcpstat.tcps_persisttimeo++;
/*
* Hack: if the peer is dead/unreachable, we do not
* time out if the window is closed. After a full
@@ -389,7 +390,7 @@ tcp_timer_persist(void *xtp)
if (tp->t_rxtshift == TCP_MAXRXTSHIFT &&
((ticks - tp->t_rcvtime) >= tcp_maxpersistidle ||
(ticks - tp->t_rcvtime) >= TCP_REXMTVAL(tp) * tcp_totbackoff)) {
- tcpstat.tcps_persistdrop++;
+ V_tcpstat.tcps_persistdrop++;
tp = tcp_drop(tp, ETIMEDOUT);
goto out;
}
@@ -405,7 +406,7 @@ out:
#endif
if (tp != NULL)
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
}
void
@@ -420,7 +421,7 @@ tcp_timer_rexmt(void * xtp)
ostate = tp->t_state;
#endif
- INP_INFO_WLOCK(&tcbinfo);
+ INP_INFO_WLOCK(&V_tcbinfo);
headlocked = 1;
inp = tp->t_inpcb;
/*
@@ -432,14 +433,14 @@ tcp_timer_rexmt(void * xtp)
*/
if (inp == NULL) {
tcp_timer_race++;
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
return;
}
INP_WLOCK(inp);
if ((inp->inp_vflag & INP_DROPPED) || callout_pending(&tp->t_timers->tt_rexmt)
|| !callout_active(&tp->t_timers->tt_rexmt)) {
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
return;
}
callout_deactivate(&tp->t_timers->tt_rexmt);
@@ -451,12 +452,12 @@ tcp_timer_rexmt(void * xtp)
*/
if (++tp->t_rxtshift > TCP_MAXRXTSHIFT) {
tp->t_rxtshift = TCP_MAXRXTSHIFT;
- tcpstat.tcps_timeoutdrop++;
+ V_tcpstat.tcps_timeoutdrop++;
tp = tcp_drop(tp, tp->t_softerror ?
tp->t_softerror : ETIMEDOUT);
goto out;
}
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
headlocked = 0;
if (tp->t_rxtshift == 1) {
/*
@@ -477,7 +478,7 @@ tcp_timer_rexmt(void * xtp)
tp->t_flags &= ~TF_WASFRECOVERY;
tp->t_badrxtwin = ticks + (tp->t_srtt >> (TCP_RTT_SHIFT + 1));
}
- tcpstat.tcps_rexmttimeo++;
+ V_tcpstat.tcps_rexmttimeo++;
if (tp->t_state == TCPS_SYN_SENT)
rexmt = TCP_REXMTVAL(tp) * tcp_syn_backoff[tp->t_rxtshift];
else
@@ -562,7 +563,7 @@ out:
if (tp != NULL)
INP_WUNLOCK(inp);
if (headlocked)
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
}
void
diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c
index 9d4b6e2..75d61e7 100644
--- a/sys/netinet/tcp_timewait.c
+++ b/sys/netinet/tcp_timewait.c
@@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$");
#include <sys/socketvar.h>
#include <sys/protosw.h>
#include <sys/random.h>
+#include <sys/vimage.h>
#include <vm/uma.h>
@@ -115,10 +116,10 @@ tcptw_auto_size(void)
* Max out at half the ephemeral port range so that TIME_WAIT
* sockets don't tie up too many ephemeral ports.
*/
- if (ipport_lastauto > ipport_firstauto)
- halfrange = (ipport_lastauto - ipport_firstauto) / 2;
+ if (V_ipport_lastauto > V_ipport_firstauto)
+ halfrange = (V_ipport_lastauto - V_ipport_firstauto) / 2;
else
- halfrange = (ipport_firstauto - ipport_lastauto) / 2;
+ halfrange = (V_ipport_firstauto - V_ipport_lastauto) / 2;
/* Protect against goofy port ranges smaller than 32. */
return (imin(imax(halfrange, 32), maxsockets / 5));
}
@@ -169,7 +170,7 @@ tcp_tw_init(void)
uma_zone_set_max(tcptw_zone, tcptw_auto_size());
else
uma_zone_set_max(tcptw_zone, maxtcptw);
- TAILQ_INIT(&twq_2msl);
+ TAILQ_INIT(&V_twq_2msl);
}
/*
@@ -185,10 +186,10 @@ tcp_twstart(struct tcpcb *tp)
int acknow;
struct socket *so;
- INP_INFO_WLOCK_ASSERT(&tcbinfo); /* tcp_tw_2msl_reset(). */
+ INP_INFO_WLOCK_ASSERT(&V_tcbinfo); /* tcp_tw_2msl_reset(). */
INP_WLOCK_ASSERT(inp);
- if (nolocaltimewait && in_localip(inp->inp_faddr)) {
+ if (V_nolocaltimewait && in_localip(inp->inp_faddr)) {
tp = tcp_close(tp);
if (tp != NULL)
INP_WUNLOCK(inp);
@@ -298,7 +299,7 @@ tcp_twrecycleable(struct tcptw *tw)
tcp_seq new_iss = tw->iss;
tcp_seq new_irs = tw->irs;
- INP_INFO_WLOCK_ASSERT(&tcbinfo);
+ INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
new_iss += (ticks - tw->t_starttime) * (ISN_BYTES_PER_SECOND / hz);
new_irs += (ticks - tw->t_starttime) * (MS_ISN_BYTES_PER_SECOND / hz);
@@ -327,7 +328,7 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to, struct tcphdr *th,
#endif
/* tcbinfo lock required for tcp_twclose(), tcp_tw_2msl_reset(). */
- INP_INFO_WLOCK_ASSERT(&tcbinfo);
+ INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
INP_WLOCK_ASSERT(inp);
/*
@@ -468,7 +469,7 @@ tcp_twclose(struct tcptw *tw, int reuse)
inp = tw->tw_inpcb;
KASSERT((inp->inp_vflag & INP_TIMEWAIT), ("tcp_twclose: !timewait"));
KASSERT(intotw(inp) == tw, ("tcp_twclose: inp_ppcb != tw"));
- INP_INFO_WLOCK_ASSERT(&tcbinfo); /* tcp_tw_2msl_stop(). */
+ INP_INFO_WLOCK_ASSERT(&V_tcbinfo); /* tcp_tw_2msl_stop(). */
INP_WLOCK_ASSERT(inp);
tw->tw_inpcb = NULL;
@@ -509,7 +510,7 @@ tcp_twclose(struct tcptw *tw, int reuse)
#endif
in_pcbfree(inp);
}
- tcpstat.tcps_closed++;
+ V_tcpstat.tcps_closed++;
crfree(tw->tw_cred);
tw->tw_cred = NULL;
if (reuse)
@@ -596,17 +597,17 @@ tcp_twrespond(struct tcptw *tw, int flags)
m->m_pkthdr.csum_flags = CSUM_TCP;
m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum);
ip->ip_len = m->m_pkthdr.len;
- if (path_mtu_discovery)
+ if (V_path_mtu_discovery)
ip->ip_off |= IP_DF;
error = ip_output(m, inp->inp_options, NULL,
((tw->tw_so_options & SO_DONTROUTE) ? IP_ROUTETOIF : 0),
NULL, inp);
}
if (flags & TH_ACK)
- tcpstat.tcps_sndacks++;
+ V_tcpstat.tcps_sndacks++;
else
- tcpstat.tcps_sndctrl++;
- tcpstat.tcps_sndtotal++;
+ V_tcpstat.tcps_sndctrl++;
+ V_tcpstat.tcps_sndtotal++;
return (error);
}
@@ -614,20 +615,20 @@ static void
tcp_tw_2msl_reset(struct tcptw *tw, int rearm)
{
- INP_INFO_WLOCK_ASSERT(&tcbinfo);
+ INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
INP_WLOCK_ASSERT(tw->tw_inpcb);
if (rearm)
- TAILQ_REMOVE(&twq_2msl, tw, tw_2msl);
+ TAILQ_REMOVE(&V_twq_2msl, tw, tw_2msl);
tw->tw_time = ticks + 2 * tcp_msl;
- TAILQ_INSERT_TAIL(&twq_2msl, tw, tw_2msl);
+ TAILQ_INSERT_TAIL(&V_twq_2msl, tw, tw_2msl);
}
static void
tcp_tw_2msl_stop(struct tcptw *tw)
{
- INP_INFO_WLOCK_ASSERT(&tcbinfo);
- TAILQ_REMOVE(&twq_2msl, tw, tw_2msl);
+ INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
+ TAILQ_REMOVE(&V_twq_2msl, tw, tw_2msl);
}
struct tcptw *
@@ -635,9 +636,9 @@ tcp_tw_2msl_scan(int reuse)
{
struct tcptw *tw;
- INP_INFO_WLOCK_ASSERT(&tcbinfo);
+ INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
for (;;) {
- tw = TAILQ_FIRST(&twq_2msl);
+ tw = TAILQ_FIRST(&V_twq_2msl);
if (tw == NULL || (!reuse && tw->tw_time > ticks))
break;
INP_WLOCK(tw->tw_inpcb);
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index 4a31e2b..6a19ad0 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
#include <sys/protosw.h>
#include <sys/proc.h>
#include <sys/jail.h>
+#include <sys/vimage.h>
#ifdef DDB
#include <ddb/ddb.h>
@@ -159,7 +160,7 @@ tcp_detach(struct socket *so, struct inpcb *inp)
int isipv6 = INP_CHECK_SOCKAF(so, AF_INET6) != 0;
#endif
- INP_INFO_WLOCK_ASSERT(&tcbinfo);
+ INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
INP_WLOCK_ASSERT(inp);
KASSERT(so->so_pcb == inp, ("tcp_detach: so_pcb != inp"));
@@ -252,12 +253,12 @@ tcp_usr_detach(struct socket *so)
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("tcp_usr_detach: inp == NULL"));
- INP_INFO_WLOCK(&tcbinfo);
+ INP_INFO_WLOCK(&V_tcbinfo);
INP_WLOCK(inp);
KASSERT(inp->inp_socket != NULL,
("tcp_usr_detach: inp_socket == NULL"));
tcp_detach(so, inp);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
}
/*
@@ -283,7 +284,7 @@ tcp_usr_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
return (EAFNOSUPPORT);
TCPDEBUG0;
- INP_INFO_WLOCK(&tcbinfo);
+ INP_INFO_WLOCK(&V_tcbinfo);
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("tcp_usr_bind: inp == NULL"));
INP_WLOCK(inp);
@@ -297,7 +298,7 @@ tcp_usr_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
out:
TCPDEBUG2(PRU_BIND);
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
return (error);
}
@@ -323,7 +324,7 @@ tcp6_usr_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
return (EAFNOSUPPORT);
TCPDEBUG0;
- INP_INFO_WLOCK(&tcbinfo);
+ INP_INFO_WLOCK(&V_tcbinfo);
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("tcp6_usr_bind: inp == NULL"));
INP_WLOCK(inp);
@@ -353,7 +354,7 @@ tcp6_usr_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
out:
TCPDEBUG2(PRU_BIND);
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
return (error);
}
#endif /* INET6 */
@@ -369,7 +370,7 @@ tcp_usr_listen(struct socket *so, int backlog, struct thread *td)
struct tcpcb *tp = NULL;
TCPDEBUG0;
- INP_INFO_WLOCK(&tcbinfo);
+ INP_INFO_WLOCK(&V_tcbinfo);
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("tcp_usr_listen: inp == NULL"));
INP_WLOCK(inp);
@@ -393,7 +394,7 @@ tcp_usr_listen(struct socket *so, int backlog, struct thread *td)
out:
TCPDEBUG2(PRU_LISTEN);
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
return (error);
}
@@ -406,7 +407,7 @@ tcp6_usr_listen(struct socket *so, int backlog, struct thread *td)
struct tcpcb *tp = NULL;
TCPDEBUG0;
- INP_INFO_WLOCK(&tcbinfo);
+ INP_INFO_WLOCK(&V_tcbinfo);
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("tcp6_usr_listen: inp == NULL"));
INP_WLOCK(inp);
@@ -433,7 +434,7 @@ tcp6_usr_listen(struct socket *so, int backlog, struct thread *td)
out:
TCPDEBUG2(PRU_LISTEN);
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
return (error);
}
#endif /* INET6 */
@@ -466,7 +467,7 @@ tcp_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
prison_remote_ip(td->td_ucred, 0, &sinp->sin_addr.s_addr);
TCPDEBUG0;
- INP_INFO_WLOCK(&tcbinfo);
+ INP_INFO_WLOCK(&V_tcbinfo);
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("tcp_usr_connect: inp == NULL"));
INP_WLOCK(inp);
@@ -482,7 +483,7 @@ tcp_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
out:
TCPDEBUG2(PRU_CONNECT);
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
return (error);
}
@@ -507,7 +508,7 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
&& IN6_IS_ADDR_MULTICAST(&sin6p->sin6_addr))
return (EAFNOSUPPORT);
- INP_INFO_WLOCK(&tcbinfo);
+ INP_INFO_WLOCK(&V_tcbinfo);
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("tcp6_usr_connect: inp == NULL"));
INP_WLOCK(inp);
@@ -543,7 +544,7 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
out:
TCPDEBUG2(PRU_CONNECT);
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
return (error);
}
#endif /* INET6 */
@@ -567,7 +568,7 @@ tcp_usr_disconnect(struct socket *so)
int error = 0;
TCPDEBUG0;
- INP_INFO_WLOCK(&tcbinfo);
+ INP_INFO_WLOCK(&V_tcbinfo);
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("tcp_usr_disconnect: inp == NULL"));
INP_WLOCK(inp);
@@ -581,7 +582,7 @@ tcp_usr_disconnect(struct socket *so)
out:
TCPDEBUG2(PRU_DISCONNECT);
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
return (error);
}
@@ -605,7 +606,7 @@ tcp_usr_accept(struct socket *so, struct sockaddr **nam)
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("tcp_usr_accept: inp == NULL"));
- INP_INFO_RLOCK(&tcbinfo);
+ INP_INFO_RLOCK(&V_tcbinfo);
INP_WLOCK(inp);
if (inp->inp_vflag & (INP_TIMEWAIT | INP_DROPPED)) {
error = ECONNABORTED;
@@ -625,7 +626,7 @@ tcp_usr_accept(struct socket *so, struct sockaddr **nam)
out:
TCPDEBUG2(PRU_ACCEPT);
INP_WUNLOCK(inp);
- INP_INFO_RUNLOCK(&tcbinfo);
+ INP_INFO_RUNLOCK(&V_tcbinfo);
if (error == 0)
*nam = in_sockaddr(port, &addr);
return error;
@@ -695,7 +696,7 @@ tcp_usr_shutdown(struct socket *so)
struct tcpcb *tp = NULL;
TCPDEBUG0;
- INP_INFO_WLOCK(&tcbinfo);
+ INP_INFO_WLOCK(&V_tcbinfo);
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("inp == NULL"));
INP_WLOCK(inp);
@@ -712,7 +713,7 @@ tcp_usr_shutdown(struct socket *so)
out:
TCPDEBUG2(PRU_SHUTDOWN);
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
return (error);
}
@@ -775,7 +776,7 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m,
* (2) PRUS_EOF is set, resulting in explicit close on the send.
*/
if ((nam != NULL) || (flags & PRUS_EOF)) {
- INP_INFO_WLOCK(&tcbinfo);
+ INP_INFO_WLOCK(&V_tcbinfo);
headlocked = 1;
}
inp = sotoinpcb(so);
@@ -814,7 +815,7 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m,
* initialize maxseg/maxopd using peer's cached
* MSS.
*/
- INP_INFO_WLOCK_ASSERT(&tcbinfo);
+ INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
#ifdef INET6
if (isipv6)
error = tcp6_connect(tp, nam, td);
@@ -831,12 +832,12 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m,
* Close the send side of the connection after
* the data is sent.
*/
- INP_INFO_WLOCK_ASSERT(&tcbinfo);
+ INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
socantsendmore(so);
tcp_usrclosed(tp);
}
if (headlocked) {
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
headlocked = 0;
}
if (tp != NULL) {
@@ -874,7 +875,7 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m,
* initialize maxseg/maxopd using peer's cached
* MSS.
*/
- INP_INFO_WLOCK_ASSERT(&tcbinfo);
+ INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
#ifdef INET6
if (isipv6)
error = tcp6_connect(tp, nam, td);
@@ -885,10 +886,10 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m,
goto out;
tp->snd_wnd = TTCP_CLIENT_SND_WND;
tcp_mss(tp, -1);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
headlocked = 0;
} else if (nam) {
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
headlocked = 0;
}
tp->snd_up = tp->snd_una + so->so_snd.sb_cc;
@@ -901,7 +902,7 @@ out:
((flags & PRUS_EOF) ? PRU_SEND_EOF : PRU_SEND));
INP_WUNLOCK(inp);
if (headlocked)
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
return (error);
}
@@ -918,7 +919,7 @@ tcp_usr_abort(struct socket *so)
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("tcp_usr_abort: inp == NULL"));
- INP_INFO_WLOCK(&tcbinfo);
+ INP_INFO_WLOCK(&V_tcbinfo);
INP_WLOCK(inp);
KASSERT(inp->inp_socket != NULL,
("tcp_usr_abort: inp_socket == NULL"));
@@ -940,7 +941,7 @@ tcp_usr_abort(struct socket *so)
inp->inp_vflag |= INP_SOCKREF;
}
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
}
/*
@@ -956,7 +957,7 @@ tcp_usr_close(struct socket *so)
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("tcp_usr_close: inp == NULL"));
- INP_INFO_WLOCK(&tcbinfo);
+ INP_INFO_WLOCK(&V_tcbinfo);
INP_WLOCK(inp);
KASSERT(inp->inp_socket != NULL,
("tcp_usr_close: inp_socket == NULL"));
@@ -979,7 +980,7 @@ tcp_usr_close(struct socket *so)
inp->inp_vflag |= INP_SOCKREF;
}
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
}
/*
@@ -1085,7 +1086,7 @@ tcp_connect(struct tcpcb *tp, struct sockaddr *nam, struct thread *td)
u_short lport;
int error;
- INP_INFO_WLOCK_ASSERT(&tcbinfo);
+ INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
INP_WLOCK_ASSERT(inp);
if (inp->inp_lport == 0) {
@@ -1120,7 +1121,7 @@ tcp_connect(struct tcpcb *tp, struct sockaddr *nam, struct thread *td)
tp->request_r_scale++;
soisconnecting(so);
- tcpstat.tcps_connattempt++;
+ V_tcpstat.tcps_connattempt++;
tp->t_state = TCPS_SYN_SENT;
tcp_timer_activate(tp, TT_KEEP, tcp_keepinit);
tp->iss = tcp_new_isn(tp);
@@ -1140,7 +1141,7 @@ tcp6_connect(struct tcpcb *tp, struct sockaddr *nam, struct thread *td)
struct in6_addr *addr6;
int error;
- INP_INFO_WLOCK_ASSERT(&tcbinfo);
+ INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
INP_WLOCK_ASSERT(inp);
if (inp->inp_lport == 0) {
@@ -1183,7 +1184,7 @@ tcp6_connect(struct tcpcb *tp, struct sockaddr *nam, struct thread *td)
tp->request_r_scale++;
soisconnecting(so);
- tcpstat.tcps_connattempt++;
+ V_tcpstat.tcps_connattempt++;
tp->t_state = TCPS_SYN_SENT;
tcp_timer_activate(tp, TT_KEEP, tcp_keepinit);
tp->iss = tcp_new_isn(tp);
@@ -1358,7 +1359,7 @@ tcp_ctloutput(struct socket *so, struct sockopt *sopt)
INP_WLOCK_RECHECK(inp);
if (optval > 0 && optval <= tp->t_maxseg &&
- optval + 40 >= tcp_minmss)
+ optval + 40 >= V_tcp_minmss)
tp->t_maxseg = optval;
else
error = EINVAL;
@@ -1458,10 +1459,10 @@ tcp_attach(struct socket *so)
}
so->so_rcv.sb_flags |= SB_AUTOSIZE;
so->so_snd.sb_flags |= SB_AUTOSIZE;
- INP_INFO_WLOCK(&tcbinfo);
- error = in_pcballoc(so, &tcbinfo);
+ INP_INFO_WLOCK(&V_tcbinfo);
+ error = in_pcballoc(so, &V_tcbinfo);
if (error) {
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
return (error);
}
inp = sotoinpcb(so);
@@ -1486,12 +1487,12 @@ tcp_attach(struct socket *so)
#ifdef INET6
}
#endif
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
return (ENOBUFS);
}
tp->t_state = TCPS_CLOSED;
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&tcbinfo);
+ INP_INFO_WUNLOCK(&V_tcbinfo);
return (0);
}
@@ -1509,7 +1510,7 @@ tcp_disconnect(struct tcpcb *tp)
struct inpcb *inp = tp->t_inpcb;
struct socket *so = inp->inp_socket;
- INP_INFO_WLOCK_ASSERT(&tcbinfo);
+ INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
INP_WLOCK_ASSERT(inp);
/*
@@ -1547,7 +1548,7 @@ static void
tcp_usrclosed(struct tcpcb *tp)
{
- INP_INFO_WLOCK_ASSERT(&tcbinfo);
+ INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
INP_WLOCK_ASSERT(tp->t_inpcb);
switch (tp->t_state) {
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index c9cf5d4..d864b83 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sysctl.h>
#include <sys/syslog.h>
#include <sys/systm.h>
+#include <sys/vimage.h>
#include <vm/uma.h>
@@ -147,7 +148,7 @@ static void
udp_zone_change(void *tag)
{
- uma_zone_set_max(udbinfo.ipi_zone, maxsockets);
+ uma_zone_set_max(V_udbinfo.ipi_zone, maxsockets);
}
static int
@@ -164,16 +165,16 @@ void
udp_init(void)
{
- INP_INFO_LOCK_INIT(&udbinfo, "udp");
- LIST_INIT(&udb);
- udbinfo.ipi_listhead = &udb;
- udbinfo.ipi_hashbase = hashinit(UDBHASHSIZE, M_PCB,
- &udbinfo.ipi_hashmask);
- udbinfo.ipi_porthashbase = hashinit(UDBHASHSIZE, M_PCB,
- &udbinfo.ipi_porthashmask);
- udbinfo.ipi_zone = uma_zcreate("udpcb", sizeof(struct inpcb), NULL,
+ INP_INFO_LOCK_INIT(&V_udbinfo, "udp");
+ LIST_INIT(&V_udb);
+ V_udbinfo.ipi_listhead = &udb;
+ V_udbinfo.ipi_hashbase = hashinit(UDBHASHSIZE, M_PCB,
+ &V_udbinfo.ipi_hashmask);
+ V_udbinfo.ipi_porthashbase = hashinit(UDBHASHSIZE, M_PCB,
+ &V_udbinfo.ipi_porthashmask);
+ V_udbinfo.ipi_zone = uma_zcreate("udpcb", sizeof(struct inpcb), NULL,
NULL, udp_inpcb_init, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE);
- uma_zone_set_max(udbinfo.ipi_zone, maxsockets);
+ uma_zone_set_max(V_udbinfo.ipi_zone, maxsockets);
EVENTHANDLER_REGISTER(maxsockets_change, udp_zone_change, NULL,
EVENTHANDLER_PRI_ANY);
}
@@ -202,7 +203,7 @@ udp_append(struct inpcb *inp, struct ip *ip, struct mbuf *n, int off,
/* Check AH/ESP integrity. */
if (ipsec4_in_reject(n, inp)) {
m_freem(n);
- ipsec4stat.in_polvio++;
+ V_ipsec4stat.in_polvio++;
return;
}
#endif /* IPSEC */
@@ -240,7 +241,7 @@ udp_append(struct inpcb *inp, struct ip *ip, struct mbuf *n, int off,
m_freem(n);
if (opts)
m_freem(opts);
- udpstat.udps_fullsock++;
+ V_udpstat.udps_fullsock++;
} else
sorwakeup_locked(so);
}
@@ -261,7 +262,7 @@ udp_input(struct mbuf *m, int off)
#endif
ifp = m->m_pkthdr.rcvif;
- udpstat.udps_ipackets++;
+ V_udpstat.udps_ipackets++;
/*
* Strip IP options, if any; should skip this, make available to
@@ -279,7 +280,7 @@ udp_input(struct mbuf *m, int off)
ip = mtod(m, struct ip *);
if (m->m_len < iphlen + sizeof(struct udphdr)) {
if ((m = m_pullup(m, iphlen + sizeof(struct udphdr))) == 0) {
- udpstat.udps_hdrops++;
+ V_udpstat.udps_hdrops++;
return;
}
ip = mtod(m, struct ip *);
@@ -309,7 +310,7 @@ udp_input(struct mbuf *m, int off)
len = ntohs((u_short)uh->uh_ulen);
if (ip->ip_len != len) {
if (len > ip->ip_len || len < sizeof(struct udphdr)) {
- udpstat.udps_badlen++;
+ V_udpstat.udps_badlen++;
goto badunlocked;
}
m_adj(m, len - ip->ip_len);
@@ -320,7 +321,7 @@ udp_input(struct mbuf *m, int off)
* Save a copy of the IP header in case we want restore it for
* sending an ICMP error message in response.
*/
- if (!udp_blackhole)
+ if (!V_udp_blackhole)
save_ip = *ip;
else
memset(&save_ip, 0, sizeof(save_ip));
@@ -349,12 +350,12 @@ udp_input(struct mbuf *m, int off)
bcopy(b, ((struct ipovly *)ip)->ih_x1, 9);
}
if (uh_sum) {
- udpstat.udps_badsum++;
+ V_udpstat.udps_badsum++;
m_freem(m);
return;
}
} else
- udpstat.udps_nosum++;
+ V_udpstat.udps_nosum++;
#ifdef IPFIREWALL_FORWARD
/*
@@ -378,14 +379,14 @@ udp_input(struct mbuf *m, int off)
}
#endif
- INP_INFO_RLOCK(&udbinfo);
+ INP_INFO_RLOCK(&V_udbinfo);
if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) ||
in_broadcast(ip->ip_dst, ifp)) {
struct inpcb *last;
struct ip_moptions *imo;
last = NULL;
- LIST_FOREACH(inp, &udb, inp_list) {
+ LIST_FOREACH(inp, &V_udb, inp_list) {
if (inp->inp_lport != uh->uh_dport)
continue;
#ifdef INET6
@@ -460,7 +461,7 @@ udp_input(struct mbuf *m, int off)
__func__);
}
#endif
- udpstat.udps_filtermcast++;
+ V_udpstat.udps_filtermcast++;
blocked++;
}
}
@@ -498,20 +499,20 @@ udp_input(struct mbuf *m, int off)
* to send an ICMP Port Unreachable for a broadcast
* or multicast datgram.)
*/
- udpstat.udps_noportbcast++;
+ V_udpstat.udps_noportbcast++;
goto badheadlocked;
}
udp_append(last, ip, m, iphlen + sizeof(struct udphdr),
&udp_in);
INP_RUNLOCK(last);
- INP_INFO_RUNLOCK(&udbinfo);
+ INP_INFO_RUNLOCK(&V_udbinfo);
return;
}
/*
* Locate pcb for datagram.
*/
- inp = in_pcblookup_hash(&udbinfo, ip->ip_src, uh->uh_sport,
+ inp = in_pcblookup_hash(&V_udbinfo, ip->ip_src, uh->uh_sport,
ip->ip_dst, uh->uh_dport, 1, ifp);
if (inp == NULL) {
if (udp_log_in_vain) {
@@ -523,19 +524,19 @@ udp_input(struct mbuf *m, int off)
buf, ntohs(uh->uh_dport), inet_ntoa(ip->ip_src),
ntohs(uh->uh_sport));
}
- udpstat.udps_noport++;
+ V_udpstat.udps_noport++;
if (m->m_flags & (M_BCAST | M_MCAST)) {
- udpstat.udps_noportbcast++;
+ V_udpstat.udps_noportbcast++;
goto badheadlocked;
}
- if (udp_blackhole)
+ if (V_udp_blackhole)
goto badheadlocked;
if (badport_bandlim(BANDLIM_ICMP_UNREACH) < 0)
goto badheadlocked;
*ip = save_ip;
ip->ip_len += iphlen;
icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_PORT, 0, 0);
- INP_INFO_RUNLOCK(&udbinfo);
+ INP_INFO_RUNLOCK(&V_udbinfo);
return;
}
@@ -543,7 +544,7 @@ udp_input(struct mbuf *m, int off)
* Check the minimum TTL for socket.
*/
INP_RLOCK(inp);
- INP_INFO_RUNLOCK(&udbinfo);
+ INP_INFO_RUNLOCK(&V_udbinfo);
if (inp->inp_ip_minttl && inp->inp_ip_minttl > ip->ip_ttl) {
INP_RUNLOCK(inp);
goto badunlocked;
@@ -555,7 +556,7 @@ udp_input(struct mbuf *m, int off)
badheadlocked:
if (inp)
INP_RUNLOCK(inp);
- INP_INFO_RUNLOCK(&udbinfo);
+ INP_INFO_RUNLOCK(&V_udbinfo);
badunlocked:
m_freem(m);
}
@@ -612,8 +613,8 @@ udp_ctlinput(int cmd, struct sockaddr *sa, void *vip)
return;
if (ip != NULL) {
uh = (struct udphdr *)((caddr_t)ip + (ip->ip_hl << 2));
- INP_INFO_RLOCK(&udbinfo);
- inp = in_pcblookup_hash(&udbinfo, faddr, uh->uh_dport,
+ INP_INFO_RLOCK(&V_udbinfo);
+ inp = in_pcblookup_hash(&V_udbinfo, faddr, uh->uh_dport,
ip->ip_src, uh->uh_sport, 0, NULL);
if (inp != NULL) {
INP_RLOCK(inp);
@@ -622,9 +623,9 @@ udp_ctlinput(int cmd, struct sockaddr *sa, void *vip)
}
INP_RUNLOCK(inp);
}
- INP_INFO_RUNLOCK(&udbinfo);
+ INP_INFO_RUNLOCK(&V_udbinfo);
} else
- in_pcbnotifyall(&udbinfo, faddr, inetctlerrmap[cmd],
+ in_pcbnotifyall(&V_udbinfo, faddr, inetctlerrmap[cmd],
udp_notify);
}
@@ -641,7 +642,7 @@ udp_pcblist(SYSCTL_HANDLER_ARGS)
* resource-intensive to repeat twice on every request.
*/
if (req->oldptr == 0) {
- n = udbinfo.ipi_count;
+ n = V_udbinfo.ipi_count;
req->oldidx = 2 * (sizeof xig)
+ (n + n/8) * sizeof(struct xinpcb);
return (0);
@@ -653,10 +654,10 @@ udp_pcblist(SYSCTL_HANDLER_ARGS)
/*
* OK, now we're committed to doing something.
*/
- INP_INFO_RLOCK(&udbinfo);
- gencnt = udbinfo.ipi_gencnt;
- n = udbinfo.ipi_count;
- INP_INFO_RUNLOCK(&udbinfo);
+ INP_INFO_RLOCK(&V_udbinfo);
+ gencnt = V_udbinfo.ipi_gencnt;
+ n = V_udbinfo.ipi_count;
+ INP_INFO_RUNLOCK(&V_udbinfo);
error = sysctl_wire_old_buffer(req, 2 * (sizeof xig)
+ n * sizeof(struct xinpcb));
@@ -675,8 +676,8 @@ udp_pcblist(SYSCTL_HANDLER_ARGS)
if (inp_list == 0)
return (ENOMEM);
- INP_INFO_RLOCK(&udbinfo);
- for (inp = LIST_FIRST(udbinfo.ipi_listhead), i = 0; inp && i < n;
+ INP_INFO_RLOCK(&V_udbinfo);
+ for (inp = LIST_FIRST(V_udbinfo.ipi_listhead), i = 0; inp && i < n;
inp = LIST_NEXT(inp, inp_list)) {
INP_RLOCK(inp);
if (inp->inp_gencnt <= gencnt &&
@@ -684,7 +685,7 @@ udp_pcblist(SYSCTL_HANDLER_ARGS)
inp_list[i++] = inp;
INP_RUNLOCK(inp);
}
- INP_INFO_RUNLOCK(&udbinfo);
+ INP_INFO_RUNLOCK(&V_udbinfo);
n = i;
error = 0;
@@ -712,11 +713,11 @@ udp_pcblist(SYSCTL_HANDLER_ARGS)
* that something happened while we were processing this
* request, and it might be necessary to retry.
*/
- INP_INFO_RLOCK(&udbinfo);
- xig.xig_gen = udbinfo.ipi_gencnt;
+ INP_INFO_RLOCK(&V_udbinfo);
+ xig.xig_gen = V_udbinfo.ipi_gencnt;
xig.xig_sogen = so_gencnt;
- xig.xig_count = udbinfo.ipi_count;
- INP_INFO_RUNLOCK(&udbinfo);
+ xig.xig_count = V_udbinfo.ipi_count;
+ INP_INFO_RUNLOCK(&V_udbinfo);
error = SYSCTL_OUT(req, &xig, sizeof xig);
}
free(inp_list, M_TEMP);
@@ -740,12 +741,12 @@ udp_getcred(SYSCTL_HANDLER_ARGS)
error = SYSCTL_IN(req, addrs, sizeof(addrs));
if (error)
return (error);
- INP_INFO_RLOCK(&udbinfo);
- inp = in_pcblookup_hash(&udbinfo, addrs[1].sin_addr, addrs[1].sin_port,
+ INP_INFO_RLOCK(&V_udbinfo);
+ inp = in_pcblookup_hash(&V_udbinfo, addrs[1].sin_addr, addrs[1].sin_port,
addrs[0].sin_addr, addrs[0].sin_port, 1, NULL);
if (inp != NULL) {
INP_RLOCK(inp);
- INP_INFO_RUNLOCK(&udbinfo);
+ INP_INFO_RUNLOCK(&V_udbinfo);
if (inp->inp_socket == NULL)
error = ENOENT;
if (error == 0)
@@ -755,7 +756,7 @@ udp_getcred(SYSCTL_HANDLER_ARGS)
cru2x(inp->inp_socket->so_cred, &xuc);
INP_RUNLOCK(inp);
} else {
- INP_INFO_RUNLOCK(&udbinfo);
+ INP_INFO_RUNLOCK(&V_udbinfo);
error = ENOENT;
}
if (error == 0)
@@ -865,7 +866,7 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr,
if (sin != NULL &&
(inp->inp_laddr.s_addr == INADDR_ANY && inp->inp_lport == 0)) {
INP_RUNLOCK(inp);
- INP_INFO_WLOCK(&udbinfo);
+ INP_INFO_WLOCK(&V_udbinfo);
INP_WLOCK(inp);
unlock_udbinfo = 2;
} else if ((sin != NULL && (
@@ -874,9 +875,9 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr,
(inp->inp_laddr.s_addr == INADDR_ANY) ||
(inp->inp_lport == 0))) ||
(src.sin_family == AF_INET)) {
- if (!INP_INFO_TRY_RLOCK(&udbinfo)) {
+ if (!INP_INFO_TRY_RLOCK(&V_udbinfo)) {
INP_RUNLOCK(inp);
- INP_INFO_RLOCK(&udbinfo);
+ INP_INFO_RLOCK(&V_udbinfo);
INP_RLOCK(inp);
}
unlock_udbinfo = 1;
@@ -891,7 +892,7 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr,
laddr = inp->inp_laddr;
lport = inp->inp_lport;
if (src.sin_family == AF_INET) {
- INP_INFO_LOCK_ASSERT(&udbinfo);
+ INP_INFO_LOCK_ASSERT(&V_udbinfo);
if ((lport == 0) ||
(laddr.s_addr == INADDR_ANY &&
src.sin_addr.s_addr == INADDR_ANY)) {
@@ -942,7 +943,7 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr,
inp->inp_lport == 0 ||
sin->sin_addr.s_addr == INADDR_ANY ||
sin->sin_addr.s_addr == INADDR_BROADCAST) {
- INP_INFO_LOCK_ASSERT(&udbinfo);
+ INP_INFO_LOCK_ASSERT(&V_udbinfo);
error = in_pcbconnect_setup(inp, addr, &laddr.s_addr,
&lport, &faddr.s_addr, &fport, NULL,
td->td_ucred);
@@ -956,7 +957,7 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr,
/* Commit the local port if newly assigned. */
if (inp->inp_laddr.s_addr == INADDR_ANY &&
inp->inp_lport == 0) {
- INP_INFO_WLOCK_ASSERT(&udbinfo);
+ INP_INFO_WLOCK_ASSERT(&V_udbinfo);
INP_WLOCK_ASSERT(inp);
/*
* Remember addr if jailed, to prevent
@@ -1050,12 +1051,12 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr,
((struct ip *)ui)->ip_len = sizeof (struct udpiphdr) + len;
((struct ip *)ui)->ip_ttl = inp->inp_ip_ttl; /* XXX */
((struct ip *)ui)->ip_tos = inp->inp_ip_tos; /* XXX */
- udpstat.udps_opackets++;
+ V_udpstat.udps_opackets++;
if (unlock_udbinfo == 2)
- INP_INFO_WUNLOCK(&udbinfo);
+ INP_INFO_WUNLOCK(&V_udbinfo);
else if (unlock_udbinfo == 1)
- INP_INFO_RUNLOCK(&udbinfo);
+ INP_INFO_RUNLOCK(&V_udbinfo);
error = ip_output(m, inp->inp_options, NULL, ipflags,
inp->inp_moptions, inp);
if (unlock_udbinfo == 2)
@@ -1067,10 +1068,10 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr,
release:
if (unlock_udbinfo == 2) {
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&udbinfo);
+ INP_INFO_WUNLOCK(&V_udbinfo);
} else if (unlock_udbinfo == 1) {
INP_RUNLOCK(inp);
- INP_INFO_RUNLOCK(&udbinfo);
+ INP_INFO_RUNLOCK(&V_udbinfo);
} else
INP_RUNLOCK(inp);
m_freem(m);
@@ -1084,7 +1085,7 @@ udp_abort(struct socket *so)
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("udp_abort: inp == NULL"));
- INP_INFO_WLOCK(&udbinfo);
+ INP_INFO_WLOCK(&V_udbinfo);
INP_WLOCK(inp);
if (inp->inp_faddr.s_addr != INADDR_ANY) {
in_pcbdisconnect(inp);
@@ -1092,7 +1093,7 @@ udp_abort(struct socket *so)
soisdisconnected(so);
}
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&udbinfo);
+ INP_INFO_WUNLOCK(&V_udbinfo);
}
static int
@@ -1106,17 +1107,17 @@ udp_attach(struct socket *so, int proto, struct thread *td)
error = soreserve(so, udp_sendspace, udp_recvspace);
if (error)
return (error);
- INP_INFO_WLOCK(&udbinfo);
- error = in_pcballoc(so, &udbinfo);
+ INP_INFO_WLOCK(&V_udbinfo);
+ error = in_pcballoc(so, &V_udbinfo);
if (error) {
- INP_INFO_WUNLOCK(&udbinfo);
+ INP_INFO_WUNLOCK(&V_udbinfo);
return (error);
}
inp = (struct inpcb *)so->so_pcb;
- INP_INFO_WUNLOCK(&udbinfo);
+ INP_INFO_WUNLOCK(&V_udbinfo);
inp->inp_vflag |= INP_IPV4;
- inp->inp_ip_ttl = ip_defttl;
+ inp->inp_ip_ttl = V_ip_defttl;
INP_WUNLOCK(inp);
return (0);
}
@@ -1129,11 +1130,11 @@ udp_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("udp_bind: inp == NULL"));
- INP_INFO_WLOCK(&udbinfo);
+ INP_INFO_WLOCK(&V_udbinfo);
INP_WLOCK(inp);
error = in_pcbbind(inp, nam, td->td_ucred);
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&udbinfo);
+ INP_INFO_WUNLOCK(&V_udbinfo);
return (error);
}
@@ -1144,7 +1145,7 @@ udp_close(struct socket *so)
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("udp_close: inp == NULL"));
- INP_INFO_WLOCK(&udbinfo);
+ INP_INFO_WLOCK(&V_udbinfo);
INP_WLOCK(inp);
if (inp->inp_faddr.s_addr != INADDR_ANY) {
in_pcbdisconnect(inp);
@@ -1152,7 +1153,7 @@ udp_close(struct socket *so)
soisdisconnected(so);
}
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&udbinfo);
+ INP_INFO_WUNLOCK(&V_udbinfo);
}
static int
@@ -1164,11 +1165,11 @@ udp_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("udp_connect: inp == NULL"));
- INP_INFO_WLOCK(&udbinfo);
+ INP_INFO_WLOCK(&V_udbinfo);
INP_WLOCK(inp);
if (inp->inp_faddr.s_addr != INADDR_ANY) {
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&udbinfo);
+ INP_INFO_WUNLOCK(&V_udbinfo);
return (EISCONN);
}
sin = (struct sockaddr_in *)nam;
@@ -1178,7 +1179,7 @@ udp_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
if (error == 0)
soisconnected(so);
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&udbinfo);
+ INP_INFO_WUNLOCK(&V_udbinfo);
return (error);
}
@@ -1191,11 +1192,11 @@ udp_detach(struct socket *so)
KASSERT(inp != NULL, ("udp_detach: inp == NULL"));
KASSERT(inp->inp_faddr.s_addr == INADDR_ANY,
("udp_detach: not disconnected"));
- INP_INFO_WLOCK(&udbinfo);
+ INP_INFO_WLOCK(&V_udbinfo);
INP_WLOCK(inp);
in_pcbdetach(inp);
in_pcbfree(inp);
- INP_INFO_WUNLOCK(&udbinfo);
+ INP_INFO_WUNLOCK(&V_udbinfo);
}
static int
@@ -1205,11 +1206,11 @@ udp_disconnect(struct socket *so)
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("udp_disconnect: inp == NULL"));
- INP_INFO_WLOCK(&udbinfo);
+ INP_INFO_WLOCK(&V_udbinfo);
INP_WLOCK(inp);
if (inp->inp_faddr.s_addr == INADDR_ANY) {
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&udbinfo);
+ INP_INFO_WUNLOCK(&V_udbinfo);
return (ENOTCONN);
}
@@ -1219,7 +1220,7 @@ udp_disconnect(struct socket *so)
so->so_state &= ~SS_ISCONNECTED; /* XXX */
SOCK_UNLOCK(so);
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&udbinfo);
+ INP_INFO_WUNLOCK(&V_udbinfo);
return (0);
}
diff --git a/sys/netinet6/dest6.c b/sys/netinet6/dest6.c
index fb508fc..20b5e9d 100644
--- a/sys/netinet6/dest6.c
+++ b/sys/netinet6/dest6.c
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
#include <sys/errno.h>
#include <sys/time.h>
#include <sys/kernel.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/route.h>
@@ -93,7 +94,7 @@ dest6_input(struct mbuf **mp, int *offp, int proto)
for (optlen = 0; dstoptlen > 0; dstoptlen -= optlen, opt += optlen) {
if (*opt != IP6OPT_PAD1 &&
(dstoptlen < IP6OPT_MINLEN || *(opt + 1) + 2 > dstoptlen)) {
- ip6stat.ip6s_toosmall++;
+ V_ip6stat.ip6s_toosmall++;
goto bad;
}
diff --git a/sys/netinet6/frag6.c b/sys/netinet6/frag6.c
index 9826f6b..bad4410 100644
--- a/sys/netinet6/frag6.c
+++ b/sys/netinet6/frag6.c
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
#include <sys/time.h>
#include <sys/kernel.h>
#include <sys/syslog.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/route.h>
@@ -91,22 +92,22 @@ static void
frag6_change(void *tag)
{
- ip6_maxfragpackets = nmbclusters / 4;
- ip6_maxfrags = nmbclusters / 4;
+ V_ip6_maxfragpackets = nmbclusters / 4;
+ V_ip6_maxfrags = nmbclusters / 4;
}
void
frag6_init(void)
{
- ip6_maxfragpackets = nmbclusters / 4;
- ip6_maxfrags = nmbclusters / 4;
+ V_ip6_maxfragpackets = nmbclusters / 4;
+ V_ip6_maxfrags = nmbclusters / 4;
EVENTHANDLER_REGISTER(nmbclusters_change,
frag6_change, NULL, EVENTHANDLER_PRI_ANY);
IP6Q_LOCK_INIT();
- ip6q.ip6q_next = ip6q.ip6q_prev = &ip6q;
+ V_ip6q.ip6q_next = V_ip6q.ip6q_prev = &V_ip6q;
}
/*
@@ -203,7 +204,7 @@ frag6_input(struct mbuf **mp, int *offp, int proto)
return IPPROTO_DONE;
}
- ip6stat.ip6s_fragments++;
+ V_ip6stat.ip6s_fragments++;
in6_ifstat_inc(dstifp, ifs6_reass_reqd);
/* offset now points to data portion */
@@ -216,18 +217,18 @@ frag6_input(struct mbuf **mp, int *offp, int proto)
* If maxfrag is 0, never accept fragments.
* If maxfrag is -1, accept all fragments without limitation.
*/
- if (ip6_maxfrags < 0)
+ if (V_ip6_maxfrags < 0)
;
- else if (frag6_nfrags >= (u_int)ip6_maxfrags)
+ else if (V_frag6_nfrags >= (u_int)V_ip6_maxfrags)
goto dropfrag;
- for (q6 = ip6q.ip6q_next; q6 != &ip6q; q6 = q6->ip6q_next)
+ for (q6 = V_ip6q.ip6q_next; q6 != &V_ip6q; q6 = q6->ip6q_next)
if (ip6f->ip6f_ident == q6->ip6q_ident &&
IN6_ARE_ADDR_EQUAL(&ip6->ip6_src, &q6->ip6q_src) &&
IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst, &q6->ip6q_dst))
break;
- if (q6 == &ip6q) {
+ if (q6 == &V_ip6q) {
/*
* the first fragment to arrive, create a reassembly queue.
*/
@@ -240,18 +241,18 @@ frag6_input(struct mbuf **mp, int *offp, int proto)
* If maxfragpackets is -1, accept all fragments without
* limitation.
*/
- if (ip6_maxfragpackets < 0)
+ if (V_ip6_maxfragpackets < 0)
;
- else if (frag6_nfragpackets >= (u_int)ip6_maxfragpackets)
+ else if (V_frag6_nfragpackets >= (u_int)V_ip6_maxfragpackets)
goto dropfrag;
- frag6_nfragpackets++;
+ V_frag6_nfragpackets++;
q6 = (struct ip6q *)malloc(sizeof(struct ip6q), M_FTABLE,
M_NOWAIT);
if (q6 == NULL)
goto dropfrag;
bzero(q6, sizeof(*q6));
- frag6_insque(q6, &ip6q);
+ frag6_insque(q6, &V_ip6q);
/* ip6q_nxt will be filled afterwards, from 1st fragment */
q6->ip6q_down = q6->ip6q_up = (struct ip6asfrag *)q6;
@@ -465,12 +466,12 @@ insert:
* the most recently active fragmented packet.
*/
frag6_enq(ip6af, af6->ip6af_up);
- frag6_nfrags++;
+ V_frag6_nfrags++;
q6->ip6q_nfrag++;
#if 0 /* xxx */
- if (q6 != ip6q.ip6q_next) {
+ if (q6 != V_ip6q.ip6q_next) {
frag6_remque(q6);
- frag6_insque(q6, &ip6q);
+ frag6_insque(q6, &V_ip6q);
}
#endif
next = 0;
@@ -528,9 +529,9 @@ insert:
/* this comes with no copy if the boundary is on cluster */
if ((t = m_split(m, offset, M_DONTWAIT)) == NULL) {
frag6_remque(q6);
- frag6_nfrags -= q6->ip6q_nfrag;
+ V_frag6_nfrags -= q6->ip6q_nfrag;
free(q6, M_FTABLE);
- frag6_nfragpackets--;
+ V_frag6_nfragpackets--;
goto dropfrag;
}
m_adj(t, sizeof(struct ip6_frag));
@@ -546,9 +547,9 @@ insert:
}
frag6_remque(q6);
- frag6_nfrags -= q6->ip6q_nfrag;
+ V_frag6_nfrags -= q6->ip6q_nfrag;
free(q6, M_FTABLE);
- frag6_nfragpackets--;
+ V_frag6_nfragpackets--;
if (m->m_flags & M_PKTHDR) { /* Isn't it always true? */
int plen = 0;
@@ -557,7 +558,7 @@ insert:
m->m_pkthdr.len = plen;
}
- ip6stat.ip6s_reassembled++;
+ V_ip6stat.ip6s_reassembled++;
in6_ifstat_inc(dstifp, ifs6_reass_ok);
/*
@@ -573,7 +574,7 @@ insert:
dropfrag:
IP6Q_UNLOCK();
in6_ifstat_inc(dstifp, ifs6_reass_fail);
- ip6stat.ip6s_fragdropped++;
+ V_ip6stat.ip6s_fragdropped++;
m_freem(m);
return IPPROTO_DONE;
}
@@ -617,9 +618,9 @@ frag6_freef(struct ip6q *q6)
free(af6, M_FTABLE);
}
frag6_remque(q6);
- frag6_nfrags -= q6->ip6q_nfrag;
+ V_frag6_nfrags -= q6->ip6q_nfrag;
free(q6, M_FTABLE);
- frag6_nfragpackets--;
+ V_frag6_nfragpackets--;
}
/*
@@ -684,13 +685,13 @@ frag6_slowtimo(void)
struct ip6q *q6;
IP6Q_LOCK();
- q6 = ip6q.ip6q_next;
+ q6 = V_ip6q.ip6q_next;
if (q6)
- while (q6 != &ip6q) {
+ while (q6 != &V_ip6q) {
--q6->ip6q_ttl;
q6 = q6->ip6q_next;
if (q6->ip6q_prev->ip6q_ttl == 0) {
- ip6stat.ip6s_fragtimeout++;
+ V_ip6stat.ip6s_fragtimeout++;
/* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */
frag6_freef(q6->ip6q_prev);
}
@@ -700,11 +701,11 @@ frag6_slowtimo(void)
* (due to the limit being lowered), drain off
* enough to get down to the new limit.
*/
- while (frag6_nfragpackets > (u_int)ip6_maxfragpackets &&
- ip6q.ip6q_prev) {
- ip6stat.ip6s_fragoverflow++;
+ while (V_frag6_nfragpackets > (u_int)V_ip6_maxfragpackets &&
+ V_ip6q.ip6q_prev) {
+ V_ip6stat.ip6s_fragoverflow++;
/* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */
- frag6_freef(ip6q.ip6q_prev);
+ frag6_freef(V_ip6q.ip6q_prev);
}
IP6Q_UNLOCK();
@@ -714,9 +715,9 @@ frag6_slowtimo(void)
* make sure we notice eventually, even if forwarding only for one
* destination and the cache is never replaced.
*/
- if (ip6_forward_rt.ro_rt) {
- RTFREE(ip6_forward_rt.ro_rt);
- ip6_forward_rt.ro_rt = 0;
+ if (V_ip6_forward_rt.ro_rt) {
+ RTFREE(V_ip6_forward_rt.ro_rt);
+ V_ip6_forward_rt.ro_rt = 0;
}
if (ipsrcchk_rt.ro_rt) {
RTFREE(ipsrcchk_rt.ro_rt);
@@ -734,10 +735,10 @@ frag6_drain(void)
if (IP6Q_TRYLOCK() == 0)
return;
- while (ip6q.ip6q_next != &ip6q) {
- ip6stat.ip6s_fragdropped++;
+ while (V_ip6q.ip6q_next != &V_ip6q) {
+ V_ip6stat.ip6s_fragdropped++;
/* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */
- frag6_freef(ip6q.ip6q_next);
+ frag6_freef(V_ip6q.ip6q_next);
}
IP6Q_UNLOCK();
}
diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c
index 89fbe29..3391d57 100644
--- a/sys/netinet6/icmp6.c
+++ b/sys/netinet6/icmp6.c
@@ -81,6 +81,7 @@ __FBSDID("$FreeBSD$");
#include <sys/syslog.h>
#include <sys/systm.h>
#include <sys/time.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_dl.h>
@@ -240,14 +241,14 @@ icmp6_error(struct mbuf *m, int type, int code, int param)
int off;
int nxt;
- icmp6stat.icp6s_error++;
+ V_icmp6stat.icp6s_error++;
/* count per-type-code statistics */
- icmp6_errcount(&icmp6stat.icp6s_outerrhist, type, code);
+ icmp6_errcount(&V_icmp6stat.icp6s_outerrhist, type, code);
#ifdef M_DECRYPTED /*not openbsd*/
if (m->m_flags & M_DECRYPTED) {
- icmp6stat.icp6s_canterror++;
+ V_icmp6stat.icp6s_canterror++;
goto freeit;
}
#endif
@@ -305,7 +306,7 @@ icmp6_error(struct mbuf *m, int type, int code, int param)
IP6_EXTHDR_GET(icp, struct icmp6_hdr *, m, off,
sizeof(*icp));
if (icp == NULL) {
- icmp6stat.icp6s_tooshort++;
+ V_icmp6stat.icp6s_tooshort++;
return;
}
#endif
@@ -316,7 +317,7 @@ icmp6_error(struct mbuf *m, int type, int code, int param)
* Special case: for redirect (which is
* informational) we must not send icmp6 error.
*/
- icmp6stat.icp6s_canterror++;
+ V_icmp6stat.icp6s_canterror++;
goto freeit;
} else {
/* ICMPv6 informational - send the error */
@@ -329,7 +330,7 @@ icmp6_error(struct mbuf *m, int type, int code, int param)
/* Finally, do rate limitation check. */
if (icmp6_ratelimit(&oip6->ip6_src, type, code)) {
- icmp6stat.icp6s_toofreq++;
+ V_icmp6stat.icp6s_toofreq++;
goto freeit;
}
@@ -370,7 +371,7 @@ icmp6_error(struct mbuf *m, int type, int code, int param)
*/
m->m_pkthdr.rcvif = NULL;
- icmp6stat.icp6s_outhist[type]++;
+ V_icmp6stat.icp6s_outhist[type]++;
icmp6_reflect(m, sizeof(struct ip6_hdr)); /* header order: IPv6 - ICMPv6 */
return;
@@ -408,7 +409,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
ip6 = mtod(m, struct ip6_hdr *);
if (icmp6len < sizeof(struct icmp6_hdr)) {
- icmp6stat.icp6s_tooshort++;
+ V_icmp6stat.icp6s_tooshort++;
goto freeit;
}
@@ -420,7 +421,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
#else
IP6_EXTHDR_GET(icmp6, struct icmp6_hdr *, m, off, sizeof(*icmp6));
if (icmp6 == NULL) {
- icmp6stat.icp6s_tooshort++;
+ V_icmp6stat.icp6s_tooshort++;
return IPPROTO_DONE;
}
#endif
@@ -431,7 +432,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
"ICMP6 checksum error(%d|%x) %s\n",
icmp6->icmp6_type, sum,
ip6_sprintf(ip6bufs, &ip6->ip6_src)));
- icmp6stat.icp6s_checksum++;
+ V_icmp6stat.icp6s_checksum++;
goto freeit;
}
@@ -451,7 +452,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
}
}
- icmp6stat.icp6s_inhist[icmp6->icmp6_type]++;
+ V_icmp6stat.icp6s_inhist[icmp6->icmp6_type]++;
icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_msg);
if (icmp6->icmp6_type < ICMP6_INFOMSG_MASK)
icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_error);
@@ -585,8 +586,8 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
nicmp6->icmp6_type = ICMP6_ECHO_REPLY;
nicmp6->icmp6_code = 0;
if (n) {
- icmp6stat.icp6s_reflect++;
- icmp6stat.icp6s_outhist[ICMP6_ECHO_REPLY]++;
+ V_icmp6stat.icp6s_reflect++;
+ V_icmp6stat.icp6s_outhist[ICMP6_ECHO_REPLY]++;
icmp6_reflect(n, noff);
}
break;
@@ -631,7 +632,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
{
enum { WRU, FQDN } mode;
- if (!icmp6_nodeinfo)
+ if (!V_icmp6_nodeinfo)
break;
if (icmp6len == sizeof(struct icmp6_hdr) + 4)
@@ -641,7 +642,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
else
goto badlen;
-#define hostnamelen strlen(hostname)
+#define hostnamelen strlen(V_hostname)
if (mode == FQDN) {
#ifndef PULLDOWN_TEST
IP6_EXTHDR_CHECK(m, off, sizeof(struct icmp6_nodeinfo),
@@ -660,7 +661,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
* XXX: this combination of flags is pointless,
* but should we keep this for compatibility?
*/
- if ((icmp6_nodeinfo & 5) != 5)
+ if ((V_icmp6_nodeinfo & 5) != 5)
break;
if (code != 0)
@@ -708,7 +709,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
bcopy(icmp6, nicmp6, sizeof(struct icmp6_hdr));
p = (u_char *)(nicmp6 + 1);
bzero(p, 4);
- bcopy(hostname, p + 4, maxhlen); /* meaningless TTL */
+ bcopy(V_hostname, p + 4, maxhlen); /* meaningless TTL */
mtx_unlock(&hostname_mtx);
noff = sizeof(struct ip6_hdr);
n->m_pkthdr.len = n->m_len = sizeof(struct ip6_hdr) +
@@ -718,8 +719,8 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
}
#undef hostnamelen
if (n) {
- icmp6stat.icp6s_reflect++;
- icmp6stat.icp6s_outhist[ICMP6_WRUREPLY]++;
+ V_icmp6stat.icp6s_reflect++;
+ V_icmp6stat.icp6s_outhist[ICMP6_WRUREPLY]++;
icmp6_reflect(n, noff);
}
break;
@@ -840,11 +841,11 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
break;
badcode:
- icmp6stat.icp6s_badcode++;
+ V_icmp6stat.icp6s_badcode++;
break;
badlen:
- icmp6stat.icp6s_badlen++;
+ V_icmp6stat.icp6s_badlen++;
break;
}
@@ -868,7 +869,7 @@ icmp6_notify_error(struct mbuf **mp, int off, int icmp6len, int code)
struct sockaddr_in6 icmp6src, icmp6dst;
if (icmp6len < sizeof(struct icmp6_hdr) + sizeof(struct ip6_hdr)) {
- icmp6stat.icp6s_tooshort++;
+ V_icmp6stat.icp6s_tooshort++;
goto freeit;
}
#ifndef PULLDOWN_TEST
@@ -879,7 +880,7 @@ icmp6_notify_error(struct mbuf **mp, int off, int icmp6len, int code)
IP6_EXTHDR_GET(icmp6, struct icmp6_hdr *, m, off,
sizeof(*icmp6) + sizeof(struct ip6_hdr));
if (icmp6 == NULL) {
- icmp6stat.icp6s_tooshort++;
+ V_icmp6stat.icp6s_tooshort++;
return (-1);
}
#endif
@@ -914,7 +915,7 @@ icmp6_notify_error(struct mbuf **mp, int off, int icmp6len, int code)
IP6_EXTHDR_GET(eh, struct ip6_ext *, m,
eoff, sizeof(*eh));
if (eh == NULL) {
- icmp6stat.icp6s_tooshort++;
+ V_icmp6stat.icp6s_tooshort++;
return (-1);
}
#endif
@@ -942,7 +943,7 @@ icmp6_notify_error(struct mbuf **mp, int off, int icmp6len, int code)
IP6_EXTHDR_GET(rth, struct ip6_rthdr *, m,
eoff, sizeof(*rth));
if (rth == NULL) {
- icmp6stat.icp6s_tooshort++;
+ V_icmp6stat.icp6s_tooshort++;
return (-1);
}
#endif
@@ -968,7 +969,7 @@ icmp6_notify_error(struct mbuf **mp, int off, int icmp6len, int code)
struct ip6_rthdr0 *, m,
eoff, rthlen);
if (rth0 == NULL) {
- icmp6stat.icp6s_tooshort++;
+ V_icmp6stat.icp6s_tooshort++;
return (-1);
}
#endif
@@ -990,7 +991,7 @@ icmp6_notify_error(struct mbuf **mp, int off, int icmp6len, int code)
IP6_EXTHDR_GET(fh, struct ip6_frag *, m,
eoff, sizeof(*fh));
if (fh == NULL) {
- icmp6stat.icp6s_tooshort++;
+ V_icmp6stat.icp6s_tooshort++;
return (-1);
}
#endif
@@ -1025,7 +1026,7 @@ icmp6_notify_error(struct mbuf **mp, int off, int icmp6len, int code)
IP6_EXTHDR_GET(icmp6, struct icmp6_hdr *, m, off,
sizeof(*icmp6) + sizeof(struct ip6_hdr));
if (icmp6 == NULL) {
- icmp6stat.icp6s_tooshort++;
+ V_icmp6stat.icp6s_tooshort++;
return (-1);
}
#endif
@@ -1129,7 +1130,7 @@ icmp6_mtudisc_update(struct ip6ctlparam *ip6cp, int validated)
if (mtu < tcp_maxmtu6(&inc, NULL)) {
tcp_hc_updatemtu(&inc, mtu);
- icmp6stat.icp6s_pmtuchg++;
+ V_icmp6stat.icp6s_pmtuchg++;
}
}
@@ -1144,7 +1145,7 @@ icmp6_mtudisc_update(struct ip6ctlparam *ip6cp, int validated)
* - joins NI group address at in6_ifattach() time only, does not cope
* with hostname changes by sethostname(3)
*/
-#define hostnamelen strlen(hostname)
+#define hostnamelen strlen(V_hostname)
static struct mbuf *
ni6_input(struct mbuf *m, int off)
{
@@ -1186,7 +1187,7 @@ ni6_input(struct mbuf *m, int off)
* link-local (note that site-local unicast was deprecated and
* ULA is defined as global scope-wise)
*/
- if ((icmp6_nodeinfo & ICMP6_NODEINFO_GLOBALOK) == 0 &&
+ if ((V_icmp6_nodeinfo & ICMP6_NODEINFO_GLOBALOK) == 0 &&
!IN6_IS_ADDR_LOOPBACK(&ip6->ip6_src) &&
!IN6_IS_ADDR_LINKLOCAL(&ip6->ip6_src))
goto bad;
@@ -1208,7 +1209,7 @@ ni6_input(struct mbuf *m, int off)
goto bad; /* XXX impossible */
if ((ia6->ia6_flags & IN6_IFF_TEMPORARY) &&
- !(icmp6_nodeinfo & ICMP6_NODEINFO_TMPADDROK)) {
+ !(V_icmp6_nodeinfo & ICMP6_NODEINFO_TMPADDROK)) {
nd6log((LOG_DEBUG, "ni6_input: ignore node info to "
"a temporary address in %s:%d",
__FILE__, __LINE__));
@@ -1299,7 +1300,7 @@ ni6_input(struct mbuf *m, int off)
* truncated hostname.
*/
mtx_lock(&hostname_mtx);
- n = ni6_nametodns(hostname, hostnamelen, 0);
+ n = ni6_nametodns(V_hostname, hostnamelen, 0);
mtx_unlock(&hostname_mtx);
if (!n || n->m_next || n->m_len == 0)
goto bad;
@@ -1325,12 +1326,12 @@ ni6_input(struct mbuf *m, int off)
/* refuse based on configuration. XXX ICMP6_NI_REFUSED? */
switch (qtype) {
case NI_QTYPE_FQDN:
- if ((icmp6_nodeinfo & ICMP6_NODEINFO_FQDNOK) == 0)
+ if ((V_icmp6_nodeinfo & ICMP6_NODEINFO_FQDNOK) == 0)
goto bad;
break;
case NI_QTYPE_NODEADDR:
case NI_QTYPE_IPV4ADDR:
- if ((icmp6_nodeinfo & ICMP6_NODEINFO_NODEADDROK) == 0)
+ if ((V_icmp6_nodeinfo & ICMP6_NODEINFO_NODEADDROK) == 0)
goto bad;
break;
}
@@ -1425,7 +1426,7 @@ ni6_input(struct mbuf *m, int off)
* XXX do we really have FQDN in variable "hostname"?
*/
mtx_lock(&hostname_mtx);
- n->m_next = ni6_nametodns(hostname, hostnamelen, oldfqdn);
+ n->m_next = ni6_nametodns(V_hostname, hostnamelen, oldfqdn);
mtx_unlock(&hostname_mtx);
if (n->m_next == NULL)
goto bad;
@@ -1655,7 +1656,7 @@ ni6_addrs(struct icmp6_nodeinfo *ni6, struct mbuf *m, struct ifnet **ifpp,
}
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)) {
addrsofif = 0;
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
if (ifa->ifa_addr->sa_family != AF_INET6)
@@ -1702,7 +1703,7 @@ ni6_addrs(struct icmp6_nodeinfo *ni6, struct mbuf *m, struct ifnet **ifpp,
(niflags & NI_NODEADDR_FLAG_ANYCAST) == 0)
continue; /* we need only unicast addresses */
if ((ifa6->ia6_flags & IN6_IFF_TEMPORARY) != 0 &&
- (icmp6_nodeinfo & ICMP6_NODEINFO_TMPADDROK) == 0) {
+ (V_icmp6_nodeinfo & ICMP6_NODEINFO_TMPADDROK) == 0) {
continue;
}
addrsofif++; /* count the address */
@@ -1724,7 +1725,7 @@ static int
ni6_store_addrs(struct icmp6_nodeinfo *ni6, struct icmp6_nodeinfo *nni6,
struct ifnet *ifp0, int resid)
{
- struct ifnet *ifp = ifp0 ? ifp0 : TAILQ_FIRST(&ifnet);
+ struct ifnet *ifp = ifp0 ? ifp0 : TAILQ_FIRST(&V_ifnet);
struct in6_ifaddr *ifa6;
struct ifaddr *ifa;
struct ifnet *ifp_dep = NULL;
@@ -1788,7 +1789,7 @@ ni6_store_addrs(struct icmp6_nodeinfo *ni6, struct icmp6_nodeinfo *nni6,
(niflags & NI_NODEADDR_FLAG_ANYCAST) == 0)
continue;
if ((ifa6->ia6_flags & IN6_IFF_TEMPORARY) != 0 &&
- (icmp6_nodeinfo & ICMP6_NODEINFO_TMPADDROK) == 0) {
+ (V_icmp6_nodeinfo & ICMP6_NODEINFO_TMPADDROK) == 0) {
continue;
}
@@ -1895,8 +1896,8 @@ icmp6_rip6_input(struct mbuf **mp, int off)
return (IPPROTO_DONE);
}
- INP_INFO_RLOCK(&ripcbinfo);
- LIST_FOREACH(in6p, &ripcb, inp_list) {
+ INP_INFO_RLOCK(&V_ripcbinfo);
+ LIST_FOREACH(in6p, &V_ripcb, inp_list) {
if ((in6p->inp_vflag & INP_IPV6) == 0)
continue;
if (in6p->in6p_ip6_nxt != IPPROTO_ICMPV6)
@@ -1973,7 +1974,7 @@ icmp6_rip6_input(struct mbuf **mp, int off)
}
last = in6p;
}
- INP_INFO_RUNLOCK(&ripcbinfo);
+ INP_INFO_RUNLOCK(&V_ripcbinfo);
if (last) {
if (last->in6p_flags & IN6P_CONTROLOPTS)
ip6_savecontrol(last, m, &opts);
@@ -2011,7 +2012,7 @@ icmp6_rip6_input(struct mbuf **mp, int off)
INP_RUNLOCK(last);
} else {
m_freem(m);
- ip6stat.ip6s_delivered--;
+ V_ip6stat.ip6s_delivered--;
}
return IPPROTO_DONE;
}
@@ -2155,7 +2156,7 @@ icmp6_reflect(struct mbuf *m, size_t off)
/* XXX: This may not be the outgoing interface */
ip6->ip6_hlim = ND_IFINFO(m->m_pkthdr.rcvif)->chlim;
} else
- ip6->ip6_hlim = ip6_defhlim;
+ ip6->ip6_hlim = V_ip6_defhlim;
icmp6->icmp6_cksum = 0;
icmp6->icmp6_cksum = in6_cksum(m, IPPROTO_ICMPV6,
@@ -2228,9 +2229,9 @@ icmp6_redirect_input(struct mbuf *m, int off)
return;
/* XXX if we are router, we don't update route by icmp6 redirect */
- if (ip6_forwarding)
+ if (V_ip6_forwarding)
goto freeit;
- if (!icmp6_rediraccept)
+ if (!V_icmp6_rediraccept)
goto freeit;
#ifndef PULLDOWN_TEST
@@ -2239,7 +2240,7 @@ icmp6_redirect_input(struct mbuf *m, int off)
#else
IP6_EXTHDR_GET(nd_rd, struct nd_redirect *, m, off, icmp6len);
if (nd_rd == NULL) {
- icmp6stat.icp6s_tooshort++;
+ V_icmp6stat.icp6s_tooshort++;
return;
}
#endif
@@ -2402,7 +2403,7 @@ icmp6_redirect_input(struct mbuf *m, int off)
return;
bad:
- icmp6stat.icp6s_badredirect++;
+ V_icmp6stat.icp6s_badredirect++;
m_freem(m);
}
@@ -2421,10 +2422,10 @@ icmp6_redirect_output(struct mbuf *m0, struct rtentry *rt)
struct ifnet *outif = NULL;
struct sockaddr_in6 src_sa;
- icmp6_errcount(&icmp6stat.icp6s_outerrhist, ND_REDIRECT, 0);
+ icmp6_errcount(&V_icmp6stat.icp6s_outerrhist, ND_REDIRECT, 0);
/* if we are not router, we don't send icmp6 redirect */
- if (!ip6_forwarding)
+ if (!V_ip6_forwarding)
goto fail;
/* sanity check */
@@ -2676,7 +2677,7 @@ noredhdropt:;
icmp6_ifstat_inc(outif, ifs6_out_msg);
icmp6_ifstat_inc(outif, ifs6_out_redirect);
}
- icmp6stat.icp6s_outhist[ND_REDIRECT]++;
+ V_icmp6stat.icp6s_outhist[ND_REDIRECT]++;
return;
@@ -2780,8 +2781,8 @@ icmp6_ratelimit(const struct in6_addr *dst, const int type,
ret = 0; /* okay to send */
/* PPS limit */
- if (!ppsratecheck(&icmp6errppslim_last, &icmp6errpps_count,
- icmp6errppslim)) {
+ if (!ppsratecheck(&V_icmp6errppslim_last, &V_icmp6errpps_count,
+ V_icmp6errppslim)) {
/* The packet is subject to rate limit */
ret++;
}
diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c
index bc9dcc9..cddb3ab 100644
--- a/sys/netinet6/in6.c
+++ b/sys/netinet6/in6.c
@@ -78,6 +78,7 @@ __FBSDID("$FreeBSD$");
#include <sys/time.h>
#include <sys/kernel.h>
#include <sys/syslog.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_types.h>
@@ -249,7 +250,7 @@ in6_ifremloop(struct ifaddr *ifa)
* (probably p2p) interfaces.
* XXX: we should avoid such a configuration in IPv6...
*/
- for (ia = in6_ifaddr; ia; ia = ia->ia_next) {
+ for (ia = V_in6_ifaddr; ia; ia = ia->ia_next) {
if (IN6_ARE_ADDR_EQUAL(IFA_IN6(ifa), &ia->ia_addr.sin6_addr)) {
ia_count++;
if (ia_count > 1)
@@ -733,7 +734,7 @@ in6_control(struct socket *so, u_long cmd, caddr_t data,
* (when required).
*/
if ((ia->ia6_flags & IN6_IFF_AUTOCONF) &&
- ip6_use_tempaddr && pr->ndpr_refcnt == 1) {
+ V_ip6_use_tempaddr && pr->ndpr_refcnt == 1) {
int e;
if ((e = in6_tmpifadd(ia, 1, 0)) != 0) {
log(LOG_NOTICE, "in6_control: failed "
@@ -939,12 +940,12 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
ia->ia_ifa.ifa_netmask = (struct sockaddr *)&ia->ia_prefixmask;
ia->ia_ifp = ifp;
- if ((oia = in6_ifaddr) != NULL) {
+ if ((oia = V_in6_ifaddr) != NULL) {
for ( ; oia->ia_next; oia = oia->ia_next)
continue;
oia->ia_next = ia;
} else
- in6_ifaddr = ia;
+ V_in6_ifaddr = ia;
ia->ia_ifa.ifa_refcnt = 1;
TAILQ_INSERT_TAIL(&ifp->if_addrlist, &ia->ia_ifa, ifa_list);
@@ -1149,7 +1150,7 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
/*
* join node information group address
*/
-#define hostnamelen strlen(hostname)
+#define hostnamelen strlen(V_hostname)
delay = 0;
if ((flags & IN6_IFAUPDATE_DADDELAY)) {
/*
@@ -1160,8 +1161,8 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
(MAX_RTR_SOLICITATION_DELAY * hz);
}
mtx_lock(&hostname_mtx);
- if (in6_nigroup(ifp, hostname, hostnamelen, &mltaddr.sin6_addr)
- == 0) {
+ if (in6_nigroup(ifp, V_hostname, hostnamelen,
+ &mltaddr.sin6_addr) == 0) {
mtx_unlock(&hostname_mtx);
imm = in6_joingroup(ifp, &mltaddr.sin6_addr, &error,
delay); /* XXX jinmei */
@@ -1328,8 +1329,8 @@ in6_unlink_ifa(struct in6_ifaddr *ia, struct ifnet *ifp)
TAILQ_REMOVE(&ifp->if_addrlist, &ia->ia_ifa, ifa_list);
oia = ia;
- if (oia == (ia = in6_ifaddr))
- in6_ifaddr = ia->ia_next;
+ if (oia == (ia = V_in6_ifaddr))
+ V_in6_ifaddr = ia->ia_next;
else {
while (ia->ia_next && (ia->ia_next != oia))
ia = ia->ia_next;
@@ -1894,7 +1895,7 @@ in6_localaddr(struct in6_addr *in6)
if (IN6_IS_ADDR_LOOPBACK(in6) || IN6_IS_ADDR_LINKLOCAL(in6))
return 1;
- for (ia = in6_ifaddr; ia; ia = ia->ia_next) {
+ for (ia = V_in6_ifaddr; ia; ia = ia->ia_next) {
if (IN6_ARE_MASKED_ADDR_EQUAL(in6, &ia->ia_addr.sin6_addr,
&ia->ia_prefixmask.sin6_addr)) {
return 1;
@@ -1909,7 +1910,7 @@ in6_is_addr_deprecated(struct sockaddr_in6 *sa6)
{
struct in6_ifaddr *ia;
- for (ia = in6_ifaddr; ia; ia = ia->ia_next) {
+ for (ia = V_in6_ifaddr; ia; ia = ia->ia_next) {
if (IN6_ARE_ADDR_EQUAL(&ia->ia_addr.sin6_addr,
&sa6->sin6_addr) &&
(ia->ia6_flags & IN6_IFF_DEPRECATED) != 0)
@@ -2022,7 +2023,7 @@ in6_ifawithifp(struct ifnet *ifp, struct in6_addr *dst)
if (((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_DETACHED)
continue;
if (((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_DEPRECATED) {
- if (ip6_use_deprecated)
+ if (V_ip6_use_deprecated)
dep[0] = (struct in6_ifaddr *)ifa;
continue;
}
@@ -2056,7 +2057,7 @@ in6_ifawithifp(struct ifnet *ifp, struct in6_addr *dst)
if (((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_DETACHED)
continue;
if (((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_DEPRECATED) {
- if (ip6_use_deprecated)
+ if (V_ip6_use_deprecated)
dep[1] = (struct in6_ifaddr *)ifa;
continue;
}
@@ -2151,7 +2152,7 @@ in6_setmaxmtu(void)
struct ifnet *ifp;
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)) {
/* this function can be called during ifnet initialization */
if (!ifp->if_afdata[AF_INET6])
continue;
@@ -2161,7 +2162,7 @@ in6_setmaxmtu(void)
}
IFNET_RUNLOCK();
if (maxmtu) /* update only when maxmtu is positive */
- in6_maxmtu = maxmtu;
+ V_in6_maxmtu = maxmtu;
}
/*
diff --git a/sys/netinet6/in6_gif.c b/sys/netinet6/in6_gif.c
index d05f8a3..1220244 100644
--- a/sys/netinet6/in6_gif.c
+++ b/sys/netinet6/in6_gif.c
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
#include <sys/protosw.h>
#include <sys/malloc.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/route.h>
@@ -175,7 +176,7 @@ in6_gif_output(struct ifnet *ifp,
ip6->ip6_vfc |= IPV6_VERSION;
ip6->ip6_plen = htons((u_short)m->m_pkthdr.len);
ip6->ip6_nxt = proto;
- ip6->ip6_hlim = ip6_gif_hlim;
+ ip6->ip6_hlim = V_ip6_gif_hlim;
ip6->ip6_src = sin6_src->sin6_addr;
/* bidirectional configured tunnel mode */
if (!IN6_IS_ADDR_UNSPECIFIED(&sin6_dst->sin6_addr))
@@ -258,14 +259,14 @@ in6_gif_input(struct mbuf **mp, int *offp, int proto)
sc = (struct gif_softc *)encap_getarg(m);
if (sc == NULL) {
m_freem(m);
- ip6stat.ip6s_nogif++;
+ V_ip6stat.ip6s_nogif++;
return IPPROTO_DONE;
}
gifp = GIF2IFP(sc);
if (gifp == NULL || (gifp->if_flags & IFF_UP) == 0) {
m_freem(m);
- ip6stat.ip6s_nogif++;
+ V_ip6stat.ip6s_nogif++;
return IPPROTO_DONE;
}
@@ -320,7 +321,7 @@ in6_gif_input(struct mbuf **mp, int *offp, int proto)
break;
default:
- ip6stat.ip6s_nogif++;
+ V_ip6stat.ip6s_nogif++;
m_freem(m);
return IPPROTO_DONE;
}
diff --git a/sys/netinet6/in6_ifattach.c b/sys/netinet6/in6_ifattach.c
index 8714377..a1b832b 100644
--- a/sys/netinet6/in6_ifattach.c
+++ b/sys/netinet6/in6_ifattach.c
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/syslog.h>
#include <sys/md5.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_dl.h>
@@ -108,7 +109,7 @@ get_rand_ifid(struct ifnet *ifp, struct in6_addr *in6)
int hostnamelen;
mtx_lock(&hostname_mtx);
- hostnamelen = strlen(hostname);
+ hostnamelen = strlen(V_hostname);
#if 0
/* we need at least several letters as seed for ifid */
if (hostnamelen < 3)
@@ -118,7 +119,7 @@ get_rand_ifid(struct ifnet *ifp, struct in6_addr *in6)
/* generate 8 bytes of pseudo-random value. */
bzero(&ctxt, sizeof(ctxt));
MD5Init(&ctxt);
- MD5Update(&ctxt, hostname, hostnamelen);
+ MD5Update(&ctxt, V_hostname, hostnamelen);
mtx_unlock(&hostname_mtx);
MD5Final(digest, &ctxt);
@@ -375,7 +376,7 @@ get_ifid(struct ifnet *ifp0, struct ifnet *altifp,
/* next, try to get it from some other hardware interface */
IFNET_RLOCK();
- for (ifp = ifnet.tqh_first; ifp; ifp = ifp->if_list.tqe_next) {
+ for (ifp = V_ifnet.tqh_first; ifp; ifp = ifp->if_list.tqe_next) {
if (ifp == ifp0)
continue;
if (in6_get_hw_ifid(ifp, in6) != 0)
@@ -701,7 +702,7 @@ in6_ifattach(struct ifnet *ifp, struct ifnet *altifp)
/*
* assign a link-local address, if there's none.
*/
- if (ip6_auto_linklocal && ifp->if_type != IFT_BRIDGE) {
+ if (V_ip6_auto_linklocal && ifp->if_type != IFT_BRIDGE) {
ia = in6ifa_ifpforlinklocal(ifp, 0);
if (ia == NULL) {
if (in6_ifattach_linklocal(ifp, altifp) == 0) {
@@ -717,8 +718,8 @@ statinit:
#endif
/* update dynamically. */
- if (in6_maxmtu < ifp->if_mtu)
- in6_maxmtu = ifp->if_mtu;
+ if (V_in6_maxmtu < ifp->if_mtu)
+ V_in6_maxmtu = ifp->if_mtu;
}
/*
@@ -783,8 +784,8 @@ in6_ifdetach(struct ifnet *ifp)
/* also remove from the IPv6 address chain(itojun&jinmei) */
oia = ia;
- if (oia == (ia = in6_ifaddr))
- in6_ifaddr = ia->ia_next;
+ if (oia == (ia = V_in6_ifaddr))
+ V_in6_ifaddr = ia->ia_next;
else {
while (ia->ia_next && (ia->ia_next != oia))
ia = ia->ia_next;
@@ -800,8 +801,8 @@ in6_ifdetach(struct ifnet *ifp)
IFAFREE(&oia->ia_ifa);
}
- in6_pcbpurgeif0(&udbinfo, ifp);
- in6_pcbpurgeif0(&ripcbinfo, ifp);
+ in6_pcbpurgeif0(&V_udbinfo, ifp);
+ in6_pcbpurgeif0(&V_ripcbinfo, ifp);
/* leave from all multicast groups joined */
in6_purgemaddrs(ifp);
@@ -824,15 +825,15 @@ in6_ifdetach(struct ifnet *ifp)
/* XXX: should not fail */
return;
/* XXX grab lock first to avoid LOR */
- if (rt_tables[0][AF_INET6] != NULL) {
- RADIX_NODE_HEAD_LOCK(rt_tables[0][AF_INET6]);
+ if (V_rt_tables[0][AF_INET6] != NULL) {
+ RADIX_NODE_HEAD_LOCK(V_rt_tables[0][AF_INET6]);
rt = rtalloc1((struct sockaddr *)&sin6, 0, 0UL);
if (rt) {
if (rt->rt_ifp == ifp)
rtexpunge(rt);
RTFREE_LOCKED(rt);
}
- RADIX_NODE_HEAD_UNLOCK(rt_tables[0][AF_INET6]);
+ RADIX_NODE_HEAD_UNLOCK(V_rt_tables[0][AF_INET6]);
}
}
@@ -869,12 +870,12 @@ in6_tmpaddrtimer(void *ignored_arg)
struct ifnet *ifp;
int s = splnet();
- callout_reset(&in6_tmpaddrtimer_ch,
- (ip6_temp_preferred_lifetime - ip6_desync_factor -
- ip6_temp_regen_advance) * hz, in6_tmpaddrtimer, NULL);
+ callout_reset(&V_in6_tmpaddrtimer_ch,
+ (V_ip6_temp_preferred_lifetime - V_ip6_desync_factor -
+ V_ip6_temp_regen_advance) * hz, in6_tmpaddrtimer, NULL);
bzero(nullbuf, sizeof(nullbuf));
- 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)) {
ndi = ND_IFINFO(ifp);
if (bcmp(ndi->randomid, nullbuf, sizeof(nullbuf)) != 0) {
/*
diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c
index 619c087..c60d8f6 100644
--- a/sys/netinet6/in6_pcb.c
+++ b/sys/netinet6/in6_pcb.c
@@ -82,6 +82,7 @@ __FBSDID("$FreeBSD$");
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/jail.h>
+#include <sys/vimage.h>
#include <vm/uma.h>
@@ -124,7 +125,7 @@ in6_pcbbind(register struct inpcb *inp, struct sockaddr *nam,
INP_INFO_WLOCK_ASSERT(pcbinfo);
INP_WLOCK_ASSERT(inp);
- if (!in6_ifaddr) /* XXX broken! */
+ if (!V_in6_ifaddr) /* XXX broken! */
return (EADDRNOTAVAIL);
if (inp->inp_lport || !IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr))
return (EINVAL);
@@ -142,7 +143,7 @@ in6_pcbbind(register struct inpcb *inp, struct sockaddr *nam,
if (nam->sa_family != AF_INET6)
return (EAFNOSUPPORT);
- if ((error = sa6_embedscope(sin6, ip6_use_defzone)) != 0)
+ if ((error = sa6_embedscope(sin6, V_ip6_use_defzone)) != 0)
return(error);
lport = sin6->sin6_port;
@@ -179,8 +180,8 @@ in6_pcbbind(register struct inpcb *inp, struct sockaddr *nam,
struct inpcb *t;
/* GROSS */
- if (ntohs(lport) <= ipport_reservedhigh &&
- ntohs(lport) >= ipport_reservedlow &&
+ if (ntohs(lport) <= V_ipport_reservedhigh &&
+ ntohs(lport) >= V_ipport_reservedlow &&
priv_check_cred(cred, PRIV_NETINET_RESERVEDPORT,
0))
return (EACCES);
@@ -297,12 +298,12 @@ in6_pcbladdr(register struct inpcb *inp, struct sockaddr *nam,
if (sin6->sin6_port == 0)
return (EADDRNOTAVAIL);
- if (sin6->sin6_scope_id == 0 && !ip6_use_defzone)
+ if (sin6->sin6_scope_id == 0 && !V_ip6_use_defzone)
scope_ambiguous = 1;
- if ((error = sa6_embedscope(sin6, ip6_use_defzone)) != 0)
+ if ((error = sa6_embedscope(sin6, V_ip6_use_defzone)) != 0)
return(error);
- if (in6_ifaddr) {
+ if (V_in6_ifaddr) {
/*
* If the destination address is UNSPECIFIED addr,
* use the loopback addr, e.g ::1.
diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c
index 9cf8091..c35a1b6 100644
--- a/sys/netinet6/in6_proto.c
+++ b/sys/netinet6/in6_proto.c
@@ -80,6 +80,7 @@ __FBSDID("$FreeBSD$");
#include <sys/mbuf.h>
#include <sys/systm.h>
#include <sys/sysctl.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/radix.h>
@@ -462,11 +463,11 @@ sysctl_ip6_temppltime(SYSCTL_HANDLER_ARGS)
error = SYSCTL_OUT(req, arg1, sizeof(int));
if (error || !req->newptr)
return (error);
- old = ip6_temp_preferred_lifetime;
+ old = V_ip6_temp_preferred_lifetime;
error = SYSCTL_IN(req, arg1, sizeof(int));
- if (ip6_temp_preferred_lifetime <
- ip6_desync_factor + ip6_temp_regen_advance) {
- ip6_temp_preferred_lifetime = old;
+ if (V_ip6_temp_preferred_lifetime <
+ V_ip6_desync_factor + V_ip6_temp_regen_advance) {
+ V_ip6_temp_preferred_lifetime = old;
return (EINVAL);
}
return (error);
@@ -481,10 +482,10 @@ sysctl_ip6_tempvltime(SYSCTL_HANDLER_ARGS)
error = SYSCTL_OUT(req, arg1, sizeof(int));
if (error || !req->newptr)
return (error);
- old = ip6_temp_valid_lifetime;
+ old = V_ip6_temp_valid_lifetime;
error = SYSCTL_IN(req, arg1, sizeof(int));
- if (ip6_temp_valid_lifetime < ip6_temp_preferred_lifetime) {
- ip6_temp_preferred_lifetime = old;
+ if (V_ip6_temp_valid_lifetime < V_ip6_temp_preferred_lifetime) {
+ V_ip6_temp_preferred_lifetime = old;
return (EINVAL);
}
return (error);
diff --git a/sys/netinet6/in6_rmx.c b/sys/netinet6/in6_rmx.c
index 2164c33..88c4dec 100644
--- a/sys/netinet6/in6_rmx.c
+++ b/sys/netinet6/in6_rmx.c
@@ -85,6 +85,7 @@ __FBSDID("$FreeBSD$");
#include <sys/mbuf.h>
#include <sys/syslog.h>
#include <sys/callout.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/route.h>
@@ -259,9 +260,9 @@ in6_clsroute(struct radix_node *rn, struct radix_node_head *head)
* If rtq_reallyold is 0, just delete the route without
* waiting for a timeout cycle to kill it.
*/
- if (rtq_reallyold != 0) {
+ if (V_rtq_reallyold != 0) {
rt->rt_flags |= RTPRF_OURS;
- rt->rt_rmx.rmx_expire = time_uptime + rtq_reallyold;
+ rt->rt_rmx.rmx_expire = time_uptime + V_rtq_reallyold;
} else {
rtexpunge(rt);
}
@@ -308,9 +309,9 @@ in6_rtqkill(struct radix_node *rn, void *rock)
} else {
if (ap->updating
&& (rt->rt_rmx.rmx_expire - time_uptime
- > rtq_reallyold)) {
+ > V_rtq_reallyold)) {
rt->rt_rmx.rmx_expire = time_uptime
- + rtq_reallyold;
+ + V_rtq_reallyold;
}
ap->nextstop = lmin(ap->nextstop,
rt->rt_rmx.rmx_expire);
@@ -334,7 +335,7 @@ in6_rtqtimo(void *rock)
arg.found = arg.killed = 0;
arg.rnh = rnh;
- arg.nextstop = time_uptime + rtq_timeout6;
+ arg.nextstop = time_uptime + V_rtq_timeout6;
arg.draining = arg.updating = 0;
RADIX_NODE_HEAD_LOCK(rnh);
rnh->rnh_walktree(rnh, in6_rtqkill, &arg);
@@ -348,18 +349,18 @@ in6_rtqtimo(void *rock)
* than once in rtq_timeout6 seconds, to keep from cranking down too
* hard.
*/
- if ((arg.found - arg.killed > rtq_toomany)
- && (time_uptime - last_adjusted_timeout >= rtq_timeout6)
- && rtq_reallyold > rtq_minreallyold) {
- rtq_reallyold = 2*rtq_reallyold / 3;
- if (rtq_reallyold < rtq_minreallyold) {
- rtq_reallyold = rtq_minreallyold;
+ if ((arg.found - arg.killed > V_rtq_toomany)
+ && (time_uptime - last_adjusted_timeout >= V_rtq_timeout6)
+ && V_rtq_reallyold > V_rtq_minreallyold) {
+ V_rtq_reallyold = 2*V_rtq_reallyold / 3;
+ if (V_rtq_reallyold < V_rtq_minreallyold) {
+ V_rtq_reallyold = V_rtq_minreallyold;
}
last_adjusted_timeout = time_uptime;
#ifdef DIAGNOSTIC
log(LOG_DEBUG, "in6_rtqtimo: adjusted rtq_reallyold to %d",
- rtq_reallyold);
+ V_rtq_reallyold);
#endif
arg.found = arg.killed = 0;
arg.updating = 1;
@@ -370,7 +371,7 @@ in6_rtqtimo(void *rock)
atv.tv_usec = 0;
atv.tv_sec = arg.nextstop - time_uptime;
- callout_reset(&rtq_timer6, tvtohz(&atv), in6_rtqtimo, rock);
+ callout_reset(&V_rtq_timer6, tvtohz(&atv), in6_rtqtimo, rock);
}
/*
@@ -426,14 +427,14 @@ in6_mtutimo(void *rock)
arg.nextstop = time_uptime + 30; /* last resort */
atv.tv_sec = 30;
}
- callout_reset(&rtq_mtutimer, tvtohz(&atv), in6_mtutimo, rock);
+ callout_reset(&V_rtq_mtutimer, tvtohz(&atv), in6_mtutimo, rock);
}
#if 0
void
in6_rtqdrain(void)
{
- struct radix_node_head *rnh = rt_tables[AF_INET6];
+ struct radix_node_head *rnh = V_rt_tables[AF_INET6];
struct rtqk_arg arg;
arg.found = arg.killed = 0;
@@ -469,9 +470,9 @@ in6_inithead(void **head, int off)
rnh->rnh_addaddr = in6_addroute;
rnh->rnh_matchaddr = in6_matroute;
rnh->rnh_close = in6_clsroute;
- callout_init(&rtq_timer6, CALLOUT_MPSAFE);
+ callout_init(&V_rtq_timer6, CALLOUT_MPSAFE);
in6_rtqtimo(rnh); /* kick off timeout first time */
- callout_init(&rtq_mtutimer, CALLOUT_MPSAFE);
+ callout_init(&V_rtq_mtutimer, CALLOUT_MPSAFE);
in6_mtutimo(rnh); /* kick off timeout first time */
return 1;
}
diff --git a/sys/netinet6/in6_src.c b/sys/netinet6/in6_src.c
index 3464445..7a0d7d1 100644
--- a/sys/netinet6/in6_src.c
+++ b/sys/netinet6/in6_src.c
@@ -82,6 +82,7 @@ __FBSDID("$FreeBSD$");
#include <sys/time.h>
#include <sys/kernel.h>
#include <sys/sx.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/route.h>
@@ -142,9 +143,9 @@ static struct in6_addrpolicy *match_addrsel_policy(struct sockaddr_in6 *);
* an entry to the caller for later use.
*/
#define REPLACE(r) do {\
- if ((r) < sizeof(ip6stat.ip6s_sources_rule) / \
- sizeof(ip6stat.ip6s_sources_rule[0])) /* check for safety */ \
- ip6stat.ip6s_sources_rule[(r)]++; \
+ if ((r) < sizeof(V_ip6stat.ip6s_sources_rule) / \
+ sizeof(V_ip6stat.ip6s_sources_rule[0])) /* check for safety */ \
+ V_ip6stat.ip6s_sources_rule[(r)]++; \
/* { \
char ip6buf[INET6_ADDRSTRLEN], ip6b[INET6_ADDRSTRLEN]; \
printf("in6_selectsrc: replace %s with %s by %d\n", ia_best ? ip6_sprintf(ip6buf, &ia_best->ia_addr.sin6_addr) : "none", ip6_sprintf(ip6b, &ia->ia_addr.sin6_addr), (r)); \
@@ -152,9 +153,9 @@ static struct in6_addrpolicy *match_addrsel_policy(struct sockaddr_in6 *);
goto replace; \
} while(0)
#define NEXT(r) do {\
- if ((r) < sizeof(ip6stat.ip6s_sources_rule) / \
- sizeof(ip6stat.ip6s_sources_rule[0])) /* check for safety */ \
- ip6stat.ip6s_sources_rule[(r)]++; \
+ if ((r) < sizeof(V_ip6stat.ip6s_sources_rule) / \
+ sizeof(V_ip6stat.ip6s_sources_rule[0])) /* check for safety */ \
+ V_ip6stat.ip6s_sources_rule[(r)]++; \
/* { \
char ip6buf[INET6_ADDRSTRLEN], ip6b[INET6_ADDRSTRLEN]; \
printf("in6_selectsrc: keep %s against %s by %d\n", ia_best ? ip6_sprintf(ip6buf, &ia_best->ia_addr.sin6_addr) : "none", ip6_sprintf(ip6b, &ia->ia_addr.sin6_addr), (r)); \
@@ -162,9 +163,9 @@ static struct in6_addrpolicy *match_addrsel_policy(struct sockaddr_in6 *);
goto next; /* XXX: we can't use 'continue' here */ \
} while(0)
#define BREAK(r) do { \
- if ((r) < sizeof(ip6stat.ip6s_sources_rule) / \
- sizeof(ip6stat.ip6s_sources_rule[0])) /* check for safety */ \
- ip6stat.ip6s_sources_rule[(r)]++; \
+ if ((r) < sizeof(V_ip6stat.ip6s_sources_rule) / \
+ sizeof(V_ip6stat.ip6s_sources_rule[0])) /* check for safety */ \
+ V_ip6stat.ip6s_sources_rule[(r)]++; \
goto out; /* XXX: we can't use 'break' here */ \
} while(0)
@@ -264,7 +265,7 @@ in6_selectsrc(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
if (*errorp != 0)
return (NULL);
- for (ia = in6_ifaddr; ia; ia = ia->ia_next) {
+ for (ia = V_in6_ifaddr; ia; ia = ia->ia_next) {
int new_scope = -1, new_matchlen = -1;
struct in6_addrpolicy *new_policy = NULL;
u_int32_t srczone, osrczone, dstzone;
@@ -293,7 +294,7 @@ in6_selectsrc(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
(IN6_IFF_NOTREADY | IN6_IFF_ANYCAST | IN6_IFF_DETACHED))) {
continue;
}
- if (!ip6_use_deprecated && IFA6_IS_DEPRECATED(ia))
+ if (!V_ip6_use_deprecated && IFA6_IS_DEPRECATED(ia))
continue;
/* Rule 1: Prefer same address */
@@ -364,7 +365,7 @@ in6_selectsrc(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
*/
if (opts == NULL ||
opts->ip6po_prefer_tempaddr == IP6PO_TEMPADDR_SYSTEM) {
- prefer_tempaddr = ip6_prefer_tempaddr;
+ prefer_tempaddr = V_ip6_prefer_tempaddr;
} else if (opts->ip6po_prefer_tempaddr ==
IP6PO_TEMPADDR_NOTPREFER) {
prefer_tempaddr = 0;
@@ -641,7 +642,7 @@ selectroute(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
error = EHOSTUNREACH;
}
if (error == EHOSTUNREACH)
- ip6stat.ip6s_noroute++;
+ V_ip6stat.ip6s_noroute++;
if (retifp != NULL)
*retifp = ifp;
@@ -754,9 +755,9 @@ in6_selecthlim(struct in6pcb *in6p, struct ifnet *ifp)
if (lifp)
return (ND_IFINFO(lifp)->chlim);
} else
- return (ip6_defhlim);
+ return (V_ip6_defhlim);
}
- return (ip6_defhlim);
+ return (V_ip6_defhlim);
}
/*
@@ -781,19 +782,19 @@ in6_pcbsetport(struct in6_addr *laddr, struct inpcb *inp, struct ucred *cred)
inp->inp_flags |= INP_ANONPORT;
if (inp->inp_flags & INP_HIGHPORT) {
- first = ipport_hifirstauto; /* sysctl */
- last = ipport_hilastauto;
+ first = V_ipport_hifirstauto; /* sysctl */
+ last = V_ipport_hilastauto;
lastport = &pcbinfo->ipi_lasthi;
} else if (inp->inp_flags & INP_LOWPORT) {
error = priv_check_cred(cred, PRIV_NETINET_RESERVEDPORT, 0);
if (error)
return error;
- first = ipport_lowfirstauto; /* 1023 */
- last = ipport_lowlastauto; /* 600 */
+ first = V_ipport_lowfirstauto; /* 1023 */
+ last = V_ipport_lowlastauto; /* 600 */
lastport = &pcbinfo->ipi_lastlow;
} else {
- first = ipport_firstauto; /* sysctl */
- last = ipport_lastauto;
+ first = V_ipport_firstauto; /* sysctl */
+ last = V_ipport_lastauto;
lastport = &pcbinfo->ipi_lastport;
}
/*
@@ -866,8 +867,8 @@ addrsel_policy_init(void)
init_policy_queue();
/* initialize the "last resort" policy */
- bzero(&defaultaddrpolicy, sizeof(defaultaddrpolicy));
- defaultaddrpolicy.label = ADDR_LABEL_NOTAPP;
+ bzero(&V_defaultaddrpolicy, sizeof(V_defaultaddrpolicy));
+ V_defaultaddrpolicy.label = ADDR_LABEL_NOTAPP;
}
static struct in6_addrpolicy *
@@ -879,7 +880,7 @@ lookup_addrsel_policy(struct sockaddr_in6 *key)
match = match_addrsel_policy(key);
if (match == NULL)
- match = &defaultaddrpolicy;
+ match = &V_defaultaddrpolicy;
else
match->use++;
ADDRSEL_UNLOCK();
@@ -965,7 +966,7 @@ static void
init_policy_queue(void)
{
- TAILQ_INIT(&addrsel_policytab);
+ TAILQ_INIT(&V_addrsel_policytab);
}
static int
@@ -979,7 +980,7 @@ add_addrsel_policyent(struct in6_addrpolicy *newpolicy)
ADDRSEL_LOCK();
/* duplication check */
- TAILQ_FOREACH(pol, &addrsel_policytab, ape_entry) {
+ TAILQ_FOREACH(pol, &V_addrsel_policytab, ape_entry) {
if (IN6_ARE_ADDR_EQUAL(&newpolicy->addr.sin6_addr,
&pol->ape_policy.addr.sin6_addr) &&
IN6_ARE_ADDR_EQUAL(&newpolicy->addrmask.sin6_addr,
@@ -996,7 +997,7 @@ add_addrsel_policyent(struct in6_addrpolicy *newpolicy)
/* XXX: should validate entry */
new->ape_policy = *newpolicy;
- TAILQ_INSERT_TAIL(&addrsel_policytab, new, ape_entry);
+ TAILQ_INSERT_TAIL(&V_addrsel_policytab, new, ape_entry);
ADDRSEL_UNLOCK();
ADDRSEL_XUNLOCK();
@@ -1012,7 +1013,7 @@ delete_addrsel_policyent(struct in6_addrpolicy *key)
ADDRSEL_LOCK();
/* search for the entry in the table */
- TAILQ_FOREACH(pol, &addrsel_policytab, ape_entry) {
+ TAILQ_FOREACH(pol, &V_addrsel_policytab, ape_entry) {
if (IN6_ARE_ADDR_EQUAL(&key->addr.sin6_addr,
&pol->ape_policy.addr.sin6_addr) &&
IN6_ARE_ADDR_EQUAL(&key->addrmask.sin6_addr,
@@ -1026,7 +1027,7 @@ delete_addrsel_policyent(struct in6_addrpolicy *key)
return (ESRCH);
}
- TAILQ_REMOVE(&addrsel_policytab, pol, ape_entry);
+ TAILQ_REMOVE(&V_addrsel_policytab, pol, ape_entry);
ADDRSEL_UNLOCK();
ADDRSEL_XUNLOCK();
@@ -1041,7 +1042,7 @@ walk_addrsel_policy(int (*callback)(struct in6_addrpolicy *, void *),
int error = 0;
ADDRSEL_SLOCK();
- TAILQ_FOREACH(pol, &addrsel_policytab, ape_entry) {
+ TAILQ_FOREACH(pol, &V_addrsel_policytab, ape_entry) {
if ((error = (*callback)(&pol->ape_policy, w)) != 0) {
ADDRSEL_SUNLOCK();
return (error);
@@ -1070,7 +1071,7 @@ match_addrsel_policy(struct sockaddr_in6 *key)
int matchlen, bestmatchlen = -1;
u_char *mp, *ep, *k, *p, m;
- TAILQ_FOREACH(pent, &addrsel_policytab, ape_entry) {
+ TAILQ_FOREACH(pent, &V_addrsel_policytab, ape_entry) {
matchlen = 0;
pol = &pent->ape_policy;
diff --git a/sys/netinet6/ip6_forward.c b/sys/netinet6/ip6_forward.c
index 8bf0595..ec25a31 100644
--- a/sys/netinet6/ip6_forward.c
+++ b/sys/netinet6/ip6_forward.c
@@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
#include <sys/time.h>
#include <sys/kernel.h>
#include <sys/syslog.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/route.h>
@@ -117,7 +118,7 @@ ip6_forward(struct mbuf *m, int srcrt)
* before forwarding packet actually.
*/
if (ipsec6_in_reject(m, NULL)) {
- ipsec6stat.in_polvio++;
+ V_ipsec6stat.in_polvio++;
m_freem(m);
return;
}
@@ -132,10 +133,10 @@ ip6_forward(struct mbuf *m, int srcrt)
if ((m->m_flags & (M_BCAST|M_MCAST)) != 0 ||
IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst) ||
IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_src)) {
- ip6stat.ip6s_cantforward++;
+ V_ip6stat.ip6s_cantforward++;
/* XXX in6_ifstat_inc(rt->rt_ifp, ifs6_in_discard) */
- if (ip6_log_time + ip6_log_interval < time_second) {
- ip6_log_time = time_second;
+ if (V_ip6_log_time + V_ip6_log_interval < time_second) {
+ V_ip6_log_time = time_second;
log(LOG_DEBUG,
"cannot forward "
"from %s to %s nxt %d received on %s\n",
@@ -149,7 +150,7 @@ ip6_forward(struct mbuf *m, int srcrt)
}
#ifdef IPSTEALTH
- if (!ip6stealth) {
+ if (!V_ip6stealth) {
#endif
if (ip6->ip6_hlim <= IPV6_HLIMDEC) {
/* XXX in6_ifstat_inc(rt->rt_ifp, ifs6_in_discard) */
@@ -179,8 +180,8 @@ ip6_forward(struct mbuf *m, int srcrt)
sp = ipsec_getpolicybyaddr(m, IPSEC_DIR_OUTBOUND,
IP_FORWARDING, &error);
if (sp == NULL) {
- ipsec6stat.out_inval++;
- ip6stat.ip6s_cantforward++;
+ V_ipsec6stat.out_inval++;
+ V_ip6stat.ip6s_cantforward++;
if (mcopy) {
#if 0
/* XXX: what icmp ? */
@@ -200,8 +201,8 @@ ip6_forward(struct mbuf *m, int srcrt)
/*
* This packet is just discarded.
*/
- ipsec6stat.out_polvio++;
- ip6stat.ip6s_cantforward++;
+ V_ipsec6stat.out_polvio++;
+ V_ip6stat.ip6s_cantforward++;
KEY_FREESP(&sp);
if (mcopy) {
#if 0
@@ -223,7 +224,7 @@ ip6_forward(struct mbuf *m, int srcrt)
if (sp->req == NULL) {
/* XXX should be panic ? */
printf("ip6_forward: No IPsec request specified.\n");
- ip6stat.ip6s_cantforward++;
+ V_ip6stat.ip6s_cantforward++;
KEY_FREESP(&sp);
if (mcopy) {
#if 0
@@ -307,7 +308,7 @@ ip6_forward(struct mbuf *m, int srcrt)
/* don't show these error codes to the user */
break;
}
- ip6stat.ip6s_cantforward++;
+ V_ip6stat.ip6s_cantforward++;
if (mcopy) {
#if 0
/* XXX: what icmp ? */
@@ -352,22 +353,22 @@ ip6_forward(struct mbuf *m, int srcrt)
goto skip_routing;
#endif
- dst = (struct sockaddr_in6 *)&ip6_forward_rt.ro_dst;
+ dst = (struct sockaddr_in6 *)&V_ip6_forward_rt.ro_dst;
if (!srcrt) {
/* ip6_forward_rt.ro_dst.sin6_addr is equal to ip6->ip6_dst */
- if (ip6_forward_rt.ro_rt == 0 ||
- (ip6_forward_rt.ro_rt->rt_flags & RTF_UP) == 0) {
- if (ip6_forward_rt.ro_rt) {
- RTFREE(ip6_forward_rt.ro_rt);
- ip6_forward_rt.ro_rt = 0;
+ if (V_ip6_forward_rt.ro_rt == 0 ||
+ (V_ip6_forward_rt.ro_rt->rt_flags & RTF_UP) == 0) {
+ if (V_ip6_forward_rt.ro_rt) {
+ RTFREE(V_ip6_forward_rt.ro_rt);
+ V_ip6_forward_rt.ro_rt = 0;
}
/* this probably fails but give it a try again */
- rtalloc((struct route *)&ip6_forward_rt);
+ rtalloc((struct route *)&V_ip6_forward_rt);
}
- if (ip6_forward_rt.ro_rt == 0) {
- ip6stat.ip6s_noroute++;
+ if (V_ip6_forward_rt.ro_rt == 0) {
+ V_ip6stat.ip6s_noroute++;
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_noroute);
if (mcopy) {
icmp6_error(mcopy, ICMP6_DST_UNREACH,
@@ -376,20 +377,20 @@ ip6_forward(struct mbuf *m, int srcrt)
m_freem(m);
return;
}
- } else if ((rt = ip6_forward_rt.ro_rt) == 0 ||
+ } else if ((rt = V_ip6_forward_rt.ro_rt) == 0 ||
!IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst, &dst->sin6_addr)) {
- if (ip6_forward_rt.ro_rt) {
- RTFREE(ip6_forward_rt.ro_rt);
- ip6_forward_rt.ro_rt = 0;
+ if (V_ip6_forward_rt.ro_rt) {
+ RTFREE(V_ip6_forward_rt.ro_rt);
+ V_ip6_forward_rt.ro_rt = 0;
}
bzero(dst, sizeof(*dst));
dst->sin6_len = sizeof(struct sockaddr_in6);
dst->sin6_family = AF_INET6;
dst->sin6_addr = ip6->ip6_dst;
- rtalloc((struct route *)&ip6_forward_rt);
- if (ip6_forward_rt.ro_rt == 0) {
- ip6stat.ip6s_noroute++;
+ rtalloc((struct route *)&V_ip6_forward_rt);
+ if (V_ip6_forward_rt.ro_rt == 0) {
+ V_ip6stat.ip6s_noroute++;
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_noroute);
if (mcopy) {
icmp6_error(mcopy, ICMP6_DST_UNREACH,
@@ -399,7 +400,7 @@ ip6_forward(struct mbuf *m, int srcrt)
return;
}
}
- rt = ip6_forward_rt.ro_rt;
+ rt = V_ip6_forward_rt.ro_rt;
#ifdef IPSEC
skip_routing:;
#endif
@@ -416,14 +417,14 @@ ip6_forward(struct mbuf *m, int srcrt)
src_in6 = ip6->ip6_src;
if (in6_setscope(&src_in6, rt->rt_ifp, &outzone)) {
/* XXX: this should not happen */
- ip6stat.ip6s_cantforward++;
- ip6stat.ip6s_badscope++;
+ V_ip6stat.ip6s_cantforward++;
+ V_ip6stat.ip6s_badscope++;
m_freem(m);
return;
}
if (in6_setscope(&src_in6, m->m_pkthdr.rcvif, &inzone)) {
- ip6stat.ip6s_cantforward++;
- ip6stat.ip6s_badscope++;
+ V_ip6stat.ip6s_cantforward++;
+ V_ip6stat.ip6s_badscope++;
m_freem(m);
return;
}
@@ -432,12 +433,12 @@ ip6_forward(struct mbuf *m, int srcrt)
&& !ipsecrt
#endif
) {
- ip6stat.ip6s_cantforward++;
- ip6stat.ip6s_badscope++;
+ V_ip6stat.ip6s_cantforward++;
+ V_ip6stat.ip6s_badscope++;
in6_ifstat_inc(rt->rt_ifp, ifs6_in_discard);
- if (ip6_log_time + ip6_log_interval < time_second) {
- ip6_log_time = time_second;
+ if (V_ip6_log_time + V_ip6_log_interval < time_second) {
+ V_ip6_log_time = time_second;
log(LOG_DEBUG,
"cannot forward "
"src %s, dst %s, nxt %d, rcvif %s, outif %s\n",
@@ -464,8 +465,8 @@ ip6_forward(struct mbuf *m, int srcrt)
if (in6_setscope(&dst_in6, m->m_pkthdr.rcvif, &inzone) != 0 ||
in6_setscope(&dst_in6, rt->rt_ifp, &outzone) != 0 ||
inzone != outzone) {
- ip6stat.ip6s_cantforward++;
- ip6stat.ip6s_badscope++;
+ V_ip6stat.ip6s_cantforward++;
+ V_ip6stat.ip6s_badscope++;
m_freem(m);
return;
}
@@ -523,7 +524,7 @@ ip6_forward(struct mbuf *m, int srcrt)
* Also, don't send redirect if forwarding using a route
* modified by a redirect.
*/
- if (ip6_sendredirects && rt->rt_ifp == m->m_pkthdr.rcvif && !srcrt &&
+ if (V_ip6_sendredirects && rt->rt_ifp == m->m_pkthdr.rcvif && !srcrt &&
#ifdef IPSEC
!ipsecrt &&
#endif /* IPSEC */
@@ -607,12 +608,12 @@ pass:
error = nd6_output(rt->rt_ifp, origifp, m, dst, rt);
if (error) {
in6_ifstat_inc(rt->rt_ifp, ifs6_out_discard);
- ip6stat.ip6s_cantforward++;
+ V_ip6stat.ip6s_cantforward++;
} else {
- ip6stat.ip6s_forward++;
+ V_ip6stat.ip6s_forward++;
in6_ifstat_inc(rt->rt_ifp, ifs6_out_forward);
if (type)
- ip6stat.ip6s_redirectsent++;
+ V_ip6stat.ip6s_redirectsent++;
else {
if (mcopy)
goto freecopy;
diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c
index e6ca375..6bd9557 100644
--- a/sys/netinet6/ip6_input.c
+++ b/sys/netinet6/ip6_input.c
@@ -80,6 +80,7 @@ __FBSDID("$FreeBSD$");
#include <sys/time.h>
#include <sys/kernel.h>
#include <sys/syslog.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_types.h>
@@ -178,14 +179,14 @@ ip6_init(void)
printf("%s: WARNING: unable to register pfil hook, "
"error %d\n", __func__, i);
- ip6intrq.ifq_maxlen = ip6qmaxlen;
+ ip6intrq.ifq_maxlen = V_ip6qmaxlen;
mtx_init(&ip6intrq.ifq_mtx, "ip6_inq", NULL, MTX_DEF);
netisr_register(NETISR_IPV6, ip6_input, &ip6intrq, 0);
scope6_init();
addrsel_policy_init();
nd6_init();
frag6_init();
- ip6_desync_factor = arc4random() % MAX_TEMP_DESYNC_FACTOR;
+ V_ip6_desync_factor = arc4random() % MAX_TEMP_DESYNC_FACTOR;
}
static void
@@ -193,14 +194,14 @@ ip6_init2(void *dummy)
{
/* nd6_timer_init */
- callout_init(&nd6_timer_ch, 0);
- callout_reset(&nd6_timer_ch, hz, nd6_timer, NULL);
+ callout_init(&V_nd6_timer_ch, 0);
+ callout_reset(&V_nd6_timer_ch, hz, nd6_timer, NULL);
/* timer for regeneranation of temporary addresses randomize ID */
- callout_init(&in6_tmpaddrtimer_ch, 0);
- callout_reset(&in6_tmpaddrtimer_ch,
- (ip6_temp_preferred_lifetime - ip6_desync_factor -
- ip6_temp_regen_advance) * hz,
+ callout_init(&V_in6_tmpaddrtimer_ch, 0);
+ callout_reset(&V_in6_tmpaddrtimer_ch,
+ (V_ip6_temp_preferred_lifetime - V_ip6_desync_factor -
+ V_ip6_temp_regen_advance) * hz,
in6_tmpaddrtimer, NULL);
}
@@ -244,20 +245,20 @@ ip6_input(struct mbuf *m)
*/
if (m->m_flags & M_EXT) {
if (m->m_next)
- ip6stat.ip6s_mext2m++;
+ V_ip6stat.ip6s_mext2m++;
else
- ip6stat.ip6s_mext1++;
+ V_ip6stat.ip6s_mext1++;
} else {
-#define M2MMAX (sizeof(ip6stat.ip6s_m2m)/sizeof(ip6stat.ip6s_m2m[0]))
+#define M2MMAX (sizeof(V_ip6stat.ip6s_m2m)/sizeof(V_ip6stat.ip6s_m2m[0]))
if (m->m_next) {
if (m->m_flags & M_LOOP) {
- ip6stat.ip6s_m2m[loif[0].if_index]++; /* XXX */
+ V_ip6stat.ip6s_m2m[V_loif[0].if_index]++; /* XXX */
} else if (m->m_pkthdr.rcvif->if_index < M2MMAX)
- ip6stat.ip6s_m2m[m->m_pkthdr.rcvif->if_index]++;
+ V_ip6stat.ip6s_m2m[m->m_pkthdr.rcvif->if_index]++;
else
- ip6stat.ip6s_m2m[0]++;
+ V_ip6stat.ip6s_m2m[0]++;
} else
- ip6stat.ip6s_m1++;
+ V_ip6stat.ip6s_m1++;
#undef M2MMAX
}
@@ -268,7 +269,7 @@ ip6_input(struct mbuf *m)
}
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_receive);
- ip6stat.ip6s_total++;
+ V_ip6stat.ip6s_total++;
#ifndef PULLDOWN_TEST
/*
@@ -306,7 +307,7 @@ ip6_input(struct mbuf *m)
struct ifnet *inifp;
inifp = m->m_pkthdr.rcvif;
if ((m = m_pullup(m, sizeof(struct ip6_hdr))) == NULL) {
- ip6stat.ip6s_toosmall++;
+ V_ip6stat.ip6s_toosmall++;
in6_ifstat_inc(inifp, ifs6_in_hdrerr);
return;
}
@@ -315,12 +316,12 @@ ip6_input(struct mbuf *m)
ip6 = mtod(m, struct ip6_hdr *);
if ((ip6->ip6_vfc & IPV6_VERSION_MASK) != IPV6_VERSION) {
- ip6stat.ip6s_badvers++;
+ V_ip6stat.ip6s_badvers++;
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_hdrerr);
goto bad;
}
- ip6stat.ip6s_nxthist[ip6->ip6_nxt]++;
+ V_ip6stat.ip6s_nxthist[ip6->ip6_nxt]++;
/*
* Check against address spoofing/corruption.
@@ -330,7 +331,7 @@ ip6_input(struct mbuf *m)
/*
* XXX: "badscope" is not very suitable for a multicast source.
*/
- ip6stat.ip6s_badscope++;
+ V_ip6stat.ip6s_badscope++;
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_addrerr);
goto bad;
}
@@ -342,7 +343,7 @@ ip6_input(struct mbuf *m)
* because ip6_mloopback() passes the "actual" interface
* as the outgoing/incoming interface.
*/
- ip6stat.ip6s_badscope++;
+ V_ip6stat.ip6s_badscope++;
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_addrerr);
goto bad;
}
@@ -367,7 +368,7 @@ ip6_input(struct mbuf *m)
*/
if (IN6_IS_ADDR_V4MAPPED(&ip6->ip6_src) ||
IN6_IS_ADDR_V4MAPPED(&ip6->ip6_dst)) {
- ip6stat.ip6s_badscope++;
+ V_ip6stat.ip6s_badscope++;
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_addrerr);
goto bad;
}
@@ -381,7 +382,7 @@ ip6_input(struct mbuf *m)
*/
if (IN6_IS_ADDR_V4COMPAT(&ip6->ip6_src) ||
IN6_IS_ADDR_V4COMPAT(&ip6->ip6_dst)) {
- ip6stat.ip6s_badscope++;
+ V_ip6stat.ip6s_badscope++;
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_addrerr);
goto bad;
}
@@ -419,12 +420,12 @@ passin:
* is not loopback.
*/
if (in6_clearscope(&ip6->ip6_src) || in6_clearscope(&ip6->ip6_dst)) {
- ip6stat.ip6s_badscope++; /* XXX */
+ V_ip6stat.ip6s_badscope++; /* XXX */
goto bad;
}
if (in6_setscope(&ip6->ip6_src, m->m_pkthdr.rcvif, NULL) ||
in6_setscope(&ip6->ip6_dst, m->m_pkthdr.rcvif, NULL)) {
- ip6stat.ip6s_badscope++;
+ V_ip6stat.ip6s_badscope++;
goto bad;
}
@@ -443,8 +444,8 @@ passin:
if (in6m)
ours = 1;
else if (!ip6_mrouter) {
- ip6stat.ip6s_notmember++;
- ip6stat.ip6s_cantforward++;
+ V_ip6stat.ip6s_notmember++;
+ V_ip6stat.ip6s_cantforward++;
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_discard);
goto bad;
}
@@ -455,28 +456,28 @@ passin:
/*
* Unicast check
*/
- if (ip6_forward_rt.ro_rt != NULL &&
- (ip6_forward_rt.ro_rt->rt_flags & RTF_UP) != 0 &&
+ if (V_ip6_forward_rt.ro_rt != NULL &&
+ (V_ip6_forward_rt.ro_rt->rt_flags & RTF_UP) != 0 &&
IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst,
- &((struct sockaddr_in6 *)(&ip6_forward_rt.ro_dst))->sin6_addr))
- ip6stat.ip6s_forward_cachehit++;
+ &((struct sockaddr_in6 *)(&V_ip6_forward_rt.ro_dst))->sin6_addr))
+ V_ip6stat.ip6s_forward_cachehit++;
else {
struct sockaddr_in6 *dst6;
- if (ip6_forward_rt.ro_rt) {
+ if (V_ip6_forward_rt.ro_rt) {
/* route is down or destination is different */
- ip6stat.ip6s_forward_cachemiss++;
- RTFREE(ip6_forward_rt.ro_rt);
- ip6_forward_rt.ro_rt = 0;
+ V_ip6stat.ip6s_forward_cachemiss++;
+ RTFREE(V_ip6_forward_rt.ro_rt);
+ V_ip6_forward_rt.ro_rt = 0;
}
- bzero(&ip6_forward_rt.ro_dst, sizeof(struct sockaddr_in6));
- dst6 = (struct sockaddr_in6 *)&ip6_forward_rt.ro_dst;
+ bzero(&V_ip6_forward_rt.ro_dst, sizeof(struct sockaddr_in6));
+ dst6 = (struct sockaddr_in6 *)&V_ip6_forward_rt.ro_dst;
dst6->sin6_len = sizeof(struct sockaddr_in6);
dst6->sin6_family = AF_INET6;
dst6->sin6_addr = ip6->ip6_dst;
- rtalloc((struct route *)&ip6_forward_rt);
+ rtalloc((struct route *)&V_ip6_forward_rt);
}
#define rt6_key(r) ((struct sockaddr_in6 *)((r)->rt_nodes->rn_key))
@@ -501,14 +502,14 @@ passin:
* while it would be less efficient. Or, should we rather install a
* reject route for such a case?
*/
- if (ip6_forward_rt.ro_rt &&
- (ip6_forward_rt.ro_rt->rt_flags &
+ if (V_ip6_forward_rt.ro_rt &&
+ (V_ip6_forward_rt.ro_rt->rt_flags &
(RTF_HOST|RTF_GATEWAY)) == RTF_HOST &&
#ifdef RTF_WASCLONED
- !(ip6_forward_rt.ro_rt->rt_flags & RTF_WASCLONED) &&
+ !(V_ip6_forward_rt.ro_rt->rt_flags & RTF_WASCLONED) &&
#endif
#ifdef RTF_CLONED
- !(ip6_forward_rt.ro_rt->rt_flags & RTF_CLONED) &&
+ !(V_ip6_forward_rt.ro_rt->rt_flags & RTF_CLONED) &&
#endif
#if 0
/*
@@ -517,11 +518,11 @@ passin:
* already done through looking up the routing table.
*/
IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst,
- &rt6_key(ip6_forward_rt.ro_rt)->sin6_addr)
+ &rt6_key(V_ip6_forward_rt.ro_rt)->sin6_addr)
#endif
- ip6_forward_rt.ro_rt->rt_ifp->if_type == IFT_LOOP) {
+ V_ip6_forward_rt.ro_rt->rt_ifp->if_type == IFT_LOOP) {
struct in6_ifaddr *ia6 =
- (struct in6_ifaddr *)ip6_forward_rt.ro_rt->rt_ifa;
+ (struct in6_ifaddr *)V_ip6_forward_rt.ro_rt->rt_ifa;
/*
* record address information into m_tag.
@@ -556,12 +557,12 @@ passin:
/*
* FAITH (Firewall Aided Internet Translator)
*/
- if (ip6_keepfaith) {
- if (ip6_forward_rt.ro_rt && ip6_forward_rt.ro_rt->rt_ifp
- && ip6_forward_rt.ro_rt->rt_ifp->if_type == IFT_FAITH) {
+ if (V_ip6_keepfaith) {
+ if (V_ip6_forward_rt.ro_rt && V_ip6_forward_rt.ro_rt->rt_ifp
+ && V_ip6_forward_rt.ro_rt->rt_ifp->if_type == IFT_FAITH) {
/* XXX do we need more sanity checks? */
ours = 1;
- deliverifp = ip6_forward_rt.ro_rt->rt_ifp; /* faith */
+ deliverifp = V_ip6_forward_rt.ro_rt->rt_ifp; /* faith */
goto hbhcheck;
}
}
@@ -570,8 +571,8 @@ passin:
* Now there is no reason to process the packet if it's not our own
* and we're not a router.
*/
- if (!ip6_forwarding) {
- ip6stat.ip6s_cantforward++;
+ if (!V_ip6_forwarding) {
+ V_ip6stat.ip6s_cantforward++;
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_discard);
goto bad;
}
@@ -628,7 +629,7 @@ passin:
* contained, ip6_hopopts_input() must set a valid
* (non-zero) payload length to the variable plen.
*/
- ip6stat.ip6s_badoptions++;
+ V_ip6stat.ip6s_badoptions++;
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_discard);
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_hdrerr);
icmp6_error(m, ICMP6_PARAM_PROB,
@@ -643,7 +644,7 @@ passin:
IP6_EXTHDR_GET(hbh, struct ip6_hbh *, m, sizeof(struct ip6_hdr),
sizeof(struct ip6_hbh));
if (hbh == NULL) {
- ip6stat.ip6s_tooshort++;
+ V_ip6stat.ip6s_tooshort++;
return;
}
#endif
@@ -656,7 +657,7 @@ passin:
* case we should pass the packet to the multicast routing
* daemon.
*/
- if (rtalert != ~0 && ip6_forwarding) {
+ if (rtalert != ~0 && V_ip6_forwarding) {
switch (rtalert) {
case IP6OPT_RTALERT_MLD:
ours = 1;
@@ -679,7 +680,7 @@ passin:
* Drop packet if shorter than we expect.
*/
if (m->m_pkthdr.len - sizeof(struct ip6_hdr) < plen) {
- ip6stat.ip6s_tooshort++;
+ V_ip6stat.ip6s_tooshort++;
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_truncated);
goto bad;
}
@@ -705,7 +706,7 @@ passin:
*/
if (ip6_mrouter && ip6_mforward &&
ip6_mforward(ip6, m->m_pkthdr.rcvif, m)) {
- ip6stat.ip6s_cantforward++;
+ V_ip6stat.ip6s_cantforward++;
m_freem(m);
return;
}
@@ -731,7 +732,7 @@ passin:
*/
if (IN6_IS_ADDR_V4MAPPED(&ip6->ip6_src) ||
IN6_IS_ADDR_V4MAPPED(&ip6->ip6_dst)) {
- ip6stat.ip6s_badscope++;
+ V_ip6stat.ip6s_badscope++;
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_addrerr);
goto bad;
}
@@ -739,13 +740,13 @@ passin:
/*
* Tell launch routine the next header
*/
- ip6stat.ip6s_delivered++;
+ V_ip6stat.ip6s_delivered++;
in6_ifstat_inc(deliverifp, ifs6_in_deliver);
nest = 0;
while (nxt != IPPROTO_DONE) {
- if (ip6_hdrnestlimit && (++nest > ip6_hdrnestlimit)) {
- ip6stat.ip6s_toomanyhdr++;
+ if (V_ip6_hdrnestlimit && (++nest > V_ip6_hdrnestlimit)) {
+ V_ip6stat.ip6s_toomanyhdr++;
goto bad;
}
@@ -754,7 +755,7 @@ passin:
* more sanity checks in header chain processing.
*/
if (m->m_pkthdr.len < off) {
- ip6stat.ip6s_tooshort++;
+ V_ip6stat.ip6s_tooshort++;
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_truncated);
goto bad;
}
@@ -829,14 +830,14 @@ ip6_hopopts_input(u_int32_t *plenp, u_int32_t *rtalertp,
IP6_EXTHDR_GET(hbh, struct ip6_hbh *, m,
sizeof(struct ip6_hdr), sizeof(struct ip6_hbh));
if (hbh == NULL) {
- ip6stat.ip6s_tooshort++;
+ V_ip6stat.ip6s_tooshort++;
return -1;
}
hbhlen = (hbh->ip6h_len + 1) << 3;
IP6_EXTHDR_GET(hbh, struct ip6_hbh *, m, sizeof(struct ip6_hdr),
hbhlen);
if (hbh == NULL) {
- ip6stat.ip6s_tooshort++;
+ V_ip6stat.ip6s_tooshort++;
return -1;
}
#endif
@@ -881,7 +882,7 @@ ip6_process_hopopts(struct mbuf *m, u_int8_t *opthead, int hbhlen,
break;
case IP6OPT_PADN:
if (hbhlen < IP6OPT_MINLEN) {
- ip6stat.ip6s_toosmall++;
+ V_ip6stat.ip6s_toosmall++;
goto bad;
}
optlen = *(opt + 1) + 2;
@@ -889,7 +890,7 @@ ip6_process_hopopts(struct mbuf *m, u_int8_t *opthead, int hbhlen,
case IP6OPT_ROUTER_ALERT:
/* XXX may need check for alignment */
if (hbhlen < IP6OPT_RTALERT_LEN) {
- ip6stat.ip6s_toosmall++;
+ V_ip6stat.ip6s_toosmall++;
goto bad;
}
if (*(opt + 1) != IP6OPT_RTALERT_LEN - 2) {
@@ -906,7 +907,7 @@ ip6_process_hopopts(struct mbuf *m, u_int8_t *opthead, int hbhlen,
case IP6OPT_JUMBO:
/* XXX may need check for alignment */
if (hbhlen < IP6OPT_JUMBO_LEN) {
- ip6stat.ip6s_toosmall++;
+ V_ip6stat.ip6s_toosmall++;
goto bad;
}
if (*(opt + 1) != IP6OPT_JUMBO_LEN - 2) {
@@ -924,7 +925,7 @@ ip6_process_hopopts(struct mbuf *m, u_int8_t *opthead, int hbhlen,
*/
ip6 = mtod(m, struct ip6_hdr *);
if (ip6->ip6_plen) {
- ip6stat.ip6s_badoptions++;
+ V_ip6stat.ip6s_badoptions++;
icmp6_error(m, ICMP6_PARAM_PROB,
ICMP6_PARAMPROB_HEADER,
erroff + opt - opthead);
@@ -948,7 +949,7 @@ ip6_process_hopopts(struct mbuf *m, u_int8_t *opthead, int hbhlen,
* there's no explicit mention in specification.
*/
if (*plenp != 0) {
- ip6stat.ip6s_badoptions++;
+ V_ip6stat.ip6s_badoptions++;
icmp6_error(m, ICMP6_PARAM_PROB,
ICMP6_PARAMPROB_HEADER,
erroff + opt + 2 - opthead);
@@ -960,7 +961,7 @@ ip6_process_hopopts(struct mbuf *m, u_int8_t *opthead, int hbhlen,
* jumbo payload length must be larger than 65535.
*/
if (jumboplen <= IPV6_MAXPACKET) {
- ip6stat.ip6s_badoptions++;
+ V_ip6stat.ip6s_badoptions++;
icmp6_error(m, ICMP6_PARAM_PROB,
ICMP6_PARAMPROB_HEADER,
erroff + opt + 2 - opthead);
@@ -971,7 +972,7 @@ ip6_process_hopopts(struct mbuf *m, u_int8_t *opthead, int hbhlen,
break;
default: /* unknown option */
if (hbhlen < IP6OPT_MINLEN) {
- ip6stat.ip6s_toosmall++;
+ V_ip6stat.ip6s_toosmall++;
goto bad;
}
optlen = ip6_unknown_opt(opt, m,
@@ -1008,11 +1009,11 @@ ip6_unknown_opt(u_int8_t *optp, struct mbuf *m, int off)
m_freem(m);
return (-1);
case IP6OPT_TYPE_FORCEICMP: /* send ICMP even if multicasted */
- ip6stat.ip6s_badoptions++;
+ V_ip6stat.ip6s_badoptions++;
icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_OPTION, off);
return (-1);
case IP6OPT_TYPE_ICMP: /* send ICMP if not multicasted */
- ip6stat.ip6s_badoptions++;
+ V_ip6stat.ip6s_badoptions++;
ip6 = mtod(m, struct ip6_hdr *);
if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst) ||
(m->m_flags & (M_BCAST|M_MCAST)))
@@ -1151,14 +1152,14 @@ ip6_savecontrol(struct inpcb *in6p, struct mbuf *m, struct mbuf **mp)
ext = ip6_pullexthdr(m, sizeof(struct ip6_hdr),
ip6->ip6_nxt);
if (ext == NULL) {
- ip6stat.ip6s_tooshort++;
+ V_ip6stat.ip6s_tooshort++;
return;
}
hbh = mtod(ext, struct ip6_hbh *);
hbhlen = (hbh->ip6h_len + 1) << 3;
if (hbhlen != ext->m_len) {
m_freem(ext);
- ip6stat.ip6s_tooshort++;
+ V_ip6stat.ip6s_tooshort++;
return;
}
#endif
@@ -1225,7 +1226,7 @@ ip6_savecontrol(struct inpcb *in6p, struct mbuf *m, struct mbuf **mp)
#else
ext = ip6_pullexthdr(m, off, nxt);
if (ext == NULL) {
- ip6stat.ip6s_tooshort++;
+ V_ip6stat.ip6s_tooshort++;
return;
}
ip6e = mtod(ext, struct ip6_ext *);
@@ -1235,7 +1236,7 @@ ip6_savecontrol(struct inpcb *in6p, struct mbuf *m, struct mbuf **mp)
elen = (ip6e->ip6e_len + 1) << 3;
if (elen != ext->m_len) {
m_freem(ext);
- ip6stat.ip6s_tooshort++;
+ V_ip6stat.ip6s_tooshort++;
return;
}
#endif
diff --git a/sys/netinet6/ip6_ipsec.c b/sys/netinet6/ip6_ipsec.c
index 9867e66..a8aaedb 100644
--- a/sys/netinet6/ip6_ipsec.c
+++ b/sys/netinet6/ip6_ipsec.c
@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/sysctl.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/route.h>
@@ -129,7 +130,7 @@ ip6_ipsec_fwd(struct mbuf *m)
KEY_FREESP(&sp);
splx(s);
if (error) {
- ip6stat.ip6s_cantforward++;
+ V_ip6stat.ip6s_cantforward++;
return 1;
}
#endif /* IPSEC */
diff --git a/sys/netinet6/ip6_mroute.c b/sys/netinet6/ip6_mroute.c
index 1465a90..1b234c7 100644
--- a/sys/netinet6/ip6_mroute.c
+++ b/sys/netinet6/ip6_mroute.c
@@ -101,6 +101,7 @@ __FBSDID("$FreeBSD$");
#include <sys/syslog.h>
#include <sys/systm.h>
#include <sys/time.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_types.h>
@@ -382,7 +383,7 @@ X_ip6_mrouter_get(struct socket *so, struct sockopt *sopt)
switch (sopt->sopt_name) {
case MRT6_PIM:
- error = sooptcopyout(sopt, &pim6, sizeof(pim6));
+ error = sooptcopyout(sopt, &V_pim6, sizeof(V_pim6));
break;
}
return (error);
@@ -454,7 +455,7 @@ set_pim6(int *i)
if ((*i != 1) && (*i != 0))
return (EINVAL);
- pim6 = *i;
+ V_pim6 = *i;
return (0);
}
@@ -466,7 +467,7 @@ static int
ip6_mrouter_init(struct socket *so, int v, int cmd)
{
#ifdef MRT6DEBUG
- if (mrt6debug)
+ if (V_mrt6debug)
log(LOG_DEBUG,
"ip6_mrouter_init: so_type = %d, pr_protocol = %d\n",
so->so_type, so->so_proto->pr_protocol);
@@ -483,19 +484,19 @@ ip6_mrouter_init(struct socket *so, int v, int cmd)
return (EADDRINUSE);
ip6_mrouter = so;
- ip6_mrouter_ver = cmd;
+ V_ip6_mrouter_ver = cmd;
bzero((caddr_t)mf6ctable, sizeof(mf6ctable));
bzero((caddr_t)n6expire, sizeof(n6expire));
- pim6 = 0;/* used for stubbing out/in pim stuff */
+ V_pim6 = 0;/* used for stubbing out/in pim stuff */
callout_init(&expire_upcalls_ch, 0);
callout_reset(&expire_upcalls_ch, EXPIRE_TIMEOUT,
expire_upcalls, NULL);
#ifdef MRT6DEBUG
- if (mrt6debug)
+ if (V_mrt6debug)
log(LOG_DEBUG, "ip6_mrouter_init\n");
#endif
@@ -528,7 +529,7 @@ X_ip6_mrouter_done(void)
* XXX: there may be an interface in which the IPv4 multicast
* daemon is not interested...
*/
- if (!ip_mrouter)
+ if (!V_ip_mrouter)
#endif
#endif
{
@@ -542,7 +543,7 @@ X_ip6_mrouter_done(void)
bzero((caddr_t)mif6table, sizeof(mif6table));
nummifs = 0;
- pim6 = 0; /* used to stub out/in pim specific code */
+ V_pim6 = 0; /* used to stub out/in pim specific code */
callout_stop(&expire_upcalls_ch);
@@ -580,12 +581,12 @@ X_ip6_mrouter_done(void)
}
ip6_mrouter = NULL;
- ip6_mrouter_ver = 0;
+ V_ip6_mrouter_ver = 0;
splx(s);
#ifdef MRT6DEBUG
- if (mrt6debug)
+ if (V_mrt6debug)
log(LOG_DEBUG, "ip6_mrouter_done\n");
#endif
@@ -609,7 +610,7 @@ add_m6if(struct mif6ctl *mifcp)
mifp = mif6table + mifcp->mif6c_mifi;
if (mifp->m6_ifp)
return (EADDRINUSE); /* XXX: is it appropriate? */
- if (mifcp->mif6c_pifi == 0 || mifcp->mif6c_pifi > if_index)
+ if (mifcp->mif6c_pifi == 0 || mifcp->mif6c_pifi > V_if_index)
return (ENXIO);
ifp = ifnet_byindex(mifcp->mif6c_pifi);
@@ -661,7 +662,7 @@ add_m6if(struct mif6ctl *mifcp)
nummifs = mifcp->mif6c_mifi + 1;
#ifdef MRT6DEBUG
- if (mrt6debug)
+ if (V_mrt6debug)
log(LOG_DEBUG,
"add_mif #%d, phyint %s\n",
mifcp->mif6c_mifi,
@@ -718,7 +719,7 @@ del_m6if(mifi_t *mifip)
splx(s);
#ifdef MRT6DEBUG
- if (mrt6debug)
+ if (V_mrt6debug)
log(LOG_DEBUG, "del_m6if %d, nummifs %d\n", *mifip, nummifs);
#endif
@@ -744,7 +745,7 @@ add_m6fc(struct mf6cctl *mfccp)
/* If an entry already exists, just update the fields */
if (rt) {
#ifdef MRT6DEBUG
- if (mrt6debug & DEBUG_MFC) {
+ if (V_mrt6debug & DEBUG_MFC) {
log(LOG_DEBUG,
"add_m6fc no upcall h %d o %s g %s p %x\n",
ip6_sprintf(ip6bufo, &mfccp->mf6cc_origin.sin6_addr),
@@ -784,7 +785,7 @@ add_m6fc(struct mf6cctl *mfccp)
mfccp->mf6cc_parent, rt->mf6c_stall);
#ifdef MRT6DEBUG
- if (mrt6debug & DEBUG_MFC)
+ if (V_mrt6debug & DEBUG_MFC)
log(LOG_DEBUG,
"add_m6fc o %s g %s p %x dbg %x\n",
ip6_sprintf(ip6bufo,
@@ -826,7 +827,7 @@ add_m6fc(struct mf6cctl *mfccp)
*/
if (nstl == 0) {
#ifdef MRT6DEBUG
- if (mrt6debug & DEBUG_MFC)
+ if (V_mrt6debug & DEBUG_MFC)
log(LOG_DEBUG,
"add_mfc no upcall h %d o %s g %s p %x\n",
hash,
@@ -930,7 +931,7 @@ del_m6fc(struct mf6cctl *mfccp)
hash = MF6CHASH(origin.sin6_addr, mcastgrp.sin6_addr);
#ifdef MRT6DEBUG
- if (mrt6debug & DEBUG_MFC) {
+ if (V_mrt6debug & DEBUG_MFC) {
char ip6bufo[INET6_ADDRSTRLEN], ip6bufg[INET6_ADDRSTRLEN];
log(LOG_DEBUG,"del_m6fc orig %s mcastgrp %s\n",
ip6_sprintf(ip6bufo, &origin.sin6_addr),
@@ -1009,7 +1010,7 @@ X_ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m)
char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN];
#ifdef MRT6DEBUG
- if (mrt6debug & DEBUG_FORWARD)
+ if (V_mrt6debug & DEBUG_FORWARD)
log(LOG_DEBUG, "ip6_mforward: src %s, dst %s, ifindex %d\n",
ip6_sprintf(ip6bufs, &ip6->ip6_src),
ip6_sprintf(ip6bufd, &ip6->ip6_dst),
@@ -1033,9 +1034,9 @@ X_ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m)
* (although such packets must normally set 1 to the hop limit field).
*/
if (IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_src)) {
- ip6stat.ip6s_cantforward++;
- if (ip6_log_time + ip6_log_interval < time_second) {
- ip6_log_time = time_second;
+ V_ip6stat.ip6s_cantforward++;
+ if (V_ip6_log_time + V_ip6_log_interval < time_second) {
+ V_ip6_log_time = time_second;
log(LOG_DEBUG,
"cannot forward "
"from %s to %s nxt %d received on %s\n",
@@ -1076,7 +1077,7 @@ X_ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m)
mrt6stat.mrt6s_no_route++;
#ifdef MRT6DEBUG
- if (mrt6debug & (DEBUG_FORWARD | DEBUG_MFC))
+ if (V_mrt6debug & (DEBUG_FORWARD | DEBUG_MFC))
log(LOG_DEBUG, "ip6_mforward: no rte s %s g %s\n",
ip6_sprintf(ip6bufs, &ip6->ip6_src),
ip6_sprintf(ip6bufd, &ip6->ip6_dst));
@@ -1155,7 +1156,7 @@ X_ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m)
#ifdef MRT6_OINIT
oim = NULL;
#endif
- switch (ip6_mrouter_ver) {
+ switch (V_ip6_mrouter_ver) {
#ifdef MRT6_OINIT
case MRT6_OINIT:
oim = mtod(mm, struct omrt6msg *);
@@ -1177,7 +1178,7 @@ X_ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m)
}
#ifdef MRT6DEBUG
- if (mrt6debug & DEBUG_FORWARD)
+ if (V_mrt6debug & DEBUG_FORWARD)
log(LOG_DEBUG,
"getting the iif info in the kernel\n");
#endif
@@ -1187,7 +1188,7 @@ X_ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m)
mifp++, mifi++)
;
- switch (ip6_mrouter_ver) {
+ switch (V_ip6_mrouter_ver) {
#ifdef MRT6_OINIT
case MRT6_OINIT:
oim->im6_mif = mifi;
@@ -1287,7 +1288,7 @@ expire_upcalls(void *unused)
mfc->mf6c_expire != 0 &&
--mfc->mf6c_expire == 0) {
#ifdef MRT6DEBUG
- if (mrt6debug & DEBUG_EXPIRE) {
+ if (V_mrt6debug & DEBUG_EXPIRE) {
char ip6bufo[INET6_ADDRSTRLEN];
char ip6bufg[INET6_ADDRSTRLEN];
log(LOG_DEBUG, "expire_upcalls: expiring (%s %s)\n",
@@ -1355,7 +1356,7 @@ ip6_mdq(struct mbuf *m, struct ifnet *ifp, struct mf6c *rt)
if ((mifi >= nummifs) || (mif6table[mifi].m6_ifp != ifp)) {
/* came in the wrong interface */
#ifdef MRT6DEBUG
- if (mrt6debug & DEBUG_FORWARD)
+ if (V_mrt6debug & DEBUG_FORWARD)
log(LOG_DEBUG,
"wrong if: ifid %d mifi %d mififid %x\n",
ifp->if_index, mifi,
@@ -1370,7 +1371,7 @@ ip6_mdq(struct mbuf *m, struct ifnet *ifp, struct mf6c *rt)
*/
/* have to make sure this is a valid mif */
if (mifi < nummifs && mif6table[mifi].m6_ifp)
- if (pim6 && (m->m_flags & M_LOOP) == 0) {
+ if (V_pim6 && (m->m_flags & M_LOOP) == 0) {
/*
* Check the M_LOOP flag to avoid an
* unnecessary PIM assert.
@@ -1397,7 +1398,7 @@ ip6_mdq(struct mbuf *m, struct ifnet *ifp, struct mf6c *rt)
oim = NULL;
#endif
im = NULL;
- switch (ip6_mrouter_ver) {
+ switch (V_ip6_mrouter_ver) {
#ifdef MRT6_OINIT
case MRT6_OINIT:
oim = mtod(mm, struct omrt6msg *);
@@ -1421,7 +1422,7 @@ ip6_mdq(struct mbuf *m, struct ifnet *ifp, struct mf6c *rt)
mifp++, iif++)
;
- switch (ip6_mrouter_ver) {
+ switch (V_ip6_mrouter_ver) {
#ifdef MRT6_OINIT
case MRT6_OINIT:
oim->im6_mif = iif;
@@ -1438,7 +1439,7 @@ ip6_mdq(struct mbuf *m, struct ifnet *ifp, struct mf6c *rt)
if (socket_send(ip6_mrouter, mm, &sin6) < 0) {
#ifdef MRT6DEBUG
- if (mrt6debug)
+ if (V_mrt6debug)
log(LOG_WARNING, "mdq, ip6_mrouter socket queue full\n");
#endif
++mrt6stat.mrt6s_upq_sockfull;
@@ -1468,7 +1469,7 @@ ip6_mdq(struct mbuf *m, struct ifnet *ifp, struct mf6c *rt)
dst0 = ip6->ip6_dst;
if ((error = in6_setscope(&src0, ifp, &iszone)) != 0 ||
(error = in6_setscope(&dst0, ifp, &idzone)) != 0) {
- ip6stat.ip6s_badscope++;
+ V_ip6stat.ip6s_badscope++;
return (error);
}
for (mifp = mif6table, mifi = 0; mifi < nummifs; mifp++, mifi++) {
@@ -1488,7 +1489,7 @@ ip6_mdq(struct mbuf *m, struct ifnet *ifp, struct mf6c *rt)
&odzone) ||
iszone != oszone ||
idzone != odzone) {
- ip6stat.ip6s_badscope++;
+ V_ip6stat.ip6s_badscope++;
continue;
}
}
@@ -1547,7 +1548,7 @@ phyint_send(struct ip6_hdr *ip6, struct mif6 *mifp, struct mbuf *m)
IPV6_FORWARDING, &im6o, NULL, NULL);
#ifdef MRT6DEBUG
- if (mrt6debug & DEBUG_XMIT)
+ if (V_mrt6debug & DEBUG_XMIT)
log(LOG_DEBUG, "phyint_send on mif %d err %d\n",
mifp - mif6table, error);
#endif
@@ -1583,7 +1584,7 @@ phyint_send(struct ip6_hdr *ip6, struct mif6 *mifp, struct mbuf *m)
error = (*ifp->if_output)(ifp, mb_copy,
(struct sockaddr *)&ro.ro_dst, NULL);
#ifdef MRT6DEBUG
- if (mrt6debug & DEBUG_XMIT)
+ if (V_mrt6debug & DEBUG_XMIT)
log(LOG_DEBUG, "phyint_send on mif %d err %d\n",
mifp - mif6table, error);
#endif
@@ -1593,11 +1594,11 @@ phyint_send(struct ip6_hdr *ip6, struct mif6 *mifp, struct mbuf *m)
* various router may notify pMTU in multicast, which can be
* a DDoS to a router
*/
- if (ip6_mcast_pmtu)
+ if (V_ip6_mcast_pmtu)
icmp6_error(mb_copy, ICMP6_PACKET_TOO_BIG, 0, linkmtu);
else {
#ifdef MRT6DEBUG
- if (mrt6debug & DEBUG_XMIT) {
+ if (V_mrt6debug & DEBUG_XMIT) {
char ip6bufs[INET6_ADDRSTRLEN];
char ip6bufd[INET6_ADDRSTRLEN];
log(LOG_DEBUG,
@@ -1625,7 +1626,7 @@ register_send(struct ip6_hdr *ip6, struct mif6 *mif, struct mbuf *m)
struct mrt6msg *im6;
#ifdef MRT6DEBUG
- if (mrt6debug) {
+ if (V_mrt6debug) {
char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN];
log(LOG_DEBUG, "** IPv6 register_send **\n src %s dst %s\n",
ip6_sprintf(ip6bufs, &ip6->ip6_src),
@@ -1671,7 +1672,7 @@ register_send(struct ip6_hdr *ip6, struct mif6 *mif, struct mbuf *m)
if (socket_send(ip6_mrouter, mm, &sin6) < 0) {
#ifdef MRT6DEBUG
- if (mrt6debug)
+ if (V_mrt6debug)
log(LOG_WARNING,
"register_send: ip6_mrouter socket queue full\n");
#endif
@@ -1709,7 +1710,7 @@ pim6_input(struct mbuf **mp, int *offp, int proto)
if (pimlen < PIM_MINLEN) {
++pim6stat.pim6s_rcv_tooshort;
#ifdef MRT6DEBUG
- if (mrt6debug & DEBUG_PIM)
+ if (V_mrt6debug & DEBUG_PIM)
log(LOG_DEBUG,"pim6_input: PIM packet too short\n");
#endif
m_freem(m);
@@ -1762,7 +1763,7 @@ pim6_input(struct mbuf **mp, int *offp, int proto)
if (in6_cksum(m, IPPROTO_PIM, off, cksumlen)) {
++pim6stat.pim6s_rcv_badsum;
#ifdef MRT6DEBUG
- if (mrt6debug & DEBUG_PIM)
+ if (V_mrt6debug & DEBUG_PIM)
log(LOG_DEBUG,
"pim6_input: invalid checksum\n");
#endif
@@ -1804,7 +1805,7 @@ pim6_input(struct mbuf **mp, int *offp, int proto)
if ((reg_mif_num >= nummifs) || (reg_mif_num == (mifi_t) -1)) {
#ifdef MRT6DEBUG
- if (mrt6debug & DEBUG_PIM)
+ if (V_mrt6debug & DEBUG_PIM)
log(LOG_DEBUG,
"pim6_input: register mif not set: %d\n",
reg_mif_num);
@@ -1836,7 +1837,7 @@ pim6_input(struct mbuf **mp, int *offp, int proto)
eip6 = (struct ip6_hdr *) (reghdr + 1);
#ifdef MRT6DEBUG
- if (mrt6debug & DEBUG_PIM)
+ if (V_mrt6debug & DEBUG_PIM)
log(LOG_DEBUG,
"pim6_input[register], eip6: %s -> %s, "
"eip6 plen %d\n",
@@ -1861,7 +1862,7 @@ pim6_input(struct mbuf **mp, int *offp, int proto)
if (!IN6_IS_ADDR_MULTICAST(&eip6->ip6_dst)) {
++pim6stat.pim6s_rcv_badregisters;
#ifdef MRT6DEBUG
- if (mrt6debug & DEBUG_PIM)
+ if (V_mrt6debug & DEBUG_PIM)
log(LOG_DEBUG,
"pim6_input: inner packet of register "
"is not multicast %s\n",
@@ -1890,7 +1891,7 @@ pim6_input(struct mbuf **mp, int *offp, int proto)
*/
m_adj(m, off + PIM_MINLEN);
#ifdef MRT6DEBUG
- if (mrt6debug & DEBUG_PIM) {
+ if (V_mrt6debug & DEBUG_PIM) {
log(LOG_DEBUG,
"pim6_input: forwarding decapsulated register: "
"src %s, dst %s, mif %d\n",
diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c
index 492e93b..7c07bdf 100644
--- a/sys/netinet6/ip6_output.c
+++ b/sys/netinet6/ip6_output.c
@@ -78,6 +78,7 @@ __FBSDID("$FreeBSD$");
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/ucred.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/netisr.h>
@@ -460,7 +461,7 @@ skip_ipsec2:;
sa.sin6_len = sizeof(sa);
sa.sin6_addr = addr[0];
if ((error = sa6_embedscope(&sa,
- ip6_use_defzone)) != 0) {
+ V_ip6_use_defzone)) != 0) {
goto bad;
}
ip6->ip6_dst = sa.sin6_addr;
@@ -480,16 +481,16 @@ skip_ipsec2:;
if (IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_src) &&
(flags & IPV6_UNSPECSRC) == 0) {
error = EOPNOTSUPP;
- ip6stat.ip6s_badscope++;
+ V_ip6stat.ip6s_badscope++;
goto bad;
}
if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_src)) {
error = EOPNOTSUPP;
- ip6stat.ip6s_badscope++;
+ V_ip6stat.ip6s_badscope++;
goto bad;
}
- ip6stat.ip6s_localout++;
+ V_ip6stat.ip6s_localout++;
/*
* Route packet.
@@ -527,7 +528,7 @@ again:
if (im6o != NULL)
ip6->ip6_hlim = im6o->im6o_multicast_hlim;
else
- ip6->ip6_hlim = ip6_defmcasthlim;
+ ip6->ip6_hlim = V_ip6_defmcasthlim;
}
#ifdef IPSEC
@@ -612,7 +613,7 @@ again:
&ifp, &rt, 0)) != 0) {
switch (error) {
case EHOSTUNREACH:
- ip6stat.ip6s_noroute++;
+ V_ip6stat.ip6s_noroute++;
break;
case EADDRNOTAVAIL:
default:
@@ -678,7 +679,7 @@ again:
goto routefound;
badscope:
- ip6stat.ip6s_badscope++;
+ V_ip6stat.ip6s_badscope++;
in6_ifstat_inc(origifp, ifs6_out_discard);
if (error == 0)
error = EHOSTUNREACH; /* XXX */
@@ -711,7 +712,7 @@ again:
* Confirm that the outgoing interface supports multicast.
*/
if (!(ifp->if_flags & IFF_MULTICAST)) {
- ip6stat.ip6s_noroute++;
+ V_ip6stat.ip6s_noroute++;
in6_ifstat_inc(ifp, ifs6_out_discard);
error = ENETUNREACH;
goto bad;
@@ -861,7 +862,7 @@ again:
/* If destination is now ourself drop to ip6_input(). */
if (in6_localaddr(&ip6->ip6_dst)) {
if (m->m_pkthdr.rcvif == NULL)
- m->m_pkthdr.rcvif = loif;
+ m->m_pkthdr.rcvif = V_loif;
if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) {
m->m_pkthdr.csum_flags |=
CSUM_DATA_VALID | CSUM_PSEUDO_HDR;
@@ -991,7 +992,7 @@ passout:
if (qslots <= 0 || ((u_int)qslots * (mtu - hlen)
< tlen /* - hlen */)) {
error = ENOBUFS;
- ip6stat.ip6s_odropped++;
+ V_ip6stat.ip6s_odropped++;
goto bad;
}
@@ -1025,7 +1026,7 @@ passout:
MGETHDR(m, M_DONTWAIT, MT_HEADER);
if (!m) {
error = ENOBUFS;
- ip6stat.ip6s_odropped++;
+ V_ip6stat.ip6s_odropped++;
goto sendorfree;
}
m->m_pkthdr.rcvif = NULL;
@@ -1038,7 +1039,7 @@ passout:
m->m_len = sizeof(*mhip6);
error = ip6_insertfraghdr(m0, m, hlen, &ip6f);
if (error) {
- ip6stat.ip6s_odropped++;
+ V_ip6stat.ip6s_odropped++;
goto sendorfree;
}
ip6f->ip6f_offlg = htons((u_short)((off - hlen) & ~7));
@@ -1050,7 +1051,7 @@ passout:
sizeof(*ip6f) - sizeof(struct ip6_hdr)));
if ((m_frgpart = m_copy(m0, off, len)) == 0) {
error = ENOBUFS;
- ip6stat.ip6s_odropped++;
+ V_ip6stat.ip6s_odropped++;
goto sendorfree;
}
m_cat(m, m_frgpart);
@@ -1059,7 +1060,7 @@ passout:
ip6f->ip6f_reserved = 0;
ip6f->ip6f_ident = id;
ip6f->ip6f_nxt = nextproto;
- ip6stat.ip6s_ofragments++;
+ V_ip6stat.ip6s_ofragments++;
in6_ifstat_inc(ifp, ifs6_out_fragcreat);
}
@@ -1088,7 +1089,7 @@ sendorfree:
}
if (error == 0)
- ip6stat.ip6s_fragmented++;
+ V_ip6stat.ip6s_fragmented++;
done:
if (ro == &ip6route && ro->ro_rt) { /* brace necessary for RTFREE */
@@ -2439,7 +2440,7 @@ ip6_setmoptions(int optname, struct ip6_moptions **im6op, struct mbuf *m)
return (ENOBUFS);
*im6op = im6o;
im6o->im6o_multicast_ifp = NULL;
- im6o->im6o_multicast_hlim = ip6_defmcasthlim;
+ im6o->im6o_multicast_hlim = V_ip6_defmcasthlim;
im6o->im6o_multicast_loop = IPV6_DEFAULT_MULTICAST_LOOP;
LIST_INIT(&im6o->im6o_memberships);
}
@@ -2455,7 +2456,7 @@ ip6_setmoptions(int optname, struct ip6_moptions **im6op, struct mbuf *m)
break;
}
bcopy(mtod(m, u_int *), &ifindex, sizeof(ifindex));
- if (ifindex < 0 || if_index < ifindex) {
+ if (ifindex < 0 || V_if_index < ifindex) {
error = ENXIO; /* XXX EINVAL? */
break;
}
@@ -2481,7 +2482,7 @@ ip6_setmoptions(int optname, struct ip6_moptions **im6op, struct mbuf *m)
if (optval < -1 || optval >= 256)
error = EINVAL;
else if (optval == -1)
- im6o->im6o_multicast_hlim = ip6_defmcasthlim;
+ im6o->im6o_multicast_hlim = V_ip6_defmcasthlim;
else
im6o->im6o_multicast_hlim = optval;
break;
@@ -2560,7 +2561,7 @@ ip6_setmoptions(int optname, struct ip6_moptions **im6op, struct mbuf *m)
* If the interface is specified, validate it.
*/
if (mreq->ipv6mr_interface < 0 ||
- if_index < mreq->ipv6mr_interface) {
+ V_if_index < mreq->ipv6mr_interface) {
error = ENXIO; /* XXX EINVAL? */
break;
}
@@ -2624,7 +2625,7 @@ ip6_setmoptions(int optname, struct ip6_moptions **im6op, struct mbuf *m)
* to its ifnet structure.
*/
if (mreq->ipv6mr_interface < 0 ||
- if_index < mreq->ipv6mr_interface) {
+ V_if_index < mreq->ipv6mr_interface) {
error = ENXIO; /* XXX EINVAL? */
break;
}
@@ -2665,7 +2666,7 @@ ip6_setmoptions(int optname, struct ip6_moptions **im6op, struct mbuf *m)
sa6_mc.sin6_family = AF_INET6;
sa6_mc.sin6_len = sizeof(sa6_mc);
sa6_mc.sin6_addr = mreq->ipv6mr_multiaddr;
- error = sa6_embedscope(&sa6_mc, ip6_use_defzone);
+ error = sa6_embedscope(&sa6_mc, V_ip6_use_defzone);
if (error != 0)
break;
mreq->ipv6mr_multiaddr = sa6_mc.sin6_addr;
@@ -2704,7 +2705,7 @@ ip6_setmoptions(int optname, struct ip6_moptions **im6op, struct mbuf *m)
* If all options have default values, no need to keep the mbuf.
*/
if (im6o->im6o_multicast_ifp == NULL &&
- im6o->im6o_multicast_hlim == ip6_defmcasthlim &&
+ im6o->im6o_multicast_hlim == V_ip6_defmcasthlim &&
im6o->im6o_multicast_loop == IPV6_DEFAULT_MULTICAST_LOOP &&
im6o->im6o_memberships.lh_first == NULL) {
free(*im6op, M_IP6MOPTS);
@@ -2739,7 +2740,7 @@ ip6_getmoptions(int optname, struct ip6_moptions *im6o, struct mbuf **mp)
hlim = mtod(*mp, u_int *);
(*mp)->m_len = sizeof(u_int);
if (im6o == NULL)
- *hlim = ip6_defmcasthlim;
+ *hlim = V_ip6_defmcasthlim;
else
*hlim = im6o->im6o_multicast_hlim;
return (0);
@@ -2748,7 +2749,7 @@ ip6_getmoptions(int optname, struct ip6_moptions *im6o, struct mbuf **mp)
loop = mtod(*mp, u_int *);
(*mp)->m_len = sizeof(u_int);
if (im6o == NULL)
- *loop = ip6_defmcasthlim;
+ *loop = V_ip6_defmcasthlim;
else
*loop = im6o->im6o_multicast_loop;
return (0);
@@ -2924,7 +2925,7 @@ ip6_setpktopt(int optname, u_char *buf, int len, struct ip6_pktopts *opt,
}
/* validate the interface index if specified. */
- if (pktinfo->ipi6_ifindex > if_index ||
+ if (pktinfo->ipi6_ifindex > V_if_index ||
pktinfo->ipi6_ifindex < 0) {
return (ENXIO);
}
@@ -3021,7 +3022,7 @@ ip6_setpktopt(int optname, u_char *buf, int len, struct ip6_pktopts *opt,
IN6_IS_ADDR_MULTICAST(&sa6->sin6_addr)) {
return (EINVAL);
}
- if ((error = sa6_embedscope(sa6, ip6_use_defzone))
+ if ((error = sa6_embedscope(sa6, V_ip6_use_defzone))
!= 0) {
return (error);
}
diff --git a/sys/netinet6/mld6.c b/sys/netinet6/mld6.c
index b8f54bf..661724f 100644
--- a/sys/netinet6/mld6.c
+++ b/sys/netinet6/mld6.c
@@ -79,6 +79,7 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/callout.h>
#include <sys/malloc.h>
+#include <sys/vimage.h>
#include <net/if.h>
@@ -128,8 +129,8 @@ mld6_init(void)
hbh_buf[5] = IP6OPT_RTALERT_LEN - 2;
bcopy((caddr_t)&rtalert_code, &hbh_buf[6], sizeof(u_int16_t));
- ip6_initpktopts(&ip6_opts);
- ip6_opts.ip6po_hbh = hbh;
+ ip6_initpktopts(&V_ip6_opts);
+ V_ip6_opts.ip6po_hbh = hbh;
}
static void
@@ -282,7 +283,7 @@ mld6_input(struct mbuf *m, int off)
#else
IP6_EXTHDR_GET(mldh, struct mld_hdr *, m, off, sizeof(*mldh));
if (mldh == NULL) {
- icmp6stat.icp6s_tooshort++;
+ V_icmp6stat.icp6s_tooshort++;
return;
}
#endif
@@ -510,9 +511,9 @@ mld6_sendpkt(struct in6_multi *in6m, int type, const struct in6_addr *dst)
im6o.im6o_multicast_loop = (ip6_mrouter != NULL);
/* increment output statictics */
- icmp6stat.icp6s_outhist[type]++;
+ V_icmp6stat.icp6s_outhist[type]++;
- ip6_output(mh, &ip6_opts, NULL, 0, &im6o, &outif, NULL);
+ ip6_output(mh, &V_ip6_opts, NULL, 0, &im6o, &outif, NULL);
if (outif) {
icmp6_ifstat_inc(outif, ifs6_out_msg);
switch (type) {
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;
diff --git a/sys/netinet6/nd6.h b/sys/netinet6/nd6.h
index 8b932a9..f191d2d 100644
--- a/sys/netinet6/nd6.h
+++ b/sys/netinet6/nd6.h
@@ -340,7 +340,7 @@ extern struct nd_drhead nd_defrouter;
extern struct nd_prhead nd_prefix;
extern int nd6_debug;
-#define nd6log(x) do { if (nd6_debug) log x; } while (/*CONSTCOND*/ 0)
+#define nd6log(x) do { if (V_nd6_debug) log x; } while (/*CONSTCOND*/ 0)
extern struct callout nd6_timer_ch;
diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c
index 86f6ff8..46b3a1e 100644
--- a/sys/netinet6/nd6_nbr.c
+++ b/sys/netinet6/nd6_nbr.c
@@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$");
#include <sys/syslog.h>
#include <sys/queue.h>
#include <sys/callout.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_types.h>
@@ -119,7 +120,7 @@ nd6_ns_input(struct mbuf *m, int off, int icmp6len)
#else
IP6_EXTHDR_GET(nd_ns, struct nd_neighbor_solicit *, m, off, icmp6len);
if (nd_ns == NULL) {
- icmp6stat.icp6s_tooshort++;
+ V_icmp6stat.icp6s_tooshort++;
return;
}
#endif
@@ -315,7 +316,7 @@ nd6_ns_input(struct mbuf *m, int off, int icmp6len)
goto bad;
nd6_na_output(ifp, &in6_all, &taddr6,
((anycast || proxy || !tlladdr) ? 0 : ND_NA_FLAG_OVERRIDE) |
- (ip6_forwarding ? ND_NA_FLAG_ROUTER : 0),
+ (V_ip6_forwarding ? ND_NA_FLAG_ROUTER : 0),
tlladdr, (struct sockaddr *)proxydl);
goto freeit;
}
@@ -325,7 +326,7 @@ nd6_ns_input(struct mbuf *m, int off, int icmp6len)
nd6_na_output(ifp, &saddr6, &taddr6,
((anycast || proxy || !tlladdr) ? 0 : ND_NA_FLAG_OVERRIDE) |
- (ip6_forwarding ? ND_NA_FLAG_ROUTER : 0) | ND_NA_FLAG_SOLICITED,
+ (V_ip6_forwarding ? ND_NA_FLAG_ROUTER : 0) | ND_NA_FLAG_SOLICITED,
tlladdr, (struct sockaddr *)proxydl);
freeit:
m_freem(m);
@@ -338,7 +339,7 @@ nd6_ns_input(struct mbuf *m, int off, int icmp6len)
ip6_sprintf(ip6bufs, &daddr6)));
nd6log((LOG_ERR, "nd6_ns_input: tgt=%s\n",
ip6_sprintf(ip6bufs, &taddr6)));
- icmp6stat.icp6s_badns++;
+ V_icmp6stat.icp6s_badns++;
m_freem(m);
}
@@ -535,7 +536,7 @@ nd6_ns_output(struct ifnet *ifp, const struct in6_addr *daddr6,
ip6_output(m, NULL, &ro, dad ? IPV6_UNSPECSRC : 0, &im6o, NULL, NULL);
icmp6_ifstat_inc(ifp, ifs6_out_msg);
icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit);
- icmp6stat.icp6s_outhist[ND_NEIGHBOR_SOLICIT]++;
+ V_icmp6stat.icp6s_outhist[ND_NEIGHBOR_SOLICIT]++;
if (ro.ro_rt) { /* we don't cache this route. */
RTFREE(ro.ro_rt);
@@ -595,7 +596,7 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
#else
IP6_EXTHDR_GET(nd_na, struct nd_neighbor_advert *, m, off, icmp6len);
if (nd_na == NULL) {
- icmp6stat.icp6s_tooshort++;
+ V_icmp6stat.icp6s_tooshort++;
return;
}
#endif
@@ -700,7 +701,7 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
}
} else {
ln->ln_state = ND6_LLINFO_STALE;
- nd6_llinfo_settimer(ln, (long)nd6_gctimer * hz);
+ nd6_llinfo_settimer(ln, (long)V_nd6_gctimer * hz);
}
if ((ln->ln_router = is_router) != 0) {
/*
@@ -754,7 +755,7 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
*/
if (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);
}
goto freeit;
} else if (is_override /* (2a) */
@@ -784,7 +785,7 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
if (lladdr != NULL && llchange) {
ln->ln_state = ND6_LLINFO_STALE;
nd6_llinfo_settimer(ln,
- (long)nd6_gctimer * hz);
+ (long)V_nd6_gctimer * hz);
}
}
}
@@ -811,7 +812,7 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
dr = defrouter_lookup(in6, ifp);
if (dr)
defrtrlist_del(dr);
- else if (!ip6_forwarding) {
+ else if (!V_ip6_forwarding) {
/*
* Even if the neighbor is not in the default
* router list, the neighbor may be used
@@ -854,7 +855,7 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
return;
bad:
- icmp6stat.icp6s_badna++;
+ V_icmp6stat.icp6s_badna++;
m_freem(m);
}
@@ -1021,7 +1022,7 @@ nd6_na_output(struct ifnet *ifp, const struct in6_addr *daddr6_0,
ip6_output(m, NULL, &ro, 0, &im6o, NULL, NULL);
icmp6_ifstat_inc(ifp, ifs6_out_msg);
icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert);
- icmp6stat.icp6s_outhist[ND_NEIGHBOR_ADVERT]++;
+ V_icmp6stat.icp6s_outhist[ND_NEIGHBOR_ADVERT]++;
if (ro.ro_rt) { /* we don't cache this route. */
RTFREE(ro.ro_rt);
@@ -1081,7 +1082,7 @@ nd6_dad_find(struct ifaddr *ifa)
{
struct dadq *dp;
- for (dp = dadq.tqh_first; dp; dp = dp->dad_list.tqe_next) {
+ for (dp = V_dadq.tqh_first; dp; dp = dp->dad_list.tqe_next) {
if (dp->dad_ifa == ifa)
return dp;
}
@@ -1113,9 +1114,9 @@ nd6_dad_start(struct ifaddr *ifa, int delay)
struct dadq *dp;
char ip6buf[INET6_ADDRSTRLEN];
- if (!dad_init) {
- TAILQ_INIT(&dadq);
- dad_init++;
+ if (!V_dad_init) {
+ TAILQ_INIT(&V_dadq);
+ V_dad_init++;
}
/*
@@ -1136,7 +1137,7 @@ nd6_dad_start(struct ifaddr *ifa, int delay)
ia->ia6_flags &= ~IN6_IFF_TENTATIVE;
return;
}
- if (!ip6_dad_count) {
+ if (!V_ip6_dad_count) {
ia->ia6_flags &= ~IN6_IFF_TENTATIVE;
return;
}
@@ -1173,7 +1174,7 @@ nd6_dad_start(struct ifaddr *ifa, int delay)
*/
dp->dad_ifa = ifa;
IFAREF(ifa); /* just for safety */
- dp->dad_count = ip6_dad_count;
+ dp->dad_count = V_ip6_dad_count;
dp->dad_ns_icount = dp->dad_na_icount = 0;
dp->dad_ns_ocount = dp->dad_ns_tcount = 0;
if (delay == 0) {
@@ -1193,7 +1194,7 @@ nd6_dad_stop(struct ifaddr *ifa)
{
struct dadq *dp;
- if (!dad_init)
+ if (!V_dad_init)
return;
dp = nd6_dad_find(ifa);
if (!dp) {
@@ -1203,7 +1204,7 @@ nd6_dad_stop(struct ifaddr *ifa)
nd6_dad_stoptimer(dp);
- TAILQ_REMOVE(&dadq, (struct dadq *)dp, dad_list);
+ TAILQ_REMOVE(&V_dadq, (struct dadq *)dp, dad_list);
free(dp, M_IP6NDP);
dp = NULL;
IFAFREE(ifa);
@@ -1245,11 +1246,11 @@ nd6_dad_timer(struct ifaddr *ifa)
}
/* timeouted with IFF_{RUNNING,UP} check */
- if (dp->dad_ns_tcount > dad_maxtry) {
+ if (dp->dad_ns_tcount > V_dad_maxtry) {
nd6log((LOG_INFO, "%s: could not run DAD, driver problem?\n",
if_name(ifa->ifa_ifp)));
- TAILQ_REMOVE(&dadq, (struct dadq *)dp, dad_list);
+ TAILQ_REMOVE(&V_dadq, (struct dadq *)dp, dad_list);
free(dp, M_IP6NDP);
dp = NULL;
IFAFREE(ifa);
@@ -1302,7 +1303,7 @@ nd6_dad_timer(struct ifaddr *ifa)
if_name(ifa->ifa_ifp),
ip6_sprintf(ip6buf, &ia->ia_addr.sin6_addr)));
- TAILQ_REMOVE(&dadq, (struct dadq *)dp, dad_list);
+ TAILQ_REMOVE(&V_dadq, (struct dadq *)dp, dad_list);
free(dp, M_IP6NDP);
dp = NULL;
IFAFREE(ifa);
@@ -1378,7 +1379,7 @@ nd6_dad_duplicated(struct ifaddr *ifa)
}
}
- TAILQ_REMOVE(&dadq, (struct dadq *)dp, dad_list);
+ TAILQ_REMOVE(&V_dadq, (struct dadq *)dp, dad_list);
free(dp, M_IP6NDP);
dp = NULL;
IFAFREE(ifa);
@@ -1421,7 +1422,7 @@ nd6_dad_ns_input(struct ifaddr *ifa)
dp = nd6_dad_find(ifa);
/* Quickhack - completely ignore DAD NS packets */
- if (dad_ignore_ns) {
+ if (V_dad_ignore_ns) {
char ip6buf[INET6_ADDRSTRLEN];
nd6log((LOG_INFO,
"nd6_dad_ns_input: ignoring DAD NS packet for "
diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c
index 39f5382..b8dacc9 100644
--- a/sys/netinet6/nd6_rtr.c
+++ b/sys/netinet6/nd6_rtr.c
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
#include <sys/errno.h>
#include <sys/syslog.h>
#include <sys/queue.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_types.h>
@@ -128,7 +129,7 @@ nd6_rs_input(struct mbuf *m, int off, int icmp6len)
char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN];
/* If I'm not a router, ignore it. */
- if (ip6_accept_rtadv != 0 || ip6_forwarding != 1)
+ if (V_ip6_accept_rtadv != 0 || V_ip6_forwarding != 1)
goto freeit;
/* Sanity checks */
@@ -153,7 +154,7 @@ nd6_rs_input(struct mbuf *m, int off, int icmp6len)
#else
IP6_EXTHDR_GET(nd_rs, struct nd_router_solicit *, m, off, icmp6len);
if (nd_rs == NULL) {
- icmp6stat.icp6s_tooshort++;
+ V_icmp6stat.icp6s_tooshort++;
return;
}
#endif
@@ -188,7 +189,7 @@ nd6_rs_input(struct mbuf *m, int off, int icmp6len)
return;
bad:
- icmp6stat.icp6s_badrs++;
+ V_icmp6stat.icp6s_badrs++;
m_freem(m);
}
@@ -217,7 +218,7 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len)
* the system-wide variable allows the acceptance, and
* per-interface variable allows RAs on the receiving interface.
*/
- if (ip6_accept_rtadv == 0)
+ if (V_ip6_accept_rtadv == 0)
goto freeit;
if (!(ndi->flags & ND6_IFF_ACCEPT_RTADV))
goto freeit;
@@ -243,7 +244,7 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len)
#else
IP6_EXTHDR_GET(nd_ra, struct nd_router_advert *, m, off, icmp6len);
if (nd_ra == NULL) {
- icmp6stat.icp6s_tooshort++;
+ V_icmp6stat.icp6s_tooshort++;
return;
}
#endif
@@ -278,7 +279,7 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len)
ndi->basereachable != advreachable) {
ndi->basereachable = advreachable;
ndi->reachable = ND_COMPUTE_RTIME(ndi->basereachable);
- ndi->recalctm = nd6_recalc_reachtm_interval; /* reset */
+ ndi->recalctm = V_nd6_recalc_reachtm_interval; /* reset */
}
}
if (nd_ra->nd_ra_retransmit)
@@ -419,7 +420,7 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len)
return;
bad:
- icmp6stat.icp6s_badra++;
+ V_icmp6stat.icp6s_badra++;
m_freem(m);
}
@@ -484,7 +485,7 @@ defrouter_lookup(struct in6_addr *addr, struct ifnet *ifp)
{
struct nd_defrouter *dr;
- for (dr = TAILQ_FIRST(&nd_defrouter); dr;
+ for (dr = TAILQ_FIRST(&V_nd_defrouter); dr;
dr = TAILQ_NEXT(dr, dr_entry)) {
if (dr->ifp == ifp && IN6_ARE_ADDR_EQUAL(addr, &dr->rtaddr))
return (dr);
@@ -532,7 +533,7 @@ defrouter_reset(void)
{
struct nd_defrouter *dr;
- for (dr = TAILQ_FIRST(&nd_defrouter); dr;
+ for (dr = TAILQ_FIRST(&V_nd_defrouter); dr;
dr = TAILQ_NEXT(dr, dr_entry))
defrouter_delreq(dr);
@@ -552,19 +553,19 @@ defrtrlist_del(struct nd_defrouter *dr)
* Flush all the routing table entries that use the router
* as a next hop.
*/
- if (!ip6_forwarding && ip6_accept_rtadv) /* XXX: better condition? */
+ if (!V_ip6_forwarding && V_ip6_accept_rtadv) /* XXX: better condition? */
rt6_flush(&dr->rtaddr, dr->ifp);
if (dr->installed) {
deldr = dr;
defrouter_delreq(dr);
}
- TAILQ_REMOVE(&nd_defrouter, dr, dr_entry);
+ TAILQ_REMOVE(&V_nd_defrouter, dr, dr_entry);
/*
* Also delete all the pointers to the router in each prefix lists.
*/
- for (pr = nd_prefix.lh_first; pr; pr = pr->ndpr_next) {
+ for (pr = V_nd_prefix.lh_first; pr; pr = pr->ndpr_next) {
struct nd_pfxrouter *pfxrtr;
if ((pfxrtr = pfxrtr_lookup(pr, dr)) != NULL)
pfxrtr_del(pfxrtr);
@@ -617,10 +618,10 @@ defrouter_select(void)
* if the node is not an autoconfigured host, we explicitly exclude
* such cases here for safety.
*/
- if (ip6_forwarding || !ip6_accept_rtadv) {
+ if (V_ip6_forwarding || !V_ip6_accept_rtadv) {
nd6log((LOG_WARNING,
"defrouter_select: called unexpectedly (forwarding=%d, "
- "accept_rtadv=%d)\n", ip6_forwarding, ip6_accept_rtadv));
+ "accept_rtadv=%d)\n", V_ip6_forwarding, V_ip6_accept_rtadv));
splx(s);
return;
}
@@ -629,7 +630,7 @@ defrouter_select(void)
* Let's handle easy case (3) first:
* If default router list is empty, there's nothing to be done.
*/
- if (!TAILQ_FIRST(&nd_defrouter)) {
+ if (!TAILQ_FIRST(&V_nd_defrouter)) {
splx(s);
return;
}
@@ -639,7 +640,7 @@ defrouter_select(void)
* We just pick up the first reachable one (if any), assuming that
* the ordering rule of the list described in defrtrlist_update().
*/
- for (dr = TAILQ_FIRST(&nd_defrouter); dr;
+ for (dr = TAILQ_FIRST(&V_nd_defrouter); dr;
dr = TAILQ_NEXT(dr, dr_entry)) {
if (selected_dr == NULL &&
(rt = nd6_lookup(&dr->rtaddr, 0, dr->ifp)) &&
@@ -666,7 +667,7 @@ defrouter_select(void)
*/
if (selected_dr == NULL) {
if (installed_dr == NULL || !TAILQ_NEXT(installed_dr, dr_entry))
- selected_dr = TAILQ_FIRST(&nd_defrouter);
+ selected_dr = TAILQ_FIRST(&V_nd_defrouter);
else
selected_dr = TAILQ_NEXT(installed_dr, dr_entry);
} else if (installed_dr &&
@@ -756,7 +757,7 @@ defrtrlist_update(struct nd_defrouter *new)
* defrouter_select() below will handle routing
* changes later.
*/
- TAILQ_REMOVE(&nd_defrouter, dr, dr_entry);
+ TAILQ_REMOVE(&V_nd_defrouter, dr, dr_entry);
n = dr;
goto insert;
}
@@ -787,7 +788,7 @@ insert:
*/
/* insert at the end of the group */
- for (dr = TAILQ_FIRST(&nd_defrouter); dr;
+ for (dr = TAILQ_FIRST(&V_nd_defrouter); dr;
dr = TAILQ_NEXT(dr, dr_entry)) {
if (rtpref(n) > rtpref(dr))
break;
@@ -795,7 +796,7 @@ insert:
if (dr)
TAILQ_INSERT_BEFORE(dr, n, dr_entry);
else
- TAILQ_INSERT_TAIL(&nd_defrouter, n, dr_entry);
+ TAILQ_INSERT_TAIL(&V_nd_defrouter, n, dr_entry);
defrouter_select();
@@ -845,7 +846,7 @@ nd6_prefix_lookup(struct nd_prefixctl *key)
{
struct nd_prefix *search;
- for (search = nd_prefix.lh_first; search; search = search->ndpr_next) {
+ for (search = V_nd_prefix.lh_first; search; search = search->ndpr_next) {
if (key->ndpr_ifp == search->ndpr_ifp &&
key->ndpr_plen == search->ndpr_plen &&
in6_are_prefix_equal(&key->ndpr_prefix.sin6_addr,
@@ -894,7 +895,7 @@ nd6_prelist_add(struct nd_prefixctl *pr, struct nd_defrouter *dr,
s = splnet();
/* link ndpr_entry to nd_prefix list */
- LIST_INSERT_HEAD(&nd_prefix, new, ndpr_entry);
+ LIST_INSERT_HEAD(&V_nd_prefix, new, ndpr_entry);
splx(s);
/* ND_OPT_PI_FLAG_ONLINK processing */
@@ -1194,20 +1195,20 @@ prelist_update(struct nd_prefixctl *new, struct nd_defrouter *dr,
if ((ifa6->ia6_flags & IN6_IFF_TEMPORARY) != 0) {
u_int32_t maxvltime, maxpltime;
- if (ip6_temp_valid_lifetime >
+ if (V_ip6_temp_valid_lifetime >
(u_int32_t)((time_second - ifa6->ia6_createtime) +
- ip6_desync_factor)) {
- maxvltime = ip6_temp_valid_lifetime -
+ V_ip6_desync_factor)) {
+ maxvltime = V_ip6_temp_valid_lifetime -
(time_second - ifa6->ia6_createtime) -
- ip6_desync_factor;
+ V_ip6_desync_factor;
} else
maxvltime = 0;
- if (ip6_temp_preferred_lifetime >
+ if (V_ip6_temp_preferred_lifetime >
(u_int32_t)((time_second - ifa6->ia6_createtime) +
- ip6_desync_factor)) {
- maxpltime = ip6_temp_preferred_lifetime -
+ V_ip6_desync_factor)) {
+ maxpltime = V_ip6_temp_preferred_lifetime -
(time_second - ifa6->ia6_createtime) -
- ip6_desync_factor;
+ V_ip6_desync_factor;
} else
maxpltime = 0;
@@ -1274,7 +1275,7 @@ prelist_update(struct nd_prefixctl *new, struct nd_defrouter *dr,
* addresses. Thus, we specifiy 1 as the 2nd arg of
* in6_tmpifadd().
*/
- if (ip6_use_tempaddr) {
+ if (V_ip6_use_tempaddr) {
int e;
if ((e = in6_tmpifadd(ia6, 1, 1)) != 0) {
nd6log((LOG_NOTICE, "prelist_update: "
@@ -1350,7 +1351,7 @@ pfxlist_onlink_check()
* Check if there is a prefix that has a reachable advertising
* router.
*/
- 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_raf_onlink && find_pfxlist_reachable_router(pr))
break;
}
@@ -1360,11 +1361,11 @@ pfxlist_onlink_check()
* that does not advertise any prefixes.
*/
if (pr == NULL) {
- for (dr = TAILQ_FIRST(&nd_defrouter); dr;
+ for (dr = TAILQ_FIRST(&V_nd_defrouter); dr;
dr = TAILQ_NEXT(dr, dr_entry)) {
struct nd_prefix *pr0;
- for (pr0 = nd_prefix.lh_first; pr0;
+ for (pr0 = V_nd_prefix.lh_first; pr0;
pr0 = pr0->ndpr_next) {
if ((pfxrtr = pfxrtr_lookup(pr0, dr)) != NULL)
break;
@@ -1373,7 +1374,7 @@ pfxlist_onlink_check()
break;
}
}
- if (pr != NULL || (TAILQ_FIRST(&nd_defrouter) && pfxrtr == NULL)) {
+ if (pr != NULL || (TAILQ_FIRST(&V_nd_defrouter) && pfxrtr == NULL)) {
/*
* There is at least one prefix that has a reachable router,
* or at least a router which probably does not advertise
@@ -1383,7 +1384,7 @@ pfxlist_onlink_check()
* Detach prefixes which have no reachable advertising
* router, and attach other prefixes.
*/
- for (pr = nd_prefix.lh_first; pr; pr = pr->ndpr_next) {
+ for (pr = V_nd_prefix.lh_first; pr; pr = pr->ndpr_next) {
/* XXX: a link-local prefix should never be detached */
if (IN6_IS_ADDR_LINKLOCAL(&pr->ndpr_prefix.sin6_addr))
continue;
@@ -1404,7 +1405,7 @@ pfxlist_onlink_check()
}
} else {
/* there is no prefix that has a reachable router */
- for (pr = nd_prefix.lh_first; pr; pr = pr->ndpr_next) {
+ for (pr = V_nd_prefix.lh_first; pr; pr = pr->ndpr_next) {
if (IN6_IS_ADDR_LINKLOCAL(&pr->ndpr_prefix.sin6_addr))
continue;
@@ -1424,7 +1425,7 @@ pfxlist_onlink_check()
* interfaces. Such cases will be handled in nd6_prefix_onlink,
* so we don't have to care about them.
*/
- for (pr = nd_prefix.lh_first; pr; pr = pr->ndpr_next) {
+ for (pr = V_nd_prefix.lh_first; pr; pr = pr->ndpr_next) {
int e;
char ip6buf[INET6_ADDRSTRLEN];
@@ -1467,7 +1468,7 @@ pfxlist_onlink_check()
* always be attached.
* The precise detection logic is same as the one for prefixes.
*/
- for (ifa = in6_ifaddr; ifa; ifa = ifa->ia_next) {
+ for (ifa = V_in6_ifaddr; ifa; ifa = ifa->ia_next) {
if (!(ifa->ia6_flags & IN6_IFF_AUTOCONF))
continue;
@@ -1484,7 +1485,7 @@ pfxlist_onlink_check()
break;
}
if (ifa) {
- for (ifa = in6_ifaddr; ifa; ifa = ifa->ia_next) {
+ for (ifa = V_in6_ifaddr; ifa; ifa = ifa->ia_next) {
if ((ifa->ia6_flags & IN6_IFF_AUTOCONF) == 0)
continue;
@@ -1503,7 +1504,7 @@ pfxlist_onlink_check()
}
}
else {
- for (ifa = in6_ifaddr; ifa; ifa = ifa->ia_next) {
+ for (ifa = V_in6_ifaddr; ifa; ifa = ifa->ia_next) {
if ((ifa->ia6_flags & IN6_IFF_AUTOCONF) == 0)
continue;
@@ -1545,7 +1546,7 @@ nd6_prefix_onlink(struct nd_prefix *pr)
* Although such a configuration is expected to be rare, we explicitly
* allow it.
*/
- for (opr = nd_prefix.lh_first; opr; opr = opr->ndpr_next) {
+ for (opr = V_nd_prefix.lh_first; opr; opr = opr->ndpr_next) {
if (opr == pr)
continue;
@@ -1674,7 +1675,7 @@ nd6_prefix_offlink(struct nd_prefix *pr)
* If there's one, try to make the prefix on-link on the
* interface.
*/
- for (opr = nd_prefix.lh_first; opr; opr = opr->ndpr_next) {
+ for (opr = V_nd_prefix.lh_first; opr; opr = opr->ndpr_next) {
if (opr == pr)
continue;
@@ -1890,7 +1891,7 @@ in6_tmpifadd(const struct in6_ifaddr *ia0, int forcegen, int delay)
* there may be a time lag between generation of the ID and generation
* of the address. So, we'll do one more sanity check.
*/
- for (ia = in6_ifaddr; ia; ia = ia->ia_next) {
+ for (ia = V_in6_ifaddr; ia; ia = ia->ia_next) {
if (IN6_ARE_ADDR_EQUAL(&ia->ia_addr.sin6_addr,
&ifra.ifra_addr.sin6_addr)) {
if (trylimit-- == 0) {
@@ -1918,20 +1919,20 @@ in6_tmpifadd(const struct in6_ifaddr *ia0, int forcegen, int delay)
vltime0 = IFA6_IS_INVALID(ia0) ? 0 :
(ia0->ia6_lifetime.ia6t_vltime -
(time_second - ia0->ia6_updatetime));
- if (vltime0 > ip6_temp_valid_lifetime)
- vltime0 = ip6_temp_valid_lifetime;
+ if (vltime0 > V_ip6_temp_valid_lifetime)
+ vltime0 = V_ip6_temp_valid_lifetime;
} else
- vltime0 = ip6_temp_valid_lifetime;
+ vltime0 = V_ip6_temp_valid_lifetime;
if (ia0->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME) {
pltime0 = IFA6_IS_DEPRECATED(ia0) ? 0 :
(ia0->ia6_lifetime.ia6t_pltime -
(time_second - ia0->ia6_updatetime));
- if (pltime0 > ip6_temp_preferred_lifetime - ip6_desync_factor){
- pltime0 = ip6_temp_preferred_lifetime -
- ip6_desync_factor;
+ if (pltime0 > V_ip6_temp_preferred_lifetime - V_ip6_desync_factor){
+ pltime0 = V_ip6_temp_preferred_lifetime -
+ V_ip6_desync_factor;
}
} else
- pltime0 = ip6_temp_preferred_lifetime - ip6_desync_factor;
+ pltime0 = V_ip6_temp_preferred_lifetime - V_ip6_desync_factor;
ifra.ifra_lifetime.ia6t_vltime = vltime0;
ifra.ifra_lifetime.ia6t_pltime = pltime0;
@@ -1939,7 +1940,7 @@ in6_tmpifadd(const struct in6_ifaddr *ia0, int forcegen, int delay)
* A temporary address is created only if this calculated Preferred
* Lifetime is greater than REGEN_ADVANCE time units.
*/
- if (ifra.ifra_lifetime.ia6t_pltime <= ip6_temp_regen_advance)
+ if (ifra.ifra_lifetime.ia6t_pltime <= V_ip6_temp_regen_advance)
return (0);
/* XXX: scope zone ID? */
@@ -2020,7 +2021,7 @@ void
rt6_flush(struct in6_addr *gateway, struct ifnet *ifp)
{
- struct radix_node_head *rnh = rt_tables[0][AF_INET6];
+ struct radix_node_head *rnh = V_rt_tables[0][AF_INET6];
int s = splnet();
/* We'll care only link-local addresses */
@@ -2074,24 +2075,24 @@ nd6_setdefaultiface(int ifindex)
{
int error = 0;
- if (ifindex < 0 || if_index < ifindex)
+ if (ifindex < 0 || V_if_index < ifindex)
return (EINVAL);
if (ifindex != 0 && !ifnet_byindex(ifindex))
return (EINVAL);
- if (nd6_defifindex != ifindex) {
- nd6_defifindex = ifindex;
- if (nd6_defifindex > 0)
- nd6_defifp = ifnet_byindex(nd6_defifindex);
+ if (V_nd6_defifindex != ifindex) {
+ V_nd6_defifindex = ifindex;
+ if (V_nd6_defifindex > 0)
+ V_nd6_defifp = ifnet_byindex(V_nd6_defifindex);
else
- nd6_defifp = NULL;
+ V_nd6_defifp = NULL;
/*
* Our current implementation assumes one-to-one maping between
* interfaces and links, so it would be natural to use the
* default interface as the default link.
*/
- scope6_setdefault(nd6_defifp);
+ scope6_setdefault(V_nd6_defifp);
}
return (error);
diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c
index 9a35dc1..cbdca81 100644
--- a/sys/netinet6/raw_ip6.c
+++ b/sys/netinet6/raw_ip6.c
@@ -78,6 +78,7 @@ __FBSDID("$FreeBSD$");
#include <sys/socketvar.h>
#include <sys/sx.h>
#include <sys/syslog.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_types.h>
@@ -142,7 +143,7 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
struct mbuf *opts = NULL;
struct sockaddr_in6 fromsa;
- rip6stat.rip6s_ipackets++;
+ V_rip6stat.rip6s_ipackets++;
if (faithprefix_p != NULL && (*faithprefix_p)(&ip6->ip6_dst)) {
/* XXX Send icmp6 host/port unreach? */
@@ -152,8 +153,8 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
init_sin6(&fromsa, m); /* general init */
- INP_INFO_RLOCK(&ripcbinfo);
- LIST_FOREACH(in6p, &ripcb, inp_list) {
+ INP_INFO_RLOCK(&V_ripcbinfo);
+ LIST_FOREACH(in6p, &V_ripcb, inp_list) {
if ((in6p->in6p_vflag & INP_IPV6) == 0)
continue;
if (in6p->in6p_ip6_nxt &&
@@ -167,11 +168,11 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
continue;
INP_RLOCK(in6p);
if (in6p->in6p_cksum != -1) {
- rip6stat.rip6s_isum++;
+ V_rip6stat.rip6s_isum++;
if (in6_cksum(m, proto, *offp,
m->m_pkthdr.len - *offp)) {
INP_RUNLOCK(in6p);
- rip6stat.rip6s_badsum++;
+ V_rip6stat.rip6s_badsum++;
continue;
}
}
@@ -184,7 +185,7 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
*/
if (n && ipsec6_in_reject(n, last)) {
m_freem(n);
- ipsec6stat.in_polvio++;
+ V_ipsec6stat.in_polvio++;
/* Do not inject data into pcb. */
} else
#endif /* IPSEC */
@@ -200,7 +201,7 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
m_freem(n);
if (opts)
m_freem(opts);
- rip6stat.rip6s_fullsock++;
+ V_rip6stat.rip6s_fullsock++;
} else
sorwakeup(last->in6p_socket);
opts = NULL;
@@ -209,15 +210,15 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
}
last = in6p;
}
- INP_INFO_RUNLOCK(&ripcbinfo);
+ INP_INFO_RUNLOCK(&V_ripcbinfo);
#ifdef IPSEC
/*
* Check AH/ESP integrity.
*/
if (last && ipsec6_in_reject(m, last)) {
m_freem(m);
- ipsec6stat.in_polvio++;
- ip6stat.ip6s_delivered--;
+ V_ipsec6stat.in_polvio++;
+ V_ip6stat.ip6s_delivered--;
/* Do not inject data into pcb. */
INP_RUNLOCK(last);
} else
@@ -233,14 +234,14 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
m_freem(m);
if (opts)
m_freem(opts);
- rip6stat.rip6s_fullsock++;
+ V_rip6stat.rip6s_fullsock++;
} else
sorwakeup(last->in6p_socket);
INP_RUNLOCK(last);
} else {
- rip6stat.rip6s_nosock++;
+ V_rip6stat.rip6s_nosock++;
if (m->m_flags & M_MCAST)
- rip6stat.rip6s_nosockmcast++;
+ V_rip6stat.rip6s_nosockmcast++;
if (proto == IPPROTO_NONE)
m_freem(m);
else {
@@ -249,7 +250,7 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
ICMP6_PARAMPROB_NEXTHEADER,
prvnxtp - mtod(m, char *));
}
- ip6stat.ip6s_delivered--;
+ V_ip6stat.ip6s_delivered--;
}
return (IPPROTO_DONE);
}
@@ -295,7 +296,7 @@ rip6_ctlinput(int cmd, struct sockaddr *sa, void *d)
sa6_src = &sa6_any;
}
- (void) in6_pcbnotify(&ripcbinfo, sa, 0,
+ (void) in6_pcbnotify(&V_ripcbinfo, sa, 0,
(const struct sockaddr *)sa6_src, 0, cmd, cmdarg, notify);
}
@@ -353,9 +354,9 @@ rip6_output(m, va_alist)
* XXX: we may still need to determine the zone later.
*/
if (!(so->so_state & SS_ISCONNECTED)) {
- if (dstsock->sin6_scope_id == 0 && !ip6_use_defzone)
+ if (dstsock->sin6_scope_id == 0 && !V_ip6_use_defzone)
scope_ambiguous = 1;
- if ((error = sa6_embedscope(dstsock, ip6_use_defzone)) != 0)
+ if ((error = sa6_embedscope(dstsock, V_ip6_use_defzone)) != 0)
goto bad;
}
@@ -455,9 +456,9 @@ rip6_output(m, va_alist)
if (so->so_proto->pr_protocol == IPPROTO_ICMPV6) {
if (oifp)
icmp6_ifoutstat_inc(oifp, type, code);
- icmp6stat.icp6s_outhist[type]++;
+ V_icmp6stat.icp6s_outhist[type]++;
} else
- rip6stat.rip6s_opackets++;
+ V_rip6stat.rip6s_opackets++;
goto freectl;
@@ -560,15 +561,15 @@ rip6_attach(struct socket *so, int proto, struct thread *td)
sizeof(struct icmp6_filter), M_PCB, M_NOWAIT);
if (filter == NULL)
return (ENOMEM);
- INP_INFO_WLOCK(&ripcbinfo);
- error = in_pcballoc(so, &ripcbinfo);
+ INP_INFO_WLOCK(&V_ripcbinfo);
+ error = in_pcballoc(so, &V_ripcbinfo);
if (error) {
- INP_INFO_WUNLOCK(&ripcbinfo);
+ INP_INFO_WUNLOCK(&V_ripcbinfo);
FREE(filter, M_PCB);
return (error);
}
inp = (struct inpcb *)so->so_pcb;
- INP_INFO_WUNLOCK(&ripcbinfo);
+ INP_INFO_WUNLOCK(&V_ripcbinfo);
inp->inp_vflag |= INP_IPV6;
inp->in6p_ip6_nxt = (long)proto;
inp->in6p_hops = -1; /* use kernel default */
@@ -590,12 +591,12 @@ rip6_detach(struct socket *so)
if (so == ip6_mrouter && ip6_mrouter_done)
ip6_mrouter_done();
/* xxx: RSVP */
- INP_INFO_WLOCK(&ripcbinfo);
+ INP_INFO_WLOCK(&V_ripcbinfo);
INP_WLOCK(inp);
FREE(inp->in6p_icmp6filt, M_PCB);
in6_pcbdetach(inp);
in6_pcbfree(inp);
- INP_INFO_WUNLOCK(&ripcbinfo);
+ INP_INFO_WUNLOCK(&V_ripcbinfo);
}
/* XXXRW: This can't ever be called. */
@@ -649,9 +650,9 @@ rip6_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
if (nam->sa_len != sizeof(*addr))
return (EINVAL);
- if (TAILQ_EMPTY(&ifnet) || addr->sin6_family != AF_INET6)
+ if (TAILQ_EMPTY(&V_ifnet) || addr->sin6_family != AF_INET6)
return (EADDRNOTAVAIL);
- if ((error = sa6_embedscope(addr, ip6_use_defzone)) != 0)
+ if ((error = sa6_embedscope(addr, V_ip6_use_defzone)) != 0)
return (error);
if (!IN6_IS_ADDR_UNSPECIFIED(&addr->sin6_addr) &&
@@ -663,11 +664,11 @@ rip6_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
IN6_IFF_DETACHED|IN6_IFF_DEPRECATED)) {
return (EADDRNOTAVAIL);
}
- INP_INFO_WLOCK(&ripcbinfo);
+ INP_INFO_WLOCK(&V_ripcbinfo);
INP_WLOCK(inp);
inp->in6p_laddr = addr->sin6_addr;
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&ripcbinfo);
+ INP_INFO_WUNLOCK(&V_ripcbinfo);
return (0);
}
@@ -685,7 +686,7 @@ rip6_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
if (nam->sa_len != sizeof(*addr))
return (EINVAL);
- if (TAILQ_EMPTY(&ifnet))
+ if (TAILQ_EMPTY(&V_ifnet))
return (EADDRNOTAVAIL);
if (addr->sin6_family != AF_INET6)
return (EAFNOSUPPORT);
@@ -698,12 +699,12 @@ rip6_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
* the outgoing interface. If we can, determine the zone ID based on
* the interface below.
*/
- if (addr->sin6_scope_id == 0 && !ip6_use_defzone)
+ if (addr->sin6_scope_id == 0 && !V_ip6_use_defzone)
scope_ambiguous = 1;
- if ((error = sa6_embedscope(addr, ip6_use_defzone)) != 0)
+ if ((error = sa6_embedscope(addr, V_ip6_use_defzone)) != 0)
return (error);
- INP_INFO_WLOCK(&ripcbinfo);
+ INP_INFO_WLOCK(&V_ripcbinfo);
INP_WLOCK(inp);
/* Source address selection. XXX: need pcblookup? */
in6a = in6_selectsrc(addr, inp->in6p_outputopts,
@@ -711,7 +712,7 @@ rip6_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
&ifp, &error);
if (in6a == NULL) {
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&ripcbinfo);
+ INP_INFO_WUNLOCK(&V_ripcbinfo);
return (error ? error : EADDRNOTAVAIL);
}
@@ -719,14 +720,14 @@ rip6_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
if (ifp && scope_ambiguous &&
(error = in6_setscope(&addr->sin6_addr, ifp, NULL)) != 0) {
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&ripcbinfo);
+ INP_INFO_WUNLOCK(&V_ripcbinfo);
return (error);
}
inp->in6p_faddr = addr->sin6_addr;
inp->in6p_laddr = *in6a;
soisconnected(so);
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&ripcbinfo);
+ INP_INFO_WUNLOCK(&V_ripcbinfo);
return (0);
}
diff --git a/sys/netinet6/route6.c b/sys/netinet6/route6.c
index e607bea..c058f3b 100644
--- a/sys/netinet6/route6.c
+++ b/sys/netinet6/route6.c
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
#include <sys/socket.h>
#include <sys/systm.h>
#include <sys/queue.h>
+#include <sys/vimage.h>
#include <net/if.h>
@@ -74,7 +75,7 @@ route6_input(struct mbuf **mp, int *offp, int proto)
if (ip6a) {
/* XXX reject home-address option before rthdr */
if (ip6a->ip6a_flags & IP6A_SWAP) {
- ip6stat.ip6s_badoptions++;
+ V_ip6stat.ip6s_badoptions++;
m_freem(m);
return IPPROTO_DONE;
}
@@ -88,7 +89,7 @@ route6_input(struct mbuf **mp, int *offp, int proto)
ip6 = mtod(m, struct ip6_hdr *);
IP6_EXTHDR_GET(rh, struct ip6_rthdr *, m, off, sizeof(*rh));
if (rh == NULL) {
- ip6stat.ip6s_tooshort++;
+ V_ip6stat.ip6s_tooshort++;
return IPPROTO_DONE;
}
#endif
@@ -115,7 +116,7 @@ route6_input(struct mbuf **mp, int *offp, int proto)
*/
IP6_EXTHDR_GET(rh, struct ip6_rthdr *, m, off, rhlen);
if (rh == NULL) {
- ip6stat.ip6s_tooshort++;
+ V_ip6stat.ip6s_tooshort++;
return IPPROTO_DONE;
}
#endif
@@ -129,7 +130,7 @@ route6_input(struct mbuf **mp, int *offp, int proto)
rhlen = (rh->ip6r_len + 1) << 3;
break; /* Final dst. Just ignore the header. */
}
- ip6stat.ip6s_badoptions++;
+ V_ip6stat.ip6s_badoptions++;
icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER,
(caddr_t)&rh->ip6r_type - (caddr_t)ip6);
return (IPPROTO_DONE);
@@ -166,14 +167,14 @@ ip6_rthdr0(struct mbuf *m, struct ip6_hdr *ip6, struct ip6_rthdr0 *rh0)
* RFC 2462: this limitation was removed since strict/loose
* bitmap field was deleted.
*/
- ip6stat.ip6s_badoptions++;
+ V_ip6stat.ip6s_badoptions++;
icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER,
(caddr_t)&rh0->ip6r0_len - (caddr_t)ip6);
return (-1);
}
if ((addrs = rh0->ip6r0_len / 2) < rh0->ip6r0_segleft) {
- ip6stat.ip6s_badoptions++;
+ V_ip6stat.ip6s_badoptions++;
icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER,
(caddr_t)&rh0->ip6r0_segleft - (caddr_t)ip6);
return (-1);
@@ -192,7 +193,7 @@ ip6_rthdr0(struct mbuf *m, struct ip6_hdr *ip6, struct ip6_rthdr0 *rh0)
IN6_IS_ADDR_UNSPECIFIED(nextaddr) ||
IN6_IS_ADDR_V4MAPPED(nextaddr) ||
IN6_IS_ADDR_V4COMPAT(nextaddr)) {
- ip6stat.ip6s_badoptions++;
+ V_ip6stat.ip6s_badoptions++;
m_freem(m);
return (-1);
}
@@ -200,7 +201,7 @@ ip6_rthdr0(struct mbuf *m, struct ip6_hdr *ip6, struct ip6_rthdr0 *rh0)
IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_dst) ||
IN6_IS_ADDR_V4MAPPED(&ip6->ip6_dst) ||
IN6_IS_ADDR_V4COMPAT(&ip6->ip6_dst)) {
- ip6stat.ip6s_badoptions++;
+ V_ip6stat.ip6s_badoptions++;
m_freem(m);
return (-1);
}
@@ -213,7 +214,7 @@ ip6_rthdr0(struct mbuf *m, struct ip6_hdr *ip6, struct ip6_rthdr0 *rh0)
if ((ifa = ip6_getdstifaddr(m)) == NULL)
goto bad;
if (in6_setscope(nextaddr, ifa->ia_ifp, NULL) != 0) {
- ip6stat.ip6s_badscope++;
+ V_ip6stat.ip6s_badscope++;
goto bad;
}
diff --git a/sys/netinet6/scope6.c b/sys/netinet6/scope6.c
index 881db7e..5dce8ce 100644
--- a/sys/netinet6/scope6.c
+++ b/sys/netinet6/scope6.c
@@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
#include <sys/systm.h>
#include <sys/queue.h>
#include <sys/syslog.h>
+#include <sys/vimage.h>
#include <net/route.h>
#include <net/if.h>
@@ -73,7 +74,7 @@ scope6_init(void)
{
SCOPE6_LOCK_INIT();
- bzero(&sid_default, sizeof(sid_default));
+ bzero(&V_sid_default, sizeof(V_sid_default));
}
struct scope6_id *
@@ -147,7 +148,7 @@ scope6_set(struct ifnet *ifp, struct scope6_id *idlist)
}
if (i == IPV6_ADDR_SCOPE_LINKLOCAL &&
- idlist->s6id_list[i] > if_index) {
+ idlist->s6id_list[i] > V_if_index) {
/*
* XXX: theoretically, there should be no
* relationship between link IDs and interface
@@ -271,13 +272,13 @@ scope6_setdefault(struct ifnet *ifp)
*/
SCOPE6_LOCK();
if (ifp) {
- sid_default.s6id_list[IPV6_ADDR_SCOPE_INTFACELOCAL] =
+ V_sid_default.s6id_list[IPV6_ADDR_SCOPE_INTFACELOCAL] =
ifp->if_index;
- sid_default.s6id_list[IPV6_ADDR_SCOPE_LINKLOCAL] =
+ V_sid_default.s6id_list[IPV6_ADDR_SCOPE_LINKLOCAL] =
ifp->if_index;
} else {
- sid_default.s6id_list[IPV6_ADDR_SCOPE_INTFACELOCAL] = 0;
- sid_default.s6id_list[IPV6_ADDR_SCOPE_LINKLOCAL] = 0;
+ V_sid_default.s6id_list[IPV6_ADDR_SCOPE_INTFACELOCAL] = 0;
+ V_sid_default.s6id_list[IPV6_ADDR_SCOPE_LINKLOCAL] = 0;
}
SCOPE6_UNLOCK();
}
@@ -287,7 +288,7 @@ scope6_get_default(struct scope6_id *idlist)
{
SCOPE6_LOCK();
- *idlist = sid_default;
+ *idlist = V_sid_default;
SCOPE6_UNLOCK();
return (0);
@@ -310,7 +311,7 @@ scope6_addr2default(struct in6_addr *addr)
* not to lock here?
*/
SCOPE6_LOCK();
- id = sid_default.s6id_list[in6_addrscope(addr)];
+ id = V_sid_default.s6id_list[in6_addrscope(addr)];
SCOPE6_UNLOCK();
return (id);
}
@@ -341,7 +342,7 @@ sa6_embedscope(struct sockaddr_in6 *sin6, int defaultok)
* zone IDs assuming a one-to-one mapping between interfaces
* and links.
*/
- if (if_index < zoneid)
+ if (V_if_index < zoneid)
return (ENXIO);
ifp = ifnet_byindex(zoneid);
if (ifp == NULL) /* XXX: this can happen for some OS */
@@ -379,7 +380,7 @@ sa6_recoverscope(struct sockaddr_in6 *sin6)
zoneid = ntohs(sin6->sin6_addr.s6_addr16[1]);
if (zoneid) {
/* sanity check */
- if (zoneid < 0 || if_index < zoneid)
+ if (zoneid < 0 || V_if_index < zoneid)
return (ENXIO);
if (!ifnet_byindex(zoneid))
return (ENXIO);
diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c
index 03f5ee2..f593e6f 100644
--- a/sys/netinet6/udp6_usrreq.c
+++ b/sys/netinet6/udp6_usrreq.c
@@ -84,6 +84,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sysctl.h>
#include <sys/syslog.h>
#include <sys/systm.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_types.h>
@@ -135,7 +136,7 @@ udp6_append(struct inpcb *inp, struct mbuf *n, int off,
/* Check AH/ESP integrity. */
if (ipsec6_in_reject(n, inp)) {
m_freem(n);
- ipsec6stat.in_polvio++;
+ V_ipsec6stat.in_polvio++;
return;
}
#endif /* IPSEC */
@@ -159,7 +160,7 @@ udp6_append(struct inpcb *inp, struct mbuf *n, int off,
m_freem(n);
if (opts)
m_freem(opts);
- udpstat.udps_fullsock++;
+ V_udpstat.udps_fullsock++;
} else
sorwakeup_locked(so);
}
@@ -193,7 +194,7 @@ udp6_input(struct mbuf **mp, int *offp, int proto)
return (IPPROTO_DONE);
#endif
- udpstat.udps_ipackets++;
+ V_udpstat.udps_ipackets++;
/*
* Destination port of 0 is illegal, based on RFC768.
@@ -205,7 +206,7 @@ udp6_input(struct mbuf **mp, int *offp, int proto)
ulen = ntohs((u_short)uh->uh_ulen);
if (plen != ulen) {
- udpstat.udps_badlen++;
+ V_udpstat.udps_badlen++;
goto badunlocked;
}
@@ -213,11 +214,11 @@ udp6_input(struct mbuf **mp, int *offp, int proto)
* Checksum extended UDP header and data.
*/
if (uh->uh_sum == 0) {
- udpstat.udps_nosum++;
+ V_udpstat.udps_nosum++;
goto badunlocked;
}
if (in6_cksum(m, IPPROTO_UDP, off, ulen) != 0) {
- udpstat.udps_badsum++;
+ V_udpstat.udps_badsum++;
goto badunlocked;
}
@@ -227,7 +228,7 @@ udp6_input(struct mbuf **mp, int *offp, int proto)
init_sin6(&fromsa, m);
fromsa.sin6_port = uh->uh_sport;
- INP_INFO_RLOCK(&udbinfo);
+ INP_INFO_RLOCK(&V_udbinfo);
if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) {
struct inpcb *last;
@@ -247,7 +248,7 @@ udp6_input(struct mbuf **mp, int *offp, int proto)
* later.
*/
last = NULL;
- LIST_FOREACH(inp, &udb, inp_list) {
+ LIST_FOREACH(inp, &V_udb, inp_list) {
if ((inp->inp_vflag & INP_IPV6) == 0)
continue;
if (inp->in6p_lport != uh->uh_dport)
@@ -302,20 +303,20 @@ udp6_input(struct mbuf **mp, int *offp, int proto)
* to send an ICMP Port Unreachable for a broadcast
* or multicast datgram.)
*/
- udpstat.udps_noport++;
- udpstat.udps_noportmcast++;
+ V_udpstat.udps_noport++;
+ V_udpstat.udps_noportmcast++;
goto badheadlocked;
}
INP_RLOCK(last);
udp6_append(last, m, off, &fromsa);
INP_RUNLOCK(last);
- INP_INFO_RUNLOCK(&udbinfo);
+ INP_INFO_RUNLOCK(&V_udbinfo);
return (IPPROTO_DONE);
}
/*
* Locate pcb for datagram.
*/
- inp = in6_pcblookup_hash(&udbinfo, &ip6->ip6_src, uh->uh_sport,
+ inp = in6_pcblookup_hash(&V_udbinfo, &ip6->ip6_src, uh->uh_sport,
&ip6->ip6_dst, uh->uh_dport, 1, m->m_pkthdr.rcvif);
if (inp == NULL) {
if (udp_log_in_vain) {
@@ -329,14 +330,14 @@ udp6_input(struct mbuf **mp, int *offp, int proto)
ip6_sprintf(ip6bufs, &ip6->ip6_src),
ntohs(uh->uh_sport));
}
- udpstat.udps_noport++;
+ V_udpstat.udps_noport++;
if (m->m_flags & M_MCAST) {
printf("UDP6: M_MCAST is set in a unicast packet.\n");
- udpstat.udps_noportmcast++;
+ V_udpstat.udps_noportmcast++;
goto badheadlocked;
}
- INP_INFO_RUNLOCK(&udbinfo);
- if (udp_blackhole)
+ INP_INFO_RUNLOCK(&V_udbinfo);
+ if (V_udp_blackhole)
goto badunlocked;
if (badport_bandlim(BANDLIM_ICMP6_UNREACH) < 0)
goto badunlocked;
@@ -344,13 +345,13 @@ udp6_input(struct mbuf **mp, int *offp, int proto)
return (IPPROTO_DONE);
}
INP_RLOCK(inp);
- INP_INFO_RUNLOCK(&udbinfo);
+ INP_INFO_RUNLOCK(&V_udbinfo);
udp6_append(inp, m, off, &fromsa);
INP_RUNLOCK(inp);
return (IPPROTO_DONE);
badheadlocked:
- INP_INFO_RUNLOCK(&udbinfo);
+ INP_INFO_RUNLOCK(&V_udbinfo);
badunlocked:
if (m)
m_freem(m);
@@ -414,11 +415,11 @@ udp6_ctlinput(int cmd, struct sockaddr *sa, void *d)
bzero(&uh, sizeof(uh));
m_copydata(m, off, sizeof(*uhp), (caddr_t)&uh);
- (void) in6_pcbnotify(&udbinfo, sa, uh.uh_dport,
+ (void) in6_pcbnotify(&V_udbinfo, sa, uh.uh_dport,
(struct sockaddr *)ip6cp->ip6c_src, uh.uh_sport, cmd,
cmdarg, notify);
} else
- (void) in6_pcbnotify(&udbinfo, sa, 0,
+ (void) in6_pcbnotify(&V_udbinfo, sa, 0,
(const struct sockaddr *)sa6_src, 0, cmd, cmdarg, notify);
}
@@ -441,17 +442,17 @@ udp6_getcred(SYSCTL_HANDLER_ARGS)
error = SYSCTL_IN(req, addrs, sizeof(addrs));
if (error)
return (error);
- if ((error = sa6_embedscope(&addrs[0], ip6_use_defzone)) != 0 ||
- (error = sa6_embedscope(&addrs[1], ip6_use_defzone)) != 0) {
+ if ((error = sa6_embedscope(&addrs[0], V_ip6_use_defzone)) != 0 ||
+ (error = sa6_embedscope(&addrs[1], V_ip6_use_defzone)) != 0) {
return (error);
}
- INP_INFO_RLOCK(&udbinfo);
- inp = in6_pcblookup_hash(&udbinfo, &addrs[1].sin6_addr,
+ INP_INFO_RLOCK(&V_udbinfo);
+ inp = in6_pcblookup_hash(&V_udbinfo, &addrs[1].sin6_addr,
addrs[1].sin6_port, &addrs[0].sin6_addr, addrs[0].sin6_port, 1,
NULL);
if (inp != NULL) {
INP_RLOCK(inp);
- INP_INFO_RUNLOCK(&udbinfo);
+ INP_INFO_RUNLOCK(&V_udbinfo);
if (inp->inp_socket == NULL)
error = ENOENT;
if (error == 0)
@@ -461,11 +462,11 @@ udp6_getcred(SYSCTL_HANDLER_ARGS)
cru2x(inp->inp_socket->so_cred, &xuc);
INP_RUNLOCK(inp);
} else {
- INP_INFO_RUNLOCK(&udbinfo);
+ INP_INFO_RUNLOCK(&V_udbinfo);
error = ENOENT;
}
INP_RUNLOCK(inp);
- INP_INFO_RUNLOCK(&udbinfo);
+ INP_INFO_RUNLOCK(&V_udbinfo);
if (error == 0)
error = SYSCTL_OUT(req, &xuc, sizeof(struct xucred));
return (error);
@@ -511,9 +512,9 @@ udp6_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr6,
* we'll see if we can determine the outgoing interface. If we
* can, determine the zone ID based on the interface below.
*/
- if (sin6->sin6_scope_id == 0 && !ip6_use_defzone)
+ if (sin6->sin6_scope_id == 0 && !V_ip6_use_defzone)
scope_ambiguous = 1;
- if ((error = sa6_embedscope(sin6, ip6_use_defzone)) != 0)
+ if ((error = sa6_embedscope(sin6, V_ip6_use_defzone)) != 0)
return (error);
}
@@ -669,7 +670,7 @@ udp6_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr6,
flags = 0;
- udpstat.udps_opackets++;
+ V_udpstat.udps_opackets++;
error = ip6_output(m, optp, NULL, flags, inp->in6p_moptions,
NULL, inp);
break;
@@ -708,7 +709,7 @@ udp6_abort(struct socket *so)
}
#endif
- INP_INFO_WLOCK(&udbinfo);
+ INP_INFO_WLOCK(&V_udbinfo);
INP_WLOCK(inp);
if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)) {
in6_pcbdisconnect(inp);
@@ -716,7 +717,7 @@ udp6_abort(struct socket *so)
soisdisconnected(so);
}
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&udbinfo);
+ INP_INFO_WUNLOCK(&V_udbinfo);
}
static int
@@ -733,14 +734,14 @@ udp6_attach(struct socket *so, int proto, struct thread *td)
if (error)
return (error);
}
- INP_INFO_WLOCK(&udbinfo);
- error = in_pcballoc(so, &udbinfo);
+ INP_INFO_WLOCK(&V_udbinfo);
+ error = in_pcballoc(so, &V_udbinfo);
if (error) {
- INP_INFO_WUNLOCK(&udbinfo);
+ INP_INFO_WUNLOCK(&V_udbinfo);
return (error);
}
inp = (struct inpcb *)so->so_pcb;
- INP_INFO_WUNLOCK(&udbinfo);
+ INP_INFO_WUNLOCK(&V_udbinfo);
inp->inp_vflag |= INP_IPV6;
if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0)
inp->inp_vflag |= INP_IPV4;
@@ -752,7 +753,7 @@ udp6_attach(struct socket *so, int proto, struct thread *td)
* because the socket may be bound to an IPv6 wildcard address,
* which may match an IPv4-mapped IPv6 address.
*/
- inp->inp_ip_ttl = ip_defttl;
+ inp->inp_ip_ttl = V_ip_defttl;
INP_WUNLOCK(inp);
return (0);
}
@@ -766,7 +767,7 @@ udp6_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("udp6_bind: inp == NULL"));
- INP_INFO_WLOCK(&udbinfo);
+ INP_INFO_WLOCK(&V_udbinfo);
INP_WLOCK(inp);
inp->inp_vflag &= ~INP_IPV4;
inp->inp_vflag |= INP_IPV6;
@@ -792,7 +793,7 @@ udp6_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
error = in6_pcbbind(inp, nam, td->td_ucred);
out:
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&udbinfo);
+ INP_INFO_WUNLOCK(&V_udbinfo);
return (error);
}
@@ -813,7 +814,7 @@ udp6_close(struct socket *so)
return;
}
#endif
- INP_INFO_WLOCK(&udbinfo);
+ INP_INFO_WLOCK(&V_udbinfo);
INP_WLOCK(inp);
if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)) {
in6_pcbdisconnect(inp);
@@ -821,7 +822,7 @@ udp6_close(struct socket *so)
soisdisconnected(so);
}
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&udbinfo);
+ INP_INFO_WUNLOCK(&V_udbinfo);
}
static int
@@ -833,7 +834,7 @@ udp6_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("udp6_connect: inp == NULL"));
- INP_INFO_WLOCK(&udbinfo);
+ INP_INFO_WLOCK(&V_udbinfo);
INP_WLOCK(inp);
if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0) {
struct sockaddr_in6 *sin6_p;
@@ -872,7 +873,7 @@ udp6_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
}
out:
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&udbinfo);
+ INP_INFO_WUNLOCK(&V_udbinfo);
return (error);
}
@@ -884,11 +885,11 @@ udp6_detach(struct socket *so)
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("udp6_detach: inp == NULL"));
- INP_INFO_WLOCK(&udbinfo);
+ INP_INFO_WLOCK(&V_udbinfo);
INP_WLOCK(inp);
in6_pcbdetach(inp);
in6_pcbfree(inp);
- INP_INFO_WUNLOCK(&udbinfo);
+ INP_INFO_WUNLOCK(&V_udbinfo);
}
static int
@@ -900,7 +901,7 @@ udp6_disconnect(struct socket *so)
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("udp6_disconnect: inp == NULL"));
- INP_INFO_WLOCK(&udbinfo);
+ INP_INFO_WLOCK(&V_udbinfo);
INP_WLOCK(inp);
#ifdef INET
@@ -924,7 +925,7 @@ udp6_disconnect(struct socket *so)
so->so_state &= ~SS_ISCONNECTED; /* XXX */
out:
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&udbinfo);
+ INP_INFO_WUNLOCK(&V_udbinfo);
return (0);
}
@@ -938,7 +939,7 @@ udp6_send(struct socket *so, int flags, struct mbuf *m,
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("udp6_send: inp == NULL"));
- INP_INFO_WLOCK(&udbinfo);
+ INP_INFO_WLOCK(&V_udbinfo);
INP_WLOCK(inp);
if (addr) {
if (addr->sa_len != sizeof(struct sockaddr_in6)) {
@@ -993,12 +994,12 @@ udp6_send(struct socket *so, int flags, struct mbuf *m,
error = udp6_output(inp, m, addr, control, td);
out:
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&udbinfo);
+ INP_INFO_WUNLOCK(&V_udbinfo);
return (error);
bad:
INP_WUNLOCK(inp);
- INP_INFO_WUNLOCK(&udbinfo);
+ INP_INFO_WUNLOCK(&V_udbinfo);
m_freem(m);
return (error);
}
diff --git a/sys/netipsec/ipsec.c b/sys/netipsec/ipsec.c
index 154694a..f973688 100644
--- a/sys/netipsec/ipsec.c
+++ b/sys/netipsec/ipsec.c
@@ -53,6 +53,7 @@
#include <sys/syslog.h>
#include <sys/sysctl.h>
#include <sys/proc.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/route.h>
@@ -240,7 +241,7 @@ key_allocsp_default(const char* where, int tag)
KEYDEBUG(KEYDEBUG_IPSEC_STAMP,
printf("DP key_allocsp_default from %s:%u\n", where, tag));
- sp = &ip4_def_policy;
+ sp = &V_ip4_def_policy;
if (sp->policy != IPSEC_POLICY_DISCARD &&
sp->policy != IPSEC_POLICY_NONE) {
ipseclog((LOG_INFO, "fixed system default policy: %d->%d\n",
@@ -458,7 +459,7 @@ ipsec4_checkpolicy(m, dir, flag, error, inp)
sp = ipsec_getpolicybysock(m, dir, inp, error);
if (sp == NULL) {
IPSEC_ASSERT(*error != 0, ("getpolicy failed w/o error"));
- ipsec4stat.ips_out_inval++;
+ V_ipsec4stat.ips_out_inval++;
return NULL;
}
IPSEC_ASSERT(*error == 0, ("sp w/ error set to %u", *error));
@@ -468,7 +469,7 @@ ipsec4_checkpolicy(m, dir, flag, error, inp)
printf("%s: invalid policy %u\n", __func__, sp->policy);
/* fall thru... */
case IPSEC_POLICY_DISCARD:
- ipsec4stat.ips_out_polvio++;
+ V_ipsec4stat.ips_out_polvio++;
*error = -EINVAL; /* packet is discarded by caller */
break;
case IPSEC_POLICY_BYPASS:
@@ -1289,7 +1290,7 @@ ipsec_get_reqlevel(isr)
#define IPSEC_CHECK_DEFAULT(lev) \
(((lev) != IPSEC_LEVEL_USE && (lev) != IPSEC_LEVEL_REQUIRE \
&& (lev) != IPSEC_LEVEL_UNIQUE) \
- ? (ipsec_debug \
+ ? (V_ipsec_debug \
? log(LOG_INFO, "fixed system default level " #lev ":%d->%d\n",\
(lev), IPSEC_LEVEL_REQUIRE) \
: 0), \
@@ -1301,18 +1302,18 @@ ipsec_get_reqlevel(isr)
switch (((struct sockaddr *)&isr->sp->spidx.src)->sa_family) {
#ifdef INET
case AF_INET:
- esp_trans_deflev = IPSEC_CHECK_DEFAULT(ip4_esp_trans_deflev);
- esp_net_deflev = IPSEC_CHECK_DEFAULT(ip4_esp_net_deflev);
- ah_trans_deflev = IPSEC_CHECK_DEFAULT(ip4_ah_trans_deflev);
- ah_net_deflev = IPSEC_CHECK_DEFAULT(ip4_ah_net_deflev);
+ esp_trans_deflev = IPSEC_CHECK_DEFAULT(V_ip4_esp_trans_deflev);
+ esp_net_deflev = IPSEC_CHECK_DEFAULT(V_ip4_esp_net_deflev);
+ ah_trans_deflev = IPSEC_CHECK_DEFAULT(V_ip4_ah_trans_deflev);
+ ah_net_deflev = IPSEC_CHECK_DEFAULT(V_ip4_ah_net_deflev);
break;
#endif
#ifdef INET6
case AF_INET6:
- esp_trans_deflev = IPSEC_CHECK_DEFAULT(ip6_esp_trans_deflev);
- esp_net_deflev = IPSEC_CHECK_DEFAULT(ip6_esp_net_deflev);
- ah_trans_deflev = IPSEC_CHECK_DEFAULT(ip6_ah_trans_deflev);
- ah_net_deflev = IPSEC_CHECK_DEFAULT(ip6_ah_net_deflev);
+ esp_trans_deflev = IPSEC_CHECK_DEFAULT(V_ip6_esp_trans_deflev);
+ esp_net_deflev = IPSEC_CHECK_DEFAULT(V_ip6_esp_net_deflev);
+ ah_trans_deflev = IPSEC_CHECK_DEFAULT(V_ip6_ah_trans_deflev);
+ ah_net_deflev = IPSEC_CHECK_DEFAULT(V_ip6_ah_net_deflev);
break;
#endif /* INET6 */
default:
@@ -1472,7 +1473,7 @@ ipsec4_in_reject(m, inp)
if (sp != NULL) {
result = ipsec_in_reject(sp, m);
if (result)
- ipsec4stat.ips_in_polvio++;
+ V_ipsec4stat.ips_in_polvio++;
KEY_FREESP(&sp);
} else {
result = 0; /* XXX should be panic ?
@@ -1512,7 +1513,7 @@ ipsec6_in_reject(m, inp)
if (sp != NULL) {
result = ipsec_in_reject(sp, m);
if (result)
- ipsec6stat.ips_in_polvio++;
+ V_ipsec6stat.ips_in_polvio++;
KEY_FREESP(&sp);
} else {
result = 0;
@@ -1936,7 +1937,7 @@ ipsec_dumpmbuf(m)
static void
ipsec_attach(void)
{
- SECPOLICY_LOCK_INIT(&ip4_def_policy);
+ SECPOLICY_LOCK_INIT(&V_ip4_def_policy);
ip4_def_policy.refcnt = 1; /* NB: disallow free */
}
SYSINIT(ipsec, SI_SUB_PROTO_DOMAIN, SI_ORDER_FIRST, ipsec_attach, NULL);
diff --git a/sys/netipsec/ipsec.h b/sys/netipsec/ipsec.h
index 6c7e4fb..6f04611 100644
--- a/sys/netipsec/ipsec.h
+++ b/sys/netipsec/ipsec.h
@@ -351,9 +351,9 @@ extern int ip4_ipsec_ecn;
extern int ip4_esp_randpad;
extern int crypto_support;
-#define ipseclog(x) do { if (ipsec_debug) log x; } while (0)
+#define ipseclog(x) do { if (V_ipsec_debug) log x; } while (0)
/* for openbsd compatibility */
-#define DPRINTF(x) do { if (ipsec_debug) printf x; } while (0)
+#define DPRINTF(x) do { if (V_ipsec_debug) printf x; } while (0)
extern struct ipsecrequest *ipsec_newisr(void);
extern void ipsec_delisr(struct ipsecrequest *);
diff --git a/sys/netipsec/ipsec_input.c b/sys/netipsec/ipsec_input.c
index edd2223..0041698 100644
--- a/sys/netipsec/ipsec_input.c
+++ b/sys/netipsec/ipsec_input.c
@@ -54,6 +54,7 @@
#include <sys/socket.h>
#include <sys/errno.h>
#include <sys/syslog.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/pfil.h>
@@ -117,8 +118,8 @@ ipsec_common_input(struct mbuf *m, int skip, int protoff, int af, int sproto)
u_int32_t spi;
int error;
- IPSEC_ISTAT(sproto, espstat.esps_input, ahstat.ahs_input,
- ipcompstat.ipcomps_input);
+ IPSEC_ISTAT(sproto, V_espstat.esps_input, V_ahstat.ahs_input,
+ V_ipcompstat.ipcomps_input);
IPSEC_ASSERT(m != NULL, ("null packet"));
@@ -126,19 +127,19 @@ ipsec_common_input(struct mbuf *m, int skip, int protoff, int af, int sproto)
sproto == IPPROTO_IPCOMP,
("unexpected security protocol %u", sproto));
- if ((sproto == IPPROTO_ESP && !esp_enable) ||
- (sproto == IPPROTO_AH && !ah_enable) ||
- (sproto == IPPROTO_IPCOMP && !ipcomp_enable)) {
+ if ((sproto == IPPROTO_ESP && !V_esp_enable) ||
+ (sproto == IPPROTO_AH && !V_ah_enable) ||
+ (sproto == IPPROTO_IPCOMP && !V_ipcomp_enable)) {
m_freem(m);
- IPSEC_ISTAT(sproto, espstat.esps_pdrops, ahstat.ahs_pdrops,
- ipcompstat.ipcomps_pdrops);
+ IPSEC_ISTAT(sproto, V_espstat.esps_pdrops, V_ahstat.ahs_pdrops,
+ V_ipcompstat.ipcomps_pdrops);
return EOPNOTSUPP;
}
if (m->m_pkthdr.len - skip < 2 * sizeof (u_int32_t)) {
m_freem(m);
- IPSEC_ISTAT(sproto, espstat.esps_hdrops, ahstat.ahs_hdrops,
- ipcompstat.ipcomps_hdrops);
+ IPSEC_ISTAT(sproto, V_espstat.esps_hdrops, V_ahstat.ahs_hdrops,
+ V_ipcompstat.ipcomps_hdrops);
DPRINTF(("%s: packet too small\n", __func__));
return EINVAL;
}
@@ -183,8 +184,8 @@ ipsec_common_input(struct mbuf *m, int skip, int protoff, int af, int sproto)
default:
DPRINTF(("%s: unsupported protocol family %u\n", __func__, af));
m_freem(m);
- IPSEC_ISTAT(sproto, espstat.esps_nopf, ahstat.ahs_nopf,
- ipcompstat.ipcomps_nopf);
+ IPSEC_ISTAT(sproto, V_espstat.esps_nopf, V_ahstat.ahs_nopf,
+ V_ipcompstat.ipcomps_nopf);
return EPFNOSUPPORT;
}
@@ -194,8 +195,8 @@ ipsec_common_input(struct mbuf *m, int skip, int protoff, int af, int sproto)
DPRINTF(("%s: no key association found for SA %s/%08lx/%u\n",
__func__, ipsec_address(&dst_address),
(u_long) ntohl(spi), sproto));
- IPSEC_ISTAT(sproto, espstat.esps_notdb, ahstat.ahs_notdb,
- ipcompstat.ipcomps_notdb);
+ IPSEC_ISTAT(sproto, V_espstat.esps_notdb, V_ahstat.ahs_notdb,
+ V_ipcompstat.ipcomps_notdb);
m_freem(m);
return ENOENT;
}
@@ -204,8 +205,8 @@ ipsec_common_input(struct mbuf *m, int skip, int protoff, int af, int sproto)
DPRINTF(("%s: attempted to use uninitialized SA %s/%08lx/%u\n",
__func__, ipsec_address(&dst_address),
(u_long) ntohl(spi), sproto));
- IPSEC_ISTAT(sproto, espstat.esps_noxform, ahstat.ahs_noxform,
- ipcompstat.ipcomps_noxform);
+ IPSEC_ISTAT(sproto, V_espstat.esps_noxform, V_ahstat.ahs_noxform,
+ V_ipcompstat.ipcomps_noxform);
KEY_FREESAV(&sav);
m_freem(m);
return ENXIO;
@@ -307,8 +308,8 @@ ipsec4_common_input_cb(struct mbuf *m, struct secasvar *sav,
/* Sanity check */
if (m == NULL) {
DPRINTF(("%s: null mbuf", __func__));
- IPSEC_ISTAT(sproto, espstat.esps_badkcr, ahstat.ahs_badkcr,
- ipcompstat.ipcomps_badkcr);
+ IPSEC_ISTAT(sproto, V_espstat.esps_badkcr, V_ahstat.ahs_badkcr,
+ V_ipcompstat.ipcomps_badkcr);
KEY_FREESAV(&sav);
return EINVAL;
}
@@ -319,8 +320,8 @@ ipsec4_common_input_cb(struct mbuf *m, struct secasvar *sav,
DPRINTF(("%s: processing failed for SA %s/%08lx\n",
__func__, ipsec_address(&sav->sah->saidx.dst),
(u_long) ntohl(sav->spi)));
- IPSEC_ISTAT(sproto, espstat.esps_hdrops, ahstat.ahs_hdrops,
- ipcompstat.ipcomps_hdrops);
+ IPSEC_ISTAT(sproto, V_espstat.esps_hdrops, V_ahstat.ahs_hdrops,
+ V_ipcompstat.ipcomps_hdrops);
error = ENOBUFS;
goto bad;
}
@@ -341,9 +342,9 @@ ipsec4_common_input_cb(struct mbuf *m, struct secasvar *sav,
struct ip ipn;
if (m->m_pkthdr.len - skip < sizeof(struct ip)) {
- IPSEC_ISTAT(sproto, espstat.esps_hdrops,
- ahstat.ahs_hdrops,
- ipcompstat.ipcomps_hdrops);
+ IPSEC_ISTAT(sproto, V_espstat.esps_hdrops,
+ V_ahstat.ahs_hdrops,
+ V_ipcompstat.ipcomps_hdrops);
error = EINVAL;
goto bad;
}
@@ -372,9 +373,9 @@ ipsec4_common_input_cb(struct mbuf *m, struct secasvar *sav,
ipsp_address(saidx->dst),
(u_long) ntohl(sav->spi)));
- IPSEC_ISTAT(sproto, espstat.esps_pdrops,
- ahstat.ahs_pdrops,
- ipcompstat.ipcomps_pdrops);
+ IPSEC_ISTAT(sproto, V_espstat.esps_pdrops,
+ V_ahstat.ahs_pdrops,
+ V_ipcompstat.ipcomps_pdrops);
error = EACCES;
goto bad;
}
@@ -385,9 +386,9 @@ ipsec4_common_input_cb(struct mbuf *m, struct secasvar *sav,
struct ip6_hdr ip6n;
if (m->m_pkthdr.len - skip < sizeof(struct ip6_hdr)) {
- IPSEC_ISTAT(sproto, espstat.esps_hdrops,
- ahstat.ahs_hdrops,
- ipcompstat.ipcomps_hdrops);
+ IPSEC_ISTAT(sproto, V_espstat.esps_hdrops,
+ V_ahstat.ahs_hdrops,
+ V_ipcompstat.ipcomps_hdrops);
error = EINVAL;
goto bad;
}
@@ -414,9 +415,9 @@ ipsec4_common_input_cb(struct mbuf *m, struct secasvar *sav,
ipsec_address(&saidx->dst),
(u_long) ntohl(sav->spi)));
- IPSEC_ISTAT(sproto, espstat.esps_pdrops,
- ahstat.ahs_pdrops,
- ipcompstat.ipcomps_pdrops);
+ IPSEC_ISTAT(sproto, V_espstat.esps_pdrops,
+ V_ahstat.ahs_pdrops,
+ V_ipcompstat.ipcomps_pdrops);
error = EACCES;
goto bad;
}
@@ -437,8 +438,8 @@ ipsec4_common_input_cb(struct mbuf *m, struct secasvar *sav,
sizeof(struct tdb_ident), M_NOWAIT);
if (mtag == NULL) {
DPRINTF(("%s: failed to get tag\n", __func__));
- IPSEC_ISTAT(sproto, espstat.esps_hdrops,
- ahstat.ahs_hdrops, ipcompstat.ipcomps_hdrops);
+ IPSEC_ISTAT(sproto, V_espstat.esps_hdrops,
+ V_ahstat.ahs_hdrops, V_ipcompstat.ipcomps_hdrops);
error = ENOMEM;
goto bad;
}
@@ -478,8 +479,8 @@ ipsec4_common_input_cb(struct mbuf *m, struct secasvar *sav,
* Re-dispatch via software interrupt.
*/
if ((error = netisr_queue(NETISR_IP, m))) {
- IPSEC_ISTAT(sproto, espstat.esps_qfull, ahstat.ahs_qfull,
- ipcompstat.ipcomps_qfull);
+ IPSEC_ISTAT(sproto, V_espstat.esps_qfull, V_ahstat.ahs_qfull,
+ V_ipcompstat.ipcomps_qfull);
DPRINTF(("%s: queue full; proto %u packet dropped\n",
__func__, sproto));
@@ -532,9 +533,9 @@ ipsec6_common_input(struct mbuf **mp, int *offp, int proto)
if (protoff + l != *offp) {
DPRINTF(("%s: bad packet header chain, protoff %u, "
"l %u, off %u\n", __func__, protoff, l, *offp));
- IPSEC_ISTAT(proto, espstat.esps_hdrops,
- ahstat.ahs_hdrops,
- ipcompstat.ipcomps_hdrops);
+ IPSEC_ISTAT(proto, V_espstat.esps_hdrops,
+ V_ahstat.ahs_hdrops,
+ V_ipcompstat.ipcomps_hdrops);
m_freem(*mp);
*mp = NULL;
return IPPROTO_DONE;
@@ -579,8 +580,8 @@ ipsec6_common_input_cb(struct mbuf *m, struct secasvar *sav, int skip, int proto
/* Sanity check */
if (m == NULL) {
DPRINTF(("%s: null mbuf", __func__));
- IPSEC_ISTAT(sproto, espstat.esps_badkcr, ahstat.ahs_badkcr,
- ipcompstat.ipcomps_badkcr);
+ IPSEC_ISTAT(sproto, V_espstat.esps_badkcr, V_ahstat.ahs_badkcr,
+ V_ipcompstat.ipcomps_badkcr);
error = EINVAL;
goto bad;
}
@@ -593,8 +594,8 @@ ipsec6_common_input_cb(struct mbuf *m, struct secasvar *sav, int skip, int proto
__func__, ipsec_address(&sav->sah->saidx.dst),
(u_long) ntohl(sav->spi)));
- IPSEC_ISTAT(sproto, espstat.esps_hdrops, ahstat.ahs_hdrops,
- ipcompstat.ipcomps_hdrops);
+ IPSEC_ISTAT(sproto, V_espstat.esps_hdrops, V_ahstat.ahs_hdrops,
+ V_ipcompstat.ipcomps_hdrops);
error = EACCES;
goto bad;
}
@@ -612,9 +613,9 @@ ipsec6_common_input_cb(struct mbuf *m, struct secasvar *sav, int skip, int proto
struct ip ipn;
if (m->m_pkthdr.len - skip < sizeof(struct ip)) {
- IPSEC_ISTAT(sproto, espstat.esps_hdrops,
- ahstat.ahs_hdrops,
- ipcompstat.ipcomps_hdrops);
+ IPSEC_ISTAT(sproto, V_espstat.esps_hdrops,
+ V_ahstat.ahs_hdrops,
+ V_ipcompstat.ipcomps_hdrops);
error = EINVAL;
goto bad;
}
@@ -639,8 +640,8 @@ ipsec6_common_input_cb(struct mbuf *m, struct secasvar *sav, int skip, int proto
ipsec_address(&saidx->dst),
(u_long) ntohl(sav->spi)));
- IPSEC_ISTATsproto, (espstat.esps_pdrops,
- ahstat.ahs_pdrops, ipcompstat.ipcomps_pdrops);
+ IPSEC_ISTATsproto, (V_espstat.esps_pdrops,
+ V_ahstat.ahs_pdrops, V_ipcompstat.ipcomps_pdrops);
error = EACCES;
goto bad;
}
@@ -652,9 +653,9 @@ ipsec6_common_input_cb(struct mbuf *m, struct secasvar *sav, int skip, int proto
struct ip6_hdr ip6n;
if (m->m_pkthdr.len - skip < sizeof(struct ip6_hdr)) {
- IPSEC_ISTAT(sproto, espstat.esps_hdrops,
- ahstat.ahs_hdrops,
- ipcompstat.ipcomps_hdrops);
+ IPSEC_ISTAT(sproto, V_espstat.esps_hdrops,
+ V_ahstat.ahs_hdrops,
+ V_ipcompstat.ipcomps_hdrops);
error = EINVAL;
goto bad;
}
@@ -681,8 +682,8 @@ ipsec6_common_input_cb(struct mbuf *m, struct secasvar *sav, int skip, int proto
ipsec_address(&saidx->dst),
(u_long) ntohl(sav->spi)));
- IPSEC_ISTAT(sproto, espstat.esps_pdrops,
- ahstat.ahs_pdrops, ipcompstat.ipcomps_pdrops);
+ IPSEC_ISTAT(sproto, V_espstat.esps_pdrops,
+ V_ahstat.ahs_pdrops, V_ipcompstat.ipcomps_pdrops);
error = EACCES;
goto bad;
}
@@ -702,8 +703,8 @@ ipsec6_common_input_cb(struct mbuf *m, struct secasvar *sav, int skip, int proto
sizeof(struct tdb_ident), M_NOWAIT);
if (mtag == NULL) {
DPRINTF(("%s: failed to get tag\n", __func__));
- IPSEC_ISTAT(sproto, espstat.esps_hdrops,
- ahstat.ahs_hdrops, ipcompstat.ipcomps_hdrops);
+ IPSEC_ISTAT(sproto, V_espstat.esps_hdrops,
+ V_ahstat.ahs_hdrops, V_ipcompstat.ipcomps_hdrops);
error = ENOMEM;
goto bad;
}
@@ -751,8 +752,8 @@ ipsec6_common_input_cb(struct mbuf *m, struct secasvar *sav, int skip, int proto
nest = 0;
nxt = nxt8;
while (nxt != IPPROTO_DONE) {
- if (ip6_hdrnestlimit && (++nest > ip6_hdrnestlimit)) {
- ip6stat.ip6s_toomanyhdr++;
+ if (V_ip6_hdrnestlimit && (++nest > V_ip6_hdrnestlimit)) {
+ V_ip6stat.ip6s_toomanyhdr++;
error = EINVAL;
goto bad;
}
@@ -762,7 +763,7 @@ ipsec6_common_input_cb(struct mbuf *m, struct secasvar *sav, int skip, int proto
* more sanity checks in header chain processing.
*/
if (m->m_pkthdr.len < skip) {
- ip6stat.ip6s_tooshort++;
+ V_ip6stat.ip6s_tooshort++;
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_truncated);
error = EINVAL;
goto bad;
diff --git a/sys/netipsec/ipsec_mbuf.c b/sys/netipsec/ipsec_mbuf.c
index d4ec42a..79c1928 100644
--- a/sys/netipsec/ipsec_mbuf.c
+++ b/sys/netipsec/ipsec_mbuf.c
@@ -36,6 +36,7 @@
#include <sys/systm.h>
#include <sys/mbuf.h>
#include <sys/socket.h>
+#include <sys/vimage.h>
#include <net/route.h>
#include <netinet/in.h>
@@ -88,7 +89,7 @@ m_makespace(struct mbuf *m0, int skip, int hlen, int *off)
return (NULL);
n->m_next = m->m_next; /* splice new mbuf */
m->m_next = n;
- ipsec4stat.ips_mbinserted++;
+ V_ipsec4stat.ips_mbinserted++;
if (hlen <= M_TRAILINGSPACE(m) + remain) {
/*
* New header fits in the old mbuf if we copy
@@ -122,7 +123,7 @@ m_makespace(struct mbuf *m0, int skip, int hlen, int *off)
/* splice in second mbuf */
n2->m_next = n->m_next;
n->m_next = n2;
- ipsec4stat.ips_mbinserted++;
+ V_ipsec4stat.ips_mbinserted++;
} else {
memcpy(mtod(n, caddr_t) + hlen,
mtod(m, caddr_t) + skip, remain);
@@ -238,7 +239,7 @@ m_striphdr(struct mbuf *m, int skip, int hlen)
/* Remove the header and associated data from the mbuf. */
if (roff == 0) {
/* The header was at the beginning of the mbuf */
- ipsec4stat.ips_input_front++;
+ V_ipsec4stat.ips_input_front++;
m_adj(m1, hlen);
if ((m1->m_flags & M_PKTHDR) == 0)
m->m_pkthdr.len -= hlen;
@@ -250,7 +251,7 @@ m_striphdr(struct mbuf *m, int skip, int hlen)
* so first let's remove the remainder of the header from
* the beginning of the remainder of the mbuf chain, if any.
*/
- ipsec4stat.ips_input_end++;
+ V_ipsec4stat.ips_input_end++;
if (roff + hlen > m1->m_len) {
/* Adjust the next mbuf by the remainder */
m_adj(m1->m_next, roff + hlen - m1->m_len);
@@ -275,7 +276,7 @@ m_striphdr(struct mbuf *m, int skip, int hlen)
* The header lies in the "middle" of the mbuf; copy
* the remainder of the mbuf down over the header.
*/
- ipsec4stat.ips_input_middle++;
+ V_ipsec4stat.ips_input_middle++;
bcopy(mtod(m1, u_char *) + roff + hlen,
mtod(m1, u_char *) + roff,
m1->m_len - (roff + hlen));
diff --git a/sys/netipsec/ipsec_output.c b/sys/netipsec/ipsec_output.c
index 72840c2..88ff2f6 100644
--- a/sys/netipsec/ipsec_output.c
+++ b/sys/netipsec/ipsec_output.c
@@ -42,6 +42,7 @@
#include <sys/socket.h>
#include <sys/errno.h>
#include <sys/syslog.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/pfil.h>
@@ -159,7 +160,7 @@ ipsec_process_done(struct mbuf *m, struct ipsecrequest *isr)
* doing further processing.
*/
if (isr->next) {
- ipsec4stat.ips_out_bundlesa++;
+ V_ipsec4stat.ips_out_bundlesa++;
return ipsec4_process_packet(m, isr->next, 0, 0);
}
key_sa_recordxfer(sav, m); /* record data transfer */
@@ -284,7 +285,7 @@ again:
* this packet because it is responsibility for
* upper layer to retransmit the packet.
*/
- ipsec4stat.ips_out_nosa++;
+ V_ipsec4stat.ips_out_nosa++;
goto bad;
}
sav = isr->sav;
@@ -308,13 +309,13 @@ again:
/*
* Check system global policy controls.
*/
- if ((isr->saidx.proto == IPPROTO_ESP && !esp_enable) ||
- (isr->saidx.proto == IPPROTO_AH && !ah_enable) ||
- (isr->saidx.proto == IPPROTO_IPCOMP && !ipcomp_enable)) {
+ if ((isr->saidx.proto == IPPROTO_ESP && !V_esp_enable) ||
+ (isr->saidx.proto == IPPROTO_AH && !V_ah_enable) ||
+ (isr->saidx.proto == IPPROTO_IPCOMP && !V_ipcomp_enable)) {
DPRINTF(("%s: IPsec outbound packet dropped due"
" to policy (check your sysctls)\n", __func__));
- IPSEC_OSTAT(espstat.esps_pdrops, ahstat.ahs_pdrops,
- ipcompstat.ipcomps_pdrops);
+ IPSEC_OSTAT(V_espstat.esps_pdrops, V_ahstat.ahs_pdrops,
+ V_ipcompstat.ipcomps_pdrops);
*error = EHOSTUNREACH;
goto bad;
}
@@ -325,8 +326,8 @@ again:
*/
if (sav->tdb_xform == NULL) {
DPRINTF(("%s: no transform for SA\n", __func__));
- IPSEC_OSTAT(espstat.esps_noxform, ahstat.ahs_noxform,
- ipcompstat.ipcomps_noxform);
+ IPSEC_OSTAT(V_espstat.esps_noxform, V_ahstat.ahs_noxform,
+ V_ipcompstat.ipcomps_noxform);
*error = EHOSTUNREACH;
goto bad;
}
@@ -394,10 +395,10 @@ ipsec4_process_packet(
}
ip = mtod(m, struct ip *);
/* Honor system-wide control of how to handle IP_DF */
- switch (ip4_ipsec_dfbit) {
+ switch (V_ip4_ipsec_dfbit) {
case 0: /* clear in outer header */
case 1: /* set in outer header */
- setdf = ip4_ipsec_dfbit;
+ setdf = V_ip4_ipsec_dfbit;
break;
default: /* propagate to outer header */
setdf = ntohs(ip->ip_off & IP_DF);
@@ -676,7 +677,7 @@ ipsec6_encapsulate(struct mbuf *m, struct secasvar *sav)
/* construct new IPv6 header. see RFC 2401 5.1.2.2 */
/* ECN consideration. */
- ip6_ecn_ingress(ip6_ipsec_ecn, &ip6->ip6_flow, &oip6->ip6_flow);
+ ip6_ecn_ingress(V_ip6_ipsec_ecn, &ip6->ip6_flow, &oip6->ip6_flow);
if (plen < IPV6_MAXPACKET - sizeof(struct ip6_hdr))
ip6->ip6_plen = htons(plen);
else {
@@ -755,14 +756,14 @@ ipsec6_output_tunnel(struct ipsec_output_state *state, struct secpolicy *sp, int
ipseclog((LOG_ERR, "%s: family mismatched between "
"inner and outer, spi=%u\n", __func__,
ntohl(isr->sav->spi)));
- ipsec6stat.ips_out_inval++;
+ V_ipsec6stat.ips_out_inval++;
error = EAFNOSUPPORT;
goto bad;
}
m = ipsec6_splithdr(m);
if (!m) {
- ipsec6stat.ips_out_nomem++;
+ V_ipsec6stat.ips_out_nomem++;
error = ENOMEM;
goto bad;
}
@@ -790,8 +791,8 @@ ipsec6_output_tunnel(struct ipsec_output_state *state, struct secpolicy *sp, int
rtalloc(state->ro);
}
if (state->ro->ro_rt == 0) {
- ip6stat.ip6s_noroute++;
- ipsec6stat.ips_out_noroute++;
+ V_ip6stat.ip6s_noroute++;
+ V_ipsec6stat.ips_out_noroute++;
error = EHOSTUNREACH;
goto bad;
}
@@ -805,7 +806,7 @@ ipsec6_output_tunnel(struct ipsec_output_state *state, struct secpolicy *sp, int
m = ipsec6_splithdr(m);
if (!m) {
- ipsec6stat.ips_out_nomem++;
+ V_ipsec6stat.ips_out_nomem++;
error = ENOMEM;
goto bad;
}
diff --git a/sys/netipsec/key.c b/sys/netipsec/key.c
index dc66a39..e575cdc 100644
--- a/sys/netipsec/key.c
+++ b/sys/netipsec/key.c
@@ -96,6 +96,7 @@
/* randomness */
#include <sys/random.h>
+#include <sys/vimage.h>
#define FULLMASK 0xff
#define _BITS(bytes) ((bytes) << 3)
@@ -554,7 +555,7 @@ int
key_havesp(u_int dir)
{
return (dir == IPSEC_DIR_INBOUND || dir == IPSEC_DIR_OUTBOUND ?
- LIST_FIRST(&sptree[dir]) != NULL : 1);
+ LIST_FIRST(&V_sptree[dir]) != NULL : 1);
}
/* %%% IPsec policy management */
@@ -582,7 +583,7 @@ key_allocsp(struct secpolicyindex *spidx, u_int dir, const char* where, int tag)
kdebug_secpolicyindex(spidx));
SPTREE_LOCK();
- LIST_FOREACH(sp, &sptree[dir], chain) {
+ LIST_FOREACH(sp, &V_sptree[dir], chain) {
KEYDEBUG(KEYDEBUG_IPSEC_DATA,
printf("*** in SPD\n");
kdebug_secpolicyindex(&sp->spidx));
@@ -639,7 +640,7 @@ key_allocsp2(u_int32_t spi,
kdebug_sockaddr(&dst->sa));
SPTREE_LOCK();
- LIST_FOREACH(sp, &sptree[dir], chain) {
+ LIST_FOREACH(sp, &V_sptree[dir], chain) {
KEYDEBUG(KEYDEBUG_IPSEC_DATA,
printf("*** in SPD\n");
kdebug_secpolicyindex(&sp->spidx));
@@ -700,7 +701,7 @@ key_gettunnel(const struct sockaddr *osrc,
}
SPTREE_LOCK();
- LIST_FOREACH(sp, &sptree[dir], chain) {
+ LIST_FOREACH(sp, &V_sptree[dir], chain) {
if (sp->state == IPSEC_SPSTATE_DEAD)
continue;
@@ -859,11 +860,11 @@ key_allocsa_policy(const struct secasindex *saidx)
const u_int *state_valid;
SAHTREE_LOCK();
- LIST_FOREACH(sah, &sahtree, chain) {
+ LIST_FOREACH(sah, &V_sahtree, chain) {
if (sah->state == SADB_SASTATE_DEAD)
continue;
if (key_cmpsaidx(&sah->saidx, saidx, CMP_MODE_REQID)) {
- if (key_preferred_oldsa) {
+ if (V_key_preferred_oldsa) {
state_valid = saorder_state_valid_prefer_old;
arraysize = N(saorder_state_valid_prefer_old);
} else {
@@ -928,7 +929,7 @@ key_do_allocsa_policy(struct secashead *sah, u_int state)
IPSEC_ASSERT(sav->lft_c != NULL, ("null sav lifetime"));
/* What the best method is to compare ? */
- if (key_preferred_oldsa) {
+ if (V_key_preferred_oldsa) {
if (candidate->lft_c->addtime >
sav->lft_c->addtime) {
candidate = sav;
@@ -1062,14 +1063,14 @@ key_allocsa(
* encrypted so we can't check internal IP header.
*/
SAHTREE_LOCK();
- if (key_preferred_oldsa) {
+ if (V_key_preferred_oldsa) {
saorder_state_valid = saorder_state_valid_prefer_old;
arraysize = _ARRAYLEN(saorder_state_valid_prefer_old);
} else {
saorder_state_valid = saorder_state_valid_prefer_new;
arraysize = _ARRAYLEN(saorder_state_valid_prefer_new);
}
- LIST_FOREACH(sah, &sahtree, chain) {
+ LIST_FOREACH(sah, &V_sahtree, chain) {
/* search valid state */
for (stateidx = 0; stateidx < arraysize; stateidx++) {
state = saorder_state_valid[stateidx];
@@ -1270,7 +1271,7 @@ key_getsp(struct secpolicyindex *spidx)
IPSEC_ASSERT(spidx != NULL, ("null spidx"));
SPTREE_LOCK();
- LIST_FOREACH(sp, &sptree[spidx->dir], chain) {
+ LIST_FOREACH(sp, &V_sptree[spidx->dir], chain) {
if (sp->state == IPSEC_SPSTATE_DEAD)
continue;
if (key_cmpspidx_exactly(spidx, &sp->spidx)) {
@@ -1294,7 +1295,7 @@ key_getspbyid(u_int32_t id)
struct secpolicy *sp;
SPTREE_LOCK();
- LIST_FOREACH(sp, &sptree[IPSEC_DIR_INBOUND], chain) {
+ LIST_FOREACH(sp, &V_sptree[IPSEC_DIR_INBOUND], chain) {
if (sp->state == IPSEC_SPSTATE_DEAD)
continue;
if (sp->id == id) {
@@ -1303,7 +1304,7 @@ key_getspbyid(u_int32_t id)
}
}
- LIST_FOREACH(sp, &sptree[IPSEC_DIR_OUTBOUND], chain) {
+ LIST_FOREACH(sp, &V_sptree[IPSEC_DIR_OUTBOUND], chain) {
if (sp->state == IPSEC_SPSTATE_DEAD)
continue;
if (sp->id == id) {
@@ -1905,7 +1906,7 @@ key_spdadd(so, m, mhp)
newsp->refcnt = 1; /* do not reclaim until I say I do */
newsp->state = IPSEC_SPSTATE_ALIVE;
- LIST_INSERT_TAIL(&sptree[newsp->spidx.dir], newsp, secpolicy, chain);
+ LIST_INSERT_TAIL(&V_sptree[newsp->spidx.dir], newsp, secpolicy, chain);
/* delete the entry in spacqtree */
if (mhp->msg->sadb_msg_type == SADB_X_SPDUPDATE) {
@@ -1974,12 +1975,12 @@ static u_int32_t
key_getnewspid()
{
u_int32_t newid = 0;
- int count = key_spi_trycnt; /* XXX */
+ int count = V_key_spi_trycnt; /* XXX */
struct secpolicy *sp;
/* when requesting to allocate spi ranged */
while (count--) {
- newid = (policy_id = (policy_id == ~0 ? 1 : policy_id + 1));
+ newid = (V_policy_id = (V_policy_id == ~0 ? 1 : V_policy_id + 1));
if ((sp = key_getspbyid(newid)) == NULL)
break;
@@ -2266,7 +2267,7 @@ key_spdacquire(sp)
/* Get an entry to check whether sent message or not. */
newspacq = key_getspacq(&sp->spidx);
if (newspacq != NULL) {
- if (key_blockacq_count < newspacq->count) {
+ if (V_key_blockacq_count < newspacq->count) {
/* reset counter and do send message. */
newspacq->count = 0;
} else {
@@ -2331,7 +2332,7 @@ key_spdflush(so, m, mhp)
for (dir = 0; dir < IPSEC_DIR_MAX; dir++) {
SPTREE_LOCK();
- LIST_FOREACH(sp, &sptree[dir], chain)
+ LIST_FOREACH(sp, &V_sptree[dir], chain)
sp->state = IPSEC_SPSTATE_DEAD;
SPTREE_UNLOCK();
}
@@ -2382,7 +2383,7 @@ key_spddump(so, m, mhp)
/* search SPD entry and get buffer size. */
cnt = 0;
for (dir = 0; dir < IPSEC_DIR_MAX; dir++) {
- LIST_FOREACH(sp, &sptree[dir], chain) {
+ LIST_FOREACH(sp, &V_sptree[dir], chain) {
cnt++;
}
}
@@ -2391,7 +2392,7 @@ key_spddump(so, m, mhp)
return key_senderror(so, m, ENOENT);
for (dir = 0; dir < IPSEC_DIR_MAX; dir++) {
- LIST_FOREACH(sp, &sptree[dir], chain) {
+ LIST_FOREACH(sp, &V_sptree[dir], chain) {
--cnt;
n = key_setdumpsp(sp, SADB_X_SPDDUMP, cnt,
mhp->msg->sadb_msg_pid);
@@ -2646,7 +2647,7 @@ key_newsah(saidx)
newsah->state = SADB_SASTATE_MATURE;
SAHTREE_LOCK();
- LIST_INSERT_HEAD(&sahtree, newsah, chain);
+ LIST_INSERT_HEAD(&V_sahtree, newsah, chain);
SAHTREE_UNLOCK();
}
return(newsah);
@@ -2668,9 +2669,9 @@ key_delsah(sah)
/* searching all SA registerd in the secindex. */
for (stateidx = 0;
- stateidx < _ARRAYLEN(saorder_state_any);
+ stateidx < _ARRAYLEN(V_saorder_state_any);
stateidx++) {
- u_int state = saorder_state_any[stateidx];
+ u_int state = V_saorder_state_any[stateidx];
LIST_FOREACH_SAFE(sav, &sah->savtree[state], chain, nextsav) {
if (sav->refcnt == 0) {
/* sanity check */
@@ -2738,7 +2739,7 @@ key_newsav(m, mhp, sah, errp, where, tag)
/* sync sequence number */
if (mhp->msg->sadb_msg_seq == 0)
newsav->seq =
- (acq_seq = (acq_seq == ~0 ? 1 : ++acq_seq));
+ (V_acq_seq = (V_acq_seq == ~0 ? 1 : ++V_acq_seq));
else
#endif
newsav->seq = mhp->msg->sadb_msg_seq;
@@ -2884,7 +2885,7 @@ key_getsah(saidx)
struct secashead *sah;
SAHTREE_LOCK();
- LIST_FOREACH(sah, &sahtree, chain) {
+ LIST_FOREACH(sah, &V_sahtree, chain) {
if (sah->state == SADB_SASTATE_DEAD)
continue;
if (key_cmpsaidx(&sah->saidx, saidx, CMP_REQID))
@@ -2920,7 +2921,7 @@ key_checkspidup(saidx, spi)
sav = NULL;
/* check all SAD */
SAHTREE_LOCK();
- LIST_FOREACH(sah, &sahtree, chain) {
+ LIST_FOREACH(sah, &V_sahtree, chain) {
if (!key_ismyaddr((struct sockaddr *)&sah->saidx.dst))
continue;
sav = key_getsavbyspi(sah, spi);
@@ -2950,10 +2951,10 @@ key_getsavbyspi(sah, spi)
SAHTREE_LOCK_ASSERT();
/* search all status */
for (stateidx = 0;
- stateidx < _ARRAYLEN(saorder_state_alive);
+ stateidx < _ARRAYLEN(V_saorder_state_alive);
stateidx++) {
- state = saorder_state_alive[stateidx];
+ state = V_saorder_state_alive[stateidx];
LIST_FOREACH(sav, &sah->savtree[state], chain) {
/* sanity check */
@@ -3716,7 +3717,7 @@ key_ismyaddr(sa)
#ifdef INET
case AF_INET:
sin = (struct sockaddr_in *)sa;
- for (ia = in_ifaddrhead.tqh_first; ia;
+ for (ia = V_in_ifaddrhead.tqh_first; ia;
ia = ia->ia_link.tqe_next)
{
if (sin->sin_family == ia->ia_addr.sin_family &&
@@ -3753,7 +3754,7 @@ key_ismyaddr6(sin6)
struct in6_ifaddr *ia;
struct in6_multi *in6m;
- for (ia = in6_ifaddr; ia; ia = ia->ia_next) {
+ for (ia = V_in6_ifaddr; ia; ia = ia->ia_next) {
if (key_sockaddrcmp((struct sockaddr *)&sin6,
(struct sockaddr *)&ia->ia_addr, 0) == 0)
return 1;
@@ -4080,7 +4081,7 @@ key_flush_spd(time_t now)
for (dir = 0; dir < IPSEC_DIR_MAX; dir++) {
restart:
SPTREE_LOCK();
- LIST_FOREACH(sp, &sptree[dir], chain) {
+ LIST_FOREACH(sp, &V_sptree[dir], chain) {
if (sp->scangen == gen) /* previously handled */
continue;
sp->scangen = gen;
@@ -4113,7 +4114,7 @@ key_flush_sad(time_t now)
/* SAD */
SAHTREE_LOCK();
- LIST_FOREACH_SAFE(sah, &sahtree, chain, nextsah) {
+ LIST_FOREACH_SAFE(sah, &V_sahtree, chain, nextsah) {
/* if sah has been dead, then delete it and process next sah. */
if (sah->state == SADB_SASTATE_DEAD) {
key_delsah(sah);
@@ -4122,7 +4123,7 @@ key_flush_sad(time_t now)
/* if LARVAL entry doesn't become MATURE, delete it. */
LIST_FOREACH_SAFE(sav, &sah->savtree[SADB_SASTATE_LARVAL], chain, nextsav) {
- if (now - sav->created > key_larval_lifetime)
+ if (now - sav->created > V_key_larval_lifetime)
KEY_FREESAV(&sav);
}
@@ -4250,9 +4251,9 @@ key_flush_acq(time_t now)
/* ACQ tree */
ACQ_LOCK();
- for (acq = LIST_FIRST(&acqtree); acq != NULL; acq = nextacq) {
+ for (acq = LIST_FIRST(&V_acqtree); acq != NULL; acq = nextacq) {
nextacq = LIST_NEXT(acq, chain);
- if (now - acq->created > key_blockacq_lifetime
+ if (now - acq->created > V_key_blockacq_lifetime
&& __LIST_CHAINED(acq)) {
LIST_REMOVE(acq, chain);
free(acq, M_IPSEC_SAQ);
@@ -4268,9 +4269,9 @@ key_flush_spacq(time_t now)
/* SP ACQ tree */
SPACQ_LOCK();
- for (acq = LIST_FIRST(&spacqtree); acq != NULL; acq = nextacq) {
+ for (acq = LIST_FIRST(&V_spacqtree); acq != NULL; acq = nextacq) {
nextacq = LIST_NEXT(acq, chain);
- if (now - acq->created > key_blockacq_lifetime
+ if (now - acq->created > V_key_blockacq_lifetime
&& __LIST_CHAINED(acq)) {
LIST_REMOVE(acq, chain);
free(acq, M_IPSEC_SAQ);
@@ -4602,15 +4603,15 @@ key_do_getnewspi(spirange, saidx)
{
u_int32_t newspi;
u_int32_t min, max;
- int count = key_spi_trycnt;
+ int count = V_key_spi_trycnt;
/* set spi range to allocate */
if (spirange != NULL) {
min = spirange->sadb_spirange_min;
max = spirange->sadb_spirange_max;
} else {
- min = key_spi_minval;
- max = key_spi_maxval;
+ min = V_key_spi_minval;
+ max = V_key_spi_maxval;
}
/* IPCOMP needs 2-byte SPI */
if (saidx->proto == IPPROTO_IPCOMP) {
@@ -4657,7 +4658,7 @@ key_do_getnewspi(spirange, saidx)
/* statistics */
keystat.getspi_count =
- (keystat.getspi_count + key_spi_trycnt - count) / 2;
+ (keystat.getspi_count + V_key_spi_trycnt - count) / 2;
return newspi;
}
@@ -5180,7 +5181,7 @@ key_delete(so, m, mhp)
/* get a SA header */
SAHTREE_LOCK();
- LIST_FOREACH(sah, &sahtree, chain) {
+ LIST_FOREACH(sah, &V_sahtree, chain) {
if (sah->state == SADB_SASTATE_DEAD)
continue;
if (key_cmpsaidx(&sah->saidx, &saidx, CMP_HEAD) == 0)
@@ -5248,7 +5249,7 @@ key_delete_all(so, m, mhp, proto)
KEY_SETSECASIDX(proto, IPSEC_MODE_ANY, 0, src0 + 1, dst0 + 1, &saidx);
SAHTREE_LOCK();
- LIST_FOREACH(sah, &sahtree, chain) {
+ LIST_FOREACH(sah, &V_sahtree, chain) {
if (sah->state == SADB_SASTATE_DEAD)
continue;
if (key_cmpsaidx(&sah->saidx, &saidx, CMP_HEAD) == 0)
@@ -5256,9 +5257,9 @@ key_delete_all(so, m, mhp, proto)
/* Delete all non-LARVAL SAs. */
for (stateidx = 0;
- stateidx < _ARRAYLEN(saorder_state_alive);
+ stateidx < _ARRAYLEN(V_saorder_state_alive);
stateidx++) {
- state = saorder_state_alive[stateidx];
+ state = V_saorder_state_alive[stateidx];
if (state == SADB_SASTATE_LARVAL)
continue;
for (sav = LIST_FIRST(&sah->savtree[state]);
@@ -5363,7 +5364,7 @@ key_get(so, m, mhp)
/* get a SA header */
SAHTREE_LOCK();
- LIST_FOREACH(sah, &sahtree, chain) {
+ LIST_FOREACH(sah, &V_sahtree, chain) {
if (sah->state == SADB_SASTATE_DEAD)
continue;
if (key_cmpsaidx(&sah->saidx, &saidx, CMP_HEAD) == 0)
@@ -5440,14 +5441,14 @@ key_getcomb_esp()
continue;
/* discard algorithms with key size smaller than system min */
- if (_BITS(algo->maxkey) < ipsec_esp_keymin)
+ if (_BITS(algo->maxkey) < V_ipsec_esp_keymin)
continue;
- if (_BITS(algo->minkey) < ipsec_esp_keymin)
- encmin = ipsec_esp_keymin;
+ if (_BITS(algo->minkey) < V_ipsec_esp_keymin)
+ encmin = V_ipsec_esp_keymin;
else
encmin = _BITS(algo->minkey);
- if (ipsec_esp_auth)
+ if (V_ipsec_esp_auth)
m = key_getcomb_ah();
else {
IPSEC_ASSERT(l <= MLEN,
@@ -5546,7 +5547,7 @@ key_getcomb_ah()
continue;
key_getsizes_ah(algo, i, &minkeysize, &maxkeysize);
/* discard algorithms with key size smaller than system min */
- if (_BITS(minkeysize) < ipsec_ah_keymin)
+ if (_BITS(minkeysize) < V_ipsec_ah_keymin)
continue;
if (!m) {
@@ -5705,7 +5706,7 @@ key_acquire(const struct secasindex *saidx, struct secpolicy *sp)
*/
/* Get an entry to check whether sending message or not. */
if ((newacq = key_getacq(saidx)) != NULL) {
- if (key_blockacq_count < newacq->count) {
+ if (V_key_blockacq_count < newacq->count) {
/* reset counter and do send message. */
newacq->count = 0;
} else {
@@ -5863,13 +5864,13 @@ key_newacq(const struct secasindex *saidx)
/* copy secindex */
bcopy(saidx, &newacq->saidx, sizeof(newacq->saidx));
- newacq->seq = (acq_seq == ~0 ? 1 : ++acq_seq);
+ newacq->seq = (V_acq_seq == ~0 ? 1 : ++V_acq_seq);
newacq->created = time_second;
newacq->count = 0;
/* add to acqtree */
ACQ_LOCK();
- LIST_INSERT_HEAD(&acqtree, newacq, chain);
+ LIST_INSERT_HEAD(&V_acqtree, newacq, chain);
ACQ_UNLOCK();
return newacq;
@@ -5881,7 +5882,7 @@ key_getacq(const struct secasindex *saidx)
struct secacq *acq;
ACQ_LOCK();
- LIST_FOREACH(acq, &acqtree, chain) {
+ LIST_FOREACH(acq, &V_acqtree, chain) {
if (key_cmpsaidx(saidx, &acq->saidx, CMP_EXACTLY))
break;
}
@@ -5897,7 +5898,7 @@ key_getacqbyseq(seq)
struct secacq *acq;
ACQ_LOCK();
- LIST_FOREACH(acq, &acqtree, chain) {
+ LIST_FOREACH(acq, &V_acqtree, chain) {
if (acq->seq == seq)
break;
}
@@ -5926,7 +5927,7 @@ key_newspacq(spidx)
/* add to spacqtree */
SPACQ_LOCK();
- LIST_INSERT_HEAD(&spacqtree, acq, chain);
+ LIST_INSERT_HEAD(&V_spacqtree, acq, chain);
SPACQ_UNLOCK();
return acq;
@@ -5939,7 +5940,7 @@ key_getspacq(spidx)
struct secspacq *acq;
SPACQ_LOCK();
- LIST_FOREACH(acq, &spacqtree, chain) {
+ LIST_FOREACH(acq, &V_spacqtree, chain) {
if (key_cmpspidx_exactly(spidx, &acq->spidx)) {
/* NB: return holding spacq_lock */
return acq;
@@ -6050,7 +6051,7 @@ key_acquire2(so, m, mhp)
/* get a SA index */
SAHTREE_LOCK();
- LIST_FOREACH(sah, &sahtree, chain) {
+ LIST_FOREACH(sah, &V_sahtree, chain) {
if (sah->state == SADB_SASTATE_DEAD)
continue;
if (key_cmpsaidx(&sah->saidx, &saidx, CMP_MODE_REQID))
@@ -6099,7 +6100,7 @@ key_register(so, m, mhp)
IPSEC_ASSERT(mhp->msg != NULL, ("null msg"));
/* check for invalid register message */
- if (mhp->msg->sadb_msg_satype >= sizeof(regtree)/sizeof(regtree[0]))
+ if (mhp->msg->sadb_msg_satype >= sizeof(V_regtree)/sizeof(V_regtree[0]))
return key_senderror(so, m, EINVAL);
/* When SATYPE_UNSPEC is specified, only return sabd_supported. */
@@ -6108,7 +6109,7 @@ key_register(so, m, mhp)
/* check whether existing or not */
REGTREE_LOCK();
- LIST_FOREACH(reg, &regtree[mhp->msg->sadb_msg_satype], chain) {
+ LIST_FOREACH(reg, &V_regtree[mhp->msg->sadb_msg_satype], chain) {
if (reg->so == so) {
REGTREE_UNLOCK();
ipseclog((LOG_DEBUG, "%s: socket exists already.\n",
@@ -6129,7 +6130,7 @@ key_register(so, m, mhp)
((struct keycb *)sotorawcb(so))->kp_registered++;
/* add regnode to regtree. */
- LIST_INSERT_HEAD(&regtree[mhp->msg->sadb_msg_satype], newreg, chain);
+ LIST_INSERT_HEAD(&V_regtree[mhp->msg->sadb_msg_satype], newreg, chain);
REGTREE_UNLOCK();
setmsg:
@@ -6257,7 +6258,7 @@ key_freereg(struct socket *so)
*/
REGTREE_LOCK();
for (i = 0; i <= SADB_SATYPE_MAX; i++) {
- LIST_FOREACH(reg, &regtree[i], chain) {
+ LIST_FOREACH(reg, &V_regtree[i], chain) {
if (reg->so == so && __LIST_CHAINED(reg)) {
LIST_REMOVE(reg, chain);
free(reg, M_IPSEC_SAR);
@@ -6436,7 +6437,7 @@ key_flush(so, m, mhp)
/* no SATYPE specified, i.e. flushing all SA. */
SAHTREE_LOCK();
- for (sah = LIST_FIRST(&sahtree);
+ for (sah = LIST_FIRST(&V_sahtree);
sah != NULL;
sah = nextsah) {
nextsah = LIST_NEXT(sah, chain);
@@ -6446,9 +6447,9 @@ key_flush(so, m, mhp)
continue;
for (stateidx = 0;
- stateidx < _ARRAYLEN(saorder_state_alive);
+ stateidx < _ARRAYLEN(V_saorder_state_alive);
stateidx++) {
- state = saorder_state_any[stateidx];
+ state = V_saorder_state_any[stateidx];
for (sav = LIST_FIRST(&sah->savtree[state]);
sav != NULL;
sav = nextsav) {
@@ -6524,15 +6525,15 @@ key_dump(so, m, mhp)
/* count sav entries to be sent to the userland. */
cnt = 0;
SAHTREE_LOCK();
- LIST_FOREACH(sah, &sahtree, chain) {
+ LIST_FOREACH(sah, &V_sahtree, chain) {
if (mhp->msg->sadb_msg_satype != SADB_SATYPE_UNSPEC
&& proto != sah->saidx.proto)
continue;
for (stateidx = 0;
- stateidx < _ARRAYLEN(saorder_state_any);
+ stateidx < _ARRAYLEN(V_saorder_state_any);
stateidx++) {
- state = saorder_state_any[stateidx];
+ state = V_saorder_state_any[stateidx];
LIST_FOREACH(sav, &sah->savtree[state], chain) {
cnt++;
}
@@ -6546,7 +6547,7 @@ key_dump(so, m, mhp)
/* send this to the userland, one at a time. */
newmsg = NULL;
- LIST_FOREACH(sah, &sahtree, chain) {
+ LIST_FOREACH(sah, &V_sahtree, chain) {
if (mhp->msg->sadb_msg_satype != SADB_SATYPE_UNSPEC
&& proto != sah->saidx.proto)
continue;
@@ -6560,9 +6561,9 @@ key_dump(so, m, mhp)
}
for (stateidx = 0;
- stateidx < _ARRAYLEN(saorder_state_any);
+ stateidx < _ARRAYLEN(V_saorder_state_any);
stateidx++) {
- state = saorder_state_any[stateidx];
+ state = V_saorder_state_any[stateidx];
LIST_FOREACH(sav, &sah->savtree[state], chain) {
n = key_setdumpsa(sav, SADB_DUMP, satype,
--cnt, mhp->msg->sadb_msg_pid);
@@ -6706,7 +6707,7 @@ key_parse(m, so)
if ((m->m_flags & M_PKTHDR) == 0 ||
m->m_pkthdr.len != m->m_pkthdr.len) {
ipseclog((LOG_DEBUG, "%s: invalid message length.\n",__func__));
- pfkeystat.out_invlen++;
+ V_pfkeystat.out_invlen++;
error = EINVAL;
goto senderror;
}
@@ -6714,7 +6715,7 @@ key_parse(m, so)
if (msg->sadb_msg_version != PF_KEY_V2) {
ipseclog((LOG_DEBUG, "%s: PF_KEY version %u is mismatched.\n",
__func__, msg->sadb_msg_version));
- pfkeystat.out_invver++;
+ V_pfkeystat.out_invver++;
error = EINVAL;
goto senderror;
}
@@ -6722,7 +6723,7 @@ key_parse(m, so)
if (msg->sadb_msg_type > SADB_MAX) {
ipseclog((LOG_DEBUG, "%s: invalid type %u is passed.\n",
__func__, msg->sadb_msg_type));
- pfkeystat.out_invmsgtype++;
+ V_pfkeystat.out_invmsgtype++;
error = EINVAL;
goto senderror;
}
@@ -6775,7 +6776,7 @@ key_parse(m, so)
ipseclog((LOG_DEBUG, "%s: must specify satype "
"when msg type=%u.\n", __func__,
msg->sadb_msg_type));
- pfkeystat.out_invsatype++;
+ V_pfkeystat.out_invsatype++;
error = EINVAL;
goto senderror;
}
@@ -6795,7 +6796,7 @@ key_parse(m, so)
case SADB_X_SPDDELETE2:
ipseclog((LOG_DEBUG, "%s: illegal satype=%u\n",
__func__, msg->sadb_msg_type));
- pfkeystat.out_invsatype++;
+ V_pfkeystat.out_invsatype++;
error = EINVAL;
goto senderror;
}
@@ -6806,7 +6807,7 @@ key_parse(m, so)
case SADB_SATYPE_MIP:
ipseclog((LOG_DEBUG, "%s: type %u isn't supported.\n",
__func__, msg->sadb_msg_satype));
- pfkeystat.out_invsatype++;
+ V_pfkeystat.out_invsatype++;
error = EOPNOTSUPP;
goto senderror;
case 1: /* XXX: What does it do? */
@@ -6816,7 +6817,7 @@ key_parse(m, so)
default:
ipseclog((LOG_DEBUG, "%s: invalid type %u is passed.\n",
__func__, msg->sadb_msg_satype));
- pfkeystat.out_invsatype++;
+ V_pfkeystat.out_invsatype++;
error = EINVAL;
goto senderror;
}
@@ -6834,7 +6835,7 @@ key_parse(m, so)
if (src0->sadb_address_proto != dst0->sadb_address_proto) {
ipseclog((LOG_DEBUG, "%s: upper layer protocol "
"mismatched.\n", __func__));
- pfkeystat.out_invaddr++;
+ V_pfkeystat.out_invaddr++;
error = EINVAL;
goto senderror;
}
@@ -6844,7 +6845,7 @@ key_parse(m, so)
PFKEY_ADDR_SADDR(dst0)->sa_family) {
ipseclog((LOG_DEBUG, "%s: address family mismatched.\n",
__func__));
- pfkeystat.out_invaddr++;
+ V_pfkeystat.out_invaddr++;
error = EINVAL;
goto senderror;
}
@@ -6852,7 +6853,7 @@ key_parse(m, so)
PFKEY_ADDR_SADDR(dst0)->sa_len) {
ipseclog((LOG_DEBUG, "%s: address struct size "
"mismatched.\n", __func__));
- pfkeystat.out_invaddr++;
+ V_pfkeystat.out_invaddr++;
error = EINVAL;
goto senderror;
}
@@ -6861,7 +6862,7 @@ key_parse(m, so)
case AF_INET:
if (PFKEY_ADDR_SADDR(src0)->sa_len !=
sizeof(struct sockaddr_in)) {
- pfkeystat.out_invaddr++;
+ V_pfkeystat.out_invaddr++;
error = EINVAL;
goto senderror;
}
@@ -6869,7 +6870,7 @@ key_parse(m, so)
case AF_INET6:
if (PFKEY_ADDR_SADDR(src0)->sa_len !=
sizeof(struct sockaddr_in6)) {
- pfkeystat.out_invaddr++;
+ V_pfkeystat.out_invaddr++;
error = EINVAL;
goto senderror;
}
@@ -6877,7 +6878,7 @@ key_parse(m, so)
default:
ipseclog((LOG_DEBUG, "%s: unsupported address family\n",
__func__));
- pfkeystat.out_invaddr++;
+ V_pfkeystat.out_invaddr++;
error = EAFNOSUPPORT;
goto senderror;
}
@@ -6899,7 +6900,7 @@ key_parse(m, so)
dst0->sadb_address_prefixlen > plen) {
ipseclog((LOG_DEBUG, "%s: illegal prefixlen.\n",
__func__));
- pfkeystat.out_invaddr++;
+ V_pfkeystat.out_invaddr++;
error = EINVAL;
goto senderror;
}
@@ -6912,7 +6913,7 @@ key_parse(m, so)
if (msg->sadb_msg_type >= sizeof(key_typesw)/sizeof(key_typesw[0]) ||
key_typesw[msg->sadb_msg_type] == NULL) {
- pfkeystat.out_invmsgtype++;
+ V_pfkeystat.out_invmsgtype++;
error = EINVAL;
goto senderror;
}
@@ -7006,7 +7007,7 @@ key_align(m, mhp)
ipseclog((LOG_DEBUG, "%s: duplicate ext_type "
"%u\n", __func__, ext->sadb_ext_type));
m_freem(m);
- pfkeystat.out_dupext++;
+ V_pfkeystat.out_dupext++;
return EINVAL;
}
break;
@@ -7014,7 +7015,7 @@ key_align(m, mhp)
ipseclog((LOG_DEBUG, "%s: invalid ext_type %u\n",
__func__, ext->sadb_ext_type));
m_freem(m);
- pfkeystat.out_invexttype++;
+ V_pfkeystat.out_invexttype++;
return EINVAL;
}
@@ -7022,7 +7023,7 @@ key_align(m, mhp)
if (key_validate_ext(ext, extlen)) {
m_freem(m);
- pfkeystat.out_invlen++;
+ V_pfkeystat.out_invlen++;
return EINVAL;
}
@@ -7040,7 +7041,7 @@ key_align(m, mhp)
if (off != end) {
m_freem(m);
- pfkeystat.out_invlen++;
+ V_pfkeystat.out_invlen++;
return EINVAL;
}
@@ -7118,19 +7119,19 @@ key_init(void)
SPACQ_LOCK_INIT();
for (i = 0; i < IPSEC_DIR_MAX; i++)
- LIST_INIT(&sptree[i]);
+ LIST_INIT(&V_sptree[i]);
- LIST_INIT(&sahtree);
+ LIST_INIT(&V_sahtree);
for (i = 0; i <= SADB_SATYPE_MAX; i++)
- LIST_INIT(&regtree[i]);
+ LIST_INIT(&V_regtree[i]);
- LIST_INIT(&acqtree);
- LIST_INIT(&spacqtree);
+ LIST_INIT(&V_acqtree);
+ LIST_INIT(&V_spacqtree);
/* system default */
- ip4_def_policy.policy = IPSEC_POLICY_NONE;
- ip4_def_policy.refcnt++; /*never reclaim this*/
+ V_ip4_def_policy.policy = IPSEC_POLICY_NONE;
+ V_ip4_def_policy.refcnt++; /*never reclaim this*/
#ifndef IPSEC_DEBUG2
timeout((void *)key_timehandler, (void *)0, hz);
@@ -7218,7 +7219,7 @@ key_sa_routechange(dst)
struct route *ro;
SAHTREE_LOCK();
- LIST_FOREACH(sah, &sahtree, chain) {
+ LIST_FOREACH(sah, &V_sahtree, chain) {
ro = &sah->sa_route;
if (ro->ro_rt && dst->sa_len == ro->ro_dst.sa_len
&& bcmp(dst, &ro->ro_dst, dst->sa_len) == 0) {
diff --git a/sys/netipsec/key_debug.h b/sys/netipsec/key_debug.h
index be53f7a..6ca0fe2 100644
--- a/sys/netipsec/key_debug.h
+++ b/sys/netipsec/key_debug.h
@@ -54,7 +54,7 @@
#define KEYDEBUG_IPSEC_DUMP (KEYDEBUG_IPSEC | KEYDEBUG_DUMP)
#define KEYDEBUG(lev,arg) \
- do { if ((key_debug_level & (lev)) == (lev)) { arg; } } while (0)
+ do { if ((V_key_debug_level & (lev)) == (lev)) { arg; } } while (0)
extern u_int32_t key_debug_level;
#endif /*_KERNEL*/
diff --git a/sys/netipsec/keysock.c b/sys/netipsec/keysock.c
index 5b26b2e..c86791e 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();
}
diff --git a/sys/netipsec/xform_ah.c b/sys/netipsec/xform_ah.c
index 2424b4a..4f87db6f 100644
--- a/sys/netipsec/xform_ah.c
+++ b/sys/netipsec/xform_ah.c
@@ -46,6 +46,7 @@
#include <sys/syslog.h>
#include <sys/kernel.h>
#include <sys/sysctl.h>
+#include <sys/vimage.h>
#include <net/if.h>
@@ -218,7 +219,7 @@ ah_init(struct secasvar *sav, struct xformsw *xsp)
error = ah_init0(sav, xsp, &cria);
return error ? error :
- crypto_newsession(&sav->tdb_cryptoid, &cria, crypto_support);
+ crypto_newsession(&sav->tdb_cryptoid, &cria, V_crypto_support);
}
/*
@@ -277,7 +278,7 @@ ah_massage_headers(struct mbuf **m0, int proto, int skip, int alg, int out)
/* Fix the IP header */
ip = mtod(m, struct ip *);
- if (ah_cleartos)
+ if (V_ah_cleartos)
ip->ip_tos = 0;
ip->ip_ttl = 0;
ip->ip_sum = 0;
@@ -573,14 +574,14 @@ ah_input(struct mbuf *m, struct secasvar *sav, int skip, int protoff)
IP6_EXTHDR_GET(ah, struct newah *, m, skip, rplen);
if (ah == NULL) {
DPRINTF(("ah_input: cannot pullup header\n"));
- ahstat.ahs_hdrops++; /*XXX*/
+ V_ahstat.ahs_hdrops++; /*XXX*/
m_freem(m);
return ENOBUFS;
}
/* Check replay window, if applicable. */
if (sav->replay && !ipsec_chkreplay(ntohl(ah->ah_seq), sav)) {
- ahstat.ahs_replay++;
+ V_ahstat.ahs_replay++;
DPRINTF(("%s: packet replay failure: %s\n", __func__,
ipsec_logsastr(sav)));
m_freem(m);
@@ -597,17 +598,17 @@ ah_input(struct mbuf *m, struct secasvar *sav, int skip, int protoff)
hl, (u_long) (authsize + rplen - sizeof (struct ah)),
ipsec_address(&sav->sah->saidx.dst),
(u_long) ntohl(sav->spi)));
- ahstat.ahs_badauthl++;
+ V_ahstat.ahs_badauthl++;
m_freem(m);
return EACCES;
}
- ahstat.ahs_ibytes += m->m_pkthdr.len - skip - hl;
+ V_ahstat.ahs_ibytes += m->m_pkthdr.len - skip - hl;
/* Get crypto descriptors. */
crp = crypto_getreq(1);
if (crp == NULL) {
DPRINTF(("%s: failed to acquire crypto descriptor\n",__func__));
- ahstat.ahs_crypto++;
+ V_ahstat.ahs_crypto++;
m_freem(m);
return ENOBUFS;
}
@@ -647,7 +648,7 @@ ah_input(struct mbuf *m, struct secasvar *sav, int skip, int protoff)
}
if (tc == NULL) {
DPRINTF(("%s: failed to allocate tdb_crypto\n", __func__));
- ahstat.ahs_crypto++;
+ V_ahstat.ahs_crypto++;
crypto_freereq(crp);
m_freem(m);
return ENOBUFS;
@@ -671,7 +672,7 @@ ah_input(struct mbuf *m, struct secasvar *sav, int skip, int protoff)
skip, ahx->type, 0);
if (error != 0) {
/* NB: mbuf is free'd by ah_massage_headers */
- ahstat.ahs_hdrops++;
+ V_ahstat.ahs_hdrops++;
free(tc, M_XDATA);
crypto_freereq(crp);
return error;
@@ -745,7 +746,7 @@ ah_input_cb(struct cryptop *crp)
sav = KEY_ALLOCSA(&tc->tc_dst, tc->tc_proto, tc->tc_spi);
if (sav == NULL) {
- ahstat.ahs_notdb++;
+ V_ahstat.ahs_notdb++;
DPRINTF(("%s: SA expired while in crypto\n", __func__));
error = ENOBUFS; /*XXX*/
goto bad;
@@ -768,19 +769,19 @@ ah_input_cb(struct cryptop *crp)
return error;
}
- ahstat.ahs_noxform++;
+ V_ahstat.ahs_noxform++;
DPRINTF(("%s: crypto error %d\n", __func__, crp->crp_etype));
error = crp->crp_etype;
goto bad;
} else {
- ahstat.ahs_hist[sav->alg_auth]++;
+ V_ahstat.ahs_hist[sav->alg_auth]++;
crypto_freereq(crp); /* No longer needed. */
crp = NULL;
}
/* Shouldn't happen... */
if (m == NULL) {
- ahstat.ahs_crypto++;
+ V_ahstat.ahs_crypto++;
DPRINTF(("%s: bogus returned buffer from crypto\n", __func__));
error = EINVAL;
goto bad;
@@ -806,7 +807,7 @@ ah_input_cb(struct cryptop *crp)
"in SA %s/%08lx\n", __func__,
ipsec_address(&saidx->dst),
(u_long) ntohl(sav->spi)));
- ahstat.ahs_badauth++;
+ V_ahstat.ahs_badauth++;
error = EACCES;
goto bad;
}
@@ -837,7 +838,7 @@ ah_input_cb(struct cryptop *crp)
m_copydata(m, skip + offsetof(struct newah, ah_seq),
sizeof (seq), (caddr_t) &seq);
if (ipsec_updatereplay(ntohl(seq), sav)) {
- ahstat.ahs_replay++;
+ V_ahstat.ahs_replay++;
error = ENOBUFS; /*XXX as above*/
goto bad;
}
@@ -851,7 +852,7 @@ ah_input_cb(struct cryptop *crp)
DPRINTF(("%s: mangled mbuf chain for SA %s/%08lx\n", __func__,
ipsec_address(&saidx->dst), (u_long) ntohl(sav->spi)));
- ahstat.ahs_hdrops++;
+ V_ahstat.ahs_hdrops++;
goto bad;
}
@@ -898,7 +899,7 @@ ah_output(
ahx = sav->tdb_authalgxform;
IPSEC_ASSERT(ahx != NULL, ("null authentication xform"));
- ahstat.ahs_output++;
+ V_ahstat.ahs_output++;
/* Figure out header size. */
rplen = HDRSIZE(sav);
@@ -921,7 +922,7 @@ ah_output(
sav->sah->saidx.dst.sa.sa_family,
ipsec_address(&sav->sah->saidx.dst),
(u_long) ntohl(sav->spi)));
- ahstat.ahs_nopf++;
+ V_ahstat.ahs_nopf++;
error = EPFNOSUPPORT;
goto bad;
}
@@ -932,20 +933,20 @@ ah_output(
ipsec_address(&sav->sah->saidx.dst),
(u_long) ntohl(sav->spi),
rplen + authsize + m->m_pkthdr.len, maxpacketsize));
- ahstat.ahs_toobig++;
+ V_ahstat.ahs_toobig++;
error = EMSGSIZE;
goto bad;
}
/* Update the counters. */
- ahstat.ahs_obytes += m->m_pkthdr.len - skip;
+ V_ahstat.ahs_obytes += m->m_pkthdr.len - skip;
m = m_unshare(m, M_NOWAIT);
if (m == NULL) {
DPRINTF(("%s: cannot clone mbuf chain, SA %s/%08lx\n", __func__,
ipsec_address(&sav->sah->saidx.dst),
(u_long) ntohl(sav->spi)));
- ahstat.ahs_hdrops++;
+ V_ahstat.ahs_hdrops++;
error = ENOBUFS;
goto bad;
}
@@ -958,7 +959,7 @@ ah_output(
rplen + authsize,
ipsec_address(&sav->sah->saidx.dst),
(u_long) ntohl(sav->spi)));
- ahstat.ahs_hdrops++; /*XXX differs from openbsd */
+ V_ahstat.ahs_hdrops++; /*XXX differs from openbsd */
error = ENOBUFS;
goto bad;
}
@@ -986,13 +987,13 @@ ah_output(
__func__,
ipsec_address(&sav->sah->saidx.dst),
(u_long) ntohl(sav->spi)));
- ahstat.ahs_wrap++;
+ V_ahstat.ahs_wrap++;
error = EINVAL;
goto bad;
}
#ifdef REGRESSION
/* Emulate replay attack when ipsec_replay is TRUE. */
- if (!ipsec_replay)
+ if (!V_ipsec_replay)
#endif
sav->replay->count++;
ah->ah_seq = htonl(sav->replay->count);
@@ -1003,7 +1004,7 @@ ah_output(
if (crp == NULL) {
DPRINTF(("%s: failed to acquire crypto descriptors\n",
__func__));
- ahstat.ahs_crypto++;
+ V_ahstat.ahs_crypto++;
error = ENOBUFS;
goto bad;
}
@@ -1025,7 +1026,7 @@ ah_output(
if (tc == NULL) {
crypto_freereq(crp);
DPRINTF(("%s: failed to allocate tdb_crypto\n", __func__));
- ahstat.ahs_crypto++;
+ V_ahstat.ahs_crypto++;
error = ENOBUFS;
goto bad;
}
@@ -1127,7 +1128,7 @@ ah_output_cb(struct cryptop *crp)
IPSECREQUEST_LOCK(isr);
sav = KEY_ALLOCSA(&tc->tc_dst, tc->tc_proto, tc->tc_spi);
if (sav == NULL) {
- ahstat.ahs_notdb++;
+ V_ahstat.ahs_notdb++;
DPRINTF(("%s: SA expired while in crypto\n", __func__));
error = ENOBUFS; /*XXX*/
goto bad;
@@ -1146,7 +1147,7 @@ ah_output_cb(struct cryptop *crp)
return error;
}
- ahstat.ahs_noxform++;
+ V_ahstat.ahs_noxform++;
DPRINTF(("%s: crypto error %d\n", __func__, crp->crp_etype));
error = crp->crp_etype;
goto bad;
@@ -1154,12 +1155,12 @@ ah_output_cb(struct cryptop *crp)
/* Shouldn't happen... */
if (m == NULL) {
- ahstat.ahs_crypto++;
+ V_ahstat.ahs_crypto++;
DPRINTF(("%s: bogus returned buffer from crypto\n", __func__));
error = EINVAL;
goto bad;
}
- ahstat.ahs_hist[sav->alg_auth]++;
+ V_ahstat.ahs_hist[sav->alg_auth]++;
/*
* Copy original headers (with the new protocol number) back
@@ -1173,7 +1174,7 @@ ah_output_cb(struct cryptop *crp)
#ifdef REGRESSION
/* Emulate man-in-the-middle attack when ipsec_integrity is TRUE. */
- if (ipsec_integrity) {
+ if (V_ipsec_integrity) {
int alen;
/*
diff --git a/sys/netipsec/xform_esp.c b/sys/netipsec/xform_esp.c
index 7e25da0..3ac01c6 100644
--- a/sys/netipsec/xform_esp.c
+++ b/sys/netipsec/xform_esp.c
@@ -46,6 +46,7 @@
#include <sys/kernel.h>
#include <sys/random.h>
#include <sys/sysctl.h>
+#include <sys/vimage.h>
#include <net/if.h>
@@ -145,7 +146,7 @@ esp_hdrsiz(struct secasvar *sav)
* + sizeof (next header field)
* + max icv supported.
*/
- size = sizeof (struct newesp) + esp_max_ivlen + 9 + 16;
+ size = sizeof (struct newesp) + V_esp_max_ivlen + 9 + 16;
}
return size;
}
@@ -224,13 +225,13 @@ esp_init(struct secasvar *sav, struct xformsw *xsp)
/* init both auth & enc */
crie.cri_next = &cria;
error = crypto_newsession(&sav->tdb_cryptoid,
- &crie, crypto_support);
+ &crie, V_crypto_support);
} else if (sav->tdb_encalgxform) {
error = crypto_newsession(&sav->tdb_cryptoid,
- &crie, crypto_support);
+ &crie, V_crypto_support);
} else if (sav->tdb_authalgxform) {
error = crypto_newsession(&sav->tdb_cryptoid,
- &cria, crypto_support);
+ &cria, V_crypto_support);
} else {
/* XXX cannot happen? */
DPRINTF(("%s: no encoding OR authentication xform!\n",
@@ -312,7 +313,7 @@ esp_input(struct mbuf *m, struct secasvar *sav, int skip, int protoff)
plen, espx->blocksize,
ipsec_address(&sav->sah->saidx.dst),
(u_long) ntohl(sav->spi)));
- espstat.esps_badilen++;
+ V_espstat.esps_badilen++;
m_freem(m);
return EINVAL;
}
@@ -323,13 +324,13 @@ esp_input(struct mbuf *m, struct secasvar *sav, int skip, int protoff)
if (esph && sav->replay && !ipsec_chkreplay(ntohl(esp->esp_seq), sav)) {
DPRINTF(("%s: packet replay check for %s\n", __func__,
ipsec_logsastr(sav))); /*XXX*/
- espstat.esps_replay++;
+ V_espstat.esps_replay++;
m_freem(m);
return ENOBUFS; /*XXX*/
}
/* Update the counters */
- espstat.esps_ibytes += m->m_pkthdr.len - (skip + hlen + alen);
+ V_espstat.esps_ibytes += m->m_pkthdr.len - (skip + hlen + alen);
/* Find out if we've already done crypto */
for (mtag = m_tag_find(m, PACKET_TAG_IPSEC_IN_CRYPTO_DONE, NULL);
@@ -348,7 +349,7 @@ esp_input(struct mbuf *m, struct secasvar *sav, int skip, int protoff)
if (crp == NULL) {
DPRINTF(("%s: failed to acquire crypto descriptors\n",
__func__));
- espstat.esps_crypto++;
+ V_espstat.esps_crypto++;
m_freem(m);
return ENOBUFS;
}
@@ -363,7 +364,7 @@ esp_input(struct mbuf *m, struct secasvar *sav, int skip, int protoff)
if (tc == NULL) {
crypto_freereq(crp);
DPRINTF(("%s: failed to allocate tdb_crypto\n", __func__));
- espstat.esps_crypto++;
+ V_espstat.esps_crypto++;
m_freem(m);
return ENOBUFS;
}
@@ -472,7 +473,7 @@ esp_input_cb(struct cryptop *crp)
sav = KEY_ALLOCSA(&tc->tc_dst, tc->tc_proto, tc->tc_spi);
if (sav == NULL) {
- espstat.esps_notdb++;
+ V_espstat.esps_notdb++;
DPRINTF(("%s: SA gone during crypto (SA %s/%08lx proto %u)\n",
__func__, ipsec_address(&tc->tc_dst),
(u_long) ntohl(tc->tc_spi), tc->tc_proto));
@@ -500,7 +501,7 @@ esp_input_cb(struct cryptop *crp)
return error;
}
- espstat.esps_noxform++;
+ V_espstat.esps_noxform++;
DPRINTF(("%s: crypto error %d\n", __func__, crp->crp_etype));
error = crp->crp_etype;
goto bad;
@@ -508,12 +509,12 @@ esp_input_cb(struct cryptop *crp)
/* Shouldn't happen... */
if (m == NULL) {
- espstat.esps_crypto++;
+ V_espstat.esps_crypto++;
DPRINTF(("%s: bogus returned buffer from crypto\n", __func__));
error = EINVAL;
goto bad;
}
- espstat.esps_hist[sav->alg_enc]++;
+ V_espstat.esps_hist[sav->alg_enc]++;
/* If authentication was performed, check now. */
if (esph != NULL) {
@@ -522,7 +523,7 @@ esp_input_cb(struct cryptop *crp)
* the verification for us. Otherwise we need to
* check the authentication calculation.
*/
- ahstat.ahs_hist[sav->alg_auth]++;
+ V_ahstat.ahs_hist[sav->alg_auth]++;
if (mtag == NULL) {
/* Copy the authenticator from the packet */
m_copydata(m, m->m_pkthdr.len - AH_HMAC_HASHLEN,
@@ -537,7 +538,7 @@ esp_input_cb(struct cryptop *crp)
__func__,
ipsec_address(&saidx->dst),
(u_long) ntohl(sav->spi)));
- espstat.esps_badauth++;
+ V_espstat.esps_badauth++;
error = EACCES;
goto bad;
}
@@ -567,7 +568,7 @@ esp_input_cb(struct cryptop *crp)
if (ipsec_updatereplay(ntohl(seq), sav)) {
DPRINTF(("%s: packet replay check for %s\n", __func__,
ipsec_logsastr(sav)));
- espstat.esps_replay++;
+ V_espstat.esps_replay++;
error = ENOBUFS;
goto bad;
}
@@ -582,7 +583,7 @@ esp_input_cb(struct cryptop *crp)
/* Remove the ESP header and IV from the mbuf. */
error = m_striphdr(m, skip, hlen);
if (error) {
- espstat.esps_hdrops++;
+ V_espstat.esps_hdrops++;
DPRINTF(("%s: bad mbuf chain, SA %s/%08lx\n", __func__,
ipsec_address(&sav->sah->saidx.dst),
(u_long) ntohl(sav->spi)));
@@ -594,7 +595,7 @@ esp_input_cb(struct cryptop *crp)
/* Verify pad length */
if (lastthree[1] + 2 > m->m_pkthdr.len - skip) {
- espstat.esps_badilen++;
+ V_espstat.esps_badilen++;
DPRINTF(("%s: invalid padding length %d for %u byte packet "
"in SA %s/%08lx\n", __func__,
lastthree[1], m->m_pkthdr.len - skip,
@@ -607,7 +608,7 @@ esp_input_cb(struct cryptop *crp)
/* Verify correct decryption by checking the last padding bytes */
if ((sav->flags & SADB_X_EXT_PMASK) != SADB_X_EXT_PRAND) {
if (lastthree[1] != lastthree[0] && lastthree[1] != 0) {
- espstat.esps_badenc++;
+ V_espstat.esps_badenc++;
DPRINTF(("%s: decryption failed for packet in "
"SA %s/%08lx\n", __func__,
ipsec_address(&sav->sah->saidx.dst),
@@ -692,7 +693,7 @@ esp_output(
else
alen = 0;
- espstat.esps_output++;
+ V_espstat.esps_output++;
saidx = &sav->sah->saidx;
/* Check for maximum packet size violations. */
@@ -712,7 +713,7 @@ esp_output(
"family %d, SA %s/%08lx\n", __func__,
saidx->dst.sa.sa_family, ipsec_address(&saidx->dst),
(u_long) ntohl(sav->spi)));
- espstat.esps_nopf++;
+ V_espstat.esps_nopf++;
error = EPFNOSUPPORT;
goto bad;
}
@@ -721,19 +722,19 @@ esp_output(
"(len %u, max len %u)\n", __func__,
ipsec_address(&saidx->dst), (u_long) ntohl(sav->spi),
skip + hlen + rlen + padding + alen, maxpacketsize));
- espstat.esps_toobig++;
+ V_espstat.esps_toobig++;
error = EMSGSIZE;
goto bad;
}
/* Update the counters. */
- espstat.esps_obytes += m->m_pkthdr.len - skip;
+ V_espstat.esps_obytes += m->m_pkthdr.len - skip;
m = m_unshare(m, M_NOWAIT);
if (m == NULL) {
DPRINTF(("%s: cannot clone mbuf chain, SA %s/%08lx\n", __func__,
ipsec_address(&saidx->dst), (u_long) ntohl(sav->spi)));
- espstat.esps_hdrops++;
+ V_espstat.esps_hdrops++;
error = ENOBUFS;
goto bad;
}
@@ -744,7 +745,7 @@ esp_output(
DPRINTF(("%s: %u byte ESP hdr inject failed for SA %s/%08lx\n",
__func__, hlen, ipsec_address(&saidx->dst),
(u_long) ntohl(sav->spi)));
- espstat.esps_hdrops++; /* XXX diffs from openbsd */
+ V_espstat.esps_hdrops++; /* XXX diffs from openbsd */
error = ENOBUFS;
goto bad;
}
@@ -756,7 +757,7 @@ esp_output(
#ifdef REGRESSION
/* Emulate replay attack when ipsec_replay is TRUE. */
- if (!ipsec_replay)
+ if (!V_ipsec_replay)
#endif
sav->replay->count++;
replay = htonl(sav->replay->count);
@@ -808,7 +809,7 @@ esp_output(
if (crp == NULL) {
DPRINTF(("%s: failed to acquire crypto descriptors\n",
__func__));
- espstat.esps_crypto++;
+ V_espstat.esps_crypto++;
error = ENOBUFS;
goto bad;
}
@@ -837,7 +838,7 @@ esp_output(
if (tc == NULL) {
crypto_freereq(crp);
DPRINTF(("%s: failed to allocate tdb_crypto\n", __func__));
- espstat.esps_crypto++;
+ V_espstat.esps_crypto++;
error = ENOBUFS;
goto bad;
}
@@ -895,7 +896,7 @@ esp_output_cb(struct cryptop *crp)
IPSECREQUEST_LOCK(isr);
sav = KEY_ALLOCSA(&tc->tc_dst, tc->tc_proto, tc->tc_spi);
if (sav == NULL) {
- espstat.esps_notdb++;
+ V_espstat.esps_notdb++;
DPRINTF(("%s: SA gone during crypto (SA %s/%08lx proto %u)\n",
__func__, ipsec_address(&tc->tc_dst),
(u_long) ntohl(tc->tc_spi), tc->tc_proto));
@@ -918,7 +919,7 @@ esp_output_cb(struct cryptop *crp)
return error;
}
- espstat.esps_noxform++;
+ V_espstat.esps_noxform++;
DPRINTF(("%s: crypto error %d\n", __func__, crp->crp_etype));
error = crp->crp_etype;
goto bad;
@@ -926,14 +927,14 @@ esp_output_cb(struct cryptop *crp)
/* Shouldn't happen... */
if (m == NULL) {
- espstat.esps_crypto++;
+ V_espstat.esps_crypto++;
DPRINTF(("%s: bogus returned buffer from crypto\n", __func__));
error = EINVAL;
goto bad;
}
- espstat.esps_hist[sav->alg_enc]++;
+ V_espstat.esps_hist[sav->alg_enc]++;
if (sav->tdb_authalgxform != NULL)
- ahstat.ahs_hist[sav->alg_auth]++;
+ V_ahstat.ahs_hist[sav->alg_auth]++;
/* Release crypto descriptors. */
free(tc, M_XDATA);
@@ -941,7 +942,7 @@ esp_output_cb(struct cryptop *crp)
#ifdef REGRESSION
/* Emulate man-in-the-middle attack when ipsec_integrity is TRUE. */
- if (ipsec_integrity) {
+ if (V_ipsec_integrity) {
static unsigned char ipseczeroes[AH_HMAC_HASHLEN];
struct auth_hash *esph;
@@ -983,10 +984,10 @@ static void
esp_attach(void)
{
#define MAXIV(xform) \
- if (xform.blocksize > esp_max_ivlen) \
- esp_max_ivlen = xform.blocksize \
+ if (xform.blocksize > V_esp_max_ivlen) \
+ V_esp_max_ivlen = xform.blocksize \
- esp_max_ivlen = 0;
+ V_esp_max_ivlen = 0;
MAXIV(enc_xform_des); /* SADB_EALG_DESCBC */
MAXIV(enc_xform_3des); /* SADB_EALG_3DESCBC */
MAXIV(enc_xform_rijndael128); /* SADB_X_EALG_AES */
diff --git a/sys/netipsec/xform_ipcomp.c b/sys/netipsec/xform_ipcomp.c
index 97f4827..2882af8 100644
--- a/sys/netipsec/xform_ipcomp.c
+++ b/sys/netipsec/xform_ipcomp.c
@@ -41,6 +41,7 @@
#include <sys/kernel.h>
#include <sys/protosw.h>
#include <sys/sysctl.h>
+#include <sys/vimage.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
@@ -114,7 +115,7 @@ ipcomp_init(struct secasvar *sav, struct xformsw *xsp)
bzero(&cric, sizeof (cric));
cric.cri_alg = sav->tdb_compalgxform->type;
- return crypto_newsession(&sav->tdb_cryptoid, &cric, crypto_support);
+ return crypto_newsession(&sav->tdb_cryptoid, &cric, V_crypto_support);
}
/*
@@ -146,7 +147,7 @@ ipcomp_input(struct mbuf *m, struct secasvar *sav, int skip, int protoff)
if (crp == NULL) {
m_freem(m);
DPRINTF(("%s: no crypto descriptors\n", __func__));
- ipcompstat.ipcomps_crypto++;
+ V_ipcompstat.ipcomps_crypto++;
return ENOBUFS;
}
/* Get IPsec-specific opaque pointer */
@@ -155,7 +156,7 @@ ipcomp_input(struct mbuf *m, struct secasvar *sav, int skip, int protoff)
m_freem(m);
crypto_freereq(crp);
DPRINTF(("%s: cannot allocate tdb_crypto\n", __func__));
- ipcompstat.ipcomps_crypto++;
+ V_ipcompstat.ipcomps_crypto++;
return ENOBUFS;
}
crdc = crp->crp_desc;
@@ -228,7 +229,7 @@ ipcomp_input_cb(struct cryptop *crp)
sav = KEY_ALLOCSA(&tc->tc_dst, tc->tc_proto, tc->tc_spi);
if (sav == NULL) {
- ipcompstat.ipcomps_notdb++;
+ V_ipcompstat.ipcomps_notdb++;
DPRINTF(("%s: SA expired while in crypto\n", __func__));
error = ENOBUFS; /*XXX*/
goto bad;
@@ -251,19 +252,19 @@ ipcomp_input_cb(struct cryptop *crp)
return error;
}
- ipcompstat.ipcomps_noxform++;
+ V_ipcompstat.ipcomps_noxform++;
DPRINTF(("%s: crypto error %d\n", __func__, crp->crp_etype));
error = crp->crp_etype;
goto bad;
}
/* Shouldn't happen... */
if (m == NULL) {
- ipcompstat.ipcomps_crypto++;
+ V_ipcompstat.ipcomps_crypto++;
DPRINTF(("%s: null mbuf returned from crypto\n", __func__));
error = EINVAL;
goto bad;
}
- ipcompstat.ipcomps_hist[sav->alg_comp]++;
+ V_ipcompstat.ipcomps_hist[sav->alg_comp]++;
clen = crp->crp_olen; /* Length of data after processing */
@@ -275,7 +276,7 @@ ipcomp_input_cb(struct cryptop *crp)
m->m_pkthdr.len = clen + hlen + skip;
if (m->m_len < skip + hlen && (m = m_pullup(m, skip + hlen)) == 0) {
- ipcompstat.ipcomps_hdrops++; /*XXX*/
+ V_ipcompstat.ipcomps_hdrops++; /*XXX*/
DPRINTF(("%s: m_pullup failed\n", __func__));
error = EINVAL; /*XXX*/
goto bad;
@@ -288,7 +289,7 @@ ipcomp_input_cb(struct cryptop *crp)
/* Remove the IPCOMP header */
error = m_striphdr(m, skip, hlen);
if (error) {
- ipcompstat.ipcomps_hdrops++;
+ V_ipcompstat.ipcomps_hdrops++;
DPRINTF(("%s: bad mbuf chain, IPCA %s/%08lx\n", __func__,
ipsec_address(&sav->sah->saidx.dst),
(u_long) ntohl(sav->spi)));
@@ -344,7 +345,7 @@ ipcomp_output(
ralen = m->m_pkthdr.len - skip; /* Raw payload length before comp. */
hlen = IPCOMP_HLENGTH;
- ipcompstat.ipcomps_output++;
+ V_ipcompstat.ipcomps_output++;
/* Check for maximum packet size violations. */
switch (sav->sah->saidx.dst.sa.sa_family) {
@@ -359,7 +360,7 @@ ipcomp_output(
break;
#endif /* INET6 */
default:
- ipcompstat.ipcomps_nopf++;
+ V_ipcompstat.ipcomps_nopf++;
DPRINTF(("%s: unknown/unsupported protocol family %d, "
"IPCA %s/%08lx\n", __func__,
sav->sah->saidx.dst.sa.sa_family,
@@ -369,7 +370,7 @@ ipcomp_output(
goto bad;
}
if (skip + hlen + ralen > maxpacketsize) {
- ipcompstat.ipcomps_toobig++;
+ V_ipcompstat.ipcomps_toobig++;
DPRINTF(("%s: packet in IPCA %s/%08lx got too big "
"(len %u, max len %u)\n", __func__,
ipsec_address(&sav->sah->saidx.dst),
@@ -380,11 +381,11 @@ ipcomp_output(
}
/* Update the counters */
- ipcompstat.ipcomps_obytes += m->m_pkthdr.len - skip;
+ V_ipcompstat.ipcomps_obytes += m->m_pkthdr.len - skip;
m = m_unshare(m, M_NOWAIT);
if (m == NULL) {
- ipcompstat.ipcomps_hdrops++;
+ V_ipcompstat.ipcomps_hdrops++;
DPRINTF(("%s: cannot clone mbuf chain, IPCA %s/%08lx\n",
__func__, ipsec_address(&sav->sah->saidx.dst),
(u_long) ntohl(sav->spi)));
@@ -395,7 +396,7 @@ ipcomp_output(
/* Inject IPCOMP header */
mo = m_makespace(m, skip, hlen, &roff);
if (mo == NULL) {
- ipcompstat.ipcomps_wrap++;
+ V_ipcompstat.ipcomps_wrap++;
DPRINTF(("%s: IPCOMP header inject failed for IPCA %s/%08lx\n",
__func__, ipsec_address(&sav->sah->saidx.dst),
(u_long) ntohl(sav->spi)));
@@ -430,7 +431,7 @@ ipcomp_output(
/* Get crypto descriptors */
crp = crypto_getreq(1);
if (crp == NULL) {
- ipcompstat.ipcomps_crypto++;
+ V_ipcompstat.ipcomps_crypto++;
DPRINTF(("%s: failed to acquire crypto descriptor\n",__func__));
error = ENOBUFS;
goto bad;
@@ -450,7 +451,7 @@ ipcomp_output(
tc = (struct tdb_crypto *) malloc(sizeof(struct tdb_crypto),
M_XDATA, M_NOWAIT|M_ZERO);
if (tc == NULL) {
- ipcompstat.ipcomps_crypto++;
+ V_ipcompstat.ipcomps_crypto++;
DPRINTF(("%s: failed to allocate tdb_crypto\n", __func__));
crypto_freereq(crp);
error = ENOBUFS;
@@ -500,7 +501,7 @@ ipcomp_output_cb(struct cryptop *crp)
IPSECREQUEST_LOCK(isr);
sav = KEY_ALLOCSA(&tc->tc_dst, tc->tc_proto, tc->tc_spi);
if (sav == NULL) {
- ipcompstat.ipcomps_notdb++;
+ V_ipcompstat.ipcomps_notdb++;
DPRINTF(("%s: SA expired while in crypto\n", __func__));
error = ENOBUFS; /*XXX*/
goto bad;
@@ -519,19 +520,19 @@ ipcomp_output_cb(struct cryptop *crp)
error = crypto_dispatch(crp);
return error;
}
- ipcompstat.ipcomps_noxform++;
+ V_ipcompstat.ipcomps_noxform++;
DPRINTF(("%s: crypto error %d\n", __func__, crp->crp_etype));
error = crp->crp_etype;
goto bad;
}
/* Shouldn't happen... */
if (m == NULL) {
- ipcompstat.ipcomps_crypto++;
+ V_ipcompstat.ipcomps_crypto++;
DPRINTF(("%s: bogus return buffer from crypto\n", __func__));
error = EINVAL;
goto bad;
}
- ipcompstat.ipcomps_hist[sav->alg_comp]++;
+ V_ipcompstat.ipcomps_hist[sav->alg_comp]++;
if (rlen > crp->crp_olen) {
/* Adjust the length in the IP header */
@@ -548,7 +549,7 @@ ipcomp_output_cb(struct cryptop *crp)
break;
#endif /* INET6 */
default:
- ipcompstat.ipcomps_nopf++;
+ V_ipcompstat.ipcomps_nopf++;
DPRINTF(("%s: unknown/unsupported protocol "
"family %d, IPCA %s/%08lx\n", __func__,
sav->sah->saidx.dst.sa.sa_family,
diff --git a/sys/netipsec/xform_ipip.c b/sys/netipsec/xform_ipip.c
index 4e8495b..cb9256d 100644
--- a/sys/netipsec/xform_ipip.c
+++ b/sys/netipsec/xform_ipip.c
@@ -50,6 +50,7 @@
#include <sys/kernel.h>
#include <sys/protosw.h>
#include <sys/sysctl.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/pfil.h>
@@ -113,9 +114,9 @@ ip4_input6(struct mbuf **m, int *offp, int proto)
{
#if 0
/* If we do not accept IP-in-IP explicitly, drop. */
- if (!ipip_allow && ((*m)->m_flags & M_IPSEC) == 0) {
+ if (!V_ipip_allow && ((*m)->m_flags & M_IPSEC) == 0) {
DPRINTF(("%s: dropped due to policy\n", __func__));
- ipipstat.ipips_pdrops++;
+ V_ipipstat.ipips_pdrops++;
m_freem(*m);
return IPPROTO_DONE;
}
@@ -134,9 +135,9 @@ ip4_input(struct mbuf *m, int off)
{
#if 0
/* If we do not accept IP-in-IP explicitly, drop. */
- if (!ipip_allow && (m->m_flags & M_IPSEC) == 0) {
+ if (!V_ipip_allow && (m->m_flags & M_IPSEC) == 0) {
DPRINTF(("%s: dropped due to policy\n", __func__));
- ipipstat.ipips_pdrops++;
+ V_ipipstat.ipips_pdrops++;
m_freem(m);
return;
}
@@ -170,7 +171,7 @@ _ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp)
u_int8_t v;
int hlen;
- ipipstat.ipips_ipackets++;
+ V_ipipstat.ipips_ipackets++;
m_copydata(m, 0, 1, &v);
@@ -186,7 +187,7 @@ _ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp)
break;
#endif
default:
- ipipstat.ipips_family++;
+ V_ipipstat.ipips_family++;
m_freem(m);
return /* EAFNOSUPPORT */;
}
@@ -195,7 +196,7 @@ _ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp)
if (m->m_len < hlen) {
if ((m = m_pullup(m, hlen)) == NULL) {
DPRINTF(("%s: m_pullup (1) failed\n", __func__));
- ipipstat.ipips_hdrops++;
+ V_ipipstat.ipips_hdrops++;
return;
}
}
@@ -232,7 +233,7 @@ _ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp)
/* Sanity check */
if (m->m_pkthdr.len < sizeof(struct ip)) {
- ipipstat.ipips_hdrops++;
+ V_ipipstat.ipips_hdrops++;
m_freem(m);
return;
}
@@ -252,7 +253,7 @@ _ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp)
break;
#endif
default:
- ipipstat.ipips_family++;
+ V_ipipstat.ipips_family++;
m_freem(m);
return; /* EAFNOSUPPORT */
}
@@ -263,7 +264,7 @@ _ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp)
if (m->m_len < hlen) {
if ((m = m_pullup(m, hlen)) == NULL) {
DPRINTF(("%s: m_pullup (2) failed\n", __func__));
- ipipstat.ipips_hdrops++;
+ V_ipipstat.ipips_hdrops++;
return;
}
}
@@ -280,7 +281,7 @@ _ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp)
case 4:
ipo = mtod(m, struct ip *);
nxt = ipo->ip_p;
- ip_ecn_egress(ip4_ipsec_ecn, &otos, &ipo->ip_tos);
+ ip_ecn_egress(V_ip4_ipsec_ecn, &otos, &ipo->ip_tos);
break;
#endif /* INET */
#ifdef INET6
@@ -288,7 +289,7 @@ _ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp)
ip6 = (struct ip6_hdr *) ipo;
nxt = ip6->ip6_nxt;
itos = (ntohl(ip6->ip6_flow) >> 20) & 0xff;
- ip_ecn_egress(ip6_ipsec_ecn, &otos, &itos);
+ ip_ecn_egress(V_ip6_ipsec_ecn, &otos, &itos);
ip6->ip6_flow &= ~htonl(0xff << 20);
ip6->ip6_flow |= htonl((u_int32_t) itos << 20);
break;
@@ -300,9 +301,9 @@ _ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp)
/* Check for local address spoofing. */
if ((m->m_pkthdr.rcvif == NULL ||
!(m->m_pkthdr.rcvif->if_flags & IFF_LOOPBACK)) &&
- ipip_allow != 2) {
+ V_ipip_allow != 2) {
IFNET_RLOCK();
- TAILQ_FOREACH(ifp, &ifnet, if_link) {
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
#ifdef INET
if (ipo) {
@@ -314,7 +315,7 @@ _ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp)
if (sin->sin_addr.s_addr ==
ipo->ip_src.s_addr) {
- ipipstat.ipips_spoof++;
+ V_ipipstat.ipips_spoof++;
m_freem(m);
IFNET_RUNLOCK();
return;
@@ -331,7 +332,7 @@ _ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp)
sin6 = (struct sockaddr_in6 *) ifa->ifa_addr;
if (IN6_ARE_ADDR_EQUAL(&sin6->sin6_addr, &ip6->ip6_src)) {
- ipipstat.ipips_spoof++;
+ V_ipipstat.ipips_spoof++;
m_freem(m);
IFNET_RUNLOCK();
return;
@@ -345,7 +346,7 @@ _ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp)
}
/* Statistics */
- ipipstat.ipips_ibytes += m->m_pkthdr.len - iphlen;
+ V_ipipstat.ipips_ibytes += m->m_pkthdr.len - iphlen;
#ifdef DEV_ENC
switch (v >> 4) {
@@ -391,7 +392,7 @@ _ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp)
}
if (netisr_queue(isr, m)) { /* (0) on success. */
- ipipstat.ipips_qfull++;
+ V_ipipstat.ipips_qfull++;
DPRINTF(("%s: packet dropped because of full queue\n",
__func__));
}
@@ -438,7 +439,7 @@ ipip_output(
"address in SA %s/%08lx\n", __func__,
ipsec_address(&saidx->dst),
(u_long) ntohl(sav->spi)));
- ipipstat.ipips_unspec++;
+ V_ipipstat.ipips_unspec++;
error = EINVAL;
goto bad;
}
@@ -446,7 +447,7 @@ ipip_output(
M_PREPEND(m, sizeof(struct ip), M_DONTWAIT);
if (m == 0) {
DPRINTF(("%s: M_PREPEND failed\n", __func__));
- ipipstat.ipips_hdrops++;
+ V_ipipstat.ipips_hdrops++;
error = ENOBUFS;
goto bad;
}
@@ -456,7 +457,7 @@ ipip_output(
ipo->ip_v = IPVERSION;
ipo->ip_hl = 5;
ipo->ip_len = htons(m->m_pkthdr.len);
- ipo->ip_ttl = ip_defttl;
+ ipo->ip_ttl = V_ip_defttl;
ipo->ip_sum = 0;
ipo->ip_src = saidx->src.sin.sin_addr;
ipo->ip_dst = saidx->dst.sin.sin_addr;
@@ -515,7 +516,7 @@ ipip_output(
"address in SA %s/%08lx\n", __func__,
ipsec_address(&saidx->dst),
(u_long) ntohl(sav->spi)));
- ipipstat.ipips_unspec++;
+ V_ipipstat.ipips_unspec++;
error = ENOBUFS;
goto bad;
}
@@ -530,7 +531,7 @@ ipip_output(
M_PREPEND(m, sizeof(struct ip6_hdr), M_DONTWAIT);
if (m == 0) {
DPRINTF(("%s: M_PREPEND failed\n", __func__));
- ipipstat.ipips_hdrops++;
+ V_ipipstat.ipips_hdrops++;
error = ENOBUFS;
goto bad;
}
@@ -541,7 +542,7 @@ ipip_output(
ip6o->ip6_vfc &= ~IPV6_VERSION_MASK;
ip6o->ip6_vfc |= IPV6_VERSION;
ip6o->ip6_plen = htons(m->m_pkthdr.len);
- ip6o->ip6_hlim = ip_defttl;
+ ip6o->ip6_hlim = V_ip_defttl;
ip6o->ip6_dst = saidx->dst.sin6.sin6_addr;
ip6o->ip6_src = saidx->src.sin6.sin6_addr;
@@ -580,12 +581,12 @@ ipip_output(
nofamily:
DPRINTF(("%s: unsupported protocol family %u\n", __func__,
saidx->dst.sa.sa_family));
- ipipstat.ipips_family++;
+ V_ipipstat.ipips_family++;
error = EAFNOSUPPORT; /* XXX diffs from openbsd */
goto bad;
}
- ipipstat.ipips_opackets++;
+ V_ipipstat.ipips_opackets++;
*mp = m;
#ifdef INET
@@ -595,7 +596,7 @@ nofamily:
tdb->tdb_cur_bytes +=
m->m_pkthdr.len - sizeof(struct ip);
#endif
- ipipstat.ipips_obytes += m->m_pkthdr.len - sizeof(struct ip);
+ V_ipipstat.ipips_obytes += m->m_pkthdr.len - sizeof(struct ip);
}
#endif /* INET */
@@ -606,7 +607,7 @@ nofamily:
tdb->tdb_cur_bytes +=
m->m_pkthdr.len - sizeof(struct ip6_hdr);
#endif
- ipipstat.ipips_obytes +=
+ V_ipipstat.ipips_obytes +=
m->m_pkthdr.len - sizeof(struct ip6_hdr);
}
#endif /* INET6 */
diff --git a/sys/nfsclient/bootp_subr.c b/sys/nfsclient/bootp_subr.c
index 7f65fe2..1274da0 100644
--- a/sys/nfsclient/bootp_subr.c
+++ b/sys/nfsclient/bootp_subr.c
@@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$");
#include <sys/socketvar.h>
#include <sys/sysctl.h>
#include <sys/uio.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/route.h>
@@ -374,9 +375,9 @@ bootpboot_p_rtlist(void)
{
printf("Routing table:\n");
- RADIX_NODE_LOCK(rt_tables[AF_INET]); /* could sleep XXX */
- bootpboot_p_tree(rt_tables[AF_INET]->rnh_treetop);
- RADIX_NODE_UNLOCK(rt_tables[AF_INET]);
+ RADIX_NODE_LOCK(V_rt_tables[AF_INET]); /* could sleep XXX */
+ bootpboot_p_tree(V_rt_tables[AF_INET]->rnh_treetop);
+ RADIX_NODE_UNLOCK(V_rt_tables[AF_INET]);
}
void
@@ -401,7 +402,7 @@ bootpboot_p_iflist(void)
printf("Interface list:\n");
IFNET_RLOCK(); /* could sleep, but okay for debugging XXX */
- for (ifp = TAILQ_FIRST(&ifnet);
+ for (ifp = TAILQ_FIRST(&V_ifnet);
ifp != NULL;
ifp = TAILQ_NEXT(ifp, if_link)) {
for (ifa = TAILQ_FIRST(&ifp->if_addrhead);
@@ -1570,8 +1571,8 @@ bootpc_decode_reply(struct nfsv3_diskless *nd, struct bootpc_ifcontext *ifctx,
} else {
strcpy(nd->my_hostnam, p);
mtx_lock(&hostname_mtx);
- strcpy(hostname, p);
- printf("hostname %s ", hostname);
+ strcpy(G_hostname, p);
+ printf("hostname %s ", G_hostname);
mtx_unlock(&hostname_mtx);
gctx->sethostname = ifctx;
}
@@ -1644,7 +1645,7 @@ bootpc_init(void)
* attaches and wins the race, it won't be eligible for bootp.
*/
IFNET_RLOCK();
- for (ifp = TAILQ_FIRST(&ifnet), ifcnt = 0;
+ for (ifp = TAILQ_FIRST(&V_ifnet), ifcnt = 0;
ifp != NULL;
ifp = TAILQ_NEXT(ifp, if_link)) {
if ((ifp->if_flags &
@@ -1661,7 +1662,7 @@ bootpc_init(void)
#endif
IFNET_RLOCK();
- for (ifp = TAILQ_FIRST(&ifnet), ifctx = gctx->interfaces;
+ for (ifp = TAILQ_FIRST(&V_ifnet), ifctx = gctx->interfaces;
ifp != NULL && ifctx != NULL;
ifp = TAILQ_NEXT(ifp, if_link)) {
strlcpy(ifctx->ireq.ifr_name, ifp->if_xname,
diff --git a/sys/nfsclient/nfs_diskless.c b/sys/nfsclient/nfs_diskless.c
index 58e99ee..be5f934 100644
--- a/sys/nfsclient/nfs_diskless.c
+++ b/sys/nfsclient/nfs_diskless.c
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
#include <sys/mount.h>
#include <sys/socket.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <net/if_types.h>
@@ -176,7 +177,7 @@ nfs_setup_diskless(void)
}
ifa = NULL;
IFNET_RLOCK();
- TAILQ_FOREACH(ifp, &ifnet, if_link) {
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
if (ifa->ifa_addr->sa_family == AF_LINK) {
sdl = (struct sockaddr_dl *)ifa->ifa_addr;
diff --git a/sys/nfsclient/nfs_vfsops.c b/sys/nfsclient/nfs_vfsops.c
index d068ab3..e7e3f12 100644
--- a/sys/nfsclient/nfs_vfsops.c
+++ b/sys/nfsclient/nfs_vfsops.c
@@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sysctl.h>
#include <sys/vnode.h>
#include <sys/signalvar.h>
+#include <sys/vimage.h>
#include <vm/vm.h>
#include <vm/vm_extern.h>
@@ -509,10 +510,10 @@ nfs_mountroot(struct mount *mp, struct thread *td)
* mount the right /var based upon its preset value.
*/
mtx_lock(&hostname_mtx);
- bcopy(nd->my_hostnam, hostname, MAXHOSTNAMELEN);
- hostname[MAXHOSTNAMELEN - 1] = '\0';
+ bcopy(nd->my_hostnam, V_hostname, MAXHOSTNAMELEN);
+ V_hostname[MAXHOSTNAMELEN - 1] = '\0';
for (i = 0; i < MAXHOSTNAMELEN; i++)
- if (hostname[i] == '\0')
+ if (V_hostname[i] == '\0')
break;
mtx_unlock(&hostname_mtx);
inittodr(ntohl(nd->root_time));
diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c
index 3711165..affc5bd 100644
--- a/sys/nfsclient/nfs_vnops.c
+++ b/sys/nfsclient/nfs_vnops.c
@@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$");
#include <sys/stat.h>
#include <sys/sysctl.h>
#include <sys/signalvar.h>
+#include <sys/vimage.h>
#include <vm/vm.h>
#include <vm/vm_object.h>
@@ -1393,8 +1394,8 @@ again:
*tl = txdr_unsigned(NFSV3CREATE_EXCLUSIVE);
tl = nfsm_build(u_int32_t *, NFSX_V3CREATEVERF);
#ifdef INET
- if (!TAILQ_EMPTY(&in_ifaddrhead))
- *tl++ = IA_SIN(TAILQ_FIRST(&in_ifaddrhead))->sin_addr.s_addr;
+ if (!TAILQ_EMPTY(&V_in_ifaddrhead))
+ *tl++ = IA_SIN(TAILQ_FIRST(&V_in_ifaddrhead))->sin_addr.s_addr;
else
#endif
*tl++ = create_verf;
diff --git a/sys/rpc/authunix_prot.c b/sys/rpc/authunix_prot.c
index b229fb3..3f61299 100644
--- a/sys/rpc/authunix_prot.c
+++ b/sys/rpc/authunix_prot.c
@@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$");
#include <sys/mutex.h>
#include <sys/systm.h>
#include <sys/ucred.h>
+#include <sys/vimage.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
@@ -74,7 +75,7 @@ xdr_authunix_parms(XDR *xdrs, uint32_t *time, struct xucred *cred)
/*
* Restrict name length to 255 according to RFC 1057.
*/
- namelen = strlen(hostname);
+ namelen = strlen(V_hostname);
if (namelen > 255)
namelen = 255;
} else {
@@ -90,7 +91,7 @@ xdr_authunix_parms(XDR *xdrs, uint32_t *time, struct xucred *cred)
* Ignore the hostname on decode.
*/
if (xdrs->x_op == XDR_ENCODE) {
- if (!xdr_opaque(xdrs, hostname, namelen))
+ if (!xdr_opaque(xdrs, V_hostname, namelen))
return (FALSE);
} else {
xdr_setpos(xdrs, xdr_getpos(xdrs) + RNDUP(namelen));
diff --git a/sys/sparc64/sparc64/dump_machdep.c b/sys/sparc64/sparc64/dump_machdep.c
index a617d4a..19e94cc 100644
--- a/sys/sparc64/sparc64/dump_machdep.c
+++ b/sys/sparc64/sparc64/dump_machdep.c
@@ -33,6 +33,7 @@
#include <sys/cons.h>
#include <sys/kernel.h>
#include <sys/kerneldump.h>
+#include <sys/vimage.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
@@ -69,7 +70,7 @@ mkdumpheader(struct kerneldumpheader *kdh, uint32_t archver, uint64_t dumplen,
kdh->dumplength = htod64(dumplen);
kdh->dumptime = htod64(time_second);
kdh->blocksize = htod32(blksz);
- strncpy(kdh->hostname, hostname, sizeof(kdh->hostname));
+ strncpy(kdh->hostname, G_hostname, sizeof(kdh->hostname));
strncpy(kdh->versionstring, version, sizeof(kdh->versionstring));
if (panicstr != NULL)
strncpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring));
diff --git a/sys/sun4v/sun4v/dump_machdep.c b/sys/sun4v/sun4v/dump_machdep.c
index 3558b53..f3acdc6 100644
--- a/sys/sun4v/sun4v/dump_machdep.c
+++ b/sys/sun4v/sun4v/dump_machdep.c
@@ -33,6 +33,7 @@
#include <sys/cons.h>
#include <sys/kernel.h>
#include <sys/kerneldump.h>
+#include <sys/vimage.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
@@ -70,7 +71,7 @@ mkdumpheader(struct kerneldumpheader *kdh, uint32_t archver, uint64_t dumplen,
kdh->dumplength = htod64(dumplen);
kdh->dumptime = htod64(time_second);
kdh->blocksize = htod32(blksz);
- strncpy(kdh->hostname, hostname, sizeof(kdh->hostname));
+ strncpy(kdh->hostname, G_hostname, sizeof(kdh->hostname));
strncpy(kdh->versionstring, version, sizeof(kdh->versionstring));
if (panicstr != NULL)
strncpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring));
diff --git a/sys/sys/param.h b/sys/sys/param.h
index f4edd2e..773f24f 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -57,7 +57,7 @@
* is created, otherwise 1.
*/
#undef __FreeBSD_version
-#define __FreeBSD_version 800043 /* Master, propagated to newvers */
+#define __FreeBSD_version 800044 /* Master, propagated to newvers */
#ifndef LOCORE
#include <sys/types.h>
diff --git a/sys/sys/vimage.h b/sys/sys/vimage.h
new file mode 100644
index 0000000..e7bf23f
--- /dev/null
+++ b/sys/sys/vimage.h
@@ -0,0 +1,344 @@
+/*-
+ * Copyright (c) 2006-2008 University of Zagreb
+ * Copyright (c) 2006-2008 FreeBSD Foundation
+ *
+ * This software was developed by the University of Zagreb and the
+ * FreeBSD Foundation under sponsorship by the Stichting NLnet and the
+ * FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _SYS_VIMAGE_H_
+#define _SYS_VIMAGE_H_
+
+#define V_hostname hostname
+#define G_hostname hostname
+#define V_domainname domainname
+#define V_acq_seq acq_seq
+#define V_acqtree acqtree
+#define V_addrsel_policytab addrsel_policytab
+#define V_ah_cleartos ah_cleartos
+#define V_ah_enable ah_enable
+#define V_ahstat ahstat
+#define V_arp_maxtries arp_maxtries
+#define V_arp_proxyall arp_proxyall
+#define V_arpt_keep arpt_keep
+#define V_autoinc_step autoinc_step
+#define V_blackhole blackhole
+#define V_crypto_support crypto_support
+#define V_curr_dyn_buckets curr_dyn_buckets
+#define V_dad_ignore_ns dad_ignore_ns
+#define V_dad_init dad_init
+#define V_dad_maxtry dad_maxtry
+#define V_dadq dadq
+#define V_defaultaddrpolicy defaultaddrpolicy
+#define V_divcb divcb
+#define V_divcbinfo divcbinfo
+#define V_drop_synfin drop_synfin
+#define V_dyn_ack_lifetime dyn_ack_lifetime
+#define V_dyn_buckets dyn_buckets
+#define V_dyn_count dyn_count
+#define V_dyn_fin_lifetime dyn_fin_lifetime
+#define V_dyn_keepalive dyn_keepalive
+#define V_dyn_keepalive_interval dyn_keepalive_interval
+#define V_dyn_keepalive_period dyn_keepalive_period
+#define V_dyn_max dyn_max
+#define V_dyn_rst_lifetime dyn_rst_lifetime
+#define V_dyn_short_lifetime dyn_short_lifetime
+#define V_dyn_syn_lifetime dyn_syn_lifetime
+#define V_dyn_udp_lifetime dyn_udp_lifetime
+#define V_esp_enable esp_enable
+#define V_esp_max_ivlen esp_max_ivlen
+#define V_espstat espstat
+#define V_ether_ipfw ether_ipfw
+#define V_frag6_nfragpackets frag6_nfragpackets
+#define V_frag6_nfrags frag6_nfrags
+#define V_fw6_enable fw6_enable
+#define V_fw_debug fw_debug
+#define V_fw_deny_unknown_exthdrs fw_deny_unknown_exthdrs
+#define V_fw_enable fw_enable
+#define V_fw_one_pass fw_one_pass
+#define V_fw_verbose fw_verbose
+#define V_gif_softc_list gif_softc_list
+#define V_icmp6_nodeinfo icmp6_nodeinfo
+#define V_icmp6_rediraccept icmp6_rediraccept
+#define V_icmp6_redirtimeout icmp6_redirtimeout
+#define V_icmp6errpps_count icmp6errpps_count
+#define V_icmp6errppslim icmp6errppslim
+#define V_icmp6errppslim_last icmp6errppslim_last
+#define V_icmp6stat icmp6stat
+#define V_icmp_may_rst icmp_may_rst
+#define V_icmpstat icmpstat
+#define V_if_index if_index
+#define V_if_indexlim if_indexlim
+#define V_ifaddr_event_tag ifaddr_event_tag
+#define V_ifg_head ifg_head
+#define V_ifindex_table ifindex_table
+#define V_ifklist ifklist
+#define V_ifnet ifnet
+#define V_igmpstat igmpstat
+#define V_in6_ifaddr in6_ifaddr
+#define V_in6_maxmtu in6_maxmtu
+#define V_in6_tmpaddrtimer_ch in6_tmpaddrtimer_ch
+#define V_in_ifaddrhashtbl in_ifaddrhashtbl
+#define V_in_ifaddrhead in_ifaddrhead
+#define V_in_ifaddrhmask in_ifaddrhmask
+#define V_in_multihead in_multihead
+#define V_ip4_ah_net_deflev ip4_ah_net_deflev
+#define V_ip4_ah_offsetmask ip4_ah_offsetmask
+#define V_ip4_ah_trans_deflev ip4_ah_trans_deflev
+#define V_ip4_def_policy ip4_def_policy
+#define V_ip4_esp_net_deflev ip4_esp_net_deflev
+#define V_ip4_esp_randpad ip4_esp_randpad
+#define V_ip4_esp_trans_deflev ip4_esp_trans_deflev
+#define V_ip4_ipsec_dfbit ip4_ipsec_dfbit
+#define V_ip4_ipsec_ecn ip4_ipsec_ecn
+#define V_ip6_accept_rtadv ip6_accept_rtadv
+#define V_ip6_ah_net_deflev ip6_ah_net_deflev
+#define V_ip6_ah_trans_deflev ip6_ah_trans_deflev
+#define V_ip6_auto_flowlabel ip6_auto_flowlabel
+#define V_ip6_auto_linklocal ip6_auto_linklocal
+#define V_ip6_dad_count ip6_dad_count
+#define V_ip6_defhlim ip6_defhlim
+#define V_ip6_defmcasthlim ip6_defmcasthlim
+#define V_ip6_desync_factor ip6_desync_factor
+#define V_ip6_esp_net_deflev ip6_esp_net_deflev
+#define V_ip6_esp_trans_deflev ip6_esp_trans_deflev
+#define V_ip6_forward_rt ip6_forward_rt
+#define V_ip6_forward_srcrt ip6_forward_srcrt
+#define V_ip6_forwarding ip6_forwarding
+#define V_ip6_gif_hlim ip6_gif_hlim
+#define V_ip6_hdrnestlimit ip6_hdrnestlimit
+#define V_ip6_ipsec_ecn ip6_ipsec_ecn
+#define V_ip6_keepfaith ip6_keepfaith
+#define V_ip6_log_interval ip6_log_interval
+#define V_ip6_log_time ip6_log_time
+#define V_ip6_maxfragpackets ip6_maxfragpackets
+#define V_ip6_maxfrags ip6_maxfrags
+#define V_ip6_mcast_pmtu ip6_mcast_pmtu
+#define V_ip6_mrouter_ver ip6_mrouter_ver
+#define V_ip6_opts ip6_opts
+#define V_ip6_ours_check_algorithm ip6_ours_check_algorithm
+#define V_ip6_prefer_tempaddr ip6_prefer_tempaddr
+#define V_ip6_rr_prune ip6_rr_prune
+#define V_ip6_sendredirects ip6_sendredirects
+#define V_ip6_sourcecheck ip6_sourcecheck
+#define V_ip6_sourcecheck_interval ip6_sourcecheck_interval
+#define V_ip6_temp_preferred_lifetime ip6_temp_preferred_lifetime
+#define V_ip6_temp_regen_advance ip6_temp_regen_advance
+#define V_ip6_temp_valid_lifetime ip6_temp_valid_lifetime
+#define V_ip6_use_defzone ip6_use_defzone
+#define V_ip6_use_deprecated ip6_use_deprecated
+#define V_ip6_use_tempaddr ip6_use_tempaddr
+#define V_ip6_v6only ip6_v6only
+#define V_ip6q ip6q
+#define V_ip6qmaxlen ip6qmaxlen
+#define V_ip6stat ip6stat
+#define V_ip6stealth ip6stealth
+#define V_ip_checkinterface ip_checkinterface
+#define V_ip_defttl ip_defttl
+#define V_ip_do_randomid ip_do_randomid
+#define V_ip_gif_ttl ip_gif_ttl
+#define V_ip_keepfaith ip_keepfaith
+#define V_ip_mrouter ip_mrouter
+#define V_ip_rsvp_on ip_rsvp_on
+#define V_ip_rsvpd ip_rsvpd
+#define V_ip_sendsourcequench ip_sendsourcequench
+#define V_ipcomp_enable ipcomp_enable
+#define V_ipcompstat ipcompstat
+#define V_ipfastforward_active ipfastforward_active
+#define V_ipforwarding ipforwarding
+#define V_ipfw_dyn_v ipfw_dyn_v
+#define V_ipfw_timeout ipfw_timeout
+#define V_ipip_allow ipip_allow
+#define V_ipipstat ipipstat
+#define V_ipport_firstauto ipport_firstauto
+#define V_ipport_hifirstauto ipport_hifirstauto
+#define V_ipport_hilastauto ipport_hilastauto
+#define V_ipport_lastauto ipport_lastauto
+#define V_ipport_lowfirstauto ipport_lowfirstauto
+#define V_ipport_lowlastauto ipport_lowlastauto
+#define V_ipport_randomcps ipport_randomcps
+#define V_ipport_randomized ipport_randomized
+#define V_ipport_randomtime ipport_randomtime
+#define V_ipport_reservedhigh ipport_reservedhigh
+#define V_ipport_reservedlow ipport_reservedlow
+#define V_ipport_stoprandom ipport_stoprandom
+#define V_ipport_tcpallocs ipport_tcpallocs
+#define V_ipport_tcplastcount ipport_tcplastcount
+#define V_ipq ipq
+#define V_ipq_zone ipq_zone
+#define V_ipsec4stat ipsec4stat
+#define V_ipsec6stat ipsec6stat
+#define V_ipsec_ah_keymin ipsec_ah_keymin
+#define V_ipsec_debug ipsec_debug
+#define V_ipsec_esp_auth ipsec_esp_auth
+#define V_ipsec_esp_keymin ipsec_esp_keymin
+#define V_ipsec_integrity ipsec_integrity
+#define V_ipsec_replay ipsec_replay
+#define V_ipsendredirects ipsendredirects
+#define V_ipstat ipstat
+#define V_ipstealth ipstealth
+#define V_isn_ctx isn_ctx
+#define V_isn_last_reseed isn_last_reseed
+#define V_isn_offset isn_offset
+#define V_isn_offset_old isn_offset_old
+#define V_isn_secret isn_secret
+#define V_key_blockacq_count key_blockacq_count
+#define V_key_blockacq_lifetime key_blockacq_lifetime
+#define V_key_cb key_cb
+#define V_key_debug_level key_debug_level
+#define V_key_int_random key_int_random
+#define V_key_larval_lifetime key_larval_lifetime
+#define V_key_preferred_oldsa key_preferred_oldsa
+#define V_key_spi_maxval key_spi_maxval
+#define V_key_spi_minval key_spi_minval
+#define V_key_spi_trycnt key_spi_trycnt
+#define V_key_src key_src
+#define V_layer3_chain layer3_chain
+#define V_llinfo_arp llinfo_arp
+#define V_llinfo_nd6 llinfo_nd6
+#define V_lo_list lo_list
+#define V_loif loif
+#define V_max_gif_nesting max_gif_nesting
+#define V_maxfragsperpacket maxfragsperpacket
+#define V_maxnipq maxnipq
+#define V_mrt6debug mrt6debug
+#define V_nd6_allocated nd6_allocated
+#define V_nd6_debug nd6_debug
+#define V_nd6_defifindex nd6_defifindex
+#define V_nd6_defifp nd6_defifp
+#define V_nd6_delay nd6_delay
+#define V_nd6_gctimer nd6_gctimer
+#define V_nd6_inuse nd6_inuse
+#define V_nd6_maxndopt nd6_maxndopt
+#define V_nd6_maxnudhint nd6_maxnudhint
+#define V_nd6_maxqueuelen nd6_maxqueuelen
+#define V_nd6_mmaxtries nd6_mmaxtries
+#define V_nd6_prune nd6_prune
+#define V_nd6_recalc_reachtm_interval nd6_recalc_reachtm_interval
+#define V_nd6_slowtimo_ch nd6_slowtimo_ch
+#define V_nd6_timer_ch nd6_timer_ch
+#define V_nd6_umaxtries nd6_umaxtries
+#define V_nd6_useloopback nd6_useloopback
+#define V_nd_defrouter nd_defrouter
+#define V_nd_prefix nd_prefix
+#define V_nextID nextID
+#define V_ng_ID_hash ng_ID_hash
+#define V_ng_eiface_unit ng_eiface_unit
+#define V_ng_iface_unit ng_iface_unit
+#define V_ng_name_hash ng_name_hash
+#define V_nipq nipq
+#define V_nolocaltimewait nolocaltimewait
+#define V_norule_counter norule_counter
+#define V_parallel_tunnels parallel_tunnels
+#define V_path_mtu_discovery path_mtu_discovery
+#define V_pfkeystat pfkeystat
+#define V_pim6 pim6
+#define V_pmtu_expire pmtu_expire
+#define V_pmtu_probe pmtu_probe
+#define V_policy_id policy_id
+#define V_rawcb_list rawcb_list
+#define V_regtree regtree
+#define V_rip6_recvspace rip6_recvspace
+#define V_rip6_sendspace rip6_sendspace
+#define V_rip6stat rip6stat
+#define V_ripcb ripcb
+#define V_ripcbinfo ripcbinfo
+#define V_router_info_head router_info_head
+#define V_rsvp_on rsvp_on
+#define V_rt_tables rt_tables
+#define V_rtq_minreallyold rtq_minreallyold
+#define V_rtq_mtutimer rtq_mtutimer
+#define V_rtq_reallyold rtq_reallyold
+#define V_rtq_timeout rtq_timeout
+#define V_rtq_timeout6 rtq_timeout6
+#define V_rtq_timer rtq_timer
+#define V_rtq_timer6 rtq_timer6
+#define V_rtq_toomany rtq_toomany
+#define V_rtstat rtstat
+#define V_rttrash rttrash
+#define V_sahtree sahtree
+#define V_sameprefixcarponly sameprefixcarponly
+#define V_saorder_state_alive saorder_state_alive
+#define V_saorder_state_any saorder_state_any
+#define V_set_disable set_disable
+#define V_sid_default sid_default
+#define V_spacqtree spacqtree
+#define V_sptree sptree
+#define V_ss_fltsz ss_fltsz
+#define V_ss_fltsz_local ss_fltsz_local
+#define V_static_count static_count
+#define V_subnetsarelocal subnetsarelocal
+#define V_tcb tcb
+#define V_tcbinfo tcbinfo
+#define V_tcp_autorcvbuf_inc tcp_autorcvbuf_inc
+#define V_tcp_autorcvbuf_max tcp_autorcvbuf_max
+#define V_tcp_autosndbuf_inc tcp_autosndbuf_inc
+#define V_tcp_autosndbuf_max tcp_autosndbuf_max
+#define V_tcp_delack_enabled tcp_delack_enabled
+#define V_tcp_do_autorcvbuf tcp_do_autorcvbuf
+#define V_tcp_do_autosndbuf tcp_do_autosndbuf
+#define V_tcp_do_ecn tcp_do_ecn
+#define V_tcp_do_newreno tcp_do_newreno
+#define V_tcp_do_rfc1323 tcp_do_rfc1323
+#define V_tcp_do_rfc3042 tcp_do_rfc3042
+#define V_tcp_do_rfc3390 tcp_do_rfc3390
+#define V_tcp_do_sack tcp_do_sack
+#define V_tcp_do_tso tcp_do_tso
+#define V_tcp_hc_callout tcp_hc_callout
+#define V_tcp_ecn_maxretries tcp_ecn_maxretries
+#define V_tcp_hostcache tcp_hostcache
+#define V_tcp_inflight_enable tcp_inflight_enable
+#define V_tcp_inflight_max tcp_inflight_max
+#define V_tcp_inflight_min tcp_inflight_min
+#define V_tcp_inflight_rttthresh tcp_inflight_rttthresh
+#define V_tcp_inflight_stab tcp_inflight_stab
+#define V_tcp_insecure_rst tcp_insecure_rst
+#define V_tcp_isn_reseed_interval tcp_isn_reseed_interval
+#define V_tcp_minmss tcp_minmss
+#define V_tcp_mssdflt tcp_mssdflt
+#define V_tcp_reass_maxqlen tcp_reass_maxqlen
+#define V_tcp_reass_maxseg tcp_reass_maxseg
+#define V_tcp_reass_overflows tcp_reass_overflows
+#define V_tcp_reass_qsize tcp_reass_qsize
+#define V_tcp_sack_globalholes tcp_sack_globalholes
+#define V_tcp_sack_globalmaxholes tcp_sack_globalmaxholes
+#define V_tcp_sack_maxholes tcp_sack_maxholes
+#define V_tcp_sc_rst_sock_fail tcp_sc_rst_sock_fail
+#define V_tcp_syncache tcp_syncache
+#define V_tcp_v6mssdflt tcp_v6mssdflt
+#define V_tcpstat tcpstat
+#define V_twq_2msl twq_2msl
+#define V_udb udb
+#define V_udbinfo udbinfo
+#define V_udp_blackhole udp_blackhole
+#define V_udp6_recvspace udp6_recvspace
+#define V_udp6_sendspace udp6_sendspace
+#define V_udpstat udpstat
+#define V_useloopback useloopback
+#define V_verbose_limit verbose_limit
+
+#endif /* !_SYS_VIMAGE_H_ */
OpenPOWER on IntegriCloud