summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
e150238)
The acl_main struct, which is defined in the acl_plugin, is not visible when
the ACL plugin inline code is being compiled within the context of other plugins.
Fix that by using the global pointer variable, which exists in both the ACL plugin
context and is set in the context of the external plugins using ACL plugin.
Change-Id: Iaa74dd8cf36ff5442a06a25c5c968722116bddf8
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
(cherry picked from commit
1286a15a6e60f80b0e1b349f876de8fa38c71368)
#include "public_inlines.h"
acl_main_t acl_main;
#include "public_inlines.h"
acl_main_t acl_main;
+acl_main_t *p_acl_main = &acl_main;
#define REPLY_MSG_ID_BASE am->msg_id_base
#include <vlibapi/api_helper_macros.h>
#define REPLY_MSG_ID_BASE am->msg_id_base
#include <vlibapi/api_helper_macros.h>
extern acl_main_t acl_main;
extern acl_main_t acl_main;
+/*
+ * pointer to the above.
+ * Needed for some gymnastics to be able to provide
+ * the inline functions from this plugin to other plugins.
+ */
+
+extern acl_main_t *p_acl_main;
void *acl_plugin_set_heap();
void *acl_plugin_set_heap();
/* check if a given ACL exists */
#ifdef ACL_PLUGIN_EXTERNAL_EXPORTS
/* check if a given ACL exists */
#ifdef ACL_PLUGIN_EXTERNAL_EXPORTS
+
+/*
+ * Define a pointer to the acl_main which will be filled during the initialization.
+ */
+acl_main_t *p_acl_main = 0;
+
+/*
+ * If the file is included more than once, the symbol collision will make the problem obvious.
+ * If the include is done only once, it is just a lonely null var
+ * sitting around.
+ */
+void *ERROR_ACL_PLUGIN_EXPORTS_FILE_MUST_BE_INCLUDED_ONLY_IN_ONE_PLACE = 0;
+
u8 (*acl_plugin_acl_exists) (u32 acl_index);
#else
u8 acl_plugin_acl_exists (u32 acl_index);
u8 (*acl_plugin_acl_exists) (u32 acl_index);
#else
u8 acl_plugin_acl_exists (u32 acl_index);
#ifdef ACL_PLUGIN_EXTERNAL_EXPORTS
#ifdef ACL_PLUGIN_EXTERNAL_EXPORTS
-#define LOAD_SYMBOL_FROM_PLUGIN(p, s) \
+#define LOAD_SYMBOL_FROM_PLUGIN_TO(p, s, st) \
- s = vlib_get_plugin_symbol(p, #s); \
- if (!s) \
+ st = vlib_get_plugin_symbol(p, #s); \
+ if (!st) \
return clib_error_return(0, \
"Plugin %s and/or symbol %s not found.", p, #s); \
})
return clib_error_return(0, \
"Plugin %s and/or symbol %s not found.", p, #s); \
})
-#define LOAD_SYMBOL(s) LOAD_SYMBOL_FROM_PLUGIN("acl_plugin.so", s)
+#define LOAD_SYMBOL(s) LOAD_SYMBOL_FROM_PLUGIN_TO("acl_plugin.so", s, s)
static inline clib_error_t * acl_plugin_exports_init (void)
{
static inline clib_error_t * acl_plugin_exports_init (void)
{
+ LOAD_SYMBOL_FROM_PLUGIN_TO("acl_plugin.so", acl_main, p_acl_main);
LOAD_SYMBOL(acl_plugin_acl_exists);
LOAD_SYMBOL(acl_plugin_register_user_module);
LOAD_SYMBOL(acl_plugin_get_lookup_context_index);
LOAD_SYMBOL(acl_plugin_acl_exists);
LOAD_SYMBOL(acl_plugin_register_user_module);
LOAD_SYMBOL(acl_plugin_get_lookup_context_index);
acl_plugin_fill_5tuple_inline (u32 lc_index, vlib_buffer_t * b0, int is_ip6,
int is_input, int is_l2_path, fa_5tuple_opaque_t * p5tuple_pkt)
{
acl_plugin_fill_5tuple_inline (u32 lc_index, vlib_buffer_t * b0, int is_ip6,
int is_input, int is_l2_path, fa_5tuple_opaque_t * p5tuple_pkt)
{
- acl_main_t *am = &acl_main;
+ acl_main_t *am = p_acl_main;
acl_fill_5tuple(am, b0, is_ip6, is_input, is_l2_path, (fa_5tuple_t *)p5tuple_pkt);
}
acl_fill_5tuple(am, b0, is_ip6, is_input, is_l2_path, (fa_5tuple_t *)p5tuple_pkt);
}
int is_ip6, u8 * r_action, u32 * r_acl_match_p,
u32 * r_rule_match_p, u32 * trace_bitmap)
{
int is_ip6, u8 * r_action, u32 * r_acl_match_p,
u32 * r_rule_match_p, u32 * trace_bitmap)
{
- acl_main_t * am = &acl_main;
+ acl_main_t * am = p_acl_main;
return single_acl_match_5tuple(am, acl_index, pkt_5tuple, is_ip6, r_action,
r_acl_match_p, r_rule_match_p, trace_bitmap);
}
return single_acl_match_5tuple(am, acl_index, pkt_5tuple, is_ip6, r_action,
r_acl_match_p, r_rule_match_p, trace_bitmap);
}
int is_ip6, u8 *r_action, u32 *acl_pos_p, u32 * acl_match_p,
u32 * rule_match_p, u32 * trace_bitmap)
{
int is_ip6, u8 *r_action, u32 *acl_pos_p, u32 * acl_match_p,
u32 * rule_match_p, u32 * trace_bitmap)
{
- acl_main_t *am = &acl_main;
+ acl_main_t *am = p_acl_main;
int i;
u32 *acl_vector;
u8 action = 0;
int i;
u32 *acl_vector;
u8 action = 0;
int is_ip6, u8 *action, u32 *acl_pos_p, u32 * acl_match_p,
u32 * rule_match_p, u32 * trace_bitmap)
{
int is_ip6, u8 *action, u32 *acl_pos_p, u32 * acl_match_p,
u32 * rule_match_p, u32 * trace_bitmap)
{
- acl_main_t *am = &acl_main;
+ acl_main_t *am = p_acl_main;
applied_hash_ace_entry_t **applied_hash_aces = vec_elt_at_index(am->hash_entry_vec_by_lc_index, lc_index);
u32 match_index = multi_acl_match_get_applied_ace_index(am, pkt_5tuple);
if (match_index < vec_len((*applied_hash_aces))) {
applied_hash_ace_entry_t **applied_hash_aces = vec_elt_at_index(am->hash_entry_vec_by_lc_index, lc_index);
u32 match_index = multi_acl_match_get_applied_ace_index(am, pkt_5tuple);
if (match_index < vec_len((*applied_hash_aces))) {
u32 * r_rule_match_p,
u32 * trace_bitmap)
{
u32 * r_rule_match_p,
u32 * trace_bitmap)
{
- acl_main_t *am = &acl_main;
+ acl_main_t *am = p_acl_main;
if (am->use_hash_acl_matching) {
return hash_multi_acl_match_5tuple(lc_index, (fa_5tuple_t *)pkt_5tuple, is_ip6, r_action,
r_acl_pos_p, r_acl_match_p, r_rule_match_p, trace_bitmap);
if (am->use_hash_acl_matching) {
return hash_multi_acl_match_5tuple(lc_index, (fa_5tuple_t *)pkt_5tuple, is_ip6, r_action,
r_acl_pos_p, r_acl_match_p, r_rule_match_p, trace_bitmap);