ifplugin

package
v1.8.0-alpha Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2018 License: Apache-2.0 Imports: 27 Imported by: 0

README

VPP interface Plugin

The ifplugin is a Core Agent Plugin for configuration of NICs, memifs, VXLANs, loopback interfaces and STN rules.

The plugin watches the northbound configuration of network interfaces, which is modelled by interfaces proto file and stored in ETCD under the following key:

/vnf-agent/<agent-label>/vpp/config/v1/interface/<interface-name>

This northbound configuration is translated to a sequence of binary API calls (using GOVPP library). Replies from the VPP are processed sequentially, i.e. one by one.

Internally in VPP, each newly created interface is assigned a unique integer for identification and future references. This integer is denoted as sw_if_index, and the agent will learn it from a VPP response to a successfully created interface (of any kind). The agent, however, needs to decouple the control plane from sw_if_index to be able to configure multiple inter-dependent objects in one transaction. For example, multiple interfaces may all be created in one transaction, together with objects that depend on them, such as L2 FIB entries, L3 routing, ACLs, etc. It is, however, not possible to describe the dependencies without knowing the identifiers of interfaces in advance. Furthermore, certain interface parameters cannot be modified once the interface was created. In order to reflect a configuration change, it may be necessary to re-create the interface in VPP with the new configuration. The new instance of the interface, however, may be assigned a different sw_if_index. All pre-existing references to this interface that would be based on sw_if_index are thus invalidated by this operation.

In order to address the limitations of VPP sw_if_index, the control plane defines a unique logical name for each network interface and uses it as a reference from dependent objects. The agent receives a logical name from a northbound configuration and calls the specific binary API (e.g. "Create NIC") to obtain sw_if_idx. The agent then maintains a one-to-one mapping between the logical name and its respective sw_if_index in a registry called NameIdx. Later, if/when the interface configuration changes, the new sw_if_idx can be looked up by its logical name and used in an up-to-date reference.

The following sequence diagrams describe the high-level behavior of the ifplugin.

Create one MEMIF (one part of the link)

... -> ifpluign : Create ietf-interface (MEMIF)
ifplugin -> GOVPP : Create MEMIF
ifplugin <-- GOVPP : sw_if_index + success/err
ifplugin -> NameIdx : register sw_if_index by name
ifplugin <-- NameIdx : success/err
ifplugin -> GOVPP : IF admin up
ifplugin <-- GOVPP : success/err
ifplugin -> GOVPP : ADD IP address
ifplugin <-- GOVPP : success/err

Update MEMIF IP addresses

... -> ifplugin : Update ietf-interface (MEMIF, IP addresses)
ifplugin -> NameIdx : lookup sw_if_index by name
ifplugin <-- NameIdx : sw_if_index / not found
ifplugin -> Calculate the delta (what IP address was added or deleted)
ifplugin -> GOVPP : (un)assign IP address(es) to the MEMIF with specific sw_if_idx
ifplugin <-- GOVPP : success/err
ifplugin -> GOVPP : VRF
ifplugin <-- GOVPP : success/err

Delete one MEMIF interface

... -> ifplugin : Remove ietf-interfaces (MEMIF)
ifplugin -> NameIdx : lookup sw_if_index by name
ifplugin <-- NameIdx : sw_if_index / not found
ifplugin -> Calculate the delta (what IP address needs to be deleted)
ifplugin -> GOVPP : delete MEMIF with the specific sw_if_idx
ifplugin <-- GOVPP : success/err
ifplugin -> GOVPP : VRF
ifplugin <-- GOVPP : success/err

JSON configuration example with vpp-agent-ctl

An example of interface configuration for MEMIF in JSON format can be found here.

To insert config into etcd in JSON format vpp-agent-ctl can be used. For example, to configure interface memif1 in vpp labeled vpp1, use the configuration in the memif.json file and run the following vpp-agent-ctl command:

vpp-agent-ctl -put "/vnf-agent/vpp1/vpp/config/v1/interface/memif1" memif.json

Inbuilt configuration example with vpp-agent-ctl

