Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/sh
0002 # SPDX-License-Identifier: GPL-2.0
0003 
0004 # Regression Test:
0005 #   Verify LACPDUs get transmitted after setting the MAC address of
0006 #   the bond.
0007 #
0008 # https://bugzilla.redhat.com/show_bug.cgi?id=2020773
0009 #
0010 #       +---------+
0011 #       | fab-br0 |
0012 #       +---------+
0013 #            |
0014 #       +---------+
0015 #       |  fbond  |
0016 #       +---------+
0017 #        |       |
0018 #    +------+ +------+
0019 #    |veth1 | |veth2 |
0020 #    +------+ +------+
0021 #
0022 # We use veths instead of physical interfaces
0023 
0024 set -e
0025 tmp=$(mktemp -q dump.XXXXXX)
0026 cleanup() {
0027         ip link del fab-br0 >/dev/null 2>&1 || :
0028         ip link del fbond  >/dev/null 2>&1 || :
0029         ip link del veth1-bond  >/dev/null 2>&1 || :
0030         ip link del veth2-bond  >/dev/null 2>&1 || :
0031         modprobe -r bonding  >/dev/null 2>&1 || :
0032         rm -f -- ${tmp}
0033 }
0034 
0035 trap cleanup 0 1 2
0036 cleanup
0037 sleep 1
0038 
0039 # create the bridge
0040 ip link add fab-br0 address 52:54:00:3B:7C:A6 mtu 1500 type bridge \
0041         forward_delay 15
0042 
0043 # create the bond
0044 ip link add fbond type bond mode 4 miimon 200 xmit_hash_policy 1 \
0045         ad_actor_sys_prio 65535 lacp_rate fast
0046 
0047 # set bond address
0048 ip link set fbond address 52:54:00:3B:7C:A6
0049 ip link set fbond up
0050 
0051 # set again bond sysfs parameters
0052 ip link set fbond type bond ad_actor_sys_prio 65535
0053 
0054 # create veths
0055 ip link add name veth1-bond type veth peer name veth1-end
0056 ip link add name veth2-bond type veth peer name veth2-end
0057 
0058 # add ports
0059 ip link set fbond master fab-br0
0060 ip link set veth1-bond down master fbond
0061 ip link set veth2-bond down master fbond
0062 
0063 # bring up
0064 ip link set veth1-end up
0065 ip link set veth2-end up
0066 ip link set fab-br0 up
0067 ip link set fbond up
0068 ip addr add dev fab-br0 10.0.0.3
0069 
0070 tcpdump -n -i veth1-end -e ether proto 0x8809 >${tmp} 2>&1 &
0071 sleep 15
0072 pkill tcpdump >/dev/null 2>&1
0073 rc=0
0074 num=$(grep "packets captured" ${tmp} | awk '{print $1}')
0075 if test "$num" -gt 0; then
0076         echo "PASS, captured ${num}"
0077 else
0078         echo "FAIL"
0079         rc=1
0080 fi
0081 exit $rc