Skip to content

Commit

Permalink
Merge pull request #1142 from unclejack/1.1.9-backports
Browse files Browse the repository at this point in the history
backport fixes for the 1.1.9 release
  • Loading branch information
unclejack authored Jun 4, 2018
2 parents 4aec51c + e4f45c5 commit 57418e1
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 13 deletions.
24 changes: 17 additions & 7 deletions drivers/ovsd/ovsSwitch.go
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ const (

// OvsSwitch represents on OVS bridge instance
type OvsSwitch struct {
bridgeName string
netType string
uplinkDb cmap.ConcurrentMap
ovsdbDriver *OvsdbDriver
ofnetAgent *ofnet.OfnetAgent
hostPvtNW int
bridgeName string
netType string
uplinkDb cmap.ConcurrentMap
ovsdbDriver *OvsdbDriver
ofnetAgent *ofnet.OfnetAgent
hostPvtNW int
vxlanEncapMtu int
}

// getPvtIP returns a private IP for the port
Expand Down Expand Up @@ -100,6 +101,10 @@ func NewOvsSwitch(bridgeName, netType, localIP, fwdMode string,
sw.netType = netType
sw.uplinkDb = cmap.New()
sw.hostPvtNW = hostPvtNW
sw.vxlanEncapMtu, err = netutils.GetHostLowestLinkMtu()
if err != nil {
log.Fatalf("Failed to get Host Node MTU. Err: %v", err)
}

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

// Set the link mtu to 1450 to allow for 50 bytes vxlan encap
// (inner eth header(14) + outer IP(20) outer UDP(8) + vxlan header(8))
err = setLinkMtu(intfName, vxlanEndpointMtu)
if sw.netType == "vxlan" {
correctMtu := sw.vxlanEncapMtu - 50 //Include Vxlan header size
err = setLinkMtu(intfName, correctMtu)
} else {
err = setLinkMtu(intfName, sw.vxlanEncapMtu)
}
if err != nil {
log.Errorf("Error setting link %s mtu. Err: %v", intfName, err)
return err
Expand Down
11 changes: 11 additions & 0 deletions mgmtfn/dockplugin/ipamDriver.go
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,17 @@ func releaseAddress(w http.ResponseWriter, r *http.Request) {

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

//Build an release request to be sent to master
releaseReq := master.AddressReleaseRequest{
NetworkID: areq.PoolID,
IPv4Address: areq.Address,
}
var releaseResp master.AddressReleaseResponse
if err = cluster.MasterPostReq("/plugin/releaseAddress",
&releaseReq, &releaseResp); err != nil {
httpError(w, "master failed to release request", err)
return
}
// response
relResp := api.ReleaseAddressResponse{}

Expand Down
4 changes: 2 additions & 2 deletions mgmtfn/dockplugin/netDriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@ func createEndpoint(hostname string) func(http.ResponseWriter, *http.Request) {
return
}

log.Infof("CreateEndpointRequest: %+v. Interface: %+v", cereq, cereq.Interface)

tenantName, netName, serviceName, err := GetDockerNetworkName(cereq.NetworkID)
if err != nil {
log.Errorf("Error getting network name for UUID: %s. Err: %v", cereq.NetworkID, err)
Expand All @@ -213,6 +211,8 @@ func createEndpoint(hostname string) func(http.ResponseWriter, *http.Request) {
},
}

log.Infof("CreateEndpointRequest: %+v. Interface: %+v", mreq, cereq.Interface)

var mresp master.CreateEndpointResponse
err = cluster.MasterPostReq("/plugin/createEndpoint", &mreq, &mresp)
if err != nil {
Expand Down
Empty file modified netmaster/daemon/daemon.go
100755 → 100644
Empty file.
3 changes: 3 additions & 0 deletions netmaster/master/api.go
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ type AddressReleaseRequest struct {
NetworkID string // Unique identifier for the network
IPv4Address string // Allocated address
}
type AddressReleaseResponse struct {
Status string
}

// CreateEndpointRequest has the endpoint create request from netplugin
type CreateEndpointRequest struct {
Expand Down
4 changes: 3 additions & 1 deletion netmaster/master/network.go
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,11 @@ func networkReleaseAddress(nwCfg *mastercfg.CfgNetworkState, epgCfg *mastercfg.E
nwCfg.EpAddrCount--
}
nwCfg.IPAllocMap.Clear(ipAddrValue)
log.Infof("Releasing IP Address: %v"+
"from networkId:%+v", ipAddrValue,
nwCfg.NetworkName)
}
}

err := nwCfg.Write()
if err != nil {
log.Errorf("error writing nw config. Error: %s", err)
Expand Down
3 changes: 2 additions & 1 deletion netplugin/cluster/cluster.go
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ func masterReq(path string, req interface{}, resp interface{}, isDel bool) error
time.Sleep(time.Second)
continue
} else if err != nil {
log.Errorf("Error making %s request: Err: %v", reqType, err)
log.Errorf("Error making %s request: Err: %v"+
"with resp:%+v", reqType, err, resp)
return err
}

Expand Down
4 changes: 2 additions & 2 deletions utils/httputils.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func HTTPPost(url string, req interface{}, resp interface{}) error {
return err
}

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

return nil
}
Expand Down Expand Up @@ -160,6 +160,6 @@ func HTTPDel(url string) error {
return fmt.Errorf("HTTP error response. Status: %s, StatusCode: %d", res.Status, res.StatusCode)
}

log.Infof("Results for (%s): %+v\n", url, res)
log.Debugf("Results for (%s): %+v\n", url, res)
return nil
}
24 changes: 24 additions & 0 deletions utils/netutils/netutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,30 @@ func GetLocalAddrList() ([]string, error) {
return addrList, err
}

//GetHostLowestLinkMtu return lowest mtu for host interface(excluding ovs
//interface
func GetHostLowestLinkMtu() (int, error) {

lowestMTU := 9000 //Jumbo frame MTU
intfList, err := net.Interfaces()
if err != nil {
return 0, err
}
// Loop thru each interface and add its ip addr to list
for _, intf := range intfList {
if strings.HasPrefix(intf.Name, "docker") || strings.HasPrefix(intf.Name, "veth") ||
strings.HasPrefix(intf.Name, "vport") || strings.HasPrefix(intf.Name, "lo") {
continue
}

lowestMTU = int(math.Min(float64(lowestMTU), float64(intf.MTU)))
}
if lowestMTU == 0 {
return 0, errors.New("Failed to find minimum MTU")
}
return lowestMTU, nil
}

// IsAddrLocal check if an address is local
func IsAddrLocal(findAddr string) bool {
// get the local addr list
Expand Down

0 comments on commit 57418e1

Please sign in to comment.