utils

package
v1.2.4-policy Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: Apache-2.0 Imports: 22 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 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 EnsureAddrWithPrefix

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

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 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 EnsureRoute

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

EnsureRoute will call ip route replace if route is not found

func EnsureVlanUntagger

func EnsureVlanUntagger(link netlink.Link) 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 QdiscReplace

func QdiscReplace(qdisc *netlink.GenericQdisc) 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 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