From 209d2ffea55a6ce3f1f3d22a2f06bda4ec25aae3 Mon Sep 17 00:00:00 2001 From: Arceliar Date: Sat, 24 Aug 2019 16:04:05 -0500 Subject: [PATCH] correctly call peer.sendPacketsFrom in the switch --- src/yggdrasil/peer.go | 6 +++--- src/yggdrasil/switch.go | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/yggdrasil/peer.go b/src/yggdrasil/peer.go index 9a6f75f..7fe33ec 100644 --- a/src/yggdrasil/peer.go +++ b/src/yggdrasil/peer.go @@ -224,9 +224,9 @@ func (p *peer) _handlePacket(packet []byte) { } switch pType { case wire_Traffic: - p._handleTraffic(packet, pTypeLen) + p._handleTraffic(packet) case wire_ProtocolTraffic: - p._handleTraffic(packet, pTypeLen) + p._handleTraffic(packet) case wire_LinkProtocolTraffic: p._handleLinkTraffic(packet) default: @@ -236,7 +236,7 @@ func (p *peer) _handlePacket(packet []byte) { // Called to handle traffic or protocolTraffic packets. // In either case, this reads from the coords of the packet header, does a switch lookup, and forwards to the next node. -func (p *peer) _handleTraffic(packet []byte, pTypeLen int) { +func (p *peer) _handleTraffic(packet []byte) { table := p.core.switchTable.getTable() if _, isIn := table.elems[p.port]; !isIn && p.port != 0 { // Drop traffic if the peer isn't in the switch diff --git a/src/yggdrasil/switch.go b/src/yggdrasil/switch.go index 905f2a7..b6fc26f 100644 --- a/src/yggdrasil/switch.go +++ b/src/yggdrasil/switch.go @@ -708,7 +708,7 @@ func (t *switchTable) _handleIn(packet []byte, idle map[switchPort]time.Time) bo if best != nil { // Send to the best idle next hop delete(idle, best.port) - best.sendPacketsFrom(nil, [][]byte{packet}) + best.sendPacketsFrom(t, [][]byte{packet}) return true } // Didn't find anyone idle to send it to @@ -822,8 +822,7 @@ func (t *switchTable) _handleIdle(port switchPort) bool { } } if len(packets) > 0 { - // TODO rewrite if/when the switch becomes an actor - to.sendPacketsFrom(nil, packets) + to.sendPacketsFrom(t, packets) return true } return false