mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-23 02:01:36 +00:00
correctly call peer.sendPacketsFrom in the switch
This commit is contained in:
parent
8c7e9ec7c0
commit
209d2ffea5
@ -224,9 +224,9 @@ func (p *peer) _handlePacket(packet []byte) {
|
|||||||
}
|
}
|
||||||
switch pType {
|
switch pType {
|
||||||
case wire_Traffic:
|
case wire_Traffic:
|
||||||
p._handleTraffic(packet, pTypeLen)
|
p._handleTraffic(packet)
|
||||||
case wire_ProtocolTraffic:
|
case wire_ProtocolTraffic:
|
||||||
p._handleTraffic(packet, pTypeLen)
|
p._handleTraffic(packet)
|
||||||
case wire_LinkProtocolTraffic:
|
case wire_LinkProtocolTraffic:
|
||||||
p._handleLinkTraffic(packet)
|
p._handleLinkTraffic(packet)
|
||||||
default:
|
default:
|
||||||
@ -236,7 +236,7 @@ func (p *peer) _handlePacket(packet []byte) {
|
|||||||
|
|
||||||
// Called to handle traffic or protocolTraffic packets.
|
// 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.
|
// 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()
|
table := p.core.switchTable.getTable()
|
||||||
if _, isIn := table.elems[p.port]; !isIn && p.port != 0 {
|
if _, isIn := table.elems[p.port]; !isIn && p.port != 0 {
|
||||||
// Drop traffic if the peer isn't in the switch
|
// Drop traffic if the peer isn't in the switch
|
||||||
|
@ -708,7 +708,7 @@ func (t *switchTable) _handleIn(packet []byte, idle map[switchPort]time.Time) bo
|
|||||||
if best != nil {
|
if best != nil {
|
||||||
// Send to the best idle next hop
|
// Send to the best idle next hop
|
||||||
delete(idle, best.port)
|
delete(idle, best.port)
|
||||||
best.sendPacketsFrom(nil, [][]byte{packet})
|
best.sendPacketsFrom(t, [][]byte{packet})
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// Didn't find anyone idle to send it to
|
// Didn't find anyone idle to send it to
|
||||||
@ -822,8 +822,7 @@ func (t *switchTable) _handleIdle(port switchPort) bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(packets) > 0 {
|
if len(packets) > 0 {
|
||||||
// TODO rewrite if/when the switch becomes an actor
|
to.sendPacketsFrom(t, packets)
|
||||||
to.sendPacketsFrom(nil, packets)
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
Loading…
Reference in New Issue
Block a user