diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2017-03-01 00:05:22 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2017-03-01 00:05:22 +0000 |
commit | 7b2730cfd0bd8e7cd26fa91d751988ce44260d79 (patch) | |
tree | 4285b50cd602e58e5869d3a9be744fd0a33f17c3 /regress | |
parent | caf6dc7d95bee7741685c9186e89f4473f9a95a9 (diff) |
Use consistent address schema with local and remote machine. Fill
variables with example IPs from my daily test run.
Diffstat (limited to 'regress')
40 files changed, 435 insertions, 336 deletions
diff --git a/regress/sys/netinet6/frag6/Makefile b/regress/sys/netinet6/frag6/Makefile index 6cd47ca6d07..6f8c229a8eb 100644 --- a/regress/sys/netinet6/frag6/Makefile +++ b/regress/sys/netinet6/frag6/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.16 2017/02/28 16:08:10 bluhm Exp $ +# $OpenBSD: Makefile,v 1.17 2017/03/01 00:05:21 bluhm Exp $ # The following ports must be installed: # @@ -13,6 +13,8 @@ PYTHON_IMPORT !!= python2.7 -c 'from scapy.all import *' 2>&1 || true .endif .if ! empty(PYTHON_IMPORT) +.BEGIN: + @true regress: @echo '${PYTHON_IMPORT}' @echo Install python and the scapy module for additional tests. @@ -20,31 +22,31 @@ regress: .endif # This test needs a manual setup of two machines -# Set up machines: SRC DST -# SRC is the machine where this makefile is running. -# DST is running OpenBSD with pf disabled to test the IPv6 stack. -# Enable echo udp6 in inetd.conf of DST to test UDP fragments. -# -# +---+ 1 +---+ -# |SRC| ----> |DST| -# +---+ +---+ -# out in +# Set up machines: LOCAL REMOTE +# LOCAL is the machine where this makefile is running. +# REMOTE is running OpenBSD with or without pf to test fragment reassemly +# Enable echo udp6 in inetd.conf on REMOTE to test UDP fragments. +# REMOTE_SSH is used to login and enable or disable pf automatically. -# Configure Addresses on the machines. +# Configure addresses on the machines. # Adapt interface and addresse variables to your local setup. -# -SRC_IF ?= -SRC_MAC ?= -DST_MAC ?= -SRC_OUT6 ?= -DST_IN6 ?= +LOCAL_IF ?= em1 +LOCAL_MAC ?= 00:1b:21:0e:6e:8e +REMOTE_MAC ?= 00:04:23:b0:68:8e + +LOCAL_ADDR ?= fdd7:e83e:66bc:81::21 +REMOTE_ADDR ?= fdd7:e83e:66bc:81::22 -.if empty (SRC_IF) || empty (SRC_MAC) || empty (DST_MAC) || \ - empty (SRC_OUT6) || empty (DST_IN6) || empty (REMOTE_SSH) +REMOTE_SSH ?= + +.if empty (LOCAL_IF) || empty (LOCAL_MAC) || empty (REMOTE_MAC) || \ + empty (LOCAL_ADDR6) || empty (REMOTE_ADDR6) || empty (REMOTE_SSH) +.BEGIN: + @true regress: @echo This tests needs a remote machine to operate on. - @echo SRC_IF SRC_MAC DST_MAC SRC_OUT6 DST_IN6 REMOTE_SSH are empty. + @echo LOCAL_IF LOCAL_MAC REMOTE_MAC LOCAL_ADDR6 REMOTE_ADDR6 REMOTE_SSH @echo Fill out these variables for additional tests. @echo SKIPPED .endif @@ -63,10 +65,10 @@ depend: addr.py # Create python include file containing the addresses. addr.py: Makefile rm -f $@ $@.tmp - echo 'SRC_IF = "${SRC_IF}"' >>$@.tmp - echo 'SRC_MAC = "${SRC_MAC}"' >>$@.tmp - echo 'DST_MAC = "${DST_MAC}"' >>$@.tmp -.for var in SRC_OUT DST_IN + echo 'LOCAL_IF = "${LOCAL_IF}"' >>$@.tmp + echo 'LOCAL_MAC = "${LOCAL_MAC}"' >>$@.tmp + echo 'REMOTE_MAC = "${REMOTE_MAC}"' >>$@.tmp +.for var in LOCAL_ADDR REMOTE_ADDR echo '${var}6 = "${${var}6}"' >>$@.tmp .endfor mv $@.tmp $@ @@ -103,17 +105,17 @@ FRAG6_SCRIPTS !!= cd ${.CURDIR} && ls -1 frag6*.py ${sp}: run-regress-${sp}-ping6 run-regress-${sp}-ping6: stamp-${sp} @echo '\n======== $@ ========' -.for ip in SRC_OUT DST_IN +.for ip in LOCAL_ADDR REMOTE_ADDR @echo Check ping6 ${ip}6: ping6 -n -c 1 ${${ip}6} .endfor # Ping all addresses again but with 5000 bytes payload. These large -# packets get fragmented by SRC and must be handled by DST. +# packets get fragmented by LOCAL and must be handled by REMOTE. ${sp}: run-regress-${sp}-fragping6 run-regress-${sp}-fragping6: stamp-${sp} @echo '\n======== $@ ========' -.for ip in SRC_OUT DST_IN +.for ip in LOCAL_ADDR REMOTE_ADDR @echo Check ping6 ${ip}6: ping6 -n -c 1 -s 5000 -m ${${ip}6} .endfor @@ -136,4 +138,29 @@ REGRESS_TARGETS += stamp-pf CLEANFILES += addr.py *.pyc *.log stamp-* +.PHONY: check-setup check-setup-local check-setup-remote + +# Check wether the address, route and remote setup is correct +check-setup: check-setup-local check-setup-remote + +check-setup-local: + @echo '\n======== $@ ========' + ping6 -n -c 1 ${LOCAL_ADDR6} # LOCAL_ADDR6 + route -n get -inet6 ${LOCAL_ADDR6} |\ + grep -q 'flags: .*LOCAL' # LOCAL_ADDR6 + ping6 -n -c 1 ${REMOTE_ADDR6} # REMOTE_ADDR6 + route -n get -inet6 ${REMOTE_ADDR6} |\ + grep -q 'interface: ${LOCAL_IF}$$' # REMOTE_ADDR6 LOCAL_IF + ndp -n ${REMOTE_ADDR6} |\ + grep -q ' ${REMOTE_MAC} ' # REMOTE_ADDR6 REMOTE_MAC + +check-setup-remote: + @echo '\n======== $@ ========' + ssh ${REMOTE_SSH} ping6 -n -c 1 ${REMOTE_ADDR6} # REMOTE_ADDR6 + ssh ${REMOTE_SSH} route -n get -inet6 ${REMOTE_ADDR6} |\ + grep -q 'flags: .*LOCAL' # REMOTE_ADDR6 + ssh ${REMOTE_SSH} ping6 -n -c 1 ${LOCAL_ADDR6} # LOCAL_ADDR6 + ssh ${REMOTE_SSH} ndp -n ${LOCAL_ADDR6} |\ + grep -q ' ${LOCAL_MAC} ' # LOCAL_ADDR6 LOCAL_MAC + .include <bsd.regress.mk> diff --git a/regress/sys/netinet6/frag6/frag6.py b/regress/sys/netinet6/frag6/frag6.py index 5a4c94007a8..e6a8b104135 100644 --- a/regress/sys/netinet6/frag6/frag6.py +++ b/regress/sys/netinet6/frag6/frag6.py @@ -12,23 +12,24 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff payload="ABCDEFGHIJKLMNOP" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/ICMPv6EchoRequest(id=eid, data=payload) +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ + ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:56]) frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/str(packet)[56:64]) eth=[] for f in frag: - pkt=IPv6(src=SRC_OUT6, dst=DST_IN6)/f - eth.append(Ether(src=SRC_MAC, dst=DST_MAC)/pkt) + pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f + eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/pkt) if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and src "+DST_IN6+" and dst "+SRC_OUT6+" and icmp6") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and src "+REMOTE_ADDR6+" and dst "+LOCAL_ADDR6+" and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ diff --git a/regress/sys/netinet6/frag6/frag6_ext.py b/regress/sys/netinet6/frag6/frag6_ext.py index e10b0e0cf4d..cb08a0eed60 100644 --- a/regress/sys/netinet6/frag6/frag6_ext.py +++ b/regress/sys/netinet6/frag6/frag6_ext.py @@ -12,23 +12,24 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff payload="ABCDEFGHIJKLMNOP" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/ICMPv6EchoRequest(id=eid, data=payload) +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ + ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:56]) frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/str(packet)[56:64]) eth=[] for f in frag: - pkt=IPv6(src=SRC_OUT6, dst=DST_IN6)/IPv6ExtHdrHopByHop()/f - eth.append(Ether(src=SRC_MAC, dst=DST_MAC)/pkt) + pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/IPv6ExtHdrHopByHop()/f + eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/pkt) if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and src "+DST_IN6+" and dst "+SRC_OUT6+" and icmp6") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and src "+REMOTE_ADDR6+" and dst "+LOCAL_ADDR6+" and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ diff --git a/regress/sys/netinet6/frag6/frag6_hop.py b/regress/sys/netinet6/frag6/frag6_hop.py index 4cee4fcfe9d..a04ae7b4c5a 100644 --- a/regress/sys/netinet6/frag6/frag6_hop.py +++ b/regress/sys/netinet6/frag6/frag6_hop.py @@ -12,7 +12,7 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff payload="ABCDEFGHIJKLMNOP" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/IPv6ExtHdrHopByHop()/ \ +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/IPv6ExtHdrHopByHop()/ \ ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff @@ -20,16 +20,16 @@ frag.append(IPv6ExtHdrFragment(nh=0, id=fid, m=1)/str(packet)[40:64]) frag.append(IPv6ExtHdrFragment(nh=0, id=fid, offset=3)/str(packet)[64:72]) eth=[] for f in frag: - pkt=IPv6(src=SRC_OUT6, dst=DST_IN6)/f - eth.append(Ether(src=SRC_MAC, dst=DST_MAC)/pkt) + pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f + eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/pkt) if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and src "+DST_IN6+" and dst "+SRC_OUT6+" and icmp6") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and src "+REMOTE_ADDR6+" and dst "+LOCAL_ADDR6+" and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ diff --git a/regress/sys/netinet6/frag6/frag6_mf0atomic.py b/regress/sys/netinet6/frag6/frag6_mf0atomic.py index e4712b1fcb6..46c9d2fd015 100644 --- a/regress/sys/netinet6/frag6/frag6_mf0atomic.py +++ b/regress/sys/netinet6/frag6/frag6_mf0atomic.py @@ -13,7 +13,8 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff payload="ABCDEFGHIJKLMNOP" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/ICMPv6EchoRequest(id=eid, data=payload) +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ + ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:56]) @@ -21,16 +22,16 @@ frag.append(IPv6ExtHdrFragment(nh=58, id=fid)/str(packet)[40:48]) frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/str(packet)[56:64]) eth=[] for f in frag: - pkt=IPv6(src=SRC_OUT6, dst=DST_IN6)/f - eth.append(Ether(src=SRC_MAC, dst=DST_MAC)/pkt) + pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f + eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/pkt) if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and src "+DST_IN6+" and dst "+SRC_OUT6+" and icmp6") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and src "+REMOTE_ADDR6+" and dst "+LOCAL_ADDR6+" and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ diff --git a/regress/sys/netinet6/frag6/frag6_mf0long.py b/regress/sys/netinet6/frag6/frag6_mf0long.py index 1e367fb6dcd..e168c2d5118 100644 --- a/regress/sys/netinet6/frag6/frag6_mf0long.py +++ b/regress/sys/netinet6/frag6/frag6_mf0long.py @@ -14,7 +14,8 @@ pid=os.getpid() eid=pid & 0xffff payload="ABCDEFGHIJKLMNOP" dummy="01234567" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/ICMPv6EchoRequest(id=eid, data=payload) +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ + ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1)/str(packet)[48:64]) @@ -23,16 +24,16 @@ frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/ \ frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:48]) eth=[] for f in frag: - pkt=IPv6(src=SRC_OUT6, dst=DST_IN6)/f - eth.append(Ether(src=SRC_MAC, dst=DST_MAC)/pkt) + pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f + eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/pkt) if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and src "+DST_IN6+" and dst "+SRC_OUT6+" and icmp6") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and src "+REMOTE_ADDR6+" and dst "+LOCAL_ADDR6+" and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ diff --git a/regress/sys/netinet6/frag6/frag6_mf0middle.py b/regress/sys/netinet6/frag6/frag6_mf0middle.py index a972e0db603..20d2dcc1e2b 100644 --- a/regress/sys/netinet6/frag6/frag6_mf0middle.py +++ b/regress/sys/netinet6/frag6/frag6_mf0middle.py @@ -13,7 +13,8 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff payload="ABCDEFGHIJKLMNOP" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/ICMPv6EchoRequest(id=eid, data=payload) +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ + ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:56]) @@ -21,16 +22,16 @@ frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1)/str(packet)[48:56]) frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/str(packet)[56:64]) eth=[] for f in frag: - pkt=IPv6(src=SRC_OUT6, dst=DST_IN6)/f - eth.append(Ether(src=SRC_MAC, dst=DST_MAC)/pkt) + pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f + eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/pkt) if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and src "+DST_IN6+" and dst "+SRC_OUT6+" and icmp6") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and src "+REMOTE_ADDR6+" and dst "+LOCAL_ADDR6+" and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ diff --git a/regress/sys/netinet6/frag6/frag6_mf0short.py b/regress/sys/netinet6/frag6/frag6_mf0short.py index b44d6ea26f1..8db27c2b08d 100644 --- a/regress/sys/netinet6/frag6/frag6_mf0short.py +++ b/regress/sys/netinet6/frag6/frag6_mf0short.py @@ -13,7 +13,8 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff payload="ABCDEFGHIJKLMNOP" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/ICMPv6EchoRequest(id=eid, data=payload) +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ + ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1)/str(packet)[48:64]) @@ -21,16 +22,16 @@ frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1)/str(packet)[48:56]) frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:48]) eth=[] for f in frag: - pkt=IPv6(src=SRC_OUT6, dst=DST_IN6)/f - eth.append(Ether(src=SRC_MAC, dst=DST_MAC)/pkt) + pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f + eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/pkt) if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and src "+DST_IN6+" and dst "+SRC_OUT6+" and icmp6") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and src "+REMOTE_ADDR6+" and dst "+LOCAL_ADDR6+" and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ diff --git a/regress/sys/netinet6/frag6/frag6_mf1end.py b/regress/sys/netinet6/frag6/frag6_mf1end.py index d245cdf1960..0edd4d1c235 100644 --- a/regress/sys/netinet6/frag6/frag6_mf1end.py +++ b/regress/sys/netinet6/frag6/frag6_mf1end.py @@ -13,7 +13,8 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff payload="ABCDEFGHIJKLMNOP" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/ICMPv6EchoRequest(id=eid, data=payload) +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ + ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1)/str(packet)[48:64]) @@ -21,16 +22,16 @@ frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1, offset=2)/str(packet)[56:64]) frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:48]) eth=[] for f in frag: - pkt=IPv6(src=SRC_OUT6, dst=DST_IN6)/f - eth.append(Ether(src=SRC_MAC, dst=DST_MAC)/pkt) + pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f + eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/pkt) if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and src "+DST_IN6+" and dst "+SRC_OUT6+" and icmp6") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and src "+REMOTE_ADDR6+" and dst "+LOCAL_ADDR6+" and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ diff --git a/regress/sys/netinet6/frag6/frag6_opt.py b/regress/sys/netinet6/frag6/frag6_opt.py index 461036e10c3..1dc87ca94e5 100644 --- a/regress/sys/netinet6/frag6/frag6_opt.py +++ b/regress/sys/netinet6/frag6/frag6_opt.py @@ -12,7 +12,7 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff payload="ABCDEFGHIJKLMNOP" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/IPv6ExtHdrDestOpt( \ +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/IPv6ExtHdrDestOpt( \ options=PadN(optdata='\0'*12)/PadN(optdata='\0'*6))/ \ ICMPv6EchoRequest(id=eid, data=payload) frag=[] @@ -21,16 +21,16 @@ frag.append(IPv6ExtHdrFragment(nh=60, id=fid, m=1)/str(packet)[40:48]) frag.append(IPv6ExtHdrFragment(nh=60, id=fid, offset=1)/str(packet)[48:88]) eth=[] for f in frag: - pkt=IPv6(src=SRC_OUT6, dst=DST_IN6)/f - eth.append(Ether(src=SRC_MAC, dst=DST_MAC)/pkt) + pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f + eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/pkt) if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and src "+DST_IN6+" and dst "+SRC_OUT6+" and icmp6") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and src "+REMOTE_ADDR6+" and dst "+LOCAL_ADDR6+" and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ diff --git a/regress/sys/netinet6/frag6/frag6_overatomic.py b/regress/sys/netinet6/frag6/frag6_overatomic.py index 82985cf200b..3759db1312e 100644 --- a/regress/sys/netinet6/frag6/frag6_overatomic.py +++ b/regress/sys/netinet6/frag6/frag6_overatomic.py @@ -13,23 +13,24 @@ pid=os.getpid() eid=pid & 0xffff payload="ABCDEFGHIJKLMNOP" dummy="0123456701234567" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/ICMPv6EchoRequest(id=eid, data=payload) +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ + ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1)/dummy) frag.append(IPv6ExtHdrFragment(nh=58, id=fid)/str(packet)[40:64]) eth=[] for f in frag: - pkt=IPv6(src=SRC_OUT6, dst=DST_IN6)/f - eth.append(Ether(src=SRC_MAC, dst=DST_MAC)/pkt) + pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f + eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/pkt) if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and src "+DST_IN6+" and dst "+SRC_OUT6+" and icmp6") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and src "+REMOTE_ADDR6+" and dst "+LOCAL_ADDR6+" and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ diff --git a/regress/sys/netinet6/frag6/frag6_overdrop.py b/regress/sys/netinet6/frag6/frag6_overdrop.py index 9b8ad7b7858..ac50b177764 100644 --- a/regress/sys/netinet6/frag6/frag6_overdrop.py +++ b/regress/sys/netinet6/frag6/frag6_overdrop.py @@ -16,7 +16,8 @@ pid=os.getpid() eid=pid & 0xffff payload="ABCDEFGHIJKLMNOP" dummy="0123456701234567" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/ICMPv6EchoRequest(id=eid, data=payload) +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ + ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:56]) @@ -26,16 +27,16 @@ frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1, m=1)/str(packet)[48:56]) frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/str(packet)[56:64]) eth=[] for f in frag: - pkt=IPv6(src=SRC_OUT6, dst=DST_IN6)/f - eth.append(Ether(src=SRC_MAC, dst=DST_MAC)/pkt) + pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f + eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/pkt) if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and src "+DST_IN6+" and dst "+SRC_OUT6+" and icmp6") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and src "+REMOTE_ADDR6+" and dst "+LOCAL_ADDR6+" and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ diff --git a/regress/sys/netinet6/frag6/frag6_overhead.py b/regress/sys/netinet6/frag6/frag6_overhead.py index 49fbba27986..8a9c23c961b 100644 --- a/regress/sys/netinet6/frag6/frag6_overhead.py +++ b/regress/sys/netinet6/frag6/frag6_overhead.py @@ -15,7 +15,8 @@ pid=os.getpid() eid=pid & 0xffff payload="ABCDEFGHIJKLMNOP" dummy="0123456701234567" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/ICMPv6EchoRequest(id=eid, data=payload) +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ + ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:48]) @@ -24,16 +25,16 @@ frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1)/dummy) frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/str(packet)[56:64]) eth=[] for f in frag: - pkt=IPv6(src=SRC_OUT6, dst=DST_IN6)/f - eth.append(Ether(src=SRC_MAC, dst=DST_MAC)/pkt) + pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f + eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/pkt) if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and src "+DST_IN6+" and dst "+SRC_OUT6+" and icmp6") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and src "+REMOTE_ADDR6+" and dst "+LOCAL_ADDR6+" and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ diff --git a/regress/sys/netinet6/frag6/frag6_overhead0.py b/regress/sys/netinet6/frag6/frag6_overhead0.py index 9a6eb78353f..9e89165ed8f 100644 --- a/regress/sys/netinet6/frag6/frag6_overhead0.py +++ b/regress/sys/netinet6/frag6/frag6_overhead0.py @@ -14,7 +14,8 @@ pid=os.getpid() eid=pid & 0xffff payload="ABCDEFGHIJKLMNOP" dummy="0123456701234567" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/ICMPv6EchoRequest(id=eid, data=payload) +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ + ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:56]) @@ -22,16 +23,16 @@ frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1)/dummy) frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/str(packet)[56:64]) eth=[] for f in frag: - pkt=IPv6(src=SRC_OUT6, dst=DST_IN6)/f - eth.append(Ether(src=SRC_MAC, dst=DST_MAC)/pkt) + pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f + eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/pkt) if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and src "+DST_IN6+" and dst "+SRC_OUT6+" and icmp6") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and src "+REMOTE_ADDR6+" and dst "+LOCAL_ADDR6+" and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ diff --git a/regress/sys/netinet6/frag6/frag6_overtail.py b/regress/sys/netinet6/frag6/frag6_overtail.py index 59a1fcf889d..44991e5d043 100644 --- a/regress/sys/netinet6/frag6/frag6_overtail.py +++ b/regress/sys/netinet6/frag6/frag6_overtail.py @@ -14,7 +14,8 @@ pid=os.getpid() eid=pid & 0xffff payload="ABCDEFGHIJKLMNOP" dummy="0123456701234567" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/ICMPv6EchoRequest(id=eid, data=payload) +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ + ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/str(packet)[56:64]) @@ -22,16 +23,16 @@ frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1)/dummy) frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:56]) eth=[] for f in frag: - pkt=IPv6(src=SRC_OUT6, dst=DST_IN6)/f - eth.append(Ether(src=SRC_MAC, dst=DST_MAC)/pkt) + pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f + eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/pkt) if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and src "+DST_IN6+" and dst "+SRC_OUT6+" and icmp6") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and src "+REMOTE_ADDR6+" and dst "+LOCAL_ADDR6+" and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ diff --git a/regress/sys/netinet6/frag6/frag6_padding.py b/regress/sys/netinet6/frag6/frag6_padding.py index 997b22da4c2..4ca8c073c28 100644 --- a/regress/sys/netinet6/frag6/frag6_padding.py +++ b/regress/sys/netinet6/frag6/frag6_padding.py @@ -13,23 +13,24 @@ pid=os.getpid() eid=pid & 0xffff payload="ABCDEFGHIJKLMNOP" padding="0123" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/ICMPv6EchoRequest(id=eid, data=payload) +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ + ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:56]) frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/str(packet)[56:64]) eth=[] for f in frag: - pkt=str(IPv6(src=SRC_OUT6, dst=DST_IN6)/f) + padding - eth.append(Ether(src=SRC_MAC, dst=DST_MAC, type=0x86dd)/pkt) + pkt=str(IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f) + padding + eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC, type=0x86dd)/pkt) if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and src "+DST_IN6+" and dst "+SRC_OUT6+" and icmp6") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and src "+REMOTE_ADDR6+" and dst "+LOCAL_ADDR6+" and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ diff --git a/regress/sys/netinet6/frag6/frag6_permute.py b/regress/sys/netinet6/frag6/frag6_permute.py index b794cf32faa..f55c98220c4 100644 --- a/regress/sys/netinet6/frag6/frag6_permute.py +++ b/regress/sys/netinet6/frag6/frag6_permute.py @@ -23,7 +23,7 @@ payload="ABCDEFGHIJKLMNOP" for p in permute: pid += 1 eid=pid & 0xffff - packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/ \ + packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff @@ -35,16 +35,16 @@ for p in permute: str(packet)[56:64]) eth=[] for i in range(3): - pkt=IPv6(src=SRC_OUT6, dst=DST_IN6)/frag[p[i]] - eth.append(Ether(src=SRC_MAC, dst=DST_MAC)/pkt) + pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/frag[p[i]] + eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/pkt) if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) - ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and src "+DST_IN6+" and dst "+SRC_OUT6+" and icmp6") + ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and src "+REMOTE_ADDR6+" and dst "+LOCAL_ADDR6+" and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ diff --git a/regress/sys/netinet6/frag6/frag6_refrag.py b/regress/sys/netinet6/frag6/frag6_refrag.py index cb1d3f42fea..4c95c17f6ca 100644 --- a/regress/sys/netinet6/frag6/frag6_refrag.py +++ b/regress/sys/netinet6/frag6/frag6_refrag.py @@ -15,7 +15,8 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff payload=100 * "ABCDEFGHIJKLMNOP" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/ICMPv6EchoRequest(id=eid, data=payload) +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ + ICMPv6EchoRequest(id=eid, data=payload) request_cksum=ICMPv6Unknown(str(packet.payload)).cksum print "request cksum=%#x" % (request_cksum) frag=[] @@ -31,16 +32,16 @@ frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=offset)/ str(packet)[40+(8*offset):]) eth=[] for f in frag: - pkt=IPv6(src=SRC_OUT6, dst=DST_IN6)/f - eth.append(Ether(src=SRC_MAC, dst=DST_MAC)/pkt) + pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f + eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/pkt) if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and src "+DST_IN6+" and dst "+SRC_OUT6+" and proto ipv6-frag") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and src "+REMOTE_ADDR6+" and dst "+LOCAL_ADDR6+" and proto ipv6-frag") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'Fragment Header' and \ diff --git a/regress/sys/netinet6/frag6/frag6_shortatomic.py b/regress/sys/netinet6/frag6/frag6_shortatomic.py index 2a209b4a70e..7df4e1e35ab 100644 --- a/regress/sys/netinet6/frag6/frag6_shortatomic.py +++ b/regress/sys/netinet6/frag6/frag6_shortatomic.py @@ -13,7 +13,7 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff payload="ABCDEFGHIJKLMNOP" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/IPv6ExtHdrDestOpt()/ \ +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/IPv6ExtHdrDestOpt()/ \ ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff @@ -22,16 +22,16 @@ frag.append(IPv6ExtHdrFragment(nh=60, id=fid)/str(packet)[40:48]) frag.append(IPv6ExtHdrFragment(nh=60, id=fid, offset=3)/str(packet)[64:72]) eth=[] for f in frag: - pkt=IPv6(src=SRC_OUT6, dst=DST_IN6)/f - eth.append(Ether(src=SRC_MAC, dst=DST_MAC)/pkt) + pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f + eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/pkt) if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and src "+DST_IN6+" and dst "+SRC_OUT6+" and icmp6") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and src "+REMOTE_ADDR6+" and dst "+LOCAL_ADDR6+" and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ diff --git a/regress/sys/netinet6/frag6/frag6_timeout.py b/regress/sys/netinet6/frag6/frag6_timeout.py index 85c7d668440..63488b16182 100644 --- a/regress/sys/netinet6/frag6/frag6_timeout.py +++ b/regress/sys/netinet6/frag6/frag6_timeout.py @@ -16,7 +16,8 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff payload="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcd" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/ICMPv6EchoRequest(id=eid, data=payload) +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ + ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:48]) @@ -27,18 +28,18 @@ frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=4, m=1)/str(packet)[72:80]) frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=5)/str(packet)[80:88]) eth=[] for f in frag: - pkt=IPv6(src=SRC_OUT6, dst=DST_IN6)/f - eth.append(Ether(src=SRC_MAC, dst=DST_MAC)/pkt) + pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f + eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/pkt) if os.fork() == 0: time.sleep(1) for e in eth: - sendp(e, iface=SRC_IF) + sendp(e, iface=LOCAL_IF) time.sleep(15) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=90, filter= - "ip6 and src "+DST_IN6+" and dst "+SRC_OUT6+" and icmp6") +ans=sniff(iface=LOCAL_IF, timeout=90, filter= + "ip6 and src "+REMOTE_ADDR6+" and dst "+LOCAL_ADDR6+" and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ diff --git a/regress/sys/netinet6/frag6/frag6_udpatomic.py b/regress/sys/netinet6/frag6/frag6_udpatomic.py index 12d6ee9c304..c4e3879dcad 100644 --- a/regress/sys/netinet6/frag6/frag6_udpatomic.py +++ b/regress/sys/netinet6/frag6/frag6_udpatomic.py @@ -14,22 +14,23 @@ uport=pid & 0xffff if uport < 1024 or uport == 2049: uport+=1024 payload="ABCDEFGHIJKLMNOP" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/UDP(sport=uport, dport=7)/payload +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ + UDP(sport=uport, dport=7)/payload frag=[] fid=pid & 0xffffffff frag.append(IPv6ExtHdrFragment(nh=17, id=fid)/str(packet)[40:64]) eth=[] for f in frag: - pkt=IPv6(src=SRC_OUT6, dst=DST_IN6)/f - eth.append(Ether(src=SRC_MAC, dst=DST_MAC)/pkt) + pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f + eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/pkt) if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and src "+DST_IN6+" and dst "+SRC_OUT6+" and udp") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and src "+REMOTE_ADDR6+" and dst "+LOCAL_ADDR6+" and udp") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'UDP' and \ diff --git a/regress/sys/netinet6/frag6/frag6_udpheader.py b/regress/sys/netinet6/frag6/frag6_udpheader.py index 02f17a01215..f56e1a669d5 100644 --- a/regress/sys/netinet6/frag6/frag6_udpheader.py +++ b/regress/sys/netinet6/frag6/frag6_udpheader.py @@ -15,23 +15,24 @@ uport=pid & 0xffff if uport < 1024 or uport == 2049: uport+=1024 payload="ABCDEFGHIJKLMNOP" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/UDP(sport=uport, dport=7)/payload +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ + UDP(sport=uport, dport=7)/payload frag=[] fid=pid & 0xffffffff frag.append(IPv6ExtHdrFragment(nh=17, id=fid, m=1)/str(packet)[40:48]) frag.append(IPv6ExtHdrFragment(nh=17, id=fid, offset=1)/str(packet)[48:64]) eth=[] for f in frag: - pkt=IPv6(src=SRC_OUT6, dst=DST_IN6)/f - eth.append(Ether(src=SRC_MAC, dst=DST_MAC)/pkt) + pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f + eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/pkt) if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and src "+DST_IN6+" and dst "+SRC_OUT6+" and udp") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and src "+REMOTE_ADDR6+" and dst "+LOCAL_ADDR6+" and udp") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'UDP' and \ diff --git a/regress/sys/netinet6/frag6/frag6_udppayload.py b/regress/sys/netinet6/frag6/frag6_udppayload.py index e7835c847ab..cc4a995f549 100644 --- a/regress/sys/netinet6/frag6/frag6_udppayload.py +++ b/regress/sys/netinet6/frag6/frag6_udppayload.py @@ -15,23 +15,24 @@ uport=pid & 0xffff if uport < 1024 or uport == 2049: uport+=1024 payload="ABCDEFGHIJKLMNOP" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/UDP(sport=uport, dport=7)/payload +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ + UDP(sport=uport, dport=7)/payload frag=[] fid=pid & 0xffffffff frag.append(IPv6ExtHdrFragment(nh=17, id=fid, m=1)/str(packet)[40:56]) frag.append(IPv6ExtHdrFragment(nh=17, id=fid, offset=2)/str(packet)[56:64]) eth=[] for f in frag: - pkt=IPv6(src=SRC_OUT6, dst=DST_IN6)/f - eth.append(Ether(src=SRC_MAC, dst=DST_MAC)/pkt) + pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f + eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/pkt) if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and src "+DST_IN6+" and dst "+SRC_OUT6+" and udp") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and src "+REMOTE_ADDR6+" and dst "+LOCAL_ADDR6+" and udp") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'UDP' and \ diff --git a/regress/sys/netinet6/frag6/frag6_zerofirst.py b/regress/sys/netinet6/frag6/frag6_zerofirst.py index f686981c52e..b739ae33aa6 100644 --- a/regress/sys/netinet6/frag6/frag6_zerofirst.py +++ b/regress/sys/netinet6/frag6/frag6_zerofirst.py @@ -13,7 +13,8 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff payload="ABCDEFGHIJKLMNOP" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/ICMPv6EchoRequest(id=eid, data=payload) +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ + ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff frag.append(IPv6ExtHdrFragment(nh=59, id=fid, m=1)) @@ -21,16 +22,16 @@ frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:56]) frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/str(packet)[56:64]) eth=[] for f in frag: - pkt=IPv6(src=SRC_OUT6, dst=DST_IN6)/f - eth.append(Ether(src=SRC_MAC, dst=DST_MAC)/pkt) + pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f + eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/pkt) if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and src "+DST_IN6+" and dst "+SRC_OUT6+" and icmp6") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and src "+REMOTE_ADDR6+" and dst "+LOCAL_ADDR6+" and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ diff --git a/regress/sys/netinet6/frag6/frag6_zerosecond.py b/regress/sys/netinet6/frag6/frag6_zerosecond.py index 62fb4473ee4..63b2d4ebd6b 100644 --- a/regress/sys/netinet6/frag6/frag6_zerosecond.py +++ b/regress/sys/netinet6/frag6/frag6_zerosecond.py @@ -13,7 +13,8 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff payload="ABCDEFGHIJKLMNOP" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/ICMPv6EchoRequest(id=eid, data=payload) +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ + ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:56]) @@ -21,16 +22,16 @@ frag.append(IPv6ExtHdrFragment(nh=59, id=fid, m=1)) frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/str(packet)[56:64]) eth=[] for f in frag: - pkt=IPv6(src=SRC_OUT6, dst=DST_IN6)/f - eth.append(Ether(src=SRC_MAC, dst=DST_MAC)/pkt) + pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f + eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/pkt) if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and src "+DST_IN6+" and dst "+SRC_OUT6+" and icmp6") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and src "+REMOTE_ADDR6+" and dst "+LOCAL_ADDR6+" and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ diff --git a/regress/sys/netinet6/nd6/LICENSE b/regress/sys/netinet6/nd6/LICENSE new file mode 100644 index 00000000000..8132b495a44 --- /dev/null +++ b/regress/sys/netinet6/nd6/LICENSE @@ -0,0 +1,13 @@ +# Copyright (c) 2012-2017 Alexander Bluhm <bluhm@openbsd.org> +# +# Permission to use, copy, modify, and distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/regress/sys/netinet6/nd6/Makefile b/regress/sys/netinet6/nd6/Makefile index 971832303a6..22b232876eb 100644 --- a/regress/sys/netinet6/nd6/Makefile +++ b/regress/sys/netinet6/nd6/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.5 2016/10/19 14:31:19 tb Exp $ +# $OpenBSD: Makefile,v 1.6 2017/03/01 00:05:21 bluhm Exp $ # The following ports must be installed: # @@ -9,36 +9,34 @@ .if ! (make(clean) || make(cleandir) || make(obj)) # Check wether all required python packages are installed. If some # are missing print a warning and skip the tests, but do not fail. -PYTHON_IMPORT != python2.7 -c 'from scapy.all import *' 2>&1 || true +PYTHON_IMPORT !!= python2.7 -c 'from scapy.all import *' 2>&1 || true .endif + .if ! empty(PYTHON_IMPORT) regress: @echo '${PYTHON_IMPORT}' - @echo install python and the scapy module for additional tests + @echo Install python and the scapy module for additional tests. @echo SKIPPED .endif # This test needs a manual setup of two machines -# Set up machines: SRC DST -# SRC is the machine where this makefile is running. -# DST is running OpenBSD with pf to test the neighbor discovery states. -# -# +---+ 1 +---+ -# |SRC| ----> |DST| -# +---+ +---+ -# out in +# Set up machines: LOCAL REMOTE +# LOCAL is the machine where this makefile is running. +# REMOTE is running OpenBSD with pf to test the neighbor discovery states. -# Configure Addresses on the machines. +# Configure addresses on the machines. # Adapt interface and addresse variables to your local setup. -# -SRC_IF ?= -SRC_MAC ?= -DST_MAC ?= -SRC_OUT6 ?= -DST_IN6 ?= +LOCAL_IF ?= em1 +LOCAL_MAC ?= 00:1b:21:0e:6e:8e +REMOTE_MAC ?= 00:04:23:b0:68:8e + +LOCAL_ADDR6 ?= fdd7:e83e:66bc:81::21 +REMOTE_ADDR6 ?= fdd7:e83e:66bc:81::22 -# pf rules on DST should look like this: +REMOTE_SSH ?= + +# pf rules on REMOTE should look like this: # # block log # pass inet6 proto icmp6 icmp6-type echoreq keep state @@ -62,12 +60,12 @@ DST_IN6 ?= # - request NS from interface address to target unicast # - response NA from interface address to source of NS -.if empty (SRC_IF) || empty (SRC_MAC) || empty (DST_MAC) || \ - empty (SRC_OUT6) || empty (DST_IN6) +.if empty (LOCAL_IF) || empty (LOCAL_MAC) || empty (REMOTE_MAC) || \ + empty (LOCAL_ADDR6) || empty (REMOTE_ADDR6) regress: - @echo this tests needs a remote machine to operate on - @echo SRC_IF SRC_MAC DST_MAC SRC_OUT6 DST_IN6 are empty - @echo fill out these variables for additional tests + @echo This tests needs a remote machine to operate on. + @echo LOCAL_IF LOCAL_MAC REMOTE_MAC LOCAL_ADDR6 REMOTE_ADDR6 + @echo Fill out these variables for additional tests. @echo SKIPPED .endif @@ -76,10 +74,10 @@ depend: addr.py # Create python include file containing the addresses. addr.py: Makefile rm -f $@ $@.tmp - echo 'SRC_IF = "${SRC_IF}"' >>$@.tmp - echo 'SRC_MAC = "${SRC_MAC}"' >>$@.tmp - echo 'DST_MAC = "${DST_MAC}"' >>$@.tmp -.for var in SRC_OUT DST_IN + echo 'LOCAL_IF = "${LOCAL_IF}"' >>$@.tmp + echo 'LOCAL_MAC = "${LOCAL_MAC}"' >>$@.tmp + echo 'REMOTE_MAC = "${REMOTE_MAC}"' >>$@.tmp +.for var in LOCAL_ADDR REMOTE_ADDR echo '${var} = "${${var}}"' >>$@.tmp echo '${var}6 = "${${var}6}"' >>$@.tmp .endfor @@ -96,45 +94,49 @@ PYTHON = PYTHONPATH=${.OBJDIR} python2.7 ${.CURDIR}/ # Clear neighbor cache and ping all addresses. This ensures that # the ip addresses are configured and all routing table are set up # to allow bidirectional packet flow. -TARGETS += ping6 run-regress-ping6: @echo '\n======== $@ ========' ${SUDO} ndp -c -.for ip in SRC_OUT DST_IN +.for ip in LOCAL_ADDR REMOTE_ADDR @echo Check ping6 ${ip}6: ping6 -n -c 1 ${${ip}6} .endfor -# Send hand-crafted duplicate address detection neighbor solicitation packet -TARGETS += nd6_dad -run-regress-nd6_dad: addr.py - @echo '\n======== $@ ========' - @echo Check duplicate address detection - ${SUDO} ${PYTHON}nd6_dad.py +ND6_SCRIPTS !!= cd ${.CURDIR} && ls -1 nd6*.py -# Send hand-crafted address resolution neighbor solicitation packet -TARGETS += nd6_ar -run-regress-nd6_ar: addr.py +.for s in ${ND6_SCRIPTS} +run-regress-${s}: addr.py @echo '\n======== $@ ========' - @echo Check address resolution - ${SUDO} ${PYTHON}nd6_ar.py + ${SUDO} ${PYTHON}${s} +.endfor -# Send hand-crafted unsolicited neighbor advertisement packet -TARGETS += nd6_una -run-regress-nd6_una: addr.py - @echo '\n======== $@ ========' - @echo Check unsolicited neighbor advertisement - ${SUDO} ${PYTHON}nd6_una.py +REGRESS_TARGETS = run-regress-ping6 ${ND6_SCRIPTS:S/^/run-regress-/} -# Send hand-crafted neighbor unreachability detection solicitation packet -TARGETS += nd6_nud -run-regress-nd6_nud: addr.py - @echo '\n======== $@ ========' - @echo Check neighbor unreachability detection - ${SUDO} ${PYTHON}nd6_nud.py +CLEANFILES += addr.py *.pyc *.log -REGRESS_TARGETS = ${TARGETS:S/^/run-regress-/} +.PHONY: check-setup check-setup-local check-setup-remote -CLEANFILES += addr.py *.pyc *.log +# Check wether the address, route and remote setup is correct +check-setup: check-setup-local check-setup-remote + +check-setup-local: + @echo '\n======== $@ ========' + ping6 -n -c 1 ${LOCAL_ADDR6} # LOCAL_ADDR6 + route -n get -inet6 ${LOCAL_ADDR6} |\ + grep -q 'flags: .*LOCAL' # LOCAL_ADDR6 + ping6 -n -c 1 ${REMOTE_ADDR6} # REMOTE_ADDR6 + route -n get -inet6 ${REMOTE_ADDR6} |\ + grep -q 'interface: ${LOCAL_IF}$$' # REMOTE_ADDR6 LOCAL_IF + ndp -n ${REMOTE_ADDR6} |\ + grep -q ' ${REMOTE_MAC} ' # REMOTE_ADDR6 REMOTE_MAC + +check-setup-remote: + @echo '\n======== $@ ========' + ssh ${REMOTE_SSH} ping6 -n -c 1 ${REMOTE_ADDR6} # REMOTE_ADDR6 + ssh ${REMOTE_SSH} route -n get -inet6 ${REMOTE_ADDR6} |\ + grep -q 'flags: .*LOCAL' # REMOTE_ADDR6 + ssh ${REMOTE_SSH} ping6 -n -c 1 ${LOCAL_ADDR6} # LOCAL_ADDR6 + ssh ${REMOTE_SSH} ndp -n ${LOCAL_ADDR6} |\ + grep -q ' ${LOCAL_MAC} ' # LOCAL_ADDR6 LOCAL_MAC .include <bsd.regress.mk> diff --git a/regress/sys/netinet6/nd6/nd6_ar.py b/regress/sys/netinet6/nd6/nd6_ar.py index 3ccf6ef49de..37fe440ddf2 100644 --- a/regress/sys/netinet6/nd6/nd6_ar.py +++ b/regress/sys/netinet6/nd6/nd6_ar.py @@ -2,6 +2,8 @@ # send Address Resolution neighbor solicitation # expect an neighbor advertisement answer and check it +print "send address resolution neighbor solicitation packet" + import os from addr import * from scapy.all import * @@ -24,25 +26,25 @@ def nsmamac(a): def lla(m): return "fe80::"+in6_mactoifaceid(m) -ip=IPv6(src=SRC_OUT6, dst=nsma(DST_IN6))/ICMPv6ND_NS(tgt=DST_IN6) -eth=Ether(src=SRC_MAC, dst=nsmamac(DST_IN6))/ip +ip=IPv6(src=LOCAL_ADDR6, dst=nsma(REMOTE_ADDR6))/ICMPv6ND_NS(tgt=REMOTE_ADDR6) +eth=Ether(src=LOCAL_MAC, dst=nsmamac(REMOTE_ADDR6))/ip if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and src "+DST_IN6+" and dst "+SRC_OUT6+" and icmp6") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and src "+REMOTE_ADDR6+" and dst "+LOCAL_ADDR6+" and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Neighbor Advertisement': tgt=a.payload.payload.tgt print "target=%s" % (tgt) - if tgt == DST_IN6: + if tgt == REMOTE_ADDR6: exit(0) - print "TARGET!=%s" % (DST_IN6) + print "TARGET!=%s" % (REMOTE_ADDR6) exit(1) print "NO NEIGHBOR ADVERTISEMENT" exit(2) diff --git a/regress/sys/netinet6/nd6/nd6_dad.py b/regress/sys/netinet6/nd6/nd6_dad.py index ace040d8153..c2d9e80daed 100644 --- a/regress/sys/netinet6/nd6/nd6_dad.py +++ b/regress/sys/netinet6/nd6/nd6_dad.py @@ -2,6 +2,8 @@ # send Duplicate Address Detection neighbor solicitation # expect an neighbor advertisement answer and check it +print "send duplicate address detection neighbor solicitation packet" + import os from addr import * from scapy.all import * @@ -24,25 +26,25 @@ def nsmamac(a): def lla(m): return "fe80::"+in6_mactoifaceid(m) -ip=IPv6(src="::", dst=nsma(DST_IN6))/ICMPv6ND_NS(tgt=DST_IN6) -eth=Ether(src=SRC_MAC, dst=nsmamac(DST_IN6))/ip +ip=IPv6(src="::", dst=nsma(REMOTE_ADDR6))/ICMPv6ND_NS(tgt=REMOTE_ADDR6) +eth=Ether(src=LOCAL_MAC, dst=nsmamac(REMOTE_ADDR6))/ip if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and src "+lla(DST_MAC)+" and dst ff02::1 and icmp6") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and src "+lla(REMOTE_MAC)+" and dst ff02::1 and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Neighbor Advertisement': tgt=a.payload.payload.tgt print "target=%s" % (tgt) - if tgt == DST_IN6: + if tgt == REMOTE_ADDR6: exit(0) - print "TARGET!=%s" % (DST_IN6) + print "TARGET!=%s" % (REMOTE_ADDR6) exit(1) print "NO NEIGHBOR ADVERTISEMENT" exit(2) diff --git a/regress/sys/netinet6/nd6/nd6_nud.py b/regress/sys/netinet6/nd6/nd6_nud.py index 4fd21825c0c..b42d13f15cf 100644 --- a/regress/sys/netinet6/nd6/nd6_nud.py +++ b/regress/sys/netinet6/nd6/nd6_nud.py @@ -2,6 +2,8 @@ # send Neighbor Unreachability Detection neighbor solicitation # expect an neighbor advertisement answer and check it +print "send neighbor unreachability detection solicitation packet" + import os from addr import * from scapy.all import * @@ -24,25 +26,25 @@ def nsmamac(a): def lla(m): return "fe80::"+in6_mactoifaceid(m) -ip=IPv6(src=SRC_OUT6, dst=DST_IN6)/ICMPv6ND_NS(tgt=DST_IN6) -eth=Ether(src=SRC_MAC, dst=DST_MAC)/ip +ip=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ICMPv6ND_NS(tgt=REMOTE_ADDR6) +eth=Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/ip if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and src "+DST_IN6+" and dst "+SRC_OUT6+" and icmp6") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and src "+REMOTE_ADDR6+" and dst "+LOCAL_ADDR6+" and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Neighbor Advertisement': tgt=a.payload.payload.tgt print "target=%s" % (tgt) - if tgt == DST_IN6: + if tgt == REMOTE_ADDR6: exit(0) - print "TARGET!=%s" % (DST_IN6) + print "TARGET!=%s" % (REMOTE_ADDR6) exit(1) print "NO NEIGHBOR ADVERTISEMENT" exit(2) diff --git a/regress/sys/netinet6/nd6/nd6_una.py b/regress/sys/netinet6/nd6/nd6_una.py index a190a07c1ab..93888b6bc74 100644 --- a/regress/sys/netinet6/nd6/nd6_una.py +++ b/regress/sys/netinet6/nd6/nd6_una.py @@ -1,6 +1,8 @@ #!/usr/local/bin/python2.7 # send Unsolicited Neighbor Advertisement +print "send unsolicited neighbor advertisement packet" + import os from addr import * from scapy.all import * @@ -23,10 +25,10 @@ def nsmamac(a): def lla(m): return "fe80::"+in6_mactoifaceid(m) -ip=IPv6(src=lla(SRC_MAC), dst="ff02::1")/ICMPv6ND_NA(tgt=SRC_OUT6) -eth=Ether(src=SRC_MAC, dst=nsmac("ff02::1"))/ip +ip=IPv6(src=lla(LOCAL_MAC), dst="ff02::1")/ICMPv6ND_NA(tgt=LOCAL_ADDR6) +eth=Ether(src=LOCAL_MAC, dst=nsmac("ff02::1"))/ip -sendp(eth, iface=SRC_IF) +sendp(eth, iface=LOCAL_IF) time.sleep(1) exit(0) diff --git a/regress/sys/netinet6/rh0/Makefile b/regress/sys/netinet6/rh0/Makefile index 86181628e07..5da51fa30c4 100644 --- a/regress/sys/netinet6/rh0/Makefile +++ b/regress/sys/netinet6/rh0/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.8 2017/02/28 16:14:35 bluhm Exp $ +# $OpenBSD: Makefile,v 1.9 2017/03/01 00:05:21 bluhm Exp $ # The following ports must be installed: # @@ -13,6 +13,8 @@ PYTHON_IMPORT !!= python2.7 -c 'from scapy.all import *' 2>&1 || true .endif .if ! empty(PYTHON_IMPORT) +.BEGIN: + @true regress: @echo '${PYTHON_IMPORT}' @echo Install python and the scapy module for additional tests. @@ -20,37 +22,38 @@ regress: .endif # This test needs a manual setup of two machines -# Set up machines: SRC DST -# SRC is the machine where this makefile is running. -# DST is running OpenBSD with pf disabled to test the IPv6 stack. -# SRT source routed host, no packets reach this host, -# it represents just bunch of addresses -# -# +---+ 1 +---+ +---+ -# |SRC| ----> |DST| |SRT| -# +---+ +---+ +---+ -# out in out in out +# Set up machines: LOCAL REMOTE +# LOCAL is the machine where this makefile is running. +# REMOTE is running OpenBSD, pf gets disabled to test the IPv6 stack. +# OTHER is an address on REMOTE, but configured on another interface. +# OTHER_FAKE source routed host, no packets reach this host, +# it represents just bunch of addresses in the OTHER net. # Configure Addresses on the machines. # Adapt interface and address variables to your local setup. -# -SRC_IF ?= -SRC_MAC ?= -DST_MAC ?= - -SRC_OUT6 ?= -DST_IN6 ?= -DST_OUT6 ?= -SRT_IN6 ?= -SRT_OUT6 ?= - -.if empty (SRC_IF) || empty (SRC_MAC) || empty (DST_MAC) || \ - empty (SRC_OUT6) || empty (DST_IN6) || empty (DST_OUT6) || \ - empty (SRT_IN6) || empty (SRT_OUT6) || empty (REMOTE_SSH) + +LOCAL_IF ?= em1 +LOCAL_MAC ?= 00:1b:21:0e:6e:8e +REMOTE_MAC ?= 00:04:23:b0:68:8e + +LOCAL_ADDR6 ?= fdd7:e83e:66bc:81::21 +REMOTE_ADDR6 ?= fdd7:e83e:66bc:81::22 +OTHER_ADDR6 ?= fdd7:e83e:66bc:82::22 +OTHER_FAKE1_ADDR6 ?= fdd7:e83e:66bc:82::dead +OTHER_FAKE2_ADDR6 ?= fdd7:e83e:66bc:82::beef + +REMOTE_SSH ?= + +.if empty (LOCAL_IF) || empty (LOCAL_MAC) || empty (REMOTE_MAC) || \ + empty (LOCAL_ADDR6) || empty (REMOTE_ADDR6) || empty(OTHER_ADDR6) || \ + empty (OTHER_FAKE1_ADDR6) || empty (OTHER_FAKE2_ADDR6) || \ + empty (REMOTE_SSH) +.BEGIN: + @true regress: @echo This tests needs a remote machine to operate on. - @echo SRC_IF SRC_MAC DST_MAC SRC_OUT6 DST_IN6 DST_OUT6 - @echo SRT_IN6 SRT_OUT6 REMOTE_SSH are empty. + @echo LOCAL_IF LOCAL_MAC REMOTE_MAC LOCAL_ADDR6 REMOTE_ADDR6 + @echo OTHER_ADDR6 OTHER_FAKE1_ADDR6 OTHER_FAKE2_ADDR6 REMOTE_SSH @echo Fill out these variables for additional tests. @echo SKIPPED .endif @@ -69,10 +72,10 @@ depend: addr.py # Create python include file containing the addresses. addr.py: Makefile rm -f $@ $@.tmp - echo 'SRC_IF = "${SRC_IF}"' >>$@.tmp - echo 'SRC_MAC = "${SRC_MAC}"' >>$@.tmp - echo 'DST_MAC = "${DST_MAC}"' >>$@.tmp -.for var in SRC_OUT DST_IN DST_OUT SRT_IN SRT_OUT + echo 'LOCAL_IF = "${LOCAL_IF}"' >>$@.tmp + echo 'LOCAL_MAC = "${LOCAL_MAC}"' >>$@.tmp + echo 'REMOTE_MAC = "${REMOTE_MAC}"' >>$@.tmp +.for var in LOCAL_ADDR REMOTE_ADDR OTHER_FAKE1_ADDR OTHER_FAKE2_ADDR echo '${var}6 = "${${var}6}"' >>$@.tmp .endfor mv $@.tmp $@ @@ -115,18 +118,40 @@ REGRESS_TARGETS += stamp-pf CLEANFILES += addr.py *.pyc *.log stamp-* -.PHONY: check-setup +.PHONY: check-setup check-setup-local check-setup-remote # Check wether the address, route and remote setup is correct -check-setup: +check-setup: check-setup-local check-setup-remote + +check-setup-local: @echo '\n======== $@ ========' - route -n get -inet6 ${SRC_OUT6} | grep -q 'flags: .*LOCAL' - ping6 -n -c 1 ${SRC_OUT6} - route -n get -inet6 ${DST_IN6} | grep -q 'interface: ${SRC_IF}$$' - ping6 -n -c 1 ${DST_IN6} - route -n get -inet6 ${DST_OUT6} | grep -q 'gateway: ${DST_IN6}$$' - ping6 -n -c 1 ${DST_OUT6} - route -n get -inet6 ${SRT_IN6} | grep -q 'gateway: ${DST_IN6}$$' - ndp -n ${DST_IN6} | grep -q ' ${DST_MAC} ' + ping6 -n -c 1 ${LOCAL_ADDR6} # LOCAL_ADDR6 + route -n get -inet6 ${LOCAL_ADDR6} |\ + grep -q 'flags: .*LOCAL' # LOCAL_ADDR6 + ping6 -n -c 1 ${REMOTE_ADDR6} # REMOTE_ADDR6 + route -n get -inet6 ${REMOTE_ADDR6} |\ + grep -q 'interface: ${LOCAL_IF}$$' # REMOTE_ADDR6 LOCAL_IF +.for ip in OTHER_ADDR6 OTHER_FAKE1_ADDR6 OTHER_FAKE2_ADDR6 + route -n get -inet6 ${${ip}} |\ + grep -q 'gateway: ${REMOTE_ADDR6}$$' # ${ip} REMOTE_ADDR6 +.endfor + ndp -n ${REMOTE_ADDR6} |\ + grep -q ' ${REMOTE_MAC} ' # REMOTE_ADDR6 REMOTE_MAC + +check-setup-remote: + @echo '\n======== $@ ========' + ssh ${REMOTE_SSH} ping6 -n -c 1 ${REMOTE_ADDR6} # REMOTE_ADDR6 + ssh ${REMOTE_SSH} route -n get -inet6 ${REMOTE_ADDR6} |\ + grep -q 'flags: .*LOCAL' # REMOTE_ADDR6 + ssh ${REMOTE_SSH} ping6 -n -c 1 ${LOCAL_ADDR6} # LOCAL_ADDR6 + ssh ${REMOTE_SSH} ping6 -n -c 1 ${OTHER_ADDR6} # OTHER_ADDR6 + ssh ${REMOTE_SSH} route -n get -inet6 ${OTHER_ADDR6} |\ + grep -q 'flags: .*LOCAL' # OTHER_ADDR6 +.for ip in OTHER_FAKE1_ADDR6 OTHER_FAKE2_ADDR6 + ssh ${REMOTE_SSH} route -n get -inet6 ${${ip}} |\ + grep -q 'if address: ${OTHER_ADDR6}$$' # ${ip} OTHER_ADDR6 +.endfor + ssh ${REMOTE_SSH} ndp -n ${LOCAL_ADDR6} |\ + grep -q ' ${LOCAL_MAC} ' # LOCAL_ADDR6 LOCAL_MAC .include <bsd.regress.mk> diff --git a/regress/sys/netinet6/rh0/rh0_empty.py b/regress/sys/netinet6/rh0/rh0_empty.py index e087131a717..b75efbba722 100644 --- a/regress/sys/netinet6/rh0/rh0_empty.py +++ b/regress/sys/netinet6/rh0/rh0_empty.py @@ -11,18 +11,18 @@ from scapy.all import * eid=os.getpid() & 0xffff payload="ABCDEFGHIJKLMNOP" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/\ +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/\ IPv6ExtHdrRouting(addresses=[])/\ ICMPv6EchoRequest(id=eid, data=payload) -eth=Ether(src=SRC_MAC, dst=DST_MAC)/packet +eth=Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/packet if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and dst "+SRC_OUT6+" and icmp6") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and dst "+LOCAL_ADDR6+" and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ diff --git a/regress/sys/netinet6/rh0/rh0_final.py b/regress/sys/netinet6/rh0/rh0_final.py index 7bb179f8ff3..3347a238f79 100644 --- a/regress/sys/netinet6/rh0/rh0_final.py +++ b/regress/sys/netinet6/rh0/rh0_final.py @@ -11,18 +11,19 @@ from scapy.all import * eid=os.getpid() & 0xffff payload="ABCDEFGHIJKLMNOP" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/\ - IPv6ExtHdrRouting(addresses=[SRT_IN6, SRT_OUT6], segleft=0)/\ +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/\ + IPv6ExtHdrRouting(addresses=[OTHER_FAKE1_ADDR6, OTHER_FAKE2_ADDR6], \ + segleft=0)/\ ICMPv6EchoRequest(id=eid, data=payload) -eth=Ether(src=SRC_MAC, dst=DST_MAC)/packet +eth=Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/packet if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and dst "+SRC_OUT6+" and icmp6") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and dst "+LOCAL_ADDR6+" and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ diff --git a/regress/sys/netinet6/rh0/rh0_frag2.py b/regress/sys/netinet6/rh0/rh0_frag2.py index 7054c3fe4a3..266e47a90dd 100644 --- a/regress/sys/netinet6/rh0/rh0_frag2.py +++ b/regress/sys/netinet6/rh0/rh0_frag2.py @@ -13,7 +13,7 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff payload="ABCDEFGHIJKLMNOP" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/\ +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/\ IPv6ExtHdrDestOpt()/\ IPv6ExtHdrRouting(addresses=[])/\ ICMPv6EchoRequest(id=eid, data=payload) @@ -23,16 +23,16 @@ frag.append(IPv6ExtHdrFragment(nh=60, id=fid, m=1)/str(packet)[40:48]) frag.append(IPv6ExtHdrFragment(nh=60, id=fid, offset=1)/str(packet)[48:80]) eth=[] for f in frag: - pkt=IPv6(src=SRC_OUT6, dst=DST_IN6)/f - eth.append(Ether(src=SRC_MAC, dst=DST_MAC)/pkt) + pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f + eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/pkt) if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and dst "+SRC_OUT6+" and icmp6") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and dst "+LOCAL_ADDR6+" and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ diff --git a/regress/sys/netinet6/rh0/rh0_frag_empty.py b/regress/sys/netinet6/rh0/rh0_frag_empty.py index 03eb969ee21..779522c44c5 100644 --- a/regress/sys/netinet6/rh0/rh0_frag_empty.py +++ b/regress/sys/netinet6/rh0/rh0_frag_empty.py @@ -14,19 +14,19 @@ pid=os.getpid() eid=pid & 0xffff fid=pid & 0xffffffff payload="ABCDEFGHIJKLMNOP" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/\ +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/\ IPv6ExtHdrFragment(id=fid)/\ IPv6ExtHdrRouting(addresses=[])/\ ICMPv6EchoRequest(id=eid, data=payload) -eth=Ether(src=SRC_MAC, dst=DST_MAC)/packet +eth=Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/packet if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and dst "+SRC_OUT6+" and icmp6") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and dst "+LOCAL_ADDR6+" and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ diff --git a/regress/sys/netinet6/rh0/rh0_frag_final.py b/regress/sys/netinet6/rh0/rh0_frag_final.py index 62ae301f3b8..e8bf0c9852c 100644 --- a/regress/sys/netinet6/rh0/rh0_frag_final.py +++ b/regress/sys/netinet6/rh0/rh0_frag_final.py @@ -14,19 +14,20 @@ pid=os.getpid() eid=pid & 0xffff fid=pid & 0xffffffff payload="ABCDEFGHIJKLMNOP" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/\ +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/\ IPv6ExtHdrFragment(id=fid)/\ - IPv6ExtHdrRouting(addresses=[SRT_IN6, SRT_OUT6], segleft=0)/\ + IPv6ExtHdrRouting(addresses=[OTHER_FAKE1_ADDR6, OTHER_FAKE2_ADDR6], \ + segleft=0)/\ ICMPv6EchoRequest(id=eid, data=payload) -eth=Ether(src=SRC_MAC, dst=DST_MAC)/packet +eth=Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/packet if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and dst "+SRC_OUT6+" and icmp6") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and dst "+LOCAL_ADDR6+" and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ diff --git a/regress/sys/netinet6/rh0/rh0_frag_route.py b/regress/sys/netinet6/rh0/rh0_frag_route.py index 3b55ae49fd9..de9bc9a8f8d 100644 --- a/regress/sys/netinet6/rh0/rh0_frag_route.py +++ b/regress/sys/netinet6/rh0/rh0_frag_route.py @@ -14,19 +14,20 @@ pid=os.getpid() eid=pid & 0xffff fid=pid & 0xffffffff payload="ABCDEFGHIJKLMNOP" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/\ +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/\ IPv6ExtHdrFragment(id=fid)/\ - IPv6ExtHdrRouting(addresses=[SRT_IN6, SRT_OUT6], segleft=2)/\ + IPv6ExtHdrRouting(addresses=[OTHER_FAKE1_ADDR6, OTHER_FAKE2_ADDR6], \ + segleft=2)/\ ICMPv6EchoRequest(id=eid, data=payload) -eth=Ether(src=SRC_MAC, dst=DST_MAC)/packet +eth=Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/packet if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and dst "+SRC_OUT6+" and icmp6") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and dst "+LOCAL_ADDR6+" and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ diff --git a/regress/sys/netinet6/rh0/rh0_none.py b/regress/sys/netinet6/rh0/rh0_none.py index 694a9277fa4..b285b2e2482 100644 --- a/regress/sys/netinet6/rh0/rh0_none.py +++ b/regress/sys/netinet6/rh0/rh0_none.py @@ -10,17 +10,17 @@ from scapy.all import * eid=os.getpid() & 0xffff payload="ABCDEFGHIJKLMNOP" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/\ +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/\ ICMPv6EchoRequest(id=eid, data=payload) -eth=Ether(src=SRC_MAC, dst=DST_MAC)/packet +eth=Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/packet if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and dst "+SRC_OUT6+" and icmp6") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and dst "+LOCAL_ADDR6+" and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ diff --git a/regress/sys/netinet6/rh0/rh0_route.py b/regress/sys/netinet6/rh0/rh0_route.py index 71d4144063a..bce287ede16 100644 --- a/regress/sys/netinet6/rh0/rh0_route.py +++ b/regress/sys/netinet6/rh0/rh0_route.py @@ -11,18 +11,19 @@ from scapy.all import * eid=os.getpid() & 0xffff payload="ABCDEFGHIJKLMNOP" -packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/\ - IPv6ExtHdrRouting(addresses=[SRT_IN6, SRT_OUT6], segleft=2)/\ +packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/\ + IPv6ExtHdrRouting(addresses=[OTHER_FAKE1_ADDR6, OTHER_FAKE2_ADDR6], \ + segleft=2)/\ ICMPv6EchoRequest(id=eid, data=payload) -eth=Ether(src=SRC_MAC, dst=DST_MAC)/packet +eth=Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/packet if os.fork() == 0: time.sleep(1) - sendp(eth, iface=SRC_IF) + sendp(eth, iface=LOCAL_IF) os._exit(0) -ans=sniff(iface=SRC_IF, timeout=3, filter= - "ip6 and dst "+SRC_OUT6+" and icmp6") +ans=sniff(iface=LOCAL_IF, timeout=3, filter= + "ip6 and dst "+LOCAL_ADDR6+" and icmp6") for a in ans: if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ |