diff --git a/backend/alivpc/alivpc.go b/backend/alivpc/alivpc.go index 1b6b1cedd..14041e8d1 100644 --- a/backend/alivpc/alivpc.go +++ b/backend/alivpc/alivpc.go @@ -18,7 +18,6 @@ package alivpc import ( "encoding/json" "fmt" - "golang.org/x/net/context" "os" "sync" @@ -28,6 +27,7 @@ import ( "github.com/flannel-io/flannel/backend" "github.com/flannel-io/flannel/pkg/ip" "github.com/flannel-io/flannel/subnet" + "golang.org/x/net/context" log "k8s.io/klog" ) diff --git a/backend/alivpc/alivpc_windows.go b/backend/alivpc/alivpc_windows.go index 123f1fcd1..e2c0e1d31 100644 --- a/backend/alivpc/alivpc_windows.go +++ b/backend/alivpc/alivpc_windows.go @@ -13,11 +13,3 @@ // limitations under the License. package alivpc - -import ( - log "k8s.io/klog" -) - -func init() { - log.Infof("AliVpc is not supported on this platform") -} diff --git a/backend/awsvpc/awsvpc.go b/backend/awsvpc/awsvpc.go index 1629629ad..5f4c5110d 100644 --- a/backend/awsvpc/awsvpc.go +++ b/backend/awsvpc/awsvpc.go @@ -26,11 +26,10 @@ import ( "github.com/aws/aws-sdk-go/aws/ec2metadata" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ec2" - "golang.org/x/net/context" - "github.com/flannel-io/flannel/backend" "github.com/flannel-io/flannel/pkg/ip" "github.com/flannel-io/flannel/subnet" + "golang.org/x/net/context" log "k8s.io/klog" ) diff --git a/backend/awsvpc/awsvpc_windows.go b/backend/awsvpc/awsvpc_windows.go index cca820751..48c77d137 100644 --- a/backend/awsvpc/awsvpc_windows.go +++ b/backend/awsvpc/awsvpc_windows.go @@ -13,11 +13,3 @@ // limitations under the License. package awsvpc - -import ( - log "k8s.io/klog" -) - -func init() { - log.Infof("AWS VPC is not supported on this platform") -} diff --git a/backend/common.go b/backend/common.go index 4ee9c6f4f..3505d442f 100644 --- a/backend/common.go +++ b/backend/common.go @@ -18,9 +18,8 @@ import ( "net" "sync" - "golang.org/x/net/context" - "github.com/flannel-io/flannel/subnet" + "golang.org/x/net/context" ) type ExternalInterface struct { diff --git a/backend/gce/gce_windows.go b/backend/gce/gce_windows.go index dd40c87b0..c0ad20238 100644 --- a/backend/gce/gce_windows.go +++ b/backend/gce/gce_windows.go @@ -36,11 +36,3 @@ // SOFTWARE. package gce - -import ( - log "k8s.io/klog" -) - -func init() { - log.Infof("GCE is not supported on this platform") -} diff --git a/backend/hostgw/hostgw.go b/backend/hostgw/hostgw.go index f36702009..d10639d45 100644 --- a/backend/hostgw/hostgw.go +++ b/backend/hostgw/hostgw.go @@ -19,7 +19,6 @@ package hostgw import ( "fmt" - "sync" "github.com/flannel-io/flannel/backend" diff --git a/backend/ipip/ipip_windows.go b/backend/ipip/ipip_windows.go index 41893b5a0..401d391cf 100644 --- a/backend/ipip/ipip_windows.go +++ b/backend/ipip/ipip_windows.go @@ -14,11 +14,3 @@ // +build windows package ipip - -import ( - log "k8s.io/klog" -) - -func init() { - log.Infof("ipip is not supported on this platform") -} diff --git a/backend/ipsec/ipsec_windows.go b/backend/ipsec/ipsec_windows.go index 0a0ef94b6..ec96b64c9 100644 --- a/backend/ipsec/ipsec_windows.go +++ b/backend/ipsec/ipsec_windows.go @@ -13,9 +13,3 @@ // limitations under the License. package ipsec - -import log "k8s.io/klog" - -func init() { - log.Infof("ipsec is not supported on this platform") -} diff --git a/backend/manager.go b/backend/manager.go index 4455466cc..98a170aba 100644 --- a/backend/manager.go +++ b/backend/manager.go @@ -19,9 +19,8 @@ import ( "strings" "sync" - "golang.org/x/net/context" - "github.com/flannel-io/flannel/subnet" + "golang.org/x/net/context" ) var constructors = make(map[string]BackendCtor) diff --git a/backend/route_network.go b/backend/route_network.go index cabd47f71..fb60398e2 100644 --- a/backend/route_network.go +++ b/backend/route_network.go @@ -22,10 +22,9 @@ import ( "sync" "time" - "golang.org/x/net/context" - "github.com/flannel-io/flannel/subnet" "github.com/vishvananda/netlink" + "golang.org/x/net/context" log "k8s.io/klog" ) diff --git a/backend/route_network_windows.go b/backend/route_network_windows.go index de5031269..eebf09e1e 100644 --- a/backend/route_network_windows.go +++ b/backend/route_network_windows.go @@ -19,10 +19,9 @@ import ( "sync" "time" - "golang.org/x/net/context" - "github.com/flannel-io/flannel/pkg/routing" "github.com/flannel-io/flannel/subnet" + "golang.org/x/net/context" log "k8s.io/klog" ) diff --git a/backend/simple_network.go b/backend/simple_network.go index d48e02a85..652a99a18 100644 --- a/backend/simple_network.go +++ b/backend/simple_network.go @@ -15,9 +15,8 @@ package backend import ( - "golang.org/x/net/context" - "github.com/flannel-io/flannel/subnet" + "golang.org/x/net/context" ) type SimpleNetwork struct { diff --git a/backend/tencentvpc/tencentvpc_windows.go b/backend/tencentvpc/tencentvpc_windows.go index 2aacaa1fa..985a6570f 100644 --- a/backend/tencentvpc/tencentvpc_windows.go +++ b/backend/tencentvpc/tencentvpc_windows.go @@ -13,11 +13,3 @@ // limitations under the License. package tencentvpc - -import ( - log "k8s.io/klog" -) - -func init() { - log.Infof("TencentVpc is not supported on this platform") -} diff --git a/backend/udp/udp_amd64.go b/backend/udp/udp_amd64.go index d375bc1af..26e43becc 100644 --- a/backend/udp/udp_amd64.go +++ b/backend/udp/udp_amd64.go @@ -20,11 +20,10 @@ import ( "fmt" "sync" - "golang.org/x/net/context" - "github.com/flannel-io/flannel/backend" "github.com/flannel-io/flannel/pkg/ip" "github.com/flannel-io/flannel/subnet" + "golang.org/x/net/context" ) func init() { diff --git a/backend/udp/udp_network_amd64.go b/backend/udp/udp_network_amd64.go index 7f9d3f778..528f74b18 100644 --- a/backend/udp/udp_network_amd64.go +++ b/backend/udp/udp_network_amd64.go @@ -24,12 +24,11 @@ import ( "sync" "syscall" - "golang.org/x/net/context" - "github.com/flannel-io/flannel/backend" "github.com/flannel-io/flannel/pkg/ip" "github.com/flannel-io/flannel/subnet" "github.com/vishvananda/netlink" + "golang.org/x/net/context" log "k8s.io/klog" ) diff --git a/backend/udp/udp_windows.go b/backend/udp/udp_windows.go index 3e2154b5e..2209dba99 100644 --- a/backend/udp/udp_windows.go +++ b/backend/udp/udp_windows.go @@ -13,11 +13,3 @@ // limitations under the License. package udp - -import ( - log "k8s.io/klog" -) - -func init() { - log.Infof("udp is not supported on this platform") -} diff --git a/backend/vxlan/vxlan.go b/backend/vxlan/vxlan.go index 871aa6bd1..c5bc11160 100644 --- a/backend/vxlan/vxlan.go +++ b/backend/vxlan/vxlan.go @@ -58,11 +58,10 @@ import ( "net" "sync" - "golang.org/x/net/context" - "github.com/flannel-io/flannel/backend" "github.com/flannel-io/flannel/pkg/ip" "github.com/flannel-io/flannel/subnet" + "golang.org/x/net/context" log "k8s.io/klog" ) diff --git a/backend/vxlan/vxlan_network.go b/backend/vxlan/vxlan_network.go index 17c09354a..089831a29 100644 --- a/backend/vxlan/vxlan_network.go +++ b/backend/vxlan/vxlan_network.go @@ -21,12 +21,11 @@ import ( "sync" "syscall" - "golang.org/x/net/context" - "github.com/flannel-io/flannel/backend" "github.com/flannel-io/flannel/pkg/ip" "github.com/flannel-io/flannel/subnet" "github.com/vishvananda/netlink" + "golang.org/x/net/context" log "k8s.io/klog" ) diff --git a/backend/vxlan/vxlan_network_windows.go b/backend/vxlan/vxlan_network_windows.go index 2d8391dbc..4a5d402c6 100644 --- a/backend/vxlan/vxlan_network_windows.go +++ b/backend/vxlan/vxlan_network_windows.go @@ -20,12 +20,11 @@ import ( "strings" "sync" - "golang.org/x/net/context" - "github.com/Microsoft/hcsshim/hcn" "github.com/flannel-io/flannel/backend" "github.com/flannel-io/flannel/pkg/ip" "github.com/flannel-io/flannel/subnet" + "golang.org/x/net/context" log "k8s.io/klog" ) diff --git a/backend/vxlan/vxlan_windows.go b/backend/vxlan/vxlan_windows.go index 1943b226e..e6b94bd5a 100644 --- a/backend/vxlan/vxlan_windows.go +++ b/backend/vxlan/vxlan_windows.go @@ -30,12 +30,11 @@ import ( "net" "sync" - "golang.org/x/net/context" - "github.com/Microsoft/hcsshim/hcn" "github.com/flannel-io/flannel/backend" "github.com/flannel-io/flannel/pkg/ip" "github.com/flannel-io/flannel/subnet" + "golang.org/x/net/context" log "k8s.io/klog" ) diff --git a/main.go b/main.go index d2e524a69..374171514 100644 --- a/main.go +++ b/main.go @@ -311,8 +311,6 @@ func main() { } } - - // Create a backend manager then use it to create the backend and register the network with it. bm := backend.NewManager(ctx, sm, extIface) be, err := bm.GetBackend(config.BackendType) @@ -521,10 +519,13 @@ func LookupExtIface(ifname string, ifregexS string, ipStack int) (*backend.Exter var ifaceAddr net.IP var ifaceV6Addr net.IP var err error + var ifregex *regexp.Regexp - ifregex, err := regexp.Compile(ifregexS) - if err != nil { - return nil, fmt.Errorf("could not compile the IP address regex '%s': %w", ifregexS, err) + if ifregexS != "" { + ifregex, err = regexp.Compile(ifregexS) + if err != nil { + return nil, fmt.Errorf("could not compile the IP address regex '%s': %w", ifregexS, err) + } } // Check ip family stack @@ -565,7 +566,7 @@ func LookupExtIface(ifname string, ifregexS string, ipStack int) (*backend.Exter return nil, fmt.Errorf("error looking up interface %s: %s", ifname, err) } } - } else if len(ifregex) > 0 { + } else if ifregex != nil { // Use the regex if specified and the iface option for matching a specific ip or name is not used ifaces, err := net.Interfaces() if err != nil { @@ -582,12 +583,7 @@ func LookupExtIface(ifname string, ifregexS string, ipStack int) (*backend.Exter continue } - matched, err := ifregex.MatchString(ifaceIP.String()) - if err != nil { - return nil, fmt.Errorf("regex error matching pattern %s to %s", ifregexS, ifaceIP.String()) - } - - if matched { + if ifregex.MatchString(ifaceIP.String()) { ifaceAddr = ifaceIP iface = &ifaceToMatch break @@ -599,12 +595,7 @@ func LookupExtIface(ifname string, ifregexS string, ipStack int) (*backend.Exter continue } - matched, err := ifregex.MatchString(ifaceIP.String()) - if err != nil { - return nil, fmt.Errorf("regex error matching pattern %s to %s", ifregexS, ifaceIP.String()) - } - - if matched { + if ifregex.MatchString(ifaceIP.String()) { ifaceV6Addr = ifaceIP iface = &ifaceToMatch break @@ -616,23 +607,13 @@ func LookupExtIface(ifname string, ifregexS string, ipStack int) (*backend.Exter continue } - matched, err := ifregex.MatchString(ifaceIP.String()) - if err != nil { - return nil, fmt.Errorf("regex error matching pattern %s to %s", ifregexS, ifaceIP.String()) - } - ifaceV6IP, err := ip.GetInterfaceIP6Addr(&ifaceToMatch) if err != nil { // Skip if there is no IPv6 address continue } - v6Matched, err := ifregex.MatchString(ifaceV6IP.String()) - if err != nil { - return nil, fmt.Errorf("regex error matching pattern %s to %s", ifregexS, ifaceIP.String()) - } - - if matched && v6Matched { + if ifregex.MatchString(ifaceIP.String()) && ifregex.MatchString(ifaceV6IP.String()) { ifaceAddr = ifaceIP ifaceV6Addr = ifaceV6IP iface = &ifaceToMatch @@ -644,12 +625,7 @@ func LookupExtIface(ifname string, ifregexS string, ipStack int) (*backend.Exter // Check Name if iface == nil && (ifaceAddr == nil || ifaceV6Addr == nil) { for _, ifaceToMatch := range ifaces { - matched, err := ifregex.MatchString(ifaceToMatch.Name) - if err != nil { - return nil, fmt.Errorf("regex error matching pattern %s to %s", ifregexS, ifaceToMatch.Name) - } - - if matched { + if ifregex.MatchString(ifaceToMatch.Name) { iface = &ifaceToMatch break } diff --git a/network/iptables_windows.go b/network/iptables_windows.go index fe563f8e6..541665cd8 100644 --- a/network/iptables_windows.go +++ b/network/iptables_windows.go @@ -31,21 +31,11 @@ type IPTablesRule struct { rulespec []string } -func MasqRules(ipn ip.IP4Net, lease *subnet.Lease) []IPTablesRule { - return nil -} - -func ForwardRules(flannelNetwork string) []IPTablesRule { - return nil -} - -func SetupAndEnsureIPTables(rules []IPTablesRule, resyncPeriod int) { - -} - -func DeleteIPTables(rules []IPTablesRule) error { - return nil -} - -func teardownIPTables(ipt IPTables, rules []IPTablesRule) { -} +func MasqRules(ipn ip.IP4Net, lease *subnet.Lease) []IPTablesRule { return nil } +func ForwardRules(flannelNetwork string) []IPTablesRule { return nil } +func SetupAndEnsureIPTables(rules []IPTablesRule, resyncPeriod int) {} +func DeleteIPTables(rules []IPTablesRule) error { return nil } +func teardownIPTables(ipt IPTables, rules []IPTablesRule) {} +func SetupAndEnsureIP6Tables(rules []IPTablesRule, resyncPeriod int) {} +func MasqIP6Rules(ipn ip.IP6Net, lease *subnet.Lease) []IPTablesRule { return nil } +func DeleteIP6Tables(rules []IPTablesRule) error { return nil } diff --git a/pkg/ip/iface_windows.go b/pkg/ip/iface_windows.go index e2b498e45..a9f4e6cf8 100644 --- a/pkg/ip/iface_windows.go +++ b/pkg/ip/iface_windows.go @@ -19,8 +19,9 @@ package ip import ( "errors" "fmt" - "github.com/flannel-io/flannel/pkg/powershell" "net" + + "github.com/flannel-io/flannel/pkg/powershell" ) // GetInterfaceIP4Addr returns the IPv4 address for the given network interface @@ -143,3 +144,7 @@ func IsForwardingEnabledForInterface(iface *net.Interface) (bool, error) { return powerShellJsonData.Forwarding == 1, nil } + +func GetInterfaceByIP6(ip net.IP) (*net.Interface, error) { return nil, nil } +func GetInterfaceIP6Addr(iface *net.Interface) (net.IP, error) { return nil, nil } +func GetDefaultV6GatewayInterface() (*net.Interface, error) { return nil, nil } diff --git a/subnet/etcdv2/mock_registry.go b/subnet/etcdv2/mock_registry.go index f33b8e664..fc3ab7a0c 100644 --- a/subnet/etcdv2/mock_registry.go +++ b/subnet/etcdv2/mock_registry.go @@ -20,11 +20,10 @@ import ( "time" etcd "github.com/coreos/etcd/client" - "github.com/jonboulle/clockwork" - "golang.org/x/net/context" - "github.com/flannel-io/flannel/pkg/ip" . "github.com/flannel-io/flannel/subnet" + "github.com/jonboulle/clockwork" + "golang.org/x/net/context" ) var clock clockwork.Clock = clockwork.NewRealClock() diff --git a/subnet/etcdv2/registry_test.go b/subnet/etcdv2/registry_test.go index 81bb551df..ed98b3d17 100644 --- a/subnet/etcdv2/registry_test.go +++ b/subnet/etcdv2/registry_test.go @@ -21,10 +21,9 @@ import ( "time" etcd "github.com/coreos/etcd/client" - "golang.org/x/net/context" - "github.com/flannel-io/flannel/pkg/ip" . "github.com/flannel-io/flannel/subnet" + "golang.org/x/net/context" ) func newTestEtcdRegistry(t *testing.T) (Registry, *mockEtcd) { diff --git a/subnet/watch.go b/subnet/watch.go index 84cea8b0a..8915fd9b1 100644 --- a/subnet/watch.go +++ b/subnet/watch.go @@ -17,9 +17,8 @@ package subnet import ( "time" - "golang.org/x/net/context" - "github.com/flannel-io/flannel/pkg/ip" + "golang.org/x/net/context" log "k8s.io/klog" ) diff --git a/version/version.go b/version/version.go index 2521a30ee..070cfb5b4 100644 --- a/version/version.go +++ b/version/version.go @@ -14,4 +14,4 @@ package version -var Version = "0.5.3+git" +var Version = "dev"