summaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/drivers/net/mlxsw/extack.sh
blob: d72d8488a3b22748a2d268ddae45724aba568808 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# Test operations that we expect to report extended ack.

lib_dir=$(dirname $0)/../../../net/forwarding

ALL_TESTS="
	netdev_pre_up_test
	vxlan_vlan_add_test
	port_vlan_add_test
"
NUM_NETIFS=2
source $lib_dir/lib.sh

setup_prepare()
{
	swp1=${NETIFS[p1]}
	swp2=${NETIFS[p2]}

	ip link set dev $swp1 up
	ip link set dev $swp2 up
}

cleanup()
{
	pre_cleanup

	ip link set dev $swp2 down
	ip link set dev $swp1 down
}

netdev_pre_up_test()
{
	RET=0

	ip link add name br1 up type bridge vlan_filtering 0 mcast_snooping 0
	ip link add name vx1 up type vxlan id 1000 \
		local 192.0.2.17 remote 192.0.2.18 \
		dstport 4789 nolearning noudpcsum tos inherit ttl 100

	ip link set dev vx1 master br1
	check_err $?

	ip link set dev $swp1 master br1
	check_err $?

	ip link add name br2 up type bridge vlan_filtering 0 mcast_snooping 0
	ip link add name vx2 up type vxlan id 2000 \
		local 192.0.2.17 remote 192.0.2.18 \
		dstport 4789 nolearning noudpcsum tos inherit ttl 100

	ip link set dev vx2 master br2
	check_err $?

	ip link set dev $swp2 master br2
	check_err $?

	# Unsupported configuration: mlxsw demands that all offloaded VXLAN
	# devices have the same TTL.
	ip link set dev vx2 down
	ip link set dev vx2 type vxlan ttl 200

	ip link set dev vx2 up &>/dev/null
	check_fail $?

	ip link set dev vx2 up 2>&1 >/dev/null | grep -q mlxsw_spectrum
	check_err $?

	log_test "extack - NETDEV_PRE_UP"

	ip link del dev vx2
	ip link del dev br2

	ip link del dev vx1
	ip link del dev br1
}

vxlan_vlan_add_test()
{
	RET=0

	ip link add name br1 up type bridge vlan_filtering 1 mcast_snooping 0

	# Unsupported configuration: mlxsw demands VXLAN with "noudpcsum".
	ip link add name vx1 up type vxlan id 1000 \
		local 192.0.2.17 remote 192.0.2.18 \
		dstport 4789 tos inherit ttl 100

	ip link set dev vx1 master br1
	check_err $?

	bridge vlan add dev vx1 vid 1
	check_err $?

	ip link set dev $swp1 master br1
	check_err $?

	bridge vlan add dev vx1 vid 1 pvid untagged 2>&1 >/dev/null \
		| grep -q mlxsw_spectrum
	check_err $?

	log_test "extack - map VLAN at VXLAN device"

	ip link del dev vx1
	ip link del dev br1
}

port_vlan_add_test()
{
	RET=0

	ip link add name br1 up type bridge vlan_filtering 1 mcast_snooping 0

	# Unsupported configuration: mlxsw demands VXLAN with "noudpcsum".
	ip link add name vx1 up type vxlan id 1000 \
		local 192.0.2.17 remote 192.0.2.18 \
		dstport 4789 tos inherit ttl 100

	ip link set dev $swp1 master br1
	check_err $?

	bridge vlan del dev $swp1 vid 1

	ip link set dev vx1 master br1
	check_err $?

	bridge vlan add dev $swp1 vid 1 pvid untagged 2>&1 >/dev/null \
		| grep -q mlxsw_spectrum
	check_err $?

	log_test "extack - map VLAN at port"

	ip link del dev vx1
	ip link del dev br1
}

trap cleanup EXIT

setup_prepare
setup_wait

tests_run

exit $EXIT_STATUS
OpenPOWER on IntegriCloud