1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0 3 4# This test uses standard topology for testing mirroring. See mirror_topo_lib.sh 5# for more details. 6# 7# Test for "tc action mirred egress mirror" that mirrors to a vlan device. 8 9ALL_TESTS=" 10 test_vlan 11 test_tagged_vlan 12" 13 14NUM_NETIFS=6 15source lib.sh 16source mirror_lib.sh 17source mirror_topo_lib.sh 18 19setup_prepare() 20{ 21 h1=${NETIFS[p1]} 22 swp1=${NETIFS[p2]} 23 24 swp2=${NETIFS[p3]} 25 h2=${NETIFS[p4]} 26 27 swp3=${NETIFS[p5]} 28 h3=${NETIFS[p6]} 29 30 vrf_prepare 31 mirror_topo_create 32 33 vlan_create $swp3 555 34 35 vlan_create $h3 555 v$h3 36 matchall_sink_create $h3.555 37 38 vlan_create $h1 111 v$h1 192.0.2.17/28 39 bridge vlan add dev $swp1 vid 111 40 41 vlan_create $h2 111 v$h2 192.0.2.18/28 42 bridge vlan add dev $swp2 vid 111 43 44 trap_install $h3 ingress 45} 46 47cleanup() 48{ 49 pre_cleanup 50 51 trap_uninstall $h3 ingress 52 53 vlan_destroy $h2 111 54 vlan_destroy $h1 111 55 vlan_destroy $h3 555 56 vlan_destroy $swp3 555 57 58 mirror_topo_destroy 59 vrf_cleanup 60} 61 62test_vlan_dir() 63{ 64 local direction=$1; shift 65 local forward_type=$1; shift 66 local backward_type=$1; shift 67 68 RET=0 69 70 mirror_install $swp1 $direction $swp3.555 "matchall" 71 test_span_dir "$h3.555" "$forward_type" "$backward_type" 72 mirror_uninstall $swp1 $direction 73 74 log_test "$direction mirror to vlan" 75} 76 77test_vlan() 78{ 79 test_vlan_dir ingress 8 0 80 test_vlan_dir egress 0 8 81} 82 83test_tagged_vlan_dir() 84{ 85 local direction=$1; shift 86 local forward_type=$1; shift 87 local backward_type=$1; shift 88 89 RET=0 90 91 mirror_install $swp1 $direction $swp3.555 "matchall" 92 do_test_span_vlan_dir_ips '>= 10' "$h3.555" 111 ip 192.0.2.17 192.0.2.18 93 do_test_span_vlan_dir_ips 0 "$h3.555" 555 ip 192.0.2.17 192.0.2.18 94 mirror_uninstall $swp1 $direction 95 96 log_test "$direction mirror tagged to vlan" 97} 98 99test_tagged_vlan() 100{ 101 test_tagged_vlan_dir ingress 8 0 102 test_tagged_vlan_dir egress 0 8 103} 104 105trap cleanup EXIT 106 107setup_prepare 108setup_wait 109 110tests_run 111 112exit $EXIT_STATUS 113