当前位置: 首页>>代码示例>>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;未经允许,请勿转载。