This commit is contained in:
Oleksandr Natalenko 2021-04-17 12:49:56 +00:00 committed by GitHub
commit 7e1f151048
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 19 additions and 5 deletions

View file

@ -80,6 +80,7 @@ type NodeConfig struct {
SwitchOptions SwitchOptions `comment:"Advanced options for tuning the switch. Normally you will not need\nto edit these options."` SwitchOptions SwitchOptions `comment:"Advanced options for tuning the switch. Normally you will not need\nto edit these options."`
NodeInfoPrivacy bool `comment:"By default, nodeinfo contains some defaults including the platform,\narchitecture and Yggdrasil version. These can help when surveying\nthe network and diagnosing network routing problems. Enabling\nnodeinfo privacy prevents this, so that only items specified in\n\"NodeInfo\" are sent back if specified."` NodeInfoPrivacy bool `comment:"By default, nodeinfo contains some defaults including the platform,\narchitecture and Yggdrasil version. These can help when surveying\nthe network and diagnosing network routing problems. Enabling\nnodeinfo privacy prevents this, so that only items specified in\n\"NodeInfo\" are sent back if specified."`
NodeInfo map[string]interface{} `comment:"Optional node info. This must be a { \"key\": \"value\", ... } map\nor set as null. This is entirely optional but, if set, is visible\nto the whole network on request."` NodeInfo map[string]interface{} `comment:"Optional node info. This must be a { \"key\": \"value\", ... } map\nor set as null. This is entirely optional but, if set, is visible\nto the whole network on request."`
TCPCongestionControl string `json:",omitempty" comment:"Optional TCP congestion control algorithm used for connections. If not set, a system-wide setting is applied. Linux-only."`
} }
// SessionFirewall controls the session firewall configuration. // SessionFirewall controls the session firewall configuration.
@ -135,6 +136,7 @@ func GenerateConfig() *NodeConfig {
cfg.SessionFirewall.AlwaysAllowOutbound = true cfg.SessionFirewall.AlwaysAllowOutbound = true
cfg.SwitchOptions.MaxTotalQueueSize = 4 * 1024 * 1024 cfg.SwitchOptions.MaxTotalQueueSize = 4 * 1024 * 1024
cfg.NodeInfoPrivacy = false cfg.NodeInfoPrivacy = false
cfg.TCPCongestionControl = defaults.GetDefaults().DefaultTCPCongestionControl
return &cfg return &cfg
} }

View file

@ -19,4 +19,5 @@ type platformDefaultParameters struct {
MaximumIfMTU types.MTU MaximumIfMTU types.MTU
DefaultIfMTU types.MTU DefaultIfMTU types.MTU
DefaultIfName string DefaultIfName string
DefaultTCPCongestionControl string
} }

View file

@ -22,5 +22,6 @@ func GetDefaults() platformDefaultParameters {
MaximumIfMTU: 65535, MaximumIfMTU: 65535,
DefaultIfMTU: 65535, DefaultIfMTU: 65535,
DefaultIfName: "auto", DefaultIfName: "auto",
DefaultTCPCongestionControl: "",
} }
} }

View file

@ -21,5 +21,6 @@ func GetDefaults() platformDefaultParameters {
MaximumIfMTU: 65535, MaximumIfMTU: 65535,
DefaultIfMTU: 65535, DefaultIfMTU: 65535,
DefaultIfName: "auto", DefaultIfName: "auto",
DefaultTCPCongestionControl: "bbr",
} }
} }

View file

@ -21,5 +21,6 @@ func GetDefaults() platformDefaultParameters {
MaximumIfMTU: 16384, MaximumIfMTU: 16384,
DefaultIfMTU: 16384, DefaultIfMTU: 16384,
DefaultIfName: "tun0", DefaultIfName: "tun0",
DefaultTCPCongestionControl: "",
} }
} }

View file

@ -21,5 +21,6 @@ func GetDefaults() platformDefaultParameters {
MaximumIfMTU: 65535, MaximumIfMTU: 65535,
DefaultIfMTU: 65535, DefaultIfMTU: 65535,
DefaultIfName: "none", DefaultIfName: "none",
DefaultTCPCongestionControl: "",
} }
} }

View file

@ -21,5 +21,6 @@ func GetDefaults() platformDefaultParameters {
MaximumIfMTU: 65535, MaximumIfMTU: 65535,
DefaultIfMTU: 65535, DefaultIfMTU: 65535,
DefaultIfName: "Yggdrasil", DefaultIfName: "Yggdrasil",
DefaultTCPCongestionControl: "",
} }
} }

View file

@ -11,19 +11,25 @@ import (
// WARNING: This context is used both by net.Dialer and net.Listen in tcp.go // WARNING: This context is used both by net.Dialer and net.Listen in tcp.go
func (t *tcp) tcpContext(network, address string, c syscall.RawConn) error { func (t *tcp) tcpContext(network, address string, c syscall.RawConn) error {
var tcp_cca = t.links.core.config.Current.TCPCongestionControl
var control error var control error
var bbr error var ret error
// do not change TCP congestion control algorithm so that a system-wide one is used
if tcp_cca == "" {
return nil
}
control = c.Control(func(fd uintptr) { control = c.Control(func(fd uintptr) {
bbr = unix.SetsockoptString(int(fd), unix.IPPROTO_TCP, unix.TCP_CONGESTION, "bbr") ret = unix.SetsockoptString(int(fd), unix.IPPROTO_TCP, unix.TCP_CONGESTION, tcp_cca)
}) })
// Log any errors // Log any errors
if bbr != nil { if ret != nil {
t.links.core.log.Debugln("Failed to set tcp_congestion_control to bbr for socket, SetsockoptString error:", bbr) t.links.core.log.Debugf("Failed to set tcp_congestion_control to %s for socket, SetsockoptString error: %s\n", tcp_cca, ret)
} }
if control != nil { if control != nil {
t.links.core.log.Debugln("Failed to set tcp_congestion_control to bbr for socket, Control error:", control) t.links.core.log.Debugf("Failed to set tcp_congestion_control to %s for socket, Control error:\n", tcp_cca, control)
} }
// Return nil because errors here are not considered fatal for the connection, it just means congestion control is suboptimal // Return nil because errors here are not considered fatal for the connection, it just means congestion control is suboptimal