qs = bpf_map_area_alloc(queue_size, numa_node); if (!qs) return ERR_PTR(-ENOMEM);
bpf_map_init_from_attr(&qs->map, attr);
qs->size = size;
raw_res_spin_lock_init(&qs->lock);
return &qs->map;
}
/* Called when map->refcnt goes to zero, either from workqueue or from syscall */ staticvoid queue_stack_map_free(struct bpf_map *map)
{ struct bpf_queue_stack *qs = bpf_queue_stack(map);
/* Called from syscall or from eBPF program */ staticlong queue_map_peek_elem(struct bpf_map *map, void *value)
{ return __queue_map_get(map, value, false);
}
/* Called from syscall or from eBPF program */ staticlong stack_map_peek_elem(struct bpf_map *map, void *value)
{ return __stack_map_get(map, value, false);
}
/* Called from syscall or from eBPF program */ staticlong queue_map_pop_elem(struct bpf_map *map, void *value)
{ return __queue_map_get(map, value, true);
}
/* Called from syscall or from eBPF program */ staticlong stack_map_pop_elem(struct bpf_map *map, void *value)
{ return __stack_map_get(map, value, true);
}
/* Called from syscall or from eBPF program */ staticlong queue_stack_map_push_elem(struct bpf_map *map, void *value,
u64 flags)
{ struct bpf_queue_stack *qs = bpf_queue_stack(map); unsignedlong irq_flags; int err = 0; void *dst;
/* BPF_EXIST is used to force making room for a new element in case the * map is full
*/ bool replace = (flags & BPF_EXIST);
/* Check supported flags for queue and stack maps */ if (flags & BPF_NOEXIST || flags > BPF_EXIST) return -EINVAL;
if (raw_res_spin_lock_irqsave(&qs->lock, irq_flags)) return -EBUSY;
if (queue_stack_map_is_full(qs)) { if (!replace) {
err = -E2BIG; goto out;
} /* advance tail pointer to overwrite oldest element */ if (unlikely(++qs->tail >= qs->size))
qs->tail = 0;
}
/* Called from syscall or from eBPF program */ staticvoid *queue_stack_map_lookup_elem(struct bpf_map *map, void *key)
{ return NULL;
}
/* Called from syscall or from eBPF program */ staticlong queue_stack_map_update_elem(struct bpf_map *map, void *key, void *value, u64 flags)
{ return -EINVAL;
}
/* Called from syscall or from eBPF program */ staticlong queue_stack_map_delete_elem(struct bpf_map *map, void *key)
{ return -EINVAL;
}
/* Called from syscall */ staticint queue_stack_map_get_next_key(struct bpf_map *map, void *key, void *next_key)
{ return -EINVAL;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.