Files
moby/daemon/libnetwork/cnmallocator/drivers_network_windows.go
Albin Kerouanton cbd04b6f08 libnet/cnmallocator: use a list of local netdrivers
The cnmallocator package has a map of supported network drivers which
are registered using a pkg-local driver registry. This registry is then
used to load drivers, and if they have a 'local' DataScope, they aren't
used for anything. Drivers with a 'global' DataScope are called to
allocate cluster-wide network resources.

Instantiating builtin network drivers may have unintended side-effects
(e.g. the bridge driver registers a callback that should run when
firewalld is reloaded), so libnetwork has dummy '*manager' drivers that
do nothing but carry the same Capability than the original driver they
masquerade.

Put 'local drivers' (e.g. those with DataScope 'local') into a separate
list that just contains drivers' name, and don't register them into the
cnmallocator's driver registry.

Remove all the dummy '*manager' drivers as they're not needed anymore.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-09-02 21:53:50 +02:00

30 lines
1004 B
Go

package cnmallocator
import (
"github.com/moby/moby/v2/daemon/libnetwork/driverapi"
"github.com/moby/moby/v2/daemon/libnetwork/drivers/overlay/ovmanager"
"github.com/moby/swarmkit/v2/manager/allocator/networkallocator"
)
// globalDrivers is a map of network drivers that support cluster-wide
// definition and require cluster-wide resources allocation (i.e. DataScope == scope.Global).
var globalDrivers = map[string]func(driverapi.Registerer) error{
"overlay": ovmanager.Register,
}
// localDrivers is a list of builtin network drivers that support cluster-wide
// definition (i.e. --scope=swarm on the CLI), but don't need global
// resources allocations (i.e., DataScope == scope.Local).
var localDrivers = []string{
"internal",
"l2bridge",
"nat",
}
// PredefinedNetworks returns the list of predefined network structures
func (*Provider) PredefinedNetworks() []networkallocator.PredefinedNetworkData {
return []networkallocator.PredefinedNetworkData{
{Name: "nat", Driver: "nat"},
}
}