Tomasz Zawadzki 7da3afd1f7 test/iscsi: use veth interfaces instead of loopback
At this time all iSCSI tests were using local address
127.0.0.1 for both sides of connection.

This patch changes iSCSI tests to use separate
veth (virtual ethernet) interfaces.
It will allow to actually verify functionality when using
different target and initiator IPs.
Veth are used as most closely resembling real enviroment
in single host and without any network hardware required.

This patch serves as a base for future VPP test changes,
where veth interfaces are used as well.

Note: Netmask changed to /30 temporarily and
verify_iscsi_connection_rpc_methods in rpc_config disabled.
Kernel will route trafic between two veth interfaces through
host stack. This causes target and initiator IPs
to be not as expected. Those are changed back in next patch
by adding namespaces.

Change-Id: Ida8fce107e8262bef94b2161e0197c45f6e3f070
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.gerrithub.io/405552
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2018-04-10 11:40:38 -04:00

35 lines
913 B
Bash

# Network configuration
TARGET_INTERFACE="spdk_tgt_int"
INITIATOR_INTERFACE="spdk_init_int"
# iSCSI target configuration
TARGET_IP=10.0.0.1
INITIATOR_IP=10.0.0.2
ISCSI_PORT=3260
NETMASK=$INITIATOR_IP/30
INITIATOR_TAG=2
INITIATOR_NAME=ANY
PORTAL_TAG=1
ISCSI_APP="./app/iscsi_tgt/iscsi_tgt -i 0"
ISCSI_TEST_CORE_MASK=0xFF
function create_veth_interfaces() {
ip link delete $INITIATOR_INTERFACE || true
# Create veth (Virtual ethernet) interface pair
ip link add $INITIATOR_INTERFACE type veth peer name $TARGET_INTERFACE
ip addr add $INITIATOR_IP/24 dev $INITIATOR_INTERFACE
ip link set $INITIATOR_INTERFACE up
ip addr add $TARGET_IP/24 dev $TARGET_INTERFACE
ip link set $TARGET_INTERFACE up
trap "cleanup_veth_interfaces; exit 1" SIGINT SIGTERM EXIT
}
function cleanup_veth_interfaces() {
# Cleanup veth interfaces
# Note: removing one veth, removes the pair
ip link delete $INITIATOR_INTERFACE
}