Whamcloud - gitweb
LU-16859 lnet: incorrect check for duplicate NI 18/52918/6
authorSerguei Smirnov <ssmirnov@whamcloud.com>
Tue, 31 Oct 2023 21:11:54 +0000 (14:11 -0700)
committerOleg Drokin <green@whamcloud.com>
Wed, 13 Dec 2023 12:21:28 +0000 (12:21 +0000)
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 <ssmirnov@whamcloud.com>
Change-Id: I0d4047118e7d9982fa791a2e324a27aa5d4abaee
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52918
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Cyril Bordage <cbordage@whamcloud.com>
Reviewed-by: Frank Sehr <fsehr@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/lnet/config.c
lustre/tests/sanity-lnet.sh

index 25c3f47..4749ab2 100644 (file)
@@ -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;
        }
 
index c8db85c..86f5c8b 100755 (executable)
@@ -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"