e402f8b929
Some checks failed
Should cover egress & ingress. Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
31 lines
963 B
Nix
31 lines
963 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 0" 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;
|
|
}
|