1# $OpenBSD: Makefile,v 1.13 2020/12/30 21:40:33 kn Exp $ 2 3# The following ports must be installed: 4# 5# scapy powerful interactive packet manipulation in python 6 7.if ! exists(/usr/local/bin/scapy) 8regress: 9 @echo Install scapy package to run this regress. 10 @echo SKIPPED 11.endif 12 13# This test needs a manual setup of two machines 14# Set up machines: LOCAL REMOTE 15# LOCAL is the machine where this makefile is running. 16# REMOTE is running OpenBSD with pf to test the neighbor discovery states. 17 18# Configure addresses on the machines. 19# Adapt interface and addresse variables to your local setup. 20 21LOCAL_IF ?= em1 22LOCAL_MAC ?= 00:1b:21:0e:6e:8e 23REMOTE_MAC ?= 00:04:23:b0:68:8e 24 25LOCAL_ADDR6 ?= fdd7:e83e:66bc:81::21 26REMOTE_ADDR6 ?= fdd7:e83e:66bc:81::22 27 28REMOTE_SSH ?= 29 30# pf rules on REMOTE should look like this: 31# 32# block log 33# pass inet6 proto icmp6 icmp6-type echoreq keep state 34# pass inet6 proto icmp6 icmp6-type neighbrsol keep state 35# pass inet6 proto icmp6 icmp6-type neighbradv keep state 36 37# RFC 4861 7. describes the following test cases for ND: 38# 39# Duplicate Address Detection 40# - request NS from unspecified address to target solicitated-node multicast 41# - response NA from interface address to all-nodes multicast 42# 43# Address Resolution 44# - request NS from interface address to target solicitated-node multicast 45# - response NA from interface address to source of NS 46# 47# Unsolicited Neighbor Advertisements 48# - request NA from interface address to all-nodes multicast 49# 50# Neighbor Unreachability Detection 51# - request NS from interface address to target unicast 52# - response NA from interface address to source of NS 53 54.if empty (LOCAL_IF) || empty (LOCAL_MAC) || empty (REMOTE_MAC) || \ 55 empty (LOCAL_ADDR6) || empty (REMOTE_ADDR6) || empty (REMOTE_SSH) 56regress: 57 @echo This tests needs a remote machine to operate on. 58 @echo LOCAL_IF LOCAL_MAC REMOTE_MAC LOCAL_ADDR6 REMOTE_ADDR6 59 @echo REMOTE_SSH are empty. 60 @echo Fill out these variables for additional tests. 61 @echo SKIPPED 62.endif 63 64# Create python include file containing the addresses. 65addr.py: Makefile 66 rm -f $@ $@.tmp 67 echo 'LOCAL_IF = "${LOCAL_IF}"' >>$@.tmp 68 echo 'LOCAL_MAC = "${LOCAL_MAC}"' >>$@.tmp 69 echo 'REMOTE_MAC = "${REMOTE_MAC}"' >>$@.tmp 70.for var in LOCAL_ADDR REMOTE_ADDR 71 echo '${var} = "${${var}}"' >>$@.tmp 72 echo '${var}6 = "${${var}6}"' >>$@.tmp 73.endfor 74 mv $@.tmp $@ 75 76# Set variables so that make runs with and without obj directory. 77# Only do that if necessary to keep visible output short. 78.if ${.CURDIR} == ${.OBJDIR} 79PYTHON = python3 -u ./ 80.else 81PYTHON = PYTHONPATH=${.OBJDIR} python3 -u ${.CURDIR}/ 82.endif 83 84# Clear neighbor cache and ping all addresses. This ensures that 85# the ip addresses are configured and all routing table are set up 86# to allow bidirectional packet flow. 87REGRESS_TARGETS += run-ping6 88run-ping6: 89 ${SUDO} ndp -c 90.for ip in LOCAL_ADDR REMOTE_ADDR 91 @echo Check ping6 ${ip}6: 92 ping6 -n -c 1 ${${ip}6} 93.endfor 94 95ND6_SCRIPTS !!= cd ${.CURDIR} && ls -1 nd6*.py 96 97.for s in ${ND6_SCRIPTS} 98REGRESS_TARGETS += run-${s} 99run-${s}: addr.py 100 ${SUDO} ${PYTHON}${s} 101.endfor 102 103CLEANFILES += addr.py *.pyc *.log 104 105.PHONY: check-setup check-setup-local check-setup-remote 106 107# Check wether the address, route and remote setup is correct 108check-setup: check-setup-local check-setup-remote 109 110check-setup-local: 111 @echo '\n======== $@ ========' 112 ping6 -n -c 1 ${LOCAL_ADDR6} # LOCAL_ADDR6 113 route -n get -inet6 ${LOCAL_ADDR6} |\ 114 grep -q 'flags: .*LOCAL' # LOCAL_ADDR6 115 ping6 -n -c 1 ${REMOTE_ADDR6} # REMOTE_ADDR6 116 route -n get -inet6 ${REMOTE_ADDR6} |\ 117 grep -q 'interface: ${LOCAL_IF}$$' # REMOTE_ADDR6 LOCAL_IF 118 ndp -n ${REMOTE_ADDR6} |\ 119 grep -q ' ${REMOTE_MAC} ' # REMOTE_ADDR6 REMOTE_MAC 120 121check-setup-remote: 122 @echo '\n======== $@ ========' 123 ssh ${REMOTE_SSH} ping6 -n -c 1 ${REMOTE_ADDR6} # REMOTE_ADDR6 124 ssh ${REMOTE_SSH} route -n get -inet6 ${REMOTE_ADDR6} |\ 125 grep -q 'flags: .*LOCAL' # REMOTE_ADDR6 126 ssh ${REMOTE_SSH} ping6 -n -c 1 ${LOCAL_ADDR6} # LOCAL_ADDR6 127 ssh ${REMOTE_SSH} ndp -n ${LOCAL_ADDR6} |\ 128 grep -q ' ${LOCAL_MAC} ' # LOCAL_ADDR6 LOCAL_MAC 129 130.include <bsd.regress.mk> 131