l2plugin

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2018 License: Apache-2.0 Imports: 22 Imported by: 0

README

L2 Plugin

The l2plugin is a Core Agent Plugin designed to configure Bridge Domains and L2 FIB in the VPP. Configuration managed by this plugin is modelled by l2 proto file. The configuration must be stored in etcd using following keys:

/vnf-agent/<agent-label>/vpp/config/v1/bd/<bridge-domain-name>
/vnf-agent/<agent-label>/vpp/config/v1/bd/<bridge-domain-name>/fib/<mac-address>
/vnf-agent/<agent-label>/vpp/config/v1/xconnect/<rx-interface-name>

JSON configuration example with vpp-agent-ctl

An example of basic bridge domain configuration in JSON format can be found here. A bit more advanced example which includes ARP termination entries can be found here. Example of FIB tables is available here

To insert config into etcd in JSON format vpp-agent-ctl can be used. Let's assume that we want to configure vpp with the label vpp1 and config for bridge domain bd1 is stored in the bridge-domain.json file. Furthermore, we assume that the bridge domain bd1 contains tap interface tap1 with configuration stored in tap.json. To convey this configuration to the agent through northbound API, you would execute:

vpp-agent-ctl -put "/vnf-agent/vpp1/vpp/config/v1/interface/tap1" tap.json
vpp-agent-ctl -put "/vnf-agent/vpp1/vpp/config/v1/bd/bd1" bridge-domain.json

Agent operating with the microservice label vpp1 will then create bridge domain, assign every interface which belongs to it (tap1 in the example above), and set BVI (if there is such an interface). If one or more ARP entries are available, all of them are written to ARP Termination table.

Every L2 FIB entry is configured for specific bridge domain and interface, both of them have to be configured (in any order) to be written to FIB table.

Inbuilt configuration example with vpp-agent-ctl

The vpp-agent-ctl binary also ships with some simple predefined bridge domain configurations. It is meant to be used solely for testing purposes.

First create a new tap interface tap1:

vpp-agent-ctl /opt/vpp-agent/dev/etcd.conf -tap

To configure a new bridge domain bd1 containing the previously created tap interface tap1, use:

vpp-agent-ctl /opt/vpp-agent/dev/etcd.conf -bd

To create a new tap interface tap2 and to L2-xConnect it with tap1, use:

vpp-agent-ctl /opt/vpp-agent/dev/etcd.conf -xconn

To create L2 FIB table, run:

vpp-agent-ctl /opt/vpp-agent/dev/etcd.conf -fib

Documentation

Overview

Package l2plugin implements the L2 plugin that handles Bridge Domains and L2 FIBs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BDConfigurator

type BDConfigurator struct {
	Log          logging.Logger
	GoVppmux     govppmux.API
	ServiceLabel servicelabel.ReaderAPI

	// bridge domains
	BdIndices l2idx.BDIndexRW
	// interface indices
	SwIfIndices ifaceidx.SwIfIndex

	BridgeDomainIDSeq      uint32
	RegisteredIfaceCounter uint32

	Stopwatch *measure.Stopwatch // timer used to measure and store time
	// contains filtered or unexported fields
}

BDConfigurator runs in the background in its own goroutine where it watches for any changes in the configuration of bridge domains as modelled by the proto file "../model/l2/l2.proto" and stored in ETCD under the key "/vnf-agent/{vnf-agent}/vpp/config/v1bd". Updates received from the northbound API are compared with the VPP run-time configuration and differences are applied through the VPP binary API.

func (*BDConfigurator) Close

func (plugin *BDConfigurator) Close() error

Close GOVPP channel.

func (*BDConfigurator) ConfigureBridgeDomain

func (plugin *BDConfigurator) ConfigureBridgeDomain(bdConfig *l2.BridgeDomains_BridgeDomain) error

ConfigureBridgeDomain handles the creation of new bridge domain including interfaces, ARP termination entries and pushes status update notification.

