From de9d0a6cf10ef6485b684d3b59cc3326c165ed6a Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Mon, 22 Jul 2019 22:41:55 +0100 Subject: [PATCH] Redirect Conn session closure errors to debug channel --- src/tuntap/conn.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/tuntap/conn.go b/src/tuntap/conn.go index 234c34f0..193c6236 100644 --- a/src/tuntap/conn.go +++ b/src/tuntap/conn.go @@ -63,7 +63,11 @@ func (s *tunConn) reader() (err error) { } if n, err = s.conn.Read(b); err != nil { if e, eok := err.(yggdrasil.ConnError); eok && !e.Temporary() { - s.tun.log.Errorln(s.conn.String(), "TUN/TAP conn read error:", err) + if e.Closed() { + s.tun.log.Debugln(s.conn.String(), "TUN/TAP conn read debug:", err) + } else { + s.tun.log.Errorln(s.conn.String(), "TUN/TAP conn read error:", err) + } return e } } else if n > 0 { @@ -98,9 +102,12 @@ func (s *tunConn) writer() error { } // TODO write timeout and close if _, err := s.conn.Write(b); err != nil { - e, eok := err.(yggdrasil.ConnError) - if !eok { - s.tun.log.Errorln(s.conn.String(), "TUN/TAP generic write error:", err) + if e, eok := err.(yggdrasil.ConnError); !eok { + if e.Closed() { + s.tun.log.Debugln(s.conn.String(), "TUN/TAP generic write debug:", err) + } else { + s.tun.log.Errorln(s.conn.String(), "TUN/TAP generic write error:", err) + } } else if ispackettoobig, maxsize := e.PacketTooBig(); ispackettoobig { // TODO: This currently isn't aware of IPv4 for CKR ptb := &icmp.PacketTooBig{ @@ -111,7 +118,11 @@ func (s *tunConn) writer() error { s.tun.send <- packet } } else { - s.tun.log.Errorln(s.conn.String(), "TUN/TAP conn write error:", err) + if e.Closed() { + s.tun.log.Debugln(s.conn.String(), "TUN/TAP conn write debug:", err) + } else { + s.tun.log.Errorln(s.conn.String(), "TUN/TAP conn write error:", err) + } } } else { s.stillAlive()