示例#1
0
文件: ui.go 项目: cilium-team/cilium
func (d *Daemon) getReceivedStats() (receivedStats, error) {
	stats := receivedStats{}
	d.endpointsMU.RLock()
	for _, ep := range d.endpoints {
		if ep.SecLabel != nil {
			if ep.PolicyMap != nil {
				pm, err := ep.PolicyMap.DumpToSlice()
				if err != nil {
					continue
				}

				stat, exists := stats[ep.SecLabel.ID]
				if !exists {
					stats[ep.SecLabel.ID] = map[uint32]*policymap.PolicyEntry{}
					stat = stats[ep.SecLabel.ID]
				}

				for _, p := range pm {
					pe, exists := stat[p.ID]
					if exists {
						pe.Add(p.PolicyEntry)
					} else {
						pe := policymap.PolicyEntry(p.PolicyEntry)
						stat[p.ID] = &pe
					}
				}
			}
		}
	}
	d.endpointsMU.RUnlock()
	return stats, nil
}
示例#2
0
文件: ui.go 项目: cilium-team/cilium
func (rs receivedStats) getStats(from, to uint32) *policymap.PolicyEntry {
	fromMap, exists := rs[to]
	if exists {
		pe, exists := fromMap[from]
		if exists && pe != nil {
			pe := policymap.PolicyEntry(*pe)
			return &pe
		}
	}
	return nil
}