{"modulePath":"github.com/emnify/vpp-agent","version":"v1.4.1","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package l2plugin\n\nPackage l2plugin implements the L2 plugin that handles Bridge Domains and L2 FIBs.\n\n## Types\n\n```go\ntype BDConfigurator struct {\n\tLog          logging.Logger\n\tGoVppmux     govppmux.API\n\tServiceLabel servicelabel.ReaderAPI\n\n\t// bridge domains\n\tBdIndices l2idx.BDIndexRW\n\t// interface indices\n\tSwIfIndices ifaceidx.SwIfIndex\n\n\tBridgeDomainIDSeq      uint32\n\tRegisteredIfaceCounter uint32\n\n\tStopwatch *measure.Stopwatch // timer used to measure and store time\n\t// contains filtered or unexported fields\n}\n```\nBDConfigurator 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.\n\n```go\nfunc (plugin *BDConfigurator) Close() error\n```\nClose GOVPP channel.\n\n```go\nfunc (plugin *BDConfigurator) ConfigureBridgeDomain(bdConfig *l2.BridgeDomains_BridgeDomain) error\n```\nConfigureBridgeDomain handles the creation of new bridge domain including interfaces, ARP termination entries and pushes status update notification.\n\n```go\nfunc (plugin *BDConfigurator) DeleteBridgeDomain(bdConfig *l2.BridgeDomains_BridgeDomain) error\n```\nDeleteBridgeDomain processes the NB config and propagates it to bin api calls.\n\n```go\nfunc (plugin *BDConfigurator) Init(notificationChannel chan BridgeDomainStateMessage) (err error)\n```\nInit members (channels...) and start go routines.\n\n```go\nfunc (plugin *BDConfigurator) ModifyBridgeDomain(newBdConfig *l2.BridgeDomains_BridgeDomain, oldBdConfig *l2.BridgeDomains_BridgeDomain) error\n```\nModifyBridgeDomain processes the NB config and propagates it to bin api calls.\n\n```go\nfunc (plugin *BDConfigurator) PropagateBdDetailsToStatus(bdID uint32, bdName string) error\n```\nPropagateBdDetailsToStatus looks for existing VPP bridge domain state and propagates it to the etcd bd state.\n\n```go\nfunc (plugin *BDConfigurator) ResolveCreatedInterface(ifName string, ifIdx uint32) error\n```\nResolveCreatedInterface looks for bridge domain this interface is assigned to and sets it up.\n\n```go\nfunc (plugin *BDConfigurator) ResolveDeletedInterface(ifName string) error\n```\nResolveDeletedInterface is called by VPP if an interface is removed.\n\n```go\nfunc (plugin *BDConfigurator) Resync(nbBDs []*l2.BridgeDomains_BridgeDomain) error\n```\nResync writes missing BDs to the VPP and removes obsolete ones.\n\n```go\ntype BridgeDomainMeta struct {\n\tIsInterfaceBvi bool\n\t// contains filtered or unexported fields\n}\n```\nBridgeDomainMeta holds info about interfaces's bridge domain index and BVI.\n\n```go\ntype BridgeDomainStateMessage struct {\n\tMessage govppapi.Message\n\tName    string\n}\n```\nBridgeDomainStateMessage 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.\n\n```go\ntype BridgeDomainStateNotification struct {\n\tState *l2.BridgeDomainState_BridgeDomain\n}\n```\nBridgeDomainStateNotification contains bridge domain state object with all data published to ETCD.\n\n```go\ntype BridgeDomainStateUpdater struct {\n\tLog      logging.Logger\n\tGoVppmux govppmux.API\n\t// contains filtered or unexported fields\n}\n```\nBridgeDomainStateUpdater holds all data required to handle bridge domain state.\n\n```go\nfunc (plugin *BridgeDomainStateUpdater) Init(ctx context.Context, bdIndexes l2idx.BDIndex, swIfIndexes ifaceidx.SwIfIndex,\n\tnotificationChan chan BridgeDomainStateMessage, publishBdState func(notification *BridgeDomainStateNotification)) (err error)\n```\nInit bridge domain state updater.\n\n```go\ntype FIBConfigurator struct {\n\tLog      logging.Logger\n\tGoVppmux govppmux.API\n\t// Injected mappings\n\tSwIfIndexes ifaceidx.SwIfIndex\n\tBdIndexes   l2idx.BDIndex\n\t// FIB-related mappings\n\tIfToBdIndexes idxvpp.NameToIdxRW // TODO: use rather BdIndexes.LookupNameByIfaceName\n\tFibIndexes    l2idx.FIBIndexRW\n\n\tStopwatch *measure.Stopwatch // timer used to measure and store time\n\t// contains filtered or unexported fields\n}\n```\nFIBConfigurator 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/\\\u003cbd-label\u003e/fib\". Updates received from the northbound API are compared with the VPP run-time configuration and differences are applied through the VPP binary API.\n\n```go\nfunc (plugin *FIBConfigurator) Add(fib *l2.FibTable_FibEntry, callback func(error)) error\n```\nAdd 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.\n\n```go\nfunc (plugin *FIBConfigurator) Close() error\n```\nClose vpp channel.\n\n```go\nfunc (plugin *FIBConfigurator) Delete(fib *l2.FibTable_FibEntry, callback func(error)) error\n```\nDelete 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.\n\n```go\nfunc (plugin *FIBConfigurator) GetFibAddCacheIndexes() l2idx.FIBIndexRW\n```\nGetFibAddCacheIndexes returns FIB memory 'add' cache indexes, for testing purpose\n\n```go\nfunc (plugin *FIBConfigurator) GetFibDelCacheIndexes() l2idx.FIBIndexRW\n```\nGetFibDelCacheIndexes returns FIB memory 'del' cache indexes, for testing purpose\n\n```go\nfunc (plugin *FIBConfigurator) Init() (err error)\n```\nInit goroutines, mappings, channels..\n\n```go\nfunc (plugin *FIBConfigurator) Modify(oldFib *l2.FibTable_FibEntry,\n\tnewFib *l2.FibTable_FibEntry, callback func(error)) error\n```\nModify 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.\n\n```go\nfunc (plugin *FIBConfigurator) ResolveCreatedBridgeDomain(bdName string, bdID uint32, callback func(error)) error\n```\nResolveCreatedBridgeDomain 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.\n\n```go\nfunc (plugin *FIBConfigurator) ResolveCreatedInterface(ifName string, ifIdx uint32, callback func(error)) error\n```\nResolveCreatedInterface 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.\n\n```go\nfunc (plugin *FIBConfigurator) ResolveDeletedBridgeDomain(bdName string, bdID uint32, callback func(error)) error\n```\nResolveDeletedInterface handles removed bridge domain. In that case, FIB entry remains on the VPP but it is not possible to delete it.\n\n```go\nfunc (plugin *FIBConfigurator) ResolveDeletedInterface(ifName string, ifIdx uint32, callback func(error)) error\n```\nResolveDeletedInterface handles removed interface. In that case, FIB entry remains on the VPP but it is not possible to delete it.\n\n```go\nfunc (plugin *FIBConfigurator) ResolveUpdatedBridgeDomain(bdName string, bdID uint32, callback func(error)) error\n```\nResolveUpdatedBridgeDomain 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.\n\n```go\nfunc (plugin *FIBConfigurator) Resync(nbFIBs []*l2.FibTable_FibEntry) error\n```\nResync writes missing FIBs to the VPP and removes obsolete ones.\n\n```go\ntype XConnectConfigurator struct {\n\t// contains filtered or unexported fields\n}\n```\nXConnectConfigurator implements PluginHandlerVPP.\n\n```go\nfunc (plugin *XConnectConfigurator) Close() error\n```\nClose govpp channel.\n\n```go\nfunc (plugin *XConnectConfigurator) ConfigureXConnectPair(xc *l2.XConnectPairs_XConnectPair) error\n```\nConfigureXConnectPair adds new cross connect pair\n\n```go\nfunc (plugin *XConnectConfigurator) DeleteXConnectPair(xc *l2.XConnectPairs_XConnectPair) error\n```\nDeleteXConnectPair removes XConnect if possible. Note: Xconnect pair cannot be removed if any interface is missing.\n\n```go\nfunc (plugin *XConnectConfigurator) GetXcAddCache() l2idx.XcIndexRW\n```\nGetXcAddCache returns cross connect 'add' cache (test purposes)\n\n```go\nfunc (plugin *XConnectConfigurator) GetXcDelCache() l2idx.XcIndexRW\n```\nGetXcDelCache returns cross connect 'del' cache (test purposes)\n\n```go\nfunc (plugin *XConnectConfigurator) GetXcIndexes() l2idx.XcIndexRW\n```\nGetXcIndexes returns cross connect memory indexes\n\n```go\nfunc (plugin *XConnectConfigurator) Init(logger logging.PluginLogger, goVppMux govppmux.API,\n\tswIfIndexes ifaceidx.SwIfIndex, enableStopwatch bool) (err error)\n```\nInit essential configurator fields.\n\n```go\nfunc (plugin *XConnectConfigurator) ModifyXConnectPair(newXc, oldXc *l2.XConnectPairs_XConnectPair) error\n```\nModifyXConnectPair modifies cross connect pair (its transmit interface). Old entry is replaced.\n\n```go\nfunc (plugin *XConnectConfigurator) ResolveCreatedInterface(ifName string) error\n```\nResolveCreatedInterface resolves XConnects waiting for an interface.\n\n```go\nfunc (plugin *XConnectConfigurator) ResolveDeletedInterface(ifName string) error\n```\nResolveDeletedInterface 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\n\n```go\nfunc (plugin *XConnectConfigurator) Resync(nbXConns []*l2.XConnectPairs_XConnectPair) error\n```\nResync writes missing XCons to the VPP and removes obsolete ones.\n\n","path":"github.com/emnify/vpp-agent/plugins/defaultplugins/l2plugin","name":"l2plugin","synopsis":"Package l2plugin implements the L2 plugin that handles Bridge Domains and L2 FIBs.","isRedistributable":true}
