commit
605edd6394
|
@ -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"`
|
||||
|
||||
// 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"`
|
||||
|
||||
// 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
|
||||
// Note: This does not apply to loopback interfaces.
|
||||
|
|
|
@ -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.IPv6Address != "" {
|
||||
if err := SetInterfaceIp(defaultDevice, config.IPv6Address); 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.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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue