Documentation
¶
Index ¶
- Variables
- func Less(ei, ej *ExtendedRoute) bool
- type Action
- type ExtendedRoute
- type ExtendedRouteTable
- type Metric
- type RouteTable
- func (rt *RouteTable) AddRoute(route tcpip.Route, metric Metric, tracksInterface bool, dynamic bool, ...)
- func (rt *RouteTable) DelRoute(route tcpip.Route) error
- func (rt *RouteTable) FindNIC(addr tcpip.Address) (tcpip.NICID, error)
- func (rt *RouteTable) GetExtendedRouteTable() ExtendedRouteTable
- func (rt *RouteTable) Set(r []ExtendedRoute)
- func (rt *RouteTable) UpdateMetricByInterface(nicid tcpip.NICID, metric Metric)
- func (rt *RouteTable) UpdateRoutesByInterface(nicid tcpip.NICID, action Action)
- func (rt *RouteTable) UpdateStack(stack *stack.Stack)
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoSuchRoute = errors.New("no such route") ErrNoSuchNIC = errors.New("no such NIC") )
Functions ¶
func Less ¶
func Less(ei, ej *ExtendedRoute) bool
Less compares two routes and returns which one should appear earlier in the route table.
Types ¶
type ExtendedRoute ¶
type ExtendedRoute struct { // Route used to build the route table to be fed into the // gvisor.dev/gvisor/pkg lib. Route tcpip.Route // Metric acts as a tie-breaker when comparing otherwise identical routes. Metric Metric // MetricTracksInterface is true when the metric tracks the metric of the // interface for this route. This means when the interface metric changes, so // will this route's metric. If false, the metric is static and only changed // explicitly by API. MetricTracksInterface bool // Dynamic marks a route as being obtained via DHCP. Such routes are removed // from the table when the interface goes down, vs. just being disabled. Dynamic bool // Enabled marks a route as inactive, i.e., its interface is down and packets // must not use this route. // Disabled routes are omitted when building the route table for the // Netstack lib. // This flag is used with non-dynamic routes (i.e., statically added routes) // to keep them in the table while their interface is down. Enabled bool }
ExtendedRoute is a single route that contains the standard tcpip.Route plus additional attributes.
func (*ExtendedRoute) Match ¶
func (er *ExtendedRoute) Match(addr tcpip.Address) bool
Match matches the given address against this route.
func (*ExtendedRoute) String ¶
func (er *ExtendedRoute) String() string
type ExtendedRouteTable ¶
type ExtendedRouteTable []ExtendedRoute
func (ExtendedRouteTable) String ¶
func (rt ExtendedRouteTable) String() string
type Metric ¶
type Metric uint32
Metric is the metric used for sorting the route table. It acts as a priority with a lower value being better.
type RouteTable ¶
type RouteTable struct {
// contains filtered or unexported fields
}
RouteTable implements a sorted list of extended routes that is used to build the Netstack lib route table.
func (*RouteTable) AddRoute ¶
func (rt *RouteTable) AddRoute(route tcpip.Route, metric Metric, tracksInterface bool, dynamic bool, enabled bool)
AddRoute inserts the given route to the table in a sorted fashion. If the route already exists, it simply updates that route's metric, dynamic and enabled fields.
func (*RouteTable) DelRoute ¶
func (rt *RouteTable) DelRoute(route tcpip.Route) error
DelRoute removes the given route from the route table.
func (*RouteTable) FindNIC ¶
FindNIC returns the NIC-ID that the given address is routed on. This requires an exact route match, i.e. no default route.
func (*RouteTable) GetExtendedRouteTable ¶
func (rt *RouteTable) GetExtendedRouteTable() ExtendedRouteTable
GetExtendedRouteTable returns a copy of the current extended route table.
func (*RouteTable) UpdateMetricByInterface ¶
func (rt *RouteTable) UpdateMetricByInterface(nicid tcpip.NICID, metric Metric)
UpdateMetricByInterface changes the metric for all routes that track a given interface.
func (*RouteTable) UpdateRoutesByInterface ¶
func (rt *RouteTable) UpdateRoutesByInterface(nicid tcpip.NICID, action Action)
UpdateRoutesByInterface applies an action to the routes pointing to an interface.
func (*RouteTable) UpdateStack ¶
func (rt *RouteTable) UpdateStack(stack *stack.Stack)
UpdateStack updates stack with the current route table.