diff options
author | Jan Srnicek <jsrnicek@cisco.com> | 2017-03-24 10:18:11 +0100 |
---|---|---|
committer | Jan Srnicek <jsrnicek@cisco.com> | 2017-08-14 12:19:31 +0000 |
commit | 5beec81360146536086f1996869b4ee32ca37ddc (patch) | |
tree | d82ccff22185b5c23c3eb624bbaa53f68abcd84b /src/vpp-api/java/jvpp-registry/jvpp_registry.c | |
parent | 0117d24a1f6d018933c8f3e4ecca269f57f431ab (diff) |
jvpp: make shm_prefix configurable (VPP-591)
svm.c - set default map region root path only if root path is not
already present
memory_shared.c - added option for tests to send memory region name
and root path in one variable, if so name and root path are
separated here and set to map region structure so find function
can find it properly
jvpp-registry.c - added parameters shmPrefix to be able pass +
removed sudo restriction
specific shared memory prefix that is used while starting
python tests(see framework.py)
JVppRegistyImpl - added option to specify shmPrefix
VppJNIConnection - added option to specify shmPrefix
Change-Id: I3f89f867fb9b20eef00fbd497cb0e41b25d6eab7
Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Signed-off-by: Matej Perina <mperina@cisco.com>
Diffstat (limited to 'src/vpp-api/java/jvpp-registry/jvpp_registry.c')
-rw-r--r-- | src/vpp-api/java/jvpp-registry/jvpp_registry.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/vpp-api/java/jvpp-registry/jvpp_registry.c b/src/vpp-api/java/jvpp-registry/jvpp_registry.c index 66adfea041a..1e2c0176db9 100644 --- a/src/vpp-api/java/jvpp-registry/jvpp_registry.c +++ b/src/vpp-api/java/jvpp-registry/jvpp_registry.c @@ -243,14 +243,13 @@ static int send_initial_control_ping() { return rv; } -static int connect_to_vpe(char *name) { +static int connect_to_vpe(char *shm_prefix, char *name) { jvpp_main_t * jm = &jvpp_main; api_main_t * am = &api_main; jvpp_registry_main_t * rm = &jvpp_registry_main; - if (vl_client_connect_to_vlib("/vpe-api", name, 32) < 0) + if (vl_client_connect_to_vlib(shm_prefix, name, 32) < 0) return -1; - jm->my_client_index = am->my_client_index; jm->vl_input_queue = am->shmem_hdr->vl_input_queue; @@ -268,9 +267,15 @@ static int connect_to_vpe(char *name) { } JNIEXPORT jobject JNICALL Java_io_fd_vpp_jvpp_VppJNIConnection_clientConnect( - JNIEnv *env, jclass obj, jstring clientName) { + JNIEnv *env, jclass obj, jstring shmPrefix, jstring clientName) { + /* + * TODO introducing memory prefix as variable can be used in hc2vpp + * to be able to run without root privileges + * https://jira.fd.io/browse/HC2VPP-176 + */ int rv; const char *client_name; + const char *shm_prefix; void vl_msg_reply_handler_hookup(void); jvpp_main_t * jm = &jvpp_main; jvpp_registry_main_t * rm = &jvpp_registry_main; @@ -280,15 +285,6 @@ JNIEXPORT jobject JNICALL Java_io_fd_vpp_jvpp_VppJNIConnection_clientConnect( jmethodID connectionInfoConstructor = (*env)->GetMethodID(env, connectionInfoClass, "<init>", "(JII)V"); - /* - * Bail out now if we're not running as root - */ - if (geteuid() != 0) { - return (*env)->NewObject(env, connectionInfoClass, - connectionInfoConstructor, 0, 0, - VNET_API_ERROR_NOT_RUNNING_AS_ROOT); - } - if (rm->is_connected) { return (*env)->NewObject(env, connectionInfoClass, connectionInfoConstructor, 0, 0, @@ -296,17 +292,25 @@ JNIEXPORT jobject JNICALL Java_io_fd_vpp_jvpp_VppJNIConnection_clientConnect( } client_name = (*env)->GetStringUTFChars(env, clientName, 0); + shm_prefix = (*env)->GetStringUTFChars(env, shmPrefix, 0); + if (!client_name) { return (*env)->NewObject(env, connectionInfoClass, - connectionInfoConstructor, 0, 0, VNET_API_ERROR_INVALID_VALUE); + connectionInfoConstructor, 0, 0, VNET_API_ERROR_INVALID_VALUE, shmPrefix); + } + + if (!shm_prefix) { + return (*env)->NewObject(env, connectionInfoClass, + connectionInfoConstructor, 0, 0, VNET_API_ERROR_INVALID_VALUE, shmPrefix); } - rv = connect_to_vpe((char *) client_name); + rv = connect_to_vpe((char *) shm_prefix, (char *) client_name); if (rv < 0) clib_warning("connection failed, rv %d", rv); (*env)->ReleaseStringUTFChars(env, clientName, client_name); + (*env)->ReleaseStringUTFChars(env, shmPrefix, shm_prefix); return (*env)->NewObject(env, connectionInfoClass, connectionInfoConstructor, (jlong) pointer_to_uword (jm->vl_input_queue), |