mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-22 21:10:29 +00:00
Enforce min 4MB switch queue total size
This commit is contained in:
parent
319457ae27
commit
b5f4637b5c
@ -638,7 +638,7 @@ func (a *admin) getData_getSwitchQueues() admin_nodeInfo {
|
|||||||
{"queues_size", switchTable.queues.size},
|
{"queues_size", switchTable.queues.size},
|
||||||
{"highest_queues_count", switchTable.queues.maxbufs},
|
{"highest_queues_count", switchTable.queues.maxbufs},
|
||||||
{"highest_queues_size", switchTable.queues.maxsize},
|
{"highest_queues_size", switchTable.queues.maxsize},
|
||||||
{"maximum_queues_size", switchTable.queuetotalmaxsize},
|
{"maximum_queues_size", switchTable.queueTotalMaxSize},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a.core.switchTable.doAdmin(getSwitchQueues)
|
a.core.switchTable.doAdmin(getSwitchQueues)
|
||||||
|
@ -105,9 +105,11 @@ func (c *Core) Start(nc *config.NodeConfig, log *log.Logger) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
c.switchTable.doAdmin(func() {
|
if nc.SwitchOptions.MaxTotalQueueSize >= SwitchQueueTotalMinSize {
|
||||||
c.switchTable.queuetotalmaxsize = nc.SwitchOptions.MaxTotalQueueSize
|
c.switchTable.doAdmin(func() {
|
||||||
})
|
c.switchTable.queueTotalMaxSize = nc.SwitchOptions.MaxTotalQueueSize
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
c.sessions.setSessionFirewallState(nc.SessionFirewall.Enable)
|
c.sessions.setSessionFirewallState(nc.SessionFirewall.Enable)
|
||||||
c.sessions.setSessionFirewallDefaults(
|
c.sessions.setSessionFirewallDefaults(
|
||||||
|
@ -169,9 +169,12 @@ type switchTable struct {
|
|||||||
idleIn chan switchPort // Incoming idle notifications from peer links
|
idleIn chan switchPort // Incoming idle notifications from peer links
|
||||||
admin chan func() // Pass a lambda for the admin socket to query stuff
|
admin chan func() // Pass a lambda for the admin socket to query stuff
|
||||||
queues switch_buffers // Queues - not atomic so ONLY use through admin chan
|
queues switch_buffers // Queues - not atomic so ONLY use through admin chan
|
||||||
queuetotalmaxsize uint64 // Maximum combined size of queues
|
queueTotalMaxSize uint64 // Maximum combined size of queues
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Minimum allowed total size of switch queues.
|
||||||
|
const SwitchQueueTotalMinSize = 4 * 1024 * 1024
|
||||||
|
|
||||||
// Initializes the switchTable struct.
|
// Initializes the switchTable struct.
|
||||||
func (t *switchTable) init(core *Core, key sigPubKey) {
|
func (t *switchTable) init(core *Core, key sigPubKey) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
@ -186,6 +189,7 @@ func (t *switchTable) init(core *Core, key sigPubKey) {
|
|||||||
t.packetIn = make(chan []byte, 1024)
|
t.packetIn = make(chan []byte, 1024)
|
||||||
t.idleIn = make(chan switchPort, 1024)
|
t.idleIn = make(chan switchPort, 1024)
|
||||||
t.admin = make(chan func())
|
t.admin = make(chan func())
|
||||||
|
t.queueTotalMaxSize = SwitchQueueTotalMinSize
|
||||||
}
|
}
|
||||||
|
|
||||||
// Safely gets a copy of this node's locator.
|
// Safely gets a copy of this node's locator.
|
||||||
@ -649,7 +653,7 @@ func (b *switch_buffers) cleanup(t *switchTable) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for b.size > b.switchTable.queuetotalmaxsize {
|
for b.size > b.switchTable.queueTotalMaxSize {
|
||||||
// Drop a random queue
|
// Drop a random queue
|
||||||
target := rand.Uint64() % b.size
|
target := rand.Uint64() % b.size
|
||||||
var size uint64 // running total
|
var size uint64 // running total
|
||||||
|
@ -69,7 +69,7 @@ func generateConfig(isAutoconf bool) *nodeConfig {
|
|||||||
cfg.SessionFirewall.Enable = false
|
cfg.SessionFirewall.Enable = false
|
||||||
cfg.SessionFirewall.AllowFromDirect = true
|
cfg.SessionFirewall.AllowFromDirect = true
|
||||||
cfg.SessionFirewall.AllowFromRemote = true
|
cfg.SessionFirewall.AllowFromRemote = true
|
||||||
cfg.SwitchOptions.MaxTotalQueueSize = 4 * 1048576
|
cfg.SwitchOptions.MaxTotalQueueSize = yggdrasil.SwitchQueueTotalMinSize
|
||||||
|
|
||||||
return &cfg
|
return &cfg
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user