|
3 | 3 |
|
4 | 4 | readonly NETNS="ns-$(mktemp -u XXXXXX)"
|
5 | 5 |
|
| 6 | +ALL_TESTS=" |
| 7 | + test_vlan_filter_check |
| 8 | + test_vlan0_del_crash_01 |
| 9 | + test_vlan0_del_crash_02 |
| 10 | + test_vlan0_del_crash_03 |
| 11 | + test_vid0_memleak |
| 12 | +" |
| 13 | + |
6 | 14 | ret=0
|
7 | 15 |
|
| 16 | +setup() { |
| 17 | + ip netns add ${NETNS} |
| 18 | +} |
| 19 | + |
8 | 20 | cleanup() {
|
9 |
| - ip netns del $NETNS |
| 21 | + ip netns del $NETNS 2>/dev/null |
10 | 22 | }
|
11 | 23 |
|
12 | 24 | trap cleanup EXIT
|
13 | 25 |
|
14 | 26 | fail() {
|
15 |
| - echo "ERROR: ${1:-unexpected return code} (ret: $_)" >&2 |
16 |
| - ret=1 |
| 27 | + echo "ERROR: ${1:-unexpected return code} (ret: $_)" >&2 |
| 28 | + ret=1 |
| 29 | +} |
| 30 | + |
| 31 | +tests_run() |
| 32 | +{ |
| 33 | + local current_test |
| 34 | + for current_test in ${TESTS:-$ALL_TESTS}; do |
| 35 | + $current_test |
| 36 | + done |
| 37 | +} |
| 38 | + |
| 39 | +test_vlan_filter_check() { |
| 40 | + setup |
| 41 | + ip netns exec ${NETNS} ip link add bond0 type bond mode 0 |
| 42 | + ip netns exec ${NETNS} ip link add bond_slave_1 type veth peer veth2 |
| 43 | + ip netns exec ${NETNS} ip link set bond_slave_1 master bond0 |
| 44 | + ip netns exec ${NETNS} ethtool -K bond0 rx-vlan-filter off |
| 45 | + ip netns exec ${NETNS} ip link add link bond_slave_1 name bond_slave_1.0 type vlan id 0 |
| 46 | + ip netns exec ${NETNS} ip link add link bond0 name bond0.0 type vlan id 0 |
| 47 | + ip netns exec ${NETNS} ip link set bond_slave_1 nomaster |
| 48 | + ip netns exec ${NETNS} ip link del veth2 || fail "Please check vlan HW filter function" |
| 49 | + cleanup |
17 | 50 | }
|
18 | 51 |
|
19 |
| -ip netns add ${NETNS} |
20 |
| -ip netns exec ${NETNS} ip link add bond0 type bond mode 0 |
21 |
| -ip netns exec ${NETNS} ip link add bond_slave_1 type veth peer veth2 |
22 |
| -ip netns exec ${NETNS} ip link set bond_slave_1 master bond0 |
23 |
| -ip netns exec ${NETNS} ethtool -K bond0 rx-vlan-filter off |
24 |
| -ip netns exec ${NETNS} ip link add link bond_slave_1 name bond_slave_1.0 type vlan id 0 |
25 |
| -ip netns exec ${NETNS} ip link add link bond0 name bond0.0 type vlan id 0 |
26 |
| -ip netns exec ${NETNS} ip link set bond_slave_1 nomaster |
27 |
| -ip netns exec ${NETNS} ip link del veth2 || fail "Please check vlan HW filter function" |
| 52 | +#enable vlan_filter feature of real_dev with vlan0 during running time |
| 53 | +test_vlan0_del_crash_01() { |
| 54 | + setup |
| 55 | + ip netns exec ${NETNS} ip link add bond0 type bond mode 0 |
| 56 | + ip netns exec ${NETNS} ip link add link bond0 name vlan0 type vlan id 0 protocol 802.1q |
| 57 | + ip netns exec ${NETNS} ethtool -K bond0 rx-vlan-filter off |
| 58 | + ip netns exec ${NETNS} ifconfig bond0 up |
| 59 | + ip netns exec ${NETNS} ethtool -K bond0 rx-vlan-filter on |
| 60 | + ip netns exec ${NETNS} ifconfig bond0 down |
| 61 | + ip netns exec ${NETNS} ifconfig bond0 up |
| 62 | + ip netns exec ${NETNS} ip link del vlan0 || fail "Please check vlan HW filter function" |
| 63 | + cleanup |
| 64 | +} |
| 65 | + |
| 66 | +#enable vlan_filter feature and add vlan0 for real_dev during running time |
| 67 | +test_vlan0_del_crash_02() { |
| 68 | + setup |
| 69 | + ip netns exec ${NETNS} ip link add bond0 type bond mode 0 |
| 70 | + ip netns exec ${NETNS} ethtool -K bond0 rx-vlan-filter off |
| 71 | + ip netns exec ${NETNS} ifconfig bond0 up |
| 72 | + ip netns exec ${NETNS} ethtool -K bond0 rx-vlan-filter on |
| 73 | + ip netns exec ${NETNS} ip link add link bond0 name vlan0 type vlan id 0 protocol 802.1q |
| 74 | + ip netns exec ${NETNS} ifconfig bond0 down |
| 75 | + ip netns exec ${NETNS} ifconfig bond0 up |
| 76 | + ip netns exec ${NETNS} ip link del vlan0 || fail "Please check vlan HW filter function" |
| 77 | + cleanup |
| 78 | +} |
| 79 | + |
| 80 | +#enable vlan_filter feature of real_dev during running time |
| 81 | +#test kernel_bug of vlan unregister |
| 82 | +test_vlan0_del_crash_03() { |
| 83 | + setup |
| 84 | + ip netns exec ${NETNS} ip link add bond0 type bond mode 0 |
| 85 | + ip netns exec ${NETNS} ip link add link bond0 name vlan0 type vlan id 0 protocol 802.1q |
| 86 | + ip netns exec ${NETNS} ethtool -K bond0 rx-vlan-filter off |
| 87 | + ip netns exec ${NETNS} ifconfig bond0 up |
| 88 | + ip netns exec ${NETNS} ethtool -K bond0 rx-vlan-filter on |
| 89 | + ip netns exec ${NETNS} ifconfig bond0 down |
| 90 | + ip netns exec ${NETNS} ip link del vlan0 || fail "Please check vlan HW filter function" |
| 91 | + cleanup |
| 92 | +} |
| 93 | + |
| 94 | +test_vid0_memleak() { |
| 95 | + setup |
| 96 | + ip netns exec ${NETNS} ip link add bond0 up type bond mode 0 |
| 97 | + ip netns exec ${NETNS} ethtool -K bond0 rx-vlan-filter off |
| 98 | + ip netns exec ${NETNS} ip link del dev bond0 || fail "Please check vlan HW filter function" |
| 99 | + cleanup |
| 100 | +} |
28 | 101 |
|
| 102 | +tests_run |
29 | 103 | exit $ret
|
0 commit comments