Skip to content
This repository has been archived by the owner on Jul 1, 2023. It is now read-only.

Update fork with upstream fixes/changes #11

Merged
merged 6 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions backend/alivpc/alivpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// 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.
//go:build !windows
// +build !windows

package alivpc
Expand Down
1 change: 1 addition & 0 deletions backend/awsvpc/awsvpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// 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.
//go:build !windows
// +build !windows

package awsvpc
Expand Down
1 change: 1 addition & 0 deletions backend/awsvpc/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// 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.
//go:build !windows
// +build !windows

package awsvpc
Expand Down
9 changes: 5 additions & 4 deletions backend/extension/extension_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ func (n *network) Run(ctx context.Context) {

for {
select {
case evtBatch := <-evts:
case evtBatch, ok := <-evts:
if !ok {
log.Infof("evts chan closed")
return
}
n.handleSubnetEvents(evtBatch)

case <-ctx.Done():
return
}
}
}
Expand Down
1 change: 1 addition & 0 deletions backend/gce/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// 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.
//go:build !windows
// +build !windows

package gce
Expand Down
1 change: 1 addition & 0 deletions backend/gce/gce.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//go:build !windows
// +build !windows

package gce
Expand Down
1 change: 1 addition & 0 deletions backend/gce/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// 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.
//go:build !windows
// +build !windows

package gce
Expand Down
4 changes: 2 additions & 2 deletions backend/hostgw/hostgw.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// +build !windows
//go:build !windows && !windows
// +build !windows,!windows

// Copyright 2015 flannel authors
//
Expand All @@ -13,7 +14,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 hostgw

Expand Down
4 changes: 2 additions & 2 deletions backend/hostgw/hostgw_windows.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// +build windows
//go:build windows && windows
// +build windows,windows

// Copyright 2015 flannel authors
//
Expand All @@ -13,7 +14,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 hostgw

Expand Down
7 changes: 4 additions & 3 deletions backend/ipip/ipip.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !windows
// +build !windows

// Copyright 2017 flannel authors
Expand Down Expand Up @@ -89,7 +90,7 @@ func (be *IPIPBackend) RegisterNetwork(ctx context.Context, wg *sync.WaitGroup,
return nil, fmt.Errorf("failed to acquire lease: %v", err)
}

link, err := be.configureIPIPDevice(n.SubnetLease)
link, err := be.configureIPIPDevice(n.SubnetLease, config.Network)

