From: Chris Horn Date: Mon, 29 Jun 2020 18:44:07 +0000 (-0500) Subject: LU-13734 lnet: Allow duplicate nets in ip2nets syntax X-Git-Tag: 2.13.56~126 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=6203ed821ffaca204e1caede03fdcb2212ac399b LU-13734 lnet: Allow duplicate nets in ip2nets syntax Before the MR feature was implemented, it was not possible to configure multiple interfaces on the same LNet, so the ip2nets syntax did not allow for this. Now that we have MR feature, we should allow it to be configured via ip2nets syntax. e.g. o2ib(ib0) 10.10.10.1 o2ib(ib1) 10.10.10.2 A test is added for configuring LNet with kernel ip2nets parameter. setup_netns() refactored to facilitate the new test. cleanup_lnet() is modified to check whether lnet module is loaded before attempting lnetctl lnet unconfigured otherwise sanity-lnet.sh could exit with rc 234 on cleanup. Test-Parameters: trivial testlist=sanity-lnet HPE-bug-id: LUS-9046 Signed-off-by: Chris Horn Change-Id: Iafc3882035269073fd7e4abb53d138d9267f6e21 Reviewed-on: https://review.whamcloud.com/39227 Reviewed-by: James Simmons Tested-by: jenkins Tested-by: Maloo Reviewed-by: Neil Brown Reviewed-by: Oleg Drokin --- diff --git a/lnet/lnet/config.c b/lnet/lnet/config.c index 428098b..bf5deea 100644 --- a/lnet/lnet/config.c +++ b/lnet/lnet/config.c @@ -356,10 +356,10 @@ lnet_net_alloc(__u32 net_id, struct list_head *net_list) { struct lnet_net *net; - if (!lnet_net_unique(net_id, net_list, NULL)) { - CERROR("Duplicate net %s. Ignore\n", - libcfs_net2str(net_id)); - return NULL; + if (!lnet_net_unique(net_id, net_list, &net)) { + CDEBUG(D_NET, "Returning duplicate net %p %s\n", net, + libcfs_net2str(net->net_id)); + return net; } LIBCFS_ALLOC(net, sizeof(*net)); @@ -1469,12 +1469,8 @@ lnet_match_networks(const char **networksp, const char *ip2nets, struct list_head *t; struct list_head *t2; struct lnet_text_buf *tb; - struct lnet_text_buf *tb2; - __u32 net1; - __u32 net2; int len; int count; - int dup; int rc; if (lnet_str2tbs_sep(&raw_entries, ip2nets) < 0) { @@ -1514,33 +1510,6 @@ lnet_match_networks(const char **networksp, const char *ip2nets, if (rc < 0) break; - dup = 0; - list_for_each(t, ¤t_nets) { - tb = list_entry(t, struct lnet_text_buf, ltb_list); - net1 = lnet_netspec2net(tb->ltb_text); - LASSERT(net1 != LNET_NIDNET(LNET_NID_ANY)); - - list_for_each(t2, &matched_nets) { - tb2 = list_entry(t2, struct lnet_text_buf, - ltb_list); - net2 = lnet_netspec2net(tb2->ltb_text); - LASSERT(net2 != LNET_NIDNET(LNET_NID_ANY)); - - if (net1 == net2) { - dup = 1; - break; - } - } - - if (dup) - break; - } - - if (dup) { - lnet_free_text_bufs(¤t_nets); - continue; - } - list_for_each_safe(t, t2, ¤t_nets) { tb = list_entry(t, struct lnet_text_buf, ltb_list); diff --git a/lustre/tests/sanity-lnet.sh b/lustre/tests/sanity-lnet.sh index d716353..c97dd3d 100755 --- a/lustre/tests/sanity-lnet.sh +++ b/lustre/tests/sanity-lnet.sh @@ -45,7 +45,8 @@ fi cleanup_lnet() { echo "Cleaning up LNet" - $LNETCTL lnet unconfigure 2>/dev/null + lsmod | grep -q lnet && + $LNETCTL lnet unconfigure 2>/dev/null unload_modules } @@ -105,19 +106,38 @@ do_ns() { ip netns exec $TESTNS "$@" } +setup_fakeif() { + local netns="$1" + + local netns_arg="" + [[ -n $netns ]] && + netns_arg="netns $netns" + + ip link add 'test1pl' type veth peer name $FAKE_IF $netns_arg + ip link set 'test1pl' up + if [[ -n $netns ]]; then + do_ns ip addr add "${FAKE_IP}/31" dev $FAKE_IF + do_ns ip link set $FAKE_IF up + else + ip addr add "${FAKE_IP}/31" dev $FAKE_IF + ip link set $FAKE_IF up + fi +} + +cleanup_fakeif() { + ip link show test1pl >& /dev/null && ip link del test1pl || return 0 +} + setup_netns() { cleanup_netns ip netns add $TESTNS - ip link add 'test1pl' type veth peer name $FAKE_IF netns $TESTNS - ip link set 'test1pl' up - do_ns ip addr add "${FAKE_IP}/31" dev $FAKE_IF - do_ns ip link set $FAKE_IF up + setup_fakeif $TESTNS } cleanup_netns() { (ip netns list | grep -q $TESTNS) && ip netns del $TESTNS - ip link show test1pl >& /dev/null && ip link del test1pl || return 0 + cleanup_fakeif } configure_dlc() { @@ -1478,6 +1498,90 @@ test_207() { } run_test 207 "Check health and resends for multi-rail remote errors" +test_208_load_and_check_lnet() { + local ip2nets="$1" + local p_nid="$2" + local s_nid="$3" + local num_expected=1 + + load_lnet "networks=\"\" ip2nets=\"${ip2nets_str}\"" + + $LCTL net up || + error "Failed to load LNet with ip2nets \"${ip2nets_str}\"" + + [[ -n $s_nid ]] && + num_expected=2 + + declare -a nids + nids=( $($LCTL list_nids) ) + + [[ ${#nids[@]} -ne ${num_expected} ]] && + error "Expect ${num_expected} NIDs found ${#nids[@]}" + + [[ ${nids[0]} == ${p_nid} ]] || + error "Expect NID \"${p_nid}\" found \"${nids[0]}\"" + + [[ -n $s_nid ]] && [[ ${nids[1]} != ${s_nid} ]] && + error "Expect second NID \"${s_nid}\" found \"${nids[1]}\"" + + $LCTL net down &>/dev/null + cleanup_lnet +} + +test_208() { + have_interface "eth0" || skip "Need eth0 interface with ipv4 configured" + + 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" + + local eth0_ip=$(ip --oneline addr show dev eth0 | + awk '/inet /{print $4}' | + sed 's:/.*::') + local ip2nets_str="tcp(eth0) $eth0_ip" + + echo "Configure single NID \"$ip2nets_str\"" + test_208_load_and_check_lnet "${ip2nets_str}" "${eth0_ip}@tcp" + + ip2nets_str="tcp(eth0) $eth0_ip; tcp1($FAKE_IF) $FAKE_IP" + echo "Configure two NIDs; two NETs \"$ip2nets_str\"" + test_208_load_and_check_lnet "${ip2nets_str}" "${eth0_ip}@tcp" \ + "${FAKE_IP}@tcp1" + + ip2nets_str="tcp(eth0) $eth0_ip; tcp($FAKE_IF) $FAKE_IP" + echo "Configure two NIDs; one NET \"$ip2nets_str\"" + test_208_load_and_check_lnet "${ip2nets_str}" "${eth0_ip}@tcp" \ + "${FAKE_IP}@tcp" + local addr1=( ${eth0_ip//./ } ) + local addr2=( ${FAKE_IP//./ } ) + local range="[${addr1[0]},${addr2[0]}]" + + local i + for i in $(seq 1 3); do + range+=".[${addr1[$i]},${addr2[$i]}]" + done + ip2nets_str="tcp(eth0,${FAKE_IF}) ${range}" + + echo "Configured two NIDs; one NET alt syntax \"$ip2nets_str\"" + test_208_load_and_check_lnet "${ip2nets_str}" "${eth0_ip}@tcp" \ + "${FAKE_IP}@tcp" + + cleanup_fakeif + + echo "alt syntax with missing IF \"$ip2nets_str\"" + load_lnet "networks=\"\" ip2nets=\"${ip2nets_str}\"" + + echo "$LCTL net up should fail" + $LCTL net up && + error "LNet bringup should have failed" + + cleanup_lnet +} +run_test 208 "Test various kernel ip2nets configurations" + test_300() { # LU-13274 local header