From: bluhm Date: Wed, 15 Apr 2015 21:29:15 +0000 (+0000) Subject: Test that ping6 fragments with ethernet padding get reassembled X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=7f476280d364f6918307de718505609218e27c22;p=openbsd Test that ping6 fragments with ethernet padding get reassembled correctly. --- diff --git a/regress/sys/netinet6/frag6/Makefile b/regress/sys/netinet6/frag6/Makefile index 585ec1aa24f..cfdb02730e4 100644 --- a/regress/sys/netinet6/frag6/Makefile +++ b/regress/sys/netinet6/frag6/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.10 2014/07/11 18:25:50 bluhm Exp $ +# $OpenBSD: Makefile,v 1.11 2015/04/15 21:29:15 bluhm Exp $ # The following ports must be installed: # @@ -106,6 +106,13 @@ run-regress-frag6-opt: addr.py @echo Check ping6 destination option reassembly ${SUDO} ${PYTHON}frag6_opt.py +# The ethernet frame has some padding that must be ignored by reassembly +TARGETS += frag6-padding +run-regress-frag6-padding: addr.py + @echo '\n======== $@ ========' + @echo Check ping6 ethernet padding + ${SUDO} ${PYTHON}frag6_padding.py + # fragmented packet with head overlapping first fragment TARGETS += frag6-overhead0 run-regress-frag6-overhead0: addr.py diff --git a/regress/sys/netinet6/frag6/frag6_padding.py b/regress/sys/netinet6/frag6/frag6_padding.py new file mode 100644 index 00000000000..714defe6126 --- /dev/null +++ b/regress/sys/netinet6/frag6/frag6_padding.py @@ -0,0 +1,46 @@ +#!/usr/local/bin/python2.7 +# send 2 non-overlapping ping6 fragments with ethernet padding + +# |--------|XX| +# |----|XX| + +import os +from addr import * +from scapy.all import * + +pid=os.getpid() +payload="ABCDEFGHIJKLMNOP" +padding="0123" +packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/ICMPv6EchoRequest(id=pid, data=payload) +frag=[] +frag.append(IPv6ExtHdrFragment(nh=58, id=pid, m=1)/str(packet)[40:56]) +frag.append(IPv6ExtHdrFragment(nh=58, id=pid, 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) + +if os.fork() == 0: + time.sleep(1) + sendp(eth, iface=SRC_IF) + os._exit(0) + +ans=sniff(iface=SRC_IF, timeout=3, filter= + "ip6 and src "+DST_IN6+" and dst "+SRC_OUT6+" 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] == 'Echo Reply': + id=a.payload.payload.id + print "id=%#x" % (id) + if id != pid: + print "WRONG ECHO REPLY ID" + exit(2) + data=a.payload.payload.data + print "payload=%s" % (data) + if data == payload: + exit(0) + print "PAYLOAD!=%s" % (payload) + exit(1) +print "NO ECHO REPLY" +exit(2)