From: James Simmons Date: Wed, 22 Nov 2023 00:26:52 +0000 (-0500) Subject: LU-10391 ptlrpc: update import debugfs to support IPv6 formats X-Git-Tag: 2.15.60~68 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=03f4ef7f32692cfdbe9fc20c218fea75ec3aee08;p=fs%2Flustre-release.git LU-10391 ptlrpc: update import debugfs to support IPv6 formats When mounting with IPv6 NIDs setting the connection will fail with LustreError: (lproc_ptlrpc.c:1417:ldebugfs_import_seq_write()) config: wrong instance # d967@tcp::1 This is due to IPv6 NIDs being able to contain "::" which is used as a delimiter. Update the code to search for '@' which is unique for the NID and then look for "::". For reading the import we need to quote all the NID strings to make it valid YAML. This changes the import output from: import: name: lustre-MDT0000-mdc-ffff96c7070a2800 target: lustre-MDT0000_UUID state: FULL .... connection: failover_nids: [ 10.37.248.15@tcp, 192.168.1.100@tcp ] current_connection: 10.37.248.15@tcp connection_attempts: 1 generation: 1 in-progress_invalidations: 0 idle: 64 sec .... to the following: import: name: lustre-MDT0000-mdc-ffff96c7070a2800 target: lustre-MDT0000_UUID state: FULL .... connection: failover_nids: [ "10.37.248.15@tcp", "192.168.1.100@tcp" ] current_connection: "10.37.248.15@tcp" connection_attempts: 1 generation: 1 in-progress_invalidations: 0 idle: 64 sec .... Change-Id: Ie68d544d8733b87d04fa0c2385de2319696b3289 Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53117 Reviewed-by: Neil Brown Reviewed-by: Feng Lei Reviewed-by: Timothy Day Reviewed-by: Nathaniel Clark Reviewed-by: Oleg Drokin Tested-by: jenkins Tested-by: Maloo --- diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 730a919..7ffbc42 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -830,7 +830,10 @@ static void lprocfs_import_seq_show_locked(struct seq_file *m, list_for_each_entry(conn, &imp->imp_conn_list, oic_item) { libcfs_nidstr_r(&conn->oic_conn->c_peer.nid, nidstr, sizeof(nidstr)); - seq_printf(m, "%s%s", j ? ", " : "", nidstr); + if (j) + seq_puts(m, ", "); + /* Place nidstr in quotes */ + seq_printf(m, "\"%s\"", nidstr); j++; } if (imp->imp_connection) @@ -839,7 +842,7 @@ static void lprocfs_import_seq_show_locked(struct seq_file *m, else strncpy(nidstr, "", sizeof(nidstr)); seq_printf(m, " ]\n" - " current_connection: %s\n" + " current_connection: \"%s\"\n" " connection_attempts: %u\n" " generation: %u\n" " in-progress_invalidations: %u\n" diff --git a/lustre/ptlrpc/lproc_ptlrpc.c b/lustre/ptlrpc/lproc_ptlrpc.c index 7503271..ce27a97 100644 --- a/lustre/ptlrpc/lproc_ptlrpc.c +++ b/lustre/ptlrpc/lproc_ptlrpc.c @@ -1378,8 +1378,6 @@ ldebugfs_import_seq_write(struct file *file, const char __user *buffer, struct obd_device *obd = m->private; struct obd_import *imp; char *kbuf = NULL; - char *uuid; - char *ptr; int do_reconn = 1; const char prefix[] = "connection="; const int prefix_len = sizeof(prefix) - 1; @@ -1402,8 +1400,14 @@ ldebugfs_import_seq_write(struct file *file, const char __user *buffer, GOTO(out, rc = -EINVAL); with_imp_locked(obd, imp, rc) { - uuid = kbuf + prefix_len; - ptr = strstr(uuid, "::"); + char *uuid = kbuf + prefix_len; + char *ptr, *tmp; + + tmp = strchr(uuid, '@'); + if (!tmp) + GOTO(out, rc = -EINVAL); + + ptr = strstr(tmp, "::"); if (ptr) { u32 inst; int rc;