2018-04-04 13:46:41 +00:00
|
|
|
# Network configuration
|
|
|
|
TARGET_INTERFACE="spdk_tgt_int"
|
|
|
|
INITIATOR_INTERFACE="spdk_init_int"
|
2018-04-25 16:16:08 +00:00
|
|
|
TARGET_NAMESPACE="spdk_iscsi_ns"
|
|
|
|
TARGET_NS_CMD="ip netns exec $TARGET_NAMESPACE"
|
2018-04-04 13:46:41 +00:00
|
|
|
|
2018-03-27 13:17:53 +00:00
|
|
|
# iSCSI target configuration
|
2018-04-04 13:46:41 +00:00
|
|
|
TARGET_IP=10.0.0.1
|
|
|
|
INITIATOR_IP=10.0.0.2
|
2018-03-27 13:17:53 +00:00
|
|
|
ISCSI_PORT=3260
|
2018-04-25 16:16:08 +00:00
|
|
|
NETMASK=$INITIATOR_IP/32
|
2018-03-27 13:17:53 +00:00
|
|
|
INITIATOR_TAG=2
|
|
|
|
INITIATOR_NAME=ANY
|
2018-03-27 13:56:16 +00:00
|
|
|
PORTAL_TAG=1
|
2018-04-25 16:16:08 +00:00
|
|
|
ISCSI_APP="$TARGET_NS_CMD ./app/iscsi_tgt/iscsi_tgt -i 0"
|
2018-03-27 13:17:53 +00:00
|
|
|
ISCSI_TEST_CORE_MASK=0xFF
|
2018-04-04 13:46:41 +00:00
|
|
|
|
|
|
|
function create_veth_interfaces() {
|
2018-04-23 07:04:15 +00:00
|
|
|
# $1 = test type (posix/vpp)
|
2018-04-25 16:16:08 +00:00
|
|
|
ip netns del $TARGET_NAMESPACE || true
|
2018-04-04 13:46:41 +00:00
|
|
|
ip link delete $INITIATOR_INTERFACE || true
|
|
|
|
|
2018-04-23 07:04:15 +00:00
|
|
|
trap "cleanup_veth_interfaces $1; exit 1" SIGINT SIGTERM EXIT
|
2018-06-22 12:15:59 +00:00
|
|
|
|
2018-04-04 13:46:41 +00:00
|
|
|
# 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
|
|
|
|
|
2018-04-25 16:16:08 +00:00
|
|
|
# Create and add interface for target to network namespace
|
|
|
|
ip netns add $TARGET_NAMESPACE
|
|
|
|
ip link set $TARGET_INTERFACE netns $TARGET_NAMESPACE
|
|
|
|
|
|
|
|
$TARGET_NS_CMD ip link set lo up
|
|
|
|
$TARGET_NS_CMD ip addr add $TARGET_IP/24 dev $TARGET_INTERFACE
|
|
|
|
$TARGET_NS_CMD ip link set $TARGET_INTERFACE up
|
2018-04-04 13:46:41 +00:00
|
|
|
|
2018-06-22 12:15:59 +00:00
|
|
|
# Verify connectivity
|
|
|
|
ping -c 1 $TARGET_IP
|
|
|
|
ip netns exec $TARGET_NAMESPACE ping -c 1 $INITIATOR_IP
|
2018-04-04 13:46:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function cleanup_veth_interfaces() {
|
2018-04-23 07:04:15 +00:00
|
|
|
# $1 = test type (posix/vpp)
|
|
|
|
|
2018-04-25 16:16:08 +00:00
|
|
|
# Cleanup veth interfaces and network namespace
|
2018-04-04 13:46:41 +00:00
|
|
|
# Note: removing one veth, removes the pair
|
|
|
|
ip link delete $INITIATOR_INTERFACE
|
2018-04-25 16:16:08 +00:00
|
|
|
ip netns del $TARGET_NAMESPACE
|
2018-04-04 13:46:41 +00:00
|
|
|
}
|