|
@@ -63,6 +63,7 @@ type network struct {
|
|
initErr error
|
|
initErr error
|
|
subnets []*subnet
|
|
subnets []*subnet
|
|
secure bool
|
|
secure bool
|
|
|
|
+ mtu int
|
|
sync.Mutex
|
|
sync.Mutex
|
|
}
|
|
}
|
|
|
|
|
|
@@ -114,6 +115,15 @@ func (d *driver) CreateNetwork(id string, option map[string]interface{}, nInfo d
|
|
if _, ok := optMap[secureOption]; ok {
|
|
if _, ok := optMap[secureOption]; ok {
|
|
n.secure = true
|
|
n.secure = true
|
|
}
|
|
}
|
|
|
|
+ if val, ok := optMap[netlabel.DriverMTU]; ok {
|
|
|
|
+ var err error
|
|
|
|
+ if n.mtu, err = strconv.Atoi(val); err != nil {
|
|
|
|
+ return fmt.Errorf("failed to parse %v: %v", val, err)
|
|
|
|
+ }
|
|
|
|
+ if n.mtu < 0 {
|
|
|
|
+ return fmt.Errorf("invalid MTU value: %v", n.mtu)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
// If we are getting vnis from libnetwork, either we get for
|
|
// If we are getting vnis from libnetwork, either we get for
|
|
@@ -315,7 +325,7 @@ func networkOnceInit() {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
- err := createVxlan("testvxlan", 1)
|
|
|
|
|
|
+ err := createVxlan("testvxlan", 1, 0)
|
|
if err != nil {
|
|
if err != nil {
|
|
logrus.Errorf("Failed to create testvxlan interface: %v", err)
|
|
logrus.Errorf("Failed to create testvxlan interface: %v", err)
|
|
return
|
|
return
|
|
@@ -459,7 +469,7 @@ func (n *network) setupSubnetSandbox(s *subnet, brName, vxlanName string) error
|
|
return fmt.Errorf("bridge creation in sandbox failed for subnet %q: %v", s.subnetIP.String(), err)
|
|
return fmt.Errorf("bridge creation in sandbox failed for subnet %q: %v", s.subnetIP.String(), err)
|
|
}
|
|
}
|
|
|
|
|
|
- err := createVxlan(vxlanName, n.vxlanID(s))
|
|
|
|
|
|
+ err := createVxlan(vxlanName, n.vxlanID(s), n.maxMTU())
|
|
if err != nil {
|
|
if err != nil {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
@@ -732,6 +742,7 @@ func (n *network) Value() []byte {
|
|
|
|
|
|
m["secure"] = n.secure
|
|
m["secure"] = n.secure
|
|
m["subnets"] = netJSON
|
|
m["subnets"] = netJSON
|
|
|
|
+ m["mtu"] = n.mtu
|
|
b, err = json.Marshal(m)
|
|
b, err = json.Marshal(m)
|
|
if err != nil {
|
|
if err != nil {
|
|
return []byte{}
|
|
return []byte{}
|
|
@@ -781,6 +792,9 @@ func (n *network) SetValue(value []byte) error {
|
|
if val, ok := m["secure"]; ok {
|
|
if val, ok := m["secure"]; ok {
|
|
n.secure = val.(bool)
|
|
n.secure = val.(bool)
|
|
}
|
|
}
|
|
|
|
+ if val, ok := m["mtu"]; ok {
|
|
|
|
+ n.mtu = int(val.(float64))
|
|
|
|
+ }
|
|
bytes, err := json.Marshal(m["subnets"])
|
|
bytes, err := json.Marshal(m["subnets"])
|
|
if err != nil {
|
|
if err != nil {
|
|
return err
|
|
return err
|