diff --git a/devices/gl-mt300a/default.nix b/devices/gl-mt300a/default.nix index 040f99c5..4c888209 100644 --- a/devices/gl-mt300a/default.nix +++ b/devices/gl-mt300a/default.nix @@ -13,6 +13,7 @@ module = { pkgs, ...}: let + inherit (pkgs.liminix.networking) interface; openwrt = pkgs.fetchFromGitHub { name = "openwrt-source"; repo = "openwrt"; @@ -32,6 +33,22 @@ "${openwrt}/target/linux/ramips/dts" ]; }; + networkInterfaces = { + # lan and wan ports are both behind a switch on eth0 + eth = interface { device = "eth0"; }; + lan = interface { + type = "vlan"; + device = "eth0.1"; + link = "eth0"; + id = "1"; + }; + wan = interface { + type = "vlan"; + device = "eth0.2"; + id = "2"; + link = "eth0"; + }; + }; }; boot.tftp = { loadAddress = "0x00A00000"; @@ -87,8 +104,16 @@ NET_RALINK_MDIO_MT7620 = "y"; NET_RALINK_MT7620 = "y"; + # both the ethernet ports on this device (lan and wan) + # are behind a switch, so we need VLANs to do anything + # useful with them + + VLAN_8021Q = "y"; SWCONFIG = "y"; SWPHY = "y"; + + BRIDGE_VLAN_FILTERING = "y"; + BRIDGE_IGMP_SNOOPING = "y"; NET_VENDOR_RALINK = "y"; MTD = "y"; diff --git a/pkgs/liminix-tools/networking/default.nix b/pkgs/liminix-tools/networking/default.nix index 04231735..22fe6dd0 100644 --- a/pkgs/liminix-tools/networking/default.nix +++ b/pkgs/liminix-tools/networking/default.nix @@ -8,11 +8,13 @@ let inherit (liminix.services) oneshot longrun; inherit (lib) concatStringsSep optional; in { - interface = { type ? "hardware", device, primary ? null, dependencies ? [] } @ args: + interface = { type ? "hardware", device, link ? null, primary ? null, id ? null, dependencies ? [] } @ args: let ups = [] ++ optional (type == "bridge") "ip link add name ${device} type bridge" + ++ optional (type == "vlan") + "ip link add link ${link} name ${device} type vlan id ${id}" ++ ["${ifwait}/bin/ifwait -v ${device} present"] ++ ["ip link set up dev ${device}"] ++ optional (primary != null)