aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/bpf/sockmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/bpf/sockmap.c')
-rw-r--r--kernel/bpf/sockmap.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/kernel/bpf/sockmap.c b/kernel/bpf/sockmap.c
index 39de541fbcdc..78b2bb9370ac 100644
--- a/kernel/bpf/sockmap.c
+++ b/kernel/bpf/sockmap.c
@@ -443,7 +443,9 @@ static struct smap_psock *smap_init_psock(struct sock *sock,
443{ 443{
444 struct smap_psock *psock; 444 struct smap_psock *psock;
445 445
446 psock = kzalloc(sizeof(struct smap_psock), GFP_ATOMIC | __GFP_NOWARN); 446 psock = kzalloc_node(sizeof(struct smap_psock),
447 GFP_ATOMIC | __GFP_NOWARN,
448 stab->map.numa_node);
447 if (!psock) 449 if (!psock)
448 return ERR_PTR(-ENOMEM); 450 return ERR_PTR(-ENOMEM);
449 451
@@ -465,7 +467,7 @@ static struct bpf_map *sock_map_alloc(union bpf_attr *attr)
465 467
466 /* check sanity of attributes */ 468 /* check sanity of attributes */
467 if (attr->max_entries == 0 || attr->key_size != 4 || 469 if (attr->max_entries == 0 || attr->key_size != 4 ||
468 attr->value_size != 4 || attr->map_flags) 470 attr->value_size != 4 || attr->map_flags & ~BPF_F_NUMA_NODE)
469 return ERR_PTR(-EINVAL); 471 return ERR_PTR(-EINVAL);
470 472
471 if (attr->value_size > KMALLOC_MAX_SIZE) 473 if (attr->value_size > KMALLOC_MAX_SIZE)
@@ -481,6 +483,7 @@ static struct bpf_map *sock_map_alloc(union bpf_attr *attr)
481 stab->map.value_size = attr->value_size; 483 stab->map.value_size = attr->value_size;
482 stab->map.max_entries = attr->max_entries; 484 stab->map.max_entries = attr->max_entries;
483 stab->map.map_flags = attr->map_flags; 485 stab->map.map_flags = attr->map_flags;
486 stab->map.numa_node = bpf_map_attr_numa_node(attr);
484 487
485 /* make sure page count doesn't overflow */ 488 /* make sure page count doesn't overflow */
486 cost = (u64) stab->map.max_entries * sizeof(struct sock *); 489 cost = (u64) stab->map.max_entries * sizeof(struct sock *);
@@ -495,7 +498,8 @@ static struct bpf_map *sock_map_alloc(union bpf_attr *attr)
495 goto free_stab; 498 goto free_stab;
496 499
497 stab->sock_map = bpf_map_area_alloc(stab->map.max_entries * 500 stab->sock_map = bpf_map_area_alloc(stab->map.max_entries *
498 sizeof(struct sock *)); 501 sizeof(struct sock *),
502 stab->map.numa_node);
499 if (!stab->sock_map) 503 if (!stab->sock_map)
500 goto free_stab; 504 goto free_stab;
501 505