brintos

brintos / linux-shallow public Read only

0
0
Text · 2.9 KiB · 921c733 Raw
142 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 for "tc action mirred egress mirror" when the device to mirror to is a8# gretap or ip6gretap netdevice. Expect that the packets come out encapsulated,9# and another gretap / ip6gretap netdevice is then capable of decapsulating the10# traffic. Test that the payload is what is expected (ICMP ping request or11# reply, depending on test).12 13ALL_TESTS="14	test_gretap15	test_ip6gretap16	test_gretap_mac17	test_ip6gretap_mac18	test_two_spans19"20 21NUM_NETIFS=622source lib.sh23source mirror_lib.sh24source mirror_gre_lib.sh25source mirror_gre_topo_lib.sh26 27setup_prepare()28{29	h1=${NETIFS[p1]}30	swp1=${NETIFS[p2]}31 32	swp2=${NETIFS[p3]}33	h2=${NETIFS[p4]}34 35	swp3=${NETIFS[p5]}36	h3=${NETIFS[p6]}37 38	vrf_prepare39	mirror_gre_topo_create40 41	ip address add dev $swp3 192.0.2.129/2842	ip address add dev $h3 192.0.2.130/2843 44	ip address add dev $swp3 2001:db8:2::1/6445	ip address add dev $h3 2001:db8:2::2/6446}47 48cleanup()49{50	pre_cleanup51 52	ip address del dev $h3 2001:db8:2::2/6453	ip address del dev $swp3 2001:db8:2::1/6454 55	ip address del dev $h3 192.0.2.130/2856	ip address del dev $swp3 192.0.2.129/2857 58	mirror_gre_topo_destroy59	vrf_cleanup60}61 62test_span_gre_mac()63{64	local tundev=$1; shift65	local direction=$1; shift66	local what=$1; shift67 68	case "$direction" in69	ingress) local src_mac=$(mac_get $h1); local dst_mac=$(mac_get $h2)70		;;71	egress) local src_mac=$(mac_get $h2); local dst_mac=$(mac_get $h1)72		;;73	esac74 75	RET=076 77	mirror_install $swp1 $direction $tundev "matchall"78	icmp_capture_install h3-${tundev} "src_mac $src_mac dst_mac $dst_mac"79 80	mirror_test v$h1 192.0.2.1 192.0.2.2 h3-${tundev} 100 1081 82	icmp_capture_uninstall h3-${tundev}83	mirror_uninstall $swp1 $direction84 85	log_test "$direction $what: envelope MAC"86}87 88test_two_spans()89{90	RET=091 92	mirror_install $swp1 ingress gt4 "matchall"93	mirror_install $swp1 egress gt6 "matchall"94	quick_test_span_gre_dir gt4 8 095	quick_test_span_gre_dir gt6 0 896 97	mirror_uninstall $swp1 ingress98	fail_test_span_gre_dir gt4 8 099	quick_test_span_gre_dir gt6 0 8100 101	mirror_install $swp1 ingress gt4 "matchall"102	mirror_uninstall $swp1 egress103	quick_test_span_gre_dir gt4 8 0104	fail_test_span_gre_dir gt6 0 8105 106	mirror_uninstall $swp1 ingress107	log_test "two simultaneously configured mirrors"108}109 110test_gretap()111{112	full_test_span_gre_dir gt4 ingress 8 0 "mirror to gretap"113	full_test_span_gre_dir gt4 egress 0 8 "mirror to gretap"114}115 116test_ip6gretap()117{118	full_test_span_gre_dir gt6 ingress 8 0 "mirror to ip6gretap"119	full_test_span_gre_dir gt6 egress 0 8 "mirror to ip6gretap"120}121 122test_gretap_mac()123{124	test_span_gre_mac gt4 ingress "mirror to gretap"125	test_span_gre_mac gt4 egress "mirror to gretap"126}127 128test_ip6gretap_mac()129{130	test_span_gre_mac gt6 ingress "mirror to ip6gretap"131	test_span_gre_mac gt6 egress "mirror to ip6gretap"132}133 134trap cleanup EXIT135 136setup_prepare137setup_wait138 139tests_run140 141exit $EXIT_STATUS142