1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3#
4# Test operations that we expect to report extended ack.
5
6lib_dir=$(dirname $0)/../../../net/forwarding
7
8ALL_TESTS="
9	netdev_pre_up_test
10	vxlan_vlan_add_test
11	port_vlan_add_test
12"
13NUM_NETIFS=2
14source $lib_dir/lib.sh
15
16setup_prepare()
17{
18	swp1=${NETIFS[p1]}
19	swp2=${NETIFS[p2]}
20
21	ip link set dev $swp1 up
22	ip link set dev $swp2 up
23}
24
25cleanup()
26{
27	pre_cleanup
28
29	ip link set dev $swp2 down
30	ip link set dev $swp1 down
31}
32
33netdev_pre_up_test()
34{
35	RET=0
36
37	ip link add name br1 up type bridge vlan_filtering 0 mcast_snooping 0
38	ip link add name vx1 up type vxlan id 1000 \
39		local 192.0.2.17 remote 192.0.2.18 \
40		dstport 4789 nolearning noudpcsum tos inherit ttl 100
41
42	ip link set dev vx1 master br1
43	check_err $?
44
45	ip link set dev $swp1 master br1
46	check_err $?
47
48	ip link add name br2 up type bridge vlan_filtering 0 mcast_snooping 0
49	ip link add name vx2 up type vxlan id 2000 \
50		local 192.0.2.17 remote 192.0.2.18 \
51		dstport 4789 nolearning noudpcsum tos inherit ttl 100
52
53	ip link set dev vx2 master br2
54	check_err $?
55
56	ip link set dev $swp2 master br2
57	check_err $?
58
59	# Unsupported configuration: mlxsw demands that all offloaded VXLAN
60	# devices have the same TTL.
61	ip link set dev vx2 down
62	ip link set dev vx2 type vxlan ttl 200
63
64	ip link set dev vx2 up &>/dev/null
65	check_fail $?
66
67	ip link set dev vx2 up 2>&1 >/dev/null | grep -q mlxsw_spectrum
68	check_err $?
69
70	log_test "extack - NETDEV_PRE_UP"
71
72	ip link del dev vx2
73	ip link del dev br2
74
75	ip link del dev vx1
76	ip link del dev br1
77}
78
79vxlan_vlan_add_test()
80{
81	RET=0
82
83	ip link add name br1 up type bridge vlan_filtering 1 mcast_snooping 0
84
85	# Unsupported configuration: mlxsw demands VXLAN with "noudpcsum".
86	ip link add name vx1 up type vxlan id 1000 \
87		local 192.0.2.17 remote 192.0.2.18 \
88		dstport 4789 tos inherit ttl 100
89
90	ip link set dev vx1 master br1
91	check_err $?
92
93	bridge vlan add dev vx1 vid 1
94	check_err $?
95
96	ip link set dev $swp1 master br1
97	check_err $?
98
99	bridge vlan add dev vx1 vid 1 pvid untagged 2>&1 >/dev/null \
100		| grep -q mlxsw_spectrum
101	check_err $?
102
103	log_test "extack - map VLAN at VXLAN device"
104
105	ip link del dev vx1
106	ip link del dev br1
107}
108
109port_vlan_add_test()
110{
111	RET=0
112
113	ip link add name br1 up type bridge vlan_filtering 1 mcast_snooping 0
114
115	# Unsupported configuration: mlxsw demands VXLAN with "noudpcsum".
116	ip link add name vx1 up type vxlan id 1000 \
117		local 192.0.2.17 remote 192.0.2.18 \
118		dstport 4789 tos inherit ttl 100
119
120	ip link set dev $swp1 master br1
121	check_err $?
122
123	bridge vlan del dev $swp1 vid 1
124
125	ip link set dev vx1 master br1
126	check_err $?
127
128	bridge vlan add dev $swp1 vid 1 pvid untagged 2>&1 >/dev/null \
129		| grep -q mlxsw_spectrum
130	check_err $?
131
132	log_test "extack - map VLAN at port"
133
134	ip link del dev vx1
135	ip link del dev br1
136}
137
138trap cleanup EXIT
139
140setup_prepare
141setup_wait
142
143tests_run
144
145exit $EXIT_STATUS
146