Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyPfConfigs(pfConfigs *[]PfConfig) []error
- func BusTrimmed(address string) string
- func DoesFileExist(filename string) bool
- func Driver(address string) string
- func GenerateMac() net.HardwareAddr
- func GetHostID() (string, error)
- func GetHostname() (string, error)
- func GetKernelCmdline() (string, error)
- func GetPciDeviceClass(address string) (string, error)
- func GetPciDeviceDevice(address string) (string, error)
- func GetPciDeviceVendor(address string) (string, error)
- func GetPfsMap() (map[string]*Pf, error)
- func InPfKindList(file string) bool
- func InterfaceNameFromAddress(address string) string
- func IommuGroup(address string) string
- func IsAllocated(allocations []string, iommuGroup string) bool
- func IsEthernet(address string) bool
- func IsPf(address string) bool
- func IsVf(address string) bool
- func IsVfio(address string) bool
- func PopulateVfIndexes(pf *Pf) error
- func ReadFileInt(filename string) (int, error)
- func ReadFileString(filename string) (string, error)
- func SetNumVfs(address string, num int) error
- func UnbindDriver(vfAddress string) error
- func VfioAllocations() ([]string, error)
- func WriteFile(path string, data []byte) error
- type Address
- type Agent
- type AgentConfig
- type BusCount
- type BusCountList
- type DriverInfo
- type Host
- type Pf
- func (pf *Pf) Features() (map[string]bool, error)
- func (pf *Pf) GetVfsConfig() error
- func (pf *Pf) ID() string
- func (pf *Pf) IPAddressesJoin() string
- func (pf *Pf) LinkSetUp() error
- func (pf *Pf) LinkState() (uint32, error)
- func (pf *Pf) PopulateLinkAttrs() error
- func (pf *Pf) PopulateVfIndexes() error
- func (pf *Pf) SetNumVfs(num int) error
- func (pf *Pf) SetVfMacAddresses() []error
- func (pf *Pf) SetVfMacAddressesNetlink() error
- func (pf *Pf) Stats() (map[string]uint64, error)
- type PfConfig
- type PfPolicy
- type PfPolicyOptions
- type PfSelector
- type PfSelectorOptions
- type Pfs
- type Vf
- func (vf *Vf) BindHostDriver() error
- func (vf *Vf) BindVfio() error
- func (vf *Vf) Bus() string
- func (vf *Vf) DeviceIDInt() *big.Int
- func (vf *Vf) GetIPAddresses() error
- func (vf *Vf) GetMacAddress() error
- func (vf *Vf) ID() string
- func (vf *Vf) IPAddressesJoin() string
- func (vf *Vf) UnbindDriver() error
- func (vf *Vf) VendorIDInt() *big.Int
- type Vfs
Constants ¶
const ( // LogService is the service name the agent publishes its log events // under (sys.log.agent); the Logs page filters on it. LogService = "agent" // LogPublishMaxPerSec caps how many log events per second each of the // agent's loggers publishes to NATS. LogPublishMaxPerSec = 100 )
const ( PF_POLICY_CURRENT = "current" PF_POLICY_PLANNED = "planned" )
const ( PF_SELECTOR_KIND_VENDOR_REGEXP = "vendor_regexp" PF_SELECTOR_VENDOR_REGEXP_DEFAULT = ".*" )
Variables ¶
var ( MByte = 1024000 GByte = 1073741824 )
var (
ErrPlanRequired = errors.New("pf-plan required by not available")
)
Functions ¶
func ApplyPfConfigs ¶
apply the pf-policy concrete config we don't want to return if there is a single error - return slice of errors
func BusTrimmed ¶
func DoesFileExist ¶
func GenerateMac ¶
func GenerateMac() net.HardwareAddr
func GetHostname ¶
func GetKernelCmdline ¶
cat /proc/cmdline BOOT_IMAGE=/vmlinuz-5.4.0-81-generic root=/dev/mapper/ubuntu--vg-ubuntu--lv ro intel_iommu=on iommu=pt vfio_iommu_type1.allow_unsafe_interrupts=1
func GetPciDeviceClass ¶
func GetPciDeviceDevice ¶
func GetPciDeviceVendor ¶
func InPfKindList ¶
func IommuGroup ¶
get the iommu group for a given pci bus address
func IsAllocated ¶
is the given iommu group allocated to a process?
func IsEthernet ¶
func ReadFileString ¶
read a single string from a file
func UnbindDriver ¶
func VfioAllocations ¶
Find all current vfio allocations part of this from mitchellh/go-ps/process_unix.go
Types ¶
type Address ¶
func FromNetString ¶
func FromString ¶
Given a string address, returns a complete Address struct, filled in with domain, bus, slot and function components. The address string may either be in $BUS:$SLOT.$FUNCTION (BSF) format or it can be a full PCI address that includes the 4-digit $DOMAIN information as well: $DOMAIN:$BUS:$SLOT.$FUNCTION.
type Agent ¶
type Agent struct {
Config *AgentConfig
ConfigLocation string
Supervisor *supervisor.Supervisor
// Messenger is the NATS connection to the controller. Start opens it
// when the configuration carries a controller URL; it stays nil
// otherwise. Callers attach their own loggers to it with
// Logger.AttachPublisher(agent.Messenger, LogService, LogPublishMaxPerSec).
Messenger *messenger.Client
}
Agent represents the host agent runtime that manages network configurations and communicates with the controller.
func NewAgent ¶
func NewAgent(config *AgentConfig) (*Agent, error)
NewAgent creates a new Agent instance with the given configuration.
func (*Agent) ApplyPfConfigs ¶
func (a *Agent) ApplyPfConfigs()
ApplyPfConfigs applies the PF configurations for SR-IOV networking.
func (*Agent) SetConfigLocation ¶
SetConfigLocation sets the path to the configuration file.
func (*Agent) SignalAndWaitAllClosed ¶
func (a *Agent) SignalAndWaitAllClosed()
SignalAndWaitAllClosed signals all routines to close, waits for them, and then closes the controller connection.
type AgentConfig ¶
type AgentConfig struct {
AccountID string `json:"account_id"`
HostID string `json:"host_id"`
// NATS credentials
JWT string `json:"jwt"`
Seed string `json:"seed"`
// TLS credentials
Certificate pki.Certificate `json:"certificate"`
PrivateKey pki.PrivateKey `json:"private_key"`
CA pki.Certificate `json:"ca"`
// Controller connection
ControllerURL string `json:"controller_url"`
// PF configurations for SR-IOV
PfConfigs []PfConfig `json:"pf_configs"`
}
AgentConfig represents the configuration for the host agent. This includes credentials for connecting to the controller and optional PF (physical function) configurations for SR-IOV networking.
func AgentConfigFromFile ¶
func AgentConfigFromFile(filename string) (*AgentConfig, error)
AgentConfigFromFile loads an AgentConfig from a JSON file.
type BusCountList ¶
type BusCountList []BusCount
func (BusCountList) Len ¶
func (b BusCountList) Len() int
func (BusCountList) Less ¶
func (b BusCountList) Less(i, j int) bool
func (BusCountList) Swap ¶
func (b BusCountList) Swap(i, j int)
type DriverInfo ¶
type DriverInfo struct {
Name string `json:"name"`
DriverVersion string `json:"driver_version"`
FirmwareVersion string `json:"firmware_version"`
}
func KernelDeviceDriver ¶
func KernelDeviceDriver(interfaceName string) (DriverInfo, error)
type Host ¶
type Host struct {
HostID string `json:"host_id"`
Hostname string `json:"hostname"`
OS string `json:"os"`
Kernel string `json:"kernel"`
Core string `json:"core"`
Platform string `json:"platform"`
CPUs int `json:"cpus"`
CPUVendor string `json:"cpu_vendor"`
CPUModel string `json:"cpu_model"`
Distribution string `json:"distribution"`
DistributorID string `json:"distributor_id"`
Release string `json:"release"`
Codename string `json:"codename"`
Pfs Pfs `json:"pfs"`
}
type Pf ¶
type Pf struct {
Address string `json:"address"`
Index int `json:"index"`
HostID string `json:"host_id"`
Hostname string `json:"hostname"`
Vendor string `json:"vendor"`
VendorID string `json:"vendor_id"`
Device string `json:"device"`
DeviceID string `json:"device_id"`
HasIPAddress bool `json:"has_ip_address"`
IPAddresses []string `json:"ip_addresses"` // ip_addr/netmask
MacAddress string `json:"mac_address"`
Driver string `json:"driver"`
DriverVersion string `json:"driver_version"`
FwVersion string `json:"fw_version"`
InterfaceName string `json:"interface_name"`
File string `json:"file"`
BondMember uint16 `json:"bond_member"`
HasSubinterfaces bool `json:"has_subinterfaces"` // could be dot1q, macvlan, etc.
TotalVfs int `json:"total_vfs"`
NumVfs int `json:"num_vfs"`
Vfs Vfs `json:"vfs"`
}
func GetPf ¶
should we look at getting information fron netlink vs. traversing directory structures?
func GetPfByAddress ¶
func PfFromVfAddress ¶
func (*Pf) GetVfsConfig ¶
func (*Pf) IPAddressesJoin ¶
func (*Pf) PopulateLinkAttrs ¶
func (*Pf) PopulateVfIndexes ¶
func (*Pf) SetVfMacAddresses ¶
handle (socket) for the network requests on a specific network namespace.
func (*Pf) SetVfMacAddressesNetlink ¶
type PfPolicy ¶
type PfPolicy struct {
PfSelector *PfSelector `json:"pf_selector"`
OnReboot bool `json:"on_reboot"`
MaxVfs bool `json:"max_vfs"`
NumVfs int `json:"num_vfs"`
// result of a state change to PLAN
// host_id: pf_id: before|after
PfPlan map[string]map[string]map[string]*Pf `json:"pf_plan"`
}
the host does not need to know id or version
func NewPfPolicy ¶
func NewPfPolicy(pfSelectorOpts *PfSelectorOptions, pfPolicyOpts *PfPolicyOptions) (*PfPolicy, error)
func (*PfPolicy) ApplyConcrete ¶
agent uses to calculate concrete from logical provided from server
type PfPolicyOptions ¶
type PfSelector ¶
type PfSelector struct {
Kind string `json:"kind"`
VendorRegexp string `json:"vendor_regexp"`
Selected *map[string][]Pf `json:"selected"` // by host_id
}
func NewPfSelector ¶
func NewPfSelector(options *PfSelectorOptions) (*PfSelector, error)
func (*PfSelector) Select ¶
func (pfSelector *PfSelector) Select(hosts *[]Host) error
this is used by host server to select from a slice of hosts that have already been selected by the host selector
func (*PfSelector) SelectLocalhost ¶
func (pfSelector *PfSelector) SelectLocalhost() error
this is used by the agent locally to select pfs based on the selector configuration
type PfSelectorOptions ¶
type Vf ¶
type Vf struct {
PfAddress string `json:"pf_address"`
Index int `json:"index"`
PfIndex int `json:"pf_index"`
Hostname string `json:"hostname"`
HostID string `json:"host_id"`
Address string `json:"address"`
Vendor string `json:"vendor"`
VendorID string `json:"vendor_id"`
Device string `json:"device"`
DeviceID string `json:"device_id"`
MacAddress string `json:"mac_address"`
IPAddresses []string `json:"ip_addresses"`
Driver string `json:"driver"`
HostDriver string `json:"host_driver"`
InterfaceName string `json:"interface_name"`
IommuGroup string `json:"iommu_group"`
Allocated bool `json:"allocated"`
}
func (*Vf) BindHostDriver ¶
func (*Vf) BindVfio ¶
make sure IOUMMU is enabled in kernel via grub: GRUB_CMDLINE_LINUX_DEFAULT="intel_iommu=on iommu=pt vfio_iommu_type1.allow_unsafe_interrupts=1"
func (*Vf) DeviceIDInt ¶
func (*Vf) GetIPAddresses ¶
func (*Vf) GetMacAddress ¶
this does not work if the vf is vfio-pci - does not have an interace name as it's not managed by the kernel driver
func (*Vf) IPAddressesJoin ¶
func (*Vf) UnbindDriver ¶
func (*Vf) VendorIDInt ¶
type Vfs ¶
type Vfs []*Vf
func GetVfsVendor ¶
func (*Vfs) ByPfAddress ¶
func (*Vfs) GetAllocations ¶
func (*Vfs) NextVfByPf ¶
Get the next available vf by pf address