Documentation ¶
Index ¶
- Variables
- func AddNeigh(link netlink.Link, mac net.HardwareAddr, ip *terwayTypes.IPSet) error
- func AddrDel(link netlink.Link, addr *netlink.Addr) error
- func AddrReplace(link netlink.Link, addr *netlink.Addr) error
- func CheckIPVLanAvailable() (bool, error)
- func DelIPRulesByIP(ipNet *net.IPNet) error
- func EnableIPv6() error
- func EnsureAddr(link netlink.Link, expect *netlink.Addr) (bool, error)
- func EnsureAddrWithPrefix(link netlink.Link, ipNetSet *terwayTypes.IPNetSet, prefixRoute bool) (bool, error)
- func EnsureClsActQdsic(link netlink.Link) error
- func EnsureDefaultRoute(link netlink.Link, gw *terwayTypes.IPSet, table int) (bool, error)
- func EnsureHostNsConfig(ipv4, ipv6 bool) error
- func EnsureHostToContainerRoute(link netlink.Link, ipNetSet *terwayTypes.IPNetSet) (bool, error)
- func EnsureIPRule(link netlink.Link, ipNetSet *terwayTypes.IPNetSet, tableID int) (bool, error)
- func EnsureLinkMTU(link netlink.Link, mtu int) (bool, error)
- func EnsureLinkName(link netlink.Link, name string) (bool, error)
- func EnsureLinkUp(link netlink.Link) (bool, error)
- func EnsureNeighbor(link netlink.Link, hostIPSet *terwayTypes.IPNetSet) (bool, error)
- func EnsureNetConfSet(ipv4, ipv6 bool) error
- func EnsureRoute(expected *netlink.Route) (bool, error)
- func EnsureVlanUntagger(link netlink.Link) error
- func FindIPRule(rule *netlink.Rule) ([]netlink.Rule, error)
- func FoundRoutes(expected *netlink.Route) ([]netlink.Route, error)
- func GetHostIP(ipv4, ipv6 bool) (*terwayTypes.IPNetSet, error)
- func IPNetToMaxMask(ipNet *terwayTypes.IPNetSet)
- func JSONStr(v interface{}) string
- func LinkAdd(link netlink.Link) error
- func LinkDel(link netlink.Link) error
- func LinkSetDown(link netlink.Link) error
- func LinkSetMTU(link netlink.Link, mtu int) error
- func LinkSetName(link netlink.Link, name string) error
- func LinkSetNsFd(link netlink.Link, netNS ns.NetNS) error
- func LinkSetUp(link netlink.Link) error
- func NeighAdd(neigh *netlink.Neigh) error
- func NeighSet(neigh *netlink.Neigh) error
- func NetlinkFamily(ip net.IP) int
- func NewDefaultLogger() *logrus.Logger
- func NewIPNetWithMaxMask(ipNet *net.IPNet) *net.IPNet
- func PodInfoKey(namespace, name string) string
- func RouteAdd(route *netlink.Route) error
- func RouteDel(route *netlink.Route) error
- func RouteReplace(route *netlink.Route) error
- func RuleAdd(rule *netlink.Rule) error
- func RuleDel(rule *netlink.Rule) error
- func SetLogDebug()
- func SetupLink(link netlink.Link, cfg *SetupConfig) error
- type CheckConfig
- type IPvlanDriver
- type Locker
- type NetnsDriver
- type PodInfoHook
- type RawNicDriver
- type RecordPodEvent
- type SetupConfig
- type TeardownCfg
- type VETHDriver
Constants ¶
This section is empty.
Variables ¶
var ( LinkIP = net.IPv4(169, 254, 1, 1) LinkIPv6 = net.ParseIP("fe80::1") )
default addrs
var DefaultLogger = NewDefaultLogger()
DefaultLogger default log
var Hook = &PodInfoHook{ExtraInfo: make(map[string]string)}
Hook for log
var Log = DefaultLogger.WithField("subSys", "terway-cni")
Log for default log
Functions ¶
func AddNeigh ¶ added in v1.1.0
func AddNeigh(link netlink.Link, mac net.HardwareAddr, ip *terwayTypes.IPSet) error
AddNeigh add arp for link
func CheckIPVLanAvailable ¶ added in v1.1.0
CheckIPVLanAvailable checks if current kernel version meet the requirement (>= 4.19)
func DelIPRulesByIP ¶ added in v1.1.0
func EnableIPv6 ¶ added in v1.1.0
func EnableIPv6() error
func EnsureAddr ¶ added in v1.1.0
EnsureAddr ensure only one IP for each family is present on link
func EnsureAddrWithPrefix ¶ added in v1.1.0
func EnsureAddrWithPrefix(link netlink.Link, ipNetSet *terwayTypes.IPNetSet, prefixRoute bool) (bool, error)
EnsureAddrWithPrefix take the ipNet set and ensure only one IP for each family is present on link it will remove other unmatched IPs
func EnsureClsActQdsic ¶ added in v1.1.0
func EnsureDefaultRoute ¶ added in v1.1.0
func EnsureHostNsConfig ¶ added in v1.1.0
EnsureHostNsConfig setup host namespace configs
func EnsureHostToContainerRoute ¶ added in v1.1.0
EnsureHostToContainerRoute create host to container route
func EnsureIPRule ¶ added in v1.1.0
func EnsureLinkMTU ¶ added in v1.1.0
EnsureLinkMTU set link mtu,return changed and err
func EnsureLinkName ¶ added in v1.1.0
func EnsureLinkUp ¶ added in v1.1.0
EnsureLinkUp set link up,return changed and err
func EnsureNeighbor ¶ added in v1.1.0
func EnsureNetConfSet ¶ added in v1.1.0
EnsureNetConfSet will set net config to all link
func EnsureRoute ¶ added in v1.1.0
EnsureRoute will call ip route replace if route is not found
func EnsureVlanUntagger ¶ added in v1.1.0
func FindIPRule ¶ added in v1.1.0
FindIPRule look up ip rules in config
func FoundRoutes ¶ added in v1.1.0
FoundRoutes look up routes
func IPNetToMaxMask ¶ added in v1.1.0
func IPNetToMaxMask(ipNet *terwayTypes.IPNetSet)
func LinkSetDown ¶ added in v1.1.0
func NetlinkFamily ¶ added in v1.1.0
func NewDefaultLogger ¶ added in v1.1.0
func PodInfoKey ¶ added in v1.1.0
func RouteReplace ¶ added in v1.1.0
func SetLogDebug ¶ added in v1.1.0
func SetLogDebug()
Types ¶
type CheckConfig ¶ added in v1.1.0
type CheckConfig struct { RecordPodEvent NetNS ns.NetNS HostVETHName string ContainerIFName string ContainerIPNet *terwayTypes.IPNetSet HostIPSet *terwayTypes.IPNetSet GatewayIP *terwayTypes.IPSet ENIIndex int32 // phy device TrunkENI bool MTU int }
type IPvlanDriver ¶ added in v1.1.0
type IPvlanDriver struct {
// contains filtered or unexported fields
}
func NewIPVlanDriver ¶ added in v1.1.0
func NewIPVlanDriver(ipv4, ipv6 bool) *IPvlanDriver
func (*IPvlanDriver) Check ¶ added in v1.1.0
func (d *IPvlanDriver) Check(cfg *CheckConfig) error
func (*IPvlanDriver) Setup ¶ added in v1.1.0
func (d *IPvlanDriver) Setup(cfg *SetupConfig, netNS ns.NetNS) error
func (*IPvlanDriver) Teardown ¶ added in v1.1.0
func (d *IPvlanDriver) Teardown(cfg *TeardownCfg, netNS ns.NetNS) error
type Locker ¶ added in v1.1.0
func GrabFileLock ¶ added in v1.1.0
GrabFileLock get file lock with timeout 11seconds
type NetnsDriver ¶
type NetnsDriver interface { Setup(cfg *SetupConfig, netNS ns.NetNS) error Teardown(cfg *TeardownCfg, netNS ns.NetNS) error Check(cfg *CheckConfig) error }
NetnsDriver to config container netns interface and routes
type PodInfoHook ¶ added in v1.1.0
func (*PodInfoHook) AddExtraInfo ¶ added in v1.1.0
func (p *PodInfoHook) AddExtraInfo(k, v string)
func (*PodInfoHook) AddExtraInfos ¶ added in v1.1.0
func (p *PodInfoHook) AddExtraInfos(e map[string]string)
func (*PodInfoHook) Levels ¶ added in v1.1.0
func (p *PodInfoHook) Levels() []logrus.Level
type RawNicDriver ¶ added in v1.1.0
type RawNicDriver struct {
// contains filtered or unexported fields
}
RawNicDriver put nic in net ns
func NewRawNICDriver ¶ added in v1.1.0
func NewRawNICDriver(ipv4, ipv6 bool) *RawNicDriver
func (*RawNicDriver) Check ¶ added in v1.1.0
func (r *RawNicDriver) Check(cfg *CheckConfig) error
func (*RawNicDriver) Setup ¶ added in v1.1.0
func (r *RawNicDriver) Setup(cfg *SetupConfig, netNS ns.NetNS) error
func (*RawNicDriver) Teardown ¶ added in v1.1.0
func (r *RawNicDriver) Teardown(cfg *TeardownCfg, netNS ns.NetNS) error
type RecordPodEvent ¶ added in v1.1.0
type RecordPodEvent func(msg string)
type SetupConfig ¶ added in v1.1.0
type SetupConfig struct { HostVETHName string ContainerIfName string ContainerIPNet *terwayTypes.IPNetSet GatewayIP *terwayTypes.IPSet MTU int ENIIndex int TrunkENI bool // add extra route in container ExtraRoutes []types.Route ServiceCIDR *terwayTypes.IPNetSet HostIPSet *terwayTypes.IPNetSet // ipvlan HostStackCIDRs []*net.IPNet Ingress uint64 Egress uint64 }
type TeardownCfg ¶ added in v1.1.0
type TeardownCfg struct { HostVETHName string ContainerIfName string ContainerIPNet *terwayTypes.IPNetSet }
type VETHDriver ¶ added in v1.1.0
type VETHDriver struct {
// contains filtered or unexported fields
}
func NewVETHDriver ¶ added in v1.1.0
func NewVETHDriver(ipv4, ipv6 bool) *VETHDriver
func (*VETHDriver) Check ¶ added in v1.1.0
func (d *VETHDriver) Check(cfg *CheckConfig) error
func (*VETHDriver) Setup ¶ added in v1.1.0
func (d *VETHDriver) Setup(cfg *SetupConfig, netNS ns.NetNS) error
func (*VETHDriver) Teardown ¶ added in v1.1.0
func (d *VETHDriver) Teardown(cfg *TeardownCfg, netNS ns.NetNS) error