summaryrefslogtreecommitdiffstats
path: root/sys/netinet/if_ether.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2009-07-14 22:48:30 +0000
committerrwatson <rwatson@FreeBSD.org>2009-07-14 22:48:30 +0000
commit57ca4583e728cab422fba8f15de10bd0b637b3dd (patch)
tree13848f891fb2f7a396281b31633563d0f764ff65 /sys/netinet/if_ether.c
parentef443476d9706035ac219f0280ef0b817dda7a6d (diff)
downloadFreeBSD-src-57ca4583e728cab422fba8f15de10bd0b637b3dd.zip
FreeBSD-src-57ca4583e728cab422fba8f15de10bd0b637b3dd.tar.gz
Build on Jeff Roberson's linker-set based dynamic per-CPU allocator
(DPCPU), as suggested by Peter Wemm, and implement a new per-virtual network stack memory allocator. Modify vnet to use the allocator instead of monolithic global container structures (vinet, ...). This change solves many binary compatibility problems associated with VIMAGE, and restores ELF symbols for virtualized global variables. Each virtualized global variable exists as a "reference copy", and also once per virtual network stack. Virtualized global variables are tagged at compile-time, placing the in a special linker set, which is loaded into a contiguous region of kernel memory. Virtualized global variables in the base kernel are linked as normal, but those in modules are copied and relocated to a reserved portion of the kernel's vnet region with the help of a the kernel linker. Virtualized global variables exist in per-vnet memory set up when the network stack instance is created, and are initialized statically from the reference copy. Run-time access occurs via an accessor macro, which converts from the current vnet and requested symbol to a per-vnet address. When "options VIMAGE" is not compiled into the kernel, normal global ELF symbols will be used instead and indirection is avoided. This change restores static initialization for network stack global variables, restores support for non-global symbols and types, eliminates the need for many subsystem constructors, eliminates large per-subsystem structures that caused many binary compatibility issues both for monitoring applications (netstat) and kernel modules, removes the per-function INIT_VNET_*() macros throughout the stack, eliminates the need for vnet_symmap ksym(2) munging, and eliminates duplicate definitions of virtualized globals under VIMAGE_GLOBALS. Bump __FreeBSD_version and update UPDATING. Portions submitted by: bz Reviewed by: bz, zec Discussed with: gnn, jamie, jeff, jhb, julian, sam Suggested by: peter Approved by: re (kensmith)
Diffstat (limited to 'sys/netinet/if_ether.c')
-rw-r--r--sys/netinet/if_ether.c70
1 files changed, 22 insertions, 48 deletions
diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c
index 97ea108..bf5f124 100644
--- a/sys/netinet/if_ether.c
+++ b/sys/netinet/if_ether.c
@@ -65,7 +65,6 @@ __FBSDID("$FreeBSD$");
#include <netinet/in_var.h>
#include <net/if_llatbl.h>
#include <netinet/if_ether.h>
-#include <netinet/vinet.h>
#include <net/if_arc.h>
#include <net/iso88025.h>
@@ -83,28 +82,33 @@ SYSCTL_DECL(_net_link_ether);
SYSCTL_NODE(_net_link_ether, PF_INET, inet, CTLFLAG_RW, 0, "");
/* timer values */
-#ifdef VIMAGE_GLOBALS
-static int arpt_keep; /* once resolved, good for 20 more minutes */
-static int arp_maxtries;
-int useloopback; /* use loopback interface for local traffic */
-static int arp_proxyall;
-#endif
-
-SYSCTL_V_INT(V_NET, vnet_inet, _net_link_ether_inet, OID_AUTO, max_age,
- CTLFLAG_RW, arpt_keep, 0, "ARP entry lifetime in seconds");
-
-SYSCTL_V_INT(V_NET, vnet_inet, _net_link_ether_inet, OID_AUTO, maxtries,
- CTLFLAG_RW, arp_maxtries, 0,
+static VNET_DEFINE(int, arpt_keep) = (20*60); /* once resolved, good for 20
+ * minutes */
+static VNET_DEFINE(int, arp_maxtries) = 5;
+static VNET_DEFINE(int, useloopback) = 1; /* use loopback interface for
+ * local traffic */
+static VNET_DEFINE(int, arp_proxyall);
+
+#define V_arpt_keep VNET_GET(arpt_keep)
+#define V_arp_maxtries VNET_GET(arp_maxtries)
+#define V_useloopback VNET_GET(useloopback)
+#define V_arp_proxyall VNET_GET(arp_proxyall)
+
+SYSCTL_VNET_INT(_net_link_ether_inet, OID_AUTO, max_age, CTLFLAG_RW,
+ &VNET_NAME(arpt_keep), 0,
+ "ARP entry lifetime in seconds");
+
+SYSCTL_VNET_INT(_net_link_ether_inet, OID_AUTO, maxtries, CTLFLAG_RW,
+ &VNET_NAME(arp_maxtries), 0,
"ARP resolution attempts before returning error");
-SYSCTL_V_INT(V_NET, vnet_inet, _net_link_ether_inet, OID_AUTO, useloopback,
- CTLFLAG_RW, useloopback, 0,
+SYSCTL_VNET_INT(_net_link_ether_inet, OID_AUTO, useloopback, CTLFLAG_RW,
+ &VNET_NAME(useloopback), 0,
"Use the loopback interface for local traffic");
-SYSCTL_V_INT(V_NET, vnet_inet, _net_link_ether_inet, OID_AUTO, proxyall,
- CTLFLAG_RW, arp_proxyall, 0,
+SYSCTL_VNET_INT(_net_link_ether_inet, OID_AUTO, proxyall, CTLFLAG_RW,
+ &VNET_NAME(arp_proxyall), 0,
"Enable proxy ARP for all suitable requests");
static void arp_init(void);
-static int arp_iattach(const void *);
void arprequest(struct ifnet *,
struct in_addr *, struct in_addr *, u_char *);
static void arpintr(struct mbuf *);
@@ -120,15 +124,6 @@ static const struct netisr_handler arp_nh = {
.nh_policy = NETISR_POLICY_SOURCE,
};
-#ifndef VIMAGE_GLOBALS
-static const vnet_modinfo_t vnet_arp_modinfo = {
- .vmi_id = VNET_MOD_ARP,
- .vmi_name = "arp",
- .vmi_dependson = VNET_MOD_INET,
- .vmi_iattach = arp_iattach
-};
-#endif /* !VIMAGE_GLOBALS */
-
#ifdef AF_INET
void arp_ifscrub(struct ifnet *ifp, uint32_t addr);
@@ -263,7 +258,6 @@ int
arpresolve(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m,
struct sockaddr *dst, u_char *desten, struct llentry **lle)
{
- INIT_VNET_INET(ifp->if_vnet);
struct llentry *la = 0;
u_int flags = 0;
int error, renew;
@@ -482,7 +476,6 @@ in_arpinput(struct mbuf *m)
sin.sin_len = sizeof(struct sockaddr_in);
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = 0;
- INIT_VNET_INET(ifp->if_vnet);
if (ifp->if_bridge)
bridged = 1;
@@ -825,29 +818,10 @@ arp_ifinit2(struct ifnet *ifp, struct ifaddr *ifa, u_char *enaddr)
ifa->ifa_rtrequest = NULL;
}
-static int
-arp_iattach(const void *unused __unused)
-{
- INIT_VNET_INET(curvnet);
-
- V_arpt_keep = (20*60); /* once resolved, good for 20 more minutes */
- V_arp_maxtries = 5;
- V_useloopback = 1; /* use loopback interface for local traffic */
- V_arp_proxyall = 0;
-
- return (0);
-}
-
static void
arp_init(void)
{
-#ifndef VIMAGE_GLOBALS
- vnet_mod_register(&vnet_arp_modinfo);
-#else
- arp_iattach(NULL);
-#endif
-
netisr_register(&arp_nh);
}
SYSINIT(arp, SI_SUB_PROTO_DOMAIN, SI_ORDER_ANY, arp_init, 0);
OpenPOWER on IntegriCloud