config

package
v3.27.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CNIServerSocket      = "/var/run/calico/cni-server.sock"
	FelixDataplaneSocket = "/var/run/calico/felix-dataplane.sock"
	VppAPISocket         = "/var/run/vpp/vpp-api.sock"
	VppManagerInfoFile   = "/var/run/vpp/vppmanagerinfofile"
	CniServerStateFile   = "/var/run/vpp/calico_vpp_pod_state"
	CalicoVppPidFile     = "/var/run/vpp/calico_vpp.pid"
	CalicoVppVersionFile = "/etc/calicovppversion"

	DefaultVXLANVni      = 4096
	DefaultVXLANPort     = 4789
	DefaultWireguardPort = 51820

	VppConfigFile     = "/etc/vpp/startup.conf"
	VppConfigExecFile = "/etc/vpp/startup.exec"
	VppApiSocket      = "/var/run/vpp/vpp-api.sock"
	VppPath           = "/usr/bin/vpp"
	VppNetnsName      = "calico-vpp-ns"
	VppSigKillTimeout = 2
	DefaultEncapSize  = 60 // Used to lower the MTU of the routes to the cluster

	DefaultPhysicalNetworkName = ""

	// BaseVppSideHardwareAddress is the base hardware address of VPP side of the HostPunt
	// tap interface. It is used to generate hardware addresses for each uplink interface.
	BaseVppSideHardwareAddress = "02:ca:11:c0:fd:00"
)
View Source
const (
	DRIVER_UIO_PCI_GENERIC = "uio_pci_generic"
	DRIVER_VFIO_PCI        = "vfio-pci"
	DRIVER_VIRTIO_PCI      = "virtio-pci"
	DRIVER_I40E            = "i40e"
	DRIVER_ICE             = "ice"
	DRIVER_MLX5_CORE       = "mlx5_core"
	DRIVER_VMXNET3         = "vmxnet3"
)
View Source
const (
	Ready    vppManagerStatus = "ready"
	Starting vppManagerStatus = "starting"
)

Variables

