Преглед изворни кода

Merge pull request #1892 from fcrisciani/limit-mtu

Add a minimum value for the CP MTU
Flavio Crisciani пре 7 година
родитељ
комит
5e03465a27
1 измењених фајлова са 11 додато и 3 уклоњено
  1. 11 3
      libnetwork/config/config.go

+ 11 - 3
libnetwork/config/config.go

@@ -15,6 +15,11 @@ import (
 	"github.com/sirupsen/logrus"
 	"github.com/sirupsen/logrus"
 )
 )
 
 
+const (
+	warningThNetworkControlPlaneMTU = 1500
+	minimumNetworkControlPlaneMTU   = 500
+)
+
 // Config encapsulates configurations of various Libnetwork components
 // Config encapsulates configurations of various Libnetwork components
 type Config struct {
 type Config struct {
 	Daemon          DaemonCfg
 	Daemon          DaemonCfg
@@ -226,9 +231,12 @@ func OptionExperimental(exp bool) Option {
 func OptionNetworkControlPlaneMTU(exp int) Option {
 func OptionNetworkControlPlaneMTU(exp int) Option {
 	return func(c *Config) {
 	return func(c *Config) {
 		logrus.Debugf("Network Control Plane MTU: %d", exp)
 		logrus.Debugf("Network Control Plane MTU: %d", exp)
-		if exp < 1500 {
-			// if exp == 0 the value won't be used
-			logrus.Warnf("Received a MTU of %d, this value is very low, the network control plane can misbehave", exp)
+		if exp < warningThNetworkControlPlaneMTU {
+			logrus.Warnf("Received a MTU of %d, this value is very low, the network control plane can misbehave,"+
+				" defaulting to minimum value (%d)", exp, minimumNetworkControlPlaneMTU)
+			if exp < minimumNetworkControlPlaneMTU {
+				exp = minimumNetworkControlPlaneMTU
+			}
 		}
 		}
 		c.Daemon.NetworkControlPlaneMTU = exp
 		c.Daemon.NetworkControlPlaneMTU = exp
 	}
 	}