WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / net / forwarding / router_vid_1.sh
bloba7306c7ac06d1afa468362d42ec50b21f99938bd
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 ALL_TESTS="ping_ipv4 ping_ipv6"
5 NUM_NETIFS=4
6 source lib.sh
8 h1_create()
10 vrf_create "vrf-h1"
11 ip link set dev vrf-h1 up
13 ip link set dev $h1 up
14 vlan_create $h1 1 vrf-h1 192.0.2.2/24 2001:db8:1::2/64
16 ip route add 198.51.100.0/24 vrf vrf-h1 nexthop via 192.0.2.1
17 ip route add 2001:db8:2::/64 vrf vrf-h1 nexthop via 2001:db8:1::1
20 h1_destroy()
22 ip route del 2001:db8:2::/64 vrf vrf-h1
23 ip route del 198.51.100.0/24 vrf vrf-h1
25 vlan_destroy $h1 1
26 ip link set dev $h1 down
28 ip link set dev vrf-h1 down
29 vrf_destroy "vrf-h1"
32 h2_create()
34 vrf_create "vrf-h2"
35 ip link set dev vrf-h2 up
37 ip link set dev $h2 up
38 vlan_create $h2 1 vrf-h2 198.51.100.2/24 2001:db8:2::2/64
40 ip route add 192.0.2.0/24 vrf vrf-h2 nexthop via 198.51.100.1
41 ip route add 2001:db8:1::/64 vrf vrf-h2 nexthop via 2001:db8:2::1
44 h2_destroy()
46 ip route del 2001:db8:1::/64 vrf vrf-h2
47 ip route del 192.0.2.0/24 vrf vrf-h2
49 vlan_destroy $h2 1
50 ip link set dev $h2 down
52 ip link set dev vrf-h2 down
53 vrf_destroy "vrf-h2"
56 router_create()
58 ip link set dev $rp1 up
59 ip link add link $rp1 name $rp1.1 up type vlan id 1
61 ip address add 192.0.2.1/24 dev $rp1.1
62 ip address add 2001:db8:1::1/64 dev $rp1.1
64 ip link set dev $rp2 up
65 ip link add link $rp2 name $rp2.1 up type vlan id 1
67 ip address add 198.51.100.1/24 dev $rp2.1
68 ip address add 2001:db8:2::1/64 dev $rp2.1
71 router_destroy()
73 ip address del 2001:db8:2::1/64 dev $rp2.1
74 ip address del 198.51.100.1/24 dev $rp2.1
76 ip link del dev $rp2.1
77 ip link set dev $rp2 down
79 ip address del 2001:db8:1::1/64 dev $rp1.1
80 ip address del 192.0.2.1/24 dev $rp1.1
82 ip link del dev $rp1.1
83 ip link set dev $rp1 down
86 setup_prepare()
88 h1=${NETIFS[p1]}
89 rp1=${NETIFS[p2]}
91 rp2=${NETIFS[p3]}
92 h2=${NETIFS[p4]}
94 vrf_prepare
96 h1_create
97 h2_create
99 router_create
101 forwarding_enable
104 cleanup()
106 pre_cleanup
108 forwarding_restore
110 router_destroy
112 h2_destroy
113 h1_destroy
115 vrf_cleanup
118 ping_ipv4()
120 ping_test $h1.1 198.51.100.2
123 ping_ipv6()
125 ping6_test $h1.1 2001:db8:2::2
128 trap cleanup EXIT
130 setup_prepare
131 setup_wait
133 tests_run
135 exit $EXIT_STATUS