On 08/07/2018 08:52 AM, Daniel Borkmann wrote:
On 08/06/2018 03:58 PM, Mauricio Vasquez B wrote:
Bpf queue implements a LIFO/FIFO data containers for ebpf programs.

It allows to push an element to the queue by using the update operation
and to pop an element from the queue by using the lookup operation.

A use case for this is to keep track of a pool of elements, like
network ports in a SNAT.

Signed-off-by: Mauricio Vasquez B <mauricio.vasq...@polito.it>
[...]
+static int prealloc_init(struct bpf_queue *queue)
+{
+       u32 node_size = sizeof(struct queue_node) +
+                       round_up(queue->map.value_size, 8);
+       u32 num_entries = queue->map.max_entries;
+       int err;
+
+       queue->nodes = bpf_map_area_alloc(node_size * num_entries,
+                                         queue->map.numa_node);
That doesn't work either. If you don't set numa node, then here in
your case you'll always use numa node 0, which is unintentional.
You need to get the node via bpf_map_attr_numa_node(attr) helper.
Same issue in queue_map_update_elem().

This should work, map.numa_node is initialized using bpf_map_attr_numa_node() in bpf_map_init_from_attr()

The htab does exactly the same.

Reply via email to