View Source
var (
	// fake constants for place where we need a pointer to true or false
	True  = true
	False = false

	NodeName    = RequiredStringEnvVar("NODENAME")
	LogLevel    = EnvVar("CALICOVPP_LOG_LEVEL", logrus.InfoLevel, logrus.ParseLevel)
	BGPLogLevel = EnvVar("CALICOVPP_BGP_LOG_LEVEL", apipb.SetLogLevelRequest_INFO, BGPLogLevelParse)

	ServiceCIDRs                     = PrefixListEnvVar("SERVICE_PREFIX")
	IPSecIkev2Psk                    = StringEnvVar("CALICOVPP_IPSEC_IKEV2_PSK", "")
	CalicoVppDebug                   = JsonEnvVar("CALICOVPP_DEBUG", &CalicoVppDebugConfigType{})
	CalicoVppInterfaces              = JsonEnvVar("CALICOVPP_INTERFACES", &CalicoVppInterfacesConfigType{})
	CalicoVppFeatureGates            = JsonEnvVar("CALICOVPP_FEATURE_GATES", &CalicoVppFeatureGatesConfigType{})
	CalicoVppIpsec                   = JsonEnvVar("CALICOVPP_IPSEC", &CalicoVppIpsecConfigType{})
	CalicoVppSrv6                    = JsonEnvVar("CALICOVPP_SRV6", &CalicoVppSrv6ConfigType{})
	CalicoVppInitialConfig           = JsonEnvVar("CALICOVPP_INITIAL_CONFIG", &CalicoVppInitialConfigConfigType{})
	CalicoVppGracefulShutdownTimeout = EnvVar("CALICOVPP_GRACEFUL_SHUTDOWN_TIMEOUT", 10*time.Second, time.ParseDuration)
	LogFormat                        = StringEnvVar("CALICOVPP_LOG_FORMAT", "")

	/* Deprecated vars */
	/* linux name of the uplink interface to be used by VPP */
	InterfaceVar = StringEnvVar("CALICOVPP_INTERFACE", "")
	/* Driver to consume the uplink with. Leave empty for autoconf */
	NativeDriver = StringEnvVar("CALICOVPP_NATIVE_DRIVER", "")
	SwapDriver   = StringEnvVar("CALICOVPP_SWAP_DRIVER", "")

	/* Bash script template run before getting config
	   from $CALICOVPP_INTERFACE (same as
	   CALICOVPP_HOOK_BEFORE_IF_READ)*/
	InitScriptTemplate = StringEnvVar("CALICOVPP_INIT_SCRIPT_TEMPLATE", "")

	/* Template for VppConfigFile (/etc/vpp/startup.conf)
	   It contains the VPP startup configuration */
	ConfigTemplate = RequiredStringEnvVar("CALICOVPP_CONFIG_TEMPLATE")

	/* Template for VppConfigExecFile (/etc/vpp/startup.exec)
	   It contains the CLI to be executed in vppctl after startup */
	ConfigExecTemplate = StringEnvVar("CALICOVPP_CONFIG_EXEC_TEMPLATE", "")

	//go:embed default_hook.sh
	DEFAULT_HOOK_SCRIPT string

	/* Run this before getLinuxConfig() in case this is a script
	 * that's responsible for creating the interface */
	HookScriptBeforeIfRead = StringEnvVar("CALICOVPP_HOOK_BEFORE_IF_READ", DEFAULT_HOOK_SCRIPT) // InitScriptTemplate
	/* Bash script template run just after getting config
	   from $CALICOVPP_INTERFACE & before starting VPP */
	HookScriptBeforeVppRun = StringEnvVar("CALICOVPP_HOOK_BEFORE_VPP_RUN", DEFAULT_HOOK_SCRIPT) // InitPostIfScriptTemplate
	/* Bash script template run after VPP has started */
	HookScriptVppRunning = StringEnvVar("CALICOVPP_HOOK_VPP_RUNNING", DEFAULT_HOOK_SCRIPT) // FinalizeScriptTemplate
	/* Bash script template run when VPP stops gracefully */
	HookScriptVppDoneOk = StringEnvVar("CALICOVPP_HOOK_VPP_DONE_OK", DEFAULT_HOOK_SCRIPT)
	/* Bash script template run when VPP stops with an error */
	HookScriptVppErrored = StringEnvVar("CALICOVPP_HOOK_VPP_ERRORED", DEFAULT_HOOK_SCRIPT)

	AllHooks = []*string{
		HookScriptBeforeIfRead,
		HookScriptBeforeVppRun,
		HookScriptVppRunning,
		HookScriptVppDoneOk,
		HookScriptVppErrored,
	}

	Info = &VppManagerInfo{}

	// VppHostPuntFakeGatewayAddress is the fake gateway we use with a static neighbor
	// in the punt table to route punted packets to the host
	VppHostPuntFakeGatewayAddress = net.ParseIP("169.254.0.1")
)

Functions

func AddrEnvVar

func AddrEnvVar(varName string, defaultValue net.IP) *net.IP

func AddrListEnvVar

func AddrListEnvVar(varName string) *[]net.IP

func BGPLogLevelParse added in v3.26.0

func BGPLogLevelParse(lvl string) (apipb.SetLogLevelRequest_Level, error)

func BoolEnvVar

func BoolEnvVar(varName string, defaultValue bool) *bool

func EnvVar

func EnvVar[T any](varName string, defaultValue T, parser func(string) (T, error)) *T

func IntEnvVar

func IntEnvVar(varName string, defaultValue int) *int

func JsonEnvVar

func JsonEnvVar[T any](varName string, defaultValue T) *T

JsonEnvVar allows to declare envvars containing structs formatted as json * defaultValue should be a pointer to a SomeStructType * this returns a **SomeStructType * if SomeStructType implements Validable (pointer receiver) it will be run as part of the parsing process, allowing to set defaults.

func LoadConfig

func LoadConfig(log *logrus.Logger) (err error)

func LoadConfigSilent

func LoadConfigSilent(log *logrus.Logger) (err error)

func ParseAllEnvVars

func ParseAllEnvVars() []error

func ParseEnvVars

func ParseEnvVars(varNames ...string) []error

func PrefixEnvVar

func PrefixEnvVar(varName string) *net.IPNet

func PrefixListEnvVar

func PrefixListEnvVar(varName string) *[]*net.IPNet

func PrintAgentConfig

func PrintAgentConfig(log *logrus.Logger)

func PrintEnvVarConfig

func PrintEnvVarConfig(log *logrus.Logger)

func RequiredAddrEnvVar

func RequiredAddrEnvVar(varName string) *net.IP

func RequiredAddrListEnvVar

func RequiredAddrListEnvVar(varName string) *[]net.IP

func RequiredEnvVar

func RequiredEnvVar[T any](varName string, defaultValue T, parser func(string) (T, error)) *T

func RequiredPrefixEnvVar

func RequiredPrefixEnvVar(varName string) *net.IPNet

func RequiredPrefixListEnvVar

func RequiredPrefixListEnvVar(varName string) *[]*net.IPNet

func RequiredStringEnvVar

func RequiredStringEnvVar(varName string) *string

func RunHook added in v3.26.0

func RunHook(hookScript *string, hookName string, params *VppManagerParams, log *logrus.Logger)

func StringEnvVar

func StringEnvVar(varName string, defaultValue string) *string

func StringListEnvVar

func StringListEnvVar(varName string, defaultValue []string) *[]string

func TemplateScriptReplace

func TemplateScriptReplace(input string, params *VppManagerParams, conf []*LinuxInterfaceState) (template string, err error)

func Uint16EnvVar

func Uint16EnvVar(varName string, defaultValue uint16) *uint16

func Uint32EnvVar

func Uint32EnvVar(varName string, defaultValue uint32) *uint32

Types

type CalicoVppDebugConfigType

type CalicoVppDebugConfigType struct {
	PoliciesEnabled *bool `json:"policiesEnabled,omitempty"`
	ServicesEnabled *bool `json:"servicesEnabled,omitempty"`
	GSOEnabled      *bool `json:"gsoEnabled,omitempty"`
}

func GetCalicoVppDebug

func GetCalicoVppDebug() *CalicoVppDebugConfigType

func (*CalicoVppDebugConfigType) String

func (self *CalicoVppDebugConfigType) String() string

func (*CalicoVppDebugConfigType) Validate

func (self *CalicoVppDebugConfigType) Validate() (err error)

type CalicoVppFeatureGatesConfigType

type CalicoVppFeatureGatesConfigType struct {
	MemifEnabled    *bool `json:"memifEnabled,omitempty"`
	VCLEnabled      *bool `json:"vclEnabled,omitempty"`
	MultinetEnabled *bool `json:"multinetEnabled,omitempty"`
	SRv6Enabled     *bool `json:"srv6Enabled,omitempty"`
	IPSecEnabled    *bool `json:"ipsecEnabled,omitempty"`
}

func GetCalicoVppFeatureGates

func GetCalicoVppFeatureGates() *CalicoVppFeatureGatesConfigType

func (*CalicoVppFeatureGatesConfigType) String

func (self *CalicoVppFeatureGatesConfigType) String() string

func (*CalicoVppFeatureGatesConfigType) Validate

func (self *CalicoVppFeatureGatesConfigType) Validate() (err error)

type CalicoVppInitialConfigConfigType

type CalicoVppInitialConfigConfigType struct {
	VppStartupSleepSeconds int `json:"vppStartupSleepSeconds"`
	/* Set the pattern for VPP corefiles. Usually "/var/lib/vpp/vppcore.%e.%p" */
	CorePattern      string `json:"corePattern"`
	ExtraAddrCount   int    `json:"extraAddrCount"`
	IfConfigSavePath string `json:"ifConfigSavePath"`
	/* Comma separated list of IPs to be configured in VPP as default GW */
	DefaultGWs string `json:"defaultGWs"`
	/* List of rules for redirecting traffic to host */
	RedirectToHostRules []RedirectToHostRulesConfigType `json:"redirectToHostRules"`
}

func GetCalicoVppInitialConfig

func GetCalicoVppInitialConfig() *CalicoVppInitialConfigConfigType

func (*CalicoVppInitialConfigConfigType) GetDefaultGWs

func (self *CalicoVppInitialConfigConfigType) GetDefaultGWs() (gws []net.IP, err error)

func (*CalicoVppInitialConfigConfigType) String

func (*CalicoVppInitialConfigConfigType) Validate

func (self *CalicoVppInitialConfigConfigType) Validate() (err error)

type CalicoVppInterfacesConfigType

type CalicoVppInterfacesConfigType struct {
	DefaultPodIfSpec *InterfaceSpec        `json:"defaultPodIfSpec,omitempty"`
	MaxPodIfSpec     *InterfaceSpec        `json:"maxPodIfSpec,omitempty"`
	VppHostTapSpec   *InterfaceSpec        `json:"vppHostTapSpec,omitempty"`
	UplinkInterfaces []UplinkInterfaceSpec `json:"uplinkInterfaces,omitempty"`
}

func GetCalicoVppInterfaces

func GetCalicoVppInterfaces() *CalicoVppInterfacesConfigType

func (*CalicoVppInterfacesConfigType) String

func (self *CalicoVppInterfacesConfigType) String() string

func (*CalicoVppInterfacesConfigType) Validate

func (self *CalicoVppInterfacesConfigType) Validate() (err error)

type CalicoVppIpsecConfigType

type CalicoVppIpsecConfigType struct {
	CrossIpsecTunnels        *bool `json:"crossIPSecTunnels,omitempty"`
	IpsecNbAsyncCryptoThread int   `json:"nbAsyncCryptoThreads"`
	ExtraAddresses           int   `json:"extraAddresses"`
}

func GetCalicoVppIpsec

func GetCalicoVppIpsec() *CalicoVppIpsecConfigType

func (*CalicoVppIpsecConfigType) GetIpsecAddressCount

func (self *CalicoVppIpsecConfigType) GetIpsecAddressCount() int

func (*CalicoVppIpsecConfigType) GetIpsecNbAsyncCryptoThread

func (self *CalicoVppIpsecConfigType) GetIpsecNbAsyncCryptoThread() int

func (*CalicoVppIpsecConfigType) String

func (self *CalicoVppIpsecConfigType) String() string

func (*CalicoVppIpsecConfigType) Validate

func (self *CalicoVppIpsecConfigType) Validate() (err error)

type CalicoVppSrv6ConfigType

type CalicoVppSrv6ConfigType struct {
	LocalsidPool string `json:"localsidPool"`
	PolicyPool   string `json:"policyPool"`
}

func GetCalicoVppSrv6

func GetCalicoVppSrv6() *CalicoVppSrv6ConfigType

func (*CalicoVppSrv6ConfigType) String

func (self *CalicoVppSrv6ConfigType) String() string

func (*CalicoVppSrv6ConfigType) Validate

func (self *CalicoVppSrv6ConfigType) Validate() (err error)

type EnvVarParser

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

type InterfaceSpec

type InterfaceSpec struct {
	NumRxQueues int   `json:"rx"`
	NumTxQueues int   `json:"tx"`
	RxQueueSize int   `json:"rxqsz"`
	TxQueueSize int   `json:"txqsz"`
	IsL3        *bool `json:"isl3"`
	/* "interrupt" "adaptive" or "polling" mode */
	RxMode types.RxMode `json:"rxMode"`
}

func (*InterfaceSpec) GetBuffersNeeded

func (i *InterfaceSpec) GetBuffersNeeded() uint64

func (*InterfaceSpec) GetIsL3

func (i *InterfaceSpec) GetIsL3(isMemif bool) bool

func (*InterfaceSpec) GetRxModeWithDefault

func (i *InterfaceSpec) GetRxModeWithDefault(defaultRxMode types.RxMode) types.RxMode

func (*InterfaceSpec) String

func (i *InterfaceSpec) String() string

func (*InterfaceSpec) Validate

func (i *InterfaceSpec) Validate(maxIfSpec *InterfaceSpec) error

type KernelVersion

type KernelVersion struct {
	Kernel int
	Major  int
	Minor  int
	Patch  int
}

func (*KernelVersion) IsAtLeast

func (ver *KernelVersion) IsAtLeast(other *KernelVersion) bool

func (*KernelVersion) String

func (ver *KernelVersion) String() string

type LinuxInterfaceState

type LinuxInterfaceState struct {
	PciId         string
	Driver        string
	IsUp          bool
	Addresses     []netlink.Addr
	Routes        []netlink.Route
	HardwareAddr  net.HardwareAddr
	PromiscOn     bool
	NumTxQueues   int
	NumRxQueues   int
	DoSwapDriver  bool
	Hasv4         bool
	Hasv6         bool
	NodeIP4       string
	NodeIP6       string
	Mtu           int
	InterfaceName string
	IsTunTap      bool
	IsVeth        bool
}

