eal: do not hardcode socket filter value in IPC
authorAnatoly Burakov <anatoly.burakov@intel.com>
Tue, 13 Mar 2018 17:42:37 +0000 (17:42 +0000)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 21 Mar 2018 17:42:39 +0000 (18:42 +0100)
Currently, filter value is hardcoded and disconnected from actual
value returned by eal_mp_socket_path(). Fix this to generate filter
value by deriving it from eal_mp_socket_path() instead.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Jianfeng Tan <jianfeng.tan@intel.com>
lib/librte_eal/common/eal_common_proc.c

index 1aab3ac..9587211 100644 (file)
@@ -359,18 +359,19 @@ int
 rte_mp_channel_init(void)
 {
        char thread_name[RTE_MAX_THREAD_NAME_LEN];
-       char *path;
+       char path[PATH_MAX];
        pthread_t tid;
 
-       snprintf(mp_filter, PATH_MAX, ".%s_unix_*",
-                internal_config.hugefile_prefix);
+       /* create filter path */
+       create_socket_path("*", path, sizeof(path));
+       snprintf(mp_filter, sizeof(mp_filter), "%s", basename(path));
 
-       path = strdup(eal_mp_socket_path());
-       snprintf(mp_dir_path, PATH_MAX, "%s", dirname(path));
-       free(path);
+       /* path may have been modified, so recreate it */
+       create_socket_path("*", path, sizeof(path));
+       snprintf(mp_dir_path, sizeof(mp_dir_path), "%s", dirname(path));
 
        if (rte_eal_process_type() == RTE_PROC_PRIMARY &&
-           unlink_sockets(mp_filter)) {
+                       unlink_sockets(mp_filter)) {
                RTE_LOG(ERR, EAL, "failed to unlink mp sockets\n");
                return -1;
        }