cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

bridge_vlan_aware.sh (2517B)


      1#!/bin/bash
      2# SPDX-License-Identifier: GPL-2.0
      3
      4ALL_TESTS="ping_ipv4 ping_ipv6 learning flooding vlan_deletion extern_learn"
      5NUM_NETIFS=4
      6CHECK_TC="yes"
      7source lib.sh
      8
      9h1_create()
     10{
     11	simple_if_init $h1 192.0.2.1/24 2001:db8:1::1/64
     12}
     13
     14h1_destroy()
     15{
     16	simple_if_fini $h1 192.0.2.1/24 2001:db8:1::1/64
     17}
     18
     19h2_create()
     20{
     21	simple_if_init $h2 192.0.2.2/24 2001:db8:1::2/64
     22}
     23
     24h2_destroy()
     25{
     26	simple_if_fini $h2 192.0.2.2/24 2001:db8:1::2/64
     27}
     28
     29switch_create()
     30{
     31	ip link add dev br0 type bridge \
     32		vlan_filtering 1 \
     33		ageing_time $LOW_AGEING_TIME \
     34		mcast_snooping 0
     35
     36	ip link set dev $swp1 master br0
     37	ip link set dev $swp2 master br0
     38
     39	ip link set dev br0 up
     40	ip link set dev $swp1 up
     41	ip link set dev $swp2 up
     42}
     43
     44switch_destroy()
     45{
     46	ip link set dev $swp2 down
     47	ip link set dev $swp1 down
     48
     49	ip link del dev br0
     50}
     51
     52setup_prepare()
     53{
     54	h1=${NETIFS[p1]}
     55	swp1=${NETIFS[p2]}
     56
     57	swp2=${NETIFS[p3]}
     58	h2=${NETIFS[p4]}
     59
     60	vrf_prepare
     61
     62	h1_create
     63	h2_create
     64
     65	switch_create
     66}
     67
     68cleanup()
     69{
     70	pre_cleanup
     71
     72	switch_destroy
     73
     74	h2_destroy
     75	h1_destroy
     76
     77	vrf_cleanup
     78}
     79
     80ping_ipv4()
     81{
     82	ping_test $h1 192.0.2.2
     83}
     84
     85ping_ipv6()
     86{
     87	ping6_test $h1 2001:db8:1::2
     88}
     89
     90learning()
     91{
     92	learning_test "br0" $swp1 $h1 $h2
     93}
     94
     95flooding()
     96{
     97	flood_test $swp2 $h1 $h2
     98}
     99
    100vlan_deletion()
    101{
    102	# Test that the deletion of a VLAN on a bridge port does not affect
    103	# the PVID VLAN
    104	log_info "Add and delete a VLAN on bridge port $swp1"
    105
    106	bridge vlan add vid 10 dev $swp1
    107	bridge vlan del vid 10 dev $swp1
    108
    109	ping_ipv4
    110	ping_ipv6
    111}
    112
    113extern_learn()
    114{
    115	local mac=de:ad:be:ef:13:37
    116	local ageing_time
    117
    118	# Test that externally learned FDB entries can roam, but not age out
    119	RET=0
    120
    121	bridge fdb add de:ad:be:ef:13:37 dev $swp1 master extern_learn vlan 1
    122
    123	bridge fdb show brport $swp1 | grep -q de:ad:be:ef:13:37
    124	check_err $? "Did not find FDB entry when should"
    125
    126	# Wait for 10 seconds after the ageing time to make sure the FDB entry
    127	# was not aged out
    128	ageing_time=$(bridge_ageing_time_get br0)
    129	sleep $((ageing_time + 10))
    130
    131	bridge fdb show brport $swp1 | grep -q de:ad:be:ef:13:37
    132	check_err $? "FDB entry was aged out when should not"
    133
    134	$MZ $h2 -c 1 -p 64 -a $mac -t ip -q
    135
    136	bridge fdb show brport $swp2 | grep -q de:ad:be:ef:13:37
    137	check_err $? "FDB entry did not roam when should"
    138
    139	log_test "Externally learned FDB entry - ageing & roaming"
    140
    141	bridge fdb del de:ad:be:ef:13:37 dev $swp2 master vlan 1 &> /dev/null
    142	bridge fdb del de:ad:be:ef:13:37 dev $swp1 master vlan 1 &> /dev/null
    143}
    144
    145trap cleanup EXIT
    146
    147setup_prepare
    148setup_wait
    149
    150tests_run
    151
    152exit $EXIT_STATUS