Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leverage govpp templates from vpplink #430

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@ vpp-manager/images/*/vpp-manager
vpp-manager/images/*/vppdev.sh
vpp-manager/vpp_build/
*.deb
vpplink/binapi/bin/
multinet-monitor/watcher

test/k8s-e2e-tests/kubernetes-*
test/vagrant/local-config.env
test/vagrant/.vagrant

# cherry-pick patch caching
vpplink/binapi/.cherries-cache

# Test outputs
*.out
*.test
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ restart-calicovpp:
.PHONY: goapi
export VPP_DIR ?= $(shell pwd)/vpp-manager/vpp_build
goapi:
@./vpplink/binapi/generate_binapi.sh
@go generate -v ./vpplink/generated/

.PHONY: cherry-vpp
cherry-vpp:
Expand All @@ -157,7 +157,7 @@ cherry-vpp:
@echo "directory : ${VPP_DIR}"
@echo "branch : $(shell cd ${VPP_DIR} && git branch --show-current)"
@echo "Are you sure? [y/N] " && read ans && [ $${ans:-N} = y ]
@bash ./vpplink/binapi/vpp_clone_current.sh ${VPP_DIR}
@bash ./vpplink/generated/vpp_clone_current.sh ${VPP_DIR}
@make goapi

.PHONY: cherry-wipe
Expand Down Expand Up @@ -196,7 +196,7 @@ run-integration-tests:

.PHONY: test
test:
gofmt -s -l . | grep -v binapi | grep -v vpp_build | diff -u /dev/null -
gofmt -s -l . | grep -v generated | grep -v vpp_build | diff -u /dev/null -
go vet ./...
go test ./...

Expand Down
2 changes: 1 addition & 1 deletion calico-vpp-agent/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

TAG ?= latest # Tag images with :$(TAG)
ALSO_LATEST ?= n # If 'y' also tag images with :latest
GENERATE_LOG_FILE=../vpplink/binapi/vppapi/generate.log
GENERATE_LOG_FILE=../vpplink/generated/generate.log
VERSION_FILE=version

all: build gobgp image
Expand Down
4 changes: 2 additions & 2 deletions calico-vpp-agent/cmd/api-proxy/felix-api-proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"os"
"time"