The vpp-agent-ctl binary also ships with some simple predefined ietf-interface configurations. This is intended solely for testing purposes.

To create a master memif with IP address 192.168.42.1, run:

vpp-agent-ctl -memif

It is not possible to change the operating mode of memif interface once it was created, the agent must first remove the existing interface and then create a new instance of memif in slave mode.

To remove the interface, run:

vpp-agent-ctl -memifd

Similarly, vpp-agent-ctl offers commands to create, change and delete VXLANs, tap and loopback interfaces with predefined configurations. Run vpp-agent-ctl with no arguments to get the list of all available commands. The documentation for vpp-agent-ctl is incomplete right now, and the only way to find out what a given command does is to study the source code itself.

Bidirectional Forwarding Detection

iflplugin is also able to configure BFD sessions, authentication keys and echo function.

BFD is modelled by bfd proto file. Every part of BFD is stored in ETCD under unique. Every BFD session is stored under following key:

/vnf-agent/{agent-label}/vpp/config/v1/bfd/session/{session-name}

Every created authentication key, which can be used in sessions is stored under:

/vnf-agent/{agent-label}/vpp/config/v1/bfd/auth-key/{key-name}

If echo function is configured, it can be found under key:

/vnf-agent/{agent-label}/vpp/config/v1/bfd/echo-function

Each newly created BFD element is assigned an integer for identification (the same concept as with interfaces). There are several mappings used for every BFD configuration part. bfd_session_index is used for BFD sessions, bfd_keys_index for authentication keys and echo function index is stored in bfd_echo_function_index.

Configuration example with vpp-agent-ctl using JSON

// todo

Inbuilt configuration example with vpp-agent-ctl

Use predefined vpp-agent-ctl configurations:

Create BFD session

vpp-agent-ctl -bfds

Note: BFD session requires interface over which session will be created. This interface has to contain IP address defined also as BFD session source address. Authentication is assigned only if particular key (defined in BFD session) already exists

Create BFD authentication key

vpp-agent-ctl -bfdk

Set up Echo Function

vpp-agent-ctl -bfde

To remove any part of BFD configuration, just add d before vpp-agent-ctl suffix (for example -dbfds to remove BFD session). Keep in mind that authentication key cannot be removed (or modified) if it is used in any BFD session.

Network address translation

NAT configuration can be set up on the VPP using ifplugin.

NAT is modelled by nat proto file. Model is divided to two parts; the general configuration with defined interfaces and enabled IP address pools, and DNAT configuration with a set of static and/or identity mappings.

NAT global configuration is stored under single key. There is no unique name or label to distinguish different configurations (only one global setting can be stored in the ETCD at a time):

/vnf-agent/{agent-lanbel}/vpp/config/v1/nat/global/

NAT DNAT case has the following key:

/vnf-agent/vpp1/vpp/config/v1/nat/dnat/{label}

JSON configuration example with vpp-agent-ctl

To inset NAT global config into ETCD in JSON format, use vpp-agent-ctl with nat-global.json file. Use the following command:

vpp-agent-ctl -put "/vnf-agent/vpp1/vpp/config/v1/nat/global/" json/nat-global.json

To put DNAT configuration, use vpp-agent-ctl with nat-dnat.json file. Use the following command:

vpp-agent-ctl -put "/vnf-agent/vpp1/vpp/config/v1/nat/dnat/dnat1" json/nat-dnat.json

Inbuilt configuration example with vpp-agent-ctl

The vpp-agent-ctl binary also ships with some simple predefined ietf-interface configurations. This is intended solely for testing purposes.

To create a global NAT config, run:

vpp-agent-ctl -gnat

To create a DNAT config, run:

vpp-agent-ctl -dnat
STN Rules

iflplugin is also able to configure STN rules.

STN is modelled by stn proto file. Every part of STN is stored in ETCD under unique. Every STN rule is store under following key:

/vnf-agent/{agent-lanbel}/vpp/config/v1/stn/rules/{rule-name}

JSON configuration example with vpp-agent-ctl

An example of interface configuration for STN rule in JSON format can be found here.

