1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3#
4# This test is for checking the FIB offload API on top of mlxsw.
5
6lib_dir=$(dirname $0)/../../../net/forwarding
7
8ALL_TESTS="
9	ipv4_identical_routes
10	ipv4_tos
11	ipv4_metric
12	ipv4_replace
13	ipv4_delete
14	ipv4_plen
15	ipv4_replay
16	ipv4_flush
17	ipv6_add
18	ipv6_metric
19	ipv6_append_single
20	ipv6_replace_single
21	ipv6_metric_multipath
22	ipv6_append_multipath
23	ipv6_replace_multipath
24	ipv6_append_multipath_to_single
25	ipv6_delete_single
26	ipv6_delete_multipath
27	ipv6_replay_single
28	ipv6_replay_multipath
29"
30NUM_NETIFS=0
31source $lib_dir/lib.sh
32source $lib_dir/devlink_lib.sh
33source $lib_dir/fib_offload_lib.sh
34
35ipv4_identical_routes()
36{
37	fib_ipv4_identical_routes_test "testns1"
38}
39
40ipv4_tos()
41{
42	fib_ipv4_tos_test "testns1"
43}
44
45ipv4_metric()
46{
47	fib_ipv4_metric_test "testns1"
48}
49
50ipv4_replace()
51{
52	fib_ipv4_replace_test "testns1"
53}
54
55ipv4_delete()
56{
57	fib_ipv4_delete_test "testns1"
58}
59
60ipv4_plen()
61{
62	fib_ipv4_plen_test "testns1"
63}
64
65ipv4_replay_metric()
66{
67	fib_ipv4_replay_metric_test "testns1" "$DEVLINK_DEV"
68}
69
70ipv4_replay_tos()
71{
72	fib_ipv4_replay_tos_test "testns1" "$DEVLINK_DEV"
73}
74
75ipv4_replay_plen()
76{
77	fib_ipv4_replay_plen_test "testns1" "$DEVLINK_DEV"
78}
79
80ipv4_replay()
81{
82	ipv4_replay_metric
83	ipv4_replay_tos
84	ipv4_replay_plen
85}
86
87ipv4_flush()
88{
89	fib_ipv4_flush_test "testns1"
90}
91
92ipv6_add()
93{
94	fib_ipv6_add_test "testns1"
95}
96
97ipv6_metric()
98{
99	fib_ipv6_metric_test "testns1"
100}
101
102ipv6_append_single()
103{
104	fib_ipv6_append_single_test "testns1"
105}
106
107ipv6_replace_single()
108{
109	fib_ipv6_replace_single_test "testns1"
110}
111
112ipv6_metric_multipath()
113{
114	fib_ipv6_metric_multipath_test "testns1"
115}
116
117ipv6_append_multipath()
118{
119	fib_ipv6_append_multipath_test "testns1"
120}
121
122ipv6_replace_multipath()
123{
124	fib_ipv6_replace_multipath_test "testns1"
125}
126
127ipv6_append_multipath_to_single()
128{
129	fib_ipv6_append_multipath_to_single_test "testns1"
130}
131
132ipv6_delete_single()
133{
134	fib_ipv6_delete_single_test "testns1"
135}
136
137ipv6_delete_multipath()
138{
139	fib_ipv6_delete_multipath_test "testns1"
140}
141
142ipv6_replay_single()
143{
144	fib_ipv6_replay_single_test "testns1" "$DEVLINK_DEV"
145}
146
147ipv6_replay_multipath()
148{
149	fib_ipv6_replay_multipath_test "testns1" "$DEVLINK_DEV"
150}
151
152setup_prepare()
153{
154	ip netns add testns1
155	if [ $? -ne 0 ]; then
156		echo "Failed to add netns \"testns1\""
157		exit 1
158	fi
159
160	devlink dev reload $DEVLINK_DEV netns testns1
161	if [ $? -ne 0 ]; then
162		echo "Failed to reload into netns \"testns1\""
163		exit 1
164	fi
165}
166
167cleanup()
168{
169	pre_cleanup
170	devlink -N testns1 dev reload $DEVLINK_DEV netns $$
171	ip netns del testns1
172}
173
174trap cleanup EXIT
175
176setup_prepare
177
178tests_run
179
180exit $EXIT_STATUS
181