1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0 3 4# Regression Test: 5# Verify bond interface could up when set IPv6 link local address target. 6# 7# +----------------+ 8# | br0 | 9# | | | sw 10# | veth0 veth1 | 11# +---+-------+----+ 12# | | 13# +---+-------+----+ 14# | veth0 veth1 | 15# | | | host 16# | bond0 | 17# +----------------+ 18# 19# We use veths instead of physical interfaces 20REQUIRE_MZ=no 21NUM_NETIFS=0 22lib_dir=$(dirname "$0") 23source "$lib_dir"/../../../net/forwarding/lib.sh 24 25sw="sw-$(mktemp -u XXXXXX)" 26host="ns-$(mktemp -u XXXXXX)" 27 28cleanup() 29{ 30 ip netns del $sw 31 ip netns del $host 32} 33 34wait_lladdr_dad() 35{ 36 $@ | grep fe80 | grep -qv tentative 37} 38 39wait_bond_up() 40{ 41 $@ | grep -q 'state UP' 42} 43 44trap cleanup 0 1 2 45 46ip netns add $sw 47ip netns add $host 48 49ip -n $host link add veth0 type veth peer name veth0 netns $sw 50ip -n $host link add veth1 type veth peer name veth1 netns $sw 51 52ip -n $sw link add br0 type bridge 53ip -n $sw link set br0 up 54sw_lladdr=$(ip -n $sw addr show br0 | awk '/fe80/{print $2}' | cut -d'/' -f1) 55# wait some time to make sure bridge lladdr pass DAD 56slowwait 2 wait_lladdr_dad ip -n $sw addr show br0 57 58ip -n $host link add bond0 type bond mode 1 ns_ip6_target ${sw_lladdr} \ 59 arp_validate 3 arp_interval 1000 60# add a lladdr for bond to make sure there is a route to target 61ip -n $host addr add fe80::beef/64 dev bond0 62ip -n $host link set bond0 up 63ip -n $host link set veth0 master bond0 64ip -n $host link set veth1 master bond0 65 66ip -n $sw link set veth0 master br0 67ip -n $sw link set veth1 master br0 68ip -n $sw link set veth0 up 69ip -n $sw link set veth1 up 70 71slowwait 5 wait_bond_up ip -n $host link show bond0 72 73rc=0 74if ip -n $host link show bond0 | grep -q LOWER_UP; then 75 echo "PASS" 76else 77 echo "FAIL" 78 rc=1 79fi 80exit $rc 81