func SetInterfaceInNamespaceFd(name string, fd uintptr) error { iface, err := net.InterfaceByName(name) if err != nil { return err } return netlink.NetworkSetNsFd(iface, int(fd)) }
// SetPeerLinkNsFd sends peer link into container specified by path func (veth *VethPair) SetPeerLinkNsFd(nspath string) error { fd, err := syscall.Open(nspath, syscall.O_RDONLY, 0) if err != nil { return fmt.Errorf("Could not attach to Network namespace: %s", err) } return netlink.NetworkSetNsFd(veth.peerIfc, fd) }
// SetLinkNsFd sets the link's Linux namespace to the one specified by filesystem path. func (l *Link) SetLinkNsFd(nspath string) error { fd, err := syscall.Open(nspath, syscall.O_RDONLY, 0) if err != nil { return fmt.Errorf("Could not attach to Network namespace: %s", err) } return netlink.NetworkSetNsFd(l.NetInterface(), fd) }
func (Link) SetNs(intf *net.Interface, ns int) error { netlinkMu.Lock() defer netlinkMu.Unlock() return errF(netlink.NetworkSetNsFd(intf, ns)) }