~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/drivers/net/bonding/bond_macvlan.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/bash
  2 # SPDX-License-Identifier: GPL-2.0
  3 #
  4 # Test macvlan over balance-alb
  5 
  6 lib_dir=$(dirname "$0")
  7 source ${lib_dir}/bond_topo_2d1c.sh
  8 
  9 m1_ns="m1-$(mktemp -u XXXXXX)"
 10 m2_ns="m1-$(mktemp -u XXXXXX)"
 11 m1_ip4="192.0.2.11"
 12 m1_ip6="2001:db8::11"
 13 m2_ip4="192.0.2.12"
 14 m2_ip6="2001:db8::12"
 15 
 16 cleanup()
 17 {
 18         ip -n ${m1_ns} link del macv0
 19         ip netns del ${m1_ns}
 20         ip -n ${m2_ns} link del macv0
 21         ip netns del ${m2_ns}
 22 
 23         client_destroy
 24         server_destroy
 25         gateway_destroy
 26 }
 27 
 28 check_connection()
 29 {
 30         local ns=${1}
 31         local target=${2}
 32         local message=${3:-"macvlan_over_bond"}
 33         RET=0
 34 
 35 
 36         ip netns exec ${ns} ping ${target} -c 4 -i 0.1 &>/dev/null
 37         check_err $? "ping failed"
 38         log_test "$mode: $message"
 39 }
 40 
 41 macvlan_over_bond()
 42 {
 43         local param="$1"
 44         RET=0
 45 
 46         # setup new bond mode
 47         bond_reset "${param}"
 48 
 49         ip -n ${s_ns} link add link bond0 name macv0 type macvlan mode bridge
 50         ip -n ${s_ns} link set macv0 netns ${m1_ns}
 51         ip -n ${m1_ns} link set dev macv0 up
 52         ip -n ${m1_ns} addr add ${m1_ip4}/24 dev macv0
 53         ip -n ${m1_ns} addr add ${m1_ip6}/24 dev macv0
 54 
 55         ip -n ${s_ns} link add link bond0 name macv0 type macvlan mode bridge
 56         ip -n ${s_ns} link set macv0 netns ${m2_ns}
 57         ip -n ${m2_ns} link set dev macv0 up
 58         ip -n ${m2_ns} addr add ${m2_ip4}/24 dev macv0
 59         ip -n ${m2_ns} addr add ${m2_ip6}/24 dev macv0
 60 
 61         sleep 2
 62 
 63         check_connection "${c_ns}" "${s_ip4}" "IPv4: client->server"
 64         check_connection "${c_ns}" "${s_ip6}" "IPv6: client->server"
 65         check_connection "${c_ns}" "${m1_ip4}" "IPv4: client->macvlan_1"
 66         check_connection "${c_ns}" "${m1_ip6}" "IPv6: client->macvlan_1"
 67         check_connection "${c_ns}" "${m2_ip4}" "IPv4: client->macvlan_2"
 68         check_connection "${c_ns}" "${m2_ip6}" "IPv6: client->macvlan_2"
 69         check_connection "${m1_ns}" "${m2_ip4}" "IPv4: macvlan_1->macvlan_2"
 70         check_connection "${m1_ns}" "${m2_ip6}" "IPv6: macvlan_1->macvlan_2"
 71 
 72 
 73         sleep 5
 74 
 75         check_connection "${s_ns}" "${c_ip4}" "IPv4: server->client"
 76         check_connection "${s_ns}" "${c_ip6}" "IPv6: server->client"
 77         check_connection "${m1_ns}" "${c_ip4}" "IPv4: macvlan_1->client"
 78         check_connection "${m1_ns}" "${c_ip6}" "IPv6: macvlan_1->client"
 79         check_connection "${m2_ns}" "${c_ip4}" "IPv4: macvlan_2->client"
 80         check_connection "${m2_ns}" "${c_ip6}" "IPv6: macvlan_2->client"
 81         check_connection "${m2_ns}" "${m1_ip4}" "IPv4: macvlan_2->macvlan_2"
 82         check_connection "${m2_ns}" "${m1_ip6}" "IPv6: macvlan_2->macvlan_2"
 83 
 84         ip -n ${c_ns} neigh flush dev eth0
 85 }
 86 
 87 trap cleanup EXIT
 88 
 89 setup_prepare
 90 ip netns add ${m1_ns}
 91 ip netns add ${m2_ns}
 92 
 93 modes="active-backup balance-tlb balance-alb"
 94 
 95 for mode in $modes; do
 96         macvlan_over_bond "mode $mode"
 97 done
 98 
 99 exit $EXIT_STATUS

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php