Whamcloud - gitweb
LU-18114 lctl: split "lctl net_drop_*" group into subcommands 54/56154/7
authorEmoly Liu <emoly@whamcloud.com>
Tue, 27 Aug 2024 11:30:32 +0000 (19:30 +0800)
committerOleg Drokin <green@whamcloud.com>
Mon, 9 Dec 2024 06:08:21 +0000 (06:08 +0000)
Split "lctl net_drop_*" command group into subcommands, e.g.
"lctl net_drop_add" to "lctl net_drop add".
Also, sanity-lnet.sh is modified to verify this patch.

Test-Parameters: trivial testlist=sanity-lnet
Signed-off-by: Emoly Liu <emoly@whamcloud.com>
Change-Id: I5094328435e5b93a8a7311f26ec77275211e0517
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56154
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/sanity-lnet.sh
lustre/utils/lctl.c

index 70b31fc..231a1c6 100755 (executable)
@@ -2148,10 +2148,15 @@ cleanup_health_test() {
 add_health_test_drop_rules() {
        local args="-m GET -r 1 -e ${1}"
        local src dst
+       if (( $MDS1_VERSION >= $(version_code 2.15.65) )); then
+               net_drop_add="net_drop add"
+       else
+               net_drop_add="net_drop_add"
+       fi
 
        for src in "${LNIDS[@]}"; do
                for dst in "${RNIDS[@]}" "${LNIDS[@]}"; do
-                       $LCTL net_drop_add -s $src -d $dst ${args} ||
+                       $LCTL $net_drop_add -s $src -d $dst ${args} ||
                                error "Failed to add drop rule $src $dst $args"
                done
        done
@@ -2159,6 +2164,11 @@ add_health_test_drop_rules() {
 
 do_lnet_health_ping_test() {
        local hstatus="$1"
+       if (( $MDS1_VERSION >= $(version_code 2.15.65) )); then
+               net_drop_del="net_drop del"
+       else
+               net_drop_del="net_drop_del"
+       fi
 
        echo "Simulate $hstatus"
 
@@ -2170,7 +2180,7 @@ do_lnet_health_ping_test() {
 
        lnet_health_post
 
-       $LCTL net_drop_del -a
+       $LCTL $net_drop_del -a
 
        return 0
 }
index 23d7482..0f6545c 100644 (file)
@@ -105,6 +105,32 @@ command_t changelog_cmdlist[] = {
 };
 JT_SUBCMD(changelog);
 
+/**
+ * command_t net_drop_cmdlist - lctl net_drop commands.
+ */
+command_t net_drop_cmdlist[] = {
+       {.pc_name = "add", .pc_func = jt_ptl_drop_add,
+        .pc_help = "Add LNet drop rule\n"
+        "usage: net_drop add {-s | --source NID}\n"
+        "                    {-d | --dest NID}\n"
+        "                    {{-r | --rate DROP_RATE} | {-i | --interval SECONDS}}\n"
+        "                    [-p | --portal PORTAL...]\n"
+        "                    [-m | --message {PUT|ACK|GET|REPLY...}]\n"
+        "                    [-e | --health_error]"},
+       {.pc_name = "del", .pc_func = jt_ptl_drop_del,
+        .pc_help = "remove LNet drop rule\n"
+        "usage: net_drop del {-a | --all} |\n"
+        "                    {{-s | --source NID} {-d | --dest NID}}"},
+       {.pc_name = "reset", .pc_func = jt_ptl_drop_reset,
+        .pc_help = "reset drop rule stats\n"
+        "usage: net_drop reset"},
+       {.pc_name = "list", .pc_func = jt_ptl_drop_list,
+        .pc_help = "list LNet drop rules\n"
+        "usage: net_drop list"},
+       { .pc_help = NULL }
+};
+JT_SUBCMD(net_drop);
+
 #ifdef HAVE_SERVER_SUPPORT
 /**
  * command_t barrier_cmdlist - lctl barrier commands.
@@ -245,22 +271,23 @@ command_t cmdlist[] = {
         "usage: show_route"},
        {"ping", jt_ptl_ping, 0, "Check LNET connectivity\n"
         "usage: ping nid [timeout [pid]]"},
+
        {"net_drop_add", jt_ptl_drop_add, 0, "Add LNet drop rule\n"
-        "usage: net_drop_add <-s | --source NID>\n"
-        "                    <-d | --dest NID>\n"
-        "                    <<-r | --rate DROP_RATE> |\n"
-        "                    <-i | --interval SECONDS>>\n"
-        "                    [<-p | --portal> PORTAL...]\n"
-        "                    [<-m | --message> <PUT|ACK|GET|REPLY>...]\n"
-        "                    [< -e | --health_error]\n"},
+        "usage: net_drop_add {-s | --source NID}\n"
+        "                    {-d | --dest NID}\n"
+        "                    {{-r | --rate DROP_RATE} | {-i | --interval SECONDS}}\n"
+        "                    [-p | --portal PORTAL...]\n"
+        "                    [-m | --message {PUT|ACK|GET|REPLY...}]\n"
+        "                    [-e | --health_error]"},
        {"net_drop_del", jt_ptl_drop_del, 0, "remove LNet drop rule\n"
-        "usage: net_drop_del <[-a | --all] |\n"
-        "                    <-s | --source NID>\n"
-        "                    <-d | --dest NID>>\n"},
+        "usage: net_drop_del {-a | --all} |\n"
+        "                    {{-s | --source NID} {-d | --dest NID}}"},
        {"net_drop_reset", jt_ptl_drop_reset, 0, "reset drop rule stats\n"
         "usage: net_drop_reset"},
        {"net_drop_list", jt_ptl_drop_list, 0, "list LNet drop rules\n"
         "usage: net_drop_list"},
+       {"net_drop", jt_net_drop, net_drop_cmdlist, ""},
+
        {"net_delay_add", jt_ptl_delay_add, 0, "Add LNet delay rule\n"
         "usage: net_delay_add <-s | --source NID>\n"
         "                     <-d | --dest NID>\n"