1# $NetBSD: t_rfc4182.sh,v 1.6 2020/04/01 01:49:26 christos Exp $ 2# 3# Copyright (c) 2013 The NetBSD Foundation, Inc. 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: 9# 1. Redistributions of source code must retain the above copyright 10# notice, this list of conditions and the following disclaimer. 11# 2. Redistributions in binary form must reproduce the above copyright 12# notice, this list of conditions and the following disclaimer in the 13# documentation and/or other materials provided with the distribution. 14# 15# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 16# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25# POSSIBILITY OF SUCH DAMAGE. 26# 27 28# TEST RFC 4182 29# Setup four routers connected like this: R1---R2---R3---R4-- 30# Goal is to be able to ping from R1 the outermost interface of R4 31# Disable net.inet.ip.forwarding, enable net.mpls.forwarding 32# Add route on R1 in order to encapsulate into MPLS the IP packets with 33# destination equal to R4 right hand side interface. Use two labels here: 34# 25 and IPv6 Explicit NULL 35# Add a double tagged MPLS route on R2 in order to forward frames belonging to 36# that FEC to R3, with IPv4 NULL being the most outermost one 37# Add MPLS "POP" route on R3 for that FEC, pointing to R4 38# Do the same for the reverse direction (R4 to R1) 39# ping from R1 to R4 right hand side interface 40 41 42atf_test_case rfc4182 cleanup 43rfc4182_head() 44{ 45 46 atf_set "descr" "RFC 4182 conformance test" 47 atf_set "require.progs" "rump_server" 48} 49 50configservers() 51{ 52 53 # Setup the first server 54 export RUMP_SERVER=${RUMP_SERVER1} 55 atf_check -s exit:0 rump.ifconfig shmif0 create 56 atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom1 57 atf_check -s exit:0 rump.ifconfig shmif0 10.0.1.1/24 58 atf_check -s exit:0 rump.ifconfig mpls0 create up 59 atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1 60 atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0 61 atf_check -s exit:0 rump.route -q add 10.0.4.0/24 -ifa 10.0.1.1 \ 62 -ifp mpls0 -tag 25,2 -inet 10.0.1.2 63 64 # Setup the second server 65 export RUMP_SERVER=${RUMP_SERVER2} 66 atf_check -s exit:0 rump.ifconfig shmif0 create 67 atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom1 68 atf_check -s exit:0 rump.ifconfig shmif0 10.0.1.2/24 69 atf_check -s exit:0 rump.ifconfig shmif1 create 70 atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom2 71 atf_check -s exit:0 rump.ifconfig shmif1 10.0.2.1/24 72 atf_check -s exit:0 rump.ifconfig mpls0 create up 73 atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1 74 atf_check -s exit:0 rump.sysctl -q -w net.mpls.forwarding=1 75 atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0 76 atf_check -s exit:0 rump.route -q add -mpls 25 -tag 30,0 -inet 10.0.2.2 77 atf_check -s exit:0 rump.route -q add -mpls 27 -tag 3 -inet 10.0.1.1 78 79 # Setup the third server 80 export RUMP_SERVER=${RUMP_SERVER3} 81 atf_check -s exit:0 rump.ifconfig shmif0 create 82 atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom2 83 atf_check -s exit:0 rump.ifconfig shmif0 10.0.2.2/24 84 atf_check -s exit:0 rump.ifconfig shmif1 create 85 atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom3 86 atf_check -s exit:0 rump.ifconfig shmif1 10.0.3.1/24 87 atf_check -s exit:0 rump.ifconfig mpls0 create up 88 atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1 89 atf_check -s exit:0 rump.sysctl -q -w net.mpls.forwarding=1 90 atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0 91 atf_check -s exit:0 rump.route -q add -mpls 30 -tag 3 -inet 10.0.3.2 92 atf_check -s exit:0 rump.route -q add -mpls 26 -tag 27,0 -inet 10.0.2.1 93 94 # Setup the fourth server 95 export RUMP_SERVER=${RUMP_SERVER4} 96 atf_check -s exit:0 rump.ifconfig shmif0 create 97 atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom3 98 atf_check -s exit:0 rump.ifconfig shmif0 10.0.3.2/24 99 atf_check -s exit:0 rump.ifconfig shmif1 create 100 atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom4 101 atf_check -s exit:0 rump.ifconfig shmif1 10.0.4.1/24 102 atf_check -s exit:0 rump.ifconfig mpls0 create up 103 atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1 104 atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0 105 atf_check -s exit:0 rump.route -q add 10.0.1.0/24 -ifa 10.0.3.2 \ 106 -ifp mpls0 -tag 26 -inet 10.0.3.1 107 108 unset RUMP_SERVER 109} 110 111doping() 112{ 113 114 export RUMP_SERVER=${RUMP_SERVER1} 115 atf_check -s exit:0 -o match:"64 bytes from 10.0.4.1: icmp_seq=" \ 116 rump.ping -n -o -w 5 10.0.4.1 117 unset RUMP_SERVER 118} 119 120rfc4182_body() 121{ 122 123 dostart 124 configservers 125 doping 126} 127 128rfc4182_cleanup() 129{ 130 131 docleanup 132} 133 134atf_init_test_cases() 135{ 136 137 atf_add_test_case rfc4182 138} 139