patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] please check if patch 'eal: fix strdup usages in internal config' is applicable to LTS release 17.11.6
@ 2019-03-08 18:08 Yongseok Koh
  2019-03-08 18:09 ` [dpdk-stable] please check if patch 'net/cxgbe: fix macros related to logs for Windows' " Yongseok Koh
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Yongseok Koh @ 2019-03-08 18:08 UTC (permalink / raw)
  To: Anatoly Burakov; +Cc: dpdk stable

Hi,

Even though the patch doesn't have "Cc: stable@dpdk.org" tag or "Fixes:" tag,
the commit log says it fixes some issue. Tags might be mistakenly missed. We
don't want to miss any fixes for stable releases. That's why I'm sending this
email.

Please send backports if you think the patch should be merged to LTS release 17.11.6
Or, let me know if you have any comments, say, need more time, or it's worthless
to backport it. And please send it to "stable@dpdk.org", but not "dev@dpdk.org".

FYI, branch 17.11 is located at tree:
   git://dpdk.org/dpdk-stable

It'd be great if you could do that in one or two weeks. Also, please add a
heading line like below before the commit log body:
    [ backported from upstream commit xxx ]

Example: http://dpdk.org/browse/dpdk-stable/commit/?h=16.07&id=c4831394c7d1944d8ec27d52c22997f20d19718e

Also please mention the target LTS in the subject line, as we have
more than one at the same time, for example:

    [PATCH 17.11] foo/bar: fix baz

With git send-email, this can be achieved by appending the parameter:

    --subject-prefix='17.11'


Thanks.

Yongseok

---
>From 66d9f61de0885bd07662a016542600fe139d4eed Mon Sep 17 00:00:00 2001
From: Anatoly Burakov <anatoly.burakov@intel.com>
Date: Thu, 10 Jan 2019 13:38:59 +0000
Subject: [PATCH] eal: fix strdup usages in internal config

Currently, we use strdup in a few places to store command-line
parameter values for certain internal config values. There are
several issues with that.

First of all, they're never freed, so memory ends up leaking
either after EAL exit, or when these command-line options are
supplied multiple times.

Second of all, they're defined as `const char *`, so they
*cannot* be freed even if we wanted to.

Finally, strdup may return NULL, which will be stored in the
config. For most fields, NULL is a valid value, but for the
default prefix, the value is always expected to be valid.

To fix all of this, three things are done. First, we change
the definitions of these values to `char *` as opposed to
`const char *`. This does not break the ABI, and previous
code assumes constness (which is more restrictive), so it's
safe to do so.

Then, fix all usages of strdup to check return value, and add
a cleanup function that will free the memory occupied by
these strings, as well as freeing them before assigning a new
value to prevent leaks when parameter is specified multiple
times.

And finally, add an internal API to query hugefile prefix, so
that, absent of a valid value, a default value will be
returned, and also fix up all usages of hugefile prefix to
use this API instead of accessing hugefile prefix directly.

Bugzilla ID: 108

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/bsdapp/eal/eal.c            | 19 ++++++++++--
 lib/librte_eal/common/eal_common_options.c | 25 ++++++++++++++--
 lib/librte_eal/common/eal_filesystem.h     |  6 +++-
 lib/librte_eal/common/eal_internal_cfg.h   |  6 ++--
 lib/librte_eal/common/eal_options.h        |  1 +
 lib/librte_eal/linuxapp/eal/eal.c          | 46 ++++++++++++++++++++++++------
 lib/librte_eal/linuxapp/eal/eal_memory.c   |  2 +-
 7 files changed, 87 insertions(+), 18 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index c8e0da097..1ba9bd7cf 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -117,7 +117,7 @@ eal_create_runtime_dir(void)
 
 	/* create prefix-specific subdirectory under DPDK runtime dir */
 	ret = snprintf(runtime_dir, sizeof(runtime_dir), "%s/%s",
-			tmp, internal_config.hugefile_prefix);
+			tmp, eal_get_hugefile_prefix());
 	if (ret < 0 || ret == sizeof(runtime_dir)) {
 		RTE_LOG(ERR, EAL, "Error creating prefix-specific runtime path name\n");
 		return -1;
@@ -535,9 +535,21 @@ eal_parse_args(int argc, char **argv)
 
 		switch (opt) {
 		case OPT_MBUF_POOL_OPS_NAME_NUM:
-			internal_config.user_mbuf_pool_ops_name =
-			    strdup(optarg);
+		{
+			char *ops_name = strdup(optarg);
+			if (ops_name == NULL)
+				RTE_LOG(ERR, EAL, "Could not store mbuf pool ops name\n");
+			else {
+				/* free old ops name */
+				if (internal_config.user_mbuf_pool_ops_name !=
+						NULL)
+					free(internal_config.user_mbuf_pool_ops_name);
+
+				internal_config.user_mbuf_pool_ops_name =
+						ops_name;
+			}
 			break;
+		}
 		case 'h':
 			eal_usage(prgname);
 			exit(EXIT_SUCCESS);
@@ -923,6 +935,7 @@ rte_eal_cleanup(void)
 {
 	rte_service_finalize();
 	rte_mp_channel_cleanup();
+	eal_cleanup_config(&internal_config);
 	return 0;
 }
 
diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index 6e3a83b98..a2d862b5f 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -169,6 +169,14 @@ eal_option_device_parse(void)
 	return ret;
 }
 
+const char *
+eal_get_hugefile_prefix(void)
+{
+	if (internal_config.hugefile_prefix != NULL)
+		return internal_config.hugefile_prefix;
+	return HUGEFILE_PREFIX_DEFAULT;
+}
+
 void
 eal_reset_internal_config(struct internal_config *internal_cfg)
 {
@@ -177,7 +185,7 @@ eal_reset_internal_config(struct internal_config *internal_cfg)
 	internal_cfg->memory = 0;
 	internal_cfg->force_nrank = 0;
 	internal_cfg->force_nchannel = 0;
-	internal_cfg->hugefile_prefix = HUGEFILE_PREFIX_DEFAULT;
+	internal_cfg->hugefile_prefix = NULL;
 	internal_cfg->hugepage_dir = NULL;
 	internal_cfg->force_sockets = 0;
 	/* zero out the NUMA config */
@@ -1348,6 +1356,19 @@ eal_auto_detect_cores(struct rte_config *cfg)
 }
 
 int
+eal_cleanup_config(struct internal_config *internal_cfg)
+{
+	if (internal_cfg->hugefile_prefix != NULL)
+		free(internal_cfg->hugefile_prefix);
+	if (internal_cfg->hugepage_dir != NULL)
+		free(internal_cfg->hugepage_dir);
+	if (internal_cfg->user_mbuf_pool_ops_name != NULL)
+		free(internal_cfg->user_mbuf_pool_ops_name);
+
+	return 0;
+}
+
+int
 eal_adjust_config(struct internal_config *internal_cfg)
 {
 	int i;
@@ -1387,7 +1408,7 @@ eal_check_common_options(struct internal_config *internal_cfg)
 		RTE_LOG(ERR, EAL, "Invalid process type specified\n");
 		return -1;
 	}
-	if (index(internal_cfg->hugefile_prefix, '%') != NULL) {
+	if (index(eal_get_hugefile_prefix(), '%') != NULL) {
 		RTE_LOG(ERR, EAL, "Invalid char, '%%', in --"OPT_FILE_PREFIX" "
 			"option\n");
 		return -1;
diff --git a/lib/librte_eal/common/eal_filesystem.h b/lib/librte_eal/common/eal_filesystem.h
index 64a028db7..89a3added 100644
--- a/lib/librte_eal/common/eal_filesystem.h
+++ b/lib/librte_eal/common/eal_filesystem.h
@@ -28,6 +28,10 @@ eal_create_runtime_dir(void);
 int
 eal_clean_runtime_dir(void);
 
+/** Function to return hugefile prefix that's currently set up */
+const char *
+eal_get_hugefile_prefix(void);
+
 #define RUNTIME_CONFIG_FNAME "config"
 static inline const char *
 eal_runtime_config_path(void)
@@ -89,7 +93,7 @@ static inline const char *
 eal_get_hugefile_path(char *buffer, size_t buflen, const char *hugedir, int f_id)
 {
 	snprintf(buffer, buflen, HUGEFILE_FMT, hugedir,
-			internal_config.hugefile_prefix, f_id);
+			eal_get_hugefile_prefix(), f_id);
 	buffer[buflen - 1] = '\0';
 	return buffer;
 }
diff --git a/lib/librte_eal/common/eal_internal_cfg.h b/lib/librte_eal/common/eal_internal_cfg.h
index 98e314fef..60eaead8f 100644
--- a/lib/librte_eal/common/eal_internal_cfg.h
+++ b/lib/librte_eal/common/eal_internal_cfg.h
@@ -66,9 +66,9 @@ struct internal_config {
 	volatile int syslog_facility;	  /**< facility passed to openlog() */
 	/** default interrupt mode for VFIO */
 	volatile enum rte_intr_mode vfio_intr_mode;
-	const char *hugefile_prefix;      /**< the base filename of hugetlbfs files */
-	const char *hugepage_dir;         /**< specific hugetlbfs directory to use */
-	const char *user_mbuf_pool_ops_name;
+	char *hugefile_prefix;      /**< the base filename of hugetlbfs files */
+	char *hugepage_dir;         /**< specific hugetlbfs directory to use */
+	char *user_mbuf_pool_ops_name;
 			/**< user defined mbuf pool ops name */
 	unsigned num_hugepage_sizes;      /**< how many sizes on this system */
 	struct hugepage_info hugepage_info[MAX_HUGEPAGE_SIZES];
diff --git a/lib/librte_eal/common/eal_options.h b/lib/librte_eal/common/eal_options.h
index 1480c5d77..58ee9ae33 100644
--- a/lib/librte_eal/common/eal_options.h
+++ b/lib/librte_eal/common/eal_options.h
@@ -77,6 +77,7 @@ int eal_parse_common_option(int opt, const char *argv,
 			    struct internal_config *conf);
 int eal_option_device_parse(void);
 int eal_adjust_config(struct internal_config *internal_cfg);
+int eal_cleanup_config(struct internal_config *internal_cfg);
 int eal_check_common_options(struct internal_config *internal_cfg);
 void eal_common_usage(void);
 enum rte_proc_type_t eal_proc_type_detect(void);
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 2d8d470b8..a386829f3 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -125,7 +125,7 @@ eal_create_runtime_dir(void)
 
 	/* create prefix-specific subdirectory under DPDK runtime dir */
 	ret = snprintf(runtime_dir, sizeof(runtime_dir), "%s/%s",
-			tmp, internal_config.hugefile_prefix);
+			tmp, eal_get_hugefile_prefix());
 	if (ret < 0 || ret == sizeof(runtime_dir)) {
 		RTE_LOG(ERR, EAL, "Error creating prefix-specific runtime path name\n");
 		return -1;
@@ -727,13 +727,31 @@ eal_parse_args(int argc, char **argv)
 			exit(EXIT_SUCCESS);
 
 		case OPT_HUGE_DIR_NUM:
-			internal_config.hugepage_dir = strdup(optarg);
+		{
+			char *hdir = strdup(optarg);
+			if (hdir == NULL)
+				RTE_LOG(ERR, EAL, "Could not store hugepage directory\n");
+			else {
+				/* free old hugepage dir */
+				if (internal_config.hugepage_dir != NULL)
+					free(internal_config.hugepage_dir);
+				internal_config.hugepage_dir = hdir;
+			}
 			break;
-
+		}
 		case OPT_FILE_PREFIX_NUM:
-			internal_config.hugefile_prefix = strdup(optarg);
+		{
+			char *prefix = strdup(optarg);
+			if (prefix == NULL)
+				RTE_LOG(ERR, EAL, "Could not store file prefix\n");
+			else {
+				/* free old prefix */
+				if (internal_config.hugefile_prefix != NULL)
+					free(internal_config.hugefile_prefix);
+				internal_config.hugefile_prefix = prefix;
+			}
 			break;
-
+		}
 		case OPT_SOCKET_MEM_NUM:
 			if (eal_parse_socket_arg(optarg,
 					internal_config.socket_mem) < 0) {
@@ -783,10 +801,21 @@ eal_parse_args(int argc, char **argv)
 			break;
 
 		case OPT_MBUF_POOL_OPS_NAME_NUM:
-			internal_config.user_mbuf_pool_ops_name =
-			    strdup(optarg);
+		{
+			char *ops_name = strdup(optarg);
+			if (ops_name == NULL)
+				RTE_LOG(ERR, EAL, "Could not store mbuf pool ops name\n");
+			else {
+				/* free old ops name */
+				if (internal_config.user_mbuf_pool_ops_name !=
+						NULL)
+					free(internal_config.user_mbuf_pool_ops_name);
+
+				internal_config.user_mbuf_pool_ops_name =
+						ops_name;
+			}
 			break;
-
+		}
 		case OPT_MATCH_ALLOCATIONS_NUM:
 			internal_config.match_allocations = 1;
 			break;
@@ -1238,6 +1267,7 @@ rte_eal_cleanup(void)
 		rte_memseg_walk(mark_freeable, NULL);
 	rte_service_finalize();
 	rte_mp_channel_cleanup();
+	eal_cleanup_config(&internal_config);
 	return 0;
 }
 
diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c
index 7d922a965..1b96b576e 100644
--- a/lib/librte_eal/linuxapp/eal/eal_memory.c
+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
@@ -438,7 +438,7 @@ find_numasocket(struct hugepage_file *hugepg_tbl, struct hugepage_info *hpi)
 	}
 
 	snprintf(hugedir_str, sizeof(hugedir_str),
-			"%s/%s", hpi->hugedir, internal_config.hugefile_prefix);
+			"%s/%s", hpi->hugedir, eal_get_hugefile_prefix());
 
 	/* parse numa map */
 	while (fgets(buf, sizeof(buf), f) != NULL) {
-- 
2.11.0

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [dpdk-stable] please check if patch 'net/cxgbe: fix macros related to logs for Windows' is applicable to LTS release 17.11.6
  2019-03-08 18:08 [dpdk-stable] please check if patch 'eal: fix strdup usages in internal config' is applicable to LTS release 17.11.6 Yongseok Koh
@ 2019-03-08 18:09 ` Yongseok Koh
  2019-03-10 10:13   ` Rahul Lakkireddy
  2019-03-08 18:09 ` [dpdk-stable] please check if patch 'net/cxgbe: fix other misc build issues " Yongseok Koh
  2019-03-11 10:08 ` [dpdk-stable] please check if patch 'eal: fix strdup usages in internal config' " Burakov, Anatoly
  2 siblings, 1 reply; 8+ messages in thread
From: Yongseok Koh @ 2019-03-08 18:09 UTC (permalink / raw)
  To: Rahul Lakkireddy; +Cc: dpdk stable

Hi,

Even though the patch doesn't have "Cc: stable@dpdk.org" tag or "Fixes:" tag,
the commit log says it fixes some issue. Tags might be mistakenly missed. We
don't want to miss any fixes for stable releases. That's why I'm sending this
email.

Please send backports if you think the patch should be merged to LTS release 17.11.6
Or, let me know if you have any comments, say, need more time, or it's worthless
to backport it. And please send it to "stable@dpdk.org", but not "dev@dpdk.org".

FYI, branch 17.11 is located at tree:
   git://dpdk.org/dpdk-stable

It'd be great if you could do that in one or two weeks. Also, please add a
heading line like below before the commit log body:
    [ backported from upstream commit xxx ]

Example: http://dpdk.org/browse/dpdk-stable/commit/?h=16.07&id=c4831394c7d1944d8ec27d52c22997f20d19718e

Also please mention the target LTS in the subject line, as we have
more than one at the same time, for example:

    [PATCH 17.11] foo/bar: fix baz

With git send-email, this can be achieved by appending the parameter:

    --subject-prefix='17.11'


Thanks.

Yongseok

---
>From b5c3a5fd577af3b91c99b0ab88748e04ff96e363 Mon Sep 17 00:00:00 2001
From: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
Date: Wed, 19 Dec 2018 21:58:24 +0530
Subject: [PATCH] net/cxgbe: fix macros related to logs for Windows

Replace "args..." with "fmt, ..." and directly use __VA_ARGS__.

This fixes following errors reported by Intel C++ compiler in Windows
build.

C:\> cxgbe_compat.h(28): error : expected a ")"
        #define dev_printf(level, fmt, args...) \
                                       ^

C:\> cxgbe_compat.h(31): error : expected a ")"
        #define dev_err(x, args...) dev_printf(ERR, args)
                           ^
[...]

Build Environment:
1. Target OS: Microsoft Windows Server 2016
2. Compiler: Intel C++ Compiler from Intel Parallel Studio XE 2019 [1]
3. Development Tools:
   3.1 Microsoft Visual Studio 2017 Professional
   3.2 Windows Software Development Kit (SDK) v10.0.17763
   3.3 Windows Driver Kit (WDK) v10.0.17763

[1] https://software.intel.com/en-us/parallel-studio-xe

Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
---
 drivers/net/cxgbe/cxgbe_compat.h | 40 ++++++++++++++++++++++------------------
 1 file changed, 22 insertions(+), 18 deletions(-)

diff --git a/drivers/net/cxgbe/cxgbe_compat.h b/drivers/net/cxgbe/cxgbe_compat.h
index 5d47c5f3d..ce4662d54 100644
--- a/drivers/net/cxgbe/cxgbe_compat.h
+++ b/drivers/net/cxgbe/cxgbe_compat.h
@@ -19,41 +19,45 @@
 #include <rte_log.h>
 #include <rte_io.h>
 
-#define dev_printf(level, fmt, args...) \
-	RTE_LOG(level, PMD, "rte_cxgbe_pmd: " fmt, ## args)
+#define dev_printf(level, fmt, ...) \
+	RTE_LOG(level, PMD, "rte_cxgbe_pmd: " fmt, ##__VA_ARGS__)
 
-#define dev_err(x, args...) dev_printf(ERR, args)
-#define dev_info(x, args...) dev_printf(INFO, args)
-#define dev_warn(x, args...) dev_printf(WARNING, args)
+#define dev_err(x, fmt, ...) dev_printf(ERR, fmt, ##__VA_ARGS__)
+#define dev_info(x, fmt, ...) dev_printf(INFO, fmt, ##__VA_ARGS__)
+#define dev_warn(x, fmt, ...) dev_printf(WARNING, fmt, ##__VA_ARGS__)
 
 #ifdef RTE_LIBRTE_CXGBE_DEBUG
-#define dev_debug(x, args...) dev_printf(DEBUG, args)
+#define dev_debug(x, fmt, ...) dev_printf(INFO, fmt, ##__VA_ARGS__)
 #else
-#define dev_debug(x, args...) do { } while (0)
+#define dev_debug(x, fmt, ...) do { } while (0)
 #endif
 
 #ifdef RTE_LIBRTE_CXGBE_DEBUG_REG
-#define CXGBE_DEBUG_REG(x, args...) dev_printf(DEBUG, "REG:" args)
+#define CXGBE_DEBUG_REG(x, fmt, ...) \
+	dev_printf(INFO, "REG:" fmt, ##__VA_ARGS__)
 #else
-#define CXGBE_DEBUG_REG(x, args...) do { } while (0)
+#define CXGBE_DEBUG_REG(x, fmt, ...) do { } while (0)
 #endif
 
 #ifdef RTE_LIBRTE_CXGBE_DEBUG_MBOX
-#define CXGBE_DEBUG_MBOX(x, args...) dev_printf(DEBUG, "MBOX:" args)
+#define CXGBE_DEBUG_MBOX(x, fmt, ...) \
+	dev_printf(INFO, "MBOX:" fmt, ##__VA_ARGS__)
 #else
-#define CXGBE_DEBUG_MBOX(x, args...) do { } while (0)
+#define CXGBE_DEBUG_MBOX(x, fmt, ...) do { } while (0)
 #endif
 
 #ifdef RTE_LIBRTE_CXGBE_DEBUG_TX
-#define CXGBE_DEBUG_TX(x, args...) dev_printf(DEBUG, "TX:" args)
+#define CXGBE_DEBUG_TX(x, fmt, ...) \
+	dev_printf(INFO, "TX:" fmt, ##__VA_ARGS__)
 #else
-#define CXGBE_DEBUG_TX(x, args...) do { } while (0)
+#define CXGBE_DEBUG_TX(x, fmt, ...) do { } while (0)
 #endif
 
 #ifdef RTE_LIBRTE_CXGBE_DEBUG_RX
-#define CXGBE_DEBUG_RX(x, args...) dev_printf(DEBUG, "RX:" args)
+#define CXGBE_DEBUG_RX(x, fmt, ...) \
+	dev_printf(INFO, "RX:" fmt, ##__VA_ARGS__)
 #else
-#define CXGBE_DEBUG_RX(x, args...) do { } while (0)
+#define CXGBE_DEBUG_RX(x, fmt, ...) do { } while (0)
 #endif
 
 #ifdef RTE_LIBRTE_CXGBE_DEBUG
@@ -63,9 +67,9 @@
 #define CXGBE_FUNC_TRACE() do { } while (0)
 #endif
 
-#define pr_err(y, args...) dev_err(0, y, ##args)
-#define pr_warn(y, args...) dev_warn(0, y, ##args)
-#define pr_info(y, args...) dev_info(0, y, ##args)
+#define pr_err(fmt, ...) dev_err(0, fmt, ##__VA_ARGS__)
+#define pr_warn(fmt, ...) dev_warn(0, fmt, ##__VA_ARGS__)
+#define pr_info(fmt, ...) dev_info(0, fmt, ##__VA_ARGS__)
 #define BUG() pr_err("BUG at %s:%d", __func__, __LINE__)
 
 #define ASSERT(x) do {\
-- 
2.11.0

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [dpdk-stable] please check if patch 'net/cxgbe: fix other misc build issues for Windows' is applicable to LTS release 17.11.6
  2019-03-08 18:08 [dpdk-stable] please check if patch 'eal: fix strdup usages in internal config' is applicable to LTS release 17.11.6 Yongseok Koh
  2019-03-08 18:09 ` [dpdk-stable] please check if patch 'net/cxgbe: fix macros related to logs for Windows' " Yongseok Koh
