當前位置: 首頁>>代碼示例>>Golang>>正文


Golang netns.None函數代碼示例

本文整理匯總了Golang中github.com/vishvananda/netns.None函數的典型用法代碼示例。如果您正苦於以下問題:Golang None函數的具體用法?Golang None怎麽用?Golang None使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了None函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: getIPVSFamily

func getIPVSFamily() (int, error) {
	sock, err := nl.GetNetlinkSocketAt(netns.None(), netns.None(), syscall.NETLINK_GENERIC)
	if err != nil {
		return 0, err
	}

	req := newGenlRequest(genlCtrlID, genlCtrlCmdGetFamily)
	req.AddData(nl.NewRtAttr(genlCtrlAttrFamilyName, nl.ZeroTerminated("IPVS")))

	msgs, err := execute(sock, req, 0)
	if err != nil {
		return 0, err
	}

	for _, m := range msgs {
		hdr := deserializeGenlMsg(m)
		attrs, err := nl.ParseRouteAttr(m[hdr.Len():])
		if err != nil {
			return 0, err
		}

		for _, attr := range attrs {
			switch int(attr.Attr.Type) {
			case genlCtrlAttrFamilyID:
				return int(native.Uint16(attr.Value[0:2])), nil
			}
		}
	}

	return 0, fmt.Errorf("no family id in the netlink response")
}
開發者ID:vdemeester,項目名稱:libnetwork,代碼行數:31,代碼來源:netlink.go

示例2: NextEndpoint

// NextEndpoint is an implementation of the loadbalancer interface for proxy.
func (s *Segment) NextEndpoint(service string, srcAddr net.Addr) (netns.NsHandle, string, error) {
	err := s.Trigger()
	if err != nil {
		return netns.None(), "", err
	}
	host := net.JoinHostPort(s.Tail.Hostname, strconv.Itoa(s.Tail.Port))
	return s.Tail.Ns, host, nil
}
開發者ID:vishvananda,項目名稱:wormhole,代碼行數:9,代碼來源:segment.go

示例3: NewProxier

// NewProxier returns a new Proxier given a LoadBalancer and an
// address on which to listen
func NewProxier(loadBalancer LoadBalancer, address string) *Proxier {
	return &Proxier{
		loadBalancer: loadBalancer,
		serviceMap:   make(map[string]*serviceInfo),
		address:      address,
		// NOTE(vish): this ns probably should be part of the Service struct
		ns: netns.None(),
	}
}
開發者ID:vishvananda,項目名稱:wormhole,代碼行數:11,代碼來源:proxier.go

示例4: New

// New provides a new ipvs handle in the namespace pointed to by the
// passed path. It will return a valid handle or an error in case an
// error occured while creating the handle.
func New(path string) (*Handle, error) {
	setup()

	n := netns.None()
	if path != "" {
		var err error
		n, err = netns.GetFromPath(path)
		if err != nil {
			return nil, err
		}
	}
	defer n.Close()

	sock, err := nl.GetNetlinkSocketAt(n, netns.None(), syscall.NETLINK_GENERIC)
	if err != nil {
		return nil, err
	}

	return &Handle{sock: sock}, nil
}
開發者ID:SUSE,項目名稱:docker.mirror,代碼行數:23,代碼來源:ipvs.go

示例5: NextEndpoint

// NextEndpoint returns a service endpoint.
// The service endpoint is chosen using the round-robin algorithm.
func (lb *LoadBalancerRR) NextEndpoint(service string, srcAddr net.Addr) (netns.NsHandle, string, error) {
	ns := netns.None()
	lb.lock.RLock()
	endpoints, exists := lb.endpointsMap[service]
	index := lb.rrIndex[service]
	lb.lock.RUnlock()
	if !exists {
		return ns, "", ErrMissingServiceEntry
	}
	if len(endpoints) == 0 {
		return ns, "", ErrMissingEndpoints
	}
	endpoint := endpoints[index]
	lb.lock.Lock()
	lb.rrIndex[service] = (index + 1) % len(endpoints)
	lb.lock.Unlock()
	return ns, endpoint, nil
}
開發者ID:vishvananda,項目名稱:wormhole,代碼行數:20,代碼來源:roundrobin.go

