From e8e278c44f18ca26150f6429ebd540e9363decda Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 27 Jul 2021 12:12:11 +0200 Subject: [PATCH] daemon: simplify networking config Signed-off-by: Sebastiaan van Stijn --- daemon/daemon.go | 2 +- daemon/daemon_unix.go | 22 ++++++++++------------ daemon/daemon_windows.go | 4 ++-- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/daemon/daemon.go b/daemon/daemon.go index ced869a380..fd20c94f69 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -1445,7 +1445,7 @@ func (daemon *Daemon) networkOptions(dconfig *config.Config, pg plugingetter.Plu } options = append(options, nwconfig.OptionLabels(dconfig.Labels)) - options = append(options, driverOptions(dconfig)...) + options = append(options, driverOptions(dconfig)) if len(dconfig.NetworkConfig.DefaultAddressPools.Value()) > 0 { options = append(options, nwconfig.OptionDefaultAddressPoolConfig(dconfig.NetworkConfig.DefaultAddressPools.Value())) diff --git a/daemon/daemon_unix.go b/daemon/daemon_unix.go index 44429d3692..5d2b15ab93 100644 --- a/daemon/daemon_unix.go +++ b/daemon/daemon_unix.go @@ -918,18 +918,16 @@ func (daemon *Daemon) initNetworkController(config *config.Config, activeSandbox return controller, nil } -func driverOptions(config *config.Config) []nwconfig.Option { - bridgeConfig := options.Generic{ - "EnableIPForwarding": config.BridgeConfig.EnableIPForward, - "EnableIPTables": config.BridgeConfig.EnableIPTables, - "EnableIP6Tables": config.BridgeConfig.EnableIP6Tables, - "EnableUserlandProxy": config.BridgeConfig.EnableUserlandProxy, - "UserlandProxyPath": config.BridgeConfig.UserlandProxyPath} - bridgeOption := options.Generic{netlabel.GenericData: bridgeConfig} - - dOptions := []nwconfig.Option{} - dOptions = append(dOptions, nwconfig.OptionDriverConfig("bridge", bridgeOption)) - return dOptions +func driverOptions(config *config.Config) nwconfig.Option { + return nwconfig.OptionDriverConfig("bridge", options.Generic{ + netlabel.GenericData: options.Generic{ + "EnableIPForwarding": config.BridgeConfig.EnableIPForward, + "EnableIPTables": config.BridgeConfig.EnableIPTables, + "EnableIP6Tables": config.BridgeConfig.EnableIP6Tables, + "EnableUserlandProxy": config.BridgeConfig.EnableUserlandProxy, + "UserlandProxyPath": config.BridgeConfig.UserlandProxyPath, + }, + }) } func initBridgeDriver(controller libnetwork.NetworkController, config *config.Config) error { diff --git a/daemon/daemon_windows.go b/daemon/daemon_windows.go index f333b737aa..071d9fc093 100644 --- a/daemon/daemon_windows.go +++ b/daemon/daemon_windows.go @@ -517,8 +517,8 @@ func (daemon *Daemon) conditionalUnmountOnCleanup(container *container.Container return daemon.Unmount(container) } -func driverOptions(config *config.Config) []nwconfig.Option { - return []nwconfig.Option{} +func driverOptions(_ *config.Config) nwconfig.Option { + return nil } func (daemon *Daemon) stats(c *container.Container) (*types.StatsJSON, error) {