VintageNet.RouteManager (vintage_net v0.11.3) View Source

This module manages the default route.

Devices with more than one network interface may have more than one way of reaching the Internet. The routing table decides which interface an IP packet should use by looking at the "default route" entries. One interface is chosen.

Since not all interfaces are equal, we'd like Linux to pick the fastest and lowest latency one. for example, one could prefer wired Ethernet over WiFi and prefer WiFi over a cellular connection. This module lets you specify an ordering for interfaces and sets up the routes based on this ordering.

This module also handles networking failures. One failure that Linux can't figure out on its own is whether an interface can reach the Internet. Internet reachability is handled elsewhere like in the ConnectivityChecker module. This module should be told reachability status so that it can properly order default routes so that the best reachable interface is used.

IMPORTANT: This module uses priority-based routing. Make sure the following kernel options are enabled:

CONFIG_IP_ADVANCED_ROUTER=y
CONFIG_IP_MULTIPLE_TABLES=y

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Clear out the default gateway for an interface.

Refresh route metrics for all interfaces.

Set the connection status on an interface.

Set the default route for an interface.

Start the route manager

Stop the route manager.

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Specs

clear_route(VintageNet.ifname()) :: :ok

Clear out the default gateway for an interface.

Specs

refresh_route_metrics() :: :ok

Refresh route metrics for all interfaces.

Link to this function

set_connection_status(ifname, status, why \\ "unknown")

View Source

Specs

set_connection_status(
  VintageNet.ifname(),
  VintageNet.connection_status(),
  String.t()
) :: :ok

Set the connection status on an interface.

Changing the connection status can re-prioritize routing. The specified interface doesn't need to have a default route.

Link to this function

set_route(ifname, ip_subnets, route)

View Source

Specs

Set the default route for an interface.

This replaces any existing routes on that interface

Specs

start_link(keyword()) :: GenServer.on_start()

Start the route manager

Options:

Specs

stop() :: :ok

Stop the route manager.