macvtap mac address

This commit is contained in:
Sagar Ch 2024-06-11 22:48:45 +00:00
parent 0e6d764517
commit abedd98ac2
2 changed files with 5 additions and 3 deletions

View file

@ -29,7 +29,7 @@ let
'';
};
mkMacvtap = macvtapName: macvtapCfg:
mkMacvtap = macvtapName: macvtapVmCfg:
let
macvtapNetworkCfg = config.vmix.networks.${netCfg.name}.bridges.macvtaps.${macvtapName};
macvtapInterfaceName = "mt-${vmCfg.name}-${macvtapNetworkCfg.uplink.iface}";
@ -37,9 +37,10 @@ let
{
name = macvtapName;
iface = macvtapInterfaceName;
mac = macvtapCfg.mac;
mac = macvtapVmCfg.mac;
create = ''
ip link add link ${macvtapNetworkCfg.uplink.iface} name ${macvtapInterfaceName} type macvtap mode bridge
${lib.optionalString (macvtapVmCfg.mac != null) "ip link set dev ${macvtapInterfaceName} address ${macvtapVmCfg.mac}"}
ip link set ${macvtapInterfaceName} netns ${netName}.vmix
ip netns exec ${netName}.vmix ip link set dev ${macvtapInterfaceName} up
'';

View file

@ -151,7 +151,8 @@ with lib;
description = "Enable the MACVTap interface.";
};
mac = mkOption {
type = types.str;
type = types.nullOr types.str;
default = null;
description = "MAC address for the MACVTap interface.";
};
};