Skip to content

Commit

Permalink
Added windows code and fix copyright.
Browse files Browse the repository at this point in the history
  • Loading branch information
song-jiang committed Aug 8, 2020
1 parent c79ea20 commit cb49d31
Show file tree
Hide file tree
Showing 40 changed files with 4,668 additions and 5 deletions.
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ update-pod2daemon-pin:
###############################################################################
# Building the binary
###############################################################################
build: bin/calico-felix build-bpf
build: bin/calico-felix build-bpf bin/calico-felix.exe
build-all: $(addprefix sub-build-,$(VALIDARCHES))
sub-build-%:
$(MAKE) build ARCH=$*
Expand Down Expand Up @@ -759,6 +759,15 @@ cover-report: combined.coverprofile
bin/calico-felix.transfer-url: bin/calico-felix
$(DOCKER_GO_BUILD) sh -c 'curl --upload-file bin/calico-felix https://transfer.sh/calico-felix > $@'

# Cross-compile Felix for Windows
bin/calico-felix.exe: $(SRC_FILES)
@echo Building felix for Windows...
mkdir -p bin
$(DOCKER_RUN) $(LOCAL_BUILD_MOUNTS) $(CALICO_BUILD) sh -c '$(GIT_CONFIG_SSH) \
GOOS=windows go build -v -o $@ -v $(LDFLAGS) "$(PACKAGE_NAME)/cmd/calico-felix" && \
( ldd $@ 2>&1 | grep -q "Not a valid dynamic program\|not a dynamic executable" || \
( echo "Error: $@ was not statically linked"; false ) )'

.PHONY: patch-script
patch-script: bin/calico-felix.transfer-url
$(DOCKER_GO_BUILD) bash -c 'utils/make-patch-script.sh $$(cat bin/calico-felix.transfer-url)'
Expand Down
2 changes: 2 additions & 0 deletions bpf/bpf.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !windows

// Copyright (c) 2019-2020 Tigera, Inc. All rights reserved.

// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions bpf/bpf_defs.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !windows

// Copyright (c) 2020 Tigera, Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions bpf/bpf_syscall.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !windows

// Copyright (c) 2019-2020 Tigera, Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions bpf/bpf_syscall_stub.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !windows

// Copyright (c) 2019-2020 Tigera, Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
27 changes: 27 additions & 0 deletions bpf/bpf_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// +build windows

// Copyright (c) 2019-2020 Tigera, Inc. All rights reserved.
//
// 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 bpf

import "fmt"

func SyscallSupport() bool {
return false
}

func SupportsBPFDataplane() error {
return fmt.Errorf("BPF dataplane is not supported on Windows")
}
2 changes: 2 additions & 0 deletions bpf/conntrack/map.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !windows

// Copyright (c) 2020 Tigera, Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions bpf/ipsets/map.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !windows

// Copyright (c) 2020 Tigera, Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions bpf/maps.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !windows

// Copyright (c) 2019-2020 Tigera, Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions bpf/mock/map.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !windows

// Copyright (c) 2020 Tigera, Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions bpf/mock_bpf_lib.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !windows

// Copyright (c) 2019-2020 Tigera, Inc. All rights reserved.

// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions bpf/nat/maps.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !windows

// Copyright (c) 2020 Tigera, Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions bpf/routes/map.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !windows

// Copyright (c) 2020 Tigera, Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
49 changes: 49 additions & 0 deletions dataplane/driver_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (c) 2017-2020 Tigera, Inc. All rights reserved.
//
// 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 dataplane

import (
"os/exec"

log "github.com/sirupsen/logrus"
"k8s.io/client-go/kubernetes"

"github.com/projectcalico/felix/config"
windataplane "github.com/projectcalico/felix/dataplane/windows"
"github.com/projectcalico/felix/dataplane/windows/hns"
"github.com/projectcalico/libcalico-go/lib/health"
)

func StartDataplaneDriver(configParams *config.Config,
healthAggregator *health.HealthAggregator,
configChangedRestartCallback func(),
k8sClientSet *kubernetes.Clientset) (DataplaneDriver, *exec.Cmd) {
log.Info("Using Windows dataplane driver.")

dpConfig := windataplane.Config{
IPv6Enabled: configParams.Ipv6Support,
HealthAggregator: healthAggregator,

Hostname: configParams.FelixHostname,
VXLANEnabled: configParams.VXLANEnabled,
VXLANID: configParams.VXLANVNI,
VXLANPort: configParams.VXLANPort,
}

winDP := windataplane.NewWinDataplaneDriver(hns.API{}, dpConfig)
winDP.Start()

return winDP, nil
}
Loading

0 comments on commit cb49d31

Please sign in to comment.