func (*BDConfigurator) DeleteBridgeDomain

func (plugin *BDConfigurator) DeleteBridgeDomain(bdConfig *l2.BridgeDomains_BridgeDomain) error

DeleteBridgeDomain processes the NB config and propagates it to bin api calls.

func (*BDConfigurator) Init

func (plugin *BDConfigurator) Init(notificationChannel chan BridgeDomainStateMessage) (err error)

Init members (channels...) and start go routines.

func (*BDConfigurator) ModifyBridgeDomain

func (plugin *BDConfigurator) ModifyBridgeDomain(newBdConfig *l2.BridgeDomains_BridgeDomain, oldBdConfig *l2.BridgeDomains_BridgeDomain) error

ModifyBridgeDomain processes the NB config and propagates it to bin api calls.

func (*BDConfigurator) PropagateBdDetailsToStatus added in v1.4.0

func (plugin *BDConfigurator) PropagateBdDetailsToStatus(bdID uint32, bdName string) error

PropagateBdDetailsToStatus looks for existing VPP bridge domain state and propagates it to the etcd bd state.

func (*BDConfigurator) ResolveCreatedInterface

func (plugin *BDConfigurator) ResolveCreatedInterface(ifName string, ifIdx uint32) error

ResolveCreatedInterface looks for bridge domain this interface is assigned to and sets it up.

func (*BDConfigurator) ResolveDeletedInterface

func (plugin *BDConfigurator) ResolveDeletedInterface(ifName string) error

ResolveDeletedInterface is called by VPP if an interface is removed.

func (*BDConfigurator) Resync

func (plugin *BDConfigurator) Resync(nbBDs []*l2.BridgeDomains_BridgeDomain) error

Resync writes missing BDs to the VPP and removes obsolete ones.

type BridgeDomainMeta

type BridgeDomainMeta struct {
	IsInterfaceBvi bool
	// contains filtered or unexported fields
}

BridgeDomainMeta holds info about interfaces's bridge domain index and BVI.

type BridgeDomainStateMessage

type BridgeDomainStateMessage struct {
	Message govppapi.Message
	Name    string
}

BridgeDomainStateMessage is message with bridge domain state + bridge domain name (since a state message does not contain it). This state is sent to the bd_state.go to further processing after every change.

type BridgeDomainStateNotification

type BridgeDomainStateNotification struct {
	State *l2.BridgeDomainState_BridgeDomain
}

BridgeDomainStateNotification contains bridge domain state object with all data published to ETCD.

type BridgeDomainStateUpdater

type BridgeDomainStateUpdater struct {
	Log      logging.Logger
	GoVppmux govppmux.API
	// contains filtered or unexported fields
}

BridgeDomainStateUpdater holds all data required to handle bridge domain state.

func (*BridgeDomainStateUpdater) Init

func (plugin *BridgeDomainStateUpdater) Init(ctx context.Context, bdIndexes l2idx.BDIndex, swIfIndexes ifaceidx.SwIfIndex,
	notificationChan chan BridgeDomainStateMessage, publishBdState func(notification *BridgeDomainStateNotification)) (err error)

Init bridge domain state updater.

type FIBConfigurator

type FIBConfigurator struct {
	Log      logging.Logger
	GoVppmux govppmux.API
	// Injected mappings
	SwIfIndexes ifaceidx.SwIfIndex
	BdIndexes   l2idx.BDIndex
	// FIB-related mappings
	IfToBdIndexes idxvpp.NameToIdxRW // TODO: use rather BdIndexes.LookupNameByIfaceName
	FibIndexes    l2idx.FIBIndexRW

	Stopwatch *measure.Stopwatch // timer used to measure and store time
	// contains filtered or unexported fields
}

FIBConfigurator runs in the background in its own goroutine where it watches for any changes in the configuration of fib table entries as modelled by the proto file "../model/l2/l2.proto" and stored in ETCD under the key "/vnf-agent/{vnf-agent}/vpp/config/v1/bd/<bd-label>/fib". Updates received from the northbound API are compared with the VPP run-time configuration and differences are applied through the VPP binary API.

