l2plugin

package
v1.9.0-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2018 License: Apache-2.0 Imports: 16 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 {
	// 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 (c *BDConfigurator) Close() error

Close GOVPP channel.

func (*BDConfigurator) ConfigureBridgeDomain

func (c *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 (c *BDConfigurator) DeleteBridgeDomain(bdConfig *l2.BridgeDomains_BridgeDomain) error

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

func (*BDConfigurator) GetBdIndexes

func (c *BDConfigurator) GetBdIndexes() l2idx.BDIndexRW

GetBdIndexes exposes interface name-to-index mapping

func (*BDConfigurator) Init

func (c *BDConfigurator) Init(logger logging.PluginLogger, goVppMux govppmux.API, swIfIndexes ifaceidx.SwIfIndex,
	notificationChannel chan BridgeDomainStateMessage) (err error)

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

func (*BDConfigurator) LogError added in v1.8.1

func (c *BDConfigurator) LogError(err error) error

LogError prints error if not nil, including stack trace. The same value is also returned, so it can be easily propagated further

func (*BDConfigurator) ModifyBridgeDomain

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

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

func (*BDConfigurator) ResolveCreatedInterface

func (c *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 (c *BDConfigurator) ResolveDeletedInterface(ifName string) error

ResolveDeletedInterface is called by VPP if an interface is removed.

func (*BDConfigurator) Resync

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

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

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 {
	// contains filtered or unexported fields
}

BridgeDomainStateUpdater holds all data required to handle bridge domain state.

func (*BridgeDomainStateUpdater) Init

func (c *BridgeDomainStateUpdater) Init(ctx context.Context, logger logging.PluginLogger, goVppMux govppmux.API, bdIndexes l2idx.BDIndex, swIfIndexes ifaceidx.SwIfIndex,
	notificationChan chan BridgeDomainStateMessage, publishBdState func(notification *BridgeDomainStateNotification)) (err error)

Init bridge domain state updater.

func (*BridgeDomainStateUpdater) LogError added in v1.8.1

func (c *BridgeDomainStateUpdater) LogError(err error) error

LogError prints error if not nil, including stack trace. The same value is also returned, so it can be easily propagated further

type FIBConfigurator

type FIBConfigurator struct {
	// 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 (c *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 (c *FIBConfigurator) Close() error

Close vpp channel.

func (*FIBConfigurator) Delete

func (c *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

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

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

func (*FIBConfigurator) GetFibDelCacheIndexes

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

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

func (*FIBConfigurator) GetFibIndexes

func (c *FIBConfigurator) GetFibIndexes() l2idx.FIBIndexRW

GetFibIndexes returns FIB memory indexes

func (*FIBConfigurator) Init

func (c *FIBConfigurator) Init(logger logging.PluginLogger, goVppMux govppmux.API, swIfIndexes ifaceidx.SwIfIndex,
	bdIndexes l2idx.BDIndex) (err error)

Init goroutines, mappings, channels..

func (*FIBConfigurator) LogError added in v1.8.1

func (c *FIBConfigurator) LogError(err error) error

LogError prints error if not nil, including stack trace. The same value is also returned, so it can be easily propagated further

func (*FIBConfigurator) Modify

func (c *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 (c *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 (c *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 (c *FIBConfigurator) ResolveDeletedBridgeDomain(bdName string, bdID uint32, callback func(error)) error

ResolveDeletedBridgeDomain 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 (c *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

func (c *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 (c *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 (c *XConnectConfigurator) Close() error

Close govpp channel.

func (*XConnectConfigurator) ConfigureXConnectPair

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

ConfigureXConnectPair adds new cross connect pair

func (*XConnectConfigurator) DeleteXConnectPair

func (c *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

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

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

func (*XConnectConfigurator) GetXcDelCache

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

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

func (*XConnectConfigurator) GetXcIndexes

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

GetXcIndexes returns cross connect memory indexes

func (*XConnectConfigurator) Init

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

Init essential configurator fields.

func (*XConnectConfigurator) LogError added in v1.8.1

func (c *XConnectConfigurator) LogError(err error) error

LogError prints error if not nil, including stack trace. The same value is also returned, so it can be easily propagated further

func (*XConnectConfigurator) ModifyXConnectPair

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

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

func (*XConnectConfigurator) ResolveCreatedInterface

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

ResolveCreatedInterface resolves XConnects waiting for an interface.

func (*XConnectConfigurator) ResolveDeletedInterface

func (c *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

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

Directories

Path Synopsis
Package l2idx implements name-to-index mapping registry and cache for bridge-domains.
Package l2idx 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 and helpers for dumping them.
Package vppcalls contains wrappers over VPP binary APIs for bridge-domains, and L2 FIBs and XConnect pairs and helpers for dumping them.

Jump to

Keyboard shortcuts

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