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


Golang types.L3n4Addr類代碼示例

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


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

示例1: L3n4Addr2RevNatKeynValue

// L3n4Addr2RevNatKeynValue converts the given L3n4Addr to a RevNatKey and RevNatValue.
func L3n4Addr2RevNatKeynValue(svcID types.ServiceID, feL3n4Addr types.L3n4Addr) (RevNatKey, RevNatValue) {
	if feL3n4Addr.IsIPv6() {
		return NewRevNat6Key(uint16(svcID)), NewRevNat6Value(feL3n4Addr.IP, feL3n4Addr.Port)
	} else {
		return NewRevNat4Key(uint16(svcID)), NewRevNat4Value(feL3n4Addr.IP, feL3n4Addr.Port)
	}
}
開發者ID:cilium-team,項目名稱:cilium,代碼行數:8,代碼來源:lbmap.go

示例2: SVCGet

// SVCGet returns a DeepCopied frontend with its backends.
func (d *Daemon) SVCGet(feL3n4 types.L3n4Addr) (*types.LBSVC, error) {
	feL3n4Uniq, err := feL3n4.SHA256Sum()
	if err != nil {
		return nil, err
	}
	return d.SVCGetBySHA256Sum(feL3n4Uniq)
}
開發者ID:cilium-team,項目名稱:cilium,代碼行數:8,代碼來源:loadbalancer.go

示例3: L3n4Addr2ServiceKey

// L3n4Addr2ServiceKey converts the given l3n4Addr to a ServiceKey with the slave ID
// set to 0.
func L3n4Addr2ServiceKey(l3n4Addr types.L3n4Addr) ServiceKey {
	if l3n4Addr.IsIPv6() {
		return NewService6Key(l3n4Addr.IP, l3n4Addr.Port, 0)
	} else {
		return NewService4Key(l3n4Addr.IP, l3n4Addr.Port, 0)
	}
}
開發者ID:cilium-team,項目名稱:cilium,代碼行數:9,代碼來源:lbmap.go

示例4: SVCGet

// SVCGet calculates the SHA256Sum from the given frontend and sends a GET request with
// the calculated SHA256Sum to the daemon.
func (cli Client) SVCGet(fe types.L3n4Addr) (*types.LBSVC, error) {
	feSHA256Sum, err := fe.SHA256Sum()
	if err != nil {
		return nil, fmt.Errorf("invalid SHA256Sum for front end %+v: %s", fe, err)
	}
	return cli.SVCGetBySHA256Sum(feSHA256Sum)
}
開發者ID:cilium-team,項目名稱:cilium,代碼行數:9,代碼來源:loadbalancer.go

示例5: SVCDelete

// SVCDelete calculates the SHA256Sum from the given frontend and sends a DELETE request
// to the daemon.
func (cli Client) SVCDelete(fe types.L3n4Addr) error {
	feSHA256Sum, err := fe.SHA256Sum()
	if err != nil {
		return fmt.Errorf("invalid SHA256Sum for front end %+v: %s", fe, err)
	}
	return cli.SVCDeleteBySHA256Sum(feSHA256Sum)
}
開發者ID:cilium-team,項目名稱:cilium,代碼行數:9,代碼來源:loadbalancer.go

示例6: RevNATAdd

// RevNATAdd deep copies the given revNAT address to the cilium lbmap with the given id.
func (d *Daemon) RevNATAdd(id types.ServiceID, revNAT types.L3n4Addr) error {
	revNATK, revNATV := lbmap.L3n4Addr2RevNatKeynValue(id, revNAT)

	d.loadBalancer.BPFMapMU.Lock()
	defer d.loadBalancer.BPFMapMU.Unlock()

	err := lbmap.UpdateRevNat(revNATK, revNATV)
	if err != nil {
		return err
	}

	d.loadBalancer.RevNATMap[id] = *revNAT.DeepCopy()
	return nil
}
開發者ID:cilium-team,項目名稱:cilium,代碼行數:15,代碼來源:loadbalancer.go

示例7: PutL3n4Addr

// PutL3n4Addr stores the given service in the kvstore and returns the L3n4AddrID
// created for the given l3n4Addr. If baseID is different than 0, it tries to acquire that
// ID to the l3n4Addr.
func (d *Daemon) PutL3n4Addr(l3n4Addr types.L3n4Addr, baseID uint32) (*types.L3n4AddrID, error) {
	log.Debugf("Resolving service %+v", l3n4Addr)

	// Retrieve unique SHA256Sum for service
	sha256Sum, err := l3n4Addr.SHA256Sum()
	if err != nil {
		return nil, err
	}
	svcPath := path.Join(common.ServicesKeyPath, sha256Sum)

	// Lock that sha256Sum
	lockKey, err := d.kvClient.LockPath(svcPath)
	if err != nil {
		return nil, err
	}
	defer lockKey.Unlock()

	// After lock complete, get svc's path
	rmsg, err := d.kvClient.GetValue(svcPath)
	if err != nil {
		return nil, err
	}

	sl4KV := types.L3n4AddrID{}
	if rmsg != nil {
		if err := json.Unmarshal(rmsg, &sl4KV); err != nil {
			return nil, err
		}
	}
	if sl4KV.ID == 0 {
		sl4KV.L3n4Addr = l3n4Addr
		if err := d.gasNewL3n4AddrID(&sl4KV, baseID); err != nil {
			return nil, err
		}
		err = d.kvClient.SetValue(svcPath, sl4KV)
	}

	return &sl4KV, err
}
開發者ID:cilium-team,項目名稱:cilium,代碼行數:42,代碼來源:services.go

示例8: SVCDelete

// SVCDelete deletes the frontend from the local bpf map.
func (d *Daemon) SVCDelete(feL3n4 types.L3n4Addr) error {
	feL3n4Uniq, err := feL3n4.SHA256Sum()
	if err != nil {
		return err
	}

	var svcKey lbmap.ServiceKey
	if !feL3n4.IsIPv6() {
		svcKey = lbmap.NewService4Key(feL3n4.IP, feL3n4.Port, 0)
	} else {
		svcKey = lbmap.NewService6Key(feL3n4.IP, feL3n4.Port, 0)
	}

	svcKey.SetBackend(0)

	d.loadBalancer.BPFMapMU.Lock()
	defer d.loadBalancer.BPFMapMU.Unlock()
	err = lbmap.DeleteService(svcKey)
	// TODO should we delete even if err is != nil?
	if err == nil {
		delete(d.loadBalancer.SVCMap, feL3n4Uniq)
	}
	return err
}
開發者ID:cilium-team,項目名稱:cilium,代碼行數:25,代碼來源:loadbalancer.go


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