From e993d3bc6989f671a57915d591d03e21fdc10a44 Mon Sep 17 00:00:00 2001 From: Vladimir Lavor Date: Thu, 6 Jun 2019 13:53:37 +0200 Subject: [PATCH] wip Signed-off-by: Vladimir Lavor --- cmd/vpp-agent-ctl/data/ifplugin.go | 54 ++++++++++++++++++++---------- cmd/vpp-agent/app/vpp_agent.go | 17 +++++----- 2 files changed, 45 insertions(+), 26 deletions(-) diff --git a/cmd/vpp-agent-ctl/data/ifplugin.go b/cmd/vpp-agent-ctl/data/ifplugin.go index 27a4a00cf7..29b0b93fb6 100644 --- a/cmd/vpp-agent-ctl/data/ifplugin.go +++ b/cmd/vpp-agent-ctl/data/ifplugin.go @@ -15,9 +15,11 @@ package data import ( + "context" linuxIf "github.com/ligato/vpp-agent/api/models/linux/interfaces" "github.com/ligato/vpp-agent/api/models/linux/namespace" interfaces "github.com/ligato/vpp-agent/api/models/vpp/interfaces" + "strconv" ) // InterfacesCtl interface plugin related methods for vpp-agent-ctl (interfaces including linux ones) @@ -109,6 +111,7 @@ func (ctl *VppAgentCtlImpl) PutTap() error { }, Link: &interfaces.Interface_Tap{ Tap: &interfaces.TapLink{ + Version: 2, HostIfName: "tap-host", }, }, @@ -190,25 +193,42 @@ func (ctl *VppAgentCtlImpl) DeleteMemoryInterface() error { // PutVxLan puts VxLAN type interface config to the ETCD func (ctl *VppAgentCtlImpl) PutVxLan() error { - vxlan := &interfaces.Interface{ - - Name: "vxlan1", - Type: interfaces.Interface_VXLAN_TUNNEL, - Enabled: true, - IpAddresses: []string{ - "172.125.40.1/24", - }, - Link: &interfaces.Interface_Vxlan{ - Vxlan: &interfaces.VxlanLink{ - SrcAddress: "192.168.42.1", - DstAddress: "192.168.42.2", - Vni: 13, + txn := ctl.broker.NewTxn() + + var first, last int + for i := 1; i <= 10000; i++ { + last++ + if last == 255 { + last = 1 + first++ + } + srcAddr := "192.168." + strconv.Itoa(first) + "." + strconv.Itoa(last) + dstAddr := "192.168." + strconv.Itoa(first + 1) + "." + strconv.Itoa(last + 1) + + vxlan := &interfaces.Interface{ + Name: "vxlan" + strconv.Itoa(i), + Type: interfaces.Interface_VXLAN_TUNNEL, + Enabled: true, + Link: &interfaces.Interface_Vxlan{ + Vxlan: &interfaces.VxlanLink{ + SrcAddress: srcAddr, + DstAddress: dstAddr, + Vni: 13, + }, }, - }, - } + } - ctl.Log.Infof("Interface put: %v", vxlan) - return ctl.broker.Put(interfaces.InterfaceKey(vxlan.Name), vxlan) + ctl.Log.Infof("Interface put: %v", vxlan) + txn.Put(interfaces.InterfaceKey(vxlan.Name), vxlan) + + if i%100 == 0 { + if err := txn.Commit(context.Background()); err != nil { + ctl.Log.Errorf("err: %v", err) + } + txn = ctl.broker.NewTxn() + } + } + return nil } // DeleteVxLan removes VxLAN type interface config from the ETCD diff --git a/cmd/vpp-agent/app/vpp_agent.go b/cmd/vpp-agent/app/vpp_agent.go index fabc81647a..7dd6a2a8c5 100644 --- a/cmd/vpp-agent/app/vpp_agent.go +++ b/cmd/vpp-agent/app/vpp_agent.go @@ -18,7 +18,6 @@ import ( "github.com/ligato/cn-infra/datasync" "github.com/ligato/cn-infra/datasync/kvdbsync" "github.com/ligato/cn-infra/datasync/kvdbsync/local" - "github.com/ligato/cn-infra/datasync/msgsync" "github.com/ligato/cn-infra/datasync/resync" "github.com/ligato/cn-infra/db/keyval/consul" "github.com/ligato/cn-infra/db/keyval/etcd" @@ -26,7 +25,6 @@ import ( "github.com/ligato/cn-infra/health/probe" "github.com/ligato/cn-infra/health/statuscheck" "github.com/ligato/cn-infra/logging/logmanager" - "github.com/ligato/cn-infra/messaging/kafka" "github.com/ligato/vpp-agent/plugins/vpp/srplugin" "github.com/ligato/vpp-agent/plugins/configurator" @@ -85,12 +83,12 @@ func New() *VPPAgent { } statuscheck.DefaultPlugin.Transport = writers - ifStatePub := msgsync.NewPlugin( - msgsync.UseMessaging(&kafka.DefaultPlugin), - msgsync.UseConf(msgsync.Config{ - Topic: "if_state", - }), - ) + //ifStatePub := msgsync.NewPlugin( + // msgsync.UseMessaging(&kafka.DefaultPlugin), + // msgsync.UseConf(msgsync.Config{ + // Topic: "if_state", + // }), + //) // Set watcher for KVScheduler. watchers := datasync.KVProtoWatchers{ @@ -103,7 +101,8 @@ func New() *VPPAgent { orchestrator.DefaultPlugin.StatusPublisher = writers ifplugin.DefaultPlugin.Watcher = watchers - ifplugin.DefaultPlugin.NotifyStates = ifStatePub + // kafka temporary disabled + //ifplugin.DefaultPlugin.NotifyStates = ifStatePub puntplugin.DefaultPlugin.PublishState = writers // No stats publishers by default, use `vpp-ifplugin.conf` config