repo
stringlengths
5
67
sha
stringlengths
40
40
path
stringlengths
4
234
url
stringlengths
85
339
language
stringclasses
6 values
split
stringclasses
3 values
doc
stringlengths
3
51.2k
sign
stringlengths
5
8.01k
problem
stringlengths
13
51.2k
output
stringlengths
0
3.87M
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
ipam/structures.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/ipam/structures.go#L211-L224
go
train
// CopyTo deep copies the pool data to the destination pooldata
func (p *PoolData) CopyTo(dstP *PoolData) error
// CopyTo deep copies the pool data to the destination pooldata func (p *PoolData) CopyTo(dstP *PoolData) error
{ dstP.ParentKey = p.ParentKey dstP.Pool = types.GetIPNetCopy(p.Pool) if p.Range != nil { dstP.Range = &AddressRange{} dstP.Range.Sub = types.GetIPNetCopy(p.Range.Sub) dstP.Range.Start = p.Range.Start dstP.Range.End = p.Range.End } dstP.RefCount = p.RefCount return nil }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
ipam/structures.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/ipam/structures.go#L261-L304
go
train
// updatePoolDBOnAdd returns a closure which will add the subnet k to the address space when executed.
func (aSpace *addrSpace) updatePoolDBOnAdd(k SubnetKey, nw *net.IPNet, ipr *AddressRange, pdf bool) (func() error, error)
// updatePoolDBOnAdd returns a closure which will add the subnet k to the address space when executed. func (aSpace *addrSpace) updatePoolDBOnAdd(k SubnetKey, nw *net.IPNet, ipr *AddressRange, pdf bool) (func() error, error)
{ aSpace.Lock() defer aSpace.Unlock() // Check if already allocated if _, ok := aSpace.subnets[k]; ok { if pdf { return nil, types.InternalMaskableErrorf("predefined pool %s is already reserved", nw) } // This means the same pool is already allocated. updatePoolDBOnAdd is called when there // is reques...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
ipam/structures.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/ipam/structures.go#L348-L357
go
train
// Checks whether the passed subnet is a superset or subset of any of the subset in this config db
func (aSpace *addrSpace) contains(space string, nw *net.IPNet) bool
// Checks whether the passed subnet is a superset or subset of any of the subset in this config db func (aSpace *addrSpace) contains(space string, nw *net.IPNet) bool
{ for k, v := range aSpace.subnets { if space == k.AddressSpace && k.ChildSubnet == "" { if nw.Contains(v.Pool.IP) || v.Pool.Contains(nw.IP) { return true } } } return false }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
cmd/proxy/stub_proxy.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/cmd/proxy/stub_proxy.go#L26-L31
go
train
// NewStubProxy creates a new StubProxy
func NewStubProxy(frontendAddr, backendAddr net.Addr) (Proxy, error)
// NewStubProxy creates a new StubProxy func NewStubProxy(frontendAddr, backendAddr net.Addr) (Proxy, error)
{ return &StubProxy{ frontendAddr: frontendAddr, backendAddr: backendAddr, }, nil }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
netutils/utils_linux.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/netutils/utils_linux.go#L25-L39
go
train
// CheckRouteOverlaps checks whether the passed network overlaps with any existing routes
func CheckRouteOverlaps(toCheck *net.IPNet) error
// CheckRouteOverlaps checks whether the passed network overlaps with any existing routes func CheckRouteOverlaps(toCheck *net.IPNet) error
{ if networkGetRoutesFct == nil { networkGetRoutesFct = ns.NlHandle().RouteList } networks, err := networkGetRoutesFct(nil, netlink.FAMILY_V4) if err != nil { return err } for _, network := range networks { if network.Dst != nil && NetworkOverlaps(toCheck, network.Dst) { return ErrNetworkOverlaps } }...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
netutils/utils_linux.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/netutils/utils_linux.go#L44-L63
go
train
// GenerateIfaceName returns an interface name using the passed in // prefix and the length of random bytes. The api ensures that the // there are is no interface which exists with that name.
func GenerateIfaceName(nlh *netlink.Handle, prefix string, len int) (string, error)
// GenerateIfaceName returns an interface name using the passed in // prefix and the length of random bytes. The api ensures that the // there are is no interface which exists with that name. func GenerateIfaceName(nlh *netlink.Handle, prefix string, len int) (string, error)
{ linkByName := netlink.LinkByName if nlh != nil { linkByName = nlh.LinkByName } for i := 0; i < 3; i++ { name, err := GenerateRandomName(prefix, len) if err != nil { continue } _, err = linkByName(name) if err != nil { if strings.Contains(err.Error(), "not found") { return name, nil } ...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
netutils/utils_linux.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/netutils/utils_linux.go#L71-L108
go
train
// ElectInterfaceAddresses looks for an interface on the OS with the // specified name and returns returns all its IPv4 and IPv6 addresses in CIDR notation. // If a failure in retrieving the addresses or no IPv4 address is found, an error is returned. // If the interface does not exist, it chooses from a predefined // ...
func ElectInterfaceAddresses(name string) ([]*net.IPNet, []*net.IPNet, error)
// ElectInterfaceAddresses looks for an interface on the OS with the // specified name and returns returns all its IPv4 and IPv6 addresses in CIDR notation. // If a failure in retrieving the addresses or no IPv4 address is found, an error is returned. // If the interface does not exist, it chooses from a predefined // ...
{ var ( v4Nets []*net.IPNet v6Nets []*net.IPNet ) defer osl.InitOSContext()() link, _ := ns.NlHandle().LinkByName(name) if link != nil { v4addr, err := ns.NlHandle().AddrList(link, netlink.FAMILY_V4) if err != nil { return nil, nil, err } v6addr, err := ns.NlHandle().AddrList(link, netlink.FAMILY...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
netutils/utils_linux.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/netutils/utils_linux.go#L112-L128
go
train
// FindAvailableNetwork returns a network from the passed list which does not // overlap with existing interfaces in the system
func FindAvailableNetwork(list []*net.IPNet) (*net.IPNet, error)
// FindAvailableNetwork returns a network from the passed list which does not // overlap with existing interfaces in the system func FindAvailableNetwork(list []*net.IPNet) (*net.IPNet, error)
{ // We don't check for an error here, because we don't really care if we // can't read /etc/resolv.conf. So instead we skip the append if resolvConf // is nil. It either doesn't exist, or we can't read it for some reason. var nameservers []string if rc, err := resolvconf.Get(); err == nil { nameservers = resol...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
osl/namespace_linux.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/osl/namespace_linux.go#L138-L154
go
train
// GC triggers garbage collection of namespace path right away // and waits for it.
func GC()
// GC triggers garbage collection of namespace path right away // and waits for it. func GC()
{ gpmLock.Lock() if len(garbagePathMap) == 0 { // No need for GC if map is empty gpmLock.Unlock() return } gpmLock.Unlock() // if content exists in the garbage paths // we can trigger GC to run, providing a // channel to be notified on completion waitGC := make(chan struct{}) gpmChan <- waitGC // wait...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
osl/namespace_linux.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/osl/namespace_linux.go#L158-L198
go
train
// GenerateKey generates a sandbox key based on the passed // container id.
func GenerateKey(containerID string) string
// GenerateKey generates a sandbox key based on the passed // container id. func GenerateKey(containerID string) string
{ maxLen := 12 // Read sandbox key from host for overlay if strings.HasPrefix(containerID, "-") { var ( index int indexStr string tmpkey string ) dir, err := ioutil.ReadDir(basePath()) if err != nil { return "" } for _, v := range dir { id := v.Name() if strings.HasSuffix(id, con...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
osl/namespace_linux.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/osl/namespace_linux.go#L202-L246
go
train
// NewSandbox provides a new sandbox instance created in an os specific way // provided a key which uniquely identifies the sandbox
func NewSandbox(key string, osCreate, isRestore bool) (Sandbox, error)
// NewSandbox provides a new sandbox instance created in an os specific way // provided a key which uniquely identifies the sandbox func NewSandbox(key string, osCreate, isRestore bool) (Sandbox, error)
{ if !isRestore { err := createNetworkNamespace(key, osCreate) if err != nil { return nil, err } } else { once.Do(createBasePath) } n := &networkNamespace{path: key, isDefault: !osCreate, nextIfIndex: make(map[string]int)} sboxNs, err := netns.GetFromPath(n.path) if err != nil { return nil, fmt.Er...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
osl/namespace_linux.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/osl/namespace_linux.go#L261-L299
go
train
// GetSandboxForExternalKey returns sandbox object for the supplied path
func GetSandboxForExternalKey(basePath string, key string) (Sandbox, error)
// GetSandboxForExternalKey returns sandbox object for the supplied path func GetSandboxForExternalKey(basePath string, key string) (Sandbox, error)
{ if err := createNamespaceFile(key); err != nil { return nil, err } if err := mountNetworkNamespace(basePath, key); err != nil { return nil, err } n := &networkNamespace{path: key, nextIfIndex: make(map[string]int)} sboxNs, err := netns.GetFromPath(n.path) if err != nil { return nil, fmt.Errorf("failed...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
osl/namespace_linux.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/osl/namespace_linux.go#L425-L431
go
train
// InitOSContext initializes OS context while configuring network resources
func InitOSContext() func()
// InitOSContext initializes OS context while configuring network resources func InitOSContext() func()
{ runtime.LockOSThread() if err := ns.SetNamespace(); err != nil { logrus.Error(err) } return runtime.UnlockOSThread }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
osl/namespace_linux.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/osl/namespace_linux.go#L488-L587
go
train
// Restore restore the network namespace
func (n *networkNamespace) Restore(ifsopt map[string][]IfaceOption, routes []*types.StaticRoute, gw net.IP, gw6 net.IP) error
// Restore restore the network namespace func (n *networkNamespace) Restore(ifsopt map[string][]IfaceOption, routes []*types.StaticRoute, gw net.IP, gw6 net.IP) error
{ // restore interfaces for name, opts := range ifsopt { if !strings.Contains(name, "+") { return fmt.Errorf("wrong iface name in restore osl sandbox interface: %s", name) } seps := strings.Split(name, "+") srcName := seps[0] dstPrefix := seps[1] i := &nwIface{srcName: srcName, dstName: dstPrefix, ns:...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
osl/namespace_linux.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/osl/namespace_linux.go#L590-L615
go
train
// Checks whether IPv6 needs to be enabled/disabled on the loopback interface
func (n *networkNamespace) checkLoV6()
// Checks whether IPv6 needs to be enabled/disabled on the loopback interface func (n *networkNamespace) checkLoV6()
{ var ( enable = false action = "disable" ) n.Lock() for _, iface := range n.iFaces { if iface.AddressIPv6() != nil { enable = true action = "enable" break } } n.Unlock() if n.loV6Enabled == enable { return } if err := setIPv6(n.path, "lo", enable); err != nil { logrus.Warnf("Failed to...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
osl/namespace_linux.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/osl/namespace_linux.go#L680-L687
go
train
// ApplyOSTweaks applies linux configs on the sandbox
func (n *networkNamespace) ApplyOSTweaks(types []SandboxType)
// ApplyOSTweaks applies linux configs on the sandbox func (n *networkNamespace) ApplyOSTweaks(types []SandboxType)
{ for _, t := range types { switch t { case SandboxTypeLoadBalancer: kernel.ApplyOSTweaks(loadBalancerConfig) } } }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
networkdb/watch.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/networkdb/watch.go#L46-L90
go
train
// Watch creates a watcher with filters for a particular table or // network or key or any combination of the tuple. If any of the // filter is an empty string it acts as a wildcard for that // field. Watch returns a channel of events, where the events will be // sent.
func (nDB *NetworkDB) Watch(tname, nid, key string) (*events.Channel, func())
// Watch creates a watcher with filters for a particular table or // network or key or any combination of the tuple. If any of the // filter is an empty string it acts as a wildcard for that // field. Watch returns a channel of events, where the events will be // sent. func (nDB *NetworkDB) Watch(tname, nid, key string...
{ var matcher events.Matcher if tname != "" || nid != "" || key != "" { matcher = events.MatcherFunc(func(ev events.Event) bool { var evt event switch ev := ev.(type) { case CreateEvent: evt = event(ev) case UpdateEvent: evt = event(ev) case DeleteEvent: evt = event(ev) } if tnam...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
drivers/overlay/encryption.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/overlay/encryption.go#L448-L509
go
train
// updateKeys allows to add a new key and/or change the primary key and/or prune an existing key // The primary key is the key used in transmission and will go in first position in the list.
func (d *driver) updateKeys(newKey, primary, pruneKey *key) error
// updateKeys allows to add a new key and/or change the primary key and/or prune an existing key // The primary key is the key used in transmission and will go in first position in the list. func (d *driver) updateKeys(newKey, primary, pruneKey *key) error
{ logrus.Debugf("Updating Keys. New: %v, Primary: %v, Pruned: %v", newKey, primary, pruneKey) logrus.Debugf("Current: %v", d.keys) var ( newIdx = -1 priIdx = -1 delIdx = -1 lIP = net.ParseIP(d.bindAddress) aIP = net.ParseIP(d.advertiseAddress) ) d.Lock() defer d.Unlock() // add new if newKe...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
drivers/overlay/encryption.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/overlay/encryption.go#L518-L595
go
train
/******************************************************** * Steady state: rSA0, rSA1, rSA2, fSA1, fSP1 * Rotation --> -rSA0, +rSA3, +fSA2, +fSP2/-fSP1, -fSA1 * Steady state: rSA1, rSA2, rSA3, fSA2, fSP2 *********************************************************/ // Spis and keys are sorted in such away the one in po...
func updateNodeKey(lIP, aIP, rIP net.IP, idxs []*spi, curKeys []*key, newIdx, priIdx, delIdx int) []*spi
/******************************************************** * Steady state: rSA0, rSA1, rSA2, fSA1, fSP1 * Rotation --> -rSA0, +rSA3, +fSA2, +fSP2/-fSP1, -fSA1 * Steady state: rSA1, rSA2, rSA3, fSA2, fSP2 *********************************************************/ // Spis and keys are sorted in such away the one in po...
{ logrus.Debugf("Updating keys for node: %s (%d,%d,%d)", rIP, newIdx, priIdx, delIdx) spis := idxs logrus.Debugf("Current: %v", spis) // add new if newIdx != -1 { spis = append(spis, &spi{ forward: buildSPI(aIP, rIP, curKeys[newIdx].tag), reverse: buildSPI(rIP, aIP, curKeys[newIdx].tag), }) } if de...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
cmd/proxy/tcp_proxy.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/cmd/proxy/tcp_proxy.go#L19-L31
go
train
// NewTCPProxy creates a new TCPProxy.
func NewTCPProxy(frontendAddr, backendAddr *net.TCPAddr) (*TCPProxy, error)
// NewTCPProxy creates a new TCPProxy. func NewTCPProxy(frontendAddr, backendAddr *net.TCPAddr) (*TCPProxy, error)
{ listener, err := net.ListenTCP("tcp", frontendAddr) if err != nil { return nil, err } // If the port in frontendAddr was 0 then ListenTCP will have a picked // a port to listen on, hence the call to Addr to get that actual port: return &TCPProxy{ listener: listener, frontendAddr: listener.Addr().(*ne...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
cmd/proxy/tcp_proxy.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/cmd/proxy/tcp_proxy.go#L69-L80
go
train
// Run starts forwarding the traffic using TCP.
func (proxy *TCPProxy) Run()
// Run starts forwarding the traffic using TCP. func (proxy *TCPProxy) Run()
{ quit := make(chan bool) defer close(quit) for { client, err := proxy.listener.Accept() if err != nil { log.Printf("Stopping proxy on tcp/%v for tcp/%v (%s)", proxy.frontendAddr, proxy.backendAddr, err) return } go proxy.clientLoop(client.(*net.TCPConn), quit) } }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
bitseq/store.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/store.go#L12-L16
go
train
// Key provides the Key to be used in KV Store
func (h *Handle) Key() []string
// Key provides the Key to be used in KV Store func (h *Handle) Key() []string
{ h.Lock() defer h.Unlock() return []string{h.app, h.id} }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
bitseq/store.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/store.go#L19-L23
go
train
// KeyPrefix returns the immediate parent key that can be used for tree walk
func (h *Handle) KeyPrefix() []string
// KeyPrefix returns the immediate parent key that can be used for tree walk func (h *Handle) KeyPrefix() []string
{ h.Lock() defer h.Unlock() return []string{h.app} }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
bitseq/store.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/store.go#L26-L32
go
train
// Value marshals the data to be stored in the KV store
func (h *Handle) Value() []byte
// Value marshals the data to be stored in the KV store func (h *Handle) Value() []byte
{ b, err := json.Marshal(h) if err != nil { return nil } return b }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
bitseq/store.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/store.go#L35-L37
go
train
// SetValue unmarshals the data from the KV store
func (h *Handle) SetValue(value []byte) error
// SetValue unmarshals the data from the KV store func (h *Handle) SetValue(value []byte) error
{ return json.Unmarshal(value, h) }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
bitseq/store.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/store.go#L40-L44
go
train
// Index returns the latest DB Index as seen by this object
func (h *Handle) Index() uint64
// Index returns the latest DB Index as seen by this object func (h *Handle) Index() uint64
{ h.Lock() defer h.Unlock() return h.dbIndex }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
bitseq/store.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/store.go#L47-L52
go
train
// SetIndex method allows the datastore to store the latest DB Index into this object
func (h *Handle) SetIndex(index uint64)
// SetIndex method allows the datastore to store the latest DB Index into this object func (h *Handle) SetIndex(index uint64)
{ h.Lock() h.dbIndex = index h.dbExists = true h.Unlock() }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
bitseq/store.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/store.go#L55-L59
go
train
// Exists method is true if this object has been stored in the DB.
func (h *Handle) Exists() bool
// Exists method is true if this object has been stored in the DB. func (h *Handle) Exists() bool
{ h.Lock() defer h.Unlock() return h.dbExists }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
bitseq/store.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/store.go#L62-L70
go
train
// New method returns a handle based on the receiver handle
func (h *Handle) New() datastore.KVObject
// New method returns a handle based on the receiver handle func (h *Handle) New() datastore.KVObject
{ h.Lock() defer h.Unlock() return &Handle{ app: h.app, store: h.store, } }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
bitseq/store.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/store.go#L73-L94
go
train
// CopyTo deep copies the handle into the passed destination object
func (h *Handle) CopyTo(o datastore.KVObject) error
// CopyTo deep copies the handle into the passed destination object func (h *Handle) CopyTo(o datastore.KVObject) error
{ h.Lock() defer h.Unlock() dstH := o.(*Handle) if h == dstH { return nil } dstH.Lock() dstH.bits = h.bits dstH.unselected = h.unselected dstH.head = h.head.getCopy() dstH.app = h.app dstH.id = h.id dstH.dbIndex = h.dbIndex dstH.dbExists = h.dbExists dstH.store = h.store dstH.curr = h.curr dstH.Unlo...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
bitseq/store.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/store.go#L102-L107
go
train
// DataScope method returns the storage scope of the datastore
func (h *Handle) DataScope() string
// DataScope method returns the storage scope of the datastore func (h *Handle) DataScope() string
{ h.Lock() defer h.Unlock() return h.store.Scope() }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
drivers/ipvlan/ipvlan_setup.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/ipvlan/ipvlan_setup.go#L20-L49
go
train
// createIPVlan Create the ipvlan slave specifying the source name
func createIPVlan(containerIfName, parent, ipvlanMode string) (string, error)
// createIPVlan Create the ipvlan slave specifying the source name func createIPVlan(containerIfName, parent, ipvlanMode string) (string, error)
{ // Set the ipvlan mode. Default is bridge mode mode, err := setIPVlanMode(ipvlanMode) if err != nil { return "", fmt.Errorf("Unsupported %s ipvlan mode: %v", ipvlanMode, err) } // verify the Docker host interface acting as the macvlan parent iface exists if !parentExists(parent) { return "", fmt.Errorf("th...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
drivers/ipvlan/ipvlan_setup.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/ipvlan/ipvlan_setup.go#L52-L61
go
train
// setIPVlanMode setter for one of the two ipvlan port types
func setIPVlanMode(mode string) (netlink.IPVlanMode, error)
// setIPVlanMode setter for one of the two ipvlan port types func setIPVlanMode(mode string) (netlink.IPVlanMode, error)
{ switch mode { case modeL2: return netlink.IPVLAN_MODE_L2, nil case modeL3: return netlink.IPVLAN_MODE_L3, nil default: return 0, fmt.Errorf("Unknown ipvlan mode: %s", mode) } }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
drivers/ipvlan/ipvlan_setup.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/ipvlan/ipvlan_setup.go#L64-L71
go
train
// parentExists check if the specified interface exists in the default namespace
func parentExists(ifaceStr string) bool
// parentExists check if the specified interface exists in the default namespace func parentExists(ifaceStr string) bool
{ _, err := ns.NlHandle().LinkByName(ifaceStr) if err != nil { return false } return true }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
drivers/ipvlan/ipvlan_setup.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/ipvlan/ipvlan_setup.go#L74-L109
go
train
// createVlanLink parses sub-interfaces and vlan id for creation
func createVlanLink(parentName string) error
// createVlanLink parses sub-interfaces and vlan id for creation func createVlanLink(parentName string) error
{ if strings.Contains(parentName, ".") { parent, vidInt, err := parseVlan(parentName) if err != nil { return err } // VLAN identifier or VID is a 12-bit field specifying the VLAN to which the frame belongs if vidInt > 4094 || vidInt < 1 { return fmt.Errorf("vlan id must be between 1-4094, received: %d...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
drivers/ipvlan/ipvlan_setup.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/ipvlan/ipvlan_setup.go#L139-L157
go
train
// parseVlan parses and verifies a slave interface name: -o parent=eth0.10
func parseVlan(linkName string) (string, int, error)
// parseVlan parses and verifies a slave interface name: -o parent=eth0.10 func parseVlan(linkName string) (string, int, error)
{ // parse -o parent=eth0.10 splitName := strings.Split(linkName, ".") if len(splitName) != 2 { return "", 0, fmt.Errorf("required interface name format is: name.vlan_id, ex. eth0.10 for vlan 10, instead received %s", linkName) } parent, vidStr := splitName[0], splitName[1] // validate type and convert vlan id...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
drivers/ipvlan/ipvlan_setup.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/ipvlan/ipvlan_setup.go#L160-L180
go
train
// createDummyLink creates a dummy0 parent link
func createDummyLink(dummyName, truncNetID string) error
// createDummyLink creates a dummy0 parent link func createDummyLink(dummyName, truncNetID string) error
{ // create a parent interface since one was not specified parent := &netlink.Dummy{ LinkAttrs: netlink.LinkAttrs{ Name: dummyName, }, } if err := ns.NlHandle().LinkAdd(parent); err != nil { return err } parentDummyLink, err := ns.NlHandle().LinkByName(dummyName) if err != nil { return fmt.Errorf("er...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
drivers/ipvlan/ipvlan_setup.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/ipvlan/ipvlan_setup.go#L183-L200
go
train
// delDummyLink deletes the link type dummy used when -o parent is not passed
func delDummyLink(linkName string) error
// delDummyLink deletes the link type dummy used when -o parent is not passed func delDummyLink(linkName string) error
{ // delete the vlan subinterface dummyLink, err := ns.NlHandle().LinkByName(linkName) if err != nil { return fmt.Errorf("failed to find link %s on the Docker host : %v", linkName, err) } // verify a parent interface is being deleted if dummyLink.Attrs().ParentIndex != 0 { return fmt.Errorf("link %s is not a...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
datastore/datastore.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/datastore.go#L156-L164
go
train
// DefaultScopes returns a map of default scopes and its config for clients to use.
func DefaultScopes(dataDir string) map[string]*ScopeCfg
// DefaultScopes returns a map of default scopes and its config for clients to use. func DefaultScopes(dataDir string) map[string]*ScopeCfg
{ if dataDir != "" { defaultScopes[LocalScope].Client.Address = dataDir + "/network/files/local-kv.db" return defaultScopes } defaultScopes[LocalScope].Client.Address = defaultPrefix + "/local-kv.db" return defaultScopes }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
datastore/datastore.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/datastore.go#L167-L175
go
train
// IsValid checks if the scope config has valid configuration.
func (cfg *ScopeCfg) IsValid() bool
// IsValid checks if the scope config has valid configuration. func (cfg *ScopeCfg) IsValid() bool
{ if cfg == nil || strings.TrimSpace(cfg.Client.Provider) == "" || strings.TrimSpace(cfg.Client.Address) == "" { return false } return true }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
datastore/datastore.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/datastore.go#L178-L182
go
train
//Key provides convenient method to create a Key
func Key(key ...string) string
//Key provides convenient method to create a Key func Key(key ...string) string
{ keychain := append(rootChain, key...) str := strings.Join(keychain, "/") return str + "/" }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
datastore/datastore.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/datastore.go#L185-L193
go
train
//ParseKey provides convenient method to unpack the key to complement the Key function
func ParseKey(key string) ([]string, error)
//ParseKey provides convenient method to unpack the key to complement the Key function func ParseKey(key string) ([]string, error)
{ chain := strings.Split(strings.Trim(key, "/"), "/") // The key must at least be equal to the rootChain in order to be considered as valid if len(chain) <= len(rootChain) || !reflect.DeepEqual(chain[0:len(rootChain)], rootChain) { return nil, types.BadRequestErrorf("invalid Key : %s", key) } return chain[len(...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
datastore/datastore.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/datastore.go#L196-L237
go
train
// newClient used to connect to KV Store
func newClient(scope string, kv string, addr string, config *store.Config, cached bool) (DataStore, error)
// newClient used to connect to KV Store func newClient(scope string, kv string, addr string, config *store.Config, cached bool) (DataStore, error)
{ if cached && scope != LocalScope { return nil, fmt.Errorf("caching supported only for scope %s", LocalScope) } sequential := false if scope == LocalScope { sequential = true } if config == nil { config = &store.Config{} } var addrs []string if kv == string(store.BOLTDB) { // Parse file path ad...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
datastore/datastore.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/datastore.go#L240-L256
go
train
// NewDataStore creates a new instance of LibKV data store
func NewDataStore(scope string, cfg *ScopeCfg) (DataStore, error)
// NewDataStore creates a new instance of LibKV data store func NewDataStore(scope string, cfg *ScopeCfg) (DataStore, error)
{ if cfg == nil || cfg.Client.Provider == "" || cfg.Client.Address == "" { c, ok := defaultScopes[scope] if !ok || c.Client.Provider == "" || c.Client.Address == "" { return nil, fmt.Errorf("unexpected scope %s without configuration passed", scope) } cfg = c } var cached bool if scope == LocalScope { ...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
datastore/datastore.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/datastore.go#L259-L284
go
train
// NewDataStoreFromConfig creates a new instance of LibKV data store starting from the datastore config data
func NewDataStoreFromConfig(dsc discoverapi.DatastoreConfigData) (DataStore, error)
// NewDataStoreFromConfig creates a new instance of LibKV data store starting from the datastore config data func NewDataStoreFromConfig(dsc discoverapi.DatastoreConfigData) (DataStore, error)
{ var ( ok bool sCfgP *store.Config ) sCfgP, ok = dsc.Config.(*store.Config) if !ok && dsc.Config != nil { return nil, fmt.Errorf("cannot parse store configuration: %v", dsc.Config) } scopeCfg := &ScopeCfg{ Client: ScopeClientCfg{ Address: dsc.Address, Provider: dsc.Provider, Config: sCf...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
datastore/datastore.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/datastore.go#L384-L433
go
train
// PutObjectAtomic adds a new Record based on an object into the datastore
func (ds *datastore) PutObjectAtomic(kvObject KVObject) error
// PutObjectAtomic adds a new Record based on an object into the datastore func (ds *datastore) PutObjectAtomic(kvObject KVObject) error
{ var ( previous *store.KVPair pair *store.KVPair err error ) if ds.sequential { ds.Lock() defer ds.Unlock() } if kvObject == nil { return types.BadRequestErrorf("invalid KV Object : nil") } kvObjValue := kvObject.Value() if kvObjValue == nil { return types.BadRequestErrorf("invalid K...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
datastore/datastore.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/datastore.go#L436-L462
go
train
// PutObject adds a new Record based on an object into the datastore
func (ds *datastore) PutObject(kvObject KVObject) error
// PutObject adds a new Record based on an object into the datastore func (ds *datastore) PutObject(kvObject KVObject) error
{ if ds.sequential { ds.Lock() defer ds.Unlock() } if kvObject == nil { return types.BadRequestErrorf("invalid KV Object : nil") } if kvObject.Skip() { goto add_cache } if err := ds.putObjectWithKey(kvObject, kvObject.Key()...); err != nil { return err } add_cache: if ds.cache != nil { // If p...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
datastore/datastore.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/datastore.go#L474-L497
go
train
// GetObject returns a record matching the key
func (ds *datastore) GetObject(key string, o KVObject) error
// GetObject returns a record matching the key func (ds *datastore) GetObject(key string, o KVObject) error
{ if ds.sequential { ds.Lock() defer ds.Unlock() } if ds.cache != nil { return ds.cache.get(key, o) } kvPair, err := ds.store.Get(key) if err != nil { return err } if err := o.SetValue(kvPair.Value); err != nil { return err } // Make sure the object has a correct view of the DB index in // cas...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
datastore/datastore.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/datastore.go#L586-L604
go
train
// DeleteObject unconditionally deletes a record from the store
func (ds *datastore) DeleteObject(kvObject KVObject) error
// DeleteObject unconditionally deletes a record from the store func (ds *datastore) DeleteObject(kvObject KVObject) error
{ if ds.sequential { ds.Lock() defer ds.Unlock() } // cleanup the cache first if ds.cache != nil { // If persistent store is skipped, sequencing needs to // happen in cache. ds.cache.del(kvObject, kvObject.Skip()) } if kvObject.Skip() { return nil } return ds.store.Delete(Key(kvObject.Key()...))...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
datastore/datastore.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/datastore.go#L607-L639
go
train
// DeleteObjectAtomic performs atomic delete on a record
func (ds *datastore) DeleteObjectAtomic(kvObject KVObject) error
// DeleteObjectAtomic performs atomic delete on a record func (ds *datastore) DeleteObjectAtomic(kvObject KVObject) error
{ if ds.sequential { ds.Lock() defer ds.Unlock() } if kvObject == nil { return types.BadRequestErrorf("invalid KV Object : nil") } previous := &store.KVPair{Key: Key(kvObject.Key()...), LastIndex: kvObject.Index()} if kvObject.Skip() { goto del_cache } if _, err := ds.store.AtomicDelete(Key(kvObjec...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
datastore/datastore.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/datastore.go#L642-L660
go
train
// DeleteTree unconditionally deletes a record from the store
func (ds *datastore) DeleteTree(kvObject KVObject) error
// DeleteTree unconditionally deletes a record from the store func (ds *datastore) DeleteTree(kvObject KVObject) error
{ if ds.sequential { ds.Lock() defer ds.Unlock() } // cleanup the cache first if ds.cache != nil { // If persistent store is skipped, sequencing needs to // happen in cache. ds.cache.del(kvObject, kvObject.Skip()) } if kvObject.Skip() { return nil } return ds.store.DeleteTree(Key(kvObject.KeyPre...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
drivers/remote/driver.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/remote/driver.go#L33-L63
go
train
// Init makes sure a remote driver is registered when a network driver // plugin is activated.
func Init(dc driverapi.DriverCallback, config map[string]interface{}) error
// Init makes sure a remote driver is registered when a network driver // plugin is activated. func Init(dc driverapi.DriverCallback, config map[string]interface{}) error
{ newPluginHandler := func(name string, client *plugins.Client) { // negotiate driver capability with client d := newDriver(name, client) c, err := d.(*driver).getCapabilities() if err != nil { logrus.Errorf("error getting capability for %s due to %v", name, err) return } if err = dc.RegisterDriver(...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
drivers/remote/driver.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/remote/driver.go#L88-L116
go
train
// Get capability from client
func (d *driver) getCapabilities() (*driverapi.Capability, error)
// Get capability from client func (d *driver) getCapabilities() (*driverapi.Capability, error)
{ var capResp api.GetCapabilityResponse if err := d.call("GetCapabilities", nil, &capResp); err != nil { return nil, err } c := &driverapi.Capability{} switch capResp.Scope { case "global": c.DataScope = datastore.GlobalScope case "local": c.DataScope = datastore.LocalScope default: return nil, fmt.Er...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
drivers/remote/driver.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/remote/driver.go#L260-L314
go
train
// Join method is invoked when a Sandbox is attached to an endpoint.
func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error
// Join method is invoked when a Sandbox is attached to an endpoint. func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error
{ join := &api.JoinRequest{ NetworkID: nid, EndpointID: eid, SandboxKey: sboxKey, Options: options, } var ( res api.JoinResponse err error ) if err = d.call("Join", join, &res); err != nil { return err } ifaceName := res.InterfaceName if iface := jinfo.InterfaceName(); iface != nil && ifaceN...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
drivers/remote/driver.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/remote/driver.go#L317-L323
go
train
// Leave method is invoked when a Sandbox detaches from an endpoint.
func (d *driver) Leave(nid, eid string) error
// Leave method is invoked when a Sandbox detaches from an endpoint. func (d *driver) Leave(nid, eid string) error
{ leave := &api.LeaveRequest{ NetworkID: nid, EndpointID: eid, } return d.call("Leave", leave, &api.LeaveResponse{}) }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
drivers/remote/driver.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/remote/driver.go#L326-L338
go
train
// ProgramExternalConnectivity is invoked to program the rules to allow external connectivity for the endpoint.
func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error
// ProgramExternalConnectivity is invoked to program the rules to allow external connectivity for the endpoint. func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error
{ data := &api.ProgramExternalConnectivityRequest{ NetworkID: nid, EndpointID: eid, Options: options, } err := d.call("ProgramExternalConnectivity", data, &api.ProgramExternalConnectivityResponse{}) if err != nil && plugins.IsNotFound(err) { // It is not mandatory yet to support this method return ni...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
drivers/remote/driver.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/remote/driver.go#L341-L352
go
train
// RevokeExternalConnectivity method is invoked to remove any external connectivity programming related to the endpoint.
func (d *driver) RevokeExternalConnectivity(nid, eid string) error
// RevokeExternalConnectivity method is invoked to remove any external connectivity programming related to the endpoint. func (d *driver) RevokeExternalConnectivity(nid, eid string) error
{ data := &api.RevokeExternalConnectivityRequest{ NetworkID: nid, EndpointID: eid, } err := d.call("RevokeExternalConnectivity", data, &api.RevokeExternalConnectivityResponse{}) if err != nil && plugins.IsNotFound(err) { // It is not mandatory yet to support this method return nil } return err }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
drivers/remote/driver.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/remote/driver.go#L363-L372
go
train
// DiscoverNew is a notification for a new discovery event, such as a new node joining a cluster
func (d *driver) DiscoverNew(dType discoverapi.DiscoveryType, data interface{}) error
// DiscoverNew is a notification for a new discovery event, such as a new node joining a cluster func (d *driver) DiscoverNew(dType discoverapi.DiscoveryType, data interface{}) error
{ if dType != discoverapi.NodeDiscovery { return nil } notif := &api.DiscoveryNotification{ DiscoveryType: dType, DiscoveryData: data, } return d.call("DiscoverNew", notif, &api.DiscoveryResponse{}) }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
drivers/remote/driver.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/remote/driver.go#L411-L436
go
train
// parseInterfaces validates all the parameters of an Interface and returns them.
func parseInterface(r api.CreateEndpointResponse) (*api.Interface, error)
// parseInterfaces validates all the parameters of an Interface and returns them. func parseInterface(r api.CreateEndpointResponse) (*api.Interface, error)
{ var outIf *api.Interface inIf := r.Interface if inIf != nil { var err error outIf = &api.Interface{} if inIf.Address != "" { if outIf.Address, err = types.ParseCIDR(inIf.Address); err != nil { return nil, err } } if inIf.AddressIPv6 != "" { if outIf.AddressIPv6, err = types.ParseCIDR(inIf....
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
cmd/proxy/udp_proxy.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/cmd/proxy/udp_proxy.go#L57-L68
go
train
// NewUDPProxy creates a new UDPProxy.
func NewUDPProxy(frontendAddr, backendAddr *net.UDPAddr) (*UDPProxy, error)
// NewUDPProxy creates a new UDPProxy. func NewUDPProxy(frontendAddr, backendAddr *net.UDPAddr) (*UDPProxy, error)
{ listener, err := net.ListenUDP("udp", frontendAddr) if err != nil { return nil, err } return &UDPProxy{ listener: listener, frontendAddr: listener.LocalAddr().(*net.UDPAddr), backendAddr: backendAddr, connTrackTable: make(connTrackMap), }, nil }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
cmd/proxy/udp_proxy.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/cmd/proxy/udp_proxy.go#L145-L152
go
train
// Close stops forwarding the traffic.
func (proxy *UDPProxy) Close()
// Close stops forwarding the traffic. func (proxy *UDPProxy) Close()
{ proxy.listener.Close() proxy.connTrackLock.Lock() defer proxy.connTrackLock.Unlock() for _, conn := range proxy.connTrackTable { conn.Close() } }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
osl/sandbox_freebsd.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/osl/sandbox_freebsd.go#L7-L14
go
train
// GenerateKey generates a sandbox key based on the passed // container id.
func GenerateKey(containerID string) string
// GenerateKey generates a sandbox key based on the passed // container id. func GenerateKey(containerID string) string
{ maxLen := 12 if len(containerID) < maxLen { maxLen = len(containerID) } return containerID[:maxLen] }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
osl/sandbox_freebsd.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/osl/sandbox_freebsd.go#L18-L20
go
train
// NewSandbox provides a new sandbox instance created in an os specific way // provided a key which uniquely identifies the sandbox
func NewSandbox(key string, osCreate, isRestore bool) (Sandbox, error)
// NewSandbox provides a new sandbox instance created in an os specific way // provided a key which uniquely identifies the sandbox func NewSandbox(key string, osCreate, isRestore bool) (Sandbox, error)
{ return nil, nil }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
agent.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/agent.go#L241-L259
go
train
// For a given subsystem getKeys sorts the keys by lamport time and returns // slice of keys and lamport time which can used as a unique tag for the keys
func (c *controller) getKeys(subsys string) ([][]byte, []uint64)
// For a given subsystem getKeys sorts the keys by lamport time and returns // slice of keys and lamport time which can used as a unique tag for the keys func (c *controller) getKeys(subsys string) ([][]byte, []uint64)
{ c.Lock() defer c.Unlock() sort.Sort(ByTime(c.keys)) keys := [][]byte{} tags := []uint64{} for _, key := range c.keys { if key.Subsystem == subsys { keys = append(keys, key.Key) tags = append(tags, key.LamportTime) } } keys[0], keys[1] = keys[1], keys[0] tags[0], tags[1] = tags[1], tags[0] retu...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
agent.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/agent.go#L263-L274
go
train
// getPrimaryKeyTag returns the primary key for a given subsystem from the // list of sorted key and the associated tag
func (c *controller) getPrimaryKeyTag(subsys string) ([]byte, uint64, error)
// getPrimaryKeyTag returns the primary key for a given subsystem from the // list of sorted key and the associated tag func (c *controller) getPrimaryKeyTag(subsys string) ([]byte, uint64, error)
{ c.Lock() defer c.Unlock() sort.Sort(ByTime(c.keys)) keys := []*types.EncryptionKey{} for _, key := range c.keys { if key.Subsystem == subsys { keys = append(keys, key) } } return keys[1].Key, keys[1].LamportTime, nil }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
drivers/ipvlan/ipvlan_joinleave.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/ipvlan/ipvlan_joinleave.go#L27-L124
go
train
// Join method is invoked when a Sandbox is attached to an endpoint.
func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error
// Join method is invoked when a Sandbox is attached to an endpoint. func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error
{ defer osl.InitOSContext()() n, err := d.getNetwork(nid) if err != nil { return err } endpoint := n.endpoint(eid) if endpoint == nil { return fmt.Errorf("could not find endpoint with id %s", eid) } // generate a name for the iface that will be renamed to eth0 in the sbox containerIfName, err := netutils....
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
drivers/ipvlan/ipvlan_joinleave.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/ipvlan/ipvlan_joinleave.go#L127-L142
go
train
// Leave method is invoked when a Sandbox detaches from an endpoint.
func (d *driver) Leave(nid, eid string) error
// Leave method is invoked when a Sandbox detaches from an endpoint. func (d *driver) Leave(nid, eid string) error
{ defer osl.InitOSContext()() network, err := d.getNetwork(nid) if err != nil { return err } endpoint, err := network.getEndpoint(eid) if err != nil { return err } if endpoint == nil { return fmt.Errorf("could not find endpoint with id %s", eid) } return nil }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
drivers/ipvlan/ipvlan_joinleave.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/ipvlan/ipvlan_joinleave.go#L145-L157
go
train
// ifaceGateway returns a static route for either v4/v6 to be set to the container eth0
func ifaceGateway(dfNet string) (*staticRoute, error)
// ifaceGateway returns a static route for either v4/v6 to be set to the container eth0 func ifaceGateway(dfNet string) (*staticRoute, error)
{ nh, dst, err := net.ParseCIDR(dfNet) if err != nil { return nil, fmt.Errorf("unable to parse default route %v", err) } defaultRoute := &staticRoute{ Destination: dst, RouteType: types.CONNECTED, NextHop: nh, } return defaultRoute, nil }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
drivers/ipvlan/ipvlan_joinleave.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/ipvlan/ipvlan_joinleave.go#L160-L178
go
train
// getSubnetforIPv4 returns the ipv4 subnet to which the given IP belongs
func (n *network) getSubnetforIPv4(ip *net.IPNet) *ipv4Subnet
// getSubnetforIPv4 returns the ipv4 subnet to which the given IP belongs func (n *network) getSubnetforIPv4(ip *net.IPNet) *ipv4Subnet
{ for _, s := range n.config.Ipv4Subnets { _, snet, err := net.ParseCIDR(s.SubnetIP) if err != nil { return nil } // first check if the mask lengths are the same i, _ := snet.Mask.Size() j, _ := ip.Mask.Size() if i != j { continue } if snet.Contains(ip.IP) { return s } } return nil }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
drivers/ipvlan/ipvlan_joinleave.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/ipvlan/ipvlan_joinleave.go#L181-L199
go
train
// getSubnetforIPv6 returns the ipv6 subnet to which the given IP belongs
func (n *network) getSubnetforIPv6(ip *net.IPNet) *ipv6Subnet
// getSubnetforIPv6 returns the ipv6 subnet to which the given IP belongs func (n *network) getSubnetforIPv6(ip *net.IPNet) *ipv6Subnet
{ for _, s := range n.config.Ipv6Subnets { _, snet, err := net.ParseCIDR(s.SubnetIP) if err != nil { return nil } // first check if the mask lengths are the same i, _ := snet.Mask.Size() j, _ := ip.Mask.Size() if i != j { continue } if snet.Contains(ip.IP) { return s } } return nil }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
client/mflag/flag.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L345-L376
go
train
// sortFlags returns the flags as a slice in lexicographical sorted order.
func sortFlags(flags map[string]*Flag) []*Flag
// sortFlags returns the flags as a slice in lexicographical sorted order. func sortFlags(flags map[string]*Flag) []*Flag
{ var list flagSlice // The sorted list is based on the first name, when flag map might use the other names. nameMap := make(map[string]string) for n, f := range flags { fName := strings.TrimPrefix(f.Names[0], "#") nameMap[fName] = n if len(f.Names) == 1 { list = append(list, fName) continue } f...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
client/mflag/flag.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L384-L389
go
train
// Out returns the destination for usage and error messages.
func (fs *FlagSet) Out() io.Writer
// Out returns the destination for usage and error messages. func (fs *FlagSet) Out() io.Writer
{ if fs.output == nil { return os.Stderr } return fs.output }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
client/mflag/flag.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L413-L417
go
train
// Visit visits the flags in lexicographical order, calling fn for each. // It visits only those flags that have been set.
func (fs *FlagSet) Visit(fn func(*Flag))
// Visit visits the flags in lexicographical order, calling fn for each. // It visits only those flags that have been set. func (fs *FlagSet) Visit(fn func(*Flag))
{ for _, flag := range sortFlags(fs.actual) { fn(flag) } }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
client/mflag/flag.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L431-L433
go
train
// IsSet indicates whether the specified flag is set in the given FlagSet
func (fs *FlagSet) IsSet(name string) bool
// IsSet indicates whether the specified flag is set in the given FlagSet func (fs *FlagSet) IsSet(name string) bool
{ return fs.actual[name] != nil }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
client/mflag/flag.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L464-L466
go
train
// Require adds a requirement about the number of arguments for the FlagSet. // The first parameter can be Exact, Max, or Min to respectively specify the exact, // the maximum, or the minimal number of arguments required. // The actual check is done in FlagSet.CheckArgs().
func (fs *FlagSet) Require(nArgRequirementType nArgRequirementType, nArg int)
// Require adds a requirement about the number of arguments for the FlagSet. // The first parameter can be Exact, Max, or Min to respectively specify the exact, // the maximum, or the minimal number of arguments required. // The actual check is done in FlagSet.CheckArgs(). func (fs *FlagSet) Require(nArgRequirementType...
{ fs.nArgRequirements = append(fs.nArgRequirements, nArgRequirement{nArgRequirementType, nArg}) }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
client/mflag/flag.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L471-L500
go
train
// CheckArgs uses the requirements set by FlagSet.Require() to validate // the number of arguments. If the requirements are not met, // an error message string is returned.
func (fs *FlagSet) CheckArgs() (message string)
// CheckArgs uses the requirements set by FlagSet.Require() to validate // the number of arguments. If the requirements are not met, // an error message string is returned. func (fs *FlagSet) CheckArgs() (message string)
{ for _, req := range fs.nArgRequirements { var arguments string if req.N == 1 { arguments = "1 argument" } else { arguments = fmt.Sprintf("%d arguments", req.N) } str := func(kind string) string { return fmt.Sprintf("%q requires %s%s", fs.name, kind, arguments) } switch req.Type { case Exa...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
client/mflag/flag.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L503-L516
go
train
// Set sets the value of the named flag.
func (fs *FlagSet) Set(name, value string) error
// Set sets the value of the named flag. func (fs *FlagSet) Set(name, value string) error
{ flag, ok := fs.formal[name] if !ok { return fmt.Errorf("no such flag -%v", name) } if err := flag.Value.Set(value); err != nil { return err } if fs.actual == nil { fs.actual = make(map[string]*Flag) } fs.actual[name] = flag return nil }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
client/mflag/flag.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L539-L580
go
train
// PrintDefaults prints, to standard error unless configured // otherwise, the default values of all defined flags in the set.
func (fs *FlagSet) PrintDefaults()
// PrintDefaults prints, to standard error unless configured // otherwise, the default values of all defined flags in the set. func (fs *FlagSet) PrintDefaults()
{ writer := tabwriter.NewWriter(fs.Out(), 20, 1, 3, ' ', 0) home := homedir.Get() // Don't substitute when HOME is / if runtime.GOOS != "windows" && home == "/" { home = "" } // Add a blank line between cmd description and list of options if fs.FlagCount() > 0 { fmt.Fprintln(writer, "") } fs.VisitAll(f...
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
client/mflag/flag.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L588-L595
go
train
// defaultUsage is the default function to print a usage message.
func defaultUsage(fs *FlagSet)
// defaultUsage is the default function to print a usage message. func defaultUsage(fs *FlagSet)
{ if fs.name == "" { fmt.Fprintf(fs.Out(), "Usage:\n") } else { fmt.Fprintf(fs.Out(), "Usage of %s:\n", fs.name) } fs.PrintDefaults() }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
client/mflag/flag.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L618-L629
go
train
// FlagCountUndeprecated returns the number of undeprecated flags that have been defined.
func (fs *FlagSet) FlagCountUndeprecated() int
// FlagCountUndeprecated returns the number of undeprecated flags that have been defined. func (fs *FlagSet) FlagCountUndeprecated() int
{ count := 0 for _, flag := range sortFlags(fs.formal) { for _, name := range flag.Names { if name[0] != '#' { count++ break } } } return count }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
client/mflag/flag.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L639-L644
go
train
// Arg returns the i'th argument. Arg(0) is the first remaining argument // after flags have been processed.
func (fs *FlagSet) Arg(i int) string
// Arg returns the i'th argument. Arg(0) is the first remaining argument // after flags have been processed. func (fs *FlagSet) Arg(i int) string
{ if i < 0 || i >= len(fs.args) { return "" } return fs.args[i] }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
client/mflag/flag.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L666-L668
go
train
// BoolVar defines a bool flag with specified name, default value, and usage string. // The argument p points to a bool variable in which to store the value of the flag.
func (fs *FlagSet) BoolVar(p *bool, names []string, value bool, usage string)
// BoolVar defines a bool flag with specified name, default value, and usage string. // The argument p points to a bool variable in which to store the value of the flag. func (fs *FlagSet) BoolVar(p *bool, names []string, value bool, usage string)
{ fs.Var(newBoolValue(value, p), names, usage) }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
client/mflag/flag.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L678-L682
go
train
// Bool defines a bool flag with specified name, default value, and usage string. // The return value is the address of a bool variable that stores the value of the flag.
func (fs *FlagSet) Bool(names []string, value bool, usage string) *bool
// Bool defines a bool flag with specified name, default value, and usage string. // The return value is the address of a bool variable that stores the value of the flag. func (fs *FlagSet) Bool(names []string, value bool, usage string) *bool
{ p := new(bool) fs.BoolVar(p, names, value, usage) return p }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
client/mflag/flag.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L686-L688
go
train
// Bool defines a bool flag with specified name, default value, and usage string. // The return value is the address of a bool variable that stores the value of the flag.
func Bool(names []string, value bool, usage string) *bool
// Bool defines a bool flag with specified name, default value, and usage string. // The return value is the address of a bool variable that stores the value of the flag. func Bool(names []string, value bool, usage string) *bool
{ return CommandLine.Bool(names, value, usage) }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
client/mflag/flag.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L692-L694
go
train
// IntVar defines an int flag with specified name, default value, and usage string. // The argument p points to an int variable in which to store the value of the flag.
func (fs *FlagSet) IntVar(p *int, names []string, value int, usage string)
// IntVar defines an int flag with specified name, default value, and usage string. // The argument p points to an int variable in which to store the value of the flag. func (fs *FlagSet) IntVar(p *int, names []string, value int, usage string)
{ fs.Var(newIntValue(value, p), names, usage) }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
client/mflag/flag.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L704-L708
go
train
// Int defines an int flag with specified name, default value, and usage string. // The return value is the address of an int variable that stores the value of the flag.
func (fs *FlagSet) Int(names []string, value int, usage string) *int
// Int defines an int flag with specified name, default value, and usage string. // The return value is the address of an int variable that stores the value of the flag. func (fs *FlagSet) Int(names []string, value int, usage string) *int
{ p := new(int) fs.IntVar(p, names, value, usage) return p }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
client/mflag/flag.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L712-L714
go
train
// Int defines an int flag with specified name, default value, and usage string. // The return value is the address of an int variable that stores the value of the flag.
func Int(names []string, value int, usage string) *int
// Int defines an int flag with specified name, default value, and usage string. // The return value is the address of an int variable that stores the value of the flag. func Int(names []string, value int, usage string) *int
{ return CommandLine.Int(names, value, usage) }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
client/mflag/flag.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L718-L720
go
train
// Int64Var defines an int64 flag with specified name, default value, and usage string. // The argument p points to an int64 variable in which to store the value of the flag.
func (fs *FlagSet) Int64Var(p *int64, names []string, value int64, usage string)
// Int64Var defines an int64 flag with specified name, default value, and usage string. // The argument p points to an int64 variable in which to store the value of the flag. func (fs *FlagSet) Int64Var(p *int64, names []string, value int64, usage string)
{ fs.Var(newInt64Value(value, p), names, usage) }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
client/mflag/flag.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L730-L734
go
train
// Int64 defines an int64 flag with specified name, default value, and usage string. // The return value is the address of an int64 variable that stores the value of the flag.
func (fs *FlagSet) Int64(names []string, value int64, usage string) *int64
// Int64 defines an int64 flag with specified name, default value, and usage string. // The return value is the address of an int64 variable that stores the value of the flag. func (fs *FlagSet) Int64(names []string, value int64, usage string) *int64
{ p := new(int64) fs.Int64Var(p, names, value, usage) return p }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
client/mflag/flag.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L738-L740
go
train
// Int64 defines an int64 flag with specified name, default value, and usage string. // The return value is the address of an int64 variable that stores the value of the flag.
func Int64(names []string, value int64, usage string) *int64
// Int64 defines an int64 flag with specified name, default value, and usage string. // The return value is the address of an int64 variable that stores the value of the flag. func Int64(names []string, value int64, usage string) *int64
{ return CommandLine.Int64(names, value, usage) }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
client/mflag/flag.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L744-L746
go
train
// UintVar defines a uint flag with specified name, default value, and usage string. // The argument p points to a uint variable in which to store the value of the flag.
func (fs *FlagSet) UintVar(p *uint, names []string, value uint, usage string)
// UintVar defines a uint flag with specified name, default value, and usage string. // The argument p points to a uint variable in which to store the value of the flag. func (fs *FlagSet) UintVar(p *uint, names []string, value uint, usage string)
{ fs.Var(newUintValue(value, p), names, usage) }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
client/mflag/flag.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L756-L760
go
train
// Uint defines a uint flag with specified name, default value, and usage string. // The return value is the address of a uint variable that stores the value of the flag.
func (fs *FlagSet) Uint(names []string, value uint, usage string) *uint
// Uint defines a uint flag with specified name, default value, and usage string. // The return value is the address of a uint variable that stores the value of the flag. func (fs *FlagSet) Uint(names []string, value uint, usage string) *uint
{ p := new(uint) fs.UintVar(p, names, value, usage) return p }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
client/mflag/flag.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L764-L766
go
train
// Uint defines a uint flag with specified name, default value, and usage string. // The return value is the address of a uint variable that stores the value of the flag.
func Uint(names []string, value uint, usage string) *uint
// Uint defines a uint flag with specified name, default value, and usage string. // The return value is the address of a uint variable that stores the value of the flag. func Uint(names []string, value uint, usage string) *uint
{ return CommandLine.Uint(names, value, usage) }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
client/mflag/flag.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L770-L772
go
train
// Uint64Var defines a uint64 flag with specified name, default value, and usage string. // The argument p points to a uint64 variable in which to store the value of the flag.
func (fs *FlagSet) Uint64Var(p *uint64, names []string, value uint64, usage string)
// Uint64Var defines a uint64 flag with specified name, default value, and usage string. // The argument p points to a uint64 variable in which to store the value of the flag. func (fs *FlagSet) Uint64Var(p *uint64, names []string, value uint64, usage string)
{ fs.Var(newUint64Value(value, p), names, usage) }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
client/mflag/flag.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L782-L786
go
train
// Uint64 defines a uint64 flag with specified name, default value, and usage string. // The return value is the address of a uint64 variable that stores the value of the flag.
func (fs *FlagSet) Uint64(names []string, value uint64, usage string) *uint64
// Uint64 defines a uint64 flag with specified name, default value, and usage string. // The return value is the address of a uint64 variable that stores the value of the flag. func (fs *FlagSet) Uint64(names []string, value uint64, usage string) *uint64
{ p := new(uint64) fs.Uint64Var(p, names, value, usage) return p }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
client/mflag/flag.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L790-L792
go
train
// Uint64 defines a uint64 flag with specified name, default value, and usage string. // The return value is the address of a uint64 variable that stores the value of the flag.
func Uint64(names []string, value uint64, usage string) *uint64
// Uint64 defines a uint64 flag with specified name, default value, and usage string. // The return value is the address of a uint64 variable that stores the value of the flag. func Uint64(names []string, value uint64, usage string) *uint64
{ return CommandLine.Uint64(names, value, usage) }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
client/mflag/flag.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L796-L798
go
train
// Uint16Var defines a uint16 flag with specified name, default value, and usage string. // The argument p points to a uint16 variable in which to store the value of the flag.
func (fs *FlagSet) Uint16Var(p *uint16, names []string, value uint16, usage string)
// Uint16Var defines a uint16 flag with specified name, default value, and usage string. // The argument p points to a uint16 variable in which to store the value of the flag. func (fs *FlagSet) Uint16Var(p *uint16, names []string, value uint16, usage string)
{ fs.Var(newUint16Value(value, p), names, usage) }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
client/mflag/flag.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L802-L804
go
train
// Uint16Var defines a uint16 flag with specified name, default value, and usage string. // The argument p points to a uint16 variable in which to store the value of the flag.
func Uint16Var(p *uint16, names []string, value uint16, usage string)
// Uint16Var defines a uint16 flag with specified name, default value, and usage string. // The argument p points to a uint16 variable in which to store the value of the flag. func Uint16Var(p *uint16, names []string, value uint16, usage string)
{ CommandLine.Var(newUint16Value(value, p), names, usage) }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
client/mflag/flag.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L808-L812
go
train
// Uint16 defines a uint16 flag with specified name, default value, and usage string. // The return value is the address of a uint16 variable that stores the value of the flag.
func (fs *FlagSet) Uint16(names []string, value uint16, usage string) *uint16
// Uint16 defines a uint16 flag with specified name, default value, and usage string. // The return value is the address of a uint16 variable that stores the value of the flag. func (fs *FlagSet) Uint16(names []string, value uint16, usage string) *uint16
{ p := new(uint16) fs.Uint16Var(p, names, value, usage) return p }
docker/libnetwork
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
client/mflag/flag.go
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L816-L818
go
train
// Uint16 defines a uint16 flag with specified name, default value, and usage string. // The return value is the address of a uint16 variable that stores the value of the flag.
func Uint16(names []string, value uint16, usage string) *uint16
// Uint16 defines a uint16 flag with specified name, default value, and usage string. // The return value is the address of a uint16 variable that stores the value of the flag. func Uint16(names []string, value uint16, usage string) *uint16
{ return CommandLine.Uint16(names, value, usage) }