~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/net/forwarding/router_vid_1.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/bash
  2 # SPDX-License-Identifier: GPL-2.0
  3 
  4 # +--------------------+                     +----------------------+
  5 # | H1                 |                     |                   H2 |
  6 # |                    |                     |                      |
  7 # |            $h1.1 + |                     | + $h2.1              |
  8 # |     192.0.2.2/24 | |                     | | 198.51.100.2/24    |
  9 # | 2001:db8:1::2/64 | |                     | | 2001:db8:2::2/64   |
 10 # |                  | |                     | |                    |
 11 # |              $h1 + |                     | + $h2                |
 12 # |                  | |                     | |                    |
 13 # +------------------|-+                     +-|--------------------+
 14 #                    |                         |
 15 # +------------------|-------------------------|--------------------+
 16 # | SW               |                         |                    |
 17 # |                  |                         |                    |
 18 # |             $rp1 +                         + $rp2               |
 19 # |                  |                         |                    |
 20 # |           $rp1.1 +                         + $rp2.1             |
 21 # |     192.0.2.1/24                             198.51.100.1/24    |
 22 # | 2001:db8:1::1/64                             2001:db8:2::1/64   |
 23 # |                                                                 |
 24 # +-----------------------------------------------------------------+
 25 
 26 ALL_TESTS="
 27         ping_ipv4
 28         ping_ipv6
 29 "
 30 NUM_NETIFS=4
 31 source lib.sh
 32 
 33 h1_create()
 34 {
 35         vrf_create "vrf-h1"
 36         ip link set dev vrf-h1 up
 37 
 38         ip link set dev $h1 up
 39         vlan_create $h1 1 vrf-h1 192.0.2.2/24 2001:db8:1::2/64
 40 
 41         ip route add 198.51.100.0/24 vrf vrf-h1 nexthop via 192.0.2.1
 42         ip route add 2001:db8:2::/64 vrf vrf-h1 nexthop via 2001:db8:1::1
 43 }
 44 
 45 h1_destroy()
 46 {
 47         ip route del 2001:db8:2::/64 vrf vrf-h1
 48         ip route del 198.51.100.0/24 vrf vrf-h1
 49 
 50         vlan_destroy $h1 1
 51         ip link set dev $h1 down
 52 
 53         ip link set dev vrf-h1 down
 54         vrf_destroy "vrf-h1"
 55 }
 56 
 57 h2_create()
 58 {
 59         vrf_create "vrf-h2"
 60         ip link set dev vrf-h2 up
 61 
 62         ip link set dev $h2 up
 63         vlan_create $h2 1 vrf-h2 198.51.100.2/24 2001:db8:2::2/64
 64 
 65         ip route add 192.0.2.0/24 vrf vrf-h2 nexthop via 198.51.100.1
 66         ip route add 2001:db8:1::/64 vrf vrf-h2 nexthop via 2001:db8:2::1
 67 }
 68 
 69 h2_destroy()
 70 {
 71         ip route del 2001:db8:1::/64 vrf vrf-h2
 72         ip route del 192.0.2.0/24 vrf vrf-h2
 73 
 74         vlan_destroy $h2 1
 75         ip link set dev $h2 down
 76 
 77         ip link set dev vrf-h2 down
 78         vrf_destroy "vrf-h2"
 79 }
 80 
 81 router_create()
 82 {
 83         ip link set dev $rp1 up
 84         ip link add link $rp1 name $rp1.1 up type vlan id 1
 85 
 86         ip address add 192.0.2.1/24 dev $rp1.1
 87         ip address add 2001:db8:1::1/64 dev $rp1.1
 88 
 89         ip link set dev $rp2 up
 90         ip link add link $rp2 name $rp2.1 up type vlan id 1
 91 
 92         ip address add 198.51.100.1/24 dev $rp2.1
 93         ip address add 2001:db8:2::1/64 dev $rp2.1
 94 }
 95 
 96 router_destroy()
 97 {
 98         ip address del 2001:db8:2::1/64 dev $rp2.1
 99         ip address del 198.51.100.1/24 dev $rp2.1
100 
101         ip link del dev $rp2.1
102         ip link set dev $rp2 down
103 
104         ip address del 2001:db8:1::1/64 dev $rp1.1
105         ip address del 192.0.2.1/24 dev $rp1.1
106 
107         ip link del dev $rp1.1
108         ip link set dev $rp1 down
109 }
110 
111 setup_prepare()
112 {
113         h1=${NETIFS[p1]}
114         rp1=${NETIFS[p2]}
115 
116         rp2=${NETIFS[p3]}
117         h2=${NETIFS[p4]}
118 
119         vrf_prepare
120 
121         h1_create
122         h2_create
123 
124         router_create
125 
126         forwarding_enable
127 }
128 
129 cleanup()
130 {
131         pre_cleanup
132 
133         forwarding_restore
134 
135         router_destroy
136 
137         h2_destroy
138         h1_destroy
139 
140         vrf_cleanup
141 }
142 
143 ping_ipv4()
144 {
145         ping_test $h1.1 198.51.100.2
146 }
147 
148 ping_ipv6()
149 {
150         ping6_test $h1.1 2001:db8:2::2
151 }
152 
153 trap cleanup EXIT
154 
155 setup_prepare
156 setup_wait
157 
158 tests_run
159 
160 exit $EXIT_STATUS

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php