@ 2019-03-08 18:09 ` Yongseok Koh
  2019-03-10 10:13   ` Rahul Lakkireddy
  2019-03-11 10:08 ` [dpdk-stable] please check if patch 'eal: fix strdup usages in internal config' " Burakov, Anatoly
  2 siblings, 1 reply; 8+ messages in thread
From: Yongseok Koh @ 2019-03-08 18:09 UTC (permalink / raw)
  To: Rahul Lakkireddy; +Cc: dpdk stable

Hi,

Even though the patch doesn't have "Cc: stable@dpdk.org" tag or "Fixes:" tag,
the commit log says it fixes some issue. Tags might be mistakenly missed. We
don't want to miss any fixes for stable releases. That's why I'm sending this
email.

Please send backports if you think the patch should be merged to LTS release 17.11.6
Or, let me know if you have any comments, say, need more time, or it's worthless
to backport it. And please send it to "stable@dpdk.org", but not "dev@dpdk.org".

FYI, branch 17.11 is located at tree:
   git://dpdk.org/dpdk-stable

It'd be great if you could do that in one or two weeks. Also, please add a
heading line like below before the commit log body:
    [ backported from upstream commit xxx ]

Example: http://dpdk.org/browse/dpdk-stable/commit/?h=16.07&id=c4831394c7d1944d8ec27d52c22997f20d19718e

Also please mention the target LTS in the subject line, as we have
more than one at the same time, for example:

    [PATCH 17.11] foo/bar: fix baz

With git send-email, this can be achieved by appending the parameter:

    --subject-prefix='17.11'


Thanks.

Yongseok

---
>From fdd552100626750096235eca5c9ecfd2c627dac8 Mon Sep 17 00:00:00 2001
From: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
Date: Wed, 19 Dec 2018 21:58:26 +0530
Subject: [PATCH] net/cxgbe: fix other misc build issues for Windows

Fix following build errors reported by Intel C++ compiler in Windows
build.

C:\> t4_hw.c(5105): warning #147: declaration is incompatible with
"int t4_bar2_sge_qregs(struct adapter *, unsigned int, unsigned int,
u64={uint64_t={unsigned __int64}} *, unsigned int *)"
(declared at line 524 of "..\..\..\..\drivers\net\cxgbe\base\common.h")
    int t4_bar2_sge_qregs(struct adapter *adapter, unsigned int qid,
        ^

C:\> cxgbe_filter.c(42): error : expected an expression
        n_user_filters = mult_frac(adap->tids.nftids,
                         ^

C:\> sge.c(400): error : expression must be a pointer to a complete
object type
                  (uint16_t)(RTE_PTR_ALIGN((char *)mbuf->buf_addr +
                             ^

Build Environment:
1. Target OS: Microsoft Windows Server 2016
2. Compiler: Intel C++ Compiler from Intel Parallel Studio XE 2019 [1]
3. Development Tools:
   3.1 Microsoft Visual Studio 2017 Professional
   3.2 Windows Software Development Kit (SDK) v10.0.17763
   3.3 Windows Driver Kit (WDK) v10.0.17763

[1] https://software.intel.com/en-us/parallel-studio-xe

Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
---
 drivers/net/cxgbe/base/common.h  |  2 +-
 drivers/net/cxgbe/cxgbe_compat.h | 14 +++++++-------
 drivers/net/cxgbe/sge.c          |  3 ++-
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/net/cxgbe/base/common.h b/drivers/net/cxgbe/base/common.h
index 84311fc95..973d4d7dd 100644
--- a/drivers/net/cxgbe/base/common.h
+++ b/drivers/net/cxgbe/base/common.h
@@ -522,7 +522,7 @@ void t4_read_rss_key(struct adapter *adap, u32 *key);
 
 enum t4_bar2_qtype { T4_BAR2_QTYPE_EGRESS, T4_BAR2_QTYPE_INGRESS };
 int t4_bar2_sge_qregs(struct adapter *adapter, unsigned int qid,
-		      unsigned int qtype, u64 *pbar2_qoffset,
+		      enum t4_bar2_qtype qtype, u64 *pbar2_qoffset,
 		      unsigned int *pbar2_qid);
 
 int t4_init_sge_params(struct adapter *adapter);
diff --git a/drivers/net/cxgbe/cxgbe_compat.h b/drivers/net/cxgbe/cxgbe_compat.h
index 686ca6e0a..edc8ea57d 100644
--- a/drivers/net/cxgbe/cxgbe_compat.h
+++ b/drivers/net/cxgbe/cxgbe_compat.h
@@ -276,12 +276,12 @@ static inline void writel_relaxed(unsigned int val, volatile void __iomem *addr)
  * Multiplies an integer by a fraction, while avoiding unnecessary
  * overflow or loss of precision.
  */
-#define mult_frac(x, numer, denom)(                     \
-{                                                       \
-	typeof(x) quot = (x) / (denom);                 \
-	typeof(x) rem  = (x) % (denom);                 \
-	(quot * (numer)) + ((rem * (numer)) / (denom)); \
-}                                                       \
-)
+static inline unsigned int mult_frac(unsigned int x, unsigned int numer,
+				     unsigned int denom)
+{
+	unsigned int quot = x / denom;
+	unsigned int rem = x % denom;
 
+	return (quot * numer) + ((rem * numer) / denom);
+}
 #endif /* _CXGBE_COMPAT_H_ */
diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c
index bf0afb138..673c4fbb3 100644
--- a/drivers/net/cxgbe/sge.c
+++ b/drivers/net/cxgbe/sge.c
@@ -397,7 +397,8 @@ static unsigned int refill_fl_usembufs(struct adapter *adap, struct sge_fl *q,
 
 		rte_mbuf_refcnt_set(mbuf, 1);
 		mbuf->data_off =
-			(uint16_t)(RTE_PTR_ALIGN((char *)mbuf->buf_addr +
+			(uint16_t)((char *)
+				   RTE_PTR_ALIGN((char *)mbuf->buf_addr +
 						 RTE_PKTMBUF_HEADROOM,
 						 adap->sge.fl_align) -
 				   (char *)mbuf->buf_addr);
-- 
2.11.0

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [dpdk-stable] please check if patch 'net/cxgbe: fix macros related to logs for Windows' is applicable to LTS release 17.11.6
  2019-03-08 18:09 ` [dpdk-stable] please check if patch 'net/cxgbe: fix macros related to logs for Windows' " Yongseok Koh
