commit b6a8048c8bb2e9fdb46dd688173ac1c71f3924a0
parent e4f7e911b89b838b0665165bcfb4da4301f55d5b
Author: Daniel Barlow <dan@telent.net>
Date: Wed, 6 Apr 2022 22:26:37 +0000
uplink: use route with lowest metric
Diffstat:
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/blinkenlicht/netlink.nix b/blinkenlicht/netlink.nix
@@ -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 = ''
diff --git a/blinkenlicht/uplink.fnl b/blinkenlicht/uplink.fnl
@@ -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)
))