utils

package
v1.13.2 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2025 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Log = logr.Discard()

Functions

func AddrDel

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

func AddrReplace

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

func CleanIPRules

func CleanIPRules(ctx context.Context) (err error)

CleanIPRules del ip rule for detached devs

func DelEgressPriority added in v1.3.0

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

func DelFilter added in v1.3.0

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

DelFilter del u32 filter by pod ip

func DelLinkByName

func DelLinkByName(ctx context.Context, ifName string) error

DelLinkByName del by name and ignore if link not present

func EnsureAddr

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

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

func EnsureClsActQdsic

func EnsureClsActQdsic(ctx context.Context, link netlink.Link) error

func EnsureHostNsConfig

func EnsureHostNsConfig(ipv4, ipv6 bool) error

EnsureHostNsConfig setup host namespace configs

func EnsureIPRule

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

func EnsureLinkMTU

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

EnsureLinkMTU set link mtu,return changed and err

func EnsureLinkName

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

func EnsureLinkUp

func EnsureLinkUp(ctx context.Context, link netlink.Link) (bool, error)

EnsureLinkUp set link up,return changed and err

func EnsureMQQdisc added in v1.3.0

func EnsureMQQdisc(ctx context.Context, link netlink.Link) error

EnsureMQQdisc write qdisc

func EnsureNeigh

func EnsureNeigh(ctx context.Context, 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(ctx context.Context, link netlink.Link) error

EnsurePrioQdiscAt10 write qdisc attach under mq

func EnsureRoute

func EnsureRoute(ctx context.Context, 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(ctx context.Context, link netlink.Link, ipNetSet *terwayTypes.IPNetSet, vid uint16) error

EnsureVlanTag use tc-vlan set vlan tag

func EnsureVlanUntagger

func EnsureVlanUntagger(ctx context.Context, link netlink.Link) error

func FilterAdd added in v1.3.0

func FilterAdd(ctx context.Context, filter *netlink.U32) error

func FilterDel added in v1.3.0

func FilterDel(ctx context.Context, 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(ctx context.Context, netNS ns.NetNS) error

GenericTearDown target to clean all related resource as much as possible

func GetERdmaFromLink(link netlink.Link) (*netlink.RdmaLink, error)

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 InitLog added in v1.11.5

func InitLog(debug bool) logr.Logger

func JSONStr

func JSONStr(v interface{}) string

JSONStr json to str

func LinkAdd

func LinkAdd(ctx context.Context, link netlink.Link) error

func LinkDel

func LinkDel(ctx context.Context, link netlink.Link) error

func LinkSetDown

func LinkSetDown(ctx context.Context, link netlink.Link) error

func LinkSetMTU

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

func LinkSetName

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

func LinkSetNsFd

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

func LinkSetUp

func LinkSetUp(ctx context.Context, link netlink.Link) error

func NeighSet

func NeighSet(ctx context.Context, 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(ctx context.Context, qdisc netlink.Qdisc) error

func QdiscReplace

func QdiscReplace(ctx context.Context, qdisc netlink.Qdisc) error

func RouteDel

func RouteDel(ctx context.Context, route *netlink.Route) error

func RouteReplace

func RouteReplace(ctx context.Context, route *netlink.Route) error

func RuleAdd

func RuleAdd(ctx context.Context, rule *netlink.Rule) error

func RuleDel

func RuleDel(ctx context.Context, rule *netlink.Rule) error

func SetEgressPriority added in v1.3.0

func SetEgressPriority(ctx context.Context, 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(ctx context.Context, link netlink.Link, parentID, classID uint32, ipNetSet *terwayTypes.IPNetSet) error

SetFilter write u32 filter

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

Jump to

Keyboard shortcuts

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