puntmgr

package
v0.0.0-...-ae01f8c Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: Apache-2.0 Imports: 38 Imported by: 0

README

Punt Manager Plugin

To "punt" can mean different things to different people. In VPP the data-plane punts when a packet cannot be handled by any further nodes. Punt differs from drop, in that VPP is giving other elements of the system the opportunity to handle this packet.

For StoneWork the meaning of punt is to send packets to the user/control-plane of a CNF (typically a 3rd party open-source software packaged alongside a CNF). This is specific option of the more general case described above, where VPP is handing the packet to the control-plane for further prosessing.

Punt Manager plugin allows for multiple ligato plugins and even distributed agents to request packet punting between a shared VPP and the same or distinct Linux network namespace(s) using TAPs or between the VPP and CNFs directly using memifs or AF-UNIX sockets. Unless there is a conflict between punt requests, the manager will ensure that common configuration items are shared and properly updated (e.g. ABX rules, TAP connection, etc.). The manager supports different kinds of packet punting approaches for L2 or L3 source VPP interfaces, with memifs, TAPs or AF-UNIX sockets used to deliver packets to the Linux network stack / user-space application.

The plugin can be used by:

  • Standalone CNF (even for a single punt it is a good practise to use the plugin),
  • StoneWork to orchestrate punt between the all-in-one VPP and every SW-Module,
  • and by a SW-Module to learn the metadata about a created punt configuration.

Supported Punt Types

Multiple different types of packet punting methods and topologies are supported to satisfy the wide-range of requirements from present and future CNFs:

  • HAIRPIN_XCONNECT: create an L2 "hairpin x-connect" using TAPs or MEMIFs as follows:
    vpp_interface1 <-> vpp tap/memif 1 <-> linux tap/memif 1 -- CNF -- linux tap/memif 2 <-> vpp tap/memif 2 <-> vpp_interface2
    
    (i.e. hairpinning over linux network stack or via memif-enabled CNF)
  • HAIRPIN: like HAIRPIN x-connect except that while one side is attached to an existing L2 VPP interface, the other side is created as memif or TAP with given attributes. Basically it is like a feature attached to VPP interface (in the form of a new interface linked with an existing one, just like tunnel interfaces), which causes all traffic arriving/leaving via that interface to also flow through a CNF/Linux network stack before entering/exiting VPP. Unlike HAIRPIN x-connect it is therefore possible to attach further processing to this traffic (x-connect just forwards it through VPP unprocessed).
  • SPAN: copy traffic arriving and/or leaving via L2/L3 interface and send it to Linux or memif-enabled CNF.
  • ABX: effectively replicate L3 VPP interface in Linux using ACL-based xConnect as follows:
    vpp-interface with IP  <-- ABX --> unnumbered vpp memif/tap interface <-> Linux Tap / CNF memif
    
    Only packets matched by ACL associated with the ABX are punted.
    Note: ABX is a proprietary feature developed by PANTHEON.tech.
  • PUNT_TO_SOCKET: Punt traffic matching given conditions (received through any interface) and punt it over a AF_UNIX socket.
  • DHCP_PROXY: Proxy DHCP requests for a given (L3) VRF into the Linux network stack or into a memif-enabled CNF.
  • ISISX: effectively replicate L3 VPP interface in Linux for ISIS protocol packets using xConnect as follows:
    vpp-interface with IP  <-- ISISX --> unnumbered vpp memif/tap interface <-> Linux Tap / CNF memif
    
    Basically it has the same goal as ABX, but ABX can't be used for ISIS protocol packets as packets for this protocol get dropped in VPP before reaching ACL VPP node.

The following diagram visually depicts all supported packet punting methods:

Punt type

Documentation

Index

Constants

View Source
const InternalConfigLabelKey = "io.ligato.from-client"

These constants specify label for Internal StoneWork configuration (that is configuration not configured by the user or SW-Modules).

View Source
const InternalConfigLabelValue = "stonework"
View Source
const (
	NotifDescriptorName = "punt-notification"
)
View Source
const (
	// PluginName is the name of the Punting Manager Plugin.
	// Config file name is `PluginName + ".conf"`
	PluginName = "puntmgr"
)

