Browse code

Set EnableIPv4 for predefined networks

Signed-off-by: Rob Murray <rob.murray@docker.com>

Rob Murray authored on 2024/07/31 04:17:54
Showing 4 changed files
... ...
@@ -626,6 +626,7 @@ func (c *containerConfig) networkCreateRequest(name string) (clustertypes.Networ
626 626
 		return clustertypes.NetworkCreateRequest{}, errors.New("container: unknown network referenced")
627 627
 	}
628 628
 
629
+	ipv4Enabled := true
629 630
 	ipv6Enabled := na.Network.Spec.Ipv6Enabled
630 631
 	options := network.CreateOptions{
631 632
 		// ID:     na.Network.ID,
... ...
@@ -633,6 +634,7 @@ func (c *containerConfig) networkCreateRequest(name string) (clustertypes.Networ
633 633
 		Internal:   na.Network.Spec.Internal,
634 634
 		Attachable: na.Network.Spec.Attachable,
635 635
 		Ingress:    convert.IsIngressNetwork(na.Network),
636
+		EnableIPv4: &ipv4Enabled,
636 637
 		EnableIPv6: &ipv6Enabled,
637 638
 		Scope:      scope.Swarm,
638 639
 	}
... ...
@@ -1051,6 +1051,7 @@ func initBridgeDriver(controller *libnetwork.Controller, cfg config.BridgeConfig
1051 1051
 	}
1052 1052
 	// Initialize default network on "bridge" with the same name
1053 1053
 	_, err = controller.NewNetwork("bridge", network.NetworkBridge, "",
1054
+		libnetwork.NetworkOptionEnableIPv4(true),
1054 1055
 		libnetwork.NetworkOptionEnableIPv6(cfg.EnableIPv6),
1055 1056
 		libnetwork.NetworkOptionDriverOpts(netOption),
1056 1057
 		libnetwork.NetworkOptionIpam("default", "", v4Conf, v6Conf, nil),
... ...
@@ -386,6 +386,7 @@ func (daemon *Daemon) initNetworkController(daemonCfg *config.Config, activeSand
386 386
 		_, err := daemon.netController.NewNetwork(strings.ToLower(v.Type), name, nid,
387 387
 			libnetwork.NetworkOptionGeneric(options.Generic{
388 388
 				netlabel.GenericData: netOption,
389
+				netlabel.EnableIPv4:  true,
389 390
 			}),
390 391
 			libnetwork.NetworkOptionIpam("default", "", v4Conf, v6Conf, nil),
391 392
 		)
... ...
@@ -430,6 +431,7 @@ func initBridgeDriver(controller *libnetwork.Controller, config config.BridgeCon
430 430
 	_, err := controller.NewNetwork(network.DefaultNetwork, network.DefaultNetwork, "",
431 431
 		libnetwork.NetworkOptionGeneric(options.Generic{
432 432
 			netlabel.GenericData: netOption,
433
+			netlabel.EnableIPv4:  true,
433 434
 		}),
434 435
 		ipamOption,
435 436
 	)
... ...
@@ -20,6 +20,7 @@ func (c *Controller) createGWNetwork() (*Network, error) {
20 20
 			bridge.EnableICC:          strconv.FormatBool(false),
21 21
 			bridge.EnableIPMasquerade: strconv.FormatBool(true),
22 22
 		}),
23
+		NetworkOptionEnableIPv4(true),
23 24
 		NetworkOptionEnableIPv6(false),
24 25
 	)
25 26
 	if err != nil {