@ 2019-03-10 10:13   ` Rahul Lakkireddy
  0 siblings, 0 replies; 8+ messages in thread
From: Rahul Lakkireddy @ 2019-03-10 10:13 UTC (permalink / raw)
  To: Yongseok Koh; +Cc: dpdk stable

On Friday, March 03/08/19, 2019 at 23:39:00 +0530, Yongseok Koh wrote:
> Hi,
> 
> Even though the patch doesn't have "Cc: stable@dpdk.org" tag or "Fixes:" tag,
> the commit log says it fixes some issue. Tags might be mistakenly missed. We
> don't want to miss any fixes for stable releases. That's why I'm sending this
> email.
> 
> Please send backports if you think the patch should be merged to LTS release 17.11.6
> Or, let me know if you have any comments, say, need more time, or it's worthless
> to backport it. And please send it to "stable@dpdk.org", but not "dev@dpdk.org".
> 
> FYI, branch 17.11 is located at tree:
>    git://dpdk.org/dpdk-stable
> 
> It'd be great if you could do that in one or two weeks. Also, please add a
> heading line like below before the commit log body:
>     [ backported from upstream commit xxx ]
> 
> Example: http://dpdk.org/browse/dpdk-stable/commit/?h=16.07&id=c4831394c7d1944d8ec27d52c22997f20d19718e
> 
> Also please mention the target LTS in the subject line, as we have
> more than one at the same time, for example:
> 
>     [PATCH 17.11] foo/bar: fix baz
> 
> With git send-email, this can be achieved by appending the parameter:
> 
>     --subject-prefix='17.11'
> 
> 
> Thanks.
> 
> Yongseok
> 

Don't backport this patch. It fixes compilation errors reported by
Intel C++ Compiler for the upcoming DPDK Windows OS support, and
hence is unnecessary to backport to older stable releases that don't
have DPDK Windows OS support.

Thanks,
Rahul

> ---
> From b5c3a5fd577af3b91c99b0ab88748e04ff96e363 Mon Sep 17 00:00:00 2001
> From: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
> Date: Wed, 19 Dec 2018 21:58:24 +0530
> Subject: [PATCH] net/cxgbe: fix macros related to logs for Windows
> 
> Replace "args..." with "fmt, ..." and directly use __VA_ARGS__.
> 
> This fixes following errors reported by Intel C++ compiler in Windows
> build.
> 
> C:\> cxgbe_compat.h(28): error : expected a ")"
>         #define dev_printf(level, fmt, args...) \
>                                        ^
> 
> C:\> cxgbe_compat.h(31): error : expected a ")"
>         #define dev_err(x, args...) dev_printf(ERR, args)
>                            ^
> [...]
> 
> Build Environment:
> 1. Target OS: Microsoft Windows Server 2016
> 2. Compiler: Intel C++ Compiler from Intel Parallel Studio XE 2019 [1]
> 3. Development Tools:
>    3.1 Microsoft Visual Studio 2017 Professional
>    3.2 Windows Software Development Kit (SDK) v10.0.17763
>    3.3 Windows Driver Kit (WDK) v10.0.17763
> 
> [1] https://software.intel.com/en-us/parallel-studio-xe
> 
> Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
> ---
>  drivers/net/cxgbe/cxgbe_compat.h | 40 ++++++++++++++++++++++------------------
>  1 file changed, 22 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/net/cxgbe/cxgbe_compat.h b/drivers/net/cxgbe/cxgbe_compat.h
> index 5d47c5f3d..ce4662d54 100644
> --- a/drivers/net/cxgbe/cxgbe_compat.h
> +++ b/drivers/net/cxgbe/cxgbe_compat.h
> @@ -19,41 +19,45 @@
>  #include <rte_log.h>
>  #include <rte_io.h>
>  
> -#define dev_printf(level, fmt, args...) \
> -	RTE_LOG(level, PMD, "rte_cxgbe_pmd: " fmt, ## args)
> +#define dev_printf(level, fmt, ...) \
> +	RTE_LOG(level, PMD, "rte_cxgbe_pmd: " fmt, ##__VA_ARGS__)
>  
> -#define dev_err(x, args...) dev_printf(ERR, args)
> -#define dev_info(x, args...) dev_printf(INFO, args)
> -#define dev_warn(x, args...) dev_printf(WARNING, args)
> +#define dev_err(x, fmt, ...) dev_printf(ERR, fmt, ##__VA_ARGS__)
> +#define dev_info(x, fmt, ...) dev_printf(INFO, fmt, ##__VA_ARGS__)
> +#define dev_warn(x, fmt, ...) dev_printf(WARNING, fmt, ##__VA_ARGS__)
>  
>  #ifdef RTE_LIBRTE_CXGBE_DEBUG
> -#define dev_debug(x, args...) dev_printf(DEBUG, args)
> +#define dev_debug(x, fmt, ...) dev_printf(INFO, fmt, ##__VA_ARGS__)
>  #else
> -#define dev_debug(x, args...) do { } while (0)
> +#define dev_debug(x, fmt, ...) do { } while (0)
>  #endif
>  
>  #ifdef RTE_LIBRTE_CXGBE_DEBUG_REG
> -#define CXGBE_DEBUG_REG(x, args...) dev_printf(DEBUG, "REG:" args)
> +#define CXGBE_DEBUG_REG(x, fmt, ...) \
> +	dev_printf(INFO, "REG:" fmt, ##__VA_ARGS__)
>  #else
> -#define CXGBE_DEBUG_REG(x, args...) do { } while (0)
> +#define CXGBE_DEBUG_REG(x, fmt, ...) do { } while (0)
>  #endif
>  
>  #ifdef RTE_LIBRTE_CXGBE_DEBUG_MBOX
> -#define CXGBE_DEBUG_MBOX(x, args...) dev_printf(DEBUG, "MBOX:" args)
> +#define CXGBE_DEBUG_MBOX(x, fmt, ...) \
> +	dev_printf(INFO, "MBOX:" fmt, ##__VA_ARGS__)
>  #else
> -#define CXGBE_DEBUG_MBOX(x, args...) do { } while (0)
> +#define CXGBE_DEBUG_MBOX(x, fmt, ...) do { } while (0)
>  #endif
>  
>  #ifdef RTE_LIBRTE_CXGBE_DEBUG_TX
> -#define CXGBE_DEBUG_TX(x, args...) dev_printf(DEBUG, "TX:" args)
> +#define CXGBE_DEBUG_TX(x, fmt, ...) \
> +	dev_printf(INFO, "TX:" fmt, ##__VA_ARGS__)
>  #else
> -#define CXGBE_DEBUG_TX(x, args...) do { } while (0)
> +#define CXGBE_DEBUG_TX(x, fmt, ...) do { } while (0)
>  #endif
>  
>  #ifdef RTE_LIBRTE_CXGBE_DEBUG_RX
> -#define CXGBE_DEBUG_RX(x, args...) dev_printf(DEBUG, "RX:" args)
> +#define CXGBE_DEBUG_RX(x, fmt, ...) \
> +	dev_printf(INFO, "RX:" fmt, ##__VA_ARGS__)
>  #else
> -#define CXGBE_DEBUG_RX(x, args...) do { } while (0)
> +#define CXGBE_DEBUG_RX(x, fmt, ...) do { } while (0)
>  #endif
>  
>  #ifdef RTE_LIBRTE_CXGBE_DEBUG
> @@ -63,9 +67,9 @@
>  #define CXGBE_FUNC_TRACE() do { } while (0)
>  #endif
>  
> -#define pr_err(y, args...) dev_err(0, y, ##args)
> -#define pr_warn(y, args...) dev_warn(0, y, ##args)
> -#define pr_info(y, args...) dev_info(0, y, ##args)
> +#define pr_err(fmt, ...) dev_err(0, fmt, ##__VA_ARGS__)
> +#define pr_warn(fmt, ...) dev_warn(0, fmt, ##__VA_ARGS__)
> +#define pr_info(fmt, ...) dev_info(0, fmt, ##__VA_ARGS__)
>  #define BUG() pr_err("BUG at %s:%d", __func__, __LINE__)
>  
>  #define ASSERT(x) do {\
> -- 
> 2.11.0
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [dpdk-stable] please check if patch 'net/cxgbe: fix other misc build issues for Windows' is applicable to LTS release 17.11.6
  2019-03-08 18:09 ` [dpdk-stable] please check if patch 'net/cxgbe: fix other misc build issues " Yongseok Koh
