]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
selftests: fib_tests: Add tests for ipv6 gateway with ipv4 route
authorDavid Ahern <dsahern@gmail.com>
Fri, 5 Apr 2019 23:30:41 +0000 (16:30 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 8 Apr 2019 22:22:41 +0000 (15:22 -0700)
Add tests for ipv6 gateway with ipv4 route. Tests include basic
single path with ping to verify connectivity and multipath.

Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/net/fib_tests.sh

index 1080ff55a788f720f240271741fbc38680061b7a..e941024869ff89cc1dbc6bbd61aba561635b555f 100755 (executable)
@@ -9,7 +9,8 @@ ret=0
 ksft_skip=4
 
 # all tests in this script. Can be overridden with -t option
-TESTS="unregister down carrier nexthop ipv6_rt ipv4_rt ipv6_addr_metric ipv4_addr_metric ipv6_route_metrics ipv4_route_metrics"
+TESTS="unregister down carrier nexthop ipv6_rt ipv4_rt ipv6_addr_metric ipv4_addr_metric ipv6_route_metrics ipv4_route_metrics ipv4_route_v6_gw"
+
 VERBOSE=0
 PAUSE_ON_FAIL=no
 PAUSE=no
@@ -48,6 +49,7 @@ setup()
 {
        set -e
        ip netns add ns1
+       ip netns set ns1 auto
        $IP link set dev lo up
        ip netns exec ns1 sysctl -qw net.ipv4.ip_forward=1
        ip netns exec ns1 sysctl -qw net.ipv6.conf.all.forwarding=1
@@ -698,6 +700,7 @@ route_setup()
        set -e
 
        ip netns add ns2
+       ip netns set ns2 auto
        ip -netns ns2 link set dev lo up
        ip netns exec ns2 sysctl -qw net.ipv4.ip_forward=1
        ip netns exec ns2 sysctl -qw net.ipv6.conf.all.forwarding=1
@@ -1442,6 +1445,70 @@ ipv4_route_metrics_test()
        route_cleanup
 }
 
+ipv4_route_v6_gw_test()
+{
+       local rc
+
+       echo
+       echo "IPv4 route with IPv6 gateway tests"
+
+       route_setup
+       sleep 2
+
+       #
+       # single path route
+       #
+       run_cmd "$IP ro add 172.16.104.0/24 via inet6 2001:db8:101::2"
+       rc=$?
+       log_test $rc 0 "Single path route with IPv6 gateway"
+       if [ $rc -eq 0 ]; then
+               check_route "172.16.104.0/24 via inet6 2001:db8:101::2 dev veth1"
+       fi
+
+       run_cmd "ip netns exec ns1 ping -w1 -c1 172.16.104.1"
+       log_test $rc 0 "Single path route with IPv6 gateway - ping"
+
+       run_cmd "$IP ro del 172.16.104.0/24 via inet6 2001:db8:101::2"
+       rc=$?
+       log_test $rc 0 "Single path route delete"
+       if [ $rc -eq 0 ]; then
+               check_route "172.16.112.0/24"
+       fi
+
+       #
+       # multipath - v6 then v4
+       #
+       run_cmd "$IP ro add 172.16.104.0/24 nexthop via inet6 2001:db8:101::2 dev veth1 nexthop via 172.16.103.2 dev veth3"
+       rc=$?
+       log_test $rc 0 "Multipath route add - v6 nexthop then v4"
+       if [ $rc -eq 0 ]; then
+               check_route "172.16.104.0/24 nexthop via inet6 2001:db8:101::2 dev veth1 weight 1 nexthop via 172.16.103.2 dev veth3 weight 1"
+       fi
+
+       run_cmd "$IP ro del 172.16.104.0/24 nexthop via 172.16.103.2 dev veth3 nexthop via inet6 2001:db8:101::2 dev veth1"
+       log_test $? 2 "    Multipath route delete - nexthops in wrong order"
+
+       run_cmd "$IP ro del 172.16.104.0/24 nexthop via inet6 2001:db8:101::2 dev veth1 nexthop via 172.16.103.2 dev veth3"
+       log_test $? 0 "    Multipath route delete exact match"
+
+       #
+       # multipath - v4 then v6
+       #
+       run_cmd "$IP ro add 172.16.104.0/24 nexthop via 172.16.103.2 dev veth3 nexthop via inet6 2001:db8:101::2 dev veth1"
+       rc=$?
+       log_test $rc 0 "Multipath route add - v4 nexthop then v6"
+       if [ $rc -eq 0 ]; then
+               check_route "172.16.104.0/24 nexthop via 172.16.103.2 dev veth3 weight 1 nexthop via inet6 2001:db8:101::2 dev veth1 weight 1"
+       fi
+
+       run_cmd "$IP ro del 172.16.104.0/24 nexthop via inet6 2001:db8:101::2 dev veth1 nexthop via 172.16.103.2 dev veth3"
+       log_test $? 2 "    Multipath route delete - nexthops in wrong order"
+
+       run_cmd "$IP ro del 172.16.104.0/24 nexthop via 172.16.103.2 dev veth3 nexthop via inet6 2001:db8:101::2 dev veth1"
+       log_test $? 0 "    Multipath route delete exact match"
+
+       route_cleanup
+}
 
 ################################################################################
 # usage
@@ -1511,6 +1578,7 @@ do
        ipv4_addr_metric)               ipv4_addr_metric_test;;
        ipv6_route_metrics)             ipv6_route_metrics_test;;
        ipv4_route_metrics)             ipv4_route_metrics_test;;
+       ipv4_route_v6_gw)               ipv4_route_v6_gw_test;;
 
        help) echo "Test names: $TESTS"; exit 0;;
        esac