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