If vlan dev was created with reorder_hdr off and hw offload both off but up with hw offload on, it will trigger a skb_panic bug in vlan_dev_hard_header(). Add a test to automatically catch re-occurrence of the issue. Suggested-by: Jakub Kicinski Signed-off-by: Chen Zhen --- tools/testing/selftests/net/Makefile | 1 + .../testing/selftests/net/vlan_hw_offload.sh | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100755 tools/testing/selftests/net/vlan_hw_offload.sh diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile index b66ba04f19d9..8b50448a01cd 100644 --- a/tools/testing/selftests/net/Makefile +++ b/tools/testing/selftests/net/Makefile @@ -113,6 +113,7 @@ TEST_PROGS := \ veth.sh \ vlan_bridge_binding.sh \ vlan_hw_filter.sh \ + vlan_hw_offload.sh \ vrf-xfrm-tests.sh \ vrf_route_leaking.sh \ vrf_strict_mode_test.sh \ diff --git a/tools/testing/selftests/net/vlan_hw_offload.sh b/tools/testing/selftests/net/vlan_hw_offload.sh new file mode 100755 index 000000000000..ac7140539d95 --- /dev/null +++ b/tools/testing/selftests/net/vlan_hw_offload.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# shellcheck disable=SC2329 + +setup() { + ip link add veth0 type veth peer name veth1 + ip link set veth0 up + ip link set veth1 up +} + +cleanup() { + ip link delete veth0 2>/dev/null +} + +# turn on hw offload and set up vlan dev with reorder_hdr off +test_vlan_hw_offload_toggle_crash() { + ethtool -K veth0 tx-vlan-hw-insert off + ip link add link veth0 name veth0.10 type vlan id 10 reorder_hdr off + ethtool -K veth0 tx-vlan-hw-insert on + + # set up vlan dev and it will trigger ndisc + ip link set veth0.10 up + ip -6 route show dev veth0.10 +} + +trap cleanup EXIT + +setup +test_vlan_hw_offload_toggle_crash + +exit 0 -- 2.33.0