View Source VintageNet.Route.Calculator (vintage_net v0.13.5)
This module computes the desired routing table contents
It's used by the RouteManager to update the Linux routing tables when interfaces come online or change state. See the RouteManager docs for a discussion of how routes are configured.
The functions in this module have no side effects so that it's easier to test that routing scenarios result in correct Linux routing table configurations.
Summary
Functions
Compute a Linux routing table configuration
Initialize state carried between calculations
Return the table indices used for routing based on source IP.
Types
@type interface_infos() :: %{ required(VintageNet.ifname()) => VintageNet.Route.InterfaceInfo.t() }
@type table_indices() :: %{ required(VintageNet.ifname()) => VintageNet.Route.table_index() }
Functions
@spec compute(table_indices(), interface_infos(), VintageNet.Route.route_metric_fun()) :: {table_indices(), VintageNet.Route.entries()}
Compute a Linux routing table configuration
The entries are ordered so that List.myers_difference/2 can be used to minimize the routing table changes.
@spec init() :: table_indices()
Initialize state carried between calculations
@spec rule_table_index_range() :: Range.t()
Return the table indices used for routing based on source IP.