From fae628f0b2654c2998d20d3e2a882ef6205471f4 Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Thu, 28 Mar 2024 00:45:06 +0000 Subject: [PATCH] rexxar: set a kt_prefsrc --- ops/nixos/lib/bgp.nix | 12 ++++++++++-- ops/nixos/rexxar/bgp.nix | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ops/nixos/lib/bgp.nix b/ops/nixos/lib/bgp.nix index 880a46e575..d4653b1813 100644 --- a/ops/nixos/lib/bgp.nix +++ b/ops/nixos/lib/bgp.nix @@ -15,7 +15,6 @@ let if ! (avoid_martians4()) then reject; ${if ix.remote.must_be_next_hop then "if (bgp_path.first != ${toString ix.remote.asn}) then reject;" else "# no next-hop requirement"} ${lib.concatMapStringsSep "\n" (asn: "if (bgp_path ~ [= * ${toString asn} * =]) then reject;") ix.remote.drop_asns} - if (bgp_path ~ [= * 16276 * =] && gw = 195.66.225.6) then gw = 195.66.224.220; # OVH must go via router 1; router 2 is bork. ${lib.optionalString (ixName == "quadv") '' bgp_ext_community.add((ro, 205479, 1000)); bgp_ext_community.add((ro, 205479, 4000)); # etheroute @@ -26,6 +25,7 @@ let bgp_community.add((64600, 3356)); # no Lumen bgp_community.add((64600, 5459)); # no LINX peers (inc. RS) ''} + ${if ix.remote.pref_src.v4 != null then "krt_prefsrc = ${ix.remote.pref_src.v4};" else "# no krt_prefsrc"} bgp_local_pref = ${toString ix.remote.bgp_local_pref}; accept; } @@ -52,7 +52,7 @@ let if ! (avoid_martians6()) then reject; ${if ix.remote.must_be_next_hop then "if (bgp_path.first != ${toString ix.remote.asn}) then reject;" else "# no next-hop requirement"} ${lib.concatMapStringsSep "\n" (asn: "if (bgp_path ~ [= * ${toString asn} * =]) then reject;") ix.remote.drop_asns} - if (bgp_path ~ [= * 16276 * =] && gw = 2001:7f8:4::3f94:2) then gw = 2001:7f8:4::3f94:1; # OVH must go via router 1; router 2 is bork. + ${if ix.remote.pref_src.v6 != null then "krt_prefsrc = ${ix.remote.pref_src.v6};" else "# no krt_prefsrc"} bgp_local_pref = ${toString ix.remote.bgp_local_pref}; accept; } @@ -189,6 +189,14 @@ in { type = nullOr int; default = null; }; + pref_src.v4 = mkOption { # lukegbgp.config.peering..pref_src.v4 + type = nullOr str; + default = null; + }; + pref_src.v6 = mkOption { # lukegbgp.config.peering..pref_src.v6 + type = nullOr str; + default = null; + }; must_be_next_hop = mkOption { # lukegbgp.config.peering..remote.must_be_next_hop type = bool; default = true; diff --git a/ops/nixos/rexxar/bgp.nix b/ops/nixos/rexxar/bgp.nix index 2806940bb0..fa5177427e 100644 --- a/ops/nixos/rexxar/bgp.nix +++ b/ops/nixos/rexxar/bgp.nix @@ -34,6 +34,8 @@ link.linx = base ++ [{ local.v4 = "195.66.224.58"; local.v6 = "2001:7f8:4::3:22a7:1"; + remote.pref_src.v4 = "195.74.55.21"; + remote.pref_src.v6 = "2a03:ee40:8080:9:1::2"; }]; peer.velox.remote = { asn = 3170;