utils

package
v1.8.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultLogger = func() *logrus.Logger {
	l := logger.NewDefaultLogger()
	l.AddHook(Hook)
	return l
}()
View Source
var Hook = &PodInfoHook{ExtraInfo: make(map[string]string)}

Hook for log

View Source
var Log = DefaultLogger.WithField("subSys", "terway-cni")

Log for default log

Functions

func AddrDel

func AddrDel(link netlink.Link, addr *netlink.Addr) error

func AddrReplace

func AddrReplace(link netlink.Link, addr *netlink.Addr) error

func CleanIPRules

func CleanIPRules() (err error)

CleanIPRules del ip rule for detached devs

func DelEgressPriority added in v1.3.0

func DelEgressPriority(link netlink.Link, ipNetSet *terwayTypes.IPNetSet) error

func DelFilter added in v1.3.0

func DelFilter(link netlink.Link, parentID uint32, ipNetSet *terwayTypes.IPNetSet) error

DelFilter del u32 filter by pod ip

func DelLinkByName

func DelLinkByName(ifName string) error

DelLinkByName del by name and ignore if link not present

func EnsureAddr

func EnsureAddr(link netlink.Link, expect *netlink.Addr) (bool, error)

EnsureAddr ensure only one IP for each family is present on link

func EnsureClsActQdsic

func EnsureClsActQdsic(link netlink.Link) error

func EnsureHostNsConfig

func EnsureHostNsConfig(ipv4, ipv6 bool) error

EnsureHostNsConfig setup host namespace configs

func EnsureIPRule

func EnsureIPRule(expected *netlink.Rule) (bool, error)

func EnsureLinkMTU

func EnsureLinkMTU(link netlink.Link, mtu int) (bool, error)

EnsureLinkMTU set link mtu,return changed and err

func EnsureLinkName

func EnsureLinkName(link netlink.Link, name string) (bool, error)

func EnsureLinkUp

func EnsureLinkUp(link netlink.Link) (bool, error)

EnsureLinkUp set link up,return changed and err

func EnsureMQQdisc added in v1.3.0

func EnsureMQQdisc(link netlink.Link) error

EnsureMQQdisc write qdisc

func EnsureNeigh

func EnsureNeigh(neigh *netlink.Neigh) (bool, error)

func EnsureNetConfSet

func EnsureNetConfSet(ipv4, ipv6 bool) error

EnsureNetConfSet will set net config to all link

func EnsurePrioQdiscAt10 added in v1.3.0

func EnsurePrioQdiscAt10(link netlink.Link) error

EnsurePrioQdiscAt10 write qdisc attach under mq

func EnsureRoute

func EnsureRoute(expected *netlink.Route) (bool, error)

EnsureRoute will call ip route replace if route is not found

func EnsureVlanTag added in v1.4.0

func EnsureVlanTag(link netlink.Link, ipNetSet *terwayTypes.IPNetSet, vid uint16) error

EnsureVlanTag use tc-vlan set vlan tag

func EnsureVlanUntagger

func EnsureVlanUntagger(link netlink.Link) error

func FilterAdd added in v1.3.0

func FilterAdd(filter *netlink.U32) error

func FilterDel added in v1.3.0

func FilterDel(filter netlink.Filter) error

func FindIPRule

func FindIPRule(rule *netlink.Rule) ([]netlink.Rule, error)

FindIPRule look up ip rules in config

func FoundRoutes

func FoundRoutes(expected *netlink.Route) ([]netlink.Route, error)

FoundRoutes look up routes

func GenerateIPv6Sysctl

func GenerateIPv6Sysctl(ifName string, disableRA, enableForward bool) map[string][]string

func GenericTearDown

func GenericTearDown(netNS ns.NetNS) error

GenericTearDown target to clean all related resource as much as possible

func GetHostIP

func GetHostIP(ipv4, ipv6 bool) (*terwayTypes.IPNetSet, error)

func GetRouteTableID

func GetRouteTableID(linkIndex int) int

GetRouteTableID add 1000 to link index to avoid route table conflict

func JSONStr

func JSONStr(v interface{}) string

JSONStr json to str

func LinkAdd

func LinkAdd(link netlink.Link) error

func LinkDel

func LinkDel(link netlink.Link) error

func LinkSetDown

func LinkSetDown(link netlink.Link) error

func LinkSetMTU

func LinkSetMTU(link netlink.Link, mtu int) error

func LinkSetName

func LinkSetName(link netlink.Link, name string) error

func LinkSetNsFd

func LinkSetNsFd(link netlink.Link, netNS ns.NetNS) error

func LinkSetUp

func LinkSetUp(link netlink.Link) error

func NeighSet

func NeighSet(neigh *netlink.Neigh) error

func NetlinkFamily

func NetlinkFamily(ip net.IP) int

func NewIPNet

func NewIPNet(ipNet *terwayTypes.IPNetSet) *terwayTypes.IPNetSet

func NewIPNet1

func NewIPNet1(ipNet *terwayTypes.IPNetSet) []*netlink.Addr

func NewIPNetToMaxMask

func NewIPNetToMaxMask(ipNet *terwayTypes.IPNetSet) []*netlink.Addr

func NewIPNetWithMaxMask

func NewIPNetWithMaxMask(ipNet *net.IPNet) *net.IPNet

func QdiscDel added in v1.3.0

func QdiscDel(qdisc netlink.Qdisc) error

func QdiscReplace

func QdiscReplace(qdisc netlink.Qdisc) error

func RouteDel

func RouteDel(route *netlink.Route) error

func RouteReplace

func RouteReplace(route *netlink.Route) error

func RuleAdd

func RuleAdd(rule *netlink.Rule) error

func RuleDel

func RuleDel(rule *netlink.Rule) error

func SetEgressPriority added in v1.3.0

func SetEgressPriority(link netlink.Link, classID uint32, ipNetSet *terwayTypes.IPNetSet) error

SetEgressPriority write egress priority rule for pod

func SetFilter added in v1.3.0

func SetFilter(link netlink.Link, parentID, classID uint32, ipNetSet *terwayTypes.IPNetSet) error

SetFilter write u32 filter

func SetLogDebug

func SetLogDebug()

func SetupTC

func SetupTC(link netlink.Link, bandwidthInBytes uint64) error

Types

type Locker

type Locker struct {
	// contains filtered or unexported fields
}

func GrabFileLock

func GrabFileLock(lockfilePath string) (*Locker, error)

GrabFileLock get file lock with timeout 11seconds

func (*Locker) Close

func (l *Locker) Close() error

Close close

type PodInfoHook

type PodInfoHook struct {
	ExtraInfo map[string]string
}

func (*PodInfoHook) AddExtraInfo

func (p *PodInfoHook) AddExtraInfo(k, v string)

func (*PodInfoHook) AddExtraInfos

func (p *PodInfoHook) AddExtraInfos(e map[string]string)

func (*PodInfoHook) Fire

func (p *PodInfoHook) Fire(e *logrus.Entry) error

func (*PodInfoHook) Levels

func (p *PodInfoHook) Levels() []logrus.Level

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL