diff --git a/daemon/config/config.go b/daemon/config/config.go index f3c97a673b..1f6652dd3c 100644 --- a/daemon/config/config.go +++ b/daemon/config/config.go @@ -597,6 +597,9 @@ func Validate(config *Config) error { } // TODO(thaJeztah) Validations below should not accept "0" to be valid; see Validate() for a more in-depth description of this problem + if config.Mtu < 0 { + return fmt.Errorf("invalid default MTU: %d", config.Mtu) + } if config.MaxConcurrentDownloads < 0 { return fmt.Errorf("invalid max concurrent downloads: %d", config.MaxConcurrentDownloads) } diff --git a/daemon/config/config_test.go b/daemon/config/config_test.go index 6da6ec2aba..b65b50095d 100644 --- a/daemon/config/config_test.go +++ b/daemon/config/config_test.go @@ -280,6 +280,15 @@ func TestValidateConfigurationErrors(t *testing.T) { }, expectedErr: "123456 is not a valid domain", }, + { + name: "negative MTU", + config: &Config{ + CommonConfig: CommonConfig{ + Mtu: -10, + }, + }, + expectedErr: "invalid default MTU: -10", + }, { name: "negative max-concurrent-downloads", config: &Config{ @@ -397,6 +406,14 @@ func TestValidateConfiguration(t *testing.T) { }, }, }, + { + name: "with mtu", + config: &Config{ + CommonConfig: CommonConfig{ + Mtu: 1234, + }, + }, + }, { name: "with max-concurrent-downloads", config: &Config{