Variables

View Source
var DefaultPlugin = *NewPlugin()

DefaultPlugin is a default instance of the Punting Manager.

Functions

func HairpinInterfaceSelector

func HairpinInterfaceSelector(ifaceName string) string

HairpinInterfaceSelector is used only by Hairpin to ensure that no two hairpin punt requests would try to create hairpin interface of the same name.

func NotificationKey

func NotificationKey(cnfName, itemKey, puntLabel string) string

NotificationKey returns key of the SB notification which is sent when the given punt is fully created (i.e. metadata are generated and configuration is applied).

func NotificationKeyPrefix

func NotificationKeyPrefix(cnfName, itemKeyOrPrefix string) string

NotificationKeyPrefix return prefix of NotificationKey where punt-label and potentially some suffix from itemKey are trimmed.

func PuntSelector

func PuntSelector(puntKey string) string

PuntSelector is used only by socketPunt to ensure that no two punt requests attempt to configure the same punt rule.

func SpanInterfaceSelector

func SpanInterfaceSelector(ifaceName string) string

SpanInterfaceSelector is used only by spanPunt because SPAN can be combined with other punt types without conflicts.

func VppInterfaceSelector

func VppInterfaceSelector(ifaceName string) string

VppInterfaceSelector selects (all/some) packets received or sent through a given VPP interface. It can be used by punts that need to reserve entire interface and cannot share it with other punt types (that use this same selector). The same interface can be punted multiple times only within the same punt type if it supports multiplexing like it is the case with ABX.

func VrfSelector

func VrfSelector(vrf uint32) string

VrfSelector ensures that there is at most one DHCP proxy configured for a given VRF.

Types

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

AF-UNIX socket between VPP and a CNF.

type Config

type Config struct {
	// InterconnectAllocCIDR defines network from which /30 subnets are allocated for use by VPP<->CNF interconnects.
	InterconnectAllocCIDR string `json:"interconnect-alloc-cidr"`
}

Config file for PuntMgr plugin.

type Deps

type Deps struct {
	infra.PluginDeps
	ServiceLabel servicelabel.ReaderAPI
	GRPCServer   grpc.Server
	CnfRegistry  cnfreg_plugin.CnfRegistryAPI
	IfPlugin     ifplugin.API
	NsPlugin     nsplugin.API
	CfgClient    client.GenericClient
	KVScheduler  kvs.KVScheduler
}

Deps is a set of dependencies of the Punt Manager plugin

type InterconnectLink interface {
	// contains filtered or unexported methods
}

InterconnectLink is one of the:

  • AF-UNIX socket
  • pair of interfaces (memif or TAP)

and each type has type-specific parameters.

type InterconnectManager

type InterconnectManager interface {
	// Add new VPP<->CNF/Linux interconnects needed for a given punt.
	// localTxn = configuration items to configure on this side (StoneWork / Standalone CNF)
	// remoteTxn = configuration items to configure on the side of the StoneWork module
	AddInterconnects(localTxn, remoteTxn client.ChangeRequest, puntId puntID, reqs []InterconnectReq,
		icType pb.PuntRequest_InterconnectType, enableGso bool, withMultiplex bool) (interconnects []*pb.PuntMetadata_Interconnect, err error)
	// Delete all VPP<->CNF/Linux interconnects created for a given punt.
	DelInterconnects(localTxn, remoteTxn client.ChangeRequest, puntId puntID) (err error)
	// GetLinuxVrfName returns the name used for Linux VRF device corresponding to the given VPP VRF.
	// Method is "static" in the sense that it can be called anytime, regardless of the internal state of the Manager.
	GetLinuxVrfName(vrf uint32) string
}

InterconnectManager manages creation/deletion and sharing of VPP<->CNF/Linux interconnects.

func NewInterconnectManager

func NewInterconnectManager(log logging.Logger, ifPlugin ifplugin.API, svcLabel servicelabel.ReaderAPI, nsPlugin nsplugin.API,
	allocCidr *net.IPNet) InterconnectManager

type InterconnectReq

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

Request to build a VPP<->CNF interconnect.

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

