1*0a6a1f1dSLionel Sambuc# $NetBSD: t_mpls_fw6.sh,v 1.2 2015/08/07 00:50:12 ozaki-r Exp $ 2*0a6a1f1dSLionel Sambuc# 3*0a6a1f1dSLionel Sambuc# Copyright (c) 2015 The NetBSD Foundation, Inc. 4*0a6a1f1dSLionel Sambuc# All rights reserved. 5*0a6a1f1dSLionel Sambuc# 6*0a6a1f1dSLionel Sambuc# Redistribution and use in source and binary forms, with or without 7*0a6a1f1dSLionel Sambuc# modification, are permitted provided that the following conditions 8*0a6a1f1dSLionel Sambuc# are met: 9*0a6a1f1dSLionel Sambuc# 1. Redistributions of source code must retain the above copyright 10*0a6a1f1dSLionel Sambuc# notice, this list of conditions and the following disclaimer. 11*0a6a1f1dSLionel Sambuc# 2. Redistributions in binary form must reproduce the above copyright 12*0a6a1f1dSLionel Sambuc# notice, this list of conditions and the following disclaimer in the 13*0a6a1f1dSLionel Sambuc# documentation and/or other materials provided with the distribution. 14*0a6a1f1dSLionel Sambuc# 15*0a6a1f1dSLionel Sambuc# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 16*0a6a1f1dSLionel Sambuc# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17*0a6a1f1dSLionel Sambuc# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18*0a6a1f1dSLionel Sambuc# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19*0a6a1f1dSLionel Sambuc# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20*0a6a1f1dSLionel Sambuc# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21*0a6a1f1dSLionel Sambuc# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22*0a6a1f1dSLionel Sambuc# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23*0a6a1f1dSLionel Sambuc# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24*0a6a1f1dSLionel Sambuc# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25*0a6a1f1dSLionel Sambuc# POSSIBILITY OF SUCH DAMAGE. 26*0a6a1f1dSLionel Sambuc# 27*0a6a1f1dSLionel Sambuc 28*0a6a1f1dSLionel Sambuc# Test MPLS encap/decap and forwarding using INET6 as encapsulated protocol 29*0a6a1f1dSLionel Sambuc# Setup four routers connected like this: R1---R2---R3---R4-- 30*0a6a1f1dSLionel Sambuc# Goal is to be able to ping from R1 the outermost interface of R4 31*0a6a1f1dSLionel Sambuc# Disable net.inet6.ip6.forwarding, enable net.mpls.forwarding 32*0a6a1f1dSLionel Sambuc# Add route on R1 in order to encapsulate into MPLS the IP6 packets with 33*0a6a1f1dSLionel Sambuc# destination equal to R4 right hand side interface 34*0a6a1f1dSLionel Sambuc# Add MPLS routes on R2 in order to forward frames belonging to that FEC to R3 35*0a6a1f1dSLionel Sambuc# Add MPLS "POP" route on R3 for that FEC, pointing to R4 36*0a6a1f1dSLionel Sambuc# Do the same for the reverse direction (R4 to R1) 37*0a6a1f1dSLionel Sambuc# ping6 from R1 to R4 right hand side interface 38*0a6a1f1dSLionel Sambuc# 39*0a6a1f1dSLionel Sambuc# redo the test using IPv6 explicit null label 40*0a6a1f1dSLionel Sambuc 41*0a6a1f1dSLionel SambucRUMP_SERVER1=unix://./r1 42*0a6a1f1dSLionel SambucRUMP_SERVER2=unix://./r2 43*0a6a1f1dSLionel SambucRUMP_SERVER3=unix://./r3 44*0a6a1f1dSLionel SambucRUMP_SERVER4=unix://./r4 45*0a6a1f1dSLionel Sambuc 46*0a6a1f1dSLionel SambucRUMP_FLAGS6=\ 47*0a6a1f1dSLionel Sambuc"-lrumpnet -lrumpnet_net -lrumpnet_netmpls -lrumpnet_netinet -lrumpnet_netinet6 -lrumpnet_shmif" 48*0a6a1f1dSLionel Sambuc 49*0a6a1f1dSLionel Sambucatf_test_case mplsfw6 cleanup 50*0a6a1f1dSLionel Sambucmplsfw6_head() 51*0a6a1f1dSLionel Sambuc{ 52*0a6a1f1dSLionel Sambuc 53*0a6a1f1dSLionel Sambuc atf_set "descr" "IP6/MPLS forwarding test using PHP" 54*0a6a1f1dSLionel Sambuc atf_set "require.progs" "rump_server" 55*0a6a1f1dSLionel Sambuc} 56*0a6a1f1dSLionel Sambuc 57*0a6a1f1dSLionel Sambucstartservers() 58*0a6a1f1dSLionel Sambuc{ 59*0a6a1f1dSLionel Sambuc 60*0a6a1f1dSLionel Sambuc ulimit -r 300 61*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump_server ${RUMP_FLAGS6} ${RUMP_SERVER1} 62*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump_server ${RUMP_FLAGS6} ${RUMP_SERVER2} 63*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump_server ${RUMP_FLAGS6} ${RUMP_SERVER3} 64*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump_server ${RUMP_FLAGS6} ${RUMP_SERVER4} 65*0a6a1f1dSLionel Sambuc} 66*0a6a1f1dSLionel Sambuc 67*0a6a1f1dSLionel Sambucconfigservers() 68*0a6a1f1dSLionel Sambuc{ 69*0a6a1f1dSLionel Sambuc 70*0a6a1f1dSLionel Sambuc # Setup the first server 71*0a6a1f1dSLionel Sambuc export RUMP_SERVER=${RUMP_SERVER1} 72*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 create 73*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom1 74*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 inet6 fd00:1234::1/64 alias 75*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig mpls0 create up 76*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1 77*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.sysctl -q -w net.inet6.ip6.forwarding=0 78*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.route -q add -inet6 fd00:1234:0:3::/64 \ 79*0a6a1f1dSLionel Sambuc -ifa fd00:1234::1 \ 80*0a6a1f1dSLionel Sambuc -ifp mpls0 -tag 25 -inet6 fd00:1234::2 81*0a6a1f1dSLionel Sambuc 82*0a6a1f1dSLionel Sambuc # Setup the second server 83*0a6a1f1dSLionel Sambuc export RUMP_SERVER=${RUMP_SERVER2} 84*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 create 85*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom1 86*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 inet6 fd00:1234::2/64 alias 87*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif1 create 88*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom2 89*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif1 inet6 fd00:1234:0:1::1/64 alias 90*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig mpls0 create up 91*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1 92*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.sysctl -q -w net.mpls.forwarding=1 93*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.sysctl -q -w net.inet6.ip6.forwarding=0 94*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.route -q add -mpls 25 -tag 30 \ 95*0a6a1f1dSLionel Sambuc -inet6 fd00:1234:0:1::2 96*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.route -q add -mpls 27 -tag ${1} -inet6 \ 97*0a6a1f1dSLionel Sambuc fd00:1234::1 98*0a6a1f1dSLionel Sambuc 99*0a6a1f1dSLionel Sambuc # Setup the third server 100*0a6a1f1dSLionel Sambuc export RUMP_SERVER=${RUMP_SERVER3} 101*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 create 102*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom2 103*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 inet6 fd00:1234:0:1::2/64 alias 104*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif1 create 105*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom3 106*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif1 inet6 fd00:1234:0:2::1/64 alias 107*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig mpls0 create up 108*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1 109*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.sysctl -q -w net.mpls.forwarding=1 110*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.sysctl -q -w net.inet6.ip6.forwarding=0 111*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.route -q add -mpls 30 -tag ${1} \ 112*0a6a1f1dSLionel Sambuc -inet6 fd00:1234:0:2::2 113*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.route -q add -mpls 26 -tag 27 \ 114*0a6a1f1dSLionel Sambuc -inet6 fd00:1234:0:1::1 115*0a6a1f1dSLionel Sambuc 116*0a6a1f1dSLionel Sambuc # Setup the fourth server 117*0a6a1f1dSLionel Sambuc export RUMP_SERVER=${RUMP_SERVER4} 118*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 create 119*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom3 120*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 inet6 fd00:1234:0:2::2/64 alias 121*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif1 create 122*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom4 123*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif1 inet6 fd00:1234:0:3::1/64 alias 124*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig mpls0 create up 125*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1 126*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.sysctl -q -w net.inet6.ip6.forwarding=0 127*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.route -q add -inet6 fd00:1234::/64 \ 128*0a6a1f1dSLionel Sambuc -ifa fd00:1234:0:2::2 \ 129*0a6a1f1dSLionel Sambuc -ifp mpls0 -tag 26 -inet6 fd00:1234:0:2::1 130*0a6a1f1dSLionel Sambuc 131*0a6a1f1dSLionel Sambuc unset RUMP_SERVER 132*0a6a1f1dSLionel Sambuc} 133*0a6a1f1dSLionel Sambuc 134*0a6a1f1dSLionel Sambucdoping() 135*0a6a1f1dSLionel Sambuc{ 136*0a6a1f1dSLionel Sambuc 137*0a6a1f1dSLionel Sambuc export RUMP_SERVER=${RUMP_SERVER1} 138*0a6a1f1dSLionel Sambuc atf_check -s exit:0 \ 139*0a6a1f1dSLionel Sambuc -o match:" bytes from fd00:1234::2, icmp_seq=" \ 140*0a6a1f1dSLionel Sambuc rump.ping6 -n -o -X 2 fd00:1234::2 141*0a6a1f1dSLionel Sambuc export RUMP_SERVER=${RUMP_SERVER2} 142*0a6a1f1dSLionel Sambuc atf_check -s exit:0 \ 143*0a6a1f1dSLionel Sambuc -o match:" bytes from fd00:1234:0:1::2, icmp_seq=" \ 144*0a6a1f1dSLionel Sambuc rump.ping6 -n -o -X 2 fd00:1234:0:1::2 145*0a6a1f1dSLionel Sambuc export RUMP_SERVER=${RUMP_SERVER3} 146*0a6a1f1dSLionel Sambuc atf_check -s exit:0 \ 147*0a6a1f1dSLionel Sambuc -o match:" bytes from fd00:1234:0:2::2, icmp_seq=" \ 148*0a6a1f1dSLionel Sambuc rump.ping6 -n -o -X 2 fd00:1234:0:2::2 149*0a6a1f1dSLionel Sambuc export RUMP_SERVER=${RUMP_SERVER1} 150*0a6a1f1dSLionel Sambuc atf_check -s exit:0 \ 151*0a6a1f1dSLionel Sambuc -o match:" bytes from fd00:1234:0:3::1, icmp_seq=" \ 152*0a6a1f1dSLionel Sambuc rump.ping6 -n -o -X 2 fd00:1234:0:3::1 153*0a6a1f1dSLionel Sambuc unset RUMP_SERVER 154*0a6a1f1dSLionel Sambuc} 155*0a6a1f1dSLionel Sambuc 156*0a6a1f1dSLionel Sambucdo_check_route() 157*0a6a1f1dSLionel Sambuc{ 158*0a6a1f1dSLionel Sambuc 159*0a6a1f1dSLionel Sambuc export RUMP_SERVER=${RUMP_SERVER1} 160*0a6a1f1dSLionel Sambuc atf_check -s exit:0 \ 161*0a6a1f1dSLionel Sambuc -o match:"^fd00:1234:0:3::/64.+fd00:1234::2.+25.+mpls0" \ 162*0a6a1f1dSLionel Sambuc rump.netstat -nrT 163*0a6a1f1dSLionel Sambuc unset RUMP_SERVER 164*0a6a1f1dSLionel Sambuc} 165*0a6a1f1dSLionel Sambuc 166*0a6a1f1dSLionel Sambucdocleanup() 167*0a6a1f1dSLionel Sambuc{ 168*0a6a1f1dSLionel Sambuc 169*0a6a1f1dSLionel Sambuc RUMP_SERVER=${RUMP_SERVER1} rump.halt 170*0a6a1f1dSLionel Sambuc RUMP_SERVER=${RUMP_SERVER2} rump.halt 171*0a6a1f1dSLionel Sambuc RUMP_SERVER=${RUMP_SERVER3} rump.halt 172*0a6a1f1dSLionel Sambuc RUMP_SERVER=${RUMP_SERVER4} rump.halt 173*0a6a1f1dSLionel Sambuc} 174*0a6a1f1dSLionel Sambuc 175*0a6a1f1dSLionel Sambucmplsfw6_body() 176*0a6a1f1dSLionel Sambuc{ 177*0a6a1f1dSLionel Sambuc 178*0a6a1f1dSLionel Sambuc startservers 179*0a6a1f1dSLionel Sambuc configservers 3 180*0a6a1f1dSLionel Sambuc do_check_route 181*0a6a1f1dSLionel Sambuc doping 182*0a6a1f1dSLionel Sambuc} 183*0a6a1f1dSLionel Sambuc 184*0a6a1f1dSLionel Sambucmplsfw6_cleanup() 185*0a6a1f1dSLionel Sambuc{ 186*0a6a1f1dSLionel Sambuc 187*0a6a1f1dSLionel Sambuc docleanup 188*0a6a1f1dSLionel Sambuc} 189*0a6a1f1dSLionel Sambuc 190*0a6a1f1dSLionel Sambuc 191*0a6a1f1dSLionel Sambucatf_test_case mplsfw6_expl cleanup 192*0a6a1f1dSLionel Sambucmplsfw4_expl_head() 193*0a6a1f1dSLionel Sambuc{ 194*0a6a1f1dSLionel Sambuc 195*0a6a1f1dSLionel Sambuc atf_set "descr" "IP6/MPLS forwarding test using explicit NULL labels" 196*0a6a1f1dSLionel Sambuc atf_set "require.progs" "rump_server" 197*0a6a1f1dSLionel Sambuc} 198*0a6a1f1dSLionel Sambuc 199*0a6a1f1dSLionel Sambucmplsfw6_expl_body() 200*0a6a1f1dSLionel Sambuc{ 201*0a6a1f1dSLionel Sambuc 202*0a6a1f1dSLionel Sambuc startservers 203*0a6a1f1dSLionel Sambuc configservers 2 204*0a6a1f1dSLionel Sambuc do_check_route 205*0a6a1f1dSLionel Sambuc doping 206*0a6a1f1dSLionel Sambuc} 207*0a6a1f1dSLionel Sambuc 208*0a6a1f1dSLionel Sambucmplsfw6_expl_cleanup() 209*0a6a1f1dSLionel Sambuc{ 210*0a6a1f1dSLionel Sambuc 211*0a6a1f1dSLionel Sambuc docleanup 212*0a6a1f1dSLionel Sambuc} 213*0a6a1f1dSLionel Sambuc 214*0a6a1f1dSLionel Sambuc 215*0a6a1f1dSLionel Sambucatf_init_test_cases() 216*0a6a1f1dSLionel Sambuc{ 217*0a6a1f1dSLionel Sambuc 218*0a6a1f1dSLionel Sambuc atf_add_test_case mplsfw6 219*0a6a1f1dSLionel Sambuc atf_add_test_case mplsfw6_expl 220*0a6a1f1dSLionel Sambuc} 221