General cleanup of libcontainer
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
parent
ab6864d0c0
commit
84ba029e25
7 changed files with 111 additions and 166 deletions
|
@ -1,15 +1,10 @@
|
|||
package network
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/dotcloud/docker/pkg/netlink"
|
||||
"net"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrNoDefaultRoute = errors.New("no default network route found")
|
||||
)
|
||||
|
||||
func InterfaceUp(name string) error {
|
||||
iface, err := net.InterfaceByName(name)
|
||||
if err != nil {
|
||||
|
@ -46,14 +41,6 @@ func SetInterfaceInNamespacePid(name string, nsPid int) error {
|
|||
return netlink.NetworkSetNsPid(iface, nsPid)
|
||||
}
|
||||
|
||||
func SetInterfaceInNamespaceFd(name string, fd int) error {
|
||||
iface, err := net.InterfaceByName(name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return netlink.NetworkSetNsFd(iface, fd)
|
||||
}
|
||||
|
||||
func SetInterfaceMaster(name, master string) error {
|
||||
iface, err := net.InterfaceByName(name)
|
||||
if err != nil {
|
||||
|
@ -89,16 +76,3 @@ func SetMtu(name string, mtu int) error {
|
|||
}
|
||||
return netlink.NetworkSetMTU(iface, mtu)
|
||||
}
|
||||
|
||||
func GetDefaultMtu() (int, error) {
|
||||
routes, err := netlink.NetworkGetRoutes()
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
for _, r := range routes {
|
||||
if r.Default {
|
||||
return r.Iface.MTU, nil
|
||||
}
|
||||
}
|
||||
return -1, ErrNoDefaultRoute
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue