vppcalls

package
v2.0.0-beta+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2019 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package vppcalls contains wrappers over VPP binary APIs for all supported interface types and for dumping all interfaces configured in VPP.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client added in v1.8.1

type Client struct {
	SwIfIndex        uint32
	Hostname         string
	ID               string
	WantDhcpEvent    bool
	SetBroadcastFlag bool
	Pid              uint32
}

Client is helper struct grouping DHCP client data

type Dhcp added in v1.8.1

type Dhcp struct {
	Client *Client `json:"dhcp_client"`
	Lease  *Lease  `json:"dhcp_lease"`
}

Dhcp is helper struct for DHCP metadata, split to client and lease (similar to VPP binary API)

type IfVppAPI added in v1.8.1

type IfVppAPI interface {
	IfVppWrite
	IfVppRead
}

IfVppAPI provides methods for creating and managing interface plugin

type IfVppHandler added in v1.8.1

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

IfVppHandler is accessor for interface-related vppcalls methods

func NewIfVppHandler added in v1.8.1

func NewIfVppHandler(callsChan api.Channel, log logging.Logger) *IfVppHandler

NewIfVppHandler creates new instance of interface vppcalls handler

func (*IfVppHandler) AddAfPacketInterface added in v1.8.1

func (h *IfVppHandler) AddAfPacketInterface(ifName string, hwAddr string, afPacketIntf *interfaces.AfpacketLink) (swIndex uint32, err error)

AddAfPacketInterface implements AfPacket handler.

func (*IfVppHandler) AddContainerIP added in v1.8.1

func (h *IfVppHandler) AddContainerIP(ifIdx uint32, addr string) error

AddContainerIP implements interface handler.

func (*IfVppHandler) AddIPSecTunnelInterface

func (h *IfVppHandler) AddIPSecTunnelInterface(ifName string, ipSecLink *interfaces.IPSecLink) (uint32, error)

AddIPSecTunnelInterface adds a new IPSec tunnel interface.

func (*IfVppHandler) AddInterfaceIP added in v1.8.1

func (h *IfVppHandler) AddInterfaceIP(ifIdx uint32, addr *net.IPNet) error

AddInterfaceIP implements interface handler.

func (*IfVppHandler) AddLoopbackInterface added in v1.8.1

func (h *IfVppHandler) AddLoopbackInterface(ifName string) (swIndex uint32, err error)

AddLoopbackInterface implements interface handler.

func (*IfVppHandler) AddMemifInterface added in v1.8.1

func (h *IfVppHandler) AddMemifInterface(ifName string, memIface *interfaces.MemifLink, socketID uint32) (swIdx uint32, err error)

AddMemifInterface implements interface handler.

func (*IfVppHandler) AddTapInterface added in v1.8.1

func (h *IfVppHandler) AddTapInterface(ifName string, tapIf *interfaces.TapLink) (swIfIdx uint32, err error)

AddTapInterface implements interface handler.

func (*IfVppHandler) AddVmxNet3 added in v1.8.1

func (h *IfVppHandler) AddVmxNet3(ifName string, vmxNet3 *interfaces.VmxNet3Link) (swIdx uint32, err error)

AddVmxNet3 implements interface handler

func (*IfVppHandler) AddVxLanTunnel added in v1.8.1

func (h *IfVppHandler) AddVxLanTunnel(ifName string, vrf, multicastIf uint32, vxLan *interfaces.VxlanLink) (swIndex uint32, err error)

AddVxLanTunnel implements VxLan handler.

func (*IfVppHandler) CreateSubif

func (h *IfVppHandler) CreateSubif(ifIdx, vlanID uint32) (uint32, error)

CreateSubif creates sub interface.

func (*IfVppHandler) CreateVrf added in v1.8.1

func (h *IfVppHandler) CreateVrf(vrfID uint32) error

CreateVrf implements interface handler.

func (*IfVppHandler) CreateVrfIPv6 added in v1.8.1

func (h *IfVppHandler) CreateVrfIPv6(vrfID uint32) error

