5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-22 13:00:47 +00:00

force things to buffer in the switch if the best link is currently busy. note that other links can end up sending if they become non-idle for other reasons. this is a temporary workaround to packet reordering, until we can figure out a better solution

This commit is contained in:
Arceliar 2019-09-17 19:42:07 -05:00
parent 0141180279
commit 80ba24d512

View File

@ -677,13 +677,10 @@ func (t *switchTable) _handleIn(packet []byte, idle map[switchPort]struct{}) boo
ports := t.core.peers.getPorts()
for _, cinfo := range closer {
to := ports[cinfo.elem.port]
_, isIdle := idle[cinfo.elem.port]
var update bool
switch {
case to == nil:
// no port was found, ignore it
case !isIdle:
// the port is busy, ignore it
case best == nil:
// this is the first idle port we've found, so select it until we find a
// better candidate port to use instead
@ -713,6 +710,9 @@ func (t *switchTable) _handleIn(packet []byte, idle map[switchPort]struct{}) boo
}
if best != nil {
// Send to the best idle next hop
if _, isIdle := idle[best.elem.port]; !isIdle {
return false
}
delete(idle, best.elem.port)
ports[best.elem.port].sendPacketsFrom(t, [][]byte{packet})
return true