network-interfaces: reload bridges on conf changes
And adopt the tests to add an interface and remove it again. It should work when deactivating rstp, it will not work when activating rstp for the first bridge as then the userspace daemon is not yet available. But once one bridge is active with stp, it should work with the reload for any further bridge. Fixes #21745. Also see #22547.
This commit is contained in:
@@ -239,6 +239,10 @@ let
|
||||
ip link set "${i}" master "${n}"
|
||||
ip link set "${i}" up
|
||||
'')}
|
||||
# Save list of enslaved interfaces
|
||||
echo "${flip concatMapStrings v.interfaces (i: ''
|
||||
${i}
|
||||
'')}" > /run/${n}.interfaces
|
||||
|
||||
# Enable stp on the interface
|
||||
${optionalString v.rstp ''
|
||||
@@ -250,7 +254,28 @@ let
|
||||
postStop = ''
|
||||
ip link set "${n}" down || true
|
||||
ip link del "${n}" || true
|
||||
rm -f /run/${n}.interfaces
|
||||
'';
|
||||
reload = ''
|
||||
# Un-enslave child interfaces (old list of interfaces)
|
||||
for interface in `cat /run/${n}.interfaces`; do
|
||||
ip link set "$interface" nomaster up
|
||||
done
|
||||
|
||||
# Enslave child interfaces (new list of interfaces)
|
||||
${flip concatMapStrings v.interfaces (i: ''
|
||||
ip link set "${i}" master "${n}"
|
||||
ip link set "${i}" up
|
||||
'')}
|
||||
# Save list of enslaved interfaces
|
||||
echo "${flip concatMapStrings v.interfaces (i: ''
|
||||
${i}
|
||||
'')}" > /run/${n}.interfaces
|
||||
|
||||
# (Un-)set stp on the bridge
|
||||
echo ${if v.rstp then "2" else "0"} > /sys/class/net/${n}/bridge/stp_state
|
||||
'';
|
||||
reloadIfChanged = true;
|
||||
});
|
||||
|
||||
createVswitchDevice = n: v: nameValuePair "${n}-netdev"
|
||||
|
||||
Reference in New Issue
Block a user