libnetwork/drivers/bridge: link.Enable: don't register reload on error

Only register a reload function if we actually managed to enable the link.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2023-07-21 12:16:48 +02:00
parent 0f4ba145ee
commit 8b6203b613
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -36,9 +36,12 @@ func (l *link) Enable() error {
linkFunction := func() error {
return linkContainers(iptables.Append, l.parentIP, l.childIP, l.ports, l.bridge, false)
}
if err := linkFunction(); err != nil {
return err
}
iptables.OnReloaded(func() { linkFunction() })
return linkFunction()
iptables.OnReloaded(func() { _ = linkFunction() })
return nil
}
func (l *link) Disable() {