Add extern to *_main global variable declarations in header files.
- Global variables declared in header files without
the use of the 'extern' keword will result in multiple
instances of the variable to be created by the compiler
-- one for each different source file in which the
the header file is included. This results in wasted
memory allocated in the BSS segments as well as
potentially introducing bugs in the application.
Change-Id: I6ef1790b60a0bd9dd3994f8510723decf258b0cc
Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
diff --git a/src/plugins/dpdk/device/dpdk.h b/src/plugins/dpdk/device/dpdk.h
index 9762c71..a0c57ea 100644
--- a/src/plugins/dpdk/device/dpdk.h
+++ b/src/plugins/dpdk/device/dpdk.h
@@ -332,7 +332,7 @@
} dpdk_config_main_t;
-dpdk_config_main_t dpdk_config_main;
+extern dpdk_config_main_t dpdk_config_main;
typedef struct
{
diff --git a/src/plugins/dpdk/device/init.c b/src/plugins/dpdk/device/init.c
index e94d2fa..9e7bb75 100755
--- a/src/plugins/dpdk/device/init.c
+++ b/src/plugins/dpdk/device/init.c
@@ -37,6 +37,7 @@
#include <dpdk/device/dpdk_priv.h>
dpdk_main_t dpdk_main;
+dpdk_config_main_t dpdk_config_main;
#define LINK_STATE_ELOGS 0
diff --git a/src/plugins/dpdk/ipsec/ipsec.c b/src/plugins/dpdk/ipsec/ipsec.c
index 4bae8c1..6aa5fae 100644
--- a/src/plugins/dpdk/ipsec/ipsec.c
+++ b/src/plugins/dpdk/ipsec/ipsec.c
@@ -21,6 +21,8 @@
#include <dpdk/device/dpdk.h>
#include <dpdk/ipsec/ipsec.h>
+dpdk_crypto_main_t dpdk_crypto_main;
+
#define EMPTY_STRUCT {0}
static void
diff --git a/src/plugins/dpdk/ipsec/ipsec.h b/src/plugins/dpdk/ipsec/ipsec.h
index 98e5ad5..2289062 100644
--- a/src/plugins/dpdk/ipsec/ipsec.h
+++ b/src/plugins/dpdk/ipsec/ipsec.h
@@ -144,7 +144,7 @@
u8 enabled;
} dpdk_crypto_main_t;
-dpdk_crypto_main_t dpdk_crypto_main;
+extern dpdk_crypto_main_t dpdk_crypto_main;
static const u8 pad_data[] =
{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0 };
diff --git a/src/plugins/gtpu/gtpu.h b/src/plugins/gtpu/gtpu.h
index 744d21d..b1e677d 100644
--- a/src/plugins/gtpu/gtpu.h
+++ b/src/plugins/gtpu/gtpu.h
@@ -228,7 +228,7 @@
vnet_main_t *vnet_main;
} gtpu_main_t;
-gtpu_main_t gtpu_main;
+extern gtpu_main_t gtpu_main;
extern vlib_node_registration_t gtpu4_input_node;
extern vlib_node_registration_t gtpu6_input_node;
diff --git a/src/plugins/ioam/ip6/ioam_cache.c b/src/plugins/ioam/ip6/ioam_cache.c
index 4e147da..627f8b6 100644
--- a/src/plugins/ioam/ip6/ioam_cache.c
+++ b/src/plugins/ioam/ip6/ioam_cache.c
@@ -55,6 +55,8 @@
#define REPLY_MSG_ID_BASE cm->msg_id_base
#include <vlibapi/api_helper_macros.h>
+ioam_cache_main_t ioam_cache_main;
+
/* List of message types that this plugin understands */
#define foreach_ioam_cache_plugin_api_msg \
_(IOAM_CACHE_IP6_ENABLE_DISABLE, ioam_cache_ip6_enable_disable)
diff --git a/src/plugins/ioam/ip6/ioam_cache.h b/src/plugins/ioam/ip6/ioam_cache.h
index 25a8fb6..338ed98 100644
--- a/src/plugins/ioam/ip6/ioam_cache.h
+++ b/src/plugins/ioam/ip6/ioam_cache.h
@@ -203,7 +203,7 @@
u32 cleanup_process_node_index;
} ioam_cache_main_t;
-ioam_cache_main_t ioam_cache_main;
+extern ioam_cache_main_t ioam_cache_main;
extern vlib_node_registration_t ioam_cache_node;
extern vlib_node_registration_t ioam_cache_ts_node;
diff --git a/src/plugins/ixge/ixge.h b/src/plugins/ixge/ixge.h
index 42c1bfa..a87af1a 100644
--- a/src/plugins/ixge/ixge.h
+++ b/src/plugins/ixge/ixge.h
@@ -1270,8 +1270,8 @@
vlib_physmem_region_index_t physmem_region;
} ixge_main_t;
-ixge_main_t ixge_main;
-vnet_device_class_t ixge_device_class;
+extern ixge_main_t ixge_main;
+extern vnet_device_class_t ixge_device_class;
typedef enum
{
diff --git a/src/plugins/sixrd/sixrd.c b/src/plugins/sixrd/sixrd.c
index 9838752..ee198f2 100644
--- a/src/plugins/sixrd/sixrd.c
+++ b/src/plugins/sixrd/sixrd.c
@@ -32,6 +32,8 @@
* ea_bits_len = 0
*/
+sixrd_main_t sixrd_main;
+
int
sixrd_create_domain (ip6_address_t *ip6_prefix,
u8 ip6_prefix_len,
diff --git a/src/plugins/sixrd/sixrd.h b/src/plugins/sixrd/sixrd.h
index 56714c9..f911461 100644
--- a/src/plugins/sixrd/sixrd.h
+++ b/src/plugins/sixrd/sixrd.h
@@ -79,7 +79,7 @@
u32 sixrd_domain_index;
} sixrd_trace_t;
-sixrd_main_t sixrd_main;
+extern sixrd_main_t sixrd_main;
/*
* sixrd_get_addr