Interface-based interconnect (either with memif or TAP).

type NetNsRegistry

type NetNsRegistry interface {
	// Get ID representing network namespace referenced by a given microservice label.
	// Network namespace used by multiple microservices will have the same ID regardless of which ms label
	// is used to query it.
	GetNetNsID(msLabel string) (int, error)

	// Each learned network namespace is used by one or more microservices. Label of one of these
	// microservices is designated to represent the namespace.
	GetNetNsLabel(id int) (msLabel string, err error)
}

NetNsRegistry keeps track of all network namespaces used by CNFs.

func NewNetNsRegistry

func NewNetNsRegistry(nsPlugin nsplugin.API, serviceLabel servicelabel.ReaderAPI) NetNsRegistry

type Option

type Option func(plugin *Plugin)

Option is a function that can be used in NewPlugin allowing plugin customization

type Plugin

type Plugin struct {
	pb.UnimplementedPuntManagerServer
	sync.Mutex

	Deps
	// contains filtered or unexported fields
}

Punt icManager plugins allows for multiple ligato plugins and even distributed agents to request packet punting between VPP and the same or distinct Linux network namespace(s). Unless there is a conflict between punt requests, the manager will ensure that common configuration items are shared and properly updated (e.g. ABX rules, TAP connection, etc.). The manager supports different kinds of packet punting approaches for L2 or L3 source VPP interfaces, with memifs, TAPs or AF-UNIX sockets used to deliver packets to the Linux network stack / user-space application. The plugin can be used by:

  • STANDALONE CNF (even for a single punt it is a good practise to use the plugin),
  • StoneWork to orchestrate punt between the all-in-one VPP and every SW-Module,
  • and by a SW-Module to learn the metadata about a created punt configuration.

func NewPlugin

func NewPlugin(opts ...Option) *Plugin

NewPlugin creates a new Plugin with provided options

func (*Plugin) AddPunt

func (p *Plugin) AddPunt(cnfMsLabel, key string, puntReq *pb.PuntRequest) error

AddPunt is used by StoneWork or standalone CNF to configure punt between VPP and the CNF. If cnfMsLabel is empty then microservice label of this CNF is assumed (returned by ServiceLabel plugin).

func (*Plugin) Close

func (p *Plugin) Close() error

Close is NOOP.

func (*Plugin) DelPunt

func (p *Plugin) DelPunt(cnfMsLabel, key, label string) error

DelPunt is used by StoneWork or standalone CNF to un-configure punt between VPP and the CNF. If cnfMsLabel is empty then microservice label of this CNF is assumed (returned by ServiceLabel plugin).

func (*Plugin) GetAllCNFPunts

func (p *Plugin) GetAllCNFPunts(cnfMsLabel string) (punts []*pb.PuntMetadata)

GetAllCNFPunts returns metadata of all punts created for the given CNF. If cnfMsLabel is empty then microservice label of this CNF is assumed (returned by ServiceLabel plugin).

func (*Plugin) GetLinuxVrfName

func (p *Plugin) GetLinuxVrfName(vrf uint32) string

GetLinuxVrfName returns the name used for Linux VRF device corresponding to the given VPP VRF. Method is "static" in the sense that it can be called anytime, regardless of the internal state of the plugin.

func (*Plugin) GetPuntDependencies

func (p *Plugin) GetPuntDependencies(cnfMsLabel string, punt *pb.PuntRequest) (deps []kvs.Dependency)

GetPuntDependencies returns dependencies that have to be satisfied before the punt can be added.

func (*Plugin) GetPuntMetadata

func (p *Plugin) GetPuntMetadata(cnfMsLabel, key, label string) *pb.PuntMetadata

GetPuntMetadata returns metadata about configured packet punting between VPP and the CNF. If cnfMsLabel is empty then microservice label of this CNF is assumed (returned by ServiceLabel plugin).

func (*Plugin) Init

func (p *Plugin) Init() (err error)

Init initializes internal attributes and in the case of STONEWORK_MODULE also starts gRPC server for RegisterCreatedPunt and UnregisterDeletedPunt methods.

func (*Plugin) UpdatePuntState

