ifacemonitor

package
v0.0.0-...-d216c5d Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const FlapDampingDelay = 100 * time.Millisecond

Variables

This section is empty.

Functions

func FilterUpdates

func FilterUpdates(ctx context.Context,
	routeOutC chan<- netlink.RouteUpdate, routeInC <-chan netlink.RouteUpdate,
	linkOutC chan<- netlink.LinkUpdate, linkInC <-chan netlink.LinkUpdate,
	options ...UpdateFilterOp,
)

FilterUpdates filters out updates that occur when IPs are quickly removed and re-added. Some DHCP clients flap the IP during an IP renewal, for example.

Algorithm: * Maintain a queue of link and address updates per interface. * When we see a potential flap (i.e. an IP deletion), defer processing the queue for a while. * If the flap resolves itself (i.e. the IP is added back), suppress the IP deletion.

func IsInterfacePresent

func IsInterfacePresent(name string) bool

func LinkIsOperUp

func LinkIsOperUp(link netlink.Link) bool

Types

type AddrStateCallback

type AddrStateCallback func(ifaceName string, addrs set.Set[string])

type Config

type Config struct {
	// InterfaceExcludes is a list of interface names that we don't want callbacks for.
	InterfaceExcludes []*regexp.Regexp
	// ResyncInterval is the interval at which we rescan all the interfaces.  If <0 rescan is disabled.
	ResyncInterval time.Duration
	NetlinkTimeout time.Duration
}

type InSyncCallback

type InSyncCallback func()

type InterfaceMonitor

type InterfaceMonitor struct {
	Config

	StateCallback  InterfaceStateCallback
	AddrCallback   AddrStateCallback
	InSyncCallback InSyncCallback
	// contains filtered or unexported fields
}

func New

func New(config Config,
	featureDetector environment.FeatureDetectorIface,
	fatalErrCallback func(error),
) *InterfaceMonitor

func NewWithStubs

func NewWithStubs(config Config, netlinkStub netlinkStub, resyncC <-chan time.Time, fatalErrCallback func(error)) *InterfaceMonitor

func (*InterfaceMonitor) MonitorInterfaces

func (m *InterfaceMonitor) MonitorInterfaces()

type InterfaceStateCallback

type InterfaceStateCallback func(ifaceName string, ifaceState State, ifIndex int)

type State

type State string
const (
	StateNotPresent State = ""
	StateUp         State = "up"
	StateDown       State = "down"
)

type UpdateFilterOp

type UpdateFilterOp func(filter *updateFilter)

func WithTimeShim

func WithTimeShim(t timeshim.Interface) UpdateFilterOp

Jump to

Keyboard shortcuts

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