ifplugin

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2017 License: Apache-2.0 Imports: 30 Imported by: 0

README

IF Plugin

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

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 -cmm

To turn the memif from master to slave and change the IP address from 192.168.42.1 to 192.168.42.2, invoke:

vpp-agent-ctl -cms

Note: As 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 -dmm

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.

Documentation

Overview

Package ifplugin is the implementation of the Interface plugin.deps.

Package ifplugin is the implementation of the Interface plugin.deps.

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

This section is empty.

Types

type AFPacketConfigurator

type AFPacketConfigurator struct {
	Linux linuxplugin.API
	// 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 (plugin *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 (plugin *AFPacketConfigurator) DeleteAfPacketInterface(afpacket *intf.Interfaces_Interface) (err error)

DeleteAfPacketInterface removes Afpacket interface from VPP and from the cache.

func (*AFPacketConfigurator) Init

func (plugin *AFPacketConfigurator) Init(vppCh *govppapi.Channel) (err error)

Init members of AFPacketConfigurator.

func (*AFPacketConfigurator) IsPendingAfPacket

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

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

func (*AFPacketConfigurator) ModifyAfPacketInterface

func (plugin *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 nees to be recreated for the changes to be applied.

func (*AFPacketConfigurator) ResolveCreatedLinuxInterface

func (plugin *AFPacketConfigurator) ResolveCreatedLinuxInterface(interfaceName string, interfaceIndex uint32) *intf.Interfaces_Interface

ResolveCreatedLinuxInterface reacts to a newly created Linux interface.

func (*AFPacketConfigurator) ResolveDeletedLinuxInterface

func (plugin *AFPacketConfigurator) ResolveDeletedLinuxInterface(interfaceName string)

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 {
	GoVppmux     govppmux.API
	SwIfIndexes  ifaceidx.SwIfIndex
	ServiceLabel servicelabel.ReaderAPI
	BfdIDSeq     uint32
	// contains filtered or unexported fields
}

BFDConfigurator 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/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 (plugin *BFDConfigurator) Close() error

Close GOVPP channel

func (*BFDConfigurator) ConfigureBfdAuthKey

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

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

func (*BFDConfigurator) ConfigureBfdEchoFunction

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

ConfigureBfdEchoFunction is used to setup BFD Echo function on existing interface

func (*BFDConfigurator) ConfigureBfdSession

func (plugin *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 (plugin *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 (plugin *BFDConfigurator) DeleteBfdEchoFunction(bfdInput *bfd.SingleHopBFD_EchoFunction) error

DeleteBfdEchoFunction removes BFD echo function

func (*BFDConfigurator) DeleteBfdSession

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

DeleteBfdSession removes BFD session

func (*BFDConfigurator) Init

func (plugin *BFDConfigurator) Init(bfdSessionIndexes idxvpp.NameToIdxRW, bfdKeyIndexes idxvpp.NameToIdxRW, bfdEchoFunctionIndex idxvpp.NameToIdxRW,
	bfdRemovedAuthIndex idxvpp.NameToIdxRW) (err error)

Init members and channels

func (*BFDConfigurator) LookupBfdKeys

func (plugin *BFDConfigurator) LookupBfdKeys() error

LookupBfdKeys looks up all BFD auth keys and saves their name-to-index mapping

func (*BFDConfigurator) LookupBfdSessions

func (plugin *BFDConfigurator) LookupBfdSessions() error

LookupBfdSessions looks up all BFD sessions and saves their name-to-index mapping

func (*BFDConfigurator) ModifyBfdAuthKey

func (plugin *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 (plugin *BFDConfigurator) ModifyBfdEchoFunction(oldInput *bfd.SingleHopBFD_EchoFunction, newInput *bfd.SingleHopBFD_EchoFunction) error

ModifyBfdEchoFunction handles echo function changes

func (*BFDConfigurator) ModifyBfdSession

func (plugin *BFDConfigurator) ModifyBfdSession(oldBfdSession *bfd.SingleHopBFD_Session, newBfdSession *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 (plugin *BFDConfigurator) ResyncAuthKey(bfds []*bfd.SingleHopBFD_Key) error

ResyncAuthKey writes BFD keys to the empty VPP

func (*BFDConfigurator) ResyncEchoFunction

func (plugin *BFDConfigurator) ResyncEchoFunction(bfds []*bfd.SingleHopBFD_EchoFunction) error

ResyncEchoFunction writes BFD echo function to the empty VPP

func (*BFDConfigurator) ResyncSession

func (plugin *BFDConfigurator) ResyncSession(bfds []*bfd.SingleHopBFD_Session) error

ResyncSession writes BFD sessions to the empty VPP

type InterfaceConfigurator

type InterfaceConfigurator struct {
	GoVppmux     govppmux.API
	ServiceLabel servicelabel.ReaderAPI
	Linux        linuxplugin.API
	// 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 (plugin *InterfaceConfigurator) Close() error

Close GOVPP channel

func (*InterfaceConfigurator) ConfigureVPPInterface

func (plugin *InterfaceConfigurator) ConfigureVPPInterface(iface *intf.Interfaces_Interface) 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 (plugin *InterfaceConfigurator) DeleteVPPInterface(iface *intf.Interfaces_Interface) (wasError error)

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

func (*InterfaceConfigurator) Init

func (plugin *InterfaceConfigurator) Init(swIfIndexes ifaceidx.SwIfIndexRW, notifChan chan govppapi.Message) (err error)

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

func (*InterfaceConfigurator) LookupVPPInterfaces

func (plugin *InterfaceConfigurator) LookupVPPInterfaces() error

LookupVPPInterfaces looks up all VPP interfaces and saves their name-to-index mapping and state information.

func (*InterfaceConfigurator) ModifyVPPInterface

func (plugin *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 (plugin *InterfaceConfigurator) ResolveCreatedLinuxInterface(interfaceName string, interfaceIndex uint32)

ResolveCreatedLinuxInterface reacts to a newly created Linux interface.

func (*InterfaceConfigurator) ResolveDeletedLinuxInterface

func (plugin *InterfaceConfigurator) ResolveDeletedLinuxInterface(interfaceName string)

ResolveDeletedLinuxInterface reacts to a removed Linux interface.

func (*InterfaceConfigurator) Resync

func (plugin *InterfaceConfigurator) Resync(nbIfaces []*intf.Interfaces_Interface) error

Resync writes interfaces to the empty VPP

- resyncs the VPP - temporary: (checks wether sw_if_indexes are not obsolate - this will be swapped with master ID) - deletes obsolate status data

type InterfaceStateUpdater

type InterfaceStateUpdater struct {
	GoVppmux govppmux.API
	// contains filtered or unexported fields
}

InterfaceStateUpdater holds state data of all VPP interfaces.

func (*InterfaceStateUpdater) AfterInit

func (plugin *InterfaceStateUpdater) AfterInit() (err error)

AfterInit subscribes for watching VPP notifications on previously initialized channel

func (*InterfaceStateUpdater) Close

func (plugin *InterfaceStateUpdater) Close() error

Close unsubscribes from interface state notifications from VPP & GOVPP channel

func (*InterfaceStateUpdater) Init

func (plugin *InterfaceStateUpdater) Init(ctx context.Context,
	swIfIndexes ifaceidx.SwIfIndex, notifChan chan govppapi.Message,
	publishIfState func(notification *intf.InterfaceStateNotification)) (err error)

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

Directories

Path Synopsis
Package binapi is the parent for packages that define various ifplugin southbound APIs.
Package binapi is the parent for packages that define various ifplugin southbound APIs.
af_packet
Package af_packet represents the VPP binary API of the 'af_packet' VPP module.
Package af_packet represents the VPP binary API of the 'af_packet' VPP module.
bfd
Package bfd represents the VPP binary API of the 'bfd' VPP module.
Package bfd represents the VPP binary API of the 'bfd' VPP module.
interfaces
Package interfaces represents the VPP binary API of the 'interfaces' VPP module.
Package interfaces represents the VPP binary API of the 'interfaces' VPP module.
ip
Package ip represents the VPP binary API of the 'ip' VPP module.
Package ip represents the VPP binary API of the 'ip' VPP module.
memif
Package memif represents the VPP binary API of the 'memif' VPP module.
Package memif represents the VPP binary API of the 'memif' VPP module.
tap
Package tap represents the VPP binary API of the 'tap' VPP module.
Package tap represents the VPP binary API of the 'tap' VPP module.
vpe
Package vpe represents the VPP binary API of the 'vpe' VPP module.
Package vpe represents the VPP binary API of the 'vpe' VPP module.
vxlan
Package vxlan represents the VPP binary API of the 'vxlan' VPP module.
Package vxlan represents the VPP binary API of the 'vxlan' VPP module.
Package model is the parent for packages that define various if_plugin northbound APIs generated from protobuf data models.
Package model is the parent for packages that define various if_plugin northbound APIs generated from protobuf data models.
bfd
Package bfd is a generated protocol buffer package.
Package bfd is a generated protocol buffer package.
interfaces
Package interfaces is a generated protocol buffer package.
Package interfaces is a generated protocol buffer package.
Package testing provides tools and input data for unit testing of ifplugin.
Package testing provides tools and input data for unit testing of ifplugin.

Jump to

Keyboard shortcuts

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