Skip to content

Commit 57418e1

Browse files
authored
Merge pull request #1142 from unclejack/1.1.9-backports
backport fixes for the 1.1.9 release
2 parents 4aec51c + e4f45c5 commit 57418e1

File tree

9 files changed

+64
-13
lines changed

9 files changed

+64
-13
lines changed

drivers/ovsd/ovsSwitch.go

100755100644
+17-7
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,13 @@ const (
5050

5151
// OvsSwitch represents on OVS bridge instance
5252
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
5960
}
6061

6162
// getPvtIP returns a private IP for the port
@@ -100,6 +101,10 @@ func NewOvsSwitch(bridgeName, netType, localIP, fwdMode string,
100101
sw.netType = netType
101102
sw.uplinkDb = cmap.New()
102103
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+
}
103108

104109
// Create OVS db driver
105110
sw.ovsdbDriver, err = NewOvsdbDriver(bridgeName, "secure", vxlanUDPPort)
@@ -359,7 +364,12 @@ func (sw *OvsSwitch) CreatePort(intfName string, cfgEp *mastercfg.CfgEndpointSta
359364

360365
// Set the link mtu to 1450 to allow for 50 bytes vxlan encap
361366
// (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+
}
363373
if err != nil {
364374
log.Errorf("Error setting link %s mtu. Err: %v", intfName, err)
365375
return err

mgmtfn/dockplugin/ipamDriver.go

100755100644
+11
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,17 @@ func releaseAddress(w http.ResponseWriter, r *http.Request) {
288288

289289
log.Infof("Received ReleaseAddressRequest: %+v", areq)
290290

291+
//Build an release request to be sent to master
292+
releaseReq := master.AddressReleaseRequest{
293+
NetworkID: areq.PoolID,
294+
IPv4Address: areq.Address,
295+
}
296+
var releaseResp master.AddressReleaseResponse
297+
if err = cluster.MasterPostReq("/plugin/releaseAddress",
298+
&releaseReq, &releaseResp); err != nil {
299+
httpError(w, "master failed to release request", err)
300+
return
301+
}
291302
// response
292303
relResp := api.ReleaseAddressResponse{}
293304

mgmtfn/dockplugin/netDriver.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,6 @@ func createEndpoint(hostname string) func(http.ResponseWriter, *http.Request) {
189189
return
190190
}
191191

192-
log.Infof("CreateEndpointRequest: %+v. Interface: %+v", cereq, cereq.Interface)
193-
194192
tenantName, netName, serviceName, err := GetDockerNetworkName(cereq.NetworkID)
195193
if err != nil {
196194
log.Errorf("Error getting network name for UUID: %s. Err: %v", cereq.NetworkID, err)
@@ -213,6 +211,8 @@ func createEndpoint(hostname string) func(http.ResponseWriter, *http.Request) {
213211
},
214212
}
215213

214+
log.Infof("CreateEndpointRequest: %+v. Interface: %+v", mreq, cereq.Interface)
215+
216216
var mresp master.CreateEndpointResponse
217217
err = cluster.MasterPostReq("/plugin/createEndpoint", &mreq, &mresp)
218218
if err != nil {

netmaster/daemon/daemon.go

100755100644
File mode changed.

netmaster/master/api.go

100755100644
+3
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ type AddressReleaseRequest struct {
4949
NetworkID string // Unique identifier for the network
5050
IPv4Address string // Allocated address
5151
}
52+
type AddressReleaseResponse struct {
53+
Status string
54+
}
5255

5356
// CreateEndpointRequest has the endpoint create request from netplugin
5457
type CreateEndpointRequest struct {

netmaster/master/network.go

100755100644
+3-1
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,11 @@ func networkReleaseAddress(nwCfg *mastercfg.CfgNetworkState, epgCfg *mastercfg.E
512512
nwCfg.EpAddrCount--
513513
}
514514
nwCfg.IPAllocMap.Clear(ipAddrValue)
515+
log.Infof("Releasing IP Address: %v"+
516+
"from networkId:%+v", ipAddrValue,
517+
nwCfg.NetworkName)
515518
}
516519
}
517-
518520
err := nwCfg.Write()
519521
if err != nil {
520522
log.Errorf("error writing nw config. Error: %s", err)

netplugin/cluster/cluster.go

100755100644
+2-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ func masterReq(path string, req interface{}, resp interface{}, isDel bool) error
123123
time.Sleep(time.Second)
124124
continue
125125
} else if err != nil {
126-
log.Errorf("Error making %s request: Err: %v", reqType, err)
126+
log.Errorf("Error making %s request: Err: %v"+
127+
"with resp:%+v", reqType, err, resp)
127128
return err
128129
}
129130

utils/httputils.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func HTTPPost(url string, req interface{}, resp interface{}) error {
131131
return err
132132
}
133133

134-
log.Infof("Results for (%s): %+v\n", url, resp)
134+
log.Debugf("Results for (%s): %+v\n", url, resp)
135135

136136
return nil
137137
}
@@ -160,6 +160,6 @@ func HTTPDel(url string) error {
160160
return fmt.Errorf("HTTP error response. Status: %s, StatusCode: %d", res.Status, res.StatusCode)
161161
}
162162

163-
log.Infof("Results for (%s): %+v\n", url, res)
163+
log.Debugf("Results for (%s): %+v\n", url, res)
164164
return nil
165165
}

utils/netutils/netutils.go

+24
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,30 @@ func GetLocalAddrList() ([]string, error) {
755755
return addrList, err
756756
}
757757

758+
//GetHostLowestLinkMtu return lowest mtu for host interface(excluding ovs
759+
//interface
760+
func GetHostLowestLinkMtu() (int, error) {
761+
762+
lowestMTU := 9000 //Jumbo frame MTU
763+
intfList, err := net.Interfaces()
764+
if err != nil {
765+
return 0, err
766+
}
767+
// Loop thru each interface and add its ip addr to list
768+
for _, intf := range intfList {
769+
if strings.HasPrefix(intf.Name, "docker") || strings.HasPrefix(intf.Name, "veth") ||
770+
strings.HasPrefix(intf.Name, "vport") || strings.HasPrefix(intf.Name, "lo") {
771+
continue
772+
}
773+
774+
lowestMTU = int(math.Min(float64(lowestMTU), float64(intf.MTU)))
775+
}
776+
if lowestMTU == 0 {
777+
return 0, errors.New("Failed to find minimum MTU")
778+
}
779+
return lowestMTU, nil
780+
}
781+
758782
// IsAddrLocal check if an address is local
759783
func IsAddrLocal(findAddr string) bool {
760784
// get the local addr list

0 commit comments

Comments
 (0)