From 2d037d874c8d3fa4a7b61145dec0194624119bf4 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Mon, 16 May 2016 15:55:44 +0100 Subject: [PATCH] MTU selection closer to weave script Note that if initFastdp sets the MTU for the datapath then the same value is used for the bridge also. --- net/bridge.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/net/bridge.go b/net/bridge.go index 46841aab..5224a8f8 100644 --- a/net/bridge.go +++ b/net/bridge.go @@ -225,6 +225,9 @@ func initBridgePrep(config *BridgeConfig) error { linkAttrs := netlink.NewLinkAttrs() linkAttrs.Name = config.WeaveBridgeName linkAttrs.HardwareAddr = mac + if config.MTU == 0 { + config.MTU = 65535 + } linkAttrs.MTU = config.MTU // TODO this probably doesn't work - see weave script if err = netlink.LinkAdd(&netlink.Bridge{LinkAttrs: linkAttrs}); err != nil { return err @@ -251,6 +254,15 @@ func initFastdp(config *BridgeConfig) error { if err != nil { return err } + if config.MTU == 0 { + /* GCE has the lowest underlay network MTU we're likely to encounter on + a local network, at 1460 bytes. To get the overlay MTU from that we + subtract 20 bytes for the outer IPv4 header, 8 bytes for the outer + UDP header, 8 bytes for the vxlan header, and 14 bytes for the inner + ethernet header. In addition, we subtract 34 bytes for the ESP overhead + which is needed for the vxlan encryption. */ + config.MTU = 1376 + } return netlink.LinkSetMTU(datapath, config.MTU) }