From 8785f25b053c69b4303e901c6c8dc5d0d4d6dfc1 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Sun, 13 Aug 2023 11:02:33 -0400 Subject: [PATCH] LU-16552 test: add new lnet test for Multi-Rail setups You can crash lnet kernel module by setting up a interface with lctl net up and then attempting to setup the interface with the import function. This is due to improper clearing the net_cpts array. Currently sanity-lnet.sh doesn't real test MR setups. Because of this a few bugs slipped in. Add two new test to ensure MR setups behave properly. Test 107 is to see if deleting a second interface for a MR setup doesn't crash a node. Test 108 creates a multi rail setup of a tcp LNet net with two interfaces, one real and the other fake. A bug was preventing the second fake interface from being added. Test-Parameters: trivial testlist=sanity-lnet Change-Id: Ic69e14bd0617f4d6fe931140b5b6d43b795843cf Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50302 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Chris Horn Reviewed-by: Serguei Smirnov Reviewed-by: Frank Sehr Reviewed-by: Oleg Drokin --- lnet/lnet/config.c | 5 +++- lustre/tests/sanity-lnet.sh | 64 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) diff --git a/lnet/lnet/config.c b/lnet/lnet/config.c index d5eb3ed..25c3f47 100644 --- a/lnet/lnet/config.c +++ b/lnet/lnet/config.c @@ -327,8 +327,11 @@ lnet_net_free(struct lnet_net *net) lnet_ni_free(ni); } - if (net->net_cpts != NULL) + if (net->net_cpts != NULL) { CFS_FREE_PTR_ARRAY(net->net_cpts, net->net_ncpts); + net->net_ncpts = LNET_CPT_NUMBER; + net->net_cpts = NULL; + } LIBCFS_FREE(net, sizeof(*net)); } diff --git a/lustre/tests/sanity-lnet.sh b/lustre/tests/sanity-lnet.sh index e7ae70f..d25b586 100755 --- a/lustre/tests/sanity-lnet.sh +++ b/lustre/tests/sanity-lnet.sh @@ -1065,6 +1065,14 @@ add_net() { error "Failed to add net ${net} on if ${if}" } +del_net() { + local net="$1" + local if="$2" + + do_lnetctl net del --net ${net} --if ${if} || + error "Failed to del net ${net} on if ${if}" +} + compare_route_add() { local rnet="$1" local gw="$2" @@ -1314,6 +1322,62 @@ test_106() { } run_test 106 "Deleting GW peer should fail" +test_107() { + [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE" + + cleanup_netns || error "Failed to cleanup netns before test execution" + cleanup_lnet || error "Failed to unload modules before test execution" + + setup_fakeif || error "Failed to add fake IF" + have_interface "$FAKE_IF" || + error "Expect $FAKE_IF configured but not found" + + reinit_dlc || return $? + + add_net "tcp" "${INTERFACES[0]}" || return $? + add_net "tcp" "$FAKE_IF" || return $? + + del_net "tcp" "$FAKE_IF" || return $? + + cleanup_fakeif + cleanup_lnet + setup_netns +} +run_test 107 "Deleting extra interface doesn't crash node" + +test_108() { + [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE" + + cleanup_netns || error "Failed to cleanup netns before test execution" + cleanup_lnet || error "Failed to unload modules before test execution" + + setup_fakeif || error "Failed to add fake IF" + have_interface "$FAKE_IF" || + error "Expect $FAKE_IF configured but not found" + + reinit_dlc || return $? + + add_net "tcp" "${INTERFACES[0]}" || return $? + $LNETCTL net show > $TMP/sanity-lnet-$testnum-expected.yaml + add_net "tcp" "$FAKE_IF" || return $? + + cat <> $TMP/sanity-lnet-$testnum-expected.yaml + - nid: ${FAKE_IP}@tcp + status: up + interfaces: + 0: ${FAKE_IF} +EOF + $LNETCTL net show > $TMP/sanity-lnet-$testnum-actual.yaml + compare_yaml_files || error "not all interfaces were setup" + + cleanup_fakeif + cleanup_lnet + setup_netns + + return 0 +} +run_test 108 "Check Multi-Rail setup" + test_200() { [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE" -- 1.8.3.1