"github.com/projectcalico/vpp-dataplane/config/config"
"github.com/projectcalico/vpp-dataplane/config"
"github.com/sirupsen/logrus"
"gopkg.in/tomb.v2"
)
Expand All @@ -38,7 +38,7 @@ func main() {
var err error

log := logrus.New()
config.LoadConfig(log)
config.LoadConfigSilent(log)

inFile := os.NewFile(3, "pipe1")
outFile := os.NewFile(4, "pipe2")
Expand Down
8 changes: 3 additions & 5 deletions calico-vpp-agent/cmd/calico_vpp_dataplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
"github.com/projectcalico/vpp-dataplane/calico-vpp-agent/prometheus"
"github.com/projectcalico/vpp-dataplane/calico-vpp-agent/routing"
"github.com/projectcalico/vpp-dataplane/calico-vpp-agent/services"
"github.com/projectcalico/vpp-dataplane/config/config"
"github.com/projectcalico/vpp-dataplane/config"

"github.com/projectcalico/vpp-dataplane/calico-vpp-agent/watchers"
)
Expand Down Expand Up @@ -70,8 +70,6 @@ func main() {
if err != nil {
log.Fatalf("Error loading configuration: %v", err)
}
config.PrintAgentConfig(log)
log.SetLevel(config.LogLevel)

err = common.WritePidToFile()
if err != nil {
Expand Down Expand Up @@ -170,7 +168,7 @@ func main() {
*/
log.Infof("Waiting for felix config being present...")

if config.MultinetEnabled {
if *config.GetCalicoVppFeatureGates().MultinetEnabled {
Go(netWatcher.WatchNetworks)
<-netWatcher.InSync
log.Infof("Networks synced")
Expand All @@ -191,7 +189,7 @@ func main() {
Go(prometheusServer.ServePrometheus)

// watch LocalSID if SRv6 is enabled
if config.EnableSRv6 {
if *config.GetCalicoVppFeatureGates().SRv6Enabled {
Go(localSIDWatcher.WatchLocalSID)
}

Expand Down
2 changes: 1 addition & 1 deletion calico-vpp-agent/cmd/debug-state/debug-state.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"fmt"

"github.com/projectcalico/vpp-dataplane/calico-vpp-agent/cni/storage"
"github.com/projectcalico/vpp-dataplane/config/config"
"github.com/projectcalico/vpp-dataplane/config"
log "github.com/sirupsen/logrus"
)

Expand Down
39 changes: 20 additions & 19 deletions calico-vpp-agent/cni/cni_node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"testing"
"time"

vpptypes "github.com/calico-vpp/vpplink/api/v0"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
gs "github.com/onsi/gomega/gstruct"
Expand All @@ -40,10 +41,10 @@ import (
"github.com/projectcalico/vpp-dataplane/calico-vpp-agent/proto"
"github.com/projectcalico/vpp-dataplane/calico-vpp-agent/tests/mocks"
"github.com/projectcalico/vpp-dataplane/calico-vpp-agent/tests/mocks/calico"
agentConf "github.com/projectcalico/vpp-dataplane/config/config"
agentConf "github.com/projectcalico/vpp-dataplane/config"
"github.com/projectcalico/vpp-dataplane/vpplink"
"github.com/projectcalico/vpp-dataplane/vpplink/binapi/vppapi/interface_types"
"github.com/projectcalico/vpp-dataplane/vpplink/binapi/vppapi/ip_types"
"github.com/projectcalico/vpp-dataplane/vpplink/generated/bindings/interface_types"
"github.com/projectcalico/vpp-dataplane/vpplink/generated/bindings/ip_types"
"github.com/projectcalico/vpp-dataplane/vpplink/types"
"github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -200,15 +201,15 @@ var _ = Describe("Node-related functionality of CNI", func() {
})

// Enables IPSec (=uses IPSec over IPIP tunnel and not pure IPIP tunnel)
agentConf.EnableIPSec = true
agentConf.GetCalicoVppFeatureGates().IPSecEnabled = &agentConf.True

// setup PubSub handler to catch TunnelAdded events
pubSubHandlerMock = mocks.NewPubSubHandlerMock(common.TunnelAdded)
pubSubHandlerMock.Start()

// setting Ikev2 PreShared Key to non-empty string as VPP fails with empty string
// (empty preshared key = no IPSec security => makes no sense => VPP gives configuration error)
agentConf.IPSecIkev2Psk = "testing-preshared-key-for-IPSec"
*agentConf.IPSecIkev2Psk = "testing-preshared-key-for-IPSec"
})

// TODO test IPSec tunnel delete
Expand Down Expand Up @@ -247,7 +248,7 @@ var _ = Describe("Node-related functionality of CNI", func() {
"Failed to get IP-IP tunnels from VPP (for IPSec checking)")
ipipSwIfIndex, err := vpp.SearchInterfaceWithName("ipip0")
Expect(err).ToNot(HaveOccurred(), "can't find ipip tunnel interface")
backendIPIPTunnel := &types.IPIPTunnel{
backendIPIPTunnel := &vpptypes.IPIPTunnel{
Src: net.ParseIP(ThisNodeIP).To4(),
Dst: net.ParseIP(AddedNodeIP).To4(),
TableID: 0, // not filled -> used default VRF table
Expand Down Expand Up @@ -288,7 +289,7 @@ var _ = Describe("Node-related functionality of CNI", func() {
"Name": Equal(connectivity.NewIpsecTunnel(backendIPIPTunnel).Profile()),
"TunItf": Equal(ipipSwIfIndex),
"Auth": gs.MatchFields(gs.IgnoreExtras, gs.Fields{
"Data": Equal([]byte(agentConf.IPSecIkev2Psk)),
"Data": Equal([]byte(*agentConf.IPSecIkev2Psk)),
}),
//permissive (local/remote) traffic selectors
"LocTs": gs.MatchFields(gs.IgnoreExtras, gs.Fields{
Expand Down Expand Up @@ -325,7 +326,7 @@ var _ = Describe("Node-related functionality of CNI", func() {
Expect(pubSubHandlerMock.Stop()).ToNot(HaveOccurred(),
"can't properly stop mock of PubSub's handler")
}
agentConf.EnableIPSec = false // disable for following tests
agentConf.GetCalicoVppFeatureGates().IPSecEnabled = &agentConf.False // disable for following tests
})
})
Context("With VXLAN connectivity", func() {
Expand Down Expand Up @@ -470,7 +471,7 @@ var _ = Describe("Node-related functionality of CNI", func() {
Expect(err).ToNot(HaveOccurred(), "can't find ipip tunnel interface")
tunnels, err := vpp.ListIPIPTunnels()
Expect(err).ToNot(HaveOccurred(), "Failed to get IP-IP tunnels from VPP")
Expect(tunnels).To(ContainElements(&types.IPIPTunnel{
Expect(tunnels).To(ContainElements(&vpptypes.IPIPTunnel{
Src: net.ParseIP(ThisNodeIP).To4(), // set by configureBGPNodeIPAddresses() call
Dst: net.ParseIP(GatewayIP).To4(),
TableID: 0, // not filled -> used default VRF table
Expand Down Expand Up @@ -537,18 +538,18 @@ var _ = Describe("Node-related functionality of CNI", func() {
pubSubHandlerMock.Start()

// configure this node's name and make Calico info data holder for it
agentConf.NodeName = ThisNodeName
*agentConf.NodeName = ThisNodeName
_, err := client.Nodes().Create(context.Background(), &oldv3.Node{
ObjectMeta: metav1.ObjectMeta{
Name: agentConf.NodeName,
Name: *agentConf.NodeName,
},
}, options.SetOptions{})
Expect(err).ToNot(HaveOccurred(), "Failed to call client.Nodes().Create()")

// configure added node for wireguard public crypto key
_, err = client.Nodes().Create(context.Background(), &oldv3.Node{
ObjectMeta: metav1.ObjectMeta{
Name: agentConf.NodeName,
Name: *agentConf.NodeName,
},
}, options.SetOptions{})
Expect(err).ToNot(HaveOccurred(), "could not call client.Nodes().Create()")
Expand Down Expand Up @@ -606,7 +607,7 @@ var _ = Describe("Node-related functionality of CNI", func() {
By("checking remembering of public key for wireguard tunnel in calico configuration")
// Note: public/private key is created by VPP (connectivity server sends empty public/private
// keys but retrieves it back properly filled)
thisNode, err := client.Nodes().Get(context.Background(), agentConf.NodeName, options.GetOptions{})
thisNode, err := client.Nodes().Get(context.Background(), *agentConf.NodeName, options.GetOptions{})
Expect(err).ToNot(HaveOccurred(),
"can't get this node info from mocked node info storage")
Expect(thisNode.Status).ToNot(BeNil(),
Expand Down Expand Up @@ -680,13 +681,13 @@ var _ = Describe("Node-related functionality of CNI", func() {

BeforeEach(func() {
// configuring global config for SRv6 ConnectivityProvider
agentConf.EnableSRv6 = true
agentConf.SRv6localSidIPPool = "B::/16" // also B::<node number>/112 subnet for LocalSids for given node
agentConf.SRv6policyIPPool = "C::/16" // also C::<node number>/112 subnet for BindingSIDs(=BSID=PolicyIP) for given node
agentConf.NodeName = ThisNodeName
agentConf.GetCalicoVppFeatureGates().SRv6Enabled = &agentConf.True
agentConf.GetCalicoVppSrv6().LocalsidPool = "B::/16" // also B::<node number>/112 subnet for LocalSids for given node
agentConf.GetCalicoVppSrv6().PolicyPool = "C::/16" // also C::<node number>/112 subnet for BindingSIDs(=BSID=PolicyIP) for given node
*agentConf.NodeName = ThisNodeName

// add node pool for SRv6 (subnet of agentConf.SRv6localSidIPPool)
_, err := addIPPoolForCalicoClient(client, fmt.Sprintf("sr-localsids-pool-%s", agentConf.NodeName), "B::1:0/112")
// add node pool for SRv6 (subnet of agentConf.CalicoVppSrv6.LocalsidPool)
_, err := addIPPoolForCalicoClient(client, fmt.Sprintf("sr-localsids-pool-%s", *agentConf.NodeName), "B::1:0/112")
Expect(err).ToNot(HaveOccurred(), "could not call addIPPoolForCalicoClient")

// SID/BSID format for testing: <BSID/Localsid prefix><node id>:<suffix created by IPAM IP assignment>
Expand Down
8 changes: 4 additions & 4 deletions calico-vpp-agent/cni/cni_pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (
"github.com/projectcalico/vpp-dataplane/calico-vpp-agent/proto"
"github.com/projectcalico/vpp-dataplane/calico-vpp-agent/tests/mocks"
"github.com/projectcalico/vpp-dataplane/calico-vpp-agent/watchers"
"github.com/projectcalico/vpp-dataplane/config/config"
"github.com/projectcalico/vpp-dataplane/config"
"github.com/projectcalico/vpp-dataplane/multinet-monitor/networkAttachmentDefinition"
"github.com/projectcalico/vpp-dataplane/vpplink"
"github.com/projectcalico/vpp-dataplane/vpplink/types"
Expand Down Expand Up @@ -145,7 +145,7 @@ var _ = Describe("Pod-related functionality of CNI", func() {

Context("With additional memif interface configured", func() {
BeforeEach(func() {
config.MemifEnabled = true
config.GetCalicoVppFeatureGates().MemifEnabled = &config.True
})

// TODO test also use case with that creates memif-dummy interface in pod (dummy interface is
Expand Down Expand Up @@ -217,7 +217,7 @@ var _ = Describe("Pod-related functionality of CNI", func() {
Expect(memifs[0].Role).To(Equal(types.MemifMaster))
Expect(memifs[0].Mode).To(Equal(types.MemifModeEthernet))
Expect(memifs[0].Flags&types.MemifAdminUp > 0).To(BeTrue())
Expect(memifs[0].QueueSize).To(Equal(config.DefaultInterfaceSpec.RxQueueSize))
Expect(memifs[0].QueueSize).To(Equal(config.GetCalicoVppInterfaces().DefaultPodIfSpec.RxQueueSize))
//Note:Memif.NumRxQueues and Memif.NumTxQueues is not dumped by VPP binary API dump -> can't test it

By("Checking secondary tunnel's memif socket file") // checking only VPP setting, not file socket presence
Expand Down Expand Up @@ -252,7 +252,7 @@ var _ = Describe("Pod-related functionality of CNI", func() {
)

BeforeEach(func() {
config.MultinetEnabled = true
config.GetCalicoVppFeatureGates().MultinetEnabled = &config.True

// Setup test prerequisite (per-multinet-network VRF and loopback interface)")
// (this is normally done by watchers.NetWatcher.CreateVRFsForNet(...))
Expand Down
10 changes: 5 additions & 5 deletions calico-vpp-agent/cni/cni_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
"github.com/projectcalico/vpp-dataplane/calico-vpp-agent/cni/storage"
"github.com/projectcalico/vpp-dataplane/calico-vpp-agent/common"
"github.com/projectcalico/vpp-dataplane/calico-vpp-agent/watchers"
config "github.com/projectcalico/vpp-dataplane/config/config"
config "github.com/projectcalico/vpp-dataplane/config"
"github.com/projectcalico/vpp-dataplane/vpplink"
"github.com/projectcalico/vpp-dataplane/vpplink/types"
)
Expand Down Expand Up @@ -116,11 +116,11 @@ func (s *Server) newLocalPodSpecFromAdd(request *pb.AddRequest) (*storage.LocalP
}

if podSpec.NetworkName != "" {
if !config.MultinetEnabled {
if !*config.GetCalicoVppFeatureGates().MultinetEnabled {
return nil, fmt.Errorf("enable multinet in config for multiple networks")
}
if isMemif(podSpec.InterfaceName) {
if !config.MemifEnabled {
if !*config.GetCalicoVppFeatureGates().MemifEnabled {
return nil, fmt.Errorf("enable memif in config for memif interfaces")
}
podSpec.EnableMemif = true
Expand Down Expand Up @@ -265,7 +265,7 @@ func (s *Server) rescanState() {
s.FetchBufferConfig()
s.fetchNDataThreads()

if config.VCLEnabled {
if *config.GetCalicoVppFeatureGates().VCLEnabled {
err := s.vclDriver.Init()
if err != nil {
/* it might already be enabled, do not return */
Expand Down Expand Up @@ -438,7 +438,7 @@ func (s *Server) ServeCNI(t *tomb.Tomb) error {

pb.RegisterCniDataplaneServer(s.grpcServer, s)

if config.MultinetEnabled {
if *config.GetCalicoVppFeatureGates().MultinetEnabled {
netsSynced := make(chan bool)
go func() {
for {
Expand Down
10 changes: 5 additions & 5 deletions calico-vpp-agent/cni/network_vpp.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/projectcalico/vpp-dataplane/calico-vpp-agent/cni/storage"
"github.com/projectcalico/vpp-dataplane/calico-vpp-agent/common"
"github.com/projectcalico/vpp-dataplane/config/config"
"github.com/projectcalico/vpp-dataplane/config"
"github.com/projectcalico/vpp-dataplane/vpplink"
"github.com/projectcalico/vpp-dataplane/vpplink/types"
)
Expand Down Expand Up @@ -182,15 +182,15 @@ func (s *Server) AddVppInterface(podSpec *storage.LocalPodSpec, doHostSideConf b
}
}

if podSpec.EnableMemif && config.MemifEnabled {
if podSpec.EnableMemif && *config.GetCalicoVppFeatureGates().MemifEnabled {
s.log.Infof("pod(add) memif")
err = s.memifDriver.CreateInterface(podSpec, stack, doHostSideConf)
if err != nil {
goto err
}
}

if podSpec.EnableVCL && config.VCLEnabled {
if podSpec.EnableVCL && *config.GetCalicoVppFeatureGates().VCLEnabled {
s.log.Infof("pod(add) VCL socket")
err = s.vclDriver.CreateInterface(podSpec, stack)
if err != nil {
Expand Down Expand Up @@ -335,11 +335,11 @@ func (s *Server) DelVppInterface(podSpec *storage.LocalPodSpec) {
s.DeactivateStrictRPF(podSpec)

/* Interfaces */
if podSpec.EnableVCL && config.VCLEnabled {
if podSpec.EnableVCL && *config.GetCalicoVppFeatureGates().VCLEnabled {
s.log.Infof("pod(del) VCL")
s.vclDriver.DeleteInterface(podSpec)
}
if podSpec.EnableMemif && config.MemifEnabled {
if podSpec.EnableMemif && *config.GetCalicoVppFeatureGates().MemifEnabled {
s.log.Infof("pod(del) memif")
s.memifDriver.DeleteInterface(podSpec)
}
Expand Down
Loading