1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0 3 4# This test uses standard topology for testing gretap. See 5# mirror_gre_topo_lib.sh for more details. 6# 7# Test that gretap and ip6gretap mirroring works when the other tunnel endpoint 8# is reachable through a next-hop route (as opposed to directly-attached route). 9 10ALL_TESTS=" 11 test_gretap 12 test_ip6gretap 13" 14 15NUM_NETIFS=6 16source lib.sh 17source mirror_lib.sh 18source mirror_gre_lib.sh 19source mirror_gre_topo_lib.sh 20 21setup_prepare() 22{ 23 h1=${NETIFS[p1]} 24 swp1=${NETIFS[p2]} 25 26 swp2=${NETIFS[p3]} 27 h2=${NETIFS[p4]} 28 29 swp3=${NETIFS[p5]} 30 h3=${NETIFS[p6]} 31 32 sysctl_set net.ipv4.conf.all.rp_filter 0 33 sysctl_set net.ipv4.conf.$h3.rp_filter 0 34 35 vrf_prepare 36 mirror_gre_topo_create 37 38 ip address add dev $swp3 192.0.2.161/28 39 ip address add dev $h3 192.0.2.162/28 40 ip address add dev gt4 192.0.2.129/32 41 ip address add dev h3-gt4 192.0.2.130/32 42 43 # IPv6 route can't be added after address. Such routes are rejected due 44 # to the gateway address having been configured on the local system. It 45 # works the other way around though. 46 ip address add dev $swp3 2001:db8:4::1/64 47 ip -6 route add 2001:db8:2::2/128 via 2001:db8:4::2 48 ip address add dev $h3 2001:db8:4::2/64 49 ip address add dev gt6 2001:db8:2::1 50 ip address add dev h3-gt6 2001:db8:2::2 51} 52 53cleanup() 54{ 55 pre_cleanup 56 57 ip -6 route del 2001:db8:2::2/128 via 2001:db8:4::2 58 ip address del dev $h3 2001:db8:4::2/64 59 ip address del dev $swp3 2001:db8:4::1/64 60 61 ip address del dev $h3 192.0.2.162/28 62 ip address del dev $swp3 192.0.2.161/28 63 64 mirror_gre_topo_destroy 65 vrf_cleanup 66 67 sysctl_restore net.ipv4.conf.$h3.rp_filter 68 sysctl_restore net.ipv4.conf.all.rp_filter 69} 70 71test_gretap() 72{ 73 RET=0 74 mirror_install $swp1 ingress gt4 "matchall $tcflags" 75 76 # For IPv4, test that there's no mirroring without the route directing 77 # the traffic to tunnel remote address. Then add it and test that 78 # mirroring starts. For IPv6 we can't test this due to the limitation 79 # that routes for locally-specified IPv6 addresses can't be added. 80 fail_test_span_gre_dir gt4 ingress 81 82 ip route add 192.0.2.130/32 via 192.0.2.162 83 quick_test_span_gre_dir gt4 ingress 84 ip route del 192.0.2.130/32 via 192.0.2.162 85 86 mirror_uninstall $swp1 ingress 87 log_test "mirror to gre with next-hop remote ($tcflags)" 88} 89 90test_ip6gretap() 91{ 92 RET=0 93 94 mirror_install $swp1 ingress gt6 "matchall $tcflags" 95 quick_test_span_gre_dir gt6 ingress 96 mirror_uninstall $swp1 ingress 97 98 log_test "mirror to ip6gre with next-hop remote ($tcflags)" 99} 100 101test_all() 102{ 103 slow_path_trap_install $swp1 ingress 104 slow_path_trap_install $swp1 egress 105 106 tests_run 107 108 slow_path_trap_uninstall $swp1 egress 109 slow_path_trap_uninstall $swp1 ingress 110} 111 112trap cleanup EXIT 113 114setup_prepare 115setup_wait 116 117tcflags="skip_hw" 118test_all 119 120if ! tc_offload_check; then 121 echo "WARN: Could not test offloaded functionality" 122else 123 tcflags="skip_sw" 124 test_all 125fi 126 127exit $EXIT_STATUS 128