func (*FIBConfigurator) Add

func (plugin *FIBConfigurator) Add(fib *l2.FibTable_FibEntry, callback func(error)) error

Add configures provided FIB input. Every entry has to contain info about MAC address, interface, and bridge domain. If interface or bridge domain is missing or interface is not a part of the bridge domain, FIB data is cached and recalled if particular entity is registered/updated.

func (*FIBConfigurator) Close

func (plugin *FIBConfigurator) Close() error

Close vpp channel.

func (*FIBConfigurator) Delete

func (plugin *FIBConfigurator) Delete(fib *l2.FibTable_FibEntry, callback func(error)) error

Delete removes FIB table entry. The request to be successful, both interface and bridge domain indices have to be available. Request does nothing without this info. If interface (or bridge domain) was removed before, provided FIB data is just unregistered and agent assumes, that VPP removed FIB entry itself.

func (*FIBConfigurator) GetFibAddCacheIndexes added in v1.4.0

func (plugin *FIBConfigurator) GetFibAddCacheIndexes() l2idx.FIBIndexRW

GetFibAddCacheIndexes returns FIB memory 'add' cache indexes, for testing purpose

func (*FIBConfigurator) GetFibDelCacheIndexes added in v1.4.0

func (plugin *FIBConfigurator) GetFibDelCacheIndexes() l2idx.FIBIndexRW

GetFibDelCacheIndexes returns FIB memory 'del' cache indexes, for testing purpose

func (*FIBConfigurator) Init

func (plugin *FIBConfigurator) Init() (err error)

Init goroutines, mappings, channels..

func (*FIBConfigurator) Modify added in v1.4.0

func (plugin *FIBConfigurator) Modify(oldFib *l2.FibTable_FibEntry,
	newFib *l2.FibTable_FibEntry, callback func(error)) error

Modify provides changes for FIB entry. Old fib entry is removed (if possible) and a new one is registered if all the conditions are fulfilled (interface and bridge domain presence), otherwise new configuration is cached.

func (*FIBConfigurator) ResolveCreatedBridgeDomain

func (plugin *FIBConfigurator) ResolveCreatedBridgeDomain(bdName string, bdID uint32, callback func(error)) error

ResolveCreatedBridgeDomain uses FIB cache to configure any FIB entries for this bridge domain. Required interface is checked for existence. If resolution is successful, new FIB entry is configured, registered and removed from cache.

func (*FIBConfigurator) ResolveCreatedInterface

func (plugin *FIBConfigurator) ResolveCreatedInterface(ifName string, ifIdx uint32, callback func(error)) error

ResolveCreatedInterface uses FIB cache to additionally configure any FIB entries for this interface. Bridge domain is checked for existence. If resolution is successful, new FIB entry is configured, registered and removed from cache.

func (*FIBConfigurator) ResolveDeletedBridgeDomain

func (plugin *FIBConfigurator) ResolveDeletedBridgeDomain(bdName string, bdID uint32, callback func(error)) error

ResolveDeletedInterface handles removed bridge domain. In that case, FIB entry remains on the VPP but it is not possible to delete it.

func (*FIBConfigurator) ResolveDeletedInterface

func (plugin *FIBConfigurator) ResolveDeletedInterface(ifName string, ifIdx uint32, callback func(error)) error

ResolveDeletedInterface handles removed interface. In that case, FIB entry remains on the VPP but it is not possible to delete it.

func (*FIBConfigurator) ResolveUpdatedBridgeDomain added in v1.4.0

func (plugin *FIBConfigurator) ResolveUpdatedBridgeDomain(bdName string, bdID uint32, callback func(error)) error

ResolveUpdatedBridgeDomain handles case where metadata of bridge domain are updated. If interface-bridge domain pair required for a FIB entry was not bound together, but it was changed in the bridge domain later, FIB is resolved and eventually configred here.

