The fix ensures that if odp is not supported (usually due to missing openvswitch, vxlan or vport-vxlan kernel modules), weaver will create the pcap based bridge instead of crashing.
58 lines
1.3 KiB
Go
58 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
|
|
"github.com/weaveworks/weave/common"
|
|
weavenet "github.com/weaveworks/weave/net"
|
|
)
|
|
|
|
func detectBridgeType(args []string) error {
|
|
if len(args) != 2 {
|
|
cmdUsage("detect-bridge-type", "<weave-bridge-name> <datapath-name>")
|
|
}
|
|
bridgeType, err := weavenet.ExistingBridgeType(args[0], args[1])
|
|
if err != nil {
|
|
return err
|
|
} else if bridgeType == nil {
|
|
fmt.Println("none")
|
|
} else {
|
|
fmt.Println(bridgeType.String())
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func createBridge(args []string) error {
|
|
if len(args) != 10 {
|
|
cmdUsage("create-bridge", "<docker-bridge-name> <weave-bridge-name> <datapath-name> <mtu> <port> <mac> <no-fastdp> <no-bridged-fastdp> <proc-path> <expect-npc>")
|
|
}
|
|
|
|
mtu, err := strconv.Atoi(args[3])
|
|
if err != nil && args[3] != "" {
|
|
return err
|
|
}
|
|
port, err := strconv.Atoi(args[4])
|
|
if err != nil {
|
|
return err
|
|
}
|
|
config := weavenet.BridgeConfig{
|
|
DockerBridgeName: args[0],
|
|
WeaveBridgeName: args[1],
|
|
DatapathName: args[2],
|
|
MTU: mtu,
|
|
Port: port,
|
|
Mac: args[5],
|
|
NoFastdp: args[6] != "",
|
|
NoBridgedFastdp: args[7] != "",
|
|
NPC: args[9] == "--expect-npc",
|
|
}
|
|
procPath := args[8]
|
|
bridgeType, err := weavenet.EnsureBridge(procPath, &config, common.Log)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
fmt.Println(bridgeType.String())
|
|
return nil
|
|
}
|