CreateVrfIPv6 implements interface handler.

func (*IfVppHandler) DelContainerIP added in v1.8.1

func (h *IfVppHandler) DelContainerIP(ifIdx uint32, addr string) error

DelContainerIP implements interface handler.

func (*IfVppHandler) DelInterfaceIP added in v1.8.1

func (h *IfVppHandler) DelInterfaceIP(ifIdx uint32, addr *net.IPNet) error

DelInterfaceIP implements interface handler.

func (*IfVppHandler) DeleteAfPacketInterface added in v1.8.1

func (h *IfVppHandler) DeleteAfPacketInterface(ifName string, idx uint32, afPacketIntf *interfaces.AfpacketLink) error

DeleteAfPacketInterface implements AfPacket handler.

func (*IfVppHandler) DeleteIPSecTunnelInterface

func (h *IfVppHandler) DeleteIPSecTunnelInterface(ifName string, ipSecLink *interfaces.IPSecLink) error

DeleteIPSecTunnelInterface removes existing IPSec tunnel interface.

func (*IfVppHandler) DeleteLoopbackInterface added in v1.8.1

func (h *IfVppHandler) DeleteLoopbackInterface(ifName string, idx uint32) error

DeleteLoopbackInterface implements interface handler.

func (*IfVppHandler) DeleteMemifInterface added in v1.8.1

func (h *IfVppHandler) DeleteMemifInterface(ifName string, idx uint32) error

DeleteMemifInterface implements interface handler.

func (*IfVppHandler) DeleteSubif

func (h *IfVppHandler) DeleteSubif(ifIdx uint32) error

DeleteSubif deletes sub interface.

func (*IfVppHandler) DeleteTapInterface added in v1.8.1

func (h *IfVppHandler) DeleteTapInterface(ifName string, idx uint32, version uint32) error

DeleteTapInterface implements interface handler.

func (*IfVppHandler) DeleteVmxNet3

func (h *IfVppHandler) DeleteVmxNet3(ifName string, ifIdx uint32) error

DeleteVmxNet3 implements interface handler

func (*IfVppHandler) DeleteVxLanTunnel added in v1.8.1

func (h *IfVppHandler) DeleteVxLanTunnel(ifName string, idx, vrf uint32, vxLan *interfaces.VxlanLink) error

DeleteVxLanTunnel implements VxLan handler.

func (*IfVppHandler) DumpDhcpClients

func (h *IfVppHandler) DumpDhcpClients() (map[uint32]*Dhcp, error)

DumpDhcpClients returns a slice of DhcpMeta with all interfaces and other DHCP-related information available

func (*IfVppHandler) DumpInterfaces added in v1.8.1

func (h *IfVppHandler) DumpInterfaces() (map[uint32]*InterfaceDetails, error)

DumpInterfaces implements interface handler.

func (*IfVppHandler) DumpInterfacesByType added in v1.8.1

func (h *IfVppHandler) DumpInterfacesByType(reqType interfaces.Interface_Type) (map[uint32]*InterfaceDetails, error)

DumpInterfacesByType implements interface handler.

func (*IfVppHandler) DumpMemifSocketDetails added in v1.8.1

func (h *IfVppHandler) DumpMemifSocketDetails() (map[string]uint32, error)

DumpMemifSocketDetails implements interface handler.

func (*IfVppHandler) GetInterfaceVrf added in v1.8.1

func (h *IfVppHandler) GetInterfaceVrf(ifIdx uint32) (vrfID uint32, err error)

GetInterfaceVrf implements interface handler.

func (*IfVppHandler) GetInterfaceVrfIPv6 added in v1.8.1

func (h *IfVppHandler) GetInterfaceVrfIPv6(ifIdx uint32) (vrfID uint32, err error)

GetInterfaceVrfIPv6 implements interface handler.

func (*IfVppHandler) InterfaceAdminDown added in v1.8.1

func (h *IfVppHandler) InterfaceAdminDown(ifIdx uint32) error

InterfaceAdminDown implements interface handler.

