brintos

brintos / linux-shallow public Read only

0
0
Text · 3.8 KiB · e1ad623 Raw
203 lines · bash
1#!/bin/bash2# SPDX-License-Identifier: GPL-2.03 4# This test uses standard topology for testing gretap. See5# ../../../net/forwarding/mirror_gre_topo_lib.sh for more details.6#7# Test offloading various features of offloading gretap mirrors specific to8# mlxsw.9 10lib_dir=$(dirname $0)/../../../net/forwarding11 12NUM_NETIFS=613source $lib_dir/lib.sh14source $lib_dir/mirror_lib.sh15source $lib_dir/mirror_gre_lib.sh16source $lib_dir/mirror_gre_topo_lib.sh17 18ALL_TESTS="19	test_keyful20	test_soft21	test_tos_fixed22	test_ttl_inherit23"24 25setup_keyful()26{27	tunnel_create gt6-key ip6gretap 2001:db8:3::1 2001:db8:3::2 \28		      ttl 100 tos inherit allow-localremote \29		      key 123430 31	tunnel_create h3-gt6-key ip6gretap 2001:db8:3::2 2001:db8:3::1 \32		      key 123433	ip link set h3-gt6-key vrf v$h334	matchall_sink_create h3-gt6-key35 36	ip address add dev $swp3 2001:db8:3::1/6437	ip address add dev $h3 2001:db8:3::2/6438}39 40cleanup_keyful()41{42	ip address del dev $h3 2001:db8:3::2/6443	ip address del dev $swp3 2001:db8:3::1/6444 45	tunnel_destroy h3-gt6-key46	tunnel_destroy gt6-key47}48 49setup_soft()50{51	# Set up a topology for testing underlay routes that point at an52	# unsupported soft device.53 54	tunnel_create gt6-soft ip6gretap 2001:db8:4::1 2001:db8:4::2 \55		      ttl 100 tos inherit allow-localremote56 57	tunnel_create h3-gt6-soft ip6gretap 2001:db8:4::2 2001:db8:4::158	ip link set h3-gt6-soft vrf v$h359	matchall_sink_create h3-gt6-soft60 61	ip link add name v1 type veth peer name v262	ip link set dev v1 up63	ip address add dev v1 2001:db8:4::1/6464 65	ip link set dev v2 vrf v$h366	ip link set dev v2 up67	ip address add dev v2 2001:db8:4::2/6468}69 70cleanup_soft()71{72	ip link del dev v173 74	tunnel_destroy h3-gt6-soft75	tunnel_destroy gt6-soft76}77 78setup_prepare()79{80	h1=${NETIFS[p1]}81	swp1=${NETIFS[p2]}82 83	swp2=${NETIFS[p3]}84	h2=${NETIFS[p4]}85 86	swp3=${NETIFS[p5]}87	h3=${NETIFS[p6]}88 89	vrf_prepare90	mirror_gre_topo_create91 92	ip address add dev $swp3 2001:db8:2::1/6493	ip address add dev $h3 2001:db8:2::2/6494 95	ip address add dev $swp3 192.0.2.129/2896	ip address add dev $h3 192.0.2.130/2897 98	setup_keyful99	setup_soft100}101 102cleanup()103{104	pre_cleanup105 106	cleanup_soft107	cleanup_keyful108 109	ip address del dev $h3 2001:db8:2::2/64110	ip address del dev $swp3 2001:db8:2::1/64111 112	ip address del dev $h3 192.0.2.130/28113	ip address del dev $swp3 192.0.2.129/28114 115	mirror_gre_topo_destroy116	vrf_cleanup117}118 119test_span_gre_ttl_inherit()120{121	local tundev=$1; shift122	local type=$1; shift123	local what=$1; shift124 125	RET=0126 127	ip link set dev $tundev type $type ttl inherit128	mirror_install $swp1 ingress $tundev "matchall"129	fail_test_span_gre_dir $tundev130 131	ip link set dev $tundev type $type ttl 100132 133	quick_test_span_gre_dir $tundev134	mirror_uninstall $swp1 ingress135 136	log_test "$what: no offload on TTL of inherit"137}138 139test_span_gre_tos_fixed()140{141	local tundev=$1; shift142	local type=$1; shift143	local what=$1; shift144 145	RET=0146 147	ip link set dev $tundev type $type tos 0x10148	mirror_install $swp1 ingress $tundev "matchall"149	fail_test_span_gre_dir $tundev150 151	ip link set dev $tundev type $type tos inherit152	quick_test_span_gre_dir $tundev153	mirror_uninstall $swp1 ingress154 155	log_test "$what: no offload on a fixed TOS"156}157 158test_span_failable()159{160	local tundev=$1; shift161	local what=$1; shift162 163	RET=0164 165	mirror_install $swp1 ingress $tundev "matchall"166	fail_test_span_gre_dir  $tundev167	mirror_uninstall $swp1 ingress168 169	log_test "fail $what"170}171 172test_keyful()173{174	test_span_failable gt6-key "mirror to keyful gretap"175}176 177test_soft()178{179	test_span_failable gt6-soft "mirror to gretap w/ soft underlay"180}181 182test_tos_fixed()183{184	test_span_gre_tos_fixed gt4 gretap "mirror to gretap"185	test_span_gre_tos_fixed gt6 ip6gretap "mirror to ip6gretap"186}187 188 189test_ttl_inherit()190{191	test_span_gre_ttl_inherit gt4 gretap "mirror to gretap"192	test_span_gre_ttl_inherit gt6 ip6gretap "mirror to ip6gretap"193}194 195trap cleanup EXIT196 197setup_prepare198setup_wait199 200tests_run201 202exit $EXIT_STATUS203