@@ -50,12 +50,13 @@ const (
50
50
51
51
// OvsSwitch represents on OVS bridge instance
52
52
type OvsSwitch struct {
53
- bridgeName string
54
- netType string
55
- uplinkDb cmap.ConcurrentMap
56
- ovsdbDriver * OvsdbDriver
57
- ofnetAgent * ofnet.OfnetAgent
58
- hostPvtNW int
53
+ bridgeName string
54
+ netType string
55
+ uplinkDb cmap.ConcurrentMap
56
+ ovsdbDriver * OvsdbDriver
57
+ ofnetAgent * ofnet.OfnetAgent
58
+ hostPvtNW int
59
+ vxlanEncapMtu int
59
60
}
60
61
61
62
// getPvtIP returns a private IP for the port
@@ -100,6 +101,10 @@ func NewOvsSwitch(bridgeName, netType, localIP, fwdMode string,
100
101
sw .netType = netType
101
102
sw .uplinkDb = cmap .New ()
102
103
sw .hostPvtNW = hostPvtNW
104
+ sw .vxlanEncapMtu , err = netutils .GetHostLowestLinkMtu ()
105
+ if err != nil {
106
+ log .Fatalf ("Failed to get Host Node MTU. Err: %v" , err )
107
+ }
103
108
104
109
// Create OVS db driver
105
110
sw .ovsdbDriver , err = NewOvsdbDriver (bridgeName , "secure" , vxlanUDPPort )
@@ -359,7 +364,12 @@ func (sw *OvsSwitch) CreatePort(intfName string, cfgEp *mastercfg.CfgEndpointSta
359
364
360
365
// Set the link mtu to 1450 to allow for 50 bytes vxlan encap
361
366
// (inner eth header(14) + outer IP(20) outer UDP(8) + vxlan header(8))
362
- err = setLinkMtu (intfName , vxlanEndpointMtu )
367
+ if sw .netType == "vxlan" {
368
+ correctMtu := sw .vxlanEncapMtu - 50 //Include Vxlan header size
369
+ err = setLinkMtu (intfName , correctMtu )
370
+ } else {
371
+ err = setLinkMtu (intfName , sw .vxlanEncapMtu )
372
+ }
363
373
if err != nil {
364
374
log .Errorf ("Error setting link %s mtu. Err: %v" , intfName , err )
365
375
return err
0 commit comments