PERFORCE change 154661 for review
Marko Zec
zec at FreeBSD.org
Sun Dec 14 13:07:04 PST 2008
http://perforce.freebsd.org/chv.cgi?CH=154661
Change 154661 by zec at zec_tca51 on 2008/12/14 21:06:10
Unbreak GENERIC / LINT / VIMAGE_GLOBALS and VIMAGE builds.
Affected files ...
.. //depot/projects/vimage/src/sys/kern/kern_vimage.c#72 edit
.. //depot/projects/vimage/src/sys/kern/uipc_domain.c#16 edit
.. //depot/projects/vimage/src/sys/netinet/accf_http.c#6 edit
.. //depot/projects/vimage/src/sys/netinet/in_rmx.c#27 edit
.. //depot/projects/vimage/src/sys/netinet/ip_fw.h#24 edit
.. //depot/projects/vimage/src/sys/netinet/ip_fw2.c#61 edit
.. //depot/projects/vimage/src/sys/netinet/ip_var.h#16 edit
.. //depot/projects/vimage/src/sys/sys/vimage.h#75 edit
Differences ...
==== //depot/projects/vimage/src/sys/kern/kern_vimage.c#72 (text+ko) ====
@@ -62,6 +62,8 @@
#include <net/ethernet.h>
#include <net/vnet.h>
+struct vnet_modlink;
+
//#define DEBUG_ORDERING
MALLOC_DEFINE(M_VIMAGE, "vimage", "virtual image resource container");
@@ -69,12 +71,19 @@
MALLOC_DEFINE(M_VPROCG, "vprocg", "process group control block");
MALLOC_DEFINE(M_VCPU, "vcpu", "cpu resource control block");
+#ifdef VIMAGE
static struct vimage *vi_alloc(struct vimage *, char *);
static int vi_destroy(struct vimage *);
-static void vnet_mod_complete_registration(struct vnet_modlink *);
static int vnet_mod_constructor(struct vnet_modlink *);
static int vnet_mod_destructor(struct vnet_modlink *);
+#endif
+#ifndef VIMAGE
+#ifndef VIMAGE_GLOBALS
+struct vprocg vprocg_0;
+#endif
+#endif
+
#ifdef VI_PREALLOC_SIZE
/*
* A private memory allocator can be enabled by setting VI_PREALLOC_SIZE
@@ -112,33 +121,40 @@
#define vi_free(addr, type) free((addr), (type))
#endif /* VI_PREALLOC_SIZE */
-struct vimage_list_head vimage_head;
-struct vnet_list_head vnet_head;
-struct vprocg_list_head vprocg_head;
-struct vcpu_list_head vcpu_head;
+#ifndef VIMAGE_GLOBALS
+static TAILQ_HEAD(vnet_modlink_head, vnet_modlink) vnet_modlink_head;
+static TAILQ_HEAD(vnet_modpending_head, vnet_modlink) vnet_modpending_head;
+static void vnet_mod_complete_registration(struct vnet_modlink *);
-struct cv vnet_list_condvar;
-struct mtx vnet_list_refc_mtx;
-int vnet_list_refc = 0;
+int
+vi_symlookup(struct kld_sym_lookup *lookup, char *symstr)
+{
+ struct vnet_modlink *vml;
+ struct vnet_symmap *mapentry;
-struct mtx vcpu_list_mtx;
+ TAILQ_FOREACH(vml, &vnet_modlink_head, vml_mod_le) {
-#define VNET_LIST_LOCK() \
- mtx_lock(&vnet_list_refc_mtx); \
- while (vnet_list_refc != 0) \
- cv_wait(&vnet_list_condvar, &vnet_list_refc_mtx);
+ if (vml->vml_modinfo->vmi_symmap == NULL)
+ continue;
-#define VNET_LIST_UNLOCK() \
- mtx_unlock(&vnet_list_refc_mtx);
-
-static u_int last_vi_id = 0;
-static u_int last_vnet_id = 0;
-static u_int last_vprocg_id = 0;
-static u_int last_vcpu_id = 0;
+ for (mapentry = vml->vml_modinfo->vmi_symmap;
+ mapentry->name != NULL; mapentry++) {
+ if (strcmp(symstr, mapentry->name) == 0) {
+#ifdef VIMAGE
+ lookup->symvalue =
+ (u_long) curvnet->mod_data[vml->vml_modinfo->vmi_id];
+ lookup->symvalue += mapentry->offset;
+#else
+ lookup->symvalue = (u_long) mapentry->offset;
+#endif
+ lookup->symsize = mapentry->size;
+ return (0);
+ }
+ }
+ }
+ return (ENOENT);
+}
-static TAILQ_HEAD(vnet_modlink_head, vnet_modlink) vnet_modlink_head;
-static TAILQ_HEAD(vnet_modpending_head, vnet_modlink) vnet_modpending_head;
-
void
vnet_mod_register(const struct vnet_modinfo *vmi)
{
@@ -200,11 +216,13 @@
TAILQ_INSERT_TAIL(&vnet_modlink_head, vml, vml_mod_le);
+#ifdef VIMAGE
VNET_FOREACH(vnet_iter) {
CURVNET_SET_QUIET(vnet_iter);
vnet_mod_constructor(vml);
CURVNET_RESTORE();
}
+#endif
/* Check for pending modules depending on us */
do {
@@ -225,7 +243,33 @@
}
} while (vml_iter != NULL);
}
+#endif /* !VIMAGE_GLOBALS */
+
+#ifdef VIMAGE
+struct vimage_list_head vimage_head;
+struct vnet_list_head vnet_head;
+struct vprocg_list_head vprocg_head;
+struct vcpu_list_head vcpu_head;
+
+struct cv vnet_list_condvar;
+struct mtx vnet_list_refc_mtx;
+int vnet_list_refc = 0;
+
+struct mtx vcpu_list_mtx;
+
+#define VNET_LIST_LOCK() \
+ mtx_lock(&vnet_list_refc_mtx); \
+ while (vnet_list_refc != 0) \
+ cv_wait(&vnet_list_condvar, &vnet_list_refc_mtx);
+#define VNET_LIST_UNLOCK() \
+ mtx_unlock(&vnet_list_refc_mtx);
+
+static u_int last_vi_id = 0;
+static u_int last_vnet_id = 0;
+static u_int last_vprocg_id = 0;
+static u_int last_vcpu_id = 0;
+
void
vnet_mod_deregister(const struct vnet_modinfo *vmi)
{
@@ -609,32 +653,6 @@
}
-int
-vi_symlookup(struct kld_sym_lookup *lookup, char *symstr)
-{
- struct vnet_modlink *vml;
- struct vnet_symmap *mapentry;
-
- TAILQ_FOREACH(vml, &vnet_modlink_head, vml_mod_le) {
-
- if (vml->vml_modinfo->vmi_symmap == NULL)
- continue;
-
- for (mapentry = vml->vml_modinfo->vmi_symmap;
- mapentry->name != NULL; mapentry++) {
- if (strcmp(symstr, mapentry->name) == 0) {
- lookup->symvalue =
- (u_long) curvnet->mod_data[vml->vml_modinfo->vmi_id];
- lookup->symvalue += mapentry->offset;
- lookup->symsize = mapentry->size;
- return (0);
- }
- }
- }
- return (ENOENT);
-}
-
-
struct vimage *
vi_alloc(struct vimage *parent, char *name)
{
@@ -1005,3 +1023,5 @@
}
}
#endif
+
+#endif /* VIMAGE */
==== //depot/projects/vimage/src/sys/kern/uipc_domain.c#16 (text+ko) ====
==== //depot/projects/vimage/src/sys/netinet/accf_http.c#6 (text+ko) ====
@@ -78,6 +78,12 @@
int _parse_http_version;
};
+#ifndef VIMAGE
+#ifndef VIMAGE_GLOBALS
+struct vnet_accf_http vnet_accf_http_0;
+#endif
+#endif
+
#define INIT_VNET_ACCF_HTTP(vnet) \
INIT_FROM_VNET(vnet, VNET_MOD_ACCF_HTTP, struct vnet_accf_http, vnet_accf_http)
==== //depot/projects/vimage/src/sys/netinet/in_rmx.c#27 (text+ko) ====
==== //depot/projects/vimage/src/sys/netinet/ip_fw.h#24 (text+ko) ====
@@ -736,7 +736,6 @@
u_int64_t _norule_counter;
struct callout _ipfw_timeout;
eventhandler_tag _ifaddr_event_tag;
- struct ip_fw_ugid _fw_ugid_cache;
};
#ifndef VIMAGE
@@ -782,7 +781,6 @@
#define V_ipfw_timeout VNET_IPFW(ipfw_timeout)
#define V_ipfw_timeout VNET_IPFW(ipfw_timeout)
#define V_ifaddr_event_tag VNET_IPFW(ifaddr_event_tag)
-#define V_fw_ugid_cache VNET_IPFW(fw_ugid_cache)
#endif /* _KERNEL */
#endif /* _IPFW2_H */
==== //depot/projects/vimage/src/sys/netinet/ip_fw2.c#61 (text+ko) ====
@@ -289,15 +289,15 @@
SYSCTL_V_INT(V_NET, vnet_ipfw, _net_inet_ip_fw, OID_AUTO, dyn_keepalive,
CTLFLAG_RW, dyn_keepalive, 0, "Enable keepalives for dyn. rules");
-#ifndef VIMAGE
-static int fw_deny_unknown_exthdrs;
-#endif
-
#ifdef INET6
/*
* IPv6 specific variables
*/
+#ifdef VIMAGE_GLOBALS
+static int fw_deny_unknown_exthdrs;
+#endif
+
SYSCTL_DECL(_net_inet6_ip6);
SYSCTL_NODE(_net_inet6_ip6, OID_AUTO, fw, CTLFLAG_RW | CTLFLAG_SECURE,
0, "Firewall");
@@ -311,10 +311,6 @@
#endif /* INET6 */
#endif /* SYSCTL_NODE */
-#ifdef VIMAGE_GLOBALS
-static int fw_deny_unknown_exthdrs;
-#endif
-
/*
* L3HDR maps an ipv4 pointer into a layer3 header pointer of type T
* Other macros just cast void * into the appropriate type
@@ -2161,9 +2157,7 @@
* these types of constraints, as well as decrease contention
* on pcb related locks.
*/
-#ifndef VIMAGE
- struct ip_fw_ugid fw_ugid_cache; /* XXX Marko revisit this */
-#endif
+ struct ip_fw_ugid fw_ugid_cache;
int ugid_lookup = 0;
/*
@@ -2623,7 +2617,7 @@
proto, oif,
dst_ip, dst_port,
src_ip, src_port,
- &V_fw_ugid_cache,
+ &fw_ugid_cache,
&ugid_lookup, args->inp);
break;
==== //depot/projects/vimage/src/sys/netinet/ip_var.h#16 (text+ko) ====
@@ -181,7 +181,6 @@
extern int ip_do_randomid;
extern int ip_defttl; /* default IP ttl */
extern int ipforwarding; /* ip forwarding */
-extern int ip_do_randomid;
#ifdef IPSTEALTH
extern int ipstealth; /* stealth forwarding */
#endif
==== //depot/projects/vimage/src/sys/sys/vimage.h#75 (text+ko) ====
@@ -50,7 +50,6 @@
struct vprocg;
struct vnet;
struct vi_req;
-struct vnet_modinfo;
struct kld_sym_lookup;
struct ifnet; /* XXX must go away */
@@ -66,16 +65,88 @@
#endif
#ifdef VIMAGE
+#define curvnet curthread->td_vnet
+#else
+#define curvnet NULL
+#endif
-#define curvnet curthread->td_vnet
+#define VNET_SYMMAP(mod, name) \
+ { #name, offsetof(struct vnet_##mod, _##name), \
+ sizeof(((struct vnet_##mod *) curthread)->_##name) }
-#define basevnet thread0.td_ucred->cr_vimage->v_net
-#define basevprocg thread0.td_ucred->cr_vimage->v_procg
-#define basevcpu thread0.td_ucred->cr_vimage->v_cpu
+#ifdef VIMAGE
+#define VNET_MOD_DECLARE(m_name_uc, m_name_lc, m_iattach, m_idetach, \
+ m_dependson, m_symmap) \
+ static const struct vnet_modinfo vnet_##m_name_lc##_modinfo = { \
+ .vmi_id = VNET_MOD_##m_name_uc, \
+ .vmi_dependson = VNET_MOD_##m_dependson, \
+ .vmi_name = #m_name_lc, \
+ .vmi_iattach = m_iattach, \
+ .vmi_idetach = m_idetach, \
+ .vmi_struct_size = \
+ sizeof(struct vnet_##m_name_lc), \
+ .vmi_symmap = m_symmap \
+};
+#define VNET_MOD_DECLARE_STATELESS(m_name_uc, m_name_lc, m_iattach, m_idetach, \
+ m_dependson) \
+ static const struct vnet_modinfo vnet_##m_name_lc##_modinfo = { \
+ .vmi_id = VNET_MOD_##m_name_uc, \
+ .vmi_dependson = VNET_MOD_##m_dependson, \
+ .vmi_name = #m_name_lc, \
+ .vmi_iattach = m_iattach, \
+ .vmi_idetach = m_idetach \
+};
+#else
+#ifdef VIMAGE_GLOBALS
+#define VNET_MOD_DECLARE(m_name_uc, m_name_lc, m_iattach, m_idetach, \
+ m_dependson, m_symmap)
+#define VNET_MOD_DECLARE_STATELESS(m_name_uc, m_name_lc, m_iattach, m_idetach, \
+ m_dependson)
+#else
+#define VNET_MOD_DECLARE(m_name_uc, m_name_lc, m_iattach, m_idetach, \
+ m_dependson, m_symmap) \
+ static const struct vnet_modinfo vnet_##m_name_lc##_modinfo = { \
+ .vmi_symmap = m_symmap \
+};
+#define VNET_MOD_DECLARE_STATELESS(m_name_uc, m_name_lc, m_iattach, m_idetach, \
+ m_dependson)
+#endif
+#endif
typedef int vnet_attach_fn(const void *);
typedef int vnet_detach_fn(const void *);
+#ifndef VIMAGE_GLOBALS
+
+struct vnet_symmap {
+ char *name;
+ size_t offset;
+ size_t size;
+};
+
+struct vnet_modinfo {
+ u_int vmi_id;
+ u_int vmi_dependson;
+ char *vmi_name;
+ vnet_attach_fn *vmi_iattach;
+ vnet_detach_fn *vmi_idetach;
+ size_t vmi_struct_size;
+ struct vnet_symmap *vmi_symmap;
+};
+
+struct vnet_modlink {
+ TAILQ_ENTRY(vnet_modlink) vml_mod_le;
+ const struct vnet_modinfo *vml_modinfo;
+ const void *vml_iarg;
+ const char *vml_iname;
+};
+#endif
+
+#define VNET_SYMMAP_END { NULL, 0 }
+
+#define basevnet thread0.td_ucred->cr_vimage->v_net
+#define basevprocg thread0.td_ucred->cr_vimage->v_procg
+#define basevcpu thread0.td_ucred->cr_vimage->v_cpu
#define V_GLOBAL 0
#define V_NET 1
@@ -125,6 +196,8 @@
#define V_MOD_vprocg 0
#define V_MOD_vcpu 0
+#ifdef VIMAGE
+
struct vnet {
void *mod_data[VNET_MOD_MAX];
@@ -138,59 +211,6 @@
u_int vnet_magic_n;
};
-struct vnet_symmap {
- char *name;
- size_t offset;
- size_t size;
-};
-
-struct vnet_modinfo {
- u_int vmi_id;
- u_int vmi_dependson;
- char *vmi_name;
- vnet_attach_fn *vmi_iattach;
- vnet_detach_fn *vmi_idetach;
- size_t vmi_struct_size;
- struct vnet_symmap *vmi_symmap;
-};
-
-struct vnet_modlink {
- TAILQ_ENTRY(vnet_modlink) vml_mod_le;
- const struct vnet_modinfo *vml_modinfo;
- const void *vml_iarg;
- const char *vml_iname;
-};
-
-#define VNET_MOD_DECLARE(m_name_uc, m_name_lc, m_iattach, m_idetach, \
- m_dependson, m_symmap) \
- static const struct vnet_modinfo vnet_##m_name_lc##_modinfo = { \
- .vmi_id = VNET_MOD_##m_name_uc, \
- .vmi_dependson = VNET_MOD_##m_dependson, \
- .vmi_name = #m_name_lc, \
- .vmi_iattach = m_iattach, \
- .vmi_idetach = m_idetach, \
- .vmi_struct_size = \
- sizeof(struct vnet_##m_name_lc), \
- .vmi_symmap = m_symmap \
-};
-
-#define VNET_MOD_DECLARE_STATELESS(m_name_uc, m_name_lc, m_iattach, m_idetach, \
- m_dependson) \
- static const struct vnet_modinfo vnet_##m_name_lc##_modinfo = { \
- .vmi_id = VNET_MOD_##m_name_uc, \
- .vmi_dependson = VNET_MOD_##m_dependson, \
- .vmi_name = #m_name_lc, \
- .vmi_iattach = m_iattach, \
- .vmi_idetach = m_idetach \
-};
-
-#define VNET_SYMMAP(mod, name) \
- { #name, offsetof(struct vnet_##mod, _##name), \
- sizeof(((struct vnet_##mod *) curthread)->_##name) }
-
-#define VNET_SYMMAP_END \
- { NULL, 0 }
-
#define VNET_MAGIC_N 0x3e0d8f29
@@ -276,13 +296,7 @@
#else /* !VIMAGE */
-#define VNET_SYMMAP_END { NULL, 0 }
-
/* Non-VIMAGE null-macros */
-#define VNET_MOD_DECLARE(m_name_uc, m_name_lc, m_iattach, m_idetach, \
- m_dependson, m_symmap)
-#define VNET_MOD_DECLARE_STATELESS(m_name_uc, m_name_lc, m_iattach, m_idetach, \
- m_dependson)
#define CURVNET_SET(arg)
#define CURVNET_SET_QUIET(arg)
#define CURVNET_RESTORE()
More information about the p4-projects
mailing list