To insert config into etcd in JSON format vpp-agent-ctl can be used. For example, to configure stn rule rule1 in vpp labeled vpp1, use the configuration in the stn-rule.json file and run the following vpp-agent-ctl command:

vpp-agent-ctl -put "/vnf-agent/vpp1/vpp/config/v1/stn/rules/" stn-rule.json

Inbuilt configuration example with vpp-agent-ctl

The vpp-agent-ctl binary also ships with some simple predefined ietf-interface configurations. This is intended solely for testing purposes.

To create a rule1 stn rule with IP address 10.1.1.3/32, run:

vpp-agent-ctl -stn

To remove the stn rule, run:

vpp-agent-ctl -stnd

State of implementation of rx-mode for various interface types

interface type rx-modes implemented how to check on VPP example of creation of interface
tap interface PIA yes ? #tap connect tap1
memory interface PIA yes both sides of memif (slave and master) has to be configured = 2 VPPs.
#sh memif
#create memif master
vxlan tunnel PIA yes ? #create vxlan tunnel src 192.168.168.168 dst 192.168.168.170 vni 40
software loopback PIA yes ? #create loopback interface
ethernet csmad P yes #show interface rx-placement vpp will adopt interfaces on start up
af packet PIA yes #show interface rx-placement #create host-interface name

Legend:

  • P - polling
  • I - interrupt
  • A - adaptive

Documentation

Overview

Package ifplugin implements the Interface plugin that handles management of VPP interfaces.

Index

Constants

View Source
const (
	Drop    counterType = 0
	Punt                = 1
	IPv4                = 2
	IPv6                = 3
	RxNoBuf             = 4
	RxMiss              = 5
	RxError             = 6
	TxError             = 7
	MPLS                = 8
)

constants as defined in the vnet_interface_counter_type_t enum in 'vnet/interface.h'

View Source
const (
	Rx combinedCounterType = 0
	Tx                     = 1
)

constants as defined in the vnet_interface_counter_type_t enum in 'vnet/interface.h'

Variables

This section is empty.

Functions

func AuthKeyIdentifier

func AuthKeyIdentifier(id uint32) string

AuthKeyIdentifier generates common identifier for authentication key

func GetIDMappingIdentifier added in v1.8.1

func GetIDMappingIdentifier(mapping *nat.Nat44DNat_DNatConfig_IdentityMapping) string

GetIDMappingIdentifier returns unique ID of the mapping

func GetStMappingIdentifier

func GetStMappingIdentifier(mapping *nat.Nat44DNat_DNatConfig_StaticMapping) string

GetStMappingIdentifier returns unique ID of the mapping

func StnIdentifier

func StnIdentifier(iface string) string

StnIdentifier creates unique identifier which serves as a name in name to index mapping

Types

type AFPacketConfigurator

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

AFPacketConfigurator is used by InterfaceConfigurator to execute afpacket-specific management operations. Most importantly it needs to ensure that Afpacket interface is create AFTER the associated host interface.

func (*AFPacketConfigurator) ConfigureAfPacketInterface

func (c *AFPacketConfigurator) ConfigureAfPacketInterface(afpacket *intf.Interfaces_Interface) (swIndex uint32, pending bool, err error)

ConfigureAfPacketInterface creates a new Afpacket interface or marks it as pending if the target host interface doesn't exist yet.

func (*AFPacketConfigurator) DeleteAfPacketInterface

func (c *AFPacketConfigurator) DeleteAfPacketInterface(afpacket *intf.Interfaces_Interface, ifIdx uint32) (err error)

DeleteAfPacketInterface removes Afpacket interface from VPP and from the cache.

func (*AFPacketConfigurator) GetAfPacketStatusByHost

func (c *AFPacketConfigurator) GetAfPacketStatusByHost(hostIf string) (exists, pending bool, ifData *intf.Interfaces_Interface)

GetAfPacketStatusByHost looks for cached interface by host interface and returns its state and data

func (*AFPacketConfigurator) GetAfPacketStatusByName

