1322de1ee0
All checks were successful
Should cover egress & ingress. Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
31 lines
995 B
Nix
31 lines
995 B
Nix
{
|
|
liminix
|
|
, ifwait
|
|
, lib
|
|
}:
|
|
{ ifname, macAddressFromInterface ? null, untagged } :
|
|
let
|
|
inherit (liminix.services) oneshot;
|
|
inherit (lib) optional optionalString;
|
|
# This enables vlan_filtering if we do make use of it.
|
|
extra = if untagged.enable then " vlan_filtering 1 vlan_default_pvid ${toString untagged.default-pvid}" else "";
|
|
in oneshot rec {
|
|
name = "${ifname}.link";
|
|
up = ''
|
|
${if macAddressFromInterface == null then
|
|
"ip link add name ${ifname} type bridge${extra}"
|
|
else
|
|
"ip link add name ${ifname} address $(output ${macAddressFromInterface} ether) type bridge${extra}"}
|
|
|
|
${optionalString untagged.enable
|
|
"bridge vlan add vid ${toString untagged.pvid} dev ${ifname} pvid untagged self"}
|
|
|
|
(in_outputs ${name}
|
|
echo ${ifname} > ifname
|
|
cat /sys/class/net/${ifname}/address > ether
|
|
)
|
|
'';
|
|
down = "ip link delete ${ifname}";
|
|
|
|
dependencies = optional (macAddressFromInterface != null) macAddressFromInterface;
|
|
}
|