X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Futils_dpdk.c;h=fbdcaf8832a5d843d29cc242318f83e8c1a95109;hb=c7ab57a44a8bbfc17fa4d184f2c66eae03451f2a;hp=55ff7bc4e32446d023dc140a3ab7fd0ccd4b8c11;hpb=bf291ad88a70322730d7989f4663e5920bee1403;p=collectd.git diff --git a/src/utils_dpdk.c b/src/utils_dpdk.c index 55ff7bc4..fbdcaf88 100644 --- a/src/utils_dpdk.c +++ b/src/utils_dpdk.c @@ -45,7 +45,9 @@ #define DPDK_DEFAULT_RTE_CONFIG "/var/run/.rte_config" #define DPDK_EAL_ARGC 10 -//Complete trace should fit into 1024 chars +// Complete trace should fit into 1024 chars. Trace contain some headers +// and text together with traced data from pipe. This is the reason why +// we need to limit DPDK_MAX_BUFFER_SIZE value. #define DPDK_MAX_BUFFER_SIZE 896 #define DPDK_CDM_DEFAULT_TIMEOUT 10000 @@ -183,7 +185,7 @@ int dpdk_helper_eal_config_parse(dpdk_helper_ctx_t *phc, oconfig_item_t *ci) { status = cf_util_get_string_buffer(child, prefix, sizeof(prefix)); if (status == 0) { snprintf(phc->eal_config.file_prefix, DATA_MAX_NAME_LEN, - "/var/run/.%s_config", prefix); + "/var/run/.%s_config", prefix); DEBUG("dpdk_common: EAL:File prefix %s", phc->eal_config.file_prefix); } } else if (strcasecmp("LogLevel", child->key) == 0) { @@ -191,9 +193,11 @@ int dpdk_helper_eal_config_parse(dpdk_helper_ctx_t *phc, oconfig_item_t *ci) { sizeof(phc->eal_config.log_level)); DEBUG("dpdk_common: EAL:LogLevel %s", phc->eal_config.log_level); } else if (strcasecmp("RteDriverLibPath", child->key) == 0) { - status = cf_util_get_string_buffer(child, phc->eal_config.rte_driver_lib_path, - sizeof(phc->eal_config.rte_driver_lib_path)); - DEBUG("dpdk_common: EAL:RteDriverLibPath %s", phc->eal_config.rte_driver_lib_path); + status = cf_util_get_string_buffer( + child, phc->eal_config.rte_driver_lib_path, + sizeof(phc->eal_config.rte_driver_lib_path)); + DEBUG("dpdk_common: EAL:RteDriverLibPath %s", + phc->eal_config.rte_driver_lib_path); } else { ERROR("dpdk_common: Invalid '%s' configuration option", child->key); status = -EINVAL; @@ -507,8 +511,8 @@ static int dpdk_helper_eal_init(dpdk_helper_ctx_t *phc) { argp[argc++] = phc->eal_config.log_level; } if (strcasecmp(phc->eal_config.rte_driver_lib_path, "") != 0) { - argp[argc++] = "-d"; - argp[argc++] = phc->eal_config.rte_driver_lib_path; + argp[argc++] = "-d"; + argp[argc++] = phc->eal_config.rte_driver_lib_path; } assert(argc <= (DPDK_EAL_ARGC * 2 + 1)); @@ -715,7 +719,8 @@ static void dpdk_helper_check_pipe(dpdk_helper_ctx_t *phc) { .fd = phc->pipes[0], .events = POLLIN, }; int data_avail = poll(&fds, 1, 0); - DEBUG("%s:dpdk_helper_check_pipe: poll data_avail=%d", phc->shm_name, data_avail); + DEBUG("%s:dpdk_helper_check_pipe: poll data_avail=%d", phc->shm_name, + data_avail); if (data_avail < 0) { if (errno != EINTR || errno != EAGAIN) { char errbuf[ERR_BUF_SIZE]; @@ -728,8 +733,8 @@ static void dpdk_helper_check_pipe(dpdk_helper_ctx_t *phc) { DEBUG("%s:dpdk_helper_check_pipe: read nbytes=%d", phc->shm_name, nbytes); if (nbytes <= 0) break; - buf[nbytes] = '\n'; - sstrncpy(out, buf, (nbytes + 1)); + buf[nbytes] = '\0'; + sstrncpy(out, buf, sizeof(out)); DEBUG("%s: helper process:\n%s", phc->shm_name, out); } }