Example #1
0
// DeleteElement deletes the element with the given id from the LXCMap.
func (m *LXCMap) DeleteElement(ep *endpoint.Endpoint) error {
	if m == nil {
		return nil
	}

	// FIXME: errors are currently ignored
	id6 := uint32(ep.ID)
	err := bpf.DeleteElement(m.fd, unsafe.Pointer(&id6))

	if ep.IPv4 != nil {
		if id4 := uint32(ep.IPv4.EndpointID()); id4 != 0 {
			id4 = id4 | (1 << 16)
			if err := bpf.DeleteElement(m.fd, unsafe.Pointer(&id4)); err != nil {
				return err
			}
		}
	}

	return err
}
Example #2
0
func (m *CtMap) doGc(interval uint16, key unsafe.Pointer, nextKey unsafe.Pointer, deleted *int) bool {
	var entry CtEntry

	err := bpf.GetNextKey(m.Fd, key, nextKey)
	if err != nil {
		return false
	}

	err = bpf.LookupElement(m.Fd, nextKey, unsafe.Pointer(&entry))
	if err != nil {
		return false
	}

	if entry.lifetime <= interval {
		bpf.DeleteElement(m.Fd, nextKey)
		(*deleted)++
	} else {
		entry.lifetime -= interval
		bpf.UpdateElement(m.Fd, nextKey, unsafe.Pointer(&entry), 0)
	}

	return true
}
Example #3
0
func (m *PolicyMap) DeleteConsumer(id uint32) error {
	return bpf.DeleteElement(m.Fd, unsafe.Pointer(&id))
}