From 8690c489ff0a3469a001132803bd5f3ea6da68e3 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 23 Oct 2021 15:35:21 +0200 Subject: yggdrasil-wg: ... --- accounts/gkleen@sif/zshrc | 17 +++++++++++++++++ modules/yggdrasil-wg/default.nix | 18 +++++++++++------- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/accounts/gkleen@sif/zshrc b/accounts/gkleen@sif/zshrc index 9fe88163..bcdc662a 100644 --- a/accounts/gkleen@sif/zshrc +++ b/accounts/gkleen@sif/zshrc @@ -399,6 +399,23 @@ ssh-installer() { ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o IdentityFile=~/.ssh/gkleen@sif.midgard.yggdrasil $@ } +dichotomic_search() { + min=$1; shift + max=$1; shift + + while [[ $min -lt $max ]]; do + # Compute the mean between min and max, rounded up to the superior unit + current=$(( (min + max + 1 ) / 2 )) + if $@ $current; then + min=$current + else + max=$((current - 1)) + fi + done + + echo $min +} + alias '..'='cd ..' alias -g L='| less' alias -g S='&> /dev/null' diff --git a/modules/yggdrasil-wg/default.nix b/modules/yggdrasil-wg/default.nix index 316371ea..48672fcb 100644 --- a/modules/yggdrasil-wg/default.nix +++ b/modules/yggdrasil-wg/default.nix @@ -37,9 +37,14 @@ let sif = "${wgSubnet}:2::/${toString wgHostLength}"; }; greHostMACPrefixes = { - surtr = "02:00:00:00:00"; - vidhar = "02:00:00:00:01"; - sif = "02:00:00:00:02"; + surtr = "02:00:01:00:00"; + vidhar = "02:00:01:00:01"; + sif = "02:00:01:00:02"; + }; + batHostMACs = { + surtr = "02:00:00:00:00:00"; + vidhar = "02:00:00:01:00:00"; + sif = "02:00:00:02:00:00"; }; batHostIPs = { surtr = ["${batSubnet}::/${toString batHostLength}"]; @@ -70,12 +75,10 @@ let netdevConfig = { Name = "yggre-${other}"; Kind = "ip6gretap"; - MTUBytes = toString (1280 + 58); }; tunnelConfig = { Local = stripSubnet wgHostIPs.${hostName}; Remote = stripSubnet wgHostIPs.${other}; - DiscoverPathMTU = false; }; }; linkToGreNetwork = ix: opts@{from, to, ...}: @@ -123,7 +126,6 @@ in { netdevConfig = { Name = "yggdrasil-wg"; Kind = "wireguard"; - MTUBytes = toString (1280 + 58 + 70); }; wireguardConfig = { PrivateKeyFile = config.sops.secrets."yggdrasil-wg.priv".path; @@ -135,7 +137,9 @@ in { netdevConfig = { Name = "yggdrasil"; Kind = "batadv"; - MTUBytes = toString 1280; + }; + linkConfig = { + MACAddress = "${batHostMACs.${hostName}}"; }; }; } // listToAttrs (map linkToGreDev hostLinks); -- cgit v1.2.3