@@ -67,8 +67,13 @@ type NetworkManager struct {
6767// NewNetworkManager creates a brand new network manager.
6868func NewNetworkManager (cfg * config.Config , store * meta.Store , ctrMgr ContainerMgr ) (* NetworkManager , error ) {
6969 // Create a new controller instance
70- cfg .NetworkConfg .MetaPath = path .Dir (store .BaseDir )
71- cfg .NetworkConfg .ExecRoot = network .DefaultExecRoot
70+ if cfg .NetworkConfig .MetaPath == "" {
71+ cfg .NetworkConfig .MetaPath = path .Dir (store .BaseDir )
72+ }
73+
74+ if cfg .NetworkConfig .ExecRoot == "" {
75+ cfg .NetworkConfig .ExecRoot = network .DefaultExecRoot
76+ }
7277
7378 initNetworkLog (cfg )
7479
@@ -81,17 +86,17 @@ func NewNetworkManager(cfg *config.Config, store *meta.Store, ctrMgr ContainerMg
8186 logrus .Errorf ("failed to new network manager, can not get container list" )
8287 return nil , errors .Wrap (err , "failed to get container list" )
8388 }
84- cfg .NetworkConfg .ActiveSandboxes = make (map [string ]interface {})
89+ cfg .NetworkConfig .ActiveSandboxes = make (map [string ]interface {})
8590 for _ , c := range ctrs {
8691 endpoint := BuildContainerEndpoint (c )
87- sbOptions , err := buildSandboxOptions (cfg .NetworkConfg , endpoint )
92+ sbOptions , err := buildSandboxOptions (cfg .NetworkConfig , endpoint )
8893 if err != nil {
8994 return nil , errors .Wrap (err , "failed to build sandbox options" )
9095 }
91- cfg .NetworkConfg .ActiveSandboxes [c .NetworkSettings .SandboxID ] = sbOptions
96+ cfg .NetworkConfig .ActiveSandboxes [c .NetworkSettings .SandboxID ] = sbOptions
9297 }
9398
94- ctlOptions , err := controllerOptions (cfg .NetworkConfg )
99+ ctlOptions , err := controllerOptions (cfg .NetworkConfig )
95100 if err != nil {
96101 return nil , errors .Wrap (err , "failed to build network options" )
97102 }
@@ -104,7 +109,7 @@ func NewNetworkManager(cfg *config.Config, store *meta.Store, ctrMgr ContainerMg
104109 return & NetworkManager {
105110 store : store ,
106111 controller : controller ,
107- config : cfg .NetworkConfg ,
112+ config : cfg .NetworkConfig ,
108113 }, nil
109114}
110115
@@ -449,16 +454,16 @@ func controllerOptions(cfg network.Config) ([]nwconfig.Option, error) {
449454 options = append (options , nwconfig .OptionDefaultNetwork ("bridge" ))
450455
451456 // set bridge options
452- options = append (options , bridgeDriverOptions ())
457+ options = append (options , bridgeDriverOptions (cfg . BridgeConfig ))
453458
454459 return options , nil
455460}
456461
457- func bridgeDriverOptions () nwconfig.Option {
462+ func bridgeDriverOptions (cfg network. BridgeConfig ) nwconfig.Option {
458463 bridgeConfig := options.Generic {
459- "EnableIPForwarding" : true ,
460- "EnableIPTables" : true ,
461- "EnableUserlandProxy" : true }
464+ "EnableIPForwarding" : cfg . IPForward ,
465+ "EnableIPTables" : cfg . IPTables ,
466+ "EnableUserlandProxy" : cfg . UserlandProxy }
462467 bridgeOption := options.Generic {netlabel .GenericData : bridgeConfig }
463468
464469 return nwconfig .OptionDriverConfig ("bridge" , bridgeOption )
0 commit comments