Browse Source

Merge pull request #491 from sanimej/ov-mtu

For the endpoints on overlay network set the MTU to 1450 to avoid fra…
Madhu Venugopal 10 years ago
parent
commit
c712abd18e
2 changed files with 18 additions and 1 deletions
  1. 17 1
      libnetwork/drivers/overlay/joinleave.go
  2. 1 0
      libnetwork/drivers/overlay/overlay.go

+ 17 - 1
libnetwork/drivers/overlay/joinleave.go

@@ -35,15 +35,31 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo,
 		return err
 	}
 
+	// Set the container interface and its peer MTU to 1450 to allow
+	// for 50 bytes vxlan encap (inner eth header(14) + outer IP(20) +
+	// outer UDP(8) + vxlan header(8))
+	veth, err := netlink.LinkByName(name1)
+	if err != nil {
+		return fmt.Errorf("cound not find link by name %s: %v", name1, err)
+	}
+	err = netlink.LinkSetMTU(veth, vxlanVethMTU)
+	if err != nil {
+		return err
+	}
+
 	if err := sbox.AddInterface(name1, "veth",
 		sbox.InterfaceOptions().Master("bridge1")); err != nil {
 		return fmt.Errorf("could not add veth pair inside the network sandbox: %v", err)
 	}
 
-	veth, err := netlink.LinkByName(name2)
+	veth, err = netlink.LinkByName(name2)
 	if err != nil {
 		return fmt.Errorf("could not find link by name %s: %v", name2, err)
 	}
+	err = netlink.LinkSetMTU(veth, vxlanVethMTU)
+	if err != nil {
+		return err
+	}
 
 	if err := netlink.LinkSetHardwareAddr(veth, ep.mac); err != nil {
 		return fmt.Errorf("could not set mac address to the container interface: %v", err)

+ 1 - 0
libnetwork/drivers/overlay/overlay.go

@@ -21,6 +21,7 @@ const (
 	vxlanIDStart = 256
 	vxlanIDEnd   = 1000
 	vxlanPort    = 4789
+	vxlanVethMTU = 1450
 )
 
 type driver struct {