@ 2019-03-10 10:13   ` Rahul Lakkireddy
  2019-03-12 21:28     ` Yongseok Koh
  0 siblings, 1 reply; 8+ messages in thread
From: Rahul Lakkireddy @ 2019-03-10 10:13 UTC (permalink / raw)
  To: Yongseok Koh; +Cc: dpdk stable

On Friday, March 03/08/19, 2019 at 23:39:01 +0530, Yongseok Koh wrote:
> Hi,
> 
> Even though the patch doesn't have "Cc: stable@dpdk.org" tag or "Fixes:" tag,
> the commit log says it fixes some issue. Tags might be mistakenly missed. We
> don't want to miss any fixes for stable releases. That's why I'm sending this
> email.
> 
> Please send backports if you think the patch should be merged to LTS release 17.11.6
> Or, let me know if you have any comments, say, need more time, or it's worthless
> to backport it. And please send it to "stable@dpdk.org", but not "dev@dpdk.org".
> 
> FYI, branch 17.11 is located at tree:
>    git://dpdk.org/dpdk-stable
> 
> It'd be great if you could do that in one or two weeks. Also, please add a
> heading line like below before the commit log body:
>     [ backported from upstream commit xxx ]
> 
> Example: http://dpdk.org/browse/dpdk-stable/commit/?h=16.07&id=c4831394c7d1944d8ec27d52c22997f20d19718e
> 
> Also please mention the target LTS in the subject line, as we have
> more than one at the same time, for example:
> 
>     [PATCH 17.11] foo/bar: fix baz
> 
> With git send-email, this can be achieved by appending the parameter:
> 
>     --subject-prefix='17.11'
> 
> 
> Thanks.
> 
> Yongseok
> 

Don't backport this patch. It fixes compilation errors reported by
Intel C++ Compiler for the upcoming DPDK Windows OS support, and
hence is unnecessary to backport to older stable releases that don't
have DPDK Windows OS support.

Thanks,
Rahul

