brintos

brintos / linux-shallow public Read only

0
0
Text · 2.5 KiB · 34bc646 Raw
113 lines · bash
1#!/bin/bash2# SPDX-License-Identifier: GPL-2.03 4# This test uses standard topology for testing gretap. See5# mirror_gre_topo_lib.sh for more details.6#7# Test that gretap and ip6gretap mirroring works when the other tunnel endpoint8# is reachable through a next-hop route (as opposed to directly-attached route).9 10ALL_TESTS="11	test_gretap12	test_ip6gretap13"14 15NUM_NETIFS=616source lib.sh17source mirror_lib.sh18source mirror_gre_lib.sh19source mirror_gre_topo_lib.sh20 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 033	sysctl_set net.ipv4.conf.$h3.rp_filter 034 35	vrf_prepare36	mirror_gre_topo_create37 38	sysctl_set net.ipv4.conf.v$h3.rp_filter 039 40	ip address add dev $swp3 192.0.2.161/2841	ip address add dev $h3 192.0.2.162/2842	ip address add dev gt4 192.0.2.129/3243	ip address add dev h3-gt4 192.0.2.130/3244 45	# IPv6 route can't be added after address. Such routes are rejected due46	# to the gateway address having been configured on the local system. It47	# works the other way around though.48	ip address add dev $swp3 2001:db8:4::1/6449	ip -6 route add 2001:db8:2::2/128 via 2001:db8:4::250	ip address add dev $h3 2001:db8:4::2/6451	ip address add dev gt6 2001:db8:2::152	ip address add dev h3-gt6 2001:db8:2::253}54 55cleanup()56{57	pre_cleanup58 59	ip -6 route del 2001:db8:2::2/128 via 2001:db8:4::260	ip address del dev $h3 2001:db8:4::2/6461	ip address del dev $swp3 2001:db8:4::1/6462 63	ip address del dev $h3 192.0.2.162/2864	ip address del dev $swp3 192.0.2.161/2865 66	sysctl_restore net.ipv4.conf.v$h3.rp_filter 067 68	mirror_gre_topo_destroy69	vrf_cleanup70 71	sysctl_restore net.ipv4.conf.$h3.rp_filter72	sysctl_restore net.ipv4.conf.all.rp_filter73}74 75test_gretap()76{77	RET=078	mirror_install $swp1 ingress gt4 "matchall"79 80	# For IPv4, test that there's no mirroring without the route directing81	# the traffic to tunnel remote address. Then add it and test that82	# mirroring starts. For IPv6 we can't test this due to the limitation83	# that routes for locally-specified IPv6 addresses can't be added.84	fail_test_span_gre_dir gt485 86	ip route add 192.0.2.130/32 via 192.0.2.16287	quick_test_span_gre_dir gt488	ip route del 192.0.2.130/32 via 192.0.2.16289 90	mirror_uninstall $swp1 ingress91	log_test "mirror to gre with next-hop remote"92}93 94test_ip6gretap()95{96	RET=097 98	mirror_install $swp1 ingress gt6 "matchall"99	quick_test_span_gre_dir gt6100	mirror_uninstall $swp1 ingress101 102	log_test "mirror to ip6gre with next-hop remote"103}104 105trap cleanup EXIT106 107setup_prepare108setup_wait109 110tests_run111 112exit $EXIT_STATUS113