Browse Source

Merge pull request #897 from tomdee/fix-vxlan-mtu

backend/vxlan: Return correct MTU value
Gunjan Patel 7 years ago
parent
commit
1cea4d196a
2 changed files with 5 additions and 6 deletions
  1. 0 4
      backend/vxlan/device.go
  2. 5 2
      backend/vxlan/vxlan_network.go

+ 0 - 4
backend/vxlan/device.go

@@ -144,10 +144,6 @@ func (dev *vxlanDevice) MACAddr() net.HardwareAddr {
 	return dev.link.HardwareAddr
 }
 
-func (dev *vxlanDevice) MTU() int {
-	return dev.link.MTU
-}
-
 type neighbor struct {
 	MAC net.HardwareAddr
 	IP  ip.IP4

+ 5 - 2
backend/vxlan/vxlan_network.go

@@ -33,11 +33,14 @@ import (
 
 type network struct {
 	backend.SimpleNetwork
-	extIface  *backend.ExternalInterface
 	dev       *vxlanDevice
 	subnetMgr subnet.Manager
 }
 
+const (
+	encapOverhead = 50
+)
+
 func newNetwork(subnetMgr subnet.Manager, extIface *backend.ExternalInterface, dev *vxlanDevice, _ ip.IP4Net, lease *subnet.Lease) (*network, error) {
 	nw := &network{
 		SimpleNetwork: backend.SimpleNetwork{
@@ -77,7 +80,7 @@ func (nw *network) Run(ctx context.Context) {
 }
 
 func (nw *network) MTU() int {
-	return nw.dev.MTU()
+	return nw.ExtIface.Iface.MTU - encapOverhead
 }
 
 type vxlanLeaseAttrs struct {