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