Documentation ¶
Index ¶
- Constants
- Variables
- func AddrEnvVar(varName string, defaultValue net.IP) *net.IP
- func AddrListEnvVar(varName string) *[]net.IP
- func BGPLogLevelParse(lvl string) (apipb.SetLogLevelRequest_Level, error)
- func BoolEnvVar(varName string, defaultValue bool) *bool
- func DefaultToPtr[T any](ptr *T, defaultV T) *T
- func EnvVar[T any](varName string, defaultValue T, parser func(string) (T, error)) *T
- func IntEnvVar(varName string, defaultValue int) *int
- func JsonEnvVar[T any](varName string, defaultValue T) *T
- func LoadConfig(log *logrus.Logger) (err error)
- func LoadConfigSilent(log *logrus.Logger) (err error)
- func ParseAllEnvVars() []error
- func ParseEnvVars(varNames ...string) []error
- func PrefixEnvVar(varName string) *net.IPNet
- func PrefixListEnvVar(varName string) *[]*net.IPNet
- func PrintAgentConfig(log *logrus.Logger)
- func PrintEnvVarConfig(log *logrus.Logger)
- func RequiredAddrEnvVar(varName string) *net.IP
- func RequiredAddrListEnvVar(varName string) *[]net.IP
- func RequiredEnvVar[T any](varName string, defaultValue T, parser func(string) (T, error)) *T
- func RequiredPrefixEnvVar(varName string) *net.IPNet
- func RequiredPrefixListEnvVar(varName string) *[]*net.IPNet
- func RequiredStringEnvVar(varName string) *string
- func RunHook(hookScript *string, hookName string, params *VppManagerParams, ...)
- func StringEnvVar(varName string, defaultValue string) *string
- func StringListEnvVar(varName string, defaultValue []string) *[]string
- func TemplateScriptReplace(input string, params *VppManagerParams, conf []*LinuxInterfaceState) (template string, err error)
- func Uint16EnvVar(varName string, defaultValue uint16) *uint16
- func Uint32EnvVar(varName string, defaultValue uint32) *uint32
- type CalicoVppDebugConfigType
- type CalicoVppFeatureGatesConfigType
- type CalicoVppInitialConfigConfigType
- type CalicoVppInterfacesConfigType
- type CalicoVppIpsecConfigType
- type CalicoVppSrv6ConfigType
- type EnvVarParser
- type InterfaceSpec
- type KernelVersion
- type LinuxInterfaceState
- type PhysicalNetwork
- type RedirectToHostRulesConfigType
- type UnsafeNoIommuMode
- type UplinkInterfaceSpec
- type UplinkStatus
- type Validable
- type VppManagerInfo
- type VppManagerParams
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 AddrListEnvVar ¶
func BGPLogLevelParse ¶ added in v3.26.0
func BGPLogLevelParse(lvl string) (apipb.SetLogLevelRequest_Level, error)
func BoolEnvVar ¶
func DefaultToPtr ¶ added in v3.29.0
func DefaultToPtr[T any](ptr *T, defaultV T) *T
func JsonEnvVar ¶
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 LoadConfigSilent ¶
func ParseAllEnvVars ¶
func ParseAllEnvVars() []error
func ParseEnvVars ¶
func PrefixEnvVar ¶
func PrefixListEnvVar ¶
func PrintAgentConfig ¶
func PrintEnvVarConfig ¶
func RequiredAddrEnvVar ¶
func RequiredAddrListEnvVar ¶
func RequiredEnvVar ¶
func RequiredPrefixEnvVar ¶
func RequiredStringEnvVar ¶
func RunHook ¶ added in v3.26.0
func RunHook(hookScript *string, hookName string, params *VppManagerParams, log *logrus.Logger)
func StringEnvVar ¶
func StringListEnvVar ¶
func TemplateScriptReplace ¶
func TemplateScriptReplace(input string, params *VppManagerParams, conf []*LinuxInterfaceState) (template string, err error)
func Uint16EnvVar ¶
func Uint32EnvVar ¶
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 (self *CalicoVppInitialConfigConfigType) String() 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 ¶
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 RedirectToHostRulesConfigType ¶ added in v3.27.0
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 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 }
Click to show internal directories.
Click to hide internal directories.