1*427e22f8Santon# $OpenBSD: Makefile,v 1.8 2023/10/19 18:36:40 anton Exp $ 20cf0d01bSbluhm 30cf0d01bSbluhm# Copyright (c) 2017 Alexander Bluhm <bluhm@openbsd.org> 40cf0d01bSbluhm# Copyright (c) 2015 Vincent Gross <vgross@openbsd.org> 50cf0d01bSbluhm# 60cf0d01bSbluhm# Permission to use, copy, modify, and distribute this software for any 70cf0d01bSbluhm# purpose with or without fee is hereby granted, provided that the above 80cf0d01bSbluhm# copyright notice and this permission notice appear in all copies. 90cf0d01bSbluhm# 100cf0d01bSbluhm# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 110cf0d01bSbluhm# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 120cf0d01bSbluhm# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 130cf0d01bSbluhm# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 140cf0d01bSbluhm# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 150cf0d01bSbluhm# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 160cf0d01bSbluhm# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 170cf0d01bSbluhm 18a06106b4Santon# This tests creates a routing domain setup with bridge, vether, 190cf0d01bSbluhm# etherip, pair. Then ping packets are sent through these interfaces. 200cf0d01bSbluhm# Finally the setup is destroyed. 21e36760ecSbluhm 22e36760ecSbluhmSYSCTL_ETHERIP != sysctl net.inet.etherip.allow 23e36760ecSbluhm 24e36760ecSbluhm.if ${SYSCTL_ETHERIP:C/.*=//} != 1 25e36760ecSbluhmregress: 26e36760ecSbluhm @echo "${SYSCTL_ETHERIP}" 27e36760ecSbluhm @echo set this sysctl to 1 for additional tests 28e36760ecSbluhm @echo SKIPPED 29e36760ecSbluhm.endif 307f0698b9Syasuoka 31a06106b4Santon# This test uses routing domain and interface number 11 and 12. 32a06106b4Santon# Adjust it here, if you want to use something else. 33162afeacSbluhmN1 = 11 34162afeacSbluhmN2 = 12 35162afeacSbluhmNUMS = ${N1} ${N2} 36162afeacSbluhmIFS = bridge vether etherip pair 377f0698b9Syasuoka 38ca7f5f6fSbluhm.PHONY: busy-interfaces busy-rdomains ifconfig unconfig 39162afeacSbluhm 40ae9fff4eSbluhmREGRESS_SETUP_ONCE += busy-interfaces 41ca7f5f6fSbluhmbusy-interfaces: 42ae9fff4eSbluhm # Check if interfaces are busy. 43162afeacSbluhm.for n in ${NUMS} 440cf0d01bSbluhm.for i in ${IFS} 45ae9fff4eSbluhm @if ! /sbin/ifconfig $i$n 2>&1 | grep -q "no such interface"; then\ 46ae9fff4eSbluhm echo interface $i$n is already used >&2; exit 1; fi 47162afeacSbluhm.endfor 48162afeacSbluhm.endfor 49162afeacSbluhm 50ae9fff4eSbluhmREGRESS_SETUP_ONCE += busy-rdomains 51ca7f5f6fSbluhmbusy-rdomains: 52ae9fff4eSbluhm # Check if rdomains are busy. 53162afeacSbluhm.for n in ${NUMS} 54ae9fff4eSbluhm @if /sbin/ifconfig | grep -v '^lo$n:' | grep ' rdomain $n '; then\ 55ae9fff4eSbluhm echo routing domain $n is already used >&2; exit 1; fi 56162afeacSbluhm.endfor 57162afeacSbluhm 58ae9fff4eSbluhmREGRESS_SETUP_ONCE += ifconfig 59ca7f5f6fSbluhmifconfig: unconfig 60ae9fff4eSbluhm # Create and configure interfaces. 61162afeacSbluhm.for n in ${NUMS} 620cf0d01bSbluhm.for i in ${IFS} 63ae9fff4eSbluhm ${SUDO} /sbin/ifconfig $i$n create rdomain $n 64162afeacSbluhm.endfor 65162afeacSbluhm.endfor 66162afeacSbluhm ${SUDO} /sbin/ifconfig pair${N1} 172.31.0.1/24 67162afeacSbluhm ${SUDO} /sbin/ifconfig pair${N2} 172.31.0.2/24 patch pair${N1} 68162afeacSbluhm ${SUDO} /sbin/ifconfig vether${N1} 192.168.0.1 69162afeacSbluhm ${SUDO} /sbin/ifconfig vether${N2} 192.168.0.2 70162afeacSbluhm ${SUDO} /sbin/ifconfig etherip${N1} tunneldomain ${N1} 71162afeacSbluhm ${SUDO} /sbin/ifconfig etherip${N2} tunneldomain ${N2} 72162afeacSbluhm ${SUDO} /sbin/ifconfig bridge${N1} add vether${N1} add etherip${N1} up 73162afeacSbluhm ${SUDO} /sbin/ifconfig bridge${N2} add vether${N2} add etherip${N2} up 74162afeacSbluhm ${SUDO} /sbin/ifconfig etherip${N1} tunnel 172.31.0.1 172.31.0.2 up 75162afeacSbluhm ${SUDO} /sbin/ifconfig etherip${N2} tunnel 172.31.0.2 172.31.0.1 up 76162afeacSbluhm 77ae9fff4eSbluhmREGRESS_CLEANUP += unconfig 78162afeacSbluhmunconfig: 79ae9fff4eSbluhm # Destroy interfaces. 80162afeacSbluhm.for n in ${NUMS} 810cf0d01bSbluhm.for i in ${IFS} 82ae9fff4eSbluhm -${SUDO} /sbin/ifconfig $i$n destroy 83162afeacSbluhm.endfor 84162afeacSbluhm.endfor 85*427e22f8Santon -${SUDO} /sbin/ifconfig lo${N1} destroy 86*427e22f8Santon -${SUDO} /sbin/ifconfig lo${N2} destroy 87ae9fff4eSbluhm rm -f stamp-ifconfig 88162afeacSbluhm 89ae9fff4eSbluhmREGRESS_TARGETS += run-ping-1-2 90ae9fff4eSbluhmrun-ping-1-2: 910cf0d01bSbluhm /sbin/ping -n -w 1 -c 1 -V ${N1} 192.168.0.2 92162afeacSbluhm 93ae9fff4eSbluhmREGRESS_TARGETS += run-ping-2-1 94ae9fff4eSbluhmrun-ping-2-1: 950cf0d01bSbluhm /sbin/ping -n -w 1 -c 1 -V ${N2} 192.168.0.1 96162afeacSbluhm 977f0698b9Syasuoka.include <bsd.regress.mk> 98