func (c *AFPacketConfigurator) GetAfPacketStatusByName(name string) (exists, pending bool, ifData *intf.Interfaces_Interface)

GetAfPacketStatusByName looks for cached interface by its name and returns its state and data

func (*AFPacketConfigurator) GetHostInterfacesEntry

func (c *AFPacketConfigurator) GetHostInterfacesEntry(hostIf string) bool

GetHostInterfacesEntry looks for cached host interface and returns true if exists

func (*AFPacketConfigurator) Init

func (c *AFPacketConfigurator) Init(logger logging.Logger, ifHandler vppcalls.IfVppAPI, linux interface{},
	indexes ifaceidx.SwIfIndexRW) (err error)

Init members of AFPacketConfigurator.

func (*AFPacketConfigurator) IsPendingAfPacket

func (c *AFPacketConfigurator) IsPendingAfPacket(iface *intf.Interfaces_Interface) (pending bool)

IsPendingAfPacket returns true if the given config belongs to pending Afpacket interface.

func (*AFPacketConfigurator) ModifyAfPacketInterface

func (c *AFPacketConfigurator) ModifyAfPacketInterface(newConfig *intf.Interfaces_Interface,
	oldConfig *intf.Interfaces_Interface) (recreate bool, err error)

ModifyAfPacketInterface updates the cache with afpacket configurations and tells InterfaceConfigurator if the interface needs to be recreated for the changes to be applied.

func (*AFPacketConfigurator) ResolveCreatedLinuxInterface

func (c *AFPacketConfigurator) ResolveCreatedLinuxInterface(ifName, hostIfName string, ifIdx uint32) (*intf.Interfaces_Interface, error)

ResolveCreatedLinuxInterface reacts to a newly created Linux interface.

func (*AFPacketConfigurator) ResolveDeletedLinuxInterface

func (c *AFPacketConfigurator) ResolveDeletedLinuxInterface(ifName, hostIfName string, ifIdx uint32) error

ResolveDeletedLinuxInterface reacts to a removed Linux interface.

type AfPacketConfig

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

AfPacketConfig wraps the proto formatted configuration of an Afpacket interface together with a flag that tells if the interface is waiting for a host interface to get created.

type BFDConfigurator

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

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

func (*BFDConfigurator) Close

func (c *BFDConfigurator) Close() error

Close GOVPP channel

func (*BFDConfigurator) ConfigureBfdAuthKey

func (c *BFDConfigurator) ConfigureBfdAuthKey(bfdAuthKey *bfd.SingleHopBFD_Key) error

ConfigureBfdAuthKey crates new authentication key which can be used for BFD session

func (*BFDConfigurator) ConfigureBfdEchoFunction

func (c *BFDConfigurator) ConfigureBfdEchoFunction(bfdInput *bfd.SingleHopBFD_EchoFunction) error

ConfigureBfdEchoFunction is used to setup BFD Echo function on existing interface

func (*BFDConfigurator) ConfigureBfdSession

func (c *BFDConfigurator) ConfigureBfdSession(bfdInput *bfd.SingleHopBFD_Session) error

ConfigureBfdSession configures bfd session (including authentication if exists). Provided interface has to contain ip address defined in BFD as source

func (*BFDConfigurator) DeleteBfdAuthKey

func (c *BFDConfigurator) DeleteBfdAuthKey(bfdInput *bfd.SingleHopBFD_Key) error

DeleteBfdAuthKey removes BFD authentication key but only if it is not used in any BFD session

func (*BFDConfigurator) DeleteBfdEchoFunction

func (c *BFDConfigurator) DeleteBfdEchoFunction(bfdInput *bfd.SingleHopBFD_EchoFunction) error

DeleteBfdEchoFunction removes BFD echo function

func (*BFDConfigurator) DeleteBfdSession

func (c *BFDConfigurator) DeleteBfdSession(bfdInput *bfd.SingleHopBFD_Session) error

DeleteBfdSession removes BFD session

func (*BFDConfigurator) GetBfdEchoFunctionIndexes

func (c *BFDConfigurator) GetBfdEchoFunctionIndexes() idxvpp.NameToIdxRW

