Add dynamic veth name
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
parent
8430fbf11e
commit
ab6864d0c0
4 changed files with 48 additions and 73 deletions
|
@ -1,41 +0,0 @@
|
|||
package network
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/dotcloud/docker/pkg/libcontainer"
|
||||
)
|
||||
|
||||
// SetupVeth sets up an existing network namespace with the specified
|
||||
// network configuration.
|
||||
func SetupVeth(config *libcontainer.Network, tempVethName string) error {
|
||||
if err := InterfaceDown(tempVethName); err != nil {
|
||||
return fmt.Errorf("interface down %s %s", tempVethName, err)
|
||||
}
|
||||
if err := ChangeInterfaceName(tempVethName, "eth0"); err != nil {
|
||||
return fmt.Errorf("change %s to eth0 %s", tempVethName, err)
|
||||
}
|
||||
if err := SetInterfaceIp("eth0", config.IP); err != nil {
|
||||
return fmt.Errorf("set eth0 ip %s", err)
|
||||
}
|
||||
|
||||
if err := SetMtu("eth0", config.Mtu); err != nil {
|
||||
return fmt.Errorf("set eth0 mtu to %d %s", config.Mtu, err)
|
||||
}
|
||||
if err := InterfaceUp("eth0"); err != nil {
|
||||
return fmt.Errorf("eth0 up %s", err)
|
||||
}
|
||||
|
||||
if err := SetMtu("lo", config.Mtu); err != nil {
|
||||
return fmt.Errorf("set lo mtu to %d %s", config.Mtu, err)
|
||||
}
|
||||
if err := InterfaceUp("lo"); err != nil {
|
||||
return fmt.Errorf("lo up %s", err)
|
||||
}
|
||||
|
||||
if config.Gateway != "" {
|
||||
if err := SetDefaultGateway(config.Gateway); err != nil {
|
||||
return fmt.Errorf("set gateway to %s %s", config.Gateway, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue