Skip to content

Commit

Permalink
Add API to update route metrics on all interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Milde authored and fhunleth committed Oct 25, 2021
1 parent 95e7ce3 commit 5800dda
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/vintage_net/route_manager.ex
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ defmodule VintageNet.RouteManager do
GenServer.call(__MODULE__, {:clear_route, ifname})
end

@doc """
Refresh route metrics for all interfaces.
"""
@spec refresh_route_metrics() :: :ok
def refresh_route_metrics() do
GenServer.call(__MODULE__, :refresh_route_metrics)
end

## GenServer

@impl GenServer
Expand Down Expand Up @@ -190,6 +198,13 @@ defmodule VintageNet.RouteManager do
end
end

@impl GenServer
def handle_call(:refresh_route_metrics, _from, state) do
Logger.info("RouteManager: refresh_route_metrics")
new_state = update_route_tables(state)
{:reply, :ok, new_state}
end

defp interface_info_changed?(state, ifname, ip_subnets, default_gateway) do
case Map.fetch(state.interfaces, ifname) do
{:ok,
Expand Down

0 comments on commit 5800dda

Please sign in to comment.