Whamcloud - gitweb
LU-10391 ptlrpc: update import debugfs to support IPv6 formats 17/53117/7
authorJames Simmons <jsimmons@infradead.org>
Wed, 22 Nov 2023 00:26:52 +0000 (19:26 -0500)
committerOleg Drokin <green@whamcloud.com>
Wed, 13 Dec 2023 12:17:55 +0000 (12:17 +0000)
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 <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53117
Reviewed-by: Neil Brown <neilb@suse.de>
Reviewed-by: Feng Lei <flei@whamcloud.com>
Reviewed-by: Timothy Day <timday@amazon.com>
Reviewed-by: Nathaniel Clark <nclark@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/obdclass/lprocfs_status.c
lustre/ptlrpc/lproc_ptlrpc.c

index 730a919..7ffbc42 100644 (file)
@@ -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, "<none>", 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"
index 7503271..ce27a97 100644 (file)
@@ -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;