brintos

brintos / linux-shallow public Read only

0
0
Text · 1.8 KiB · 78d3e0f Raw
81 lines · bash
1#!/bin/bash2# SPDX-License-Identifier: GPL-2.03 4# Regression Test:5#   Verify bond interface could up when set IPv6 link local address target.6#7#  +----------------+8#  |      br0       |9#  |       |        |    sw10#  | veth0   veth1  |11#  +---+-------+----+12#      |       |13#  +---+-------+----+14#  | veth0   veth1  |15#  |       |        |    host16#  |     bond0      |17#  +----------------+18#19# We use veths instead of physical interfaces20REQUIRE_MZ=no21NUM_NETIFS=022lib_dir=$(dirname "$0")23source "$lib_dir"/../../../net/forwarding/lib.sh24 25sw="sw-$(mktemp -u XXXXXX)"26host="ns-$(mktemp -u XXXXXX)"27 28cleanup()29{30	ip netns del $sw31	ip netns del $host32}33 34wait_lladdr_dad()35{36	$@ | grep fe80 | grep -qv tentative37}38 39wait_bond_up()40{41	$@ | grep -q 'state UP'42}43 44trap cleanup 0 1 245 46ip netns add $sw47ip netns add $host48 49ip -n $host link add veth0 type veth peer name veth0 netns $sw50ip -n $host link add veth1 type veth peer name veth1 netns $sw51 52ip -n $sw link add br0 type bridge53ip -n $sw link set br0 up54sw_lladdr=$(ip -n $sw addr show br0 | awk '/fe80/{print $2}' | cut -d'/' -f1)55# wait some time to make sure bridge lladdr pass DAD56slowwait 2 wait_lladdr_dad ip -n $sw addr show br057 58ip -n $host link add bond0 type bond mode 1 ns_ip6_target ${sw_lladdr} \59	arp_validate 3 arp_interval 100060# add a lladdr for bond to make sure there is a route to target61ip -n $host addr add fe80::beef/64 dev bond062ip -n $host link set bond0 up63ip -n $host link set veth0 master bond064ip -n $host link set veth1 master bond065 66ip -n $sw link set veth0 master br067ip -n $sw link set veth1 master br068ip -n $sw link set veth0 up69ip -n $sw link set veth1 up70 71slowwait 5 wait_bond_up ip -n $host link show bond072 73rc=074if ip -n $host link show bond0 | grep -q LOWER_UP; then75	echo "PASS"76else77	echo "FAIL"78	rc=179fi80exit $rc81