From 90cd903381954e06131d139717daf1d35b3a4928 Mon Sep 17 00:00:00 2001 From: Astro Date: Thu, 23 Jun 2022 19:07:54 +0200 Subject: [PATCH] pkgs/switches/linksys-srw2048: implement bonded non-trunked ports --- nix/pkgs/switches/linksys-srw2048.nix | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/nix/pkgs/switches/linksys-srw2048.nix b/nix/pkgs/switches/linksys-srw2048.nix index a7bbb25..e219daf 100644 --- a/nix/pkgs/switches/linksys-srw2048.nix +++ b/nix/pkgs/switches/linksys-srw2048.nix @@ -68,8 +68,8 @@ with lib; linkConfig = hostConfig.links.${name}; isAccess = config.site.net ? ${name}; netConfig = config.site.net.${name}; - isTrunk = !isAccess; - isBond = isTrunk && builtins.length linkConfig.ports > 1; + isTrunk = linkConfig.trunk; + isBond = builtins.length linkConfig.ports > 1; vlans = concatStringsSep "," (map toString (sort linkConfig.vlans)); ports = concatStringsSep "," linkConfig.ports; in @@ -108,6 +108,29 @@ with lib; send "exit\r" expect "(config)#" '') linkConfig.ports + else if isBond + then + if builtins.length linkConfig.vlans != 1 + then throw "Cannot configure non-trunked port with multiple vlans" + else '' + send "interface range ethernet ${ports}\r" + expect "(config-if)#" + send "channel-group ${linkConfig.group} mode auto\r" + expect "(config-if)#" + send "interface port-channel ${linkConfig.group}\r" + expect "(config-if)#" + send "exit\r" + + send "interface port-channel ${linkConfig.group}\r" + expect "(config-if)#" + send "switchport mode access\r" + expect "(config-if)#" + send "switchport access vlan ${toString (builtins.head linkConfig.vlans)}\r" + expect "(config-if)#" + + send "exit\r" + expect "(config)#" + '' else concatMapStrings (port: '' send "interface ethernet ${port}\r" expect "(config-if)#"