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

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/net/hsr/hsr_redbox.sh

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ 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.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/bash
  2 # SPDX-License-Identifier: GPL-2.0
  3 
  4 ipv6=false
  5 
  6 source ./hsr_common.sh
  7 
  8 do_complete_ping_test()
  9 {
 10         echo "INFO: Initial validation ping (HSR-SAN/RedBox)."
 11         # Each node has to be able to reach each one.
 12         do_ping "${ns1}" 100.64.0.2
 13         do_ping "${ns2}" 100.64.0.1
 14         # Ping between SANs (test bridge)
 15         do_ping "${ns4}" 100.64.0.51
 16         do_ping "${ns5}" 100.64.0.41
 17         # Ping from SANs to hsr1 (via hsr2) (and opposite)
 18         do_ping "${ns3}" 100.64.0.1
 19         do_ping "${ns1}" 100.64.0.3
 20         do_ping "${ns1}" 100.64.0.41
 21         do_ping "${ns4}" 100.64.0.1
 22         do_ping "${ns1}" 100.64.0.51
 23         do_ping "${ns5}" 100.64.0.1
 24         stop_if_error "Initial validation failed."
 25 
 26         # Wait for MGNT HSR frames being received and nodes being
 27         # merged.
 28         sleep 5
 29 
 30         echo "INFO: Longer ping test (HSR-SAN/RedBox)."
 31         # Ping from SAN to hsr1 (via hsr2)
 32         do_ping_long "${ns3}" 100.64.0.1
 33         # Ping from hsr1 (via hsr2) to SANs (and opposite)
 34         do_ping_long "${ns1}" 100.64.0.3
 35         do_ping_long "${ns1}" 100.64.0.41
 36         do_ping_long "${ns4}" 100.64.0.1
 37         do_ping_long "${ns1}" 100.64.0.51
 38         do_ping_long "${ns5}" 100.64.0.1
 39         stop_if_error "Longer ping test failed."
 40 
 41         echo "INFO: All good."
 42 }
 43 
 44 setup_hsr_interfaces()
 45 {
 46         local HSRv="$1"
 47 
 48         echo "INFO: preparing interfaces for HSRv${HSRv} (HSR-SAN/RedBox)."
 49 #
 50 # IPv4 addresses (100.64.X.Y/24), and [X.Y] is presented on below diagram:
 51 #
 52 #
 53 # |NS1                     |               |NS4                |
 54 # |       [0.1]            |               |                   |
 55 # |    /-- hsr1 --\        |               |    [0.41]         |
 56 # | ns1eth1     ns1eth2    |               |    ns4eth1 (SAN)  |
 57 # |------------------------|               |-------------------|
 58 #      |            |                                |
 59 #      |            |                                |
 60 #      |            |                                |
 61 # |------------------------|   |-------------------------------|
 62 # | ns2eth1     ns2eth2    |   |                  ns3eth2      |
 63 # |    \-- hsr2 --/        |   |                 /             |
 64 # |      [0.2] \           |   |                /              |  |------------|
 65 # |             ns2eth3    |---| ns3eth1 -- ns3br1 -- ns3eth3--|--| ns5eth1    |
 66 # |             (interlink)|   | [0.3]      [0.11]             |  | [0.51]     |
 67 # |NS2 (RedBOX)            |   |NS3 (BR)                       |  | NS5 (SAN)  |
 68 #
 69 #
 70         # Check if iproute2 supports adding interlink port to hsrX device
 71         ip link help hsr | grep -q INTERLINK
 72         [ $? -ne 0 ] && { echo "iproute2: HSR interlink interface not supported!"; exit 0; }
 73 
 74         # Create interfaces for name spaces
 75         ip link add ns1eth1 netns "${ns1}" type veth peer name ns2eth1 netns "${ns2}"
 76         ip link add ns1eth2 netns "${ns1}" type veth peer name ns2eth2 netns "${ns2}"
 77         ip link add ns2eth3 netns "${ns2}" type veth peer name ns3eth1 netns "${ns3}"
 78         ip link add ns3eth2 netns "${ns3}" type veth peer name ns4eth1 netns "${ns4}"
 79         ip link add ns3eth3 netns "${ns3}" type veth peer name ns5eth1 netns "${ns5}"
 80 
 81         sleep 1
 82 
 83         ip -n "${ns1}" link set ns1eth1 up
 84         ip -n "${ns1}" link set ns1eth2 up
 85 
 86         ip -n "${ns2}" link set ns2eth1 up
 87         ip -n "${ns2}" link set ns2eth2 up
 88         ip -n "${ns2}" link set ns2eth3 up
 89 
 90         ip -n "${ns3}" link add name ns3br1 type bridge
 91         ip -n "${ns3}" link set ns3br1 up
 92         ip -n "${ns3}" link set ns3eth1 master ns3br1 up
 93         ip -n "${ns3}" link set ns3eth2 master ns3br1 up
 94         ip -n "${ns3}" link set ns3eth3 master ns3br1 up
 95 
 96         ip -n "${ns4}" link set ns4eth1 up
 97         ip -n "${ns5}" link set ns5eth1 up
 98 
 99         ip -net "$ns1" link set address 00:11:22:00:01:01 dev ns1eth1
100         ip -net "$ns1" link set address 00:11:22:00:01:02 dev ns1eth2
101 
102         ip -net "$ns2" link set address 00:11:22:00:02:01 dev ns2eth1
103         ip -net "$ns2" link set address 00:11:22:00:02:02 dev ns2eth2
104         ip -net "$ns2" link set address 00:11:22:00:02:03 dev ns2eth3
105 
106         ip -net "$ns3" link set address 00:11:22:00:03:11 dev ns3eth1
107         ip -net "$ns3" link set address 00:11:22:00:03:11 dev ns3eth2
108         ip -net "$ns3" link set address 00:11:22:00:03:11 dev ns3eth3
109         ip -net "$ns3" link set address 00:11:22:00:03:11 dev ns3br1
110 
111         ip -net "$ns4" link set address 00:11:22:00:04:01 dev ns4eth1
112         ip -net "$ns5" link set address 00:11:22:00:05:01 dev ns5eth1
113 
114         ip -net "${ns1}" link add name hsr1 type hsr slave1 ns1eth1 slave2 ns1eth2 supervision 45 version ${HSRv} proto 0
115         ip -net "${ns2}" link add name hsr2 type hsr slave1 ns2eth1 slave2 ns2eth2 interlink ns2eth3 supervision 45 version ${HSRv} proto 0
116 
117         ip -n "${ns1}" addr add 100.64.0.1/24 dev hsr1
118         ip -n "${ns2}" addr add 100.64.0.2/24 dev hsr2
119         ip -n "${ns3}" addr add 100.64.0.11/24 dev ns3br1
120         ip -n "${ns3}" addr add 100.64.0.3/24 dev ns3eth1
121         ip -n "${ns4}" addr add 100.64.0.41/24 dev ns4eth1
122         ip -n "${ns5}" addr add 100.64.0.51/24 dev ns5eth1
123 
124         ip -n "${ns1}" link set hsr1 up
125         ip -n "${ns2}" link set hsr2 up
126 }
127 
128 check_prerequisites
129 setup_ns ns1 ns2 ns3 ns4 ns5
130 
131 trap cleanup_all_ns EXIT
132 
133 setup_hsr_interfaces 1
134 do_complete_ping_test
135 
136 exit $ret

~ [ 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