netns: fix setup service restarts

This commit is contained in:
Erik Arvstedt 2020-11-03 21:54:14 +01:00
parent 63a464431b
commit 0972af55f1
No known key found for this signature in database
GPG Key ID: 33312B944DD97846

View File

@ -172,8 +172,13 @@ in {
${netnsIptables} -w -A INPUT -s ${allowedAddresses} -j ACCEPT
${netnsIptables} -w -A OUTPUT -d ${allowedAddresses} -j ACCEPT
'';
# Link deletion is implicit in netns deletion, but it sometimes only happens
# after `netns delete` finishes. Add an extra `link del` to ensure that
# the link is deleted before the service stops, which is needed for service
# restart to succeed.
preStop = ''
${ip} netns delete ${netnsName}
${ip} link del ${peer} 2> /dev/null || true
'';
serviceConfig = {
Type = "oneshot";