Skip to content

Commit

Permalink
Set EnableIPv4 for predefined networks
Browse files Browse the repository at this point in the history
Signed-off-by: Rob Murray <[email protected]>
  • Loading branch information
robmry committed Jul 31, 2024
1 parent 903daa4 commit 1f542d5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions daemon/cluster/executor/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,13 +626,15 @@ func (c *containerConfig) networkCreateRequest(name string) (clustertypes.Networ
return clustertypes.NetworkCreateRequest{}, errors.New("container: unknown network referenced")
}

ipv4Enabled := true
ipv6Enabled := na.Network.Spec.Ipv6Enabled
options := network.CreateOptions{
// ID: na.Network.ID,
Labels: na.Network.Spec.Annotations.Labels,
Internal: na.Network.Spec.Internal,
Attachable: na.Network.Spec.Attachable,
Ingress: convert.IsIngressNetwork(na.Network),
EnableIPv4: &ipv4Enabled,
EnableIPv6: &ipv6Enabled,
Scope: scope.Swarm,
}
Expand Down
1 change: 1 addition & 0 deletions daemon/daemon_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,7 @@ func initBridgeDriver(controller *libnetwork.Controller, cfg config.BridgeConfig
}
// Initialize default network on "bridge" with the same name
_, err = controller.NewNetwork("bridge", network.NetworkBridge, "",
libnetwork.NetworkOptionEnableIPv4(true),
libnetwork.NetworkOptionEnableIPv6(cfg.EnableIPv6),
libnetwork.NetworkOptionDriverOpts(netOption),
libnetwork.NetworkOptionIpam("default", "", v4Conf, v6Conf, nil),
Expand Down
2 changes: 2 additions & 0 deletions daemon/daemon_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ func (daemon *Daemon) initNetworkController(daemonCfg *config.Config, activeSand
_, err := daemon.netController.NewNetwork(strings.ToLower(v.Type), name, nid,
libnetwork.NetworkOptionGeneric(options.Generic{
netlabel.GenericData: netOption,
netlabel.EnableIPv4: true,
}),
libnetwork.NetworkOptionIpam("default", "", v4Conf, v6Conf, nil),
)
Expand Down Expand Up @@ -430,6 +431,7 @@ func initBridgeDriver(controller *libnetwork.Controller, config config.BridgeCon
_, err := controller.NewNetwork(network.DefaultNetwork, network.DefaultNetwork, "",
libnetwork.NetworkOptionGeneric(options.Generic{
netlabel.GenericData: netOption,
netlabel.EnableIPv4: true,
}),
ipamOption,
)
Expand Down
1 change: 1 addition & 0 deletions libnetwork/default_gateway_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func (c *Controller) createGWNetwork() (*Network, error) {
bridge.EnableICC: strconv.FormatBool(false),
bridge.EnableIPMasquerade: strconv.FormatBool(true),
}),
NetworkOptionEnableIPv4(true),
NetworkOptionEnableIPv6(false),
)
if err != nil {
Expand Down

0 comments on commit 1f542d5

Please sign in to comment.