From b9f35c55306df6027cf3fb4fe22e9090bf774ecd Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Sun, 6 Dec 2020 19:47:25 +0000 Subject: [PATCH] Return ICMPv6 Destination Unreachable for unknown destinations (#748) * Return ICMPv6 Destination Unreachable for unknown destinations * Update go.mod/go.sum for yggdrasil-extras * go mod tidy --- src/tuntap/iface.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/tuntap/iface.go b/src/tuntap/iface.go index 5e693ed8..86c3f838 100644 --- a/src/tuntap/iface.go +++ b/src/tuntap/iface.go @@ -5,6 +5,9 @@ import ( "github.com/yggdrasil-network/yggdrasil-go/src/crypto" "github.com/yggdrasil-network/yggdrasil-go/src/yggdrasil" + "golang.org/x/net/icmp" + "golang.org/x/net/ipv6" + "github.com/Arceliar/phony" ) @@ -147,6 +150,16 @@ func (tun *TunAdapter) _handlePacket(recvd []byte, err error) { } if addrlen != 16 || (!dstAddr.IsValid() && !dstSnet.IsValid()) { // Couldn't find this node's ygg IP + dlen := len(bs) + if dlen > 900 { + dlen = 900 + } + ptb := &icmp.DstUnreach{ + Data: bs[:dlen], + } + if packet, err := CreateICMPv6(bs[8:24], bs[24:40], ipv6.ICMPTypeDestinationUnreachable, 0, ptb); err == nil { + tun.writer.writeFrom(nil, packet) + } return } // Do we have an active connection for this node address?