From 64aa2b5cc363c7b50412a273246378c0c19cfe6d Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Mon, 9 Nov 2015 20:56:04 +0000 Subject: [PATCH] refactor: remove weave overlay-isms from mesh --- mesh/connection.go | 2 +- mesh/protocol.go | 6 +++--- router/sleeve.go | 16 ++++++++++------ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/mesh/connection.go b/mesh/connection.go index e97d52bd..b19d2c2c 100644 --- a/mesh/connection.go +++ b/mesh/connection.go @@ -422,7 +422,7 @@ func (conn *LocalConnection) receiveTCP(receiver TCPReceiver) { func (conn *LocalConnection) handleProtocolMsg(tag ProtocolTag, payload []byte) error { switch tag { case ProtocolHeartbeat: - case ProtocolConnectionEstablished, ProtocolFragmentationReceived, ProtocolPMTUVerified, ProtocolOverlayControlMsg: + case ProtocolReserved1, ProtocolReserved2, ProtocolReserved3, ProtocolOverlayControlMsg: conn.OverlayConn.ControlMessage(byte(tag), payload) case ProtocolGossipUnicast, ProtocolGossipBroadcast, ProtocolGossip: return conn.Router.handleGossip(tag, payload) diff --git a/mesh/protocol.go b/mesh/protocol.go index 1863125a..7ac06050 100644 --- a/mesh/protocol.go +++ b/mesh/protocol.go @@ -329,9 +329,9 @@ type ProtocolTag byte const ( ProtocolHeartbeat = iota - ProtocolConnectionEstablished - ProtocolFragmentationReceived - ProtocolPMTUVerified + ProtocolReserved1 // legacy overlay control messages + ProtocolReserved2 // + ProtocolReserved3 // ProtocolGossip ProtocolGossipUnicast ProtocolGossipBroadcast diff --git a/router/sleeve.go b/router/sleeve.go index 66cbe7cd..0be92572 100644 --- a/router/sleeve.go +++ b/router/sleeve.go @@ -56,6 +56,10 @@ const ( FragTestInterval = 5 * time.Minute MTUVerifyAttempts = 8 MTUVerifyTimeout = 10 * time.Millisecond // doubled with each attempt + + ProtocolConnectionEstablished = mesh.ProtocolReserved1 + ProtocolFragmentationReceived = mesh.ProtocolReserved2 + ProtocolPMTUVerified = mesh.ProtocolReserved3 ) type SleeveOverlay struct { @@ -761,13 +765,13 @@ func (fwd *sleeveForwarder) handleSpecialFrame(special specialFrame) error { func (fwd *sleeveForwarder) handleControlMessage(cm controlMessage) error { switch cm.tag { - case mesh.ProtocolConnectionEstablished: + case ProtocolConnectionEstablished: return fwd.handleHeartbeatAck() - case mesh.ProtocolFragmentationReceived: + case ProtocolFragmentationReceived: return fwd.handleFragTestAck() - case mesh.ProtocolPMTUVerified: + case ProtocolPMTUVerified: return fwd.handleMTUTestAck(cm.msg) default: @@ -836,7 +840,7 @@ func (fwd *sleeveForwarder) handleHeartbeat(special specialFrame) error { if !fwd.ackedHeartbeat { fwd.ackedHeartbeat = true - if err := fwd.sendControlMsg(mesh.ProtocolConnectionEstablished, nil); err != nil { + if err := fwd.sendControlMsg(ProtocolConnectionEstablished, nil); err != nil { return err } } @@ -897,7 +901,7 @@ func (fwd *sleeveForwarder) handleFragTest(frame []byte) error { return nil } - return fwd.sendControlMsg(mesh.ProtocolFragmentationReceived, nil) + return fwd.sendControlMsg(ProtocolFragmentationReceived, nil) } func (fwd *sleeveForwarder) handleFragTestAck() error { @@ -943,7 +947,7 @@ func (fwd *sleeveForwarder) sendMTUTest() error { func (fwd *sleeveForwarder) handleMTUTest(frame []byte) error { buf := make([]byte, 2) binary.BigEndian.PutUint16(buf, uint16(len(frame)-EthernetOverhead)) - return fwd.sendControlMsg(mesh.ProtocolPMTUVerified, buf) + return fwd.sendControlMsg(ProtocolPMTUVerified, buf) } func (fwd *sleeveForwarder) handleMTUTestAck(msg []byte) error {