GetBfdEchoFunctionIndexes gives access to BFD echo function indexes

func (*BFDConfigurator) GetBfdKeyIndexes

func (c *BFDConfigurator) GetBfdKeyIndexes() idxvpp.NameToIdxRW

GetBfdKeyIndexes gives access to BFD key indexes

func (*BFDConfigurator) GetBfdSessionIndexes

func (c *BFDConfigurator) GetBfdSessionIndexes() idxvpp.NameToIdxRW

GetBfdSessionIndexes gives access to BFD session indexes

func (*BFDConfigurator) Init

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

Init members and channels

func (*BFDConfigurator) LogError added in v1.8.1

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

func (c *BFDConfigurator) ModifyBfdAuthKey(oldInput *bfd.SingleHopBFD_Key, newInput *bfd.SingleHopBFD_Key) error

ModifyBfdAuthKey modifies auth key fields. Key which is assigned to one or more BFD session cannot be modified

func (*BFDConfigurator) ModifyBfdEchoFunction

func (c *BFDConfigurator) ModifyBfdEchoFunction(oldInput *bfd.SingleHopBFD_EchoFunction, newInput *bfd.SingleHopBFD_EchoFunction) error

ModifyBfdEchoFunction handles echo function changes

func (*BFDConfigurator) ModifyBfdSession

func (c *BFDConfigurator) ModifyBfdSession(oldBfdInput *bfd.SingleHopBFD_Session, newBfdInput *bfd.SingleHopBFD_Session) error

ModifyBfdSession modifies BFD session fields. Source and destination IP address for old and new config has to be the same. Authentication is NOT changed here, BFD modify bin api call does not support that

func (*BFDConfigurator) ResyncAuthKey

func (c *BFDConfigurator) ResyncAuthKey(nbKeys []*bfd.SingleHopBFD_Key) error

ResyncAuthKey writes BFD keys to the empty VPP

func (*BFDConfigurator) ResyncEchoFunction

func (c *BFDConfigurator) ResyncEchoFunction(echoFunctions []*bfd.SingleHopBFD_EchoFunction) error

ResyncEchoFunction writes BFD echo function to the empty VPP

func (*BFDConfigurator) ResyncSession

func (c *BFDConfigurator) ResyncSession(nbSessions []*bfd.SingleHopBFD_Session) error

ResyncSession writes BFD sessions to the empty VPP

type InterfaceConfigurator

type InterfaceConfigurator struct {

	// Notification channels
	NotifChan chan govppapi.Message // to publish SwInterfaceDetails to interface_state.go
	DhcpChan  chan govppapi.Message // channel to receive DHCP notifications
	// contains filtered or unexported fields
}

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

func (*InterfaceConfigurator) Close

func (c *InterfaceConfigurator) Close() error

Close GOVPP channel

func (*InterfaceConfigurator) ConfigureVPPInterface

func (c *InterfaceConfigurator) ConfigureVPPInterface(iface *intf.Interfaces_Interface) (err error)

ConfigureVPPInterface reacts to a new northbound VPP interface config by creating and configuring the interface in the VPP network stack through the VPP binary API.

func (*InterfaceConfigurator) DeleteVPPInterface

func (c *InterfaceConfigurator) DeleteVPPInterface(iface *intf.Interfaces_Interface) error

DeleteVPPInterface reacts to a removed NB configuration of a VPP interface. It results in the interface being removed from VPP.

func (*InterfaceConfigurator) GetDHCPIndexes

func (c *InterfaceConfigurator) GetDHCPIndexes() ifaceidx.DhcpIndexRW

GetDHCPIndexes exposes DHCP name-to-index mapping

func (*InterfaceConfigurator) GetSwIfIndexes

func (c *InterfaceConfigurator) GetSwIfIndexes() ifaceidx.SwIfIndexRW

GetSwIfIndexes exposes interface name-to-index mapping

func (*InterfaceConfigurator) Init

func (c *InterfaceConfigurator) Init(logger logging.PluginLogger, goVppMux govppmux.API, linux interface{},
	notifChan chan govppapi.Message, defaultMtu uint32) (err error)

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

