uplink: use route with lowest metric

phoen
Daniel Barlow 2022-04-06 22:26:37 +00:00
parent e4f7e911b8
commit b6a8048c8b
2 changed files with 12 additions and 2 deletions

View File

@ -1,4 +1,4 @@
{ lua, lib, fetchFromGitHub, buildLuaPackage, libmnl }:
{ lua, lib, fetchpatch, fetchFromGitHub, buildLuaPackage, libmnl }:
let pname = "netlink";
in buildLuaPackage {
inherit pname;
@ -12,6 +12,12 @@ in buildLuaPackage {
rev = "v0.1.1";
hash = "sha256:1833naskl4p7rz5kk0byfgngvw1mvf6cnz64sr3ny7i202wv7s52";
};
patches = [ (fetchpatch {
url = "https://github.com/chris2511/lua-netlink/compare/master...telent:rtnetlink-types.patch";
name = "rtnetlink-types.patch";
hash = "sha256-lBCfP8pMyBIY+XEGWD/nPQ9l2dDOnXeitR1TaRUXCq8=";
})];
buildPhase = "$CC -shared -l mnl -o netlink.so src/*.c";
installPhase = ''

View File

@ -75,7 +75,11 @@
;; (e.g wwan and wlan both have default route)
;; we probably need to store all of them and
;; distinguish by metric
(tset routes (or event.dst "default") event)
(let [dst (or event.dst "default")
existing (. routes dst)]
(if (or (not existing)
(< event.metric existing.metric))
(tset routes dst event)))
{} (print :unhandled event.event)
))