Documentation ¶
Overview ¶
Package uplinkprober is used by zedrouter to determine the connectivity status of uplink interfaces and to decide which interface should be used by each network instance (with a dynamic uplink assignment) at a given moment.
Index ¶
- type Config
- type ControllerReachProber
- func (p *ControllerReachProber) ProbeNextHopReach(ctx context.Context, uplinkLL string, dns *types.DeviceNetworkStatus) (probedNHs []net.IP, err error)
- func (p *ControllerReachProber) ProbeRemoteReach(ctx context.Context, uplinkLL string, dns *types.DeviceNetworkStatus) (probedEps []url.URL, err error)
- type MockReachProber
- func (p *MockReachProber) LastNHProbe(uplinkLL string) time.Time
- func (p *MockReachProber) LastRemoteProbe(uplinkLL string) time.Time
- func (p *MockReachProber) ProbeNextHopReach(ctx context.Context, uplinkLL string, dns *types.DeviceNetworkStatus) (probedNHs []net.IP, err error)
- func (p *MockReachProber) ProbeRemoteReach(ctx context.Context, uplinkLL string, dns *types.DeviceNetworkStatus) (probedEps []url.URL, err error)
- func (p *MockReachProber) SetNextHopState(uplinkLL string, nhs []net.IP, reachErr error, probeRTT time.Duration)
- func (p *MockReachProber) SetRemoteState(uplinkLL string, remoteEps []url.URL, reachErr error, probeRTT time.Duration)
- type NIProbeStatus
- type ReachabilityProber
- type UplinkProber
- func (p *UplinkProber) ApplyDNSUpdate(dns types.DeviceNetworkStatus)
- func (p *UplinkProber) GetProbeMetrics(ni uuid.UUID) (metrics types.ProbeMetrics, err error)
- func (p *UplinkProber) GetProbeStatus(ni uuid.UUID) (NIProbeStatus, error)
- func (p *UplinkProber) PauseProbing()
- func (p *UplinkProber) ResumeProbing()
- func (p *UplinkProber) StartNIProbing(niConfig types.NetworkInstanceConfig) (initialStatus NIProbeStatus, err error)
- func (p *UplinkProber) StopNIProbing(ni uuid.UUID) error
- func (p *UplinkProber) WatchProbeUpdates() <-chan []NIProbeStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // MaxContFailCnt : maximum number of continuous failures that is allowed to happen // before the next hop or remote network reachability is declared as DOWN. MaxContFailCnt uint8 // MaxContSuccessCnt : maximum number of continuous successes that is allowed to happen // before the next hop or remote network reachability is declared as UP. MaxContSuccessCnt uint8 // MinContPrevStateCnt : how many continuous confirmations of the previous UP/DOWN state // are needed for a sudden change to be applied immediately. This avoids frequent // uplink selection changes with a flapping connectivity, but also ensures that // an occasional change is reflected as soon as possible. // Currently only applied for Next Hop probing, not for remote probing. MinContPrevStateCnt uint8 // NextHopProbeTimeout : timeout for a single next hop probe. NextHopProbeTimeout time.Duration // RemoteProbeTimeout : timeout for a single remote probe. RemoteProbeTimeout time.Duration // NHToRemoteProbeRatio : How many NH probes must be run first before a single remote // probe is executed. // Minimum allowed value is 5. NHToRemoteProbeRatio uint8 // NHProbeInterval : how often to execute NH probe. // Remote probe interval is NHProbeInterval * NHToRemoteProbeRatio NHProbeInterval time.Duration }
Config : configuration for uplink prober. Currently, this is not configurable via controller.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig : default configuration for UplinkProber. Since these options are currently not configurable via controller, non-default config is used only in unit tests.
type ControllerReachProber ¶
type ControllerReachProber struct {
// contains filtered or unexported fields
}
ControllerReachProber is the default reachability prober that uses ICMP ping to test next hop reachability and HTTP GET against the controller to evaluate remote reachability.
func NewControllerReachProber ¶
func NewControllerReachProber(log *base.LogObject, agentName string, metrics *zedcloud.AgentMetrics) *ControllerReachProber
NewControllerReachProber is a constructor for ControllerReachProber.
func (*ControllerReachProber) ProbeNextHopReach ¶
func (p *ControllerReachProber) ProbeNextHopReach(ctx context.Context, uplinkLL string, dns *types.DeviceNetworkStatus) (probedNHs []net.IP, err error)
ProbeNextHopReach uses tatsushid/go-fastping package to efficiently execute ICMP ping against the uplink's next hop.
func (*ControllerReachProber) ProbeRemoteReach ¶
func (p *ControllerReachProber) ProbeRemoteReach(ctx context.Context, uplinkLL string, dns *types.DeviceNetworkStatus) (probedEps []url.URL, err error)
ProbeRemoteReach runs HTTP GET against the controller address to determine if remote networks are reachable.
type MockReachProber ¶
MockReachProber is a mock ReachabilityProber used only for unit testing.
func NewMockReachProber ¶
func NewMockReachProber() *MockReachProber
NewMockReachProber is constructor for NewMockReachProber.
func (*MockReachProber) LastNHProbe ¶
func (p *MockReachProber) LastNHProbe(uplinkLL string) time.Time
LastNHProbe returns the timestamp of the last NH probing executed for the given uplink.
func (*MockReachProber) LastRemoteProbe ¶
func (p *MockReachProber) LastRemoteProbe(uplinkLL string) time.Time
LastRemoteProbe returns the timestamp of the last Remote probing executed for the given uplink.
func (*MockReachProber) ProbeNextHopReach ¶
func (p *MockReachProber) ProbeNextHopReach(ctx context.Context, uplinkLL string, dns *types.DeviceNetworkStatus) (probedNHs []net.IP, err error)
ProbeNextHopReach returns fake probing results prepared using SetNextHopState.
func (*MockReachProber) ProbeRemoteReach ¶
func (p *MockReachProber) ProbeRemoteReach(ctx context.Context, uplinkLL string, dns *types.DeviceNetworkStatus) (probedEps []url.URL, err error)
ProbeRemoteReach return fake probing results prepared using SetRemoteState.
func (*MockReachProber) SetNextHopState ¶
func (p *MockReachProber) SetNextHopState(uplinkLL string, nhs []net.IP, reachErr error, probeRTT time.Duration)
SetNextHopState is used to simulate the state of next hop reachability for a given uplink port. Provide the list of next hops, non-nil error if they are not reachable and the time it takes to execute one probe.
func (*MockReachProber) SetRemoteState ¶
func (p *MockReachProber) SetRemoteState(uplinkLL string, remoteEps []url.URL, reachErr error, probeRTT time.Duration)
SetRemoteState is used to simulate the state of remote networks reachability for a given uplink port. Provide the list of probed remote endpoints, non-nil error if they are not reachable and the time it takes to execute one probe.
type NIProbeStatus ¶
type NIProbeStatus struct { NetworkInstance uuid.UUID // SelectedUplinkLL is a logical label of the uplink interface selected as having // the best working connectivity at the moment. SelectedUplinkLL string SelectedAt time.Time }
NIProbeStatus is published whenever the selected uplink interface for a network instance changes.
type ReachabilityProber ¶
type ReachabilityProber interface { // ProbeNextHopReach : test reachability of the uplink's closest router(s). // Return non-nil error if the next hop is not reachable. // Additionally, return a list of all next hops that were used for probing. // It is preferred for the method to be fast as it will be called quite often. ProbeNextHopReach(ctx context.Context, uplinkLL string, dns *types.DeviceNetworkStatus) ( probedNHs []net.IP, err error) // ProbeRemoteReach : test reachability of remote network(s), such as the Internet // (or whatever remote networks are expected to be reachable via this uplink). // Return non-nil error if remote networks are not reachable. // Additionally, return a list of all remote endpoints that were used for probing. // This method is not called as often as ProbeNextHopReach and can therefore // take a little longer to execute if needed. ProbeRemoteReach(ctx context.Context, uplinkLL string, dns *types.DeviceNetworkStatus) ( probedEps []url.URL, err error) }
ReachabilityProber is used by UplinkProber to test the reachability of the uplink's next hop(s) (the closest router(s)) and remote networks (Internet, cloud VPC, etc.). How the reachability is determined (i.e. what protocols/techniques are used, which remote endpoints are communicated with, etc.) is up to the prober implementation. The default implementation uses ICMP ping for NH probing and HTTP GET towards the controller to evaluate remote reachability. A mock implementation is also provided for unit testing purposes.
type UplinkProber ¶
UplinkProber is used by zedrouter to test the connectivity status of uplink interfaces (aka ports) used by (non-switch) network instances. The prober picks the lowest-cost working port for every network instance that is configured with the "uplink" label instead of being attached to a specific port. Whenever the selected uplink changes, zedrouter is notified by the prober. It is up to the zedrouter to perform the re-routing from one port to another.
func NewUplinkProber ¶
func NewUplinkProber(log *base.LogObject, config Config, reachProber ReachabilityProber) *UplinkProber
NewUplinkProber is a constructor for UplinkProber.
func (*UplinkProber) ApplyDNSUpdate ¶
func (p *UplinkProber) ApplyDNSUpdate(dns types.DeviceNetworkStatus)
ApplyDNSUpdate : update the state of probing based on a newly received Device Network Status from NIM.
func (*UplinkProber) GetProbeMetrics ¶
func (p *UplinkProber) GetProbeMetrics( ni uuid.UUID) (metrics types.ProbeMetrics, err error)
GetProbeMetrics : get probing metrics for a given network instance.
func (*UplinkProber) GetProbeStatus ¶
func (p *UplinkProber) GetProbeStatus(ni uuid.UUID) (NIProbeStatus, error)
GetProbeStatus : get the current probing status for a given network instance.
func (*UplinkProber) PauseProbing ¶
func (p *UplinkProber) PauseProbing()
PauseProbing : pause all probing activities for all network instances. The method is blocking and when it returns it is guaranteed that no probing is in progress. It is used by zedrouter whenever network stack is being reconfigured, which could interfere with the probing and produce false results.
func (*UplinkProber) ResumeProbing ¶
func (p *UplinkProber) ResumeProbing()
ResumeProbing : resume all probing activities after a pause.
func (*UplinkProber) StartNIProbing ¶
func (p *UplinkProber) StartNIProbing(niConfig types.NetworkInstanceConfig) ( initialStatus NIProbeStatus, err error)
StartNIProbing tells UplinkProber to start periodic probing of uplink interfaces for this network instance. It is called by zedrouter whenever a new network instance with "uplink" label is created or when the config related to probing has changed (in that case the probing is first stopped, then restarted with the new config).
func (*UplinkProber) StopNIProbing ¶
func (p *UplinkProber) StopNIProbing(ni uuid.UUID) error
StopNIProbing tells UplinkProber to stop periodic probing of uplink interfaces for this network instance. It is called by zedrouter whenever a network instance with "uplink" label is about to be deleted (i.e. the method is called before removal) or when the config related to probing has changed (in that case the probing is first stopped, then restarted with the new config).
func (*UplinkProber) WatchProbeUpdates ¶
func (p *UplinkProber) WatchProbeUpdates() <-chan []NIProbeStatus
WatchProbeUpdates returns channel where UplinkProber will for every probed network instance publish an update of which uplink interface should be used. Channel type is a slice of probe statuses - this is used to publish multiple updates in a bulk for efficiency.