WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / net / forwarding / router_nh.sh
blobf3a53738bdcc31766460b621a0ead193f8f97819
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 ALL_TESTS="
5 ping_ipv4
6 ping_ipv6
9 NUM_NETIFS=4
10 source lib.sh
11 source tc_common.sh
13 h1_create()
15 vrf_create "vrf-h1"
16 ip link set dev $h1 master vrf-h1
18 ip link set dev vrf-h1 up
19 ip link set dev $h1 up
21 ip address add 192.0.2.2/24 dev $h1
22 ip address add 2001:db8:1::2/64 dev $h1
24 ip route add 198.51.100.0/24 vrf vrf-h1 nexthop via 192.0.2.1
25 ip route add 2001:db8:2::/64 vrf vrf-h1 nexthop via 2001:db8:1::1
28 h1_destroy()
30 ip route del 2001:db8:2::/64 vrf vrf-h1
31 ip route del 198.51.100.0/24 vrf vrf-h1
33 ip address del 2001:db8:1::2/64 dev $h1
34 ip address del 192.0.2.2/24 dev $h1
36 ip link set dev $h1 down
37 vrf_destroy "vrf-h1"
40 h2_create()
42 vrf_create "vrf-h2"
43 ip link set dev $h2 master vrf-h2
45 ip link set dev vrf-h2 up
46 ip link set dev $h2 up
48 ip address add 198.51.100.2/24 dev $h2
49 ip address add 2001:db8:2::2/64 dev $h2
51 ip route add 192.0.2.0/24 vrf vrf-h2 nexthop via 198.51.100.1
52 ip route add 2001:db8:1::/64 vrf vrf-h2 nexthop via 2001:db8:2::1
55 h2_destroy()
57 ip route del 2001:db8:1::/64 vrf vrf-h2
58 ip route del 192.0.2.0/24 vrf vrf-h2
60 ip address del 2001:db8:2::2/64 dev $h2
61 ip address del 198.51.100.2/24 dev $h2
63 ip link set dev $h2 down
64 vrf_destroy "vrf-h2"
67 router_create()
69 ip link set dev $rp1 up
70 ip link set dev $rp2 up
72 tc qdisc add dev $rp2 clsact
74 ip address add 192.0.2.1/24 dev $rp1
75 ip address add 2001:db8:1::1/64 dev $rp1
77 ip address add 198.51.100.1/24 dev $rp2
78 ip address add 2001:db8:2::1/64 dev $rp2
81 router_destroy()
83 ip address del 2001:db8:2::1/64 dev $rp2
84 ip address del 198.51.100.1/24 dev $rp2
86 ip address del 2001:db8:1::1/64 dev $rp1
87 ip address del 192.0.2.1/24 dev $rp1
89 tc qdisc del dev $rp2 clsact
91 ip link set dev $rp2 down
92 ip link set dev $rp1 down
95 routing_nh_obj()
97 # Create the nexthops as AF_INET6, so that IPv4 and IPv6 routes could
98 # use them.
99 ip -6 nexthop add id 101 dev $rp1
100 ip -6 nexthop add id 102 dev $rp2
102 ip route replace 192.0.2.0/24 nhid 101
103 ip route replace 2001:db8:1::/64 nhid 101
104 ip route replace 198.51.100.0/24 nhid 102
105 ip route replace 2001:db8:2::/64 nhid 102
108 setup_prepare()
110 h1=${NETIFS[p1]}
111 rp1=${NETIFS[p2]}
113 rp2=${NETIFS[p3]}
114 h2=${NETIFS[p4]}
116 rp1mac=$(mac_get $rp1)
118 vrf_prepare
120 h1_create
121 h2_create
123 router_create
125 forwarding_enable
128 cleanup()
130 pre_cleanup
132 forwarding_restore
134 router_destroy
136 h2_destroy
137 h1_destroy
139 vrf_cleanup
142 ping_ipv4()
144 ping_test $h1 198.51.100.2
147 ping_ipv6()
149 ping6_test $h1 2001:db8:2::2
152 trap cleanup EXIT
154 setup_prepare
155 setup_wait
156 routing_nh_obj
158 tests_run
160 exit $EXIT_STATUS