fi
}
-netns_create()
+setup()
{
- local testns=$1
+ set -e
+ ip netns add testns
+ ip -netns testns link set dev lo up
+
+ ip -netns testns link add dummy0 type dummy
+ ip -netns testns link set dev dummy0 up
+ ip -netns testns address add 198.51.100.1/24 dev dummy0
+ ip -netns testns -6 address add 2001:db8:1::1/64 dev dummy0
+ set +e
+
+}
- ip netns add $testns
- ip netns exec $testns ip link set dev lo up
+cleanup()
+{
+ ip -netns testns link del dev dummy0 &> /dev/null
+ ip netns del testns
}
fib_unreg_unicast_test()
echo
echo "Single path route test"
- set -e
- netns_create "testns"
-
- ip -netns testns link add dummy0 type dummy
- ip -netns testns link set dev dummy0 up
- ip -netns testns address add 198.51.100.1/24 dev dummy0
- ip -netns testns -6 address add 2001:db8:1::1/64 dev dummy0
- set +e
+ setup
echo " Start point"
ip -netns testns route get fibmatch 198.51.100.2 &> /dev/null
ip -netns testns -6 route get fibmatch 2001:db8:1::2 &> /dev/null
log_test $? 2 "IPv6 fibmatch - no route"
- ip netns del testns
+ cleanup
}
fib_unreg_multipath_test()
echo
echo "Multipath route test"
- set -e
- netns_create "testns"
-
- ip -netns testns link add dummy0 type dummy
- ip -netns testns link set dev dummy0 up
+ setup
+ set -e
ip -netns testns link add dummy1 type dummy
ip -netns testns link set dev dummy1 up
-
- ip -netns testns address add 198.51.100.1/24 dev dummy0
- ip -netns testns -6 address add 2001:db8:1::1/64 dev dummy0
-
ip -netns testns address add 192.0.2.1/24 dev dummy1
ip -netns testns -6 address add 2001:db8:2::1/64 dev dummy1
ip -netns testns -6 route get fibmatch 2001:db8:3::1 &> /dev/null
log_test $? 2 "IPv6 - no route"
- ip netns del testns
+ cleanup
}
fib_unreg_test()
echo
echo "Single path, admin down"
- set -e
- netns_create "testns"
-
- ip -netns testns link add dummy0 type dummy
- ip -netns testns link set dev dummy0 up
-
- ip -netns testns address add 198.51.100.1/24 dev dummy0
- ip -netns testns -6 address add 2001:db8:1::1/64 dev dummy0
- set +e
+ setup
echo " Start point"
ip -netns testns route get fibmatch 198.51.100.2 &> /dev/null
ip -netns testns -6 route get fibmatch 2001:db8:1::2 &> /dev/null
log_test $? 2 "IPv6 fibmatch"
- ip -netns testns link del dev dummy0
-
- ip netns del testns
+ cleanup
}
fib_down_multipath_test_do()
echo
echo "Admin down multipath"
- set -e
- netns_create "testns"
-
- ip -netns testns link add dummy0 type dummy
- ip -netns testns link set dev dummy0 up
+ setup
+ set -e
ip -netns testns link add dummy1 type dummy
ip -netns testns link set dev dummy1 up
- ip -netns testns address add 198.51.100.1/24 dev dummy0
- ip -netns testns -6 address add 2001:db8:1::1/64 dev dummy0
-
ip -netns testns address add 192.0.2.1/24 dev dummy1
ip -netns testns -6 address add 2001:db8:2::1/64 dev dummy1
log_test $? 2 "IPv6 fibmatch"
ip -netns testns link del dev dummy1
- ip -netns testns link del dev dummy0
- ip netns del testns
+ cleanup
}
fib_down_test()
echo
echo "Local carrier tests - single path"
- set -e
- netns_create "testns"
-
- ip -netns testns link add dummy0 type dummy
- ip -netns testns link set dev dummy0 up
+ setup
+ set -e
ip -netns testns link set dev dummy0 carrier on
-
- ip -netns testns address add 198.51.100.1/24 dev dummy0
- ip -netns testns -6 address add 2001:db8:1::1/64 dev dummy0
set +e
echo " Start point"
grep -q "linkdown"
log_test $? 1 "IPv6 linkdown flag set"
- ip -netns testns link del dev dummy0
-
- ip netns del testns
+ cleanup
}
fib_carrier_unicast_test()
echo
echo "Single path route carrier test"
- netns_create "testns"
+ setup
set -e
- ip -netns testns link add dummy0 type dummy
- ip -netns testns link set dev dummy0 up
-
ip -netns testns link set dev dummy0 carrier on
-
- ip -netns testns address add 198.51.100.1/24 dev dummy0
- ip -netns testns -6 address add 2001:db8:1::1/64 dev dummy0
set +e
echo " Start point"
grep -q "linkdown"
log_test $? 0 "IPv6 linkdown flag set"
- ip -netns testns link del dev dummy0
-
- ip netns del testns
+ cleanup
}
fib_carrier_test()
exit 0
fi
+# start clean
+cleanup &> /dev/null
+
fib_test
exit $ret