Commit 41f614c4 authored by Michal Berger's avatar Michal Berger Committed by Konrad Sztyber
Browse files

test/nvmf: Always clean iptables rules



Tag them with proper comment for easier tracking and delete them
while finishing the tests.

This is done in order to make sure we don't keep adding same rules
over and over again under the same system.

Change-Id: I240fd23943cb4907fcd3666943cae2449ec3e6a5
Signed-off-by: default avatarMichal Berger <michal.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/24413


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
parent fc2854de
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -210,9 +210,9 @@ function nvmf_veth_init() {
	ip link set $NVMF_TARGET_BRIDGE2 master $NVMF_BRIDGE

	# Accept connections from veth interface
	iptables -I INPUT 1 -i $NVMF_INITIATOR_INTERFACE -p tcp --dport $NVMF_PORT -j ACCEPT
	iptables -I INPUT 1 -i $NVMF_INITIATOR_INTERFACE2 -p tcp --dport $NVMF_PORT -j ACCEPT
	iptables -A FORWARD -i $NVMF_BRIDGE -o $NVMF_BRIDGE -j ACCEPT
	ipts -I INPUT 1 -i $NVMF_INITIATOR_INTERFACE -p tcp --dport $NVMF_PORT -j ACCEPT
	ipts -I INPUT 1 -i $NVMF_INITIATOR_INTERFACE2 -p tcp --dport $NVMF_PORT -j ACCEPT
	ipts -A FORWARD -i $NVMF_BRIDGE -o $NVMF_BRIDGE -j ACCEPT

	# Verify connectivity
	ping -c 1 $NVMF_FIRST_TARGET_IP
@@ -280,7 +280,7 @@ function nvmf_tcp_init() {
	"${NVMF_TARGET_NS_CMD[@]}" ip link set lo up

	# Accept connections from phy interface
	iptables -I INPUT 1 -i $NVMF_INITIATOR_INTERFACE -p tcp --dport $NVMF_PORT -j ACCEPT
	ipts -I INPUT 1 -i $NVMF_INITIATOR_INTERFACE -p tcp --dport $NVMF_PORT -j ACCEPT

	# Verify connectivity
	ping -c 1 $NVMF_FIRST_TARGET_IP
@@ -290,6 +290,7 @@ function nvmf_tcp_init() {
}

function nvmf_tcp_fini() {
	iptr
	if [[ "$NVMF_TARGET_NAMESPACE" == "nvmf_tgt_ns_spdk" ]]; then
		nvmf_veth_fini
		return 0
@@ -777,3 +778,6 @@ get_main_ns_ip() {
uuid2nguid() {
	tr -d - <<< "${1^^}"
}

ipts() { iptables "$@" -m comment --comment "SPDK_NVMF:$*"; }
iptr() { iptables-save | grep -v SPDK_NVMF | iptables-restore; }