Ejemplo n.º 1
0
// OpenMap opens the LXCMap in the given path.
func OpenMap(path string) (*LXCMap, error) {

	fd, _, err := bpf.OpenOrCreateMap(
		path,
		C.BPF_MAP_TYPE_HASH,
		uint32(unsafe.Sizeof(uint32(0))),
		uint32(unsafe.Sizeof(LXCInfo{})),
		MaxKeys,
	)
	if err != nil {
		return nil, err
	}
	m := new(LXCMap)
	m.fd = fd

	return m, nil
}
Ejemplo n.º 2
0
func OpenMap(path string) (*PolicyMap, bool, error) {

	fd, isNewMap, err := bpf.OpenOrCreateMap(
		path,
		C.BPF_MAP_TYPE_HASH,
		uint32(unsafe.Sizeof(uint32(0))),
		uint32(unsafe.Sizeof(PolicyEntry{})),
		MAX_KEYS,
	)

	if err != nil {
		return nil, false, err
	}

	m := &PolicyMap{path: path, Fd: fd}

	return m, isNewMap, nil
}