func (*IfVppHandler) InterfaceAdminUp added in v1.8.1

func (h *IfVppHandler) InterfaceAdminUp(ifIdx uint32) error

InterfaceAdminUp implements interface handler.

func (*IfVppHandler) RegisterMemifSocketFilename added in v1.8.1

func (h *IfVppHandler) RegisterMemifSocketFilename(filename []byte, id uint32) error

RegisterMemifSocketFilename implements interface handler.

func (*IfVppHandler) RemoveInterfaceTag added in v1.8.1

func (h *IfVppHandler) RemoveInterfaceTag(tag string, ifIdx uint32) error

RemoveInterfaceTag implements interface handler.

func (*IfVppHandler) SetInterfaceAsDHCPClient added in v1.8.1

func (h *IfVppHandler) SetInterfaceAsDHCPClient(ifIdx uint32, hostName string) error

SetInterfaceAsDHCPClient implements interface handler.

func (*IfVppHandler) SetInterfaceMac added in v1.8.1

func (h *IfVppHandler) SetInterfaceMac(ifIdx uint32, macAddress string) error

SetInterfaceMac implements interface handler.

func (*IfVppHandler) SetInterfaceMtu added in v1.8.1

func (h *IfVppHandler) SetInterfaceMtu(ifIdx uint32, mtu uint32) error

SetInterfaceMtu implements interface handler.

func (*IfVppHandler) SetInterfaceTag added in v1.8.1

func (h *IfVppHandler) SetInterfaceTag(tag string, ifIdx uint32) error

SetInterfaceTag implements interface handler.

func (*IfVppHandler) SetInterfaceVrf added in v1.8.1

func (h *IfVppHandler) SetInterfaceVrf(ifIdx, vrfID uint32) error

SetInterfaceVrf implements interface handler.

func (*IfVppHandler) SetInterfaceVrfIPv6 added in v1.8.1

func (h *IfVppHandler) SetInterfaceVrfIPv6(ifIdx, vrfID uint32) error

SetInterfaceVrfIPv6 implements interface handler.

func (*IfVppHandler) SetRxMode added in v1.8.1

func (h *IfVppHandler) SetRxMode(ifIdx uint32, rxModeSettings *interfaces.Interface_RxModeSettings) error

SetRxMode implements interface handler.

func (*IfVppHandler) SetRxPlacement added in v1.8.1

func (h *IfVppHandler) SetRxPlacement(ifIdx uint32, rxPlacement *interfaces.Interface_RxPlacementSettings) error

SetRxPlacement implements interface handler.

func (*IfVppHandler) SetUnnumberedIP added in v1.8.1

func (h *IfVppHandler) SetUnnumberedIP(uIfIdx uint32, ifIdxWithIP uint32) error

SetUnnumberedIP implements interface handler.

func (*IfVppHandler) UnsetInterfaceAsDHCPClient added in v1.8.1

func (h *IfVppHandler) UnsetInterfaceAsDHCPClient(ifIdx uint32, hostName string) error

UnsetInterfaceAsDHCPClient implements interface handler.

func (*IfVppHandler) UnsetUnnumberedIP added in v1.8.1

func (h *IfVppHandler) UnsetUnnumberedIP(uIfIdx uint32) error

UnsetUnnumberedIP implements interface handler.

type IfVppRead added in v1.8.1

type IfVppRead interface {
	// DumpInterfaces dumps VPP interface data into the northbound API data structure
	// map indexed by software interface index.
	//
	// LIMITATIONS:
	// - there is no af_packet dump binary API. We relay on naming conventions of the internal VPP interface names
	// - ip.IPAddressDetails has wrong internal structure, as a workaround we need to handle them as notifications
	DumpInterfaces() (map[uint32]*InterfaceDetails, error)
	// DumpInterfacesByType returns all VPP interfaces of the specified type
	DumpInterfacesByType(reqType interfaces.Interface_Type) (map[uint32]*InterfaceDetails, error)
	// GetInterfaceVrf reads VRF table to interface
	GetInterfaceVrf(ifIdx uint32) (vrfID uint32, err error)
	// GetInterfaceVrfIPv6 reads IPv6 VRF table to interface
	GetInterfaceVrfIPv6(ifIdx uint32) (vrfID uint32, err error)
	// DumpMemifSocketDetails dumps memif socket details from the VPP
	DumpMemifSocketDetails() (map[string]uint32, error)
	// DumpDhcpClients dumps DHCP-related information for all interfaces.
	DumpDhcpClients() (map[uint32]*Dhcp, error)
}