func (*InterfaceConfigurator) IsMulticastVxLanIfCached

func (c *InterfaceConfigurator) IsMulticastVxLanIfCached(ifName string) bool

IsMulticastVxLanIfCached returns true if provided interface is cached as VxLAN with missing multicast interface

func (*InterfaceConfigurator) IsSocketFilenameCached

func (c *InterfaceConfigurator) IsSocketFilenameCached(filename string) bool

IsSocketFilenameCached returns true if provided filename is presented in the cache

func (*InterfaceConfigurator) IsUnnumberedIfCached

func (c *InterfaceConfigurator) IsUnnumberedIfCached(ifName string) bool

IsUnnumberedIfCached returns true if provided interface is cached as unconfigurabel unnubered interface

func (*InterfaceConfigurator) LogError added in v1.8.1

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

func (c *InterfaceConfigurator) ModifyVPPInterface(newConfig *intf.Interfaces_Interface,
	oldConfig *intf.Interfaces_Interface) error

ModifyVPPInterface applies changes in the NB configuration of a VPP interface into the running VPP through the VPP binary API.

func (*InterfaceConfigurator) ResolveCreatedLinuxInterface

func (c *InterfaceConfigurator) ResolveCreatedLinuxInterface(ifName, hostIfName string, ifIdx uint32) error

ResolveCreatedLinuxInterface reacts to a newly created Linux interface.

func (*InterfaceConfigurator) ResolveDeletedLinuxInterface

func (c *InterfaceConfigurator) ResolveDeletedLinuxInterface(ifName, hostIfName string, ifIdx uint32) error

ResolveDeletedLinuxInterface reacts to a removed Linux interface.

func (*InterfaceConfigurator) Resync

Resync writes interfaces to the VPP. VPP interfaces are usually configured with tag, which corresponds with interface name (exceptions are physical devices, but their name is always equal to vpp internal name). Resync consists of following steps:

  1. Dump all VPP interfaces
  2. Every VPP interface looks for NB counterpart using tag (name). If found, it is calculated whether modification is needed. Otherwise, the interface is only registered. If interface does not contain tag, it is stored for now and resolved later. Tagged interfaces without NB config are removed.
  3. Untagged interfaces are correlated heuristically (mac address, ip addresses). If correlation is found, interface is modified if needed and registered.
  4. All remaining NB interfaces are configured

func (*InterfaceConfigurator) VerifyVPPConfigPresence

func (c *InterfaceConfigurator) VerifyVPPConfigPresence(nbIfaces []*intf.Interfaces_Interface) bool

VerifyVPPConfigPresence dumps VPP interface configuration on the vpp. If there are any interfaces configured (except the local0), it returns false (do not interrupt the resto of the resync), otherwise returns true

type InterfaceStateUpdater

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

InterfaceStateUpdater holds state data of all VPP interfaces.

func (*InterfaceStateUpdater) AfterInit

func (c *InterfaceStateUpdater) AfterInit() error

AfterInit subscribes for watching VPP notifications on previously initialized channel

func (*InterfaceStateUpdater) Close

func (c *InterfaceStateUpdater) Close() error

Close unsubscribes from interface state notifications from VPP & GOVPP channel

func (*InterfaceStateUpdater) Init

func (c *InterfaceStateUpdater) Init(ctx context.Context, logger logging.PluginLogger, goVppMux govppmux.API,
	swIfIndexes ifaceidx.SwIfIndex, notifChan chan govppapi.Message,
	publishIfState func(notification *intf.InterfaceNotification)) (err error)

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

func (*InterfaceStateUpdater) LogError added in v1.8.1

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

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

NatConfigurator runs in the background in its own goroutine where it watches for any changes in the configuration of NAT address pools and static entries with or without a load ballance, as modelled by the proto file "../common/model/nat/nat.proto" and stored in ETCD under the keys:

  • "/vnf-agent/{agent-label}/vpp/config/v1/nat/{vrf}/addrpool/" for NAT address pool
  • "/vnf-agent/{agent-label}/vpp/config/v1/nat/{vrf}/static/" for NAT static mapping
  • "/vnf-agent/{agent-label}/vpp/config/v1/nat/{vrf}/staticlb/" for NAT static mapping with load balancer

