Back to home page

OSCL-LXR

 
 

    


0001 # SPDX-License-Identifier: GPL-2.0
0002 
0003 # This is the standard topology for testing mirroring. The tests that use it
0004 # tweak it in one way or another--typically add more devices to the topology.
0005 #
0006 #   +---------------------+                             +---------------------+
0007 #   | H1                  |                             |                  H2 |
0008 #   |     + $h1           |                             |           $h2 +     |
0009 #   |     | 192.0.2.1/28  |                             |  192.0.2.2/28 |     |
0010 #   +-----|---------------+                             +---------------|-----+
0011 #         |                                                             |
0012 #   +-----|-------------------------------------------------------------|-----+
0013 #   | SW  o--> mirror                                                   |     |
0014 #   | +---|-------------------------------------------------------------|---+ |
0015 #   | |   + $swp1                    BR                           $swp2 +   | |
0016 #   | +---------------------------------------------------------------------+ |
0017 #   |                                                                         |
0018 #   |     + $swp3                                                             |
0019 #   +-----|-------------------------------------------------------------------+
0020 #         |
0021 #   +-----|-------------------------------------------------------------------+
0022 #   | H3  + $h3                                                               |
0023 #   |                                                                         |
0024 #   +-------------------------------------------------------------------------+
0025 
0026 mirror_topo_h1_create()
0027 {
0028         simple_if_init $h1 192.0.2.1/28
0029 }
0030 
0031 mirror_topo_h1_destroy()
0032 {
0033         simple_if_fini $h1 192.0.2.1/28
0034 }
0035 
0036 mirror_topo_h2_create()
0037 {
0038         simple_if_init $h2 192.0.2.2/28
0039 }
0040 
0041 mirror_topo_h2_destroy()
0042 {
0043         simple_if_fini $h2 192.0.2.2/28
0044 }
0045 
0046 mirror_topo_h3_create()
0047 {
0048         simple_if_init $h3
0049         tc qdisc add dev $h3 clsact
0050 }
0051 
0052 mirror_topo_h3_destroy()
0053 {
0054         tc qdisc del dev $h3 clsact
0055         simple_if_fini $h3
0056 }
0057 
0058 mirror_topo_switch_create()
0059 {
0060         ip link set dev $swp3 up
0061 
0062         ip link add name br1 type bridge vlan_filtering 1
0063         ip link set dev br1 up
0064 
0065         ip link set dev $swp1 master br1
0066         ip link set dev $swp1 up
0067 
0068         ip link set dev $swp2 master br1
0069         ip link set dev $swp2 up
0070 
0071         tc qdisc add dev $swp1 clsact
0072 }
0073 
0074 mirror_topo_switch_destroy()
0075 {
0076         tc qdisc del dev $swp1 clsact
0077 
0078         ip link set dev $swp1 down
0079         ip link set dev $swp2 down
0080         ip link del dev br1
0081 
0082         ip link set dev $swp3 down
0083 }
0084 
0085 mirror_topo_create()
0086 {
0087         mirror_topo_h1_create
0088         mirror_topo_h2_create
0089         mirror_topo_h3_create
0090 
0091         mirror_topo_switch_create
0092 }
0093 
0094 mirror_topo_destroy()
0095 {
0096         mirror_topo_switch_destroy
0097 
0098         mirror_topo_h3_destroy
0099         mirror_topo_h2_destroy
0100         mirror_topo_h1_destroy
0101 }