File Index
Files and directories
Sign in
FILE

bridge_vlan_unaware.sh

File preview with syntax highlighting.

linux-6.19.14/tools/testing/selftests/net/forwarding/bridge_vlan_unaware.sh BASH
  1#!/bin/bash
  2# SPDX-License-Identifier: GPL-2.0
  3
  4ALL_TESTS="ping_ipv4 ping_ipv6 learning flooding pvid_change"
  5NUM_NETIFS=4
  6source lib.sh
  7
  8h1_create()
  9{
 10	simple_if_init $h1 192.0.2.1/24 2001:db8:1::1/64
 11}
 12
 13h1_destroy()
 14{
 15	simple_if_fini $h1 192.0.2.1/24 2001:db8:1::1/64
 16}
 17
 18h2_create()
 19{
 20	simple_if_init $h2 192.0.2.2/24 2001:db8:1::2/64
 21}
 22
 23h2_destroy()
 24{
 25	simple_if_fini $h2 192.0.2.2/24 2001:db8:1::2/64
 26}
 27
 28switch_create()
 29{
 30	ip link add dev br0 type bridge \
 31		ageing_time $LOW_AGEING_TIME \
 32		mcast_snooping 0
 33
 34	ip link set dev $swp1 master br0
 35	ip link set dev $swp2 master br0
 36
 37	ip link set dev br0 up
 38	ip link set dev $swp1 up
 39	ip link set dev $swp2 up
 40}
 41
 42switch_destroy()
 43{
 44	ip link set dev $swp2 down
 45	ip link set dev $swp1 down
 46
 47	ip link del dev br0
 48}
 49
 50setup_prepare()
 51{
 52	h1=${NETIFS[p1]}
 53	swp1=${NETIFS[p2]}
 54
 55	swp2=${NETIFS[p3]}
 56	h2=${NETIFS[p4]}
 57
 58	vrf_prepare
 59
 60	h1_create
 61	h2_create
 62
 63	switch_create
 64}
 65
 66cleanup()
 67{
 68	pre_cleanup
 69
 70	switch_destroy
 71
 72	h2_destroy
 73	h1_destroy
 74
 75	vrf_cleanup
 76}
 77
 78ping_ipv4()
 79{
 80	local msg=$1
 81
 82	ping_test $h1 192.0.2.2 "$msg"
 83}
 84
 85ping_ipv6()
 86{
 87	local msg=$1
 88
 89	ping6_test $h1 2001:db8:1::2 "$msg"
 90}
 91
 92learning()
 93{
 94	learning_test "br0" $swp1 $h1 $h2
 95}
 96
 97flooding()
 98{
 99	flood_test $swp2 $h1 $h2
100}
101
102pvid_change()
103{
104	# Test that the changing of the VLAN-aware PVID does not affect
105	# VLAN-unaware forwarding
106	bridge vlan add vid 3 dev $swp1 pvid untagged
107
108	ping_ipv4 " with bridge port $swp1 PVID changed"
109	ping_ipv6 " with bridge port $swp1 PVID changed"
110
111	bridge vlan del vid 3 dev $swp1
112
113	ping_ipv4 " with bridge port $swp1 PVID deleted"
114	ping_ipv6 " with bridge port $swp1 PVID deleted"
115}
116
117trap cleanup EXIT
118
119setup_prepare
120setup_wait
121
122tests_run
123
124exit $EXIT_STATUS
~/ Read-only file preview.