aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2017-10-16 12:33:12 +0200
committerDave Wallace <dwallacelf@gmail.com>2017-10-16 14:18:09 +0000
commitc7fc97ad85993956a5e76c2ea69dbd90b34360ac (patch)
tree34dcf0074b5c6b1f95e742af767f28bc9986f507 /src
parentf90813d64c4d1aee3a51609e85e632b1f9a37536 (diff)
jvpp: stop plugin intialization on first mismatch
Java bindings use get_message_id from jvpp-common to detect if messages known at compile time are avaliable at runtime. In case of missing entry, Java exception is propagated via JNI using (*env)->ThrowNew. But this function does not end code execution so, in order to prevent unexpected behaviour (e.g. calling vl_msg_api_set_handlers with id == 0), get_message_id caller should do it manually. Change-Id: I2edb5013fd3658dcdd77a867b5cdf62e559ee071 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/vpp-api/java/jvpp-acl/jvpp_acl.c2
-rw-r--r--src/vpp-api/java/jvpp-common/jvpp_common.c9
-rw-r--r--src/vpp-api/java/jvpp-core/jvpp_core.c4
-rw-r--r--src/vpp-api/java/jvpp-gtpu/jvpp_gtpu.c2
-rw-r--r--src/vpp-api/java/jvpp-ioamexport/jvpp_ioam_export.c2
-rw-r--r--src/vpp-api/java/jvpp-ioampot/jvpp_ioam_pot.c2
-rw-r--r--src/vpp-api/java/jvpp-ioamtrace/jvpp_ioam_trace.c2
-rw-r--r--src/vpp-api/java/jvpp-nat/jvpp_nat.c2
-rw-r--r--src/vpp-api/java/jvpp-pppoe/jvpp_pppoe.c2
9 files changed, 15 insertions, 12 deletions
diff --git a/src/vpp-api/java/jvpp-acl/jvpp_acl.c b/src/vpp-api/java/jvpp-acl/jvpp_acl.c
index f5467e99b9d..82719aafbc8 100644
--- a/src/vpp-api/java/jvpp-acl/jvpp_acl.c
+++ b/src/vpp-api/java/jvpp-acl/jvpp_acl.c
@@ -54,7 +54,7 @@ JNIEXPORT void JNICALL Java_io_fd_vpp_jvpp_acl_JVppAclImpl_init0
// verify API has not changed since jar generation
#define _(N) \
- get_message_id(env, #N); \
+ if (get_message_id(env, #N) == 0) return;
foreach_supported_api_message;
#undef _
diff --git a/src/vpp-api/java/jvpp-common/jvpp_common.c b/src/vpp-api/java/jvpp-common/jvpp_common.c
index c00298bfa81..2425607c582 100644
--- a/src/vpp-api/java/jvpp-common/jvpp_common.c
+++ b/src/vpp-api/java/jvpp-common/jvpp_common.c
@@ -83,11 +83,14 @@ u32 get_message_id(JNIEnv *env, const char *key) {
uword *p = hash_get(jvpp_main.messages_hash, key);
if (!p) {
jclass exClass = (*env)->FindClass(env, "java/lang/IllegalStateException");
- char *msgBuf = clib_mem_alloc(strlen(key) + 40);
+ char *msgBuf = clib_mem_alloc(strlen(key) + 70);
strcpy(msgBuf, "API mismatch detected: ");
strcat(msgBuf, key);
- strcat(msgBuf, " is missing");
- DEBUG_LOG("get_message_id : %s\n", msgBuf);
+ strcat(msgBuf, " is missing in global name_crc hash table.");
+ DEBUG_LOG("%s", msgBuf);
+ DEBUG_LOG("Possible reasons:");
+ DEBUG_LOG("1) incompatible VPP version used");
+ DEBUG_LOG("2) message present in JSON file but not in global name_crc table");
(*env)->ThrowNew(env, exClass, msgBuf);
clib_mem_free(msgBuf);
return 0;
diff --git a/src/vpp-api/java/jvpp-core/jvpp_core.c b/src/vpp-api/java/jvpp-core/jvpp_core.c
index e57c62a3e9f..b12f63af16f 100644
--- a/src/vpp-api/java/jvpp-core/jvpp_core.c
+++ b/src/vpp-api/java/jvpp-core/jvpp_core.c
@@ -55,9 +55,9 @@ JNIEXPORT void JNICALL Java_io_fd_vpp_jvpp_core_JVppCoreImpl_init0
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
+ // verify API has not changed since jar generation (exit on mismatch)
#define _(N) \
- get_message_id(env, #N); \
+ if (get_message_id(env, #N) == 0) return;
foreach_supported_api_message;
#undef _
diff --git a/src/vpp-api/java/jvpp-gtpu/jvpp_gtpu.c b/src/vpp-api/java/jvpp-gtpu/jvpp_gtpu.c
index 12b3090eabd..286a9ceccbe 100644
--- a/src/vpp-api/java/jvpp-gtpu/jvpp_gtpu.c
+++ b/src/vpp-api/java/jvpp-gtpu/jvpp_gtpu.c
@@ -54,7 +54,7 @@ JNIEXPORT void JNICALL Java_io_fd_vpp_jvpp_gtpu_JVppGtpuImpl_init0
// verify API has not changed since jar generation
#define _(N) \
- get_message_id(env, #N); \
+ if (get_message_id(env, #N) == 0) return;
foreach_supported_api_message;
#undef _
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 cf4499d5b12..8d486134cfa 100644
--- a/src/vpp-api/java/jvpp-ioamexport/jvpp_ioam_export.c
+++ b/src/vpp-api/java/jvpp-ioamexport/jvpp_ioam_export.c
@@ -54,7 +54,7 @@ JNIEXPORT void JNICALL Java_io_fd_vpp_jvpp_ioamexport_JVppIoamexportImpl_init0
// verify API has not changed since jar generation
#define _(N) \
- get_message_id(env, #N);
+ if (get_message_id(env, #N) == 0) return;
foreach_supported_api_message;
#undef _
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 8f396989366..4b9d1a58932 100644
--- a/src/vpp-api/java/jvpp-ioampot/jvpp_ioam_pot.c
+++ b/src/vpp-api/java/jvpp-ioampot/jvpp_ioam_pot.c
@@ -54,7 +54,7 @@ JNIEXPORT void JNICALL Java_io_fd_vpp_jvpp_ioampot_JVppIoampotImpl_init0
// verify API has not changed since jar generation
#define _(N) \
- get_message_id(env, #N);
+ if (get_message_id(env, #N) == 0) return;
foreach_supported_api_message;
#undef _
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 f53937e73b6..f917d1c684e 100644
--- a/src/vpp-api/java/jvpp-ioamtrace/jvpp_ioam_trace.c
+++ b/src/vpp-api/java/jvpp-ioamtrace/jvpp_ioam_trace.c
@@ -54,7 +54,7 @@ JNIEXPORT void JNICALL Java_io_fd_vpp_jvpp_ioamtrace_JVppIoamtraceImpl_init0
// verify API has not changed since jar generation
#define _(N) \
- get_message_id(env, #N);
+ if (get_message_id(env, #N) == 0) return;
foreach_supported_api_message;
#undef _
diff --git a/src/vpp-api/java/jvpp-nat/jvpp_nat.c b/src/vpp-api/java/jvpp-nat/jvpp_nat.c
index 85217f04a22..56c74d21141 100644
--- a/src/vpp-api/java/jvpp-nat/jvpp_nat.c
+++ b/src/vpp-api/java/jvpp-nat/jvpp_nat.c
@@ -54,7 +54,7 @@ JNIEXPORT void JNICALL Java_io_fd_vpp_jvpp_nat_JVppNatImpl_init0
// verify API has not changed since jar generation
#define _(N) \
- get_message_id(env, #N);
+ if (get_message_id(env, #N) == 0) return;
foreach_supported_api_message;
#undef _
diff --git a/src/vpp-api/java/jvpp-pppoe/jvpp_pppoe.c b/src/vpp-api/java/jvpp-pppoe/jvpp_pppoe.c
index c9c30305728..d339700ea22 100644
--- a/src/vpp-api/java/jvpp-pppoe/jvpp_pppoe.c
+++ b/src/vpp-api/java/jvpp-pppoe/jvpp_pppoe.c
@@ -54,7 +54,7 @@ JNIEXPORT void JNICALL Java_io_fd_vpp_jvpp_pppoe_JVppPppoeImpl_init0
// verify API has not changed since jar generation
#define _(N) \
- get_message_id(env, #N); \
+ if (get_message_id(env, #N) == 0) return;
foreach_supported_api_message;
#undef _