func (p *Plugin) UpdatePuntState(_ context.Context, req *pb.UpdatePuntStateReq) (resp *pb.UpdatePuntStateResp, err error)

UpdatePuntState is called by Punt Manager of StoneWork to notify SW-Module about state change of a punt.

type PuntHandler

type PuntHandler interface {
	// GetInterconnectReqs returns definitions of all interconnects which are required between VPP and CNF
	// for this punt request.
	GetInterconnectReqs(punt *pb.PuntRequest) []InterconnectReq

	// GetPuntDependencies returns dependencies that have to be satisfied before the punt can be added.
	GetPuntDependencies(punt *pb.PuntRequest) (deps []kvs.Dependency)

	// CanMultiplex enables interconnection multiplexing for this punting. It could be enabled in certain cases:
	// 1. two or more punts of this type can coexist even if they have the same vpp selector
	// 2. one or more punts of this type can coexist with other type of punts on the same (TAP-only)
	// interconnection if they all have the same vpp selector and cnf selector.
	// The TAP-backed interconnection is shared for multiple multiplexing punts with the same cnf selector
	// (same network namespace) and vpp selector.
	CanMultiplex() bool

	// ConfigurePunt prepares txn to (un)configures VPP-side of the punt.
	ConfigurePunt(txn client.ChangeRequest, puntId puntID, puntReq *pb.PuntRequest,
		interconnects []*pb.PuntMetadata_Interconnect, remove bool) error
}

PuntHandler should be implemented one for each punt type.

func NewAbxPuntHandler

func NewAbxPuntHandler(ifPlugin ifplugin.API) PuntHandler

func NewDhcpProxyPuntHandler

func NewDhcpProxyPuntHandler() PuntHandler

func NewHairpinPuntHandler

func NewHairpinPuntHandler() PuntHandler

func NewHairpinXConnPuntHandler

func NewHairpinXConnPuntHandler() PuntHandler

func NewIsisxPuntHandler

func NewIsisxPuntHandler() PuntHandler

func NewSocketPuntHandler

func NewSocketPuntHandler() PuntHandler

func NewSpanPuntHandler

func NewSpanPuntHandler() PuntHandler

type PuntManagerAPI

type PuntManagerAPI interface {
	// GetPuntMetadata returns metadata about configured packet punt between VPP and the CNF.
	// If cnfMsLabel is empty then microservice label of this CNF is assumed (returned by ServiceLabel plugin).
	GetPuntMetadata(cnfMsLabel, key, label string) *pb.PuntMetadata
	// GetAllCNFPunts returns metadata of all punts created for the given CNF.
	// If cnfMsLabel is empty then microservice label of this CNF is assumed (returned by ServiceLabel plugin).
	GetAllCNFPunts(cnfMsLabel string) []*pb.PuntMetadata
	// AddPunt is used by StoneWork or standalone CNF to configure punt between VPP and the CNF.
	// If cnfMsLabel is empty then microservice label of this CNF is assumed (returned by ServiceLabel plugin).
	AddPunt(cnfMsLabel, key string, punt *pb.PuntRequest) error
	// DelPunt is used by StoneWork or standalone CNF to un-configure punt between VPP and the CNF.
	// If cnfMsLabel is empty then microservice label of this CNF is assumed (returned by ServiceLabel plugin).
	DelPunt(cnfMsLabel, key string, label string) error
	// GetPuntDependencies returns dependencies that have to be satisfied before the punt can be added.
	GetPuntDependencies(cnfMsLabel string, punt *pb.PuntRequest) (deps []kvs.Dependency)
}

Punt Manager API.

type PuntManagerNamingAPI

type PuntManagerNamingAPI interface {
	// GetLinuxVrfName returns the name used for Linux VRF device corresponding to the given VPP VRF.
	// Method is "static" in the sense that it can be called anytime, regardless of the internal state of the plugin.
	// Deprecated: use Punt metadata that can be obtained using GetPuntMetadata().
	GetLinuxVrfName(vrf uint32) string
}

API to obtain names of configuration items generated for punts. Deprecated: use Punt metadata that can be obtained using GetPuntMetadata().

Jump to

Keyboard shortcuts

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