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

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