aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2017-02-20 09:14:13 +0100
committerDamjan Marion <dmarion.lists@gmail.com>2017-02-22 15:59:48 +0000
commit2291a36008e197423a0f0414f6dcca4afa3ac4c1 (patch)
treef52ef2fc21c0a5b719e38bd67f25cde268bd6e47
parent2dd6852d8109e39d15a5c60f7ba58f1abcf9e455 (diff)
jvpp: remove unnecessary msg_id_base caching
Jvpp code uses CRCs to obtain msg IDs. Checking api_main_t.msg_index_by_name_and_crc is enough to detect API mismatch. Calling vl_client_get_first_plugin_msg_id is not needed. Also fixes VPP-627. Change-Id: Ie3085dfa458795fa11f17615ac94e76197a1c8cd Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
-rw-r--r--src/vpp-api/java/jvpp-acl/jvpp_acl.c50
-rw-r--r--src/vpp-api/java/jvpp-acl/jvpp_acl.h3
-rw-r--r--src/vpp-api/java/jvpp-core/jvpp_core.c3
-rw-r--r--src/vpp-api/java/jvpp-ioamexport/jvpp_ioam_export.c50
-rw-r--r--src/vpp-api/java/jvpp-ioamexport/jvpp_ioam_export.h3
-rw-r--r--src/vpp-api/java/jvpp-ioampot/jvpp_ioam_pot.c50
-rw-r--r--src/vpp-api/java/jvpp-ioampot/jvpp_ioam_pot.h3
-rw-r--r--src/vpp-api/java/jvpp-ioamtrace/jvpp_ioam_trace.c50
-rw-r--r--src/vpp-api/java/jvpp-ioamtrace/jvpp_ioam_trace.h3
-rw-r--r--src/vpp-api/java/jvpp-snat/jvpp_snat.c50
-rw-r--r--src/vpp-api/java/jvpp-snat/jvpp_snat.h3
11 files changed, 90 insertions, 178 deletions
diff --git a/src/vpp-api/java/jvpp-acl/jvpp_acl.c b/src/vpp-api/java/jvpp-acl/jvpp_acl.c
index 9150ce6b..b59f5358 100644
--- a/src/vpp-api/java/jvpp-acl/jvpp_acl.c
+++ b/src/vpp-api/java/jvpp-acl/jvpp_acl.c
@@ -29,11 +29,6 @@
#include <acl/acl_all_api_h.h>
#undef vl_printfun
-/* Get the API version number */
-#define vl_api_version(n,v) static u32 api_version=(v);
-#include <acl/acl_all_api_h.h>
-#undef vl_api_version
-
#include <vnet/api_errno.h>
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
@@ -58,38 +53,29 @@
JNIEXPORT void JNICALL Java_io_fd_vpp_jvpp_acl_JVppAclImpl_init0
(JNIEnv *env, jclass clazz, jobject callback, jlong queue_address, jint my_client_index) {
acl_main_t * plugin_main = &acl_main;
- u8 * name;
clib_warning ("Java_io_fd_vpp_jvpp_acl_JVppAclImpl_init0");
plugin_main->my_client_index = my_client_index;
plugin_main->vl_input_queue = (unix_shared_memory_queue_t *)queue_address;
- name = format (0, "acl_%08x%c", api_version, 0);
- plugin_main->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name);
-
- if (plugin_main->msg_id_base == (u16) ~0) {
- jclass exClass = (*env)->FindClass(env, "java/lang/IllegalStateException");
- (*env)->ThrowNew(env, exClass, "acl plugin is not loaded in VPP");
- } else {
- plugin_main->callbackObject = (*env)->NewGlobalRef(env, callback);
- plugin_main->callbackClass = (jclass)(*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, callback));
-
- // verify API has not changed since jar generation
- #define _(N) \
- get_message_id(env, #N); \
- foreach_supported_api_message;
- #undef _
-
- #define _(N,n) \
- vl_msg_api_set_handlers(get_message_id(env, #N), #n, \
- vl_api_##n##_t_handler, \
- vl_noop_handler, \
- vl_api_##n##_t_endian, \
- vl_api_##n##_t_print, \
- sizeof(vl_api_##n##_t), 1);
- foreach_api_reply_handler;
- #undef _
- }
+ plugin_main->callbackObject = (*env)->NewGlobalRef(env, callback);
+ plugin_main->callbackClass = (jclass)(*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, callback));
+
+ // verify API has not changed since jar generation
+ #define _(N) \
+ get_message_id(env, #N); \
+ foreach_supported_api_message;
+ #undef _
+
+ #define _(N,n) \
+ vl_msg_api_set_handlers(get_message_id(env, #N), #n, \
+ vl_api_##n##_t_handler, \
+ vl_noop_handler, \
+ vl_api_##n##_t_endian, \
+ vl_api_##n##_t_print, \
+ sizeof(vl_api_##n##_t), 1);
+ foreach_api_reply_handler;
+ #undef _
}
JNIEXPORT void JNICALL Java_io_fd_vpp_jvpp_acl_JVppAclImpl_close0
diff --git a/src/vpp-api/java/jvpp-acl/jvpp_acl.h b/src/vpp-api/java/jvpp-acl/jvpp_acl.h
index 2b73d672..726f7298 100644
--- a/src/vpp-api/java/jvpp-acl/jvpp_acl.h
+++ b/src/vpp-api/java/jvpp-acl/jvpp_acl.h
@@ -24,9 +24,6 @@
/* Global state for JVPP-acl */
typedef struct {
- /* Base message index for the acl plugin */
- u16 msg_id_base;
-
/* Pointer to shared memory queue */
unix_shared_memory_queue_t * vl_input_queue;
diff --git a/src/vpp-api/java/jvpp-core/jvpp_core.c b/src/vpp-api/java/jvpp-core/jvpp_core.c
index c04666b2..8c579811 100644
--- a/src/vpp-api/java/jvpp-core/jvpp_core.c
+++ b/src/vpp-api/java/jvpp-core/jvpp_core.c
@@ -38,9 +38,6 @@
// TODO: generate jvpp_plugin_name.c files (or at least reuse plugin's main structure)
typedef struct {
- /* Base message index for the jvpp-core plugin */
- u16 msg_id_base;
-
/* Pointer to shared memory queue */
unix_shared_memory_queue_t * vl_input_queue;
diff --git a/src/vpp-api/java/jvpp-ioamexport/jvpp_ioam_export.c b/src/vpp-api/java/jvpp-ioamexport/jvpp_ioam_export.c
index 068d2ec3..bf0e9f0a 100644
--- a/src/vpp-api/java/jvpp-ioamexport/jvpp_ioam_export.c
+++ b/src/vpp-api/java/jvpp-ioamexport/jvpp_ioam_export.c
@@ -29,11 +29,6 @@
#include <ioam/export/ioam_export_all_api_h.h>
#undef vl_printfun
-/* Get the API version number */
-#define vl_api_version(n,v) static u32 api_version=(v);
-#include <ioam/export/ioam_export_all_api_h.h>
-#undef vl_api_version
-
#include <vnet/api_errno.h>
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
@@ -58,38 +53,29 @@
JNIEXPORT void JNICALL Java_io_fd_vpp_jvpp_ioamexport_JVppIoamexportImpl_init0
(JNIEnv *env, jclass clazz, jobject callback, jlong queue_address, jint my_client_index) {
ioamexport_main_t * plugin_main = &ioamexport_main;
- u8 * name;
clib_warning ("Java_io_fd_vpp_jvpp_ioamexport_JVppIoamexportImpl_init0");
plugin_main->my_client_index = my_client_index;
plugin_main->vl_input_queue = (unix_shared_memory_queue_t *)queue_address;
- name = format (0, "ioam_export_%08x%c", api_version, 0);
- plugin_main->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name);
-
- if (plugin_main->msg_id_base == (u16) ~0) {
- jclass exClass = (*env)->FindClass(env, "java/lang/IllegalStateException");
- (*env)->ThrowNew(env, exClass, "ioam_export plugin is not loaded in VPP");
- } else {
- plugin_main->callbackObject = (*env)->NewGlobalRef(env, callback);
- plugin_main->callbackClass = (jclass)(*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, callback));
-
- // verify API has not changed since jar generation
- #define _(N) \
- get_message_id(env, #N); \
- foreach_supported_api_message;
- #undef _
-
- #define _(N,n) \
- vl_msg_api_set_handlers(get_message_id(env, #N), #n, \
- vl_api_##n##_t_handler, \
- vl_noop_handler, \
- vl_api_##n##_t_endian, \
- vl_api_##n##_t_print, \
- sizeof(vl_api_##n##_t), 1);
- foreach_api_reply_handler;
- #undef _
- }
+ plugin_main->callbackObject = (*env)->NewGlobalRef(env, callback);
+ plugin_main->callbackClass = (jclass)(*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, callback));
+
+ // verify API has not changed since jar generation
+ #define _(N) \
+ get_message_id(env, #N);
+ foreach_supported_api_message;
+ #undef _
+
+ #define _(N,n) \
+ vl_msg_api_set_handlers(get_message_id(env, #N), #n, \
+ vl_api_##n##_t_handler, \
+ vl_noop_handler, \
+ vl_api_##n##_t_endian, \
+ vl_api_##n##_t_print, \
+ sizeof(vl_api_##n##_t), 1);
+ foreach_api_reply_handler;
+ #undef _
}
JNIEXPORT void JNICALL Java_io_fd_vpp_jvpp_ioamexport_JVppIoamexportImpl_close0
diff --git a/src/vpp-api/java/jvpp-ioamexport/jvpp_ioam_export.h b/src/vpp-api/java/jvpp-ioamexport/jvpp_ioam_export.h
index b6c0c16e..8b243def 100644
--- a/src/vpp-api/java/jvpp-ioamexport/jvpp_ioam_export.h
+++ b/src/vpp-api/java/jvpp-ioamexport/jvpp_ioam_export.h
@@ -24,9 +24,6 @@
/* Global state for JVPP-IOAM-EXPORT */
typedef struct {
- /* Base message index for the export plugin */
- u16 msg_id_base;
-
/* Pointer to shared memory queue */
unix_shared_memory_queue_t * vl_input_queue;
diff --git a/src/vpp-api/java/jvpp-ioampot/jvpp_ioam_pot.c b/src/vpp-api/java/jvpp-ioampot/jvpp_ioam_pot.c
index 51b6a075..f7e2b901 100644
--- a/src/vpp-api/java/jvpp-ioampot/jvpp_ioam_pot.c
+++ b/src/vpp-api/java/jvpp-ioampot/jvpp_ioam_pot.c
@@ -29,11 +29,6 @@
#include <ioam/lib-pot/pot_all_api_h.h>
#undef vl_printfun
-/* Get the API version number */
-#define vl_api_version(n,v) static u32 api_version=(v);
-#include <ioam/lib-pot/pot_all_api_h.h>
-#undef vl_api_version
-
#include <vnet/api_errno.h>
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
@@ -58,38 +53,29 @@
JNIEXPORT void JNICALL Java_io_fd_vpp_jvpp_ioampot_JVppIoampotImpl_init0
(JNIEnv *env, jclass clazz, jobject callback, jlong queue_address, jint my_client_index) {
ioampot_main_t * plugin_main = &ioampot_main;
- u8 * name;
clib_warning ("Java_io_fd_vpp_jvpp_ioampot_JVppIoampotImpl_init0");
plugin_main->my_client_index = my_client_index;
plugin_main->vl_input_queue = (unix_shared_memory_queue_t *)queue_address;
- name = format (0, "ioam_pot_%08x%c", api_version, 0);
- plugin_main->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name);
-
- if (plugin_main->msg_id_base == (u16) ~0) {
- jclass exClass = (*env)->FindClass(env, "java/lang/IllegalStateException");
- (*env)->ThrowNew(env, exClass, "ioam_pot plugin is not loaded in VPP");
- } else {
- plugin_main->callbackObject = (*env)->NewGlobalRef(env, callback);
- plugin_main->callbackClass = (jclass)(*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, callback));
-
- // verify API has not changed since jar generation
- #define _(N) \
- get_message_id(env, #N); \
- foreach_supported_api_message;
- #undef _
-
- #define _(N,n) \
- vl_msg_api_set_handlers(get_message_id(env, #N), #n, \
- vl_api_##n##_t_handler, \
- vl_noop_handler, \
- vl_api_##n##_t_endian, \
- vl_api_##n##_t_print, \
- sizeof(vl_api_##n##_t), 1);
- foreach_api_reply_handler;
- #undef _
- }
+ plugin_main->callbackObject = (*env)->NewGlobalRef(env, callback);
+ plugin_main->callbackClass = (jclass)(*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, callback));
+
+ // verify API has not changed since jar generation
+ #define _(N) \
+ get_message_id(env, #N);
+ foreach_supported_api_message;
+ #undef _
+
+ #define _(N,n) \
+ vl_msg_api_set_handlers(get_message_id(env, #N), #n, \
+ vl_api_##n##_t_handler, \
+ vl_noop_handler, \
+ vl_api_##n##_t_endian, \
+ vl_api_##n##_t_print, \
+ sizeof(vl_api_##n##_t), 1);
+ foreach_api_reply_handler;
+ #undef _
}
JNIEXPORT void JNICALL Java_io_fd_vpp_jvpp_ioampot_JVppIoampotImpl_close0
diff --git a/src/vpp-api/java/jvpp-ioampot/jvpp_ioam_pot.h b/src/vpp-api/java/jvpp-ioampot/jvpp_ioam_pot.h
index 00aa51db..81e2a1bb 100644
--- a/src/vpp-api/java/jvpp-ioampot/jvpp_ioam_pot.h
+++ b/src/vpp-api/java/jvpp-ioampot/jvpp_ioam_pot.h
@@ -24,9 +24,6 @@
/* Global state for JVPP-IOAM-POT */
typedef struct {
- /* Base message index for the pot plugin */
- u16 msg_id_base;
-
/* Pointer to shared memory queue */
unix_shared_memory_queue_t * vl_input_queue;
diff --git a/src/vpp-api/java/jvpp-ioamtrace/jvpp_ioam_trace.c b/src/vpp-api/java/jvpp-ioamtrace/jvpp_ioam_trace.c
index 2f74b5ad..5a0fda69 100644
--- a/src/vpp-api/java/jvpp-ioamtrace/jvpp_ioam_trace.c
+++ b/src/vpp-api/java/jvpp-ioamtrace/jvpp_ioam_trace.c
@@ -29,11 +29,6 @@
#include <ioam/lib-trace/trace_all_api_h.h>
#undef vl_printfun
-/* Get the API version number */
-#define vl_api_version(n,v) static u32 api_version=(v);
-#include <ioam/lib-trace/trace_all_api_h.h>
-#undef vl_api_version
-
#include <vnet/api_errno.h>
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
@@ -58,38 +53,29 @@
JNIEXPORT void JNICALL Java_io_fd_vpp_jvpp_ioamtrace_JVppIoamtraceImpl_init0
(JNIEnv *env, jclass clazz, jobject callback, jlong queue_address, jint my_client_index) {
ioamtrace_main_t * plugin_main = &ioamtrace_main;
- u8 * name;
clib_warning ("Java_io_fd_vpp_jvpp_ioamtrace_JVppIoamtraceImpl_init0");
plugin_main->my_client_index = my_client_index;
plugin_main->vl_input_queue = (unix_shared_memory_queue_t *)queue_address;
- name = format (0, "ioam_trace_%08x%c", api_version, 0);
- plugin_main->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name);
-
- if (plugin_main->msg_id_base == (u16) ~0) {
- jclass exClass = (*env)->FindClass(env, "java/lang/IllegalStateException");
- (*env)->ThrowNew(env, exClass, "ioam_trace plugin is not loaded in VPP");
- } else {
- plugin_main->callbackObject = (*env)->NewGlobalRef(env, callback);
- plugin_main->callbackClass = (jclass)(*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, callback));
-
- // verify API has not changed since jar generation
- #define _(N) \
- get_message_id(env, #N); \
- foreach_supported_api_message;
- #undef _
-
- #define _(N,n) \
- vl_msg_api_set_handlers(get_message_id(env, #N), #n, \
- vl_api_##n##_t_handler, \
- vl_noop_handler, \
- vl_api_##n##_t_endian, \
- vl_api_##n##_t_print, \
- sizeof(vl_api_##n##_t), 1);
- foreach_api_reply_handler;
- #undef _
- }
+ plugin_main->callbackObject = (*env)->NewGlobalRef(env, callback);
+ plugin_main->callbackClass = (jclass)(*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, callback));
+
+ // verify API has not changed since jar generation
+ #define _(N) \
+ get_message_id(env, #N);
+ foreach_supported_api_message;
+ #undef _
+
+ #define _(N,n) \
+ vl_msg_api_set_handlers(get_message_id(env, #N), #n, \
+ vl_api_##n##_t_handler, \
+ vl_noop_handler, \
+ vl_api_##n##_t_endian, \
+ vl_api_##n##_t_print, \
+ sizeof(vl_api_##n##_t), 1);
+ foreach_api_reply_handler;
+ #undef _
}
JNIEXPORT void JNICALL Java_io_fd_vpp_jvpp_ioamtrace_JVppIoamtraceImpl_close0
diff --git a/src/vpp-api/java/jvpp-ioamtrace/jvpp_ioam_trace.h b/src/vpp-api/java/jvpp-ioamtrace/jvpp_ioam_trace.h
index 9fc16c15..cb0b27e1 100644
--- a/src/vpp-api/java/jvpp-ioamtrace/jvpp_ioam_trace.h
+++ b/src/vpp-api/java/jvpp-ioamtrace/jvpp_ioam_trace.h
@@ -24,9 +24,6 @@
/* Global state for JVPP-IOAM-TRACE */
typedef struct {
- /* Base message index for the trace plugin */
- u16 msg_id_base;
-
/* Pointer to shared memory queue */
unix_shared_memory_queue_t * vl_input_queue;
diff --git a/src/vpp-api/java/jvpp-snat/jvpp_snat.c b/src/vpp-api/java/jvpp-snat/jvpp_snat.c
index c4d1afe8..31265772 100644
--- a/src/vpp-api/java/jvpp-snat/jvpp_snat.c
+++ b/src/vpp-api/java/jvpp-snat/jvpp_snat.c
@@ -29,11 +29,6 @@
#include <snat/snat_all_api_h.h>
#undef vl_printfun
-/* Get the API version number */
-#define vl_api_version(n,v) static u32 api_version=(v);
-#include <snat/snat_all_api_h.h>
-#undef vl_api_version
-
#include <vnet/api_errno.h>
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
@@ -58,38 +53,29 @@
JNIEXPORT void JNICALL Java_io_fd_vpp_jvpp_snat_JVppSnatImpl_init0
(JNIEnv *env, jclass clazz, jobject callback, jlong queue_address, jint my_client_index) {
snat_main_t * plugin_main = &snat_main;
- u8 * name;
clib_warning ("Java_io_fd_vpp_jvpp_snat_JVppSnatImpl_init0");
plugin_main->my_client_index = my_client_index;
plugin_main->vl_input_queue = (unix_shared_memory_queue_t *)queue_address;
- name = format (0, "snat_%08x%c", api_version, 0);
- plugin_main->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name);
-
- if (plugin_main->msg_id_base == (u16) ~0) {
- jclass exClass = (*env)->FindClass(env, "java/lang/IllegalStateException");
- (*env)->ThrowNew(env, exClass, "snat plugin is not loaded in VPP");
- } else {
- plugin_main->callbackObject = (*env)->NewGlobalRef(env, callback);
- plugin_main->callbackClass = (jclass)(*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, callback));
-
- // verify API has not changed since jar generation
- #define _(N) \
- get_message_id(env, #N);
- foreach_supported_api_message;
- #undef _
-
- #define _(N,n) \
- vl_msg_api_set_handlers(get_message_id(env, #N), #n, \
- vl_api_##n##_t_handler, \
- vl_noop_handler, \
- vl_api_##n##_t_endian, \
- vl_api_##n##_t_print, \
- sizeof(vl_api_##n##_t), 1);
- foreach_api_reply_handler;
- #undef _
- }
+ plugin_main->callbackObject = (*env)->NewGlobalRef(env, callback);
+ plugin_main->callbackClass = (jclass)(*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, callback));
+
+ // verify API has not changed since jar generation
+ #define _(N) \
+ get_message_id(env, #N);
+ foreach_supported_api_message;
+ #undef _
+
+ #define _(N,n) \
+ vl_msg_api_set_handlers(get_message_id(env, #N), #n, \
+ vl_api_##n##_t_handler, \
+ vl_noop_handler, \
+ vl_api_##n##_t_endian, \
+ vl_api_##n##_t_print, \
+ sizeof(vl_api_##n##_t), 1);
+ foreach_api_reply_handler;
+ #undef _
}
JNIEXPORT void JNICALL Java_io_fd_vpp_jvpp_snat_JVppSnatImpl_close0
diff --git a/src/vpp-api/java/jvpp-snat/jvpp_snat.h b/src/vpp-api/java/jvpp-snat/jvpp_snat.h
index 6426bda8..7739a411 100644
--- a/src/vpp-api/java/jvpp-snat/jvpp_snat.h
+++ b/src/vpp-api/java/jvpp-snat/jvpp_snat.h
@@ -24,9 +24,6 @@
/* Global state for JVPP-SNAT */
typedef struct {
- /* Base message index for the nsh plugin */
- u16 msg_id_base;
-
/* Pointer to shared memory queue */
unix_shared_memory_queue_t * vl_input_queue;