Commit 8425f00c authored by Konrad Sztyber's avatar Konrad Sztyber
Browse files

nvme/tcp: respect the src_{addr,svcid} parameters



Previously, both were completely ignored.

Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: I9df0b50038742956e2be0b80ad239e80ac4dcba6
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/24070


Reviewed-by: default avatarTomasz Zawadzki <tomasz@tzawadzki.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
parent f59b603f
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -2374,6 +2374,8 @@ nvme_tcp_qpair_connect_sock(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_qpai
	spdk_sock_get_default_opts(&opts);
	opts.priority = ctrlr->trid.priority;
	opts.zcopy = !nvme_qpair_is_admin_queue(qpair);
	opts.src_addr = ctrlr->opts.src_addr[0] ? ctrlr->opts.src_addr : NULL;
	opts.src_port = src_port;
	if (ctrlr->opts.transport_ack_timeout) {
		opts.ack_timeout = 1ULL << ctrlr->opts.transport_ack_timeout;
	}
+22 −6
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ waitforlisten $bdevperf_pid $bdevperf_rpc_sock

# Create a controller from the first IP/Port combination.
$rpc_py -s $bdevperf_rpc_sock bdev_nvme_attach_controller -b NVMe0 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP \
	-s $NVMF_PORT -f ipv4 -n nqn.2016-06.io.spdk:cnode1 -i $NVMF_FIRST_TARGET_IP -c $NVMF_HOST_FIRST_PORT
	-s $NVMF_PORT -f ipv4 -n nqn.2016-06.io.spdk:cnode1 -i $NVMF_FIRST_INITIATOR_IP

# wait for the first controller to show up.
while ! $rpc_py -s $bdevperf_rpc_sock bdev_nvme_get_controllers | grep -c NVMe; do
@@ -58,21 +58,21 @@ done

# try to attach with same controller name but different hostnqn. Should fail.
NOT $rpc_py -s $bdevperf_rpc_sock bdev_nvme_attach_controller -b NVMe0 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP \
	-s $NVMF_PORT -f ipv4 -n nqn.2016-06.io.spdk:cnode1 -i $NVMF_FIRST_TARGET_IP -c $NVMF_HOST_FIRST_PORT \
	-s $NVMF_PORT -f ipv4 -n nqn.2016-06.io.spdk:cnode1 -i $NVMF_FIRST_INITIATOR_IP \
	-q nqn.2021-09-7.io.spdk:00001

# try to attach with same controller name but different subnqn. Should fail.
NOT $rpc_py -s $bdevperf_rpc_sock bdev_nvme_attach_controller -b NVMe0 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP \
	-s $NVMF_PORT -f ipv4 -n nqn.2016-06.io.spdk:cnode2 -i $NVMF_FIRST_TARGET_IP -c $NVMF_HOST_FIRST_PORT
	-s $NVMF_PORT -f ipv4 -n nqn.2016-06.io.spdk:cnode2 -i $NVMF_FIRST_INITIATOR_IP

# try to attach with the same controller name and multipathing disabled. Should fail
NOT $rpc_py -s $bdevperf_rpc_sock bdev_nvme_attach_controller -b NVMe0 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP \
	-s $NVMF_PORT -f ipv4 -n nqn.2016-06.io.spdk:cnode1 -i $NVMF_FIRST_TARGET_IP -c $NVMF_HOST_FIRST_PORT \
	-s $NVMF_PORT -f ipv4 -n nqn.2016-06.io.spdk:cnode1 -i $NVMF_FIRST_INITIATOR_IP \
	-x disable

# Attempt to add an identical path as a failover path. Should fail.
NOT $rpc_py -s $bdevperf_rpc_sock bdev_nvme_attach_controller -b NVMe0 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP \
	-s $NVMF_PORT -f ipv4 -n nqn.2016-06.io.spdk:cnode1 -i $NVMF_FIRST_TARGET_IP -c $NVMF_HOST_FIRST_PORT \
	-s $NVMF_PORT -f ipv4 -n nqn.2016-06.io.spdk:cnode1 -i $NVMF_FIRST_INITIATOR_IP \
	-x failover

# Add a second path without specifying the host information. Should pass.
@@ -85,7 +85,7 @@ $rpc_py -s $bdevperf_rpc_sock bdev_nvme_detach_controller NVMe0 -t $TEST_TRANSPO

# Add a second controller by attaching to the same subsystem with a different controller name
$rpc_py -s $bdevperf_rpc_sock bdev_nvme_attach_controller -b NVMe1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP \
	-s $NVMF_SECOND_PORT -f ipv4 -n nqn.2016-06.io.spdk:cnode1 -i $NVMF_FIRST_TARGET_IP -c $NVMF_HOST_FIRST_PORT
	-s $NVMF_SECOND_PORT -f ipv4 -n nqn.2016-06.io.spdk:cnode1 -i $NVMF_FIRST_INITIATOR_IP

if [ "$($rpc_py -s $bdevperf_rpc_sock bdev_nvme_get_controllers | grep -c NVMe)" != "2" ]; then
	echo "actual number of controllers is not equal to expected count."
@@ -97,6 +97,22 @@ $rootdir/examples/bdev/bdevperf/bdevperf.py -s $bdevperf_rpc_sock perform_tests
# Remove the second controller
$rpc_py -s $bdevperf_rpc_sock bdev_nvme_detach_controller NVMe1

if [[ -n "$NVMF_SECOND_INITIATOR_IP" ]]; then
	# Verify that host address is respected
	"$rpc_py" -s "$bdevperf_rpc_sock" bdev_nvme_attach_controller -b nvme1 -t $TEST_TRANSPORT \
		-a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT -f ipv4 -n nqn.2016-06.io.spdk:cnode2 \
		-i $NVMF_FIRST_INITIATOR_IP
	[[ $("$rpc_py" nvmf_subsystem_get_qpairs nqn.2016-06.io.spdk:cnode2 \
		| jq -r '.[].peer_address.traddr') == "$NVMF_FIRST_INITIATOR_IP" ]]
	"$rpc_py" -s "$bdevperf_rpc_sock" bdev_nvme_detach_controller nvme1

	"$rpc_py" -s "$bdevperf_rpc_sock" bdev_nvme_attach_controller -b nvme1 -t $TEST_TRANSPORT \
		-a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT -f ipv4 -n nqn.2016-06.io.spdk:cnode2 \
		-i $NVMF_SECOND_INITIATOR_IP
	[[ $("$rpc_py" nvmf_subsystem_get_qpairs nqn.2016-06.io.spdk:cnode2 \
		| jq -r '.[].peer_address.traddr') == "$NVMF_SECOND_INITIATOR_IP" ]]
fi

killprocess $bdevperf_pid

$rpc_py nvmf_delete_subsystem nqn.2016-06.io.spdk:cnode1