diff --git a/ops/nixos/lib/blade-router.nix b/ops/nixos/lib/blade-router.nix index ef08070881..0c2ed7e545 100644 --- a/ops/nixos/lib/blade-router.nix +++ b/ops/nixos/lib/blade-router.nix @@ -2,9 +2,26 @@ # # SPDX-License-Identifier: Apache-2.0 -{ lib, config, ... }: +{ lib, config, pkgs, ... }: with lib; -{ +let + notifyBird = pkgs.writeScript "blade-router-vrrp-bird.sh" '' + ENDSTATE=$3 + NAME=$2 + TYPE=$1 + + case $ENDSTATE in + "MASTER") birdc enable export4 + birdc enable export6 + exit 0 + ;; + *) birdc disable export4 + birdc disable export6 + exit 0 + ;; + esac + ''; +in { imports = [ ../lib/bgp.nix ]; @@ -112,7 +129,7 @@ with lib; }; in { enable = true; - vrrpInstances.mgmtGateway = mgmtBase // { + vrrpInstances.mgmtGateway4 = mgmtBase // { virtualIps = [ { addr = "10.100.0.1/23"; } { addr = "${config.my.blade-router.addresses.br-public-vip.v4.addr}/${toString config.my.blade-router.addresses.br-public-vip.v4.prefixLength}"; dev = "br-public"; } @@ -126,6 +143,15 @@ with lib; ]; virtualRouterId = 2; }; + extraConfig = '' + vrrp_sync_group mgmtGateway { + group { + mgmtGateway4 + mgmtGateway6 + } + notify ${notifyBird} + } + ''; }; services.radvd = {