1 1.11 hannken # $NetBSD: t_ldp_regen.sh,v 1.11 2021/11/25 14:17:22 hannken Exp $ 2 1.1 kefren # 3 1.1 kefren # Copyright (c) 2013 The NetBSD Foundation, Inc. 4 1.1 kefren # All rights reserved. 5 1.1 kefren # 6 1.1 kefren # Redistribution and use in source and binary forms, with or without 7 1.1 kefren # modification, are permitted provided that the following conditions 8 1.1 kefren # are met: 9 1.1 kefren # 1. Redistributions of source code must retain the above copyright 10 1.1 kefren # notice, this list of conditions and the following disclaimer. 11 1.1 kefren # 2. Redistributions in binary form must reproduce the above copyright 12 1.1 kefren # notice, this list of conditions and the following disclaimer in the 13 1.1 kefren # documentation and/or other materials provided with the distribution. 14 1.1 kefren # 15 1.1 kefren # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 16 1.1 kefren # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17 1.1 kefren # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 1.1 kefren # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19 1.1 kefren # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 1.1 kefren # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 1.1 kefren # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 1.1 kefren # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 1.1 kefren # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 1.1 kefren # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 1.1 kefren # POSSIBILITY OF SUCH DAMAGE. 26 1.1 kefren # 27 1.1 kefren 28 1.1 kefren # IP/MPLS & LDP label reallocation test 29 1.1 kefren # Create 4 routers connected like this: R1--R2--R3--R4-- 30 1.1 kefren # The goal is to push packets from R1 to the R4 shmif1 (the right one) interface 31 1.1 kefren # Enable MPLS forwarding on R2 32 1.1 kefren # Disable IP forwarding and enable MPLS forwarding on R3 33 1.1 kefren # Start ldpd and wait for adjancencies to come up 34 1.1 kefren # Add an alias on shmif1 on R4 for which we already have a route on R3 35 1.1 kefren # Now: * R4 should install label IMPLNULL for that prefix 36 1.1 kefren # * R3 should realloc the target label from IMPLNULL to something else 37 1.1 kefren 38 1.1 kefren LDP_FLAGS="" 39 1.1 kefren 40 1.1 kefren atf_test_case ldp_regen cleanup 41 1.1 kefren ldp_regen_head() { 42 1.1 kefren 43 1.1 kefren atf_set "descr" "IP/MPLS and LDP label regeneration test" 44 1.1 kefren atf_set "require.progs" "rump_server" 45 1.1 kefren atf_set "use.fs" "true" 46 1.1 kefren } 47 1.1 kefren 48 1.1 kefren newaddr_and_ping() { 49 1.1 kefren 50 1.1 kefren # Add new address on R4 51 1.1 kefren RUMP_SERVER=${RUMP_SERVER4} atf_check -s exit:0 \ 52 1.1 kefren rump.ifconfig shmif1 10.0.5.1/24 alias 53 1.6 martin RUMP_SERVER=${RUMP_SERVER4} atf_check -s exit:0 \ 54 1.6 martin rump.ifconfig -w 60 55 1.1 kefren 56 1.1 kefren # Now ldpd on R5 should take notice of the new route and announce it 57 1.1 kefren # to R4's ldpd. ldpd on R4 should verify that the next hop 58 1.1 kefren # corresponds to its routing table and change its tag entry 59 1.1 kefren RUMP_SERVER=${RUMP_SERVER1} atf_check -s exit:0 -o ignore -e ignore \ 60 1.1 kefren rump.ping -n -o -w 5 10.0.5.1 61 1.1 kefren } 62 1.1 kefren 63 1.9 christos configservers() { 64 1.1 kefren 65 1.1 kefren # LDP HIJACK 66 1.1 kefren export RUMPHIJACK=path=/rump,socket=all,sysctl=yes 67 1.1 kefren export LD_PRELOAD=/usr/lib/librumphijack.so 68 1.1 kefren 69 1.1 kefren # Setup first server 70 1.1 kefren export RUMP_SERVER=${RUMP_SERVER1} 71 1.1 kefren atf_check -s exit:0 rump.ifconfig shmif0 create 72 1.1 kefren atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom1 73 1.1 kefren atf_check -s exit:0 rump.ifconfig shmif0 10.0.1.1/24 74 1.1 kefren atf_check -s exit:0 rump.ifconfig mpls0 create up 75 1.1 kefren atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0 76 1.1 kefren atf_check -s exit:0 rump.route -q add 10.0.4.0/24 10.0.1.2 77 1.1 kefren atf_check -s exit:0 rump.route -q add 10.0.5.0/24 10.0.1.2 78 1.1 kefren atf_check -s exit:0 /usr/sbin/ldpd ${LDP_FLAGS} 79 1.1 kefren 80 1.1 kefren # Setup second server 81 1.1 kefren export RUMP_SERVER=${RUMP_SERVER2} 82 1.1 kefren atf_check -s exit:0 rump.ifconfig shmif0 create 83 1.1 kefren atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom1 84 1.1 kefren atf_check -s exit:0 rump.ifconfig shmif0 10.0.1.2/24 85 1.1 kefren atf_check -s exit:0 rump.ifconfig shmif1 create 86 1.1 kefren atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom2 87 1.1 kefren atf_check -s exit:0 rump.ifconfig shmif1 10.0.2.1/24 88 1.1 kefren atf_check -s exit:0 rump.ifconfig mpls0 create up 89 1.1 kefren atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1 90 1.1 kefren atf_check -s exit:0 rump.sysctl -q -w net.mpls.forwarding=1 91 1.1 kefren # This one should still do ip forwarding because it announces IMPLNULL 92 1.1 kefren # for the 10.0.1.0/24 subnet 93 1.1 kefren atf_check -s exit:0 rump.route -q add 10.0.4.0/24 10.0.2.2 94 1.1 kefren atf_check -s exit:0 rump.route -q add 10.0.5.0/24 10.0.2.2 95 1.1 kefren atf_check -s exit:0 /usr/sbin/ldpd ${LDP_FLAGS} 96 1.1 kefren 97 1.1 kefren # Setup third server 98 1.1 kefren export RUMP_SERVER=${RUMP_SERVER3} 99 1.1 kefren atf_check -s exit:0 rump.ifconfig shmif0 create 100 1.1 kefren atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom2 101 1.1 kefren atf_check -s exit:0 rump.ifconfig shmif0 10.0.2.2/24 102 1.1 kefren atf_check -s exit:0 rump.ifconfig shmif1 create 103 1.1 kefren atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom3 104 1.1 kefren atf_check -s exit:0 rump.ifconfig shmif1 10.0.3.1/24 105 1.1 kefren atf_check -s exit:0 rump.ifconfig mpls0 create up 106 1.1 kefren atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1 107 1.1 kefren atf_check -s exit:0 rump.sysctl -q -w net.mpls.forwarding=1 108 1.1 kefren atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0 109 1.1 kefren atf_check -s exit:0 rump.route -q add 10.0.1.0/24 10.0.2.1 110 1.1 kefren atf_check -s exit:0 rump.route -q add 10.0.4.0/24 10.0.3.2 111 1.1 kefren atf_check -s exit:0 rump.route -q add 10.0.5.0/24 10.0.3.2 112 1.1 kefren atf_check -s exit:0 /usr/sbin/ldpd ${LDP_FLAGS} 113 1.1 kefren 114 1.1 kefren # Setup fourth server 115 1.1 kefren export RUMP_SERVER=${RUMP_SERVER4} 116 1.1 kefren atf_check -s exit:0 rump.ifconfig shmif0 create 117 1.1 kefren atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom3 118 1.1 kefren atf_check -s exit:0 rump.ifconfig shmif0 10.0.3.2/24 119 1.1 kefren atf_check -s exit:0 rump.ifconfig shmif1 create 120 1.1 kefren atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom4 121 1.1 kefren atf_check -s exit:0 rump.ifconfig shmif1 10.0.4.1/24 122 1.1 kefren atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0 123 1.1 kefren atf_check -s exit:0 rump.ifconfig mpls0 create up 124 1.1 kefren atf_check -s exit:0 rump.route -q add 10.0.1.0/24 10.0.3.1 125 1.1 kefren atf_check -s exit:0 /usr/sbin/ldpd ${LDP_FLAGS} 126 1.1 kefren 127 1.1 kefren unset RUMP_SERVER 128 1.1 kefren unset LD_PRELOAD 129 1.1 kefren unset RUMPHIJACK 130 1.1 kefren } 131 1.1 kefren 132 1.1 kefren wait_ldp_ok() { 133 1.1 kefren 134 1.1 kefren RUMP_SERVER=${RUMP_SERVER1} atf_check -s exit:0 -o ignore -e ignore \ 135 1.6 martin rump.ifconfig -w 60 136 1.6 martin RUMP_SERVER=${RUMP_SERVER1} atf_check -s exit:0 -o ignore -e ignore \ 137 1.1 kefren rump.ping -o -w 60 10.0.4.1 138 1.1 kefren } 139 1.1 kefren 140 1.1 kefren ldp_regen_body() { 141 1.1 kefren 142 1.11 hannken if drvctl -l qemufwcfg0 >/dev/null 2>&1 143 1.4 gson then 144 1.4 gson atf_skip "unreliable under qemu, skip until PR kern/43997 fixed" 145 1.4 gson fi 146 1.9 christos dostart 147 1.9 christos configservers 148 1.1 kefren wait_ldp_ok 149 1.1 kefren newaddr_and_ping 150 1.1 kefren } 151 1.1 kefren 152 1.1 kefren ldp_regen_cleanup() { 153 1.1 kefren 154 1.1 kefren docleanup 155 1.1 kefren } 156 1.1 kefren 157 1.1 kefren atf_init_test_cases() { 158 1.1 kefren 159 1.1 kefren atf_add_test_case ldp_regen 160 1.1 kefren } 161