func (*FIBConfigurator) Resync

func (plugin *FIBConfigurator) Resync(nbFIBs []*l2.FibTable_FibEntry) error

Resync writes missing FIBs to the VPP and removes obsolete ones.

type XConnectConfigurator

type XConnectConfigurator struct {
	// contains filtered or unexported fields
}

XConnectConfigurator implements PluginHandlerVPP.

func (*XConnectConfigurator) Close

func (plugin *XConnectConfigurator) Close() error

Close govpp channel.

func (*XConnectConfigurator) ConfigureXConnectPair

func (plugin *XConnectConfigurator) ConfigureXConnectPair(xc *l2.XConnectPairs_XConnectPair) error

ConfigureXConnectPair adds new cross connect pair

func (*XConnectConfigurator) DeleteXConnectPair

func (plugin *XConnectConfigurator) DeleteXConnectPair(xc *l2.XConnectPairs_XConnectPair) error

DeleteXConnectPair removes XConnect if possible. Note: Xconnect pair cannot be removed if any interface is missing.

func (*XConnectConfigurator) GetXcAddCache added in v1.4.0

func (plugin *XConnectConfigurator) GetXcAddCache() l2idx.XcIndexRW

GetXcAddCache returns cross connect 'add' cache (test purposes)

func (*XConnectConfigurator) GetXcDelCache added in v1.4.0

func (plugin *XConnectConfigurator) GetXcDelCache() l2idx.XcIndexRW

GetXcDelCache returns cross connect 'del' cache (test purposes)

func (*XConnectConfigurator) GetXcIndexes added in v1.4.0

func (plugin *XConnectConfigurator) GetXcIndexes() l2idx.XcIndexRW

GetXcIndexes returns cross connect memory indexes

func (*XConnectConfigurator) Init

func (plugin *XConnectConfigurator) Init(logger logging.PluginLogger, goVppMux govppmux.API,
	swIfIndexes ifaceidx.SwIfIndex, enableStopwatch bool) (err error)

Init essential configurator fields.

func (*XConnectConfigurator) ModifyXConnectPair

func (plugin *XConnectConfigurator) ModifyXConnectPair(newXc, oldXc *l2.XConnectPairs_XConnectPair) error

ModifyXConnectPair modifies cross connect pair (its transmit interface). Old entry is replaced.

func (*XConnectConfigurator) ResolveCreatedInterface added in v1.0.3

func (plugin *XConnectConfigurator) ResolveCreatedInterface(ifName string) error

ResolveCreatedInterface resolves XConnects waiting for an interface.

func (*XConnectConfigurator) ResolveDeletedInterface added in v1.0.3

func (plugin *XConnectConfigurator) ResolveDeletedInterface(ifName string) error

ResolveDeletedInterface resolves XConnects using deleted interface If deleted interface is a received interface, the XConnect was removed by the VPP If deleted interface is a transmit interface, it will get flag 'DELETED' in VPP, but the entry will be kept

func (*XConnectConfigurator) Resync

func (plugin *XConnectConfigurator) Resync(nbXConns []*l2.XConnectPairs_XConnectPair) error

Resync writes missing XCons to the VPP and removes obsolete ones.

Directories

Path Synopsis
Package bdidx implements name-to-index mapping registry and cache for bridge-domains.
Package bdidx implements name-to-index mapping registry and cache for bridge-domains.
Package vppcalls contains wrappers over VPP binary APIs for bridge-domains, and L2 FIBs and XConnect pairs.
Package vppcalls contains wrappers over VPP binary APIs for bridge-domains, and L2 FIBs and XConnect pairs.
Package vppdump provides helpers for dumping all bridge-domains, L2 FIBs and XConnect pairs configured in VPP.
Package vppdump provides helpers for dumping all bridge-domains, L2 FIBs and XConnect pairs configured in VPP.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL