diff --git a/internal/server/network/driver_physical.go b/internal/server/network/driver_physical.go index 1908c76b2f3..a7a2ca06f99 100644 --- a/internal/server/network/driver_physical.go +++ b/internal/server/network/driver_physical.go @@ -11,6 +11,7 @@ import ( "github.com/lxc/incus/v6/internal/server/cluster/request" "github.com/lxc/incus/v6/internal/server/db" "github.com/lxc/incus/v6/internal/server/ip" + "github.com/lxc/incus/v6/internal/server/network/ovs" "github.com/lxc/incus/v6/shared/api" "github.com/lxc/incus/v6/shared/logger" "github.com/lxc/incus/v6/shared/util" @@ -340,6 +341,24 @@ func (n *physical) Update(newNetwork api.NetworkPut, targetNode string, clientTy return err } + // Update OVS bridge entries (for dependent OVN networks). + if hostNameChanged { + vswitch, err := n.state.OVS() + if err == nil { + ovsBridge := fmt.Sprintf("incusovn%d", n.id) + + err := vswitch.DeleteBridgePort(context.TODO(), ovsBridge, oldNetwork.Config["parent"]) + if err != nil && err != ovs.ErrNotFound { + return err + } + + err = vswitch.CreateBridgePort(context.TODO(), ovsBridge, newNetwork.Config["parent"], true) + if err != nil && err != ovs.ErrNotFound { + return err + } + } + } + revert.Success() // Notify dependent networks (those using this network as their uplink) of the changes.