Documentation
¶
Overview ¶
Package utils holds utilities for opi-gateway-evpn-cni
Index ¶
- Variables
- func AnnounceIPs(ifName string, ipConfigs []*current.IPConfig) error
- func CleanCachedNetConf(cRefPath string) error
- func EnableArpAndNdiscNotify(ifName string) error
- func GetContainerNetDevFromPci(netNSPath, pciAddress string) ([]string, error)
- func GetPciAddress(ifName string, vf int) (string, error)
- func GetPfName(vf string) (string, error)
- func GetSharedPF(ifName string) (string, error)
- func GetSriovNumVfs(ifName string) (int, error)
- func GetVFLinkNames(pciAddr string) (string, error)
- func GetVFLinkNamesFromVFID(pfName string, vfID int) ([]string, error)
- func GetVfid(addr string, pfName string) (int, error)
- func HasDpdkDriver(pciAddr string) (bool, error)
- func IsIPv4(ip net.IP) bool
- func IsIPv6(ip net.IP) bool
- func IsValidMACAddress(addr net.HardwareAddr) bool
- func PathExists(path string) (bool, error)
- func ReadScratchNetConf(cRefPath string) ([]byte, error)
- func RetrieveMacFromPci(pciAddr string, pciToMacFile string) (string, error)
- func Retry(retries int, sleep time.Duration, f func() error) error
- func SaveNetConf(cid, dataDir, podIfName string, conf interface{}) error
- func SendGratuitousArp(srcIP net.IP, linkObj netlink.Link) error
- func SendUnsolicitedNeighborAdvertisement(srcIP net.IP, linkObj netlink.Link) error
- type PCIAllocation
- type PCIAllocator
Constants ¶
This section is empty.
Variables ¶
var ( // NetDirectory sysfs net directory NetDirectory = "/sys/class/net" // SysBusPci is sysfs pci device directory for host SysBusPci = "/sys/bus/pci/devices" // ContainerSysBusPci is sysfs pci device directory for containers ContainerSysBusPci = "/root/sys/bus/pci/devices" // SysV4ArpNotify is the sysfs IPv4 ARP Notify directory SysV4ArpNotify = "/proc/sys/net/ipv4/conf/" // SysV6NdiscNotify is the sysfs IPv6 Neighbor Discovery Notify directory SysV6NdiscNotify = "/proc/sys/net/ipv6/conf/" // UserspaceDrivers is a list of driver names that don't have netlink representation for their devices UserspaceDrivers = []string{"vfio-pci", "uio_pci_generic", "igb_uio"} )
Functions ¶
func AnnounceIPs ¶
AnnounceIPs sends either a GARP or Unsolicited NA depending on the IP address type (IPv4 vs. IPv6 respectively) configured on the interface.
func CleanCachedNetConf ¶
CleanCachedNetConf removed cached NetConf from disk
func EnableArpAndNdiscNotify ¶
EnableArpAndNdiscNotify enables IPv4 arp_notify and IPv6 ndisc_notify for netdev
func GetContainerNetDevFromPci ¶
GetContainerNetDevFromPci returns a list of netdevices from PCI address that is attached to container
func GetPciAddress ¶
GetPciAddress takes in a interface(ifName) and VF id and returns its pci addr as string
func GetSharedPF ¶
GetSharedPF takes in VF name(ifName) as string and returns the other VF name that shares same PCI address as string
func GetSriovNumVfs ¶
GetSriovNumVfs takes in a PF name(ifName) as string and returns number of VF configured as int
func GetVFLinkNames ¶
GetVFLinkNames returns VF's network interface name given it's PCI addr
func GetVFLinkNamesFromVFID ¶
GetVFLinkNamesFromVFID returns VF's network interface name given it's PF name as string and VF id as int
func GetVfid ¶
GetVfid takes in VF's PCI address(addr) and pfName as string and returns VF's ID as int
func HasDpdkDriver ¶
HasDpdkDriver checks if a device is attached to dpdk supported driver
func IsValidMACAddress ¶
func IsValidMACAddress(addr net.HardwareAddr) bool
IsValidMACAddress checks if net.HardwareAddr is a valid MAC address.
func PathExists ¶
PathExists checks if a file exists on a specified path
func ReadScratchNetConf ¶
ReadScratchNetConf takes in container ID, Pod interface name and data dir as string and returns a pointer to Conf
func RetrieveMacFromPci ¶
RetrieveMacFromPci gets the Mac address from the PCI address of the VF by reading a config file where the mapping is located.
func SaveNetConf ¶
SaveNetConf takes in container ID, data dir and Pod interface name as string and a json encoded struct Conf and save this Conf in data dir
func SendGratuitousArp ¶
SendGratuitousArp sends a gratuitous ARP packet with the provided source IP over the provided interface.
Types ¶
type PCIAllocation ¶
type PCIAllocation interface { SaveAllocatedPCI(string, string) error DeleteAllocatedPCI(string) error IsAllocated(string) error }
PCIAllocation holds functions for managing PCI devices
type PCIAllocator ¶
type PCIAllocator struct {
// contains filtered or unexported fields
}
PCIAllocator implements PCIAllocation interface
func NewPCIAllocator ¶
func NewPCIAllocator(dataDir string) *PCIAllocator
NewPCIAllocator returns a new PCI allocator it will use the <dataDir>/pci folder to store the information about allocated PCI addresses
func (*PCIAllocator) DeleteAllocatedPCI ¶
func (p *PCIAllocator) DeleteAllocatedPCI(pciAddress string) error
DeleteAllocatedPCI Remove the allocated PCI file return error if the file doesn't exist
func (*PCIAllocator) IsAllocated ¶
func (p *PCIAllocator) IsAllocated(pciAddress string) (bool, error)
IsAllocated checks if the PCI address file exist if it exists we also check the network namespace still exist if not we delete the allocation The function will return an error if the pci is still allocated to a running pod
func (*PCIAllocator) SaveAllocatedPCI ¶
func (p *PCIAllocator) SaveAllocatedPCI(pciAddress, ns string) error
SaveAllocatedPCI creates a file with the pci address as a name and the network namespace as the content return error if the file was not created