IfVppRead provides read methods for interface plugin

type IfVppWrite added in v1.8.1

type IfVppWrite interface {
	// AddAfPacketInterface calls AfPacketCreate VPP binary API.
	AddAfPacketInterface(ifName string, hwAddr string, afPacketIntf *interfaces.AfpacketLink) (swIndex uint32, err error)
	// DeleteAfPacketInterface calls AfPacketDelete VPP binary API.
	DeleteAfPacketInterface(ifName string, idx uint32, afPacketIntf *interfaces.AfpacketLink) error
	// AddLoopbackInterface calls CreateLoopback bin API.
	AddLoopbackInterface(ifName string) (swIndex uint32, err error)
	// DeleteLoopbackInterface calls DeleteLoopback bin API.
	DeleteLoopbackInterface(ifName string, idx uint32) error
	// AddMemifInterface calls MemifCreate bin API.
	AddMemifInterface(ifName string, memIface *interfaces.MemifLink, socketID uint32) (swIdx uint32, err error)
	// DeleteMemifInterface calls MemifDelete bin API.
	DeleteMemifInterface(ifName string, idx uint32) error
	// AddTapInterface calls TapConnect bin API.
	AddTapInterface(ifName string, tapIf *interfaces.TapLink) (swIfIdx uint32, err error)
	// DeleteTapInterface calls TapDelete bin API.
	DeleteTapInterface(ifName string, idx uint32, version uint32) error
	// AddVxLanTunnel calls AddDelVxLanTunnelReq with flag add=1.
	// Note: VxLAN tunnel also creates a VRF table with proper IP version if needed
	AddVxLanTunnel(ifName string, vrf, multicastIf uint32, vxLan *interfaces.VxlanLink) (swIndex uint32, err error)
	// DeleteVxLanTunnel calls AddDelVxLanTunnelReq with flag add=0.
	DeleteVxLanTunnel(ifName string, idx, vrf uint32, vxLan *interfaces.VxlanLink) error
	// AddIPSecTunnelInterface adds a new IPSec tunnel interface
	AddIPSecTunnelInterface(ifName string, ipSecLink *interfaces.IPSecLink) (uint32, error)
	// DeleteIPSecTunnelInterface removes existing IPSec tunnel interface
	DeleteIPSecTunnelInterface(ifName string, ipSecLink *interfaces.IPSecLink) error
	// AddVmxNet3 configures vmxNet3 interface. Second parameter is optional in this case.
	AddVmxNet3(ifName string, vmxNet3 *interfaces.VmxNet3Link) (uint32, error)
	// DeleteVmxNet3 removes vmxNet3 interface
	DeleteVmxNet3(ifName string, ifIdx uint32) error
	// InterfaceAdminDown calls binary API SwInterfaceSetFlagsReply with AdminUpDown=0.
	InterfaceAdminDown(ifIdx uint32) error
	// InterfaceAdminUp calls binary API SwInterfaceSetFlagsReply with AdminUpDown=1.
	InterfaceAdminUp(ifIdx uint32) error
	// SetInterfaceTag registers new interface index/tag pair
	SetInterfaceTag(tag string, ifIdx uint32) error
	// RemoveInterfaceTag un-registers new interface index/tag pair
	RemoveInterfaceTag(tag string, ifIdx uint32) error
	// SetInterfaceAsDHCPClient sets provided interface as a DHCP client
	SetInterfaceAsDHCPClient(ifIdx uint32, hostName string) error
	// UnsetInterfaceAsDHCPClient un-sets interface as DHCP client
	UnsetInterfaceAsDHCPClient(ifIdx uint32, hostName string) error
	// AddContainerIP calls IPContainerProxyAddDel VPP API with IsAdd=1
	AddContainerIP(ifIdx uint32, addr string) error
	// DelContainerIP calls IPContainerProxyAddDel VPP API with IsAdd=0
	DelContainerIP(ifIdx uint32, addr string) error
	// AddInterfaceIP calls SwInterfaceAddDelAddress bin API with IsAdd=1.
	AddInterfaceIP(ifIdx uint32, addr *net.IPNet) error
	// DelInterfaceIP calls SwInterfaceAddDelAddress bin API with IsAdd=00.
	DelInterfaceIP(ifIdx uint32, addr *net.IPNet) error
	// SetUnnumberedIP sets interface as un-numbered, linking IP address of the another interface (ifIdxWithIP)
	SetUnnumberedIP(uIfIdx uint32, ifIdxWithIP uint32) error
	// UnsetUnnumberedIP unset provided interface as un-numbered. IP address of the linked interface is removed
	UnsetUnnumberedIP(uIfIdx uint32) error
	// SetInterfaceMac calls SwInterfaceSetMacAddress bin API.
	SetInterfaceMac(ifIdx uint32, macAddress string) error
	// RegisterMemifSocketFilename registers new socket file name with provided ID.
	RegisterMemifSocketFilename(filename []byte, id uint32) error
	// SetInterfaceMtu calls HwInterfaceSetMtu bin API with desired MTU value.
	SetInterfaceMtu(ifIdx uint32, mtu uint32) error
	// SetRxMode calls SwInterfaceSetRxMode bin
	SetRxMode(ifIdx uint32, rxModeSettings *interfaces.Interface_RxModeSettings) error
	// SetRxPlacement configures rx-placement for interface
	SetRxPlacement(ifIdx uint32, rxPlacement *interfaces.Interface_RxPlacementSettings) error
	// CreateVrf checks if VRF exists and creates it if not
	CreateVrf(vrfID uint32) error
	// CreateVrfIPv6 checks if IPv6 VRF exists and creates it if not
	CreateVrfIPv6(vrfID uint32) error
	// SetInterfaceVrf retrieves VRF table from interface
	SetInterfaceVrf(ifaceIndex, vrfID uint32) error
	// SetInterfaceVrfIPv6 retrieves IPV6 VRF table from interface
	SetInterfaceVrfIPv6(ifaceIndex, vrfID uint32) error
	// CreateSubif creates sub interface.
	CreateSubif(ifIdx, vlanID uint32) (swIfIdx uint32, err error)
	// DeleteSubif deletes sub interface.
	DeleteSubif(ifIdx uint32) error
}

IfVppWrite provides write methods for interface plugin

type InterfaceDetails added in v1.8.1

type InterfaceDetails struct {
	Interface *interfaces.Interface `json:"interface"`
	Meta      *InterfaceMeta        `json:"interface_meta"`
}

InterfaceDetails is the wrapper structure for the interface northbound API structure.

type InterfaceMeta added in v1.8.1

type InterfaceMeta struct {
	SwIfIndex    uint32 `json:"sw_if_index"`
	SupSwIfIndex uint32 `json:"sub_sw_if_index"`
	Tag          string `json:"tag"`
	InternalName string `json:"internal_name"`
	Dhcp         *Dhcp  `json:"dhcp"`
	SubID        uint32 `json:"sub_id"`
	VrfIPv4      uint32 `json:"vrf_ipv4"`
	VrfIPv6      uint32 `json:"vrf_ipv6"`
	Pci          uint32 `json:"pci"`
}

InterfaceMeta is combination of proto-modelled Interface data and VPP provided metadata

type Lease added in v1.8.1

type Lease struct {
	SwIfIndex     uint32
	State         uint8
	Hostname      string
	IsIPv6        bool
	HostAddress   string
	RouterAddress string
	HostMac       string
}

Lease is helper struct grouping DHCP lease data

Jump to

Keyboard shortcuts

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