more switch fixes

This commit is contained in:
Arceliar 2020-05-30 10:47:54 -05:00
parent 8775075c18
commit 5e170e22e1

View File

@ -392,6 +392,9 @@ func (t *switchTable) _handleMsg(msg *switchMsg, fromPort switchPort, reprocessi
sender.key = prevKey sender.key = prevKey
prevKey = hop.Next prevKey = hop.Next
} }
if sender.key == t.key {
return // Don't peer with ourself via different interfaces
}
sender.msg = *msg sender.msg = *msg
sender.port = fromPort sender.port = fromPort
sender.time = now sender.time = now
@ -516,8 +519,8 @@ func (t *switchTable) _handleMsg(msg *switchMsg, fromPort switchPort, reprocessi
} }
// Note that we depend on the LIFO order of the stack of defers here... // Note that we depend on the LIFO order of the stack of defers here...
if updateRoot { if updateRoot {
if !equiv(&sender.locator, &t.data.locator) {
doUpdate = true doUpdate = true
if !equiv(&sender.locator, &t.data.locator) {
t.data.seq++ t.data.seq++
defer t.core.router.reset(t) defer t.core.router.reset(t)
} }
@ -528,8 +531,8 @@ func (t *switchTable) _handleMsg(msg *switchMsg, fromPort switchPort, reprocessi
t.parent = sender.port t.parent = sender.port
defer t.core.peers.sendSwitchMsgs(t) defer t.core.peers.sendSwitchMsgs(t)
} }
if true || doUpdate { if doUpdate {
defer t._updateTable() t._updateTable()
} }
return return
} }
@ -546,9 +549,7 @@ func (t *switchTable) _updateTable() {
} }
newTable._init() newTable._init()
for _, pinfo := range t.data.peers { for _, pinfo := range t.data.peers {
if pinfo.blocked || if pinfo.blocked || pinfo.locator.root != newTable.self.root {
pinfo.locator.root != newTable.self.root ||
pinfo.key == t.key {
continue continue
} }
loc := pinfo.locator.clone() loc := pinfo.locator.clone()