forked from DGNum/liminix
fix(bridge): pick up MAC from another interface
This avoids the OPERSTATE unknown when the bridge is brought up but the members are not ready yet. This will make OPERSTATE to down, enabling us to wait until we have brought up completely all the members. Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
This commit is contained in:
parent
f0b4e826cb
commit
21ff11503e
3 changed files with 15 additions and 3 deletions
|
@ -28,6 +28,12 @@ in
|
||||||
type = types.str;
|
type = types.str;
|
||||||
description = "bridge interface name to create";
|
description = "bridge interface name to create";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
macAddressFromInterface = mkOption {
|
||||||
|
type = types.nullOr liminix.lib.types.service;
|
||||||
|
default = null;
|
||||||
|
description = "reuse mac address from an existing interface service";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
members = config.system.callService ./members.nix {
|
members = config.system.callService ./members.nix {
|
||||||
primary = mkOption {
|
primary = mkOption {
|
||||||
|
|
|
@ -3,15 +3,20 @@
|
||||||
, ifwait
|
, ifwait
|
||||||
, lib
|
, lib
|
||||||
}:
|
}:
|
||||||
{ ifname } :
|
{ ifname, macAddressFromInterface ? null } :
|
||||||
let
|
let
|
||||||
inherit (liminix.services) bundle oneshot;
|
inherit (liminix.services) bundle oneshot;
|
||||||
inherit (lib) mkOption types;
|
inherit (lib) mkOption types optional;
|
||||||
in oneshot rec {
|
in oneshot rec {
|
||||||
name = "${ifname}.link";
|
name = "${ifname}.link";
|
||||||
up = ''
|
up = ''
|
||||||
ip link add name ${ifname} type bridge
|
${if macAddressFromInterface == null then
|
||||||
|
"ip link add name ${ifname} type bridge"
|
||||||
|
else
|
||||||
|
"ip link add name ${ifname} address $(output ${macAddressFromInterface} ether) type bridge"}
|
||||||
${liminix.networking.ifup name ifname}
|
${liminix.networking.ifup name ifname}
|
||||||
'';
|
'';
|
||||||
down = "ip link set down dev ${ifname}";
|
down = "ip link set down dev ${ifname}";
|
||||||
|
|
||||||
|
dependencies = optional (macAddressFromInterface != null) macAddressFromInterface;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
ip link set up dev ${ifname}
|
ip link set up dev ${ifname}
|
||||||
(in_outputs ${name}
|
(in_outputs ${name}
|
||||||
echo ${ifname} > ifname
|
echo ${ifname} > ifname
|
||||||
|
cat /sys/class/net/${ifname}/address > ether
|
||||||
)
|
)
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue