commit e86e9430fc7bd97260094df1e281ccc1ffe8b282
parent 06687a819a46aa721b3886e0c6af4959e7b4a334
Author: Daniel Barlow <dan@telent.net>
Date: Tue, 7 Mar 2023 19:10:12 +0000
vlans and mt300a wired network interfaces
Diffstat:
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git 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
@@ -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)