瀏覽代碼

backend/vxlan: Return correct MTU value

Ensure that the correct MTU is being used for vxlan
Tom Denham 7 年之前
父節點
當前提交
f72fa98bfd
共有 2 個文件被更改,包括 5 次插入6 次删除
  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 {