if err != nil {
return nil, err
Expand Down Expand Up @@ -124,7 +125,7 @@ func (be *IPIPBackend) RegisterNetwork(ctx context.Context, wg *sync.WaitGroup,
return n, nil
}

func (be *IPIPBackend) configureIPIPDevice(lease *subnet.Lease) (*netlink.Iptun, error) {
func (be *IPIPBackend) configureIPIPDevice(lease *subnet.Lease, flannelnet ip.IP4Net) (*netlink.Iptun, error) {
// When modprobe ipip module, a tunl0 ipip device is created automatically per network namespace by ipip kernel module.
// It is the namespace default IPIP device with attributes local=any and remote=any.
// When receiving IPIP protocol packets, kernel will forward them to tunl0 as a fallback device
Expand Down Expand Up @@ -196,7 +197,7 @@ func (be *IPIPBackend) configureIPIPDevice(lease *subnet.Lease) (*netlink.Iptun,
// Ensure that the device has a /32 address so that no broadcast routes are created.
// This IP is just used as a source address for host to workload traffic (so
// the return path for the traffic has an address on the flannel network to use as the destination)
if err := ip.EnsureV4AddressOnLink(ip.IP4Net{IP: lease.Subnet.IP, PrefixLen: 32}, link); err != nil {
if err := ip.EnsureV4AddressOnLink(ip.IP4Net{IP: lease.Subnet.IP, PrefixLen: 32}, flannelnet, link); err != nil {
return nil, fmt.Errorf("failed to ensure address of interface %s: %s", link.Attrs().Name, err)
}

Expand Down
1 change: 1 addition & 0 deletions backend/ipip/ipip_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// 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.
//go:build windows
// +build windows

package ipip
Expand Down
1 change: 1 addition & 0 deletions backend/ipsec/handle_charon.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// 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.
//go:build !windows
// +build !windows

package ipsec
Expand Down
1 change: 1 addition & 0 deletions backend/ipsec/handle_xfrm.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// 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.
//go:build !windows
// +build !windows

package ipsec
Expand Down
1 change: 1 addition & 0 deletions backend/ipsec/ipsec.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// 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.
//go:build !windows
// +build !windows

package ipsec
Expand Down
10 changes: 6 additions & 4 deletions backend/ipsec/ipsec_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// 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.
//go:build !windows
// +build !windows

package ipsec
Expand Down Expand Up @@ -95,12 +96,13 @@ func (n *network) Run(ctx context.Context) {

for {
select {
case evtsBatch := <-evts:
case evtsBatch, ok := <-evts:
if !ok {
log.Infof("evts chan closed")
return
}
log.Info("Handling event")
n.handleSubnetEvents(evtsBatch)
case <-ctx.Done():
log.Info("Received DONE")
return
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions backend/route_network.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !windows
// +build !windows

// Copyright 2017 flannel authors
Expand Down Expand Up @@ -69,11 +70,12 @@ func (n *RouteNetwork) Run(ctx context.Context) {

for {
select {
case evtBatch := <-evts:
case evtBatch, ok := <-evts:
if !ok {
log.Infof("evts chan closed")
return
}
n.handleSubnetEvents(evtBatch)

case <-ctx.Done():
return
}
}
}
Expand Down
1 change: 1 addition & 0 deletions backend/route_network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// 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.
//go:build !windows
// +build !windows

package backend
Expand Down
22 changes: 14 additions & 8 deletions backend/vxlan/device.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !windows
// +build !windows

// Copyright 2015 flannel authors
Expand All @@ -13,7 +14,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

Expand All @@ -22,11 +22,11 @@ import (
"net"
"syscall"

log "github.com/golang/glog"
"github.com/vishvananda/netlink"

"github.com/containernetworking/plugins/pkg/utils/sysctl"
"github.com/coreos/flannel/pkg/ip"
"github.com/coreos/flannel/pkg/mac"
log "github.com/golang/glog"
"github.com/vishvananda/netlink"
)

type vxlanDeviceAttrs struct {
Expand All @@ -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,
Expand All @@ -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
}
Expand Down Expand Up @@ -112,8 +118,8 @@ func ensureLink(vxlan *netlink.Vxlan) (*netlink.Vxlan, error) {
return vxlan, nil
}

func (dev *vxlanDevice) Configure(ipn ip.IP4Net) error {
if err := ip.EnsureV4AddressOnLink(ipn, dev.link); err != nil {
func (dev *vxlanDevice) Configure(ipa ip.IP4Net, flannelnet ip.IP4Net) error {
if err := ip.EnsureV4AddressOnLink(ipa, flannelnet, dev.link); err != nil {
return fmt.Errorf("failed to ensure address of interface %s: %s", dev.link.Attrs().Name, err)
}

Expand Down
3 changes: 2 additions & 1 deletion backend/vxlan/vxlan.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// 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.
//go:build !windows
// +build !windows

package vxlan
Expand Down Expand Up @@ -152,7 +153,7 @@ func (be *VXLANBackend) RegisterNetwork(ctx context.Context, wg *sync.WaitGroup,
// Ensure that the device has a /32 address so that no broadcast routes are created.
// This IP is just used as a source address for host to workload traffic (so
// the return path for the traffic has an address on the flannel network to use as the destination)
if err := dev.Configure(ip.IP4Net{IP: lease.Subnet.IP, PrefixLen: 32}); err != nil {
if err := dev.Configure(ip.IP4Net{IP: lease.Subnet.IP, PrefixLen: 32}, config.Network); err != nil {
return nil, fmt.Errorf("failed to configure interface %s: %s", dev.link.Attrs().Name, err)
}

Expand Down
10 changes: 6 additions & 4 deletions backend/vxlan/vxlan_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// 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.
//go:build !windows
// +build !windows

package vxlan
Expand Down Expand Up @@ -70,11 +71,12 @@ func (nw *network) Run(ctx context.Context) {

for {
select {
case evtBatch := <-events:
case evtBatch, ok := <-events:
if !ok {
log.Infof("evts chan closed")
return
}
nw.handleSubnetEvents(evtBatch)

case <-ctx.Done():
return
}
}
}
Expand Down
1 change: 1 addition & 0 deletions backend/vxlan/vxlan_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// 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.
//go:build windows
// +build windows

package vxlan
Expand Down
14 changes: 7 additions & 7 deletions dist/functional-test-k8s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ test_vxlan() {
pings
}

if [[ ${ARCH} == "amd64" ]]; then
test_udp() {
start_flannel udp
create_ping_dest # creates ping_dest1 and ping_dest2 variables
pings
}
fi
#if [[ ${ARCH} == "amd64" ]]; then
#test_udp() {
# start_flannel udp
# create_ping_dest # creates ping_dest1 and ping_dest2 variables
# pings
#}
#fi

test_host-gw() {
start_flannel host-gw
Expand Down
28 changes: 14 additions & 14 deletions dist/functional-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ test_vxlan_ping() {
pings
}

if [[ ${ARCH} == "amd64" ]]; then
test_udp_ping() {
write_config_etcd udp
create_ping_dest # creates ping_dest1 and ping_dest2 variables
pings
}
fi
#if [[ ${ARCH} == "amd64" ]]; then
#test_udp_ping() {
# write_config_etcd udp
# create_ping_dest # creates ping_dest1 and ping_dest2 variables
# pings
#}
#fi

test_hostgw_ping() {
write_config_etcd host-gw
Expand Down Expand Up @@ -135,13 +135,13 @@ test_vxlan_perf() {
perf
}

if [[ ${ARCH} == "amd64" ]]; then
test_udp_perf() {
write_config_etcd udp
create_ping_dest
perf
}
fi
#if [[ ${ARCH} == "amd64" ]]; then
#test_udp_perf() {
# write_config_etcd udp
# create_ping_dest
# perf
#}
#fi

test_ipip_perf() {
write_config_etcd ipip
Expand Down
Loading