Merge pull request #135315 from johnjameswhitman/johnjameswhitman/fix-wlan-sub-interfaces
nixos/tasks/network-interfaces: Assign mac to new wlan interface instead of underlying one
This commit is contained in:
commit
052009bf2b
|
@ -1296,14 +1296,14 @@ in
|
|||
'';
|
||||
|
||||
# Udev script to execute for a new WLAN interface. The script configures the new WLAN interface.
|
||||
newInterfaceScript = device: new: pkgs.writeScript "udev-run-script-wlan-interfaces-${new._iName}.sh" ''
|
||||
newInterfaceScript = new: pkgs.writeScript "udev-run-script-wlan-interfaces-${new._iName}.sh" ''
|
||||
#!${pkgs.runtimeShell}
|
||||
# Configure the new interface
|
||||
${pkgs.iw}/bin/iw dev ${new._iName} set type ${new.type}
|
||||
${optionalString (new.type == "mesh" && new.meshID!=null) "${pkgs.iw}/bin/iw dev ${device} set meshid ${new.meshID}"}
|
||||
${optionalString (new.type == "monitor" && new.flags!=null) "${pkgs.iw}/bin/iw dev ${device} set monitor ${new.flags}"}
|
||||
${optionalString (new.type == "managed" && new.fourAddr!=null) "${pkgs.iw}/bin/iw dev ${device} set 4addr ${if new.fourAddr then "on" else "off"}"}
|
||||
${optionalString (new.mac != null) "${pkgs.iproute2}/bin/ip link set dev ${device} address ${new.mac}"}
|
||||
${optionalString (new.type == "mesh" && new.meshID!=null) "${pkgs.iw}/bin/iw dev ${new._iName} set meshid ${new.meshID}"}
|
||||
${optionalString (new.type == "monitor" && new.flags!=null) "${pkgs.iw}/bin/iw dev ${new._iName} set monitor ${new.flags}"}
|
||||
${optionalString (new.type == "managed" && new.fourAddr!=null) "${pkgs.iw}/bin/iw dev ${new._iName} set 4addr ${if new.fourAddr then "on" else "off"}"}
|
||||
${optionalString (new.mac != null) "${pkgs.iproute2}/bin/ip link set dev ${new._iName} address ${new.mac}"}
|
||||
'';
|
||||
|
||||
# Udev attributes for systemd to name the device and to create a .device target.
|
||||
|
@ -1318,7 +1318,7 @@ in
|
|||
# It is important to have that rule first as overwriting the NAME attribute also prevents the
|
||||
# next rules from matching.
|
||||
${flip (concatMapStringsSep "\n") (wlanListDeviceFirst device wlanDeviceInterfaces.${device}) (interface:
|
||||
''ACTION=="add", SUBSYSTEM=="net", ENV{DEVTYPE}=="wlan", ENV{INTERFACE}=="${interface._iName}", ${systemdAttrs interface._iName}, RUN+="${newInterfaceScript device interface}"'')}
|
||||
''ACTION=="add", SUBSYSTEM=="net", ENV{DEVTYPE}=="wlan", ENV{INTERFACE}=="${interface._iName}", ${systemdAttrs interface._iName}, RUN+="${newInterfaceScript interface}"'')}
|
||||
|
||||
# Add the required, new WLAN interfaces to the default WLAN interface with the
|
||||
# persistent, default name as assigned by udev.
|
||||
|
|
|
@ -721,6 +721,24 @@ let
|
|||
assert "mtu 1442" in client.succeed("ip l show dummy0")
|
||||
'';
|
||||
};
|
||||
wlanInterface = let
|
||||
testMac = "06:00:00:00:02:00";
|
||||
in {
|
||||
name = "WlanInterface";
|
||||
machine = { pkgs, ... }: {
|
||||
boot.kernelModules = [ "mac80211_hwsim" ];
|
||||
networking.wlanInterfaces = {
|
||||
wlan0 = { device = "wlan0"; };
|
||||
wap0 = { device = "wlan0"; mac = testMac; };
|
||||
};
|
||||
};
|
||||
testScript = ''
|
||||
machine.start()
|
||||
machine.wait_for_unit("network.target")
|
||||
machine.wait_until_succeeds("ip address show wap0 | grep -q ${testMac}")
|
||||
machine.fail("ip address show wlan0 | grep -q ${testMac}")
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
in mapAttrs (const (attrs: makeTest (attrs // {
|
||||
|
|
Loading…
Reference in a new issue