xref: /linux/tools/testing/selftests/drivers/net/team/non_ether_header_ops.sh (revision 453a4a5f97f0c95b7df458e6afb98d4ab057d90b)
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3# shellcheck disable=SC2154
4#
5# Reproduce the non-Ethernet header_ops confusion scenario with:
6#   g0 (gre) -> b0 (bond) -> t0 (team)
7#
8# Before the fix, direct header_ops inheritance in this stack could call
9# callbacks with the wrong net_device context and crash.
10
11lib_dir=$(dirname "$0")
12source "$lib_dir"/../../../net/lib.sh
13
14trap cleanup_all_ns EXIT
15
16setup_ns ns1
17
18ip -n "$ns1" link add d0 type dummy
19ip -n "$ns1" addr add 10.10.10.1/24 dev d0
20ip -n "$ns1" link set d0 up
21
22ip -n "$ns1" link add g0 type gre local 10.10.10.1
23ip -n "$ns1" link add b0 type bond mode active-backup
24ip -n "$ns1" link add t0 type team
25
26ip -n "$ns1" link set g0 master b0
27ip -n "$ns1" link set b0 master t0
28
29ip -n "$ns1" link set g0 up
30ip -n "$ns1" link set b0 up
31ip -n "$ns1" link set t0 up
32
33# IPv6 address assignment triggers MLD join reports that call
34# dev_hard_header() on t0, exercising the inherited header_ops path.
35ip -n "$ns1" -6 addr add 2001:db8:1::1/64 dev t0 nodad
36for i in $(seq 1 20); do
37	ip netns exec "$ns1" ping -6 -I t0 ff02::1 -c1 -W1 &>/dev/null || true
38done
39
40echo "PASS: non-Ethernet header_ops stacking did not crash"
41exit "$EXIT_STATUS"
42