From 11dce34b4ea62d1b3d3a6f5a0743b2a97b914954 Mon Sep 17 00:00:00 2001 From: Manuel Buil Date: Wed, 20 Oct 2021 12:01:40 +0200 Subject: [PATCH] Update to the newest flannel Fixes issues such as the internode connectivity Signed-off-by: Manuel Buil --- go.mod | 2 +- go.sum | 4 +-- pkg/agent/flannel/setup.go | 1 + .../flannel/backend/vxlan/device.go | 12 +++++-- .../flannel-io/flannel/pkg/mac/mac.go | 35 +++++++++++++++++++ vendor/modules.txt | 3 +- 6 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 vendor/github.com/flannel-io/flannel/pkg/mac/mac.go diff --git a/go.mod b/go.mod index 80c2f8b6e3..2cf60ac939 100644 --- a/go.mod +++ b/go.mod @@ -78,7 +78,7 @@ require ( github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f github.com/docker/docker v20.10.5+incompatible github.com/erikdubbelboer/gspt v0.0.0-20190125194910-e68493906b83 - github.com/flannel-io/flannel v0.14.1-0.20210827074410-fca1560c91cc + github.com/flannel-io/flannel v0.15.1 github.com/go-bindata/go-bindata v3.1.2+incompatible github.com/go-sql-driver/mysql v1.4.1 github.com/golangplus/testing v1.0.0 // indirect diff --git a/go.sum b/go.sum index a23a30fdc3..f377f6a67d 100644 --- a/go.sum +++ b/go.sum @@ -263,8 +263,8 @@ github.com/fatih/camelcase v1.0.0 h1:hxNvNX/xYBp0ovncs8WyWZrOrpBNub/JfaMvbURyft8 github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= -github.com/flannel-io/flannel v0.14.1-0.20210827074410-fca1560c91cc h1:t/L/tIYcAayH7XICVYtAscY/PXaJDKXsKheAMCtiKS0= -github.com/flannel-io/flannel v0.14.1-0.20210827074410-fca1560c91cc/go.mod h1:fIcQpjXVBEE22oxqfZN0cXN0ZInsMDqTF5YoeGo6DgY= +github.com/flannel-io/flannel v0.15.1 h1:9v5/fapXePDnXVsFBVnji4IeLoXcO81bO8nEbQioYVQ= +github.com/flannel-io/flannel v0.15.1/go.mod h1:fIcQpjXVBEE22oxqfZN0cXN0ZInsMDqTF5YoeGo6DgY= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/form3tech-oss/jwt-go v3.2.2+incompatible h1:TcekIExNqud5crz4xD2pavyTgWiPvpYe4Xau31I0PRk= diff --git a/pkg/agent/flannel/setup.go b/pkg/agent/flannel/setup.go index 542082a777..79b16ec062 100644 --- a/pkg/agent/flannel/setup.go +++ b/pkg/agent/flannel/setup.go @@ -2,6 +2,7 @@ package flannel import ( "context" + "errors" "fmt" "net" "os" diff --git a/vendor/github.com/flannel-io/flannel/backend/vxlan/device.go b/vendor/github.com/flannel-io/flannel/backend/vxlan/device.go index 3fa215e96e..1bf2dbc876 100644 --- a/vendor/github.com/flannel-io/flannel/backend/vxlan/device.go +++ b/vendor/github.com/flannel-io/flannel/backend/vxlan/device.go @@ -13,7 +13,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// +build !windows package vxlan @@ -24,6 +23,7 @@ import ( "github.com/containernetworking/plugins/pkg/utils/sysctl" "github.com/flannel-io/flannel/pkg/ip" + "github.com/flannel-io/flannel/pkg/mac" "github.com/vishvananda/netlink" log "k8s.io/klog" ) @@ -44,9 +44,15 @@ type vxlanDevice struct { } func newVXLANDevice(devAttrs *vxlanDeviceAttrs) (*vxlanDevice, error) { + hardwareAddr, err := mac.NewHardwareAddr() + if err != nil { + return nil, err + } + link := &netlink.Vxlan{ LinkAttrs: netlink.LinkAttrs{ - Name: devAttrs.name, + Name: devAttrs.name, + HardwareAddr: hardwareAddr, }, VxlanId: int(devAttrs.vni), VtepDevIndex: devAttrs.vtepIndex, @@ -56,7 +62,7 @@ func newVXLANDevice(devAttrs *vxlanDeviceAttrs) (*vxlanDevice, error) { GBP: devAttrs.gbp, } - link, err := ensureLink(link) + link, err = ensureLink(link) if err != nil { return nil, err } diff --git a/vendor/github.com/flannel-io/flannel/pkg/mac/mac.go b/vendor/github.com/flannel-io/flannel/pkg/mac/mac.go new file mode 100644 index 0000000000..b88f3e1f4e --- /dev/null +++ b/vendor/github.com/flannel-io/flannel/pkg/mac/mac.go @@ -0,0 +1,35 @@ +// Copyright 2021 flannel authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package mac + +import ( + "crypto/rand" + "fmt" + "net" +) + +// NewHardwareAddr generates a new random hardware (MAC) address, local and +// unicast. +func NewHardwareAddr() (net.HardwareAddr, error) { + hardwareAddr := make(net.HardwareAddr, 6) + if _, err := rand.Read(hardwareAddr); err != nil { + return nil, fmt.Errorf("could not generate random MAC address: %w", err) + } + + // Ensure that address is locally administered and unicast. + hardwareAddr[0] = (hardwareAddr[0] & 0xfe) | 0x02 + + return hardwareAddr, nil +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 22a81025c8..4284a35394 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -490,7 +490,7 @@ github.com/evanphx/json-patch github.com/exponent-io/jsonpath # github.com/fatih/camelcase v1.0.0 github.com/fatih/camelcase -# github.com/flannel-io/flannel v0.14.1-0.20210827074410-fca1560c91cc +# github.com/flannel-io/flannel v0.15.1 ## explicit github.com/flannel-io/flannel/backend github.com/flannel-io/flannel/backend/extension @@ -499,6 +499,7 @@ github.com/flannel-io/flannel/backend/ipsec github.com/flannel-io/flannel/backend/vxlan github.com/flannel-io/flannel/network github.com/flannel-io/flannel/pkg/ip +github.com/flannel-io/flannel/pkg/mac github.com/flannel-io/flannel/pkg/powershell github.com/flannel-io/flannel/pkg/routing github.com/flannel-io/flannel/subnet