Documentation
¶
Index ¶
- Variables
- func AnnounceIPs(ifName string, ipConfigs []*current.IPConfig) error
- func CleanCachedNetConf(cRefPath string) error
- func EnableArpAndNdiscNotify(ifName string) error
- func GetPciAddress(ifName string, vf int) (string, error)
- func GetPciFromNetDev(ifName string) (string, error)
- func GetPfName(vf string) (string, error)
- func GetSharedPF(ifName string) (string, error)
- func GetSriovNumVfs(ifName string) (int, error)
- func GetVFLinkName(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 IsValidPCIAddress(id string) bool
- func ReadScratchNetConf(cRefPath string) ([]byte, 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
- func SetVFEffectiveMAC(netLinkManager NetlinkManager, netDeviceName string, macAddress string) error
- func SetVFHardwareMAC(netLinkManager NetlinkManager, pfDevice string, vfID int, macAddress string) error
- type MyNetlink
- func (n *MyNetlink) LinkByName(name string) (netlink.Link, error)
- func (n *MyNetlink) LinkSetDown(link netlink.Link) error
- func (n *MyNetlink) LinkSetHardwareAddr(link netlink.Link, hwaddr net.HardwareAddr) error
- func (n *MyNetlink) LinkSetName(link netlink.Link, name string) error
- func (n *MyNetlink) LinkSetNsFd(link netlink.Link, fd int) error
- func (n *MyNetlink) LinkSetUp(link netlink.Link) error
- func (n *MyNetlink) LinkSetVfHardwareAddr(link netlink.Link, vf int, hwaddr net.HardwareAddr) error
- func (n *MyNetlink) LinkSetVfRate(link netlink.Link, vf int, minRate int, maxRate int) error
- func (n *MyNetlink) LinkSetVfSpoofchk(link netlink.Link, vf int, check bool) error
- func (n *MyNetlink) LinkSetVfState(link netlink.Link, vf int, state uint32) error
- func (n *MyNetlink) LinkSetVfTrust(link netlink.Link, vf int, state bool) error
- func (n *MyNetlink) LinkSetVfVlanQosProto(link netlink.Link, vf, vlan, qos, proto int) error
- type NetlinkManager
- 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 SysBusPci = "/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 GetPciAddress ¶
GetPciAddress takes in a interface(ifName) and VF id and returns its pci addr as string
func GetPciFromNetDev ¶
GetPciFromNetDev takes in a network device name and returns its PCI address
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 GetVFLinkName ¶
GetVFLinkName 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 IsValidPCIAddress ¶
isValidPCIAddress checks if a provide string is a valid PCI address
func ReadScratchNetConf ¶
ReadScratchNetConf takes in container ID, Pod interface name and data dir as string and returns a pointer to Conf
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.
func SendUnsolicitedNeighborAdvertisement ¶
SendUnsolicitedNeighborAdvertisement sends an unsolicited neighbor advertisement packet with the provided source IP over the provided interface.
func SetVFEffectiveMAC ¶
func SetVFEffectiveMAC(netLinkManager NetlinkManager, netDeviceName string, macAddress string) error
SetVFEffectiveMAC will try to set the mac address on a specific VF interface
the function will also validate that the mac address was configured as expect it will return an error if it didn't manage to configure the vf mac address or the mac is not equal to the expect one retries 20 times and wait 100 milliseconds
Some NIC drivers (i.e. i40e/iavf) set VF MAC address asynchronously via PF. This means that while the PF could already show the VF with the desired MAC address, the netdev VF may still have the original one. If in this window we issue a netdev VF MAC address set, the driver will return an error and the pod will fail to create. Other NICs (Mellanox) require explicit netdev VF MAC address so we cannot skip this part. Retry up to 5 times; wait 200 milliseconds between retries
func SetVFHardwareMAC ¶
func SetVFHardwareMAC(netLinkManager NetlinkManager, pfDevice string, vfID int, macAddress string) error
the function will also validate that the mac address was configured as expect it will return an error if it didn't manage to configure the vf mac address or the mac is not equal to the expect one retries 20 times and wait 100 milliseconds
Types ¶
type MyNetlink ¶
type MyNetlink struct {
NetlinkManager
}
MyNetlink NetlinkManager
func (*MyNetlink) LinkByName ¶
LinkByName implements NetlinkManager
func (*MyNetlink) LinkSetDown ¶
LinkSetDown using NetlinkManager
func (*MyNetlink) LinkSetHardwareAddr ¶
LinkSetHardwareAddr using NetlinkManager
func (*MyNetlink) LinkSetName ¶
LinkSetName using NetlinkManager
func (*MyNetlink) LinkSetNsFd ¶
LinkSetNsFd using NetlinkManager
func (*MyNetlink) LinkSetVfHardwareAddr ¶
LinkSetVfHardwareAddr using NetlinkManager
func (*MyNetlink) LinkSetVfRate ¶
LinkSetVfRate using NetlinkManager
func (*MyNetlink) LinkSetVfSpoofchk ¶
LinkSetVfSpoofchk using NetlinkManager
func (*MyNetlink) LinkSetVfState ¶
LinkSetVfState using NetlinkManager
func (*MyNetlink) LinkSetVfTrust ¶
LinkSetVfTrust using NetlinkManager
type NetlinkManager ¶
type NetlinkManager interface { LinkByName(string) (netlink.Link, error) LinkSetVfVlanQosProto(netlink.Link, int, int, int, int) error LinkSetVfHardwareAddr(netlink.Link, int, net.HardwareAddr) error LinkSetHardwareAddr(netlink.Link, net.HardwareAddr) error LinkSetUp(netlink.Link) error LinkSetDown(netlink.Link) error LinkSetNsFd(netlink.Link, int) error LinkSetName(netlink.Link, string) error LinkSetVfRate(netlink.Link, int, int, int) error LinkSetVfSpoofchk(netlink.Link, int, bool) error LinkSetVfTrust(netlink.Link, int, bool) error LinkSetVfState(netlink.Link, int, uint32) error }
NetlinkManager is an interface to mock nelink library
type PCIAllocation ¶
type PCIAllocator ¶
type PCIAllocator struct {
// contains filtered or unexported fields
}
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