Updates received from the northbound API are compared with the VPP run-time configuration and differences are applied through the VPP binary API.

func (*NatConfigurator) Close

func (c *NatConfigurator) Close() error

Close used resources

func (*NatConfigurator) ConfigureDNat

func (c *NatConfigurator) ConfigureDNat(dNat *nat.Nat44DNat_DNatConfig) error

ConfigureDNat configures new DNAT setup

func (*NatConfigurator) ConfigureSNat

func (c *NatConfigurator) ConfigureSNat(sNat *nat.Nat44SNat_SNatConfig) error

ConfigureSNat configures new SNAT setup

func (*NatConfigurator) DeleteDNat

func (c *NatConfigurator) DeleteDNat(dNat *nat.Nat44DNat_DNatConfig) error

DeleteDNat removes existing DNAT setup

func (*NatConfigurator) DeleteNatGlobalConfig

func (c *NatConfigurator) DeleteNatGlobalConfig(config *nat.Nat44Global) (err error)

DeleteNatGlobalConfig removes common setup for all NAT use cases

func (*NatConfigurator) DeleteSNat

func (c *NatConfigurator) DeleteSNat(sNat *nat.Nat44SNat_SNatConfig) error

DeleteSNat removes existing SNAT setup

func (*NatConfigurator) DumpNatDNat

func (c *NatConfigurator) DumpNatDNat() (*nat.Nat44DNat, error)

DumpNatDNat returns the current NAT44 DNAT config

func (*NatConfigurator) DumpNatGlobal

func (c *NatConfigurator) DumpNatGlobal() (*nat.Nat44Global, error)

DumpNatGlobal returns the current NAT44 global config

func (*NatConfigurator) GetGlobalNat

func (c *NatConfigurator) GetGlobalNat() *nat.Nat44Global

GetGlobalNat makes current global nat accessible

func (*NatConfigurator) Init

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

Init NAT configurator

func (*NatConfigurator) IsDNatLabelIDMappingRegistered added in v1.8.1

func (c *NatConfigurator) IsDNatLabelIDMappingRegistered(id string) bool

IsDNatLabelIDMappingRegistered checks if DNAT identity mapping with provided id is registered

func (*NatConfigurator) IsDNatLabelRegistered

func (c *NatConfigurator) IsDNatLabelRegistered(label string) bool

IsDNatLabelRegistered checks if interface is present in 'notDisabledIfs' cache

func (*NatConfigurator) IsDNatLabelStMappingRegistered

func (c *NatConfigurator) IsDNatLabelStMappingRegistered(id string) bool

IsDNatLabelStMappingRegistered checks if DNAT static mapping with provided id is registered

func (*NatConfigurator) IsInNotDisabledIfCache

func (c *NatConfigurator) IsInNotDisabledIfCache(ifName string) bool

IsInNotDisabledIfCache checks if interface is present in 'notDisabledIfs' cache

func (*NatConfigurator) IsInNotEnabledIfCache

func (c *NatConfigurator) IsInNotEnabledIfCache(ifName string) bool

IsInNotEnabledIfCache checks if interface is present in 'notEnabledIfs' cache

func (*NatConfigurator) LogError added in v1.8.1

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

func (c *NatConfigurator) ModifyDNat(oldDNat, newDNat *nat.Nat44DNat_DNatConfig) error

ModifyDNat modifies existing DNAT setup

func (*NatConfigurator) ModifyNatGlobalConfig

func (c *NatConfigurator) ModifyNatGlobalConfig(oldConfig, newConfig *nat.Nat44Global) (err error)

ModifyNatGlobalConfig modifies common setup for all NAT use cases

func (*NatConfigurator) ModifySNat

func (c *NatConfigurator) ModifySNat(oldSNat, newSNat *nat.Nat44SNat_SNatConfig) error