func (*LinuxInterfaceState) AddressString

func (c *LinuxInterfaceState) AddressString() string

func (*LinuxInterfaceState) RouteString

func (c *LinuxInterfaceState) RouteString() string

func (*LinuxInterfaceState) SortRoutes

func (c *LinuxInterfaceState) SortRoutes()

SortRoutes sorts the route slice by dependency order, so we can then add them in the order of the slice without issues

type PhysicalNetwork added in v3.26.0

type PhysicalNetwork struct {
	VrfId    uint32
	PodVrfId uint32
}

type RedirectToHostRulesConfigType added in v3.27.0

type RedirectToHostRulesConfigType struct {
	Port uint16 `json:"port,omitempty"`
	Ip   string `json:"ip,omitempty"`
	/* "tcp", "udp",... */
	Proto types.IPProto `json:"proto,omitempty"`
}

type UnsafeNoIommuMode added in v3.27.0

type UnsafeNoIommuMode string

UnsafeNoIommuMode represents the content of the /sys/module/vfio/parameters/enable_unsafe_noiommu_mode file. The 'disabled' value is used when no iommu is available in the environment.

const (
	VFIO_UNSAFE_NO_IOMMU_MODE_YES      UnsafeNoIommuMode = "Y"
	VFIO_UNSAFE_NO_IOMMU_MODE_NO       UnsafeNoIommuMode = "N"
	VFIO_UNSAFE_NO_IOMMU_MODE_DISABLED UnsafeNoIommuMode = "disabled"
)

type UplinkInterfaceSpec

type UplinkInterfaceSpec struct {
	InterfaceSpec
	IsMain              bool              `json:"isMain"`
	PhysicalNetworkName string            `json:"physicalNetworkName"`
	InterfaceName       string            `json:"interfaceName"`
	VppDriver           string            `json:"vppDriver"`
	NewDriverName       string            `json:"newDriver"`
	Annotations         map[string]string `json:"annotations"`
	// Mtu is the User specified MTU for uplink & the tap
	Mtu       int    `json:"mtu"`
	SwIfIndex uint32 `json:"-"`
	// contains filtered or unexported fields
}

func (*UplinkInterfaceSpec) GetVppSideHardwareAddress added in v3.27.0

func (u *UplinkInterfaceSpec) GetVppSideHardwareAddress() net.HardwareAddr

func (*UplinkInterfaceSpec) SetUplinkInterfaceIndex added in v3.27.0

func (u *UplinkInterfaceSpec) SetUplinkInterfaceIndex(uplinkInterfaceIndex int)

func (*UplinkInterfaceSpec) String

func (u *UplinkInterfaceSpec) String() string

func (*UplinkInterfaceSpec) Validate

func (u *UplinkInterfaceSpec) Validate(maxIfSpec *InterfaceSpec) (err error)

type UplinkStatus

type UplinkStatus struct {
	SwIfIndex           uint32
	TapSwIfIndex        uint32
	LinkIndex           int
	Name                string
	IsMain              bool
	Mtu                 int
	PhysicalNetworkName string

	// FakeNextHopIP4 is the computed next hop for v4 routes added
	// in linux to (ServiceCIDR, podCIDR, etc...) towards this interface
	FakeNextHopIP4 net.IP
	// FakeNextHopIP6 is the computed next hop for v6 routes added
	// in linux to (ServiceCIDR, podCIDR, etc...) towards this interface
	FakeNextHopIP6 net.IP
}

type Validable

type Validable interface {
	Validate() error
}

type VppManagerInfo

type VppManagerInfo struct {
	Status         vppManagerStatus
	UplinkStatuses map[string]UplinkStatus
	PhysicalNets   map[string]PhysicalNetwork
}

func (*VppManagerInfo) GetMainSwIfIndex

func (i *VppManagerInfo) GetMainSwIfIndex() uint32

type VppManagerParams

type VppManagerParams struct {
	UplinksSpecs []UplinkInterfaceSpec
	/* Capabilities */
	LoadedDrivers                      map[string]bool
	KernelVersion                      *KernelVersion
	AvailableHugePages                 int
	InitialVfioEnableUnsafeNoIommuMode UnsafeNoIommuMode

	NodeAnnotations map[string]string
}

Jump to

Keyboard shortcuts

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