Merge pull request #3043 from weaveworks/issues/fastdp-enosupport-fallback
Fix fallback to pcap based bridge when odp is not supported
This commit is contained in:
commit
b79cc948b3
3 files changed
+15
-8
No files matched your search
+12
-6
@@ -62,7 +62,8 @@ type Bridge interface {
|
|||||||
String() string // human-readable type string
|
String() string // human-readable type string
|
||||||
}
|
}
|
||||||
|
|
||||||
var errBridgeFallback = errors.New("special error value used to trigger a fallback to bridge type")
|
// Used to indicate a fallback to the Bridge type
|
||||||
|
var errBridgeNotSupported = errors.New("bridge not supported")
|
||||||
|
|
||||||
type bridgeImpl struct{ bridge netlink.Link }
|
type bridgeImpl struct{ bridge netlink.Link }
|
||||||
type fastdpImpl struct{ datapathName string }
|
type fastdpImpl struct{ datapathName string }
|
||||||
@@ -226,7 +227,7 @@ func (config *BridgeConfig) configuredBridgeType() Bridge {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func EnsureBridge(procPath string, config *BridgeConfig) (Bridge, error) {
|
func EnsureBridge(procPath string, config *BridgeConfig, log *logrus.Logger) (Bridge, error) {
|
||||||
bridgeType, err := ExistingBridgeType(config.WeaveBridgeName, config.DatapathName)
|
bridgeType, err := ExistingBridgeType(config.WeaveBridgeName, config.DatapathName)
|
||||||
if bridgeType != nil || err != nil {
|
if bridgeType != nil || err != nil {
|
||||||
return bridgeType, err
|
return bridgeType, err
|
||||||
@@ -235,7 +236,8 @@ func EnsureBridge(procPath string, config *BridgeConfig) (Bridge, error) {
|
|||||||
bridgeType = config.configuredBridgeType()
|
bridgeType = config.configuredBridgeType()
|
||||||
for {
|
for {
|
||||||
if err := bridgeType.init(config); err != nil {
|
if err := bridgeType.init(config); err != nil {
|
||||||
if err == errBridgeFallback {
|
if errors.Cause(err) == errBridgeNotSupported {
|
||||||
|
log.Warnf("Skipping bridge creation of %q due to: %s", bridgeType, err)
|
||||||
bridgeType = bridgeImpl{}
|
bridgeType = bridgeImpl{}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -333,12 +335,16 @@ func (b bridgeImpl) init(config *BridgeConfig) error {
|
|||||||
|
|
||||||
func (f fastdpImpl) init(config *BridgeConfig) error {
|
func (f fastdpImpl) init(config *BridgeConfig) error {
|
||||||
odpSupported, err := odp.CreateDatapath(f.datapathName)
|
odpSupported, err := odp.CreateDatapath(f.datapathName)
|
||||||
|
if !odpSupported {
|
||||||
|
msg := ""
|
||||||
|
if err != nil {
|
||||||
|
msg = err.Error()
|
||||||
|
}
|
||||||
|
return errors.Wrap(errBridgeNotSupported, msg)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "creating datapath %q", f.datapathName)
|
return errors.Wrapf(err, "creating datapath %q", f.datapathName)
|
||||||
}
|
}
|
||||||
if !odpSupported {
|
|
||||||
return errBridgeFallback
|
|
||||||
}
|
|
||||||
datapath, err := netlink.LinkByName(f.datapathName)
|
datapath, err := netlink.LinkByName(f.datapathName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "finding datapath %q", f.datapathName)
|
return errors.Wrapf(err, "finding datapath %q", f.datapathName)
|
||||||
|
|||||||
+1
-1
@@ -282,7 +282,7 @@ func main() {
|
|||||||
name := peerName(routerName, bridgeConfig.WeaveBridgeName, dbPrefix, hostRoot)
|
name := peerName(routerName, bridgeConfig.WeaveBridgeName, dbPrefix, hostRoot)
|
||||||
|
|
||||||
bridgeConfig.Mac = name.String()
|
bridgeConfig.Mac = name.String()
|
||||||
bridgeType, err := weavenet.EnsureBridge(procPath, &bridgeConfig)
|
bridgeType, err := weavenet.EnsureBridge(procPath, &bridgeConfig, Log)
|
||||||
checkFatal(err)
|
checkFatal(err)
|
||||||
Log.Println("Bridge type is", bridgeType)
|
Log.Println("Bridge type is", bridgeType)
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/weaveworks/weave/common"
|
||||||
weavenet "github.com/weaveworks/weave/net"
|
weavenet "github.com/weaveworks/weave/net"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -47,7 +48,7 @@ func createBridge(args []string) error {
|
|||||||
NPC: args[9] == "--expect-npc",
|
NPC: args[9] == "--expect-npc",
|
||||||
}
|
}
|
||||||
procPath := args[8]
|
procPath := args[8]
|
||||||
bridgeType, err := weavenet.EnsureBridge(procPath, &config)
|
bridgeType, err := weavenet.EnsureBridge(procPath, &config, common.Log)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user