summaryrefslogtreecommitdiff
path: root/examples/vm_power_manager
diff options
context:
space:
mode:
authorBruce Richardson <bruce.richardson@intel.com>2014-12-16 15:03:51 +0000
committerThomas Monjalon <thomas.monjalon@6wind.com>2014-12-17 01:04:06 +0100
commit0d74597c1b4ff660b3fb6cd97c7d86643d42065b (patch)
tree528c8cf148551b19d966a33de852611727ff0118 /examples/vm_power_manager
parent95df1d78c66567a229667acfed290ced6fef8b61 (diff)
downloaddpdk-0d74597c1b4ff660b3fb6cd97c7d86643d42065b.zip
dpdk-0d74597c1b4ff660b3fb6cd97c7d86643d42065b.tar.gz
dpdk-0d74597c1b4ff660b3fb6cd97c7d86643d42065b.tar.xz
examples/vm_power: fix max length of unix socket path
The length of the path to a unix socket is not PATH_MAX but instead is UNIX_PATH_MAX which is generally just over 100 bytes in size. It's not actually defined in sys/un.h on linux - despite the man page referencing it, so calculate the size in the case where it's not defined. Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Diffstat (limited to 'examples/vm_power_manager')
-rw-r--r--examples/vm_power_manager/channel_manager.c2
-rw-r--r--examples/vm_power_manager/channel_manager.h8
2 files changed, 8 insertions, 2 deletions
diff --git a/examples/vm_power_manager/channel_manager.c b/examples/vm_power_manager/channel_manager.c
index 7828be7..34a395d 100644
--- a/examples/vm_power_manager/channel_manager.c
+++ b/examples/vm_power_manager/channel_manager.c
@@ -597,7 +597,7 @@ get_info_vm(const char *vm_name, struct vm_info *info)
ITERATIVE_BITMASK_CHECK_64(mask, i) {
info->channels[channel_num].channel_num = i;
memcpy(info->channels[channel_num].channel_path,
- vm_info->channels[i]->channel_path, PATH_MAX);
+ vm_info->channels[i]->channel_path, UNIX_PATH_MAX);
info->channels[channel_num].status = vm_info->channels[i]->status;
info->channels[channel_num].fd = vm_info->channels[i]->fd;
channel_num++;
diff --git a/examples/vm_power_manager/channel_manager.h b/examples/vm_power_manager/channel_manager.h
index 12c29c3..67e26ec 100644
--- a/examples/vm_power_manager/channel_manager.h
+++ b/examples/vm_power_manager/channel_manager.h
@@ -39,6 +39,7 @@ extern "C" {
#endif
#include <linux/limits.h>
+#include <sys/un.h>
#include <rte_atomic.h>
#include "channel_commands.h"
@@ -54,6 +55,11 @@ extern "C" {
/* File socket directory */
#define CHANNEL_MGR_SOCKET_PATH "/tmp/powermonitor/"
+#ifndef UNIX_PATH_MAX
+struct sockaddr_un _sockaddr_un;
+#define UNIX_PATH_MAX sizeof(_sockaddr_un.sun_path)
+#endif
+
/* Communication Channel Status */
enum channel_status { CHANNEL_MGR_CHANNEL_DISCONNECTED = 0,
CHANNEL_MGR_CHANNEL_CONNECTED,
@@ -68,7 +74,7 @@ enum vm_status { CHANNEL_MGR_VM_INACTIVE = 0, CHANNEL_MGR_VM_ACTIVE};
* the host.
*/
struct channel_info {
- char channel_path[PATH_MAX]; /**< Path to host socket */
+ char channel_path[UNIX_PATH_MAX]; /**< Path to host socket */
volatile uint32_t status; /**< Connection status(enum channel_status) */
int fd; /**< AF_UNIX socket fd */
unsigned channel_num; /**< CHANNEL_MGR_SOCKET_PATH/<vm_name>.channel_num */