示例6: createGlobalInstance

			t.Fatal(err)
		}
		return
	}
	defer func() {
		if err := n.Delete(); err != nil {
			t.Fatal(err)
		}
	}()
}

var (
	once   sync.Once
	start  = make(chan struct{})
	done   = make(chan chan struct{}, numThreads-1)
	origns = netns.None()
	testns = netns.None()
	sboxes = make([]libnetwork.Sandbox, numThreads)
)

const (
	iterCnt    = 25
	numThreads = 3
	first      = 1
	last       = numThreads
	debug      = false
)

func createGlobalInstance(t *testing.T) {
	var err error
	defer close(start)
開發者ID:hurrygeek,項目名稱:libnetwork,代碼行數:31,代碼來源:libnetwork_test.go

示例7: LinkSubscribeAt

// LinkSubscribeAt works like LinkSubscribe plus it allows the caller
// to choose the network namespace in which to subscribe (ns).
func LinkSubscribeAt(ns netns.NsHandle, ch chan<- LinkUpdate, done <-chan struct{}) error {
	return linkSubscribe(ns, netns.None(), ch, done)
}
開發者ID:jonboulle,項目名稱:fleet,代碼行數:5,代碼來源:link_linux.go

示例8: LinkSubscribe

// LinkSubscribe takes a chan down which notifications will be sent
// when links change.  Close the 'done' chan to stop subscription.
func LinkSubscribe(ch chan<- LinkUpdate, done <-chan struct{}) error {
	return linkSubscribe(netns.None(), netns.None(), ch, done)
}
開發者ID:jonboulle,項目名稱:fleet,代碼行數:5,代碼來源:link_linux.go

示例9: NewHandleAt

// NewHandle returns a netlink handle on the network namespace
// specified by ns. If ns=netns.None(), current network namespace
// will be assumed
func NewHandleAt(ns netns.NsHandle, nlFamilies ...int) (*Handle, error) {
	return newHandle(ns, netns.None(), nlFamilies...)
}
開發者ID:harche,項目名稱:docker,代碼行數:6,代碼來源:handle_linux.go

示例10: RouteSubscribeAt

// RouteSubscribeAt works like RouteSubscribe plus it allows the caller
// to choose the network namespace in which to subscribe (ns).
func RouteSubscribeAt(ns netns.NsHandle, ch chan<- RouteUpdate, done <-chan struct{}) error {
	return routeSubscribeAt(ns, netns.None(), ch, done)
}
開發者ID:accense,項目名稱:netlink,代碼行數:5,代碼來源:route_linux.go

示例11: AddrSubscribeAt

// AddrSubscribeAt works like AddrSubscribe plus it allows the caller
// to choose the network namespace in which to subscribe (ns).
func AddrSubscribeAt(ns netns.NsHandle, ch chan<- AddrUpdate, done <-chan struct{}) error {
	return addrSubscribe(ns, netns.None(), ch, done)
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:5,代碼來源:addr_linux.go

示例12: AddrSubscribe

// AddrSubscribe takes a chan down which notifications will be sent
// when addresses change.  Close the 'done' chan to stop subscription.
func AddrSubscribe(ch chan<- AddrUpdate, done <-chan struct{}) error {
	return addrSubscribe(netns.None(), netns.None(), ch, done)
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:5,代碼來源:addr_linux.go

示例13: NewSegment

func NewSegment() *Segment {
	return &Segment{Head: ConnectionInfo{Ns: netns.None()}, Tail: ConnectionInfo{Ns: netns.None()}}
}
開發者ID:vishvananda,項目名稱:wormhole,代碼行數:3,代碼來源:segment.go

示例14: NewHandleAt

// NewHandle returns a netlink handle on the network namespace
// specified by ns. If ns=netns.None(), current network namespace
// will be assumed
func NewHandleAt(ns netns.NsHandle) (*Handle, error) {
	return newHandle(ns, netns.None())
}
開發者ID:rossj,項目名稱:docker,代碼行數:6,代碼來源:handle.go

示例15: NewHandle

// NewHandle returns a netlink handle on the current network namespace.
func NewHandle() (*Handle, error) {
	return newHandle(netns.None(), netns.None())
}
開發者ID:rossj,項目名稱:docker,代碼行數:4,代碼來源:handle.go


注:本文中的github.com/vishvananda/netns.None函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。