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

vpp: cnat performance #275

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
30 changes: 16 additions & 14 deletions calico-vpp-agent/cmd/calico_vpp_dataplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ var (
log *logrus.Logger
)

func Go(f func(t *tomb.Tomb) error) {
func Go(f func(t *tomb.Tomb) error, name string) {
if t.Alive() {
log.Infof("STARTING %s", name)
t.Go(func() error {
err := f(&t)
if err != nil {
log.Warnf("Tomb function errored with %s", err)
}
log.Infof("STOPPED %s", name)
return err
})
}
Expand Down Expand Up @@ -160,7 +162,7 @@ func main() {
serviceServer.SetBGPConf(bgpConf)

watchDog := watchdog.NewWatchDog(log.WithFields(logrus.Fields{"component": "watchDog"}), &t)
Go(policyServer.ServePolicy)
Go(policyServer.ServePolicy, "policyServer.ServePolicy")
felixConfig := watchDog.Wait(policyServer.FelixConfigChan, "Waiting for FelixConfig to be provided by the calico pod")
ourBGPSpec := watchDog.Wait(policyServer.GotOurNodeBGPchan, "Waiting for bgp spec to be provided on node add")
if ourBGPSpec != nil {
Expand All @@ -173,7 +175,7 @@ func main() {
}

if *config.GetCalicoVppFeatureGates().MultinetEnabled {
Go(netWatcher.WatchNetworks)
Go(netWatcher.WatchNetworks, "netWatcher.WatchNetworks")
watchDog.Wait(netWatcher.InSync, "Waiting for networks to be listed and synced")
}

Expand All @@ -182,20 +184,20 @@ func main() {
connectivityServer.SetFelixConfig(felixConfig.(*felixconfig.Config))
}

Go(routeWatcher.WatchRoutes)
Go(linkWatcher.WatchLinks)
Go(bgpConfigurationWatcher.WatchBGPConfiguration)
Go(prefixWatcher.WatchPrefix)
Go(peerWatcher.WatchBGPPeers)
Go(connectivityServer.ServeConnectivity)
Go(routingServer.ServeRouting)
Go(serviceServer.ServeService)
Go(cniServer.ServeCNI)
Go(prometheusServer.ServePrometheus)
Go(routeWatcher.WatchRoutes, "routeWatcher.WatchRoutes")
Go(linkWatcher.WatchLinks, "linkWatcher.WatchLinks")
Go(bgpConfigurationWatcher.WatchBGPConfiguration, "bgpConfigurationWatcher.WatchBGPConfiguration")
Go(prefixWatcher.WatchPrefix, "prefixWatcher.WatchPrefix")
Go(peerWatcher.WatchBGPPeers, "peerWatcher.WatchBGPPeers")
Go(connectivityServer.ServeConnectivity, "connectivityServer.ServeConnectivity")
Go(routingServer.ServeRouting, "routingServer.ServeRouting")
Go(serviceServer.ServeService, "serviceServer.ServeService")
Go(cniServer.ServeCNI, "cniServer.ServeCNI")
Go(prometheusServer.ServePrometheus, "prometheusServer.ServePrometheus")

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

log.Infof("Agent started")
Expand Down
2 changes: 1 addition & 1 deletion calico-vpp-agent/cni/cni_pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ var _ = Describe("Pod-related functionality of CNI", func() {
socket, err := vpp.MemifsocketByID(memifs[0].SocketId)
Expect(err).ToNot(HaveOccurred(), "failed to get memif socket")
Expect(socket.SocketFilename).To(Equal(
fmt.Sprintf("@netns:%s@vpp/memif-%s", newPod.Netns, newPod.InterfaceName)),
fmt.Sprintf("abstract:%s,netns_name=%s", newPod.InterfaceName, newPod.Netns)),
"memif socket file is not configured correctly")

By("Checking PBL (packet punting) to redirect some traffic into memif (secondary interface)")
Expand Down
7 changes: 5 additions & 2 deletions calico-vpp-agent/cni/cni_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,8 @@ func (s *Server) cniServerEventLoop(t *tomb.Tomb) error {
for {
select {
case <-t.Dying():
break
s.log.Warnf("CNI server asked to stop")
return nil
case evt := <-s.cniEventChan:
switch evt.Type {
case common.FelixConfChanged:
Expand Down Expand Up @@ -482,12 +483,14 @@ func (s *Server) ServeCNI(t *tomb.Tomb) error {
}

s.log.Infof("CNI Server returned")
s.grpcServer.Stop()
s.log.Infof("GRPC stopped")

s.grpcServer.GracefulStop()
err = syscall.Unlink(config.CNIServerSocket)
if err != nil {
return err
}
s.log.Infof("Socket CNI unlink")

return nil
}
Expand Down
2 changes: 2 additions & 0 deletions calico-vpp-agent/cni/pod_interface/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ func (i *PodInterfaceDriverData) SpreadTxQueuesOnWorkers(swIfIndex uint32, numTx
"swIfIndex": swIfIndex,
}).Debugf("Spreading %d TX queues on %d workers for pod interface: %v", numTxQueues, i.NDataThreads, i.Name)

return nil // FIXME

// set first tx queue for main worker
err = i.vpp.SetInterfaceTxPlacement(swIfIndex, 0 /* queue */, 0 /* worker */)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion calico-vpp-agent/cni/pod_interface/memif.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (i *MemifPodInterfaceDriver) CreateInterface(podSpec *storage.LocalPodSpec,
if podSpec.NetworkName == "" {
memifName = "@vpp/memif-" + podSpec.InterfaceName
}
socketId, err := i.vpp.AddMemifSocketFileName(fmt.Sprintf("@netns:%s%s", podSpec.NetnsName, memifName))
socketId, err := i.vpp.AddMemifSocketFileName(fmt.Sprintf("abstract:%s,netns_name=%s", memifName, podSpec.NetnsName))
if err != nil {
return err
} else {
Expand Down
17 changes: 14 additions & 3 deletions vpplink/cnat.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@ package vpplink
import (
"fmt"
"net"
"github.com/pkg/errors"

"github.com/projectcalico/vpp-dataplane/v3/vpplink/generated/bindings/cnat"
"github.com/projectcalico/vpp-dataplane/v3/vpplink/generated/bindings/interface_types"
"github.com/projectcalico/vpp-dataplane/v3/vpplink/types"
)

const (
FeatureArcCnatInput = "ip?-unicast cnat-input-ip?"
FeatureArcCnatOutput = "ip?-output cnat-output-ip?"
FeatureArcSnat = "ip?-unicast cnat-snat-ip?"
FeatureArcCnatLookup = "ip?-unicast cnat-lookup-ip?"
FeatureArcCnatInput = "ip?-unicast cnat-input-ip?"
FeatureArcCnatOutput = "ip?-output cnat-output-ip?"
FeatureArcCnatWriteBack = "ip?-output cnat-writeback-ip?"
FeatureArcSnat = "ip?-unicast cnat-snat-ip?"
)

const InvalidID = ^uint32(0)
Expand Down Expand Up @@ -124,6 +127,14 @@ func (v *VppLink) CnatDelSnatPrefix(prefix *net.IPNet) error {
}

func (v *VppLink) CnatEnableFeatures(swIfIndex uint32) (err error) {
err = v.EnableFeatureArc46(swIfIndex, FeatureArcCnatLookup)
if err != nil {
return errors.Wrap(err, "Error enabling arc dnat in")
}
err = v.EnableFeatureArc46(swIfIndex, FeatureArcCnatWriteBack)
if err != nil {
return errors.Wrap(err, "Error enabling arc dnat out")
}
err = v.EnableFeatureArc46(swIfIndex, FeatureArcCnatInput)
if err != nil {
return fmt.Errorf("enabling arc dnat input failed: %w", err)
Expand Down
24 changes: 0 additions & 24 deletions vpplink/generated/bindings/capo/capo.ba.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 0 additions & 48 deletions vpplink/generated/bindings/cnat/cnat.ba.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading