cniIntf

package
v0.0.0-...-b98a061 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

***************************************************************************

  • Base class for interface managed by Contrail Cni ***************************************************************************

***************************************************************************

  • File responsible to create and configure macvlan interfaces

  • This is typically used in nested-k8s scenario where containers are spawned

  • inside the container. The VMI for container is modeled as sub-interface in

  • this case.

  • The class creates a vlan-interface corresponding to the vlan in

  • sub-interface and then creates a macvlan interface over it. ***************************************************************************

***************************************************************************

  • File responsible to create and configure veth interfaces ***************************************************************************

Index

Constants

View Source
const CNI_ID_IFNAME_END_LEN = 5

Number of characters from end to pick from container-id for ifname

View Source
const CNI_ID_IFNAME_START_LEN = 5

Number of characters from start to pick from container-id for ifname

View Source
const CNI_MTU = 1500

Default MTU for interface configured

View Source
const CNI_UUID_IFNAME_LEN = 11

Number of characters to pick from UUID for ifname

View Source
const INTF_ALIAS = "contrail-k8s-cni-vlan-"

Prefix for macvlan interface alias

Variables

This section is empty.

Functions

This section is empty.

Types

type CniIntf

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

Base definition for CniIntf

func (CniIntf) Configure

func (intf CniIntf) Configure(mac string, result *current.Result) error

Configure MAC address and IP address on the interface Assumes that interface inside container is already created.

func (CniIntf) DeleteByAlias

func (intf CniIntf) DeleteByAlias(intfAlias string) error

DeleteByAlias deletes an interface with the given link alias

func (CniIntf) DeleteByName

func (intf CniIntf) DeleteByName(ifName string) error

Delete an interface with given name Every interface inside a container has a peer in host-namespace. Deleting the interface in host-namespace deletes interface in container also. The API is used to delete interface in host-namespace

type CniIntfMethods

type CniIntfMethods interface {
	Log()
	Create() error
	Delete() error
	Configure(mac string, result *current.Result) error
	GetHostIfName() string
}

Common methods for all CniIntf

type MacVlan

type MacVlan struct {
	CniIntf
	// parent interface on which vlan-interface is created
	ParentIfName string
	// contains filtered or unexported fields
}

Definition for MacVlan interfaces

func InitMacVlan

func InitMacVlan(parentIfName, containerIfName, containerId, containerUuid,
	containerNamespace string, mtu, vlanId int) MacVlan

Create MacVlan interface object

func (MacVlan) Create

func (intf MacVlan) Create() error

Create MacVlan interfaces.

func (MacVlan) Delete

func (intf MacVlan) Delete() error

Remove macvlan interface Deletes the vlan interface from host-os. It will automatically remove the corresponding interface from container namespace also

func (MacVlan) GetHostIfName

func (intf MacVlan) GetHostIfName() string

func (MacVlan) Log

func (intf MacVlan) Log()

type VEth

type VEth struct {
	CniIntf
	HostIfName string
	// Since HostIfName interface is in host-namespace, veth interface is
	// initially created in host-namespace with a temporary name. The temporary
	// interface is then moved to container-namespace with containerIfName
	TmpHostIfName string
}

Definition for veth interface

func InitVEth

func InitVEth(containerIfName, containerId, containerUuid,
	containerNamespace string, mtu int) VEth

func (VEth) Create

func (intf VEth) Create() error

Create veth interfaces. One end of interface will be inside container and another end in host-os network namespace

func (VEth) Delete

func (intf VEth) Delete() error

Remove veth interface Deletes the tap interface from host-os. It will automatically remove the corresponding interface from container namespace also

func (VEth) GetHostIfName

func (intf VEth) GetHostIfName() string

func (VEth) Log

func (intf VEth) Log()

Jump to

Keyboard shortcuts

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