]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - kernel/bpf/hashtab.c
bpf: charge user for creation of BPF maps and programs
[mirror_ubuntu-zesty-kernel.git] / kernel / bpf / hashtab.c
index 83c209d9b17ae6b23eb16d0fd0d94b873897ffba..28592d79502b0dcb0deac7dfb1ac10f07d435eb5 100644 (file)
@@ -88,6 +88,10 @@ static struct bpf_map *htab_map_alloc(union bpf_attr *attr)
        htab->elem_size = sizeof(struct htab_elem) +
                          round_up(htab->map.key_size, 8) +
                          htab->map.value_size;
+
+       htab->map.pages = round_up(htab->n_buckets * sizeof(struct hlist_head) +
+                                  htab->elem_size * htab->map.max_entries,
+                                  PAGE_SIZE) >> PAGE_SHIFT;
        return &htab->map;
 
 free_htab: