aboutsummaryrefslogtreecommitdiffstats
path: root/src/vpp-api/java/jvpp-registry/jvpp_registry.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vpp-api/java/jvpp-registry/jvpp_registry.c')
-rw-r--r--src/vpp-api/java/jvpp-registry/jvpp_registry.c34
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),