From dd9e42732e268026b11fd1769ae0cda917809560 Mon Sep 17 00:00:00 2001 From: Malte Janduda Date: Wed, 24 Sep 2014 11:36:40 +0200 Subject: [PATCH 1/2] Adding IPv6 network support Docker-DCO-1.1-Signed-off-by: Malte Janduda (github: MalteJ) --- network/types.go | 8 +++++++- network/veth.go | 11 +++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/network/types.go b/network/types.go index 3b7a4e39..2b363f9e 100644 --- a/network/types.go +++ b/network/types.go @@ -17,12 +17,18 @@ type Network struct { // Prefix for the veth interfaces. VethPrefix string `json:"veth_prefix,omitempty"` - // Address contains the IP and mask to set on the network interface + // Address contains the IPv4 and mask to set on the network interface Address string `json:"address,omitempty"` + // Address contains the IPv6 and mask to set on the network interface + Address6 string `json:"address6,omitempty"` + // Gateway sets the gateway address that is used as the default for the interface Gateway string `json:"gateway,omitempty"` + // Gateway sets the ipv6 gateway address that is used as the default for the interface + Gateway6 string `json:"gateway6,omitempty"` + // Mtu sets the mtu value for the interface and will be mirrored on both the host and // container's interfaces if a pair is created, specifically in the case of type veth // Note: This does not apply to loopback interfaces. diff --git a/network/veth.go b/network/veth.go index fcafd85c..85d827b0 100644 --- a/network/veth.go +++ b/network/veth.go @@ -63,6 +63,12 @@ func (v *Veth) Initialize(config *Network, networkState *NetworkState) error { if err := SetInterfaceIp(defaultDevice, config.Address); err != nil { return fmt.Errorf("set %s ip %s", defaultDevice, err) } + if config.Address6 != "" { + if err := SetInterfaceIp(defaultDevice, config.Address6); err != nil { + return fmt.Errorf("set %s ipv6 %s", defaultDevice, err) + } + } + if err := SetMtu(defaultDevice, config.Mtu); err != nil { return fmt.Errorf("set %s mtu to %d %s", defaultDevice, config.Mtu, err) } @@ -74,6 +80,11 @@ func (v *Veth) Initialize(config *Network, networkState *NetworkState) error { return fmt.Errorf("set gateway to %s on device %s failed with %s", config.Gateway, defaultDevice, err) } } + if config.Gateway6 != "" { + if err := SetDefaultGateway(config.Gateway6, defaultDevice); err != nil { + return fmt.Errorf("set gateway for ipv6 to %s on device %s failed with %s", config.Gateway6, defaultDevice, err) + } + } return nil } From 4a14248dc8a2ca85e175d40ff13369dce6d85117 Mon Sep 17 00:00:00 2001 From: Malte Janduda Date: Wed, 24 Sep 2014 20:47:23 +0200 Subject: [PATCH 2/2] Address6 -> IPv6Address and Gateway6 -> IPv6Gateway Docker-DCO-1.1-Signed-off-by: Malte Janduda (github: MalteJ) --- network/types.go | 8 ++++---- network/veth.go | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/network/types.go b/network/types.go index 2b363f9e..ae098981 100644 --- a/network/types.go +++ b/network/types.go @@ -20,14 +20,14 @@ type Network struct { // Address contains the IPv4 and mask to set on the network interface Address string `json:"address,omitempty"` - // Address contains the IPv6 and mask to set on the network interface - Address6 string `json:"address6,omitempty"` + // IPv6Address contains the IPv6 and mask to set on the network interface + IPv6Address string `json:"ipv6_address,omitempty"` // Gateway sets the gateway address that is used as the default for the interface Gateway string `json:"gateway,omitempty"` - // Gateway sets the ipv6 gateway address that is used as the default for the interface - Gateway6 string `json:"gateway6,omitempty"` + // IPv6Gateway sets the ipv6 gateway address that is used as the default for the interface + IPv6Gateway string `json:"ipv6_gateway,omitempty"` // Mtu sets the mtu value for the interface and will be mirrored on both the host and // container's interfaces if a pair is created, specifically in the case of type veth diff --git a/network/veth.go b/network/veth.go index 85d827b0..c38fe3d2 100644 --- a/network/veth.go +++ b/network/veth.go @@ -63,8 +63,8 @@ func (v *Veth) Initialize(config *Network, networkState *NetworkState) error { if err := SetInterfaceIp(defaultDevice, config.Address); err != nil { return fmt.Errorf("set %s ip %s", defaultDevice, err) } - if config.Address6 != "" { - if err := SetInterfaceIp(defaultDevice, config.Address6); err != nil { + if config.IPv6Address != "" { + if err := SetInterfaceIp(defaultDevice, config.IPv6Address); err != nil { return fmt.Errorf("set %s ipv6 %s", defaultDevice, err) } } @@ -80,9 +80,9 @@ func (v *Veth) Initialize(config *Network, networkState *NetworkState) error { return fmt.Errorf("set gateway to %s on device %s failed with %s", config.Gateway, defaultDevice, err) } } - if config.Gateway6 != "" { - if err := SetDefaultGateway(config.Gateway6, defaultDevice); err != nil { - return fmt.Errorf("set gateway for ipv6 to %s on device %s failed with %s", config.Gateway6, defaultDevice, err) + if config.IPv6Gateway != "" { + if err := SetDefaultGateway(config.IPv6Gateway, defaultDevice); err != nil { + return fmt.Errorf("set gateway for ipv6 to %s on device %s failed with %s", config.IPv6Gateway, defaultDevice, err) } } return nil