From: Serguei Smirnov Date: Tue, 31 Oct 2023 21:11:54 +0000 (-0700) Subject: LU-16859 lnet: incorrect check for duplicate NI X-Git-Tag: 2.15.60~56 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=7dcdb9eb0ded98e956fe417abbd835433a8de3f0 LU-16859 lnet: incorrect check for duplicate NI When NI is being added to an existing LNet, checking against existing NI interface names currently fails if the new NI happens to use interface name which is a prefix of one used by an existing NI. The following example assumes ib0 and its alias ib0:1 are configured: lnetctl net add --net o2ib --if ib0:1 lnetctl net add --net o2ib --if ib0 Fix this by making sure interface strings are compared properly regardless of relative length. Test-Parameters: trivial testlist=sanity-lnet Signed-off-by: Serguei Smirnov Change-Id: I0d4047118e7d9982fa791a2e324a27aa5d4abaee Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52918 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Cyril Bordage Reviewed-by: Frank Sehr Reviewed-by: Oleg Drokin --- diff --git a/lnet/lnet/config.c b/lnet/lnet/config.c index 25c3f47..4749ab2 100644 --- a/lnet/lnet/config.c +++ b/lnet/lnet/config.c @@ -115,7 +115,9 @@ lnet_ni_unique_net(struct list_head *nilist, char *iface) ni = list_entry(tmp, struct lnet_ni, ni_netlist); if (ni->ni_interface != NULL && - strncmp(ni->ni_interface, iface, strlen(iface)) == 0) + strncmp(ni->ni_interface, + iface, + LNET_MAX_STR_LEN) == 0) return false; } diff --git a/lustre/tests/sanity-lnet.sh b/lustre/tests/sanity-lnet.sh index c8db85c..86f5c8b 100755 --- a/lustre/tests/sanity-lnet.sh +++ b/lustre/tests/sanity-lnet.sh @@ -65,6 +65,7 @@ cleanup_testsuite() { TESTNS='test_ns' FAKE_IF="test1pg" FAKE_IP="10.1.2.3" +FAKE_IP_ALIAS="10.1.2.31" do_ns() { echo "ip netns exec $TESTNS $*" ip netns exec $TESTNS "$@" @@ -1387,6 +1388,44 @@ EOF } run_test 108 "Check Multi-Rail setup" +test_109() { + [[ ${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" + + FAKE_IF_ALIAS="${FAKE_IF}" + FAKE_IF_ALIAS+=":0" + + ifconfig "$FAKE_IF_ALIAS" "$FAKE_IP_ALIAS" up || + error "Failed to add fake IF alias" + + reinit_dlc || return $? + + # add interface with longer name first + add_net "tcp" "$FAKE_IF_ALIAS" || return $? + add_net "tcp" "$FAKE_IF" || return $? + + del_net "tcp" "$FAKE_IF" || return $? + del_net "tcp" "$FAKE_IF_ALIAS" || return $? + + # add interface with shorter name first + add_net "tcp" "$FAKE_IF" || return $? + add_net "tcp" "$FAKE_IF_ALIAS" || return $? + + ifconfig "$FAKE_IF_ALIAS" "$FAKE_IP_ALIAS" down || + error "Failed to clean up fake IF alias" + + cleanup_fakeif + cleanup_lnet + setup_netns +} +run_test 109 "Add NI using a network interface alias (LU-16859)" + test_200() { [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"