From 5800dda13ecc995270c36d8a351349e1b7de773c Mon Sep 17 00:00:00 2001 From: Benjamin Milde Date: Fri, 22 Oct 2021 18:30:45 +0200 Subject: [PATCH] Add API to update route metrics on all interfaces --- lib/vintage_net/route_manager.ex | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/vintage_net/route_manager.ex b/lib/vintage_net/route_manager.ex index 05f0fb30..0752c8b1 100644 --- a/lib/vintage_net/route_manager.ex +++ b/lib/vintage_net/route_manager.ex @@ -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 @@ -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,