Skip to content

Commit

Permalink
add IPAM if subnet is set, use enableIPv6 flag
Browse files Browse the repository at this point in the history
  • Loading branch information
karimra committed Nov 20, 2020
1 parent 46a1e3a commit bb320a2
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions clab/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,21 @@ const sysctlBase = "/proc/sys"
// CreateBridge creates a docker bridge
func (c *cLab) CreateBridge(ctx context.Context) (err error) {
log.Info("Creating docker bridge")
log.Debugf("Creating docker bridge: Name: %s, IPv4Subnet: '%s', IPv6Subnet: '%s", c.Config.Mgmt.Network, c.Config.Mgmt.IPv4Subnet, c.Config.Mgmt.IPv6Subnet)

ipamIPv4Config := network.IPAMConfig{
Subnet: c.Config.Mgmt.Ipv4Subnet,
enableIPv6 := false
var ipamConfig []network.IPAMConfig
if c.Config.Mgmt.IPv4Subnet != "" {
ipamConfig = append(ipamConfig, network.IPAMConfig{
Subnet: c.Config.Mgmt.IPv4Subnet,
})
}
ipamIPv6Config := network.IPAMConfig{
Subnet: c.Config.Mgmt.Ipv6Subnet,
if c.Config.Mgmt.IPv6Subnet != "" {
ipamConfig = append(ipamConfig, network.IPAMConfig{
Subnet: c.Config.Mgmt.IPv6Subnet,
})
enableIPv6 = true
}
var ipamConfig []network.IPAMConfig
ipamConfig = append(ipamConfig, ipamIPv4Config)
ipamConfig = append(ipamConfig, ipamIPv6Config)

ipam := &network.IPAM{
Driver: "default",
Expand All @@ -44,7 +49,7 @@ func (c *cLab) CreateBridge(ctx context.Context) (err error) {
CheckDuplicate: true,
Driver: "bridge",
//Scope: "local",
EnableIPv6: true,
EnableIPv6: enableIPv6,
IPAM: ipam,
Internal: false,
Attachable: false,
Expand Down

0 comments on commit bb320a2

Please sign in to comment.