1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0 3 4ALL_TESTS=" 5 ping_ipv4 6 ping_ipv6 7 vlan 8" 9NUM_NETIFS=4 10source lib.sh 11 12h1_create() 13{ 14 simple_if_init $h1 15 vlan_create $h1 555 v$h1 192.0.2.1/28 2001:db8:1::1/64 16 ip -4 route add 192.0.2.128/28 vrf v$h1 nexthop via 192.0.2.2 17 ip -6 route add 2001:db8:2::/64 vrf v$h1 nexthop via 2001:db8:1::2 18} 19 20h1_destroy() 21{ 22 ip -6 route del 2001:db8:2::/64 vrf v$h1 23 ip -4 route del 192.0.2.128/28 vrf v$h1 24 vlan_destroy $h1 555 25 simple_if_fini $h1 26} 27 28h2_create() 29{ 30 simple_if_init $h2 192.0.2.130/28 2001:db8:2::2/64 31 ip -4 route add 192.0.2.0/28 vrf v$h2 nexthop via 192.0.2.129 32 ip -6 route add 2001:db8:1::/64 vrf v$h2 nexthop via 2001:db8:2::1 33} 34 35h2_destroy() 36{ 37 ip -6 route del 2001:db8:1::/64 vrf v$h2 38 ip -4 route del 192.0.2.0/28 vrf v$h2 39 simple_if_fini $h2 192.0.2.130/28 40} 41 42router_create() 43{ 44 ip link add name br1 type bridge vlan_filtering 1 45 ip link set dev br1 up 46 47 ip link set dev $swp1 master br1 48 ip link set dev $swp1 up 49 50 bridge vlan add dev br1 vid 555 self pvid untagged 51 bridge vlan add dev $swp1 vid 555 52 53 __addr_add_del br1 add 192.0.2.2/28 2001:db8:1::2/64 54 55 ip link set dev $swp2 up 56 __addr_add_del $swp2 add 192.0.2.129/28 2001:db8:2::1/64 57} 58 59router_destroy() 60{ 61 __addr_add_del $swp2 del 192.0.2.129/28 2001:db8:2::1/64 62 ip link set dev $swp2 down 63 64 __addr_add_del br1 del 192.0.2.2/28 2001:db8:1::2/64 65 ip link set dev $swp1 down 66 ip link set dev $swp1 nomaster 67 68 ip link del dev br1 69} 70 71setup_prepare() 72{ 73 h1=${NETIFS[p1]} 74 swp1=${NETIFS[p2]} 75 76 swp2=${NETIFS[p3]} 77 h2=${NETIFS[p4]} 78 79 vrf_prepare 80 81 h1_create 82 h2_create 83 84 router_create 85 86 forwarding_enable 87} 88 89cleanup() 90{ 91 pre_cleanup 92 93 forwarding_restore 94 95 router_destroy 96 97 h2_destroy 98 h1_destroy 99 100 vrf_cleanup 101} 102 103vlan() 104{ 105 RET=0 106 107 bridge vlan add dev br1 vid 333 self 108 check_err $? "Can't add a non-PVID VLAN" 109 bridge vlan del dev br1 vid 333 self 110 check_err $? "Can't remove a non-PVID VLAN" 111 112 log_test "vlan" 113} 114 115ping_ipv4() 116{ 117 ping_test $h1 192.0.2.130 118} 119 120ping_ipv6() 121{ 122 ping6_test $h1 2001:db8:2::2 123} 124 125trap cleanup EXIT 126 127setup_prepare 128setup_wait 129 130tests_run 131 132exit $EXIT_STATUS 133