anitazha / rpms / ndctl

Forked from rpms/ndctl 2 years ago
Clone

Blame SOURCES/0163-cxl-port-Relax-port-identifier-validation.patch

e0018b
From e32631009a97e4cb72e4afb8eec09f89c3317eb9 Mon Sep 17 00:00:00 2001
e0018b
From: Dan Williams <dan.j.williams@intel.com>
e0018b
Date: Thu, 28 Apr 2022 15:10:48 -0700
e0018b
Subject: [PATCH 163/217] cxl/port: Relax port identifier validation
e0018b
e0018b
Now that util_cxl_port_filter() accepts port host identifiers it is no
e0018b
longer possible to pre-validate that the port arguments follow the "port%d"
e0018b
format. Instead, let all inputs through and warn if the filter fails to
e0018b
identify a port.
e0018b
e0018b
Link: https://lore.kernel.org/r/165118384845.1676208.7570620216888371408.stgit@dwillia2-desk3.amr.corp.intel.com
e0018b
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
e0018b
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
e0018b
---
e0018b
 cxl/port.c | 30 ++++--------------------------
e0018b
 1 file changed, 4 insertions(+), 26 deletions(-)
e0018b
e0018b
diff --git a/cxl/port.c b/cxl/port.c
e0018b
index 46a8f32..89f3916 100644
e0018b
--- a/cxl/port.c
e0018b
+++ b/cxl/port.c
e0018b
@@ -145,7 +145,6 @@ static int port_action(int argc, const char **argv, struct cxl_ctx *ctx,
e0018b
 		usage,
e0018b
 		NULL
e0018b
 	};
e0018b
-	unsigned long id;
e0018b
 
e0018b
 	log_init(&pl, "cxl port", "CXL_PORT_LOG");
e0018b
 	argc = parse_options(argc, argv, options, u, 0);
e0018b
@@ -153,31 +152,10 @@ static int port_action(int argc, const char **argv, struct cxl_ctx *ctx,
e0018b
 	if (argc == 0)
e0018b
 		usage_with_options(u, options);
e0018b
 	for (i = 0; i < argc; i++) {
e0018b
-		const char *fmt;
e0018b
-
e0018b
 		if (strcmp(argv[i], "all") == 0) {
e0018b
 			argc = 1;
e0018b
 			break;
e0018b
 		}
e0018b
-
e0018b
-		if (param.endpoint)
e0018b
-			fmt = "endpoint%lu";
e0018b
-		else
e0018b
-			fmt = "port%lu";
e0018b
-
e0018b
-		if (sscanf(argv[i], fmt, &id) == 1)
e0018b
-			continue;
e0018b
-		if (sscanf(argv[i], "%lu", &id) == 1)
e0018b
-			continue;
e0018b
-
e0018b
-		log_err(&pl, "'%s' is not a valid %s identifer\n", argv[i],
e0018b
-			param.endpoint ? "endpoint" : "port");
e0018b
-		err++;
e0018b
-	}
e0018b
-
e0018b
-	if (err == argc) {
e0018b
-		usage_with_options(u, options);
e0018b
-		return -EINVAL;
e0018b
 	}
e0018b
 
e0018b
 	if (param.debug) {
e0018b
@@ -187,7 +165,6 @@ static int port_action(int argc, const char **argv, struct cxl_ctx *ctx,
e0018b
 		pl.log_priority = LOG_INFO;
e0018b
 
e0018b
 	rc = 0;
e0018b
-	err = 0;
e0018b
 	count = 0;
e0018b
 
e0018b
 	for (i = 0; i < argc; i++) {
e0018b
@@ -198,15 +175,16 @@ static int port_action(int argc, const char **argv, struct cxl_ctx *ctx,
e0018b
 
e0018b
 			endpoint = find_cxl_endpoint(ctx, argv[i]);
e0018b
 			if (!endpoint) {
e0018b
-				log_dbg(&pl, "endpoint: %s not found\n",
e0018b
-					argv[i]);
e0018b
+				log_notice(&pl, "endpoint: %s not found\n",
e0018b
+					   argv[i]);
e0018b
 				continue;
e0018b
 			}
e0018b
 			port = cxl_endpoint_get_port(endpoint);
e0018b
 		} else {
e0018b
 			port = find_cxl_port(ctx, argv[i]);
e0018b
 			if (!port) {
e0018b
-				log_dbg(&pl, "port: %s not found\n", argv[i]);
e0018b
+				log_notice(&pl, "port: %s not found\n",
e0018b
+					   argv[i]);
e0018b
 				continue;
e0018b
 			}
e0018b
 		}
e0018b
-- 
e0018b
2.27.0
e0018b