ModifySNat modifies existing SNAT setup

func (*NatConfigurator) ResolveCreatedInterface

func (c *NatConfigurator) ResolveCreatedInterface(ifName string, ifIdx uint32) error

ResolveCreatedInterface looks for cache of interfaces which should be enabled or disabled for NAT

func (*NatConfigurator) ResolveDeletedInterface

func (c *NatConfigurator) ResolveDeletedInterface(ifName string, ifIdx uint32) error

ResolveDeletedInterface handles removed interface from NAT perspective

func (*NatConfigurator) ResyncDNat

func (c *NatConfigurator) ResyncDNat(nbDNatConfig []*nat.Nat44DNat_DNatConfig) error

ResyncDNat writes NAT static mapping config to the the empty VPP

func (*NatConfigurator) ResyncNatGlobal

func (c *NatConfigurator) ResyncNatGlobal(nbGlobal *nat.Nat44Global) error

ResyncNatGlobal writes NAT address pool config to the the empty VPP

func (*NatConfigurator) ResyncSNat

func (c *NatConfigurator) ResyncSNat(sNatConf []*nat.Nat44SNat_SNatConfig) error

ResyncSNat writes NAT static mapping config to the the empty VPP

func (*NatConfigurator) SetNatGlobalConfig

func (c *NatConfigurator) SetNatGlobalConfig(config *nat.Nat44Global) error

SetNatGlobalConfig configures common setup for all NAT use cases

type StnConfigurator

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

StnConfigurator runs in the background in its own goroutine where it watches for any changes in the configuration of interfaces as modelled by the proto file "../model/stn/stn.proto" and stored in ETCD under the key "vpp/config/v1/stn/rules/".

func (*StnConfigurator) Add

func (c *StnConfigurator) Add(rule *modelStn.STN_Rule) error

Add create a new STN rule.

func (*StnConfigurator) Close

func (c *StnConfigurator) Close() error

Close GOVPP channel.

func (*StnConfigurator) Delete

func (c *StnConfigurator) Delete(rule *modelStn.STN_Rule) error

Delete removes STN rule.

func (*StnConfigurator) Dump

func (c *StnConfigurator) Dump() (*vppcalls.StnDetails, error)

Dump STN rules configured on the VPP

func (*StnConfigurator) IndexExistsFor

func (c *StnConfigurator) IndexExistsFor(name string) bool

IndexExistsFor returns true if there is and mapping entry for provided name

func (*StnConfigurator) Init

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

Init initializes STN configurator

func (*StnConfigurator) LogError added in v1.8.1

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

func (c *StnConfigurator) Modify(ruleOld *modelStn.STN_Rule, ruleNew *modelStn.STN_Rule) error

Modify configured rule.

func (*StnConfigurator) ResolveCreatedInterface

func (c *StnConfigurator) ResolveCreatedInterface(interfaceName string) error

ResolveCreatedInterface will check rules and if there is one waiting for interfaces it will be written into VPP.

func (*StnConfigurator) ResolveDeletedInterface

func (c *StnConfigurator) ResolveDeletedInterface(interfaceName string) error

ResolveDeletedInterface resolves when interface is deleted. If there exist a rule for this interface the rule will be deleted also.

func (*StnConfigurator) Resync

func (c *StnConfigurator) Resync(nbStnRules []*stn.STN_Rule) error

Resync writes stn rule to the the empty VPP

func (*StnConfigurator) UnstoredIndexExistsFor

func (c *StnConfigurator) UnstoredIndexExistsFor(name string) bool

UnstoredIndexExistsFor returns true if there is and mapping entry for provided name

Directories

Path Synopsis
Package ifaceidx implements name-to-index mapping registry and cache for VPP interfaces.
Package ifaceidx implements name-to-index mapping registry and cache for VPP interfaces.
Package vppcalls contains wrappers over VPP binary APIs for all supported interface types and for dumping all interfaces configured in VPP.
Package vppcalls contains wrappers over VPP binary APIs for all supported interface types and for dumping all interfaces configured in VPP.

Jump to

Keyboard shortcuts

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