aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/module.h
diff options
context:
space:
mode:
authorJonathan T. Looney <jtl@FreeBSD.org>2017-06-08 20:41:28 +0000
committerJonathan T. Looney <jtl@FreeBSD.org>2017-06-08 20:41:28 +0000
commitdc6a41b936668b4022d98d986f4db7dec8e94b90 (patch)
treebe74ecf011f53c4b9a56dc38093d3f0cdc4d00b7 /sys/sys/module.h
parentc2aa86d19c5b52ce2a7383a088ddda959c23db58 (diff)
downloadsrc-dc6a41b936668b4022d98d986f4db7dec8e94b90.tar.gz
src-dc6a41b936668b4022d98d986f4db7dec8e94b90.zip
Add the infrastructure to support loading multiple versions of TCP
stack modules. It adds support for mangling symbols exported by a module by prepending a string to them. (This avoids overlapping symbols in the kernel linker.) It allows the use of a macro as the module name in the DECLARE_MACRO() and MACRO_VERSION() macros. It allows the code to register stack aliases (e.g. both a generic name ["default"] and version-specific name ["default_10_3p1"]). With these changes, it is trivial to compile TCP stack modules with the name defined in the Makefile and to load multiple versions of the same stack simultaneously. This functionality can be used to enable side-by-side testing of an old and new version of the same TCP stack. It also could support upgrading the TCP stack without a reboot. Reviewed by: gnn, sjg (makefiles only) Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D11086
Notes
Notes: svn path=/head/; revision=319719
Diffstat (limited to 'sys/sys/module.h')
-rw-r--r--sys/sys/module.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/sys/module.h b/sys/sys/module.h
index 71aa9954b210..5a268fc11d7e 100644
--- a/sys/sys/module.h
+++ b/sys/sys/module.h
@@ -106,14 +106,15 @@ struct mod_pnp_match_info
#include <sys/linker_set.h>
+#define MODULE_METADATA_CONCAT(uniquifier) _mod_metadata##uniquifier
#define MODULE_METADATA(uniquifier, type, data, cval) \
- static struct mod_metadata _mod_metadata##uniquifier = { \
+ static struct mod_metadata MODULE_METADATA_CONCAT(uniquifier) = { \
MDT_STRUCT_VERSION, \
type, \
data, \
cval \
}; \
- DATA_SET(modmetadata_set, _mod_metadata##uniquifier)
+ DATA_SET(modmetadata_set, MODULE_METADATA_CONCAT(uniquifier))
#define MODULE_DEPEND(module, mdepend, vmin, vpref, vmax) \
static struct mod_depend _##module##_depend_on_##mdepend \
@@ -139,7 +140,7 @@ struct mod_pnp_match_info
#define DECLARE_MODULE_WITH_MAXVER(name, data, sub, order, maxver) \
MODULE_DEPEND(name, kernel, __FreeBSD_version, \
__FreeBSD_version, maxver); \
- MODULE_METADATA(_md_##name, MDT_MODULE, &data, #name); \
+ MODULE_METADATA(_md_##name, MDT_MODULE, &data, __XSTRING(name));\
SYSINIT(name##module, sub, order, module_register_init, &data); \
struct __hack
@@ -156,13 +157,14 @@ struct mod_pnp_match_info
#define DECLARE_MODULE_TIED(name, data, sub, order) \
DECLARE_MODULE_WITH_MAXVER(name, data, sub, order, __FreeBSD_version)
+#define MODULE_VERSION_CONCAT(module, version) _##module##_version
#define MODULE_VERSION(module, version) \
- static struct mod_version _##module##_version \
+ static struct mod_version MODULE_VERSION_CONCAT(module, version)\
__section(".data") = { \
version \
}; \
- MODULE_METADATA(_##module##_version, MDT_VERSION, \
- &_##module##_version, #module)
+ MODULE_METADATA(MODULE_VERSION_CONCAT(module, version), MDT_VERSION,\
+ &MODULE_VERSION_CONCAT(module, version), __XSTRING(module))
/**
* Generic macros to create pnp info hints that modules may export