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

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/net/hsr/hsr_ping.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=true
  5 
  6 source ./hsr_common.sh
  7 
  8 optstring="h4"
  9 usage() {
 10         echo "Usage: $0 [OPTION]"
 11         echo -e "\t-4: IPv4 only: disable IPv6 tests (default: test both IPv4 and IPv6)"
 12 }
 13 
 14 while getopts "$optstring" option;do
 15         case "$option" in
 16         "h")
 17                 usage $0
 18                 exit 0
 19                 ;;
 20         "4")
 21                 ipv6=false
 22                 ;;
 23         "?")
 24                 usage $0
 25                 exit 1
 26                 ;;
 27 esac
 28 done
 29 
 30 do_complete_ping_test()
 31 {
 32         echo "INFO: Initial validation ping."
 33         # Each node has to be able each one.
 34         do_ping "$ns1" 100.64.0.2
 35         do_ping "$ns2" 100.64.0.1
 36         do_ping "$ns3" 100.64.0.1
 37         stop_if_error "Initial validation failed."
 38 
 39         do_ping "$ns1" 100.64.0.3
 40         do_ping "$ns2" 100.64.0.3
 41         do_ping "$ns3" 100.64.0.2
 42 
 43         do_ping "$ns1" dead:beef:1::2
 44         do_ping "$ns1" dead:beef:1::3
 45         do_ping "$ns2" dead:beef:1::1
 46         do_ping "$ns2" dead:beef:1::2
 47         do_ping "$ns3" dead:beef:1::1
 48         do_ping "$ns3" dead:beef:1::2
 49 
 50         stop_if_error "Initial validation failed."
 51 
 52 # Wait until supervisor all supervision frames have been processed and the node
 53 # entries have been merged. Otherwise duplicate frames will be observed which is
 54 # valid at this stage.
 55         WAIT=5
 56         while [ ${WAIT} -gt 0 ]
 57         do
 58                 grep 00:00:00:00:00:00 /sys/kernel/debug/hsr/hsr*/node_table
 59                 if [ $? -ne 0 ]
 60                 then
 61                         break
 62                 fi
 63                 sleep 1
 64                 let "WAIT = WAIT - 1"
 65         done
 66 
 67 # Just a safety delay in case the above check didn't handle it.
 68         sleep 1
 69 
 70         echo "INFO: Longer ping test."
 71         do_ping_long "$ns1" 100.64.0.2
 72         do_ping_long "$ns1" dead:beef:1::2
 73         do_ping_long "$ns1" 100.64.0.3
 74         do_ping_long "$ns1" dead:beef:1::3
 75 
 76         stop_if_error "Longer ping test failed."
 77 
 78         do_ping_long "$ns2" 100.64.0.1
 79         do_ping_long "$ns2" dead:beef:1::1
 80         do_ping_long "$ns2" 100.64.0.3
 81         do_ping_long "$ns2" dead:beef:1::2
 82         stop_if_error "Longer ping test failed."
 83 
 84         do_ping_long "$ns3" 100.64.0.1
 85         do_ping_long "$ns3" dead:beef:1::1
 86         do_ping_long "$ns3" 100.64.0.2
 87         do_ping_long "$ns3" dead:beef:1::2
 88         stop_if_error "Longer ping test failed."
 89 
 90         echo "INFO: Cutting one link."
 91         do_ping_long "$ns1" 100.64.0.3 &
 92 
 93         sleep 3
 94         ip -net "$ns3" link set ns3eth1 down
 95         wait
 96 
 97         ip -net "$ns3" link set ns3eth1 up
 98 
 99         stop_if_error "Failed with one link down."
100 
101         echo "INFO: Delay the link and drop a few packages."
102         tc -net "$ns3" qdisc add dev ns3eth1 root netem delay 50ms
103         tc -net "$ns2" qdisc add dev ns2eth1 root netem delay 5ms loss 25%
104 
105         do_ping_long "$ns1" 100.64.0.2
106         do_ping_long "$ns1" 100.64.0.3
107 
108         stop_if_error "Failed with delay and packetloss."
109 
110         do_ping_long "$ns2" 100.64.0.1
111         do_ping_long "$ns2" 100.64.0.3
112 
113         stop_if_error "Failed with delay and packetloss."
114 
115         do_ping_long "$ns3" 100.64.0.1
116         do_ping_long "$ns3" 100.64.0.2
117         stop_if_error "Failed with delay and packetloss."
118 
119         echo "INFO: All good."
120 }
121 
122 setup_hsr_interfaces()
123 {
124         local HSRv="$1"
125 
126         echo "INFO: preparing interfaces for HSRv${HSRv}."
127 # Three HSR nodes. Each node has one link to each of its neighbour, two links in total.
128 #
129 #    ns1eth1 ----- ns2eth1
130 #      hsr1         hsr2
131 #    ns1eth2       ns2eth2
132 #       |            |
133 #    ns3eth1      ns3eth2
134 #           \    /
135 #            hsr3
136 #
137         # Interfaces
138         ip link add ns1eth1 netns "$ns1" type veth peer name ns2eth1 netns "$ns2"
139         ip link add ns1eth2 netns "$ns1" type veth peer name ns3eth1 netns "$ns3"
140         ip link add ns3eth2 netns "$ns3" type veth peer name ns2eth2 netns "$ns2"
141 
142         # HSRv0/1
143         ip -net "$ns1" link add name hsr1 type hsr slave1 ns1eth1 slave2 ns1eth2 supervision 45 version $HSRv proto 0
144         ip -net "$ns2" link add name hsr2 type hsr slave1 ns2eth1 slave2 ns2eth2 supervision 45 version $HSRv proto 0
145         ip -net "$ns3" link add name hsr3 type hsr slave1 ns3eth1 slave2 ns3eth2 supervision 45 version $HSRv proto 0
146 
147         # IP for HSR
148         ip -net "$ns1" addr add 100.64.0.1/24 dev hsr1
149         ip -net "$ns1" addr add dead:beef:1::1/64 dev hsr1 nodad
150         ip -net "$ns2" addr add 100.64.0.2/24 dev hsr2
151         ip -net "$ns2" addr add dead:beef:1::2/64 dev hsr2 nodad
152         ip -net "$ns3" addr add 100.64.0.3/24 dev hsr3
153         ip -net "$ns3" addr add dead:beef:1::3/64 dev hsr3 nodad
154 
155         ip -net "$ns1" link set address 00:11:22:00:01:01 dev ns1eth1
156         ip -net "$ns1" link set address 00:11:22:00:01:02 dev ns1eth2
157 
158         ip -net "$ns2" link set address 00:11:22:00:02:01 dev ns2eth1
159         ip -net "$ns2" link set address 00:11:22:00:02:02 dev ns2eth2
160 
161         ip -net "$ns3" link set address 00:11:22:00:03:01 dev ns3eth1
162         ip -net "$ns3" link set address 00:11:22:00:03:02 dev ns3eth2
163 
164         # All Links up
165         ip -net "$ns1" link set ns1eth1 up
166         ip -net "$ns1" link set ns1eth2 up
167         ip -net "$ns1" link set hsr1 up
168 
169         ip -net "$ns2" link set ns2eth1 up
170         ip -net "$ns2" link set ns2eth2 up
171         ip -net "$ns2" link set hsr2 up
172 
173         ip -net "$ns3" link set ns3eth1 up
174         ip -net "$ns3" link set ns3eth2 up
175         ip -net "$ns3" link set hsr3 up
176 }
177 
178 check_prerequisites
179 setup_ns ns1 ns2 ns3
180 
181 trap cleanup_all_ns EXIT
182 
183 setup_hsr_interfaces 0
184 do_complete_ping_test
185 
186 setup_ns ns1 ns2 ns3
187 
188 setup_hsr_interfaces 1
189 do_complete_ping_test
190 
191 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