diff --git a/src/tuntap/icmpv6.go b/src/tuntap/icmpv6.go index f4f9efe..55c3280 100644 --- a/src/tuntap/icmpv6.go +++ b/src/tuntap/icmpv6.go @@ -93,7 +93,7 @@ func (i *ICMPv6) ParsePacket(datain []byte) { } // Write the packet to TUN/TAP - i.tun.Send <- response + i.tun.iface.Write(response) } // Unwraps the ethernet headers of an incoming ICMPv6 packet and hands off diff --git a/src/tuntap/tun.go b/src/tuntap/tun.go index 7dab31c..780043f 100644 --- a/src/tuntap/tun.go +++ b/src/tuntap/tun.go @@ -107,13 +107,20 @@ func (tun *TunAdapter) Start(a address.Address, s address.Subnet) error { } } if ifname == "none" || ifname == "dummy" { + tun.log.Debugln("Not starting TUN/TAP as ifname is none or dummy") return nil } tun.mutex.Lock() tun.isOpen = true tun.mutex.Unlock() - go func() { tun.log.Errorln("WARNING: tun.read() exited with error:", tun.Read()) }() - go func() { tun.log.Errorln("WARNING: tun.write() exited with error:", tun.Write()) }() + go func() { + tun.log.Debugln("Starting TUN/TAP reader goroutine") + tun.log.Errorln("WARNING: tun.read() exited with error:", tun.Read()) + }() + go func() { + tun.log.Debugln("Starting TUN/TAP writer goroutine") + tun.log.Errorln("WARNING: tun.write() exited with error:", tun.Write()) + }() if iftapmode { go func() { for { @@ -147,12 +154,16 @@ func (tun *TunAdapter) Write() error { var destAddr address.Address if data[0]&0xf0 == 0x60 { if len(data) < 40 { - panic("Tried to send a packet shorter than an IPv6 header...") + //panic("Tried to send a packet shorter than an IPv6 header...") + util.PutBytes(data) + continue } copy(destAddr[:16], data[24:]) } else if data[0]&0xf0 == 0x40 { if len(data) < 20 { - panic("Tried to send a packet shorter than an IPv4 header...") + //panic("Tried to send a packet shorter than an IPv4 header...") + util.PutBytes(data) + continue } copy(destAddr[:4], data[16:]) } else { @@ -255,7 +266,6 @@ func (tun *TunAdapter) Read() error { if !open { return nil } else { - // panic(err) return err } } diff --git a/src/yggdrasil/adapter.go b/src/yggdrasil/adapter.go index 7437eb0..4103d1e 100644 --- a/src/yggdrasil/adapter.go +++ b/src/yggdrasil/adapter.go @@ -29,7 +29,8 @@ type adapterImplementation interface { } // Initialises the adapter. -func (adapter Adapter) Init(config *config.NodeState, log *log.Logger, send chan<- []byte, recv <-chan []byte) { +func (adapter *Adapter) Init(config *config.NodeState, log *log.Logger, send chan<- []byte, recv <-chan []byte) { + log.Traceln("Adapter setup - given channels:", send, recv) adapter.Send = send adapter.Recv = recv adapter.Reconfigure = make(chan chan error, 1)