tools/testing/selftests/net/forwarding/tc_vlan_modify.sh

Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/forwarding/tc_vlan_modify.sh

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/net/forwarding/tc_vlan_modify.sh
Extension
.sh
Size
3246 bytes
Lines
165
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: tools
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

#!/bin/bash
# SPDX-License-Identifier: GPL-2.0

ALL_TESTS="
	vlan_modify_ingress
	vlan_modify_egress
"

NUM_NETIFS=4
CHECK_TC="yes"
source lib.sh

h1_create()
{
	simple_if_init $h1 192.0.2.1/28 2001:db8:1::1/64
	vlan_create $h1 85 v$h1 192.0.2.17/28 2001:db8:2::1/64
}

h1_destroy()
{
	vlan_destroy $h1 85
	simple_if_fini $h1 192.0.2.1/28 2001:db8:1::1/64
}

h2_create()
{
	simple_if_init $h2 192.0.2.2/28 2001:db8:1::2/64
	vlan_create $h2 65 v$h2 192.0.2.18/28 2001:db8:2::2/64
}

h2_destroy()
{
	vlan_destroy $h2 65
	simple_if_fini $h2 192.0.2.2/28 2001:db8:1::2/64
}

switch_create()
{
	ip link add dev br0 type bridge vlan_filtering 1 mcast_snooping 0

	ip link set dev $swp1 master br0
	ip link set dev $swp2 master br0

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

	bridge vlan add dev $swp1 vid 85
	bridge vlan add dev $swp2 vid 65

	bridge vlan add dev $swp2 vid 85
	bridge vlan add dev $swp1 vid 65

	tc qdisc add dev $swp1 clsact
	tc qdisc add dev $swp2 clsact
}

switch_destroy()
{
	tc qdisc del dev $swp2 clsact
	tc qdisc del dev $swp1 clsact

	bridge vlan del vid 65 dev $swp1
	bridge vlan del vid 85 dev $swp2

	bridge vlan del vid 65 dev $swp2
	bridge vlan del vid 85 dev $swp1

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

Annotation

Implementation Notes