> ---
> From fdd552100626750096235eca5c9ecfd2c627dac8 Mon Sep 17 00:00:00 2001
> From: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
> Date: Wed, 19 Dec 2018 21:58:26 +0530
> Subject: [PATCH] net/cxgbe: fix other misc build issues for Windows
> 
> Fix following build errors reported by Intel C++ compiler in Windows
> build.
> 
> C:\> t4_hw.c(5105): warning #147: declaration is incompatible with
> "int t4_bar2_sge_qregs(struct adapter *, unsigned int, unsigned int,
> u64={uint64_t={unsigned __int64}} *, unsigned int *)"
> (declared at line 524 of "..\..\..\..\drivers\net\cxgbe\base\common.h")
>     int t4_bar2_sge_qregs(struct adapter *adapter, unsigned int qid,
>         ^
> 
> C:\> cxgbe_filter.c(42): error : expected an expression
>         n_user_filters = mult_frac(adap->tids.nftids,
>                          ^
> 
> C:\> sge.c(400): error : expression must be a pointer to a complete
> object type
>                   (uint16_t)(RTE_PTR_ALIGN((char *)mbuf->buf_addr +
>                              ^
> 
> Build Environment:
> 1. Target OS: Microsoft Windows Server 2016
> 2. Compiler: Intel C++ Compiler from Intel Parallel Studio XE 2019 [1]
> 3. Development Tools:
>    3.1 Microsoft Visual Studio 2017 Professional
>    3.2 Windows Software Development Kit (SDK) v10.0.17763
>    3.3 Windows Driver Kit (WDK) v10.0.17763
> 
> [1] https://software.intel.com/en-us/parallel-studio-xe
> 
> Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
> ---
>  drivers/net/cxgbe/base/common.h  |  2 +-
>  drivers/net/cxgbe/cxgbe_compat.h | 14 +++++++-------
>  drivers/net/cxgbe/sge.c          |  3 ++-
>  3 files changed, 10 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/net/cxgbe/base/common.h b/drivers/net/cxgbe/base/common.h
> index 84311fc95..973d4d7dd 100644
> --- a/drivers/net/cxgbe/base/common.h
> +++ b/drivers/net/cxgbe/base/common.h
> @@ -522,7 +522,7 @@ void t4_read_rss_key(struct adapter *adap, u32 *key);
>  
>  enum t4_bar2_qtype { T4_BAR2_QTYPE_EGRESS, T4_BAR2_QTYPE_INGRESS };
>  int t4_bar2_sge_qregs(struct adapter *adapter, unsigned int qid,
> -		      unsigned int qtype, u64 *pbar2_qoffset,
> +		      enum t4_bar2_qtype qtype, u64 *pbar2_qoffset,
>  		      unsigned int *pbar2_qid);
>  
>  int t4_init_sge_params(struct adapter *adapter);
> diff --git a/drivers/net/cxgbe/cxgbe_compat.h b/drivers/net/cxgbe/cxgbe_compat.h
> index 686ca6e0a..edc8ea57d 100644
> --- a/drivers/net/cxgbe/cxgbe_compat.h
> +++ b/drivers/net/cxgbe/cxgbe_compat.h
> @@ -276,12 +276,12 @@ static inline void writel_relaxed(unsigned int val, volatile void __iomem *addr)
>   * Multiplies an integer by a fraction, while avoiding unnecessary
>   * overflow or loss of precision.
>   */
> -#define mult_frac(x, numer, denom)(                     \
> -{                                                       \
> -	typeof(x) quot = (x) / (denom);                 \
> -	typeof(x) rem  = (x) % (denom);                 \
> -	(quot * (numer)) + ((rem * (numer)) / (denom)); \
> -}                                                       \
> -)
> +static inline unsigned int mult_frac(unsigned int x, unsigned int numer,
> +				     unsigned int denom)
> +{
> +	unsigned int quot = x / denom;
> +	unsigned int rem = x % denom;
>  
> +	return (quot * numer) + ((rem * numer) / denom);
> +}
>  #endif /* _CXGBE_COMPAT_H_ */
> diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c
> index bf0afb138..673c4fbb3 100644
> --- a/drivers/net/cxgbe/sge.c
> +++ b/drivers/net/cxgbe/sge.c
> @@ -397,7 +397,8 @@ static unsigned int refill_fl_usembufs(struct adapter *adap, struct sge_fl *q,
>  
>  		rte_mbuf_refcnt_set(mbuf, 1);
>  		mbuf->data_off =
> -			(uint16_t)(RTE_PTR_ALIGN((char *)mbuf->buf_addr +
> +			(uint16_t)((char *)
> +				   RTE_PTR_ALIGN((char *)mbuf->buf_addr +
>  						 RTE_PKTMBUF_HEADROOM,
>  						 adap->sge.fl_align) -
>  				   (char *)mbuf->buf_addr);
> -- 
> 2.11.0
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [dpdk-stable] please check if patch 'eal: fix strdup usages in internal config' is applicable to LTS release 17.11.6
  2019-03-08 18:08 [dpdk-stable] please check if patch 'eal: fix strdup usages in internal config' is applicable to LTS release 17.11.6 Yongseok Koh
  2019-03-08 18:09 ` [dpdk-stable] please check if patch 'net/cxgbe: fix macros related to logs for Windows' " Yongseok Koh
  2019-03-08 18:09 ` [dpdk-stable] please check if patch 'net/cxgbe: fix other misc build issues " Yongseok Koh
@ 2019-03-11 10:08 ` Burakov, Anatoly
  2019-03-12 21:43   ` Yongseok Koh
  2 siblings, 1 reply; 8+ messages in thread
From: Burakov, Anatoly @ 2019-03-11 10:08 UTC (permalink / raw)
  To: Yongseok Koh; +Cc: dpdk stable

It's not a critical bugfix, so it can be left out of it is deemed too much change for a stable release. However, it is indeed applicable to stable, and can be merged.

Thanks,
Anatoly


> -----Original Message-----
> From: Yongseok Koh [mailto:yskoh@mellanox.com]
> Sent: Friday, March 8, 2019 6:09 PM
> To: Burakov, Anatoly <anatoly.burakov@intel.com>
> Cc: dpdk stable <stable@dpdk.org>
> Subject: please check if patch 'eal: fix strdup usages in internal config' is
> applicable to LTS release 17.11.6
> 
> Hi,
> 
> Even though the patch doesn't have "Cc: stable@dpdk.org" tag or "Fixes:"
> tag, the commit log says it fixes some issue. Tags might be mistakenly missed.
> We don't want to miss any fixes for stable releases. That's why I'm sending
> this email.
> 
> Please send backports if you think the patch should be merged to LTS release
> 17.11.6 Or, let me know if you have any comments, say, need more time, or
> it's worthless to backport it. And please send it to "stable@dpdk.org", but
> not "dev@dpdk.org".
> 
> FYI, branch 17.11 is located at tree:
>    git://dpdk.org/dpdk-stable
> 
> It'd be great if you could do that in one or two weeks. Also, please add a
> heading line like below before the commit log body:
>     [ backported from upstream commit xxx ]
> 
> Example: http://dpdk.org/browse/dpdk-
> stable/commit/?h=16.07&id=c4831394c7d1944d8ec27d52c22997f20d19718e
> 
> Also please mention the target LTS in the subject line, as we have more than
> one at the same time, for example:
> 
>     [PATCH 17.11] foo/bar: fix baz
> 
> With git send-email, this can be achieved by appending the parameter:
> 
>     --subject-prefix='17.11'
> 
> 
> Thanks.
> 
> Yongseok
> 
> ---
> From 66d9f61de0885bd07662a016542600fe139d4eed Mon Sep 17 00:00:00
> 2001
> From: Anatoly Burakov <anatoly.burakov@intel.com>
> Date: Thu, 10 Jan 2019 13:38:59 +0000
> Subject: [PATCH] eal: fix strdup usages in internal config
> 
> Currently, we use strdup in a few places to store command-line parameter
> values for certain internal config values. There are several issues with that.
> 
> First of all, they're never freed, so memory ends up leaking either after EAL
> exit, or when these command-line options are supplied multiple times.
> 
> Second of all, they're defined as `const char *`, so they
> *cannot* be freed even if we wanted to.
> 
> Finally, strdup may return NULL, which will be stored in the config. For most
> fields, NULL is a valid value, but for the default prefix, the value is always
> expected to be valid.
> 
> To fix all of this, three things are done. First, we change the definitions of
> these values to `char *` as opposed to `const char *`. This does not break the
> ABI, and previous code assumes constness (which is more restrictive), so it's
> safe to do so.
> 
> Then, fix all usages of strdup to check return value, and add a cleanup
> function that will free the memory occupied by these strings, as well as
> freeing them before assigning a new value to prevent leaks when parameter
> is specified multiple times.
> 
> And finally, add an internal API to query hugefile prefix, so that, absent of a
> valid value, a default value will be returned, and also fix up all usages of
> hugefile prefix to use this API instead of accessing hugefile prefix directly.
> 
> Bugzilla ID: 108
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---
>  lib/librte_eal/bsdapp/eal/eal.c            | 19 ++++++++++--
>  lib/librte_eal/common/eal_common_options.c | 25 ++++++++++++++--
>  lib/librte_eal/common/eal_filesystem.h     |  6 +++-
>  lib/librte_eal/common/eal_internal_cfg.h   |  6 ++--
>  lib/librte_eal/common/eal_options.h        |  1 +
>  lib/librte_eal/linuxapp/eal/eal.c          | 46 ++++++++++++++++++++++++----
> --
>  lib/librte_eal/linuxapp/eal/eal_memory.c   |  2 +-
>  7 files changed, 87 insertions(+), 18 deletions(-)
> 
> diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
> index c8e0da097..1ba9bd7cf 100644
> --- a/lib/librte_eal/bsdapp/eal/eal.c
> +++ b/lib/librte_eal/bsdapp/eal/eal.c
> @@ -117,7 +117,7 @@ eal_create_runtime_dir(void)
> 
>  	/* create prefix-specific subdirectory under DPDK runtime dir */
>  	ret = snprintf(runtime_dir, sizeof(runtime_dir), "%s/%s",
> -			tmp, internal_config.hugefile_prefix);
> +			tmp, eal_get_hugefile_prefix());
>  	if (ret < 0 || ret == sizeof(runtime_dir)) {
>  		RTE_LOG(ERR, EAL, "Error creating prefix-specific runtime
> path name\n");
>  		return -1;
> @@ -535,9 +535,21 @@ eal_parse_args(int argc, char **argv)
> 
>  		switch (opt) {
>  		case OPT_MBUF_POOL_OPS_NAME_NUM:
> -			internal_config.user_mbuf_pool_ops_name =
> -			    strdup(optarg);
> +		{
> +			char *ops_name = strdup(optarg);
> +			if (ops_name == NULL)
> +				RTE_LOG(ERR, EAL, "Could not store mbuf
> pool ops name\n");
> +			else {
> +				/* free old ops name */
> +				if
> (internal_config.user_mbuf_pool_ops_name !=
> +						NULL)
> +
> 	free(internal_config.user_mbuf_pool_ops_name);
> +
> +				internal_config.user_mbuf_pool_ops_name
> =
> +						ops_name;
> +			}
>  			break;
> +		}
>  		case 'h':
>  			eal_usage(prgname);
>  			exit(EXIT_SUCCESS);
> @@ -923,6 +935,7 @@ rte_eal_cleanup(void)  {
>  	rte_service_finalize();
>  	rte_mp_channel_cleanup();
> +	eal_cleanup_config(&internal_config);
>  	return 0;
>  }
> 
> diff --git a/lib/librte_eal/common/eal_common_options.c
> b/lib/librte_eal/common/eal_common_options.c
> index 6e3a83b98..a2d862b5f 100644
> --- a/lib/librte_eal/common/eal_common_options.c
> +++ b/lib/librte_eal/common/eal_common_options.c
> @@ -169,6 +169,14 @@ eal_option_device_parse(void)
>  	return ret;
>  }
> 
> +const char *
> +eal_get_hugefile_prefix(void)
> +{
> +	if (internal_config.hugefile_prefix != NULL)
> +		return internal_config.hugefile_prefix;
> +	return HUGEFILE_PREFIX_DEFAULT;
> +}
> +
>  void
>  eal_reset_internal_config(struct internal_config *internal_cfg)  { @@ -177,7
> +185,7 @@ eal_reset_internal_config(struct internal_config *internal_cfg)
>  	internal_cfg->memory = 0;
>  	internal_cfg->force_nrank = 0;
>  	internal_cfg->force_nchannel = 0;
> -	internal_cfg->hugefile_prefix = HUGEFILE_PREFIX_DEFAULT;
> +	internal_cfg->hugefile_prefix = NULL;
>  	internal_cfg->hugepage_dir = NULL;
>  	internal_cfg->force_sockets = 0;
>  	/* zero out the NUMA config */
> @@ -1348,6 +1356,19 @@ eal_auto_detect_cores(struct rte_config *cfg)  }
> 
>  int
> +eal_cleanup_config(struct internal_config *internal_cfg) {
> +	if (internal_cfg->hugefile_prefix != NULL)
> +		free(internal_cfg->hugefile_prefix);
> +	if (internal_cfg->hugepage_dir != NULL)
> +		free(internal_cfg->hugepage_dir);
> +	if (internal_cfg->user_mbuf_pool_ops_name != NULL)
> +		free(internal_cfg->user_mbuf_pool_ops_name);
> +
> +	return 0;
> +}
> +
> +int
>  eal_adjust_config(struct internal_config *internal_cfg)  {
>  	int i;
> @@ -1387,7 +1408,7 @@ eal_check_common_options(struct internal_config
> *internal_cfg)
>  		RTE_LOG(ERR, EAL, "Invalid process type specified\n");
>  		return -1;
>  	}
> -	if (index(internal_cfg->hugefile_prefix, '%') != NULL) {
> +	if (index(eal_get_hugefile_prefix(), '%') != NULL) {
>  		RTE_LOG(ERR, EAL, "Invalid char, '%%', in --
> "OPT_FILE_PREFIX" "
>  			"option\n");
>  		return -1;
> diff --git a/lib/librte_eal/common/eal_filesystem.h
> b/lib/librte_eal/common/eal_filesystem.h
> index 64a028db7..89a3added 100644
> --- a/lib/librte_eal/common/eal_filesystem.h
> +++ b/lib/librte_eal/common/eal_filesystem.h
> @@ -28,6 +28,10 @@ eal_create_runtime_dir(void);  int
> eal_clean_runtime_dir(void);
> 
> +/** Function to return hugefile prefix that's currently set up */ const
> +char * eal_get_hugefile_prefix(void);
> +
>  #define RUNTIME_CONFIG_FNAME "config"
>  static inline const char *
>  eal_runtime_config_path(void)
> @@ -89,7 +93,7 @@ static inline const char *  eal_get_hugefile_path(char
> *buffer, size_t buflen, const char *hugedir, int f_id)  {
>  	snprintf(buffer, buflen, HUGEFILE_FMT, hugedir,
> -			internal_config.hugefile_prefix, f_id);
> +			eal_get_hugefile_prefix(), f_id);
>  	buffer[buflen - 1] = '\0';
>  	return buffer;
>  }
> diff --git a/lib/librte_eal/common/eal_internal_cfg.h
> b/lib/librte_eal/common/eal_internal_cfg.h
> index 98e314fef..60eaead8f 100644
> --- a/lib/librte_eal/common/eal_internal_cfg.h
> +++ b/lib/librte_eal/common/eal_internal_cfg.h
> @@ -66,9 +66,9 @@ struct internal_config {
>  	volatile int syslog_facility;	  /**< facility passed to openlog() */
>  	/** default interrupt mode for VFIO */
>  	volatile enum rte_intr_mode vfio_intr_mode;
> -	const char *hugefile_prefix;      /**< the base filename of hugetlbfs
> files */
> -	const char *hugepage_dir;         /**< specific hugetlbfs directory to
> use */
> -	const char *user_mbuf_pool_ops_name;
> +	char *hugefile_prefix;      /**< the base filename of hugetlbfs files */
> +	char *hugepage_dir;         /**< specific hugetlbfs directory to use */
> +	char *user_mbuf_pool_ops_name;
>  			/**< user defined mbuf pool ops name */
>  	unsigned num_hugepage_sizes;      /**< how many sizes on this
> system */
>  	struct hugepage_info hugepage_info[MAX_HUGEPAGE_SIZES];
> diff --git a/lib/librte_eal/common/eal_options.h
> b/lib/librte_eal/common/eal_options.h
> index 1480c5d77..58ee9ae33 100644
> --- a/lib/librte_eal/common/eal_options.h
> +++ b/lib/librte_eal/common/eal_options.h
> @@ -77,6 +77,7 @@ int eal_parse_common_option(int opt, const char
> *argv,
>  			    struct internal_config *conf);
>  int eal_option_device_parse(void);
>  int eal_adjust_config(struct internal_config *internal_cfg);
> +int eal_cleanup_config(struct internal_config *internal_cfg);
>  int eal_check_common_options(struct internal_config *internal_cfg);  void
> eal_common_usage(void);  enum rte_proc_type_t
> eal_proc_type_detect(void); diff --git a/lib/librte_eal/linuxapp/eal/eal.c
> b/lib/librte_eal/linuxapp/eal/eal.c
> index 2d8d470b8..a386829f3 100644
> --- a/lib/librte_eal/linuxapp/eal/eal.c
> +++ b/lib/librte_eal/linuxapp/eal/eal.c
> @@ -125,7 +125,7 @@ eal_create_runtime_dir(void)
> 
>  	/* create prefix-specific subdirectory under DPDK runtime dir */
>  	ret = snprintf(runtime_dir, sizeof(runtime_dir), "%s/%s",
> -			tmp, internal_config.hugefile_prefix);
> +			tmp, eal_get_hugefile_prefix());
>  	if (ret < 0 || ret == sizeof(runtime_dir)) {
>  		RTE_LOG(ERR, EAL, "Error creating prefix-specific runtime
> path name\n");
>  		return -1;
> @@ -727,13 +727,31 @@ eal_parse_args(int argc, char **argv)
>  			exit(EXIT_SUCCESS);
> 
>  		case OPT_HUGE_DIR_NUM:
> -			internal_config.hugepage_dir = strdup(optarg);
> +		{
> +			char *hdir = strdup(optarg);
> +			if (hdir == NULL)
> +				RTE_LOG(ERR, EAL, "Could not store
> hugepage directory\n");
> +			else {
> +				/* free old hugepage dir */
> +				if (internal_config.hugepage_dir != NULL)
> +					free(internal_config.hugepage_dir);
> +				internal_config.hugepage_dir = hdir;
> +			}
>  			break;
> -
> +		}
>  		case OPT_FILE_PREFIX_NUM:
> -			internal_config.hugefile_prefix = strdup(optarg);
> +		{
> +			char *prefix = strdup(optarg);
> +			if (prefix == NULL)
> +				RTE_LOG(ERR, EAL, "Could not store file
> prefix\n");
> +			else {
> +				/* free old prefix */
> +				if (internal_config.hugefile_prefix != NULL)
> +					free(internal_config.hugefile_prefix);
> +				internal_config.hugefile_prefix = prefix;
> +			}
>  			break;
> -
> +		}
>  		case OPT_SOCKET_MEM_NUM:
>  			if (eal_parse_socket_arg(optarg,
>  					internal_config.socket_mem) < 0) {
> @@ -783,10 +801,21 @@ eal_parse_args(int argc, char **argv)
>  			break;
> 
>  		case OPT_MBUF_POOL_OPS_NAME_NUM:
> -			internal_config.user_mbuf_pool_ops_name =
> -			    strdup(optarg);
> +		{
> +			char *ops_name = strdup(optarg);
> +			if (ops_name == NULL)
> +				RTE_LOG(ERR, EAL, "Could not store mbuf
> pool ops name\n");
> +			else {
> +				/* free old ops name */
> +				if
> (internal_config.user_mbuf_pool_ops_name !=
> +						NULL)
> +
> 	free(internal_config.user_mbuf_pool_ops_name);
> +
> +				internal_config.user_mbuf_pool_ops_name
> =
> +						ops_name;
> +			}
>  			break;
> -
> +		}
>  		case OPT_MATCH_ALLOCATIONS_NUM:
>  			internal_config.match_allocations = 1;
>  			break;
> @@ -1238,6 +1267,7 @@ rte_eal_cleanup(void)
>  		rte_memseg_walk(mark_freeable, NULL);
>  	rte_service_finalize();
>  	rte_mp_channel_cleanup();
> +	eal_cleanup_config(&internal_config);
>  	return 0;
>  }
> 
> diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c
> b/lib/librte_eal/linuxapp/eal/eal_memory.c
> index 7d922a965..1b96b576e 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_memory.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
> @@ -438,7 +438,7 @@ find_numasocket(struct hugepage_file *hugepg_tbl,
> struct hugepage_info *hpi)
>  	}
> 
>  	snprintf(hugedir_str, sizeof(hugedir_str),
> -			"%s/%s", hpi->hugedir,
> internal_config.hugefile_prefix);
> +			"%s/%s", hpi->hugedir, eal_get_hugefile_prefix());
> 
>  	/* parse numa map */
>  	while (fgets(buf, sizeof(buf), f) != NULL) {
> --
> 2.11.0

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [dpdk-stable] please check if patch 'net/cxgbe: fix other misc build issues for Windows' is applicable to LTS release 17.11.6
  2019-03-10 10:13   ` Rahul Lakkireddy
@ 2019-03-12 21:28     ` Yongseok Koh
  0 siblings, 0 replies; 8+ messages in thread
From: Yongseok Koh @ 2019-03-12 21:28 UTC (permalink / raw)
  To: Rahul Lakkireddy; +Cc: dpdk stable


> On Mar 10, 2019, at 3:13 AM, Rahul Lakkireddy <rahul.lakkireddy@chelsio.com> wrote:
> 
> On Friday, March 03/08/19, 2019 at 23:39:01 +0530, Yongseok Koh wrote:
>> Hi,
>> 
>> Even though the patch doesn't have "Cc: stable@dpdk.org" tag or "Fixes:" tag,
>> the commit log says it fixes some issue. Tags might be mistakenly missed. We
>> don't want to miss any fixes for stable releases. That's why I'm sending this
>> email.
>> 
>> Please send backports if you think the patch should be merged to LTS release 17.11.6
>> Or, let me know if you have any comments, say, need more time, or it's worthless
>> to backport it. And please send it to "stable@dpdk.org", but not "dev@dpdk.org".
>> 
>> FYI, branch 17.11 is located at tree:
>>   git://dpdk.org/dpdk-stable
>> 
>> It'd be great if you could do that in one or two weeks. Also, please add a
>> heading line like below before the commit log body:
>>    [ backported from upstream commit xxx ]
>> 
>> Example: https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdpdk.org%2Fbrowse%2Fdpdk-stable%2Fcommit%2F%3Fh%3D16.07%26id%3Dc4831394c7d1944d8ec27d52c22997f20d19718e&amp;data=02%7C01%7Cyskoh%40mellanox.com%7C557b5b77ae9d4d67632e08d6a5418ea6%7Ca652971c7d2e4d9ba6a4d149256f461b%7C0%7C0%7C636878098323509754&amp;sdata=sQgQqWONbvvx0sM34wJlz%2B8qiBlWmnaMdS%2FSohty%2B7E%3D&amp;reserved=0
>> 
>> Also please mention the target LTS in the subject line, as we have
>> more than one at the same time, for example:
>> 
>>    [PATCH 17.11] foo/bar: fix baz
>> 
>> With git send-email, this can be achieved by appending the parameter:
>> 
>>    --subject-prefix='17.11'
>> 
>> 
>> Thanks.
>> 
>> Yongseok
>> 
> 
> Don't backport this patch. It fixes compilation errors reported by
> Intel C++ Compiler for the upcoming DPDK Windows OS support, and
> hence is unnecessary to backport to older stable releases that don't
> have DPDK Windows OS support.

Thanks for confirming.
Yongseok

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [dpdk-stable] please check if patch 'eal: fix strdup usages in internal config' is applicable to LTS release 17.11.6
  2019-03-11 10:08 ` [dpdk-stable] please check if patch 'eal: fix strdup usages in internal config' " Burakov, Anatoly
@ 2019-03-12 21:43   ` Yongseok Koh
  0 siblings, 0 replies; 8+ messages in thread
From: Yongseok Koh @ 2019-03-12 21:43 UTC (permalink / raw)
  To: Burakov, Anatoly; +Cc: dpdk stable

Okay will not merge it then.


Thanks,
Yongseok

> On Mar 11, 2019, at 3:08 AM, Burakov, Anatoly <anatoly.burakov@intel.com> wrote:
> 
> It's not a critical bugfix, so it can be left out of it is deemed too much change for a stable release. However, it is indeed applicable to stable, and can be merged.
> 
> Thanks,
> Anatoly
> 
> 
>> -----Original Message-----
>> From: Yongseok Koh [mailto:yskoh@mellanox.com]
>> Sent: Friday, March 8, 2019 6:09 PM
>> To: Burakov, Anatoly <anatoly.burakov@intel.com>
>> Cc: dpdk stable <stable@dpdk.org>
>> Subject: please check if patch 'eal: fix strdup usages in internal config' is
>> applicable to LTS release 17.11.6
>> 
>> Hi,
>> 
>> Even though the patch doesn't have "Cc: stable@dpdk.org" tag or "Fixes:"
>> tag, the commit log says it fixes some issue. Tags might be mistakenly missed.
>> We don't want to miss any fixes for stable releases. That's why I'm sending
>> this email.
>> 
>> Please send backports if you think the patch should be merged to LTS release
>> 17.11.6 Or, let me know if you have any comments, say, need more time, or
>> it's worthless to backport it. And please send it to "stable@dpdk.org", but
>> not "dev@dpdk.org".
>> 
>> FYI, branch 17.11 is located at tree:
>>   git://dpdk.org/dpdk-stable
>> 
>> It'd be great if you could do that in one or two weeks. Also, please add a
>> heading line like below before the commit log body:
>>    [ backported from upstream commit xxx ]
>> 
>> Example: https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdpdk.org%2Fbrowse%2Fdpdk-&amp;data=02%7C01%7Cyskoh%40mellanox.com%7C3d7486372a674d3f22a108d6a60974d8%7Ca652971c7d2e4d9ba6a4d149256f461b%7C0%7C0%7C636878956887750739&amp;sdata=kYJAXumgJWJqqb%2BUSAkXdBusXo%2FEp%2FqL25txtHXH%2FHs%3D&amp;reserved=0
>> stable/commit/?h=16.07&id=c4831394c7d1944d8ec27d52c22997f20d19718e
>> 
>> Also please mention the target LTS in the subject line, as we have more than
>> one at the same time, for example:
>> 
>>    [PATCH 17.11] foo/bar: fix baz
>> 
>> With git send-email, this can be achieved by appending the parameter:
>> 
>>    --subject-prefix='17.11'
>> 
>> 
>> Thanks.
>> 
>> Yongseok
>> 
>> ---
>> From 66d9f61de0885bd07662a016542600fe139d4eed Mon Sep 17 00:00:00
>> 2001
>> From: Anatoly Burakov <anatoly.burakov@intel.com>
>> Date: Thu, 10 Jan 2019 13:38:59 +0000
>> Subject: [PATCH] eal: fix strdup usages in internal config
>> 
>> Currently, we use strdup in a few places to store command-line parameter
>> values for certain internal config values. There are several issues with that.
>> 
>> First of all, they're never freed, so memory ends up leaking either after EAL
>> exit, or when these command-line options are supplied multiple times.
>> 
>> Second of all, they're defined as `const char *`, so they
>> *cannot* be freed even if we wanted to.
>> 
>> Finally, strdup may return NULL, which will be stored in the config. For most
>> fields, NULL is a valid value, but for the default prefix, the value is always
>> expected to be valid.
>> 
>> To fix all of this, three things are done. First, we change the definitions of
>> these values to `char *` as opposed to `const char *`. This does not break the
>> ABI, and previous code assumes constness (which is more restrictive), so it's
>> safe to do so.
>> 
>> Then, fix all usages of strdup to check return value, and add a cleanup
>> function that will free the memory occupied by these strings, as well as
>> freeing them before assigning a new value to prevent leaks when parameter
>> is specified multiple times.
>> 
>> And finally, add an internal API to query hugefile prefix, so that, absent of a
>> valid value, a default value will be returned, and also fix up all usages of
>> hugefile prefix to use this API instead of accessing hugefile prefix directly.
>> 
>> Bugzilla ID: 108
>> 
>> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
>> ---
>> lib/librte_eal/bsdapp/eal/eal.c            | 19 ++++++++++--
>> lib/librte_eal/common/eal_common_options.c | 25 ++++++++++++++--
>> lib/librte_eal/common/eal_filesystem.h     |  6 +++-
>> lib/librte_eal/common/eal_internal_cfg.h   |  6 ++--
>> lib/librte_eal/common/eal_options.h        |  1 +
>> lib/librte_eal/linuxapp/eal/eal.c          | 46 ++++++++++++++++++++++++----
>> --
>> lib/librte_eal/linuxapp/eal/eal_memory.c   |  2 +-
>> 7 files changed, 87 insertions(+), 18 deletions(-)
>> 
>> diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
>> index c8e0da097..1ba9bd7cf 100644
>> --- a/lib/librte_eal/bsdapp/eal/eal.c
>> +++ b/lib/librte_eal/bsdapp/eal/eal.c
>> @@ -117,7 +117,7 @@ eal_create_runtime_dir(void)
>> 
>> 	/* create prefix-specific subdirectory under DPDK runtime dir */
>> 	ret = snprintf(runtime_dir, sizeof(runtime_dir), "%s/%s",
>> -			tmp, internal_config.hugefile_prefix);
>> +			tmp, eal_get_hugefile_prefix());
>> 	if (ret < 0 || ret == sizeof(runtime_dir)) {
>> 		RTE_LOG(ERR, EAL, "Error creating prefix-specific runtime
>> path name\n");
>> 		return -1;
>> @@ -535,9 +535,21 @@ eal_parse_args(int argc, char **argv)
>> 
>> 		switch (opt) {
>> 		case OPT_MBUF_POOL_OPS_NAME_NUM:
>> -			internal_config.user_mbuf_pool_ops_name =
>> -			    strdup(optarg);
>> +		{
>> +			char *ops_name = strdup(optarg);
>> +			if (ops_name == NULL)
>> +				RTE_LOG(ERR, EAL, "Could not store mbuf
>> pool ops name\n");
>> +			else {
>> +				/* free old ops name */
>> +				if
>> (internal_config.user_mbuf_pool_ops_name !=
>> +						NULL)
>> +
>> 	free(internal_config.user_mbuf_pool_ops_name);
>> +
>> +				internal_config.user_mbuf_pool_ops_name
>> =
>> +						ops_name;
>> +			}
>> 			break;
>> +		}
>> 		case 'h':
>> 			eal_usage(prgname);
>> 			exit(EXIT_SUCCESS);
>> @@ -923,6 +935,7 @@ rte_eal_cleanup(void)  {
>> 	rte_service_finalize();
>> 	rte_mp_channel_cleanup();
>> +	eal_cleanup_config(&internal_config);
>> 	return 0;
>> }
>> 
>> diff --git a/lib/librte_eal/common/eal_common_options.c
>> b/lib/librte_eal/common/eal_common_options.c
>> index 6e3a83b98..a2d862b5f 100644
>> --- a/lib/librte_eal/common/eal_common_options.c
>> +++ b/lib/librte_eal/common/eal_common_options.c
>> @@ -169,6 +169,14 @@ eal_option_device_parse(void)
>> 	return ret;
>> }
>> 
>> +const char *
>> +eal_get_hugefile_prefix(void)
>> +{
>> +	if (internal_config.hugefile_prefix != NULL)
>> +		return internal_config.hugefile_prefix;
>> +	return HUGEFILE_PREFIX_DEFAULT;
>> +}
>> +
>> void
>> eal_reset_internal_config(struct internal_config *internal_cfg)  { @@ -177,7
>> +185,7 @@ eal_reset_internal_config(struct internal_config *internal_cfg)
>> 	internal_cfg->memory = 0;
>> 	internal_cfg->force_nrank = 0;
>> 	internal_cfg->force_nchannel = 0;
>> -	internal_cfg->hugefile_prefix = HUGEFILE_PREFIX_DEFAULT;
>> +	internal_cfg->hugefile_prefix = NULL;
>> 	internal_cfg->hugepage_dir = NULL;
>> 	internal_cfg->force_sockets = 0;
>> 	/* zero out the NUMA config */
>> @@ -1348,6 +1356,19 @@ eal_auto_detect_cores(struct rte_config *cfg)  }
>> 
>> int
>> +eal_cleanup_config(struct internal_config *internal_cfg) {
>> +	if (internal_cfg->hugefile_prefix != NULL)
>> +		free(internal_cfg->hugefile_prefix);
>> +	if (internal_cfg->hugepage_dir != NULL)
>> +		free(internal_cfg->hugepage_dir);
>> +	if (internal_cfg->user_mbuf_pool_ops_name != NULL)
>> +		free(internal_cfg->user_mbuf_pool_ops_name);
>> +
>> +	return 0;
>> +}
>> +
>> +int
>> eal_adjust_config(struct internal_config *internal_cfg)  {
>> 	int i;
>> @@ -1387,7 +1408,7 @@ eal_check_common_options(struct internal_config
>> *internal_cfg)
>> 		RTE_LOG(ERR, EAL, "Invalid process type specified\n");
>> 		return -1;
>> 	}
>> -	if (index(internal_cfg->hugefile_prefix, '%') != NULL) {
>> +	if (index(eal_get_hugefile_prefix(), '%') != NULL) {
>> 		RTE_LOG(ERR, EAL, "Invalid char, '%%', in --
>> "OPT_FILE_PREFIX" "
>> 			"option\n");
>> 		return -1;
>> diff --git a/lib/librte_eal/common/eal_filesystem.h
>> b/lib/librte_eal/common/eal_filesystem.h
>> index 64a028db7..89a3added 100644
>> --- a/lib/librte_eal/common/eal_filesystem.h
>> +++ b/lib/librte_eal/common/eal_filesystem.h
>> @@ -28,6 +28,10 @@ eal_create_runtime_dir(void);  int
>> eal_clean_runtime_dir(void);
>> 
>> +/** Function to return hugefile prefix that's currently set up */ const
>> +char * eal_get_hugefile_prefix(void);
>> +
>> #define RUNTIME_CONFIG_FNAME "config"
>> static inline const char *
>> eal_runtime_config_path(void)
>> @@ -89,7 +93,7 @@ static inline const char *  eal_get_hugefile_path(char
>> *buffer, size_t buflen, const char *hugedir, int f_id)  {
>> 	snprintf(buffer, buflen, HUGEFILE_FMT, hugedir,
>> -			internal_config.hugefile_prefix, f_id);
>> +			eal_get_hugefile_prefix(), f_id);
>> 	buffer[buflen - 1] = '\0';
>> 	return buffer;
>> }
>> diff --git a/lib/librte_eal/common/eal_internal_cfg.h
>> b/lib/librte_eal/common/eal_internal_cfg.h
>> index 98e314fef..60eaead8f 100644
>> --- a/lib/librte_eal/common/eal_internal_cfg.h
>> +++ b/lib/librte_eal/common/eal_internal_cfg.h
>> @@ -66,9 +66,9 @@ struct internal_config {
>> 	volatile int syslog_facility;	  /**< facility passed to openlog() */
>> 	/** default interrupt mode for VFIO */
>> 	volatile enum rte_intr_mode vfio_intr_mode;
>> -	const char *hugefile_prefix;      /**< the base filename of hugetlbfs
>> files */
>> -	const char *hugepage_dir;         /**< specific hugetlbfs directory to
>> use */
>> -	const char *user_mbuf_pool_ops_name;
>> +	char *hugefile_prefix;      /**< the base filename of hugetlbfs files */
>> +	char *hugepage_dir;         /**< specific hugetlbfs directory to use */
>> +	char *user_mbuf_pool_ops_name;
>> 			/**< user defined mbuf pool ops name */
>> 	unsigned num_hugepage_sizes;      /**< how many sizes on this
>> system */
>> 	struct hugepage_info hugepage_info[MAX_HUGEPAGE_SIZES];
>> diff --git a/lib/librte_eal/common/eal_options.h
>> b/lib/librte_eal/common/eal_options.h
>> index 1480c5d77..58ee9ae33 100644
>> --- a/lib/librte_eal/common/eal_options.h
>> +++ b/lib/librte_eal/common/eal_options.h
>> @@ -77,6 +77,7 @@ int eal_parse_common_option(int opt, const char
>> *argv,
>> 			    struct internal_config *conf);
>> int eal_option_device_parse(void);
>> int eal_adjust_config(struct internal_config *internal_cfg);
>> +int eal_cleanup_config(struct internal_config *internal_cfg);
>> int eal_check_common_options(struct internal_config *internal_cfg);  void
>> eal_common_usage(void);  enum rte_proc_type_t
>> eal_proc_type_detect(void); diff --git a/lib/librte_eal/linuxapp/eal/eal.c
>> b/lib/librte_eal/linuxapp/eal/eal.c
>> index 2d8d470b8..a386829f3 100644
>> --- a/lib/librte_eal/linuxapp/eal/eal.c
>> +++ b/lib/librte_eal/linuxapp/eal/eal.c
>> @@ -125,7 +125,7 @@ eal_create_runtime_dir(void)
>> 
>> 	/* create prefix-specific subdirectory under DPDK runtime dir */
>> 	ret = snprintf(runtime_dir, sizeof(runtime_dir), "%s/%s",
>> -			tmp, internal_config.hugefile_prefix);
>> +			tmp, eal_get_hugefile_prefix());
>> 	if (ret < 0 || ret == sizeof(runtime_dir)) {
>> 		RTE_LOG(ERR, EAL, "Error creating prefix-specific runtime
>> path name\n");
>> 		return -1;
>> @@ -727,13 +727,31 @@ eal_parse_args(int argc, char **argv)
>> 			exit(EXIT_SUCCESS);
>> 
>> 		case OPT_HUGE_DIR_NUM:
>> -			internal_config.hugepage_dir = strdup(optarg);
>> +		{
>> +			char *hdir = strdup(optarg);
>> +			if (hdir == NULL)
>> +				RTE_LOG(ERR, EAL, "Could not store
>> hugepage directory\n");
>> +			else {
>> +				/* free old hugepage dir */
>> +				if (internal_config.hugepage_dir != NULL)
>> +					free(internal_config.hugepage_dir);
>> +				internal_config.hugepage_dir = hdir;
>> +			}
>> 			break;
>> -
>> +		}
>> 		case OPT_FILE_PREFIX_NUM:
>> -			internal_config.hugefile_prefix = strdup(optarg);
>> +		{
>> +			char *prefix = strdup(optarg);
>> +			if (prefix == NULL)
>> +				RTE_LOG(ERR, EAL, "Could not store file
>> prefix\n");
>> +			else {
>> +				/* free old prefix */
>> +				if (internal_config.hugefile_prefix != NULL)
>> +					free(internal_config.hugefile_prefix);
>> +				internal_config.hugefile_prefix = prefix;
>> +			}
>> 			break;
>> -
>> +		}
>> 		case OPT_SOCKET_MEM_NUM:
>> 			if (eal_parse_socket_arg(optarg,
>> 					internal_config.socket_mem) < 0) {
>> @@ -783,10 +801,21 @@ eal_parse_args(int argc, char **argv)
>> 			break;
>> 
>> 		case OPT_MBUF_POOL_OPS_NAME_NUM:
>> -			internal_config.user_mbuf_pool_ops_name =
>> -			    strdup(optarg);
>> +		{
>> +			char *ops_name = strdup(optarg);
>> +			if (ops_name == NULL)
>> +				RTE_LOG(ERR, EAL, "Could not store mbuf
>> pool ops name\n");
>> +			else {
>> +				/* free old ops name */
>> +				if
>> (internal_config.user_mbuf_pool_ops_name !=
>> +						NULL)
>> +
>> 	free(internal_config.user_mbuf_pool_ops_name);
>> +
>> +				internal_config.user_mbuf_pool_ops_name
>> =
>> +						ops_name;
>> +			}
>> 			break;
>> -
>> +		}
>> 		case OPT_MATCH_ALLOCATIONS_NUM:
>> 			internal_config.match_allocations = 1;
>> 			break;
>> @@ -1238,6 +1267,7 @@ rte_eal_cleanup(void)
>> 		rte_memseg_walk(mark_freeable, NULL);
>> 	rte_service_finalize();
>> 	rte_mp_channel_cleanup();
>> +	eal_cleanup_config(&internal_config);
>> 	return 0;
>> }
>> 
>> diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c
>> b/lib/librte_eal/linuxapp/eal/eal_memory.c
>> index 7d922a965..1b96b576e 100644
>> --- a/lib/librte_eal/linuxapp/eal/eal_memory.c
>> +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
>> @@ -438,7 +438,7 @@ find_numasocket(struct hugepage_file *hugepg_tbl,
>> struct hugepage_info *hpi)
>> 	}
>> 
>> 	snprintf(hugedir_str, sizeof(hugedir_str),
>> -			"%s/%s", hpi->hugedir,
>> internal_config.hugefile_prefix);
>> +			"%s/%s", hpi->hugedir, eal_get_hugefile_prefix());
>> 
>> 	/* parse numa map */
>> 	while (fgets(buf, sizeof(buf), f) != NULL) {
>> --
>> 2.11.0

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-03-12 21:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-08 18:08 [dpdk-stable] please check if patch 'eal: fix strdup usages in internal config' is applicable to LTS release 17.11.6 Yongseok Koh
2019-03-08 18:09 ` [dpdk-stable] please check if patch 'net/cxgbe: fix macros related to logs for Windows' " Yongseok Koh
2019-03-10 10:13   ` Rahul Lakkireddy
2019-03-08 18:09 ` [dpdk-stable] please check if patch 'net/cxgbe: fix other misc build issues " Yongseok Koh
2019-03-10 10:13   ` Rahul Lakkireddy
2019-03-12 21:28     ` Yongseok Koh
2019-03-11 10:08 ` [dpdk-stable] please check if patch 'eal: fix strdup usages in internal config' " Burakov, Anatoly
2019-03-12 21:43   ` Yongseok Koh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).