Lines Matching refs:map

18 	struct bpf_map map;  member
34 static int sock_map_prog_update(struct bpf_map *map, struct bpf_prog *prog,
37 static struct sk_psock_progs *sock_map_progs(struct bpf_map *map);
54 bpf_map_init_from_attr(&stab->map, attr); in sock_map_alloc()
57 stab->sks = bpf_map_area_alloc((u64) stab->map.max_entries * in sock_map_alloc()
59 stab->map.numa_node); in sock_map_alloc()
65 return &stab->map; in sock_map_alloc()
70 struct bpf_map *map; in sock_map_get_from_fd() local
77 map = __bpf_map_get(f); in sock_map_get_from_fd()
78 if (IS_ERR(map)) in sock_map_get_from_fd()
79 return PTR_ERR(map); in sock_map_get_from_fd()
81 ret = sock_map_prog_update(map, prog, NULL, NULL, attr->attach_type); in sock_map_get_from_fd()
89 struct bpf_map *map; in sock_map_prog_detach() local
96 map = __bpf_map_get(f); in sock_map_prog_detach()
97 if (IS_ERR(map)) in sock_map_prog_detach()
98 return PTR_ERR(map); in sock_map_prog_detach()
110 ret = sock_map_prog_update(map, NULL, prog, NULL, attr->attach_type); in sock_map_prog_detach()
133 struct bpf_map *map, void *link_raw) in sock_map_add_link() argument
136 link->map = map; in sock_map_add_link()
151 struct bpf_map *map = link->map; in sock_map_del_link() local
152 struct sk_psock_progs *progs = sock_map_progs(map); in sock_map_del_link()
217 static int sock_map_link(struct bpf_map *map, struct sock *sk) in sock_map_link() argument
219 struct sk_psock_progs *progs = sock_map_progs(map); in sock_map_link()
279 psock = sk_psock_init(sk, map->numa_node); in sock_map_link()
339 static void sock_map_free(struct bpf_map *map) in sock_map_free() argument
341 struct bpf_stab *stab = container_of(map, struct bpf_stab, map); in sock_map_free()
349 for (i = 0; i < stab->map.max_entries; i++) { in sock_map_free()
372 static void sock_map_release_progs(struct bpf_map *map) in sock_map_release_progs() argument
374 psock_progs_drop(&container_of(map, struct bpf_stab, map)->progs); in sock_map_release_progs()
377 static struct sock *__sock_map_lookup_elem(struct bpf_map *map, u32 key) in __sock_map_lookup_elem() argument
379 struct bpf_stab *stab = container_of(map, struct bpf_stab, map); in __sock_map_lookup_elem()
383 if (unlikely(key >= map->max_entries)) in __sock_map_lookup_elem()
388 static void *sock_map_lookup(struct bpf_map *map, void *key) in sock_map_lookup() argument
392 sk = __sock_map_lookup_elem(map, *(u32 *)key); in sock_map_lookup()
400 static void *sock_map_lookup_sys(struct bpf_map *map, void *key) in sock_map_lookup_sys() argument
404 if (map->value_size != sizeof(u64)) in sock_map_lookup_sys()
407 sk = __sock_map_lookup_elem(map, *(u32 *)key); in sock_map_lookup_sys()
434 static void sock_map_delete_from_link(struct bpf_map *map, struct sock *sk, in sock_map_delete_from_link() argument
437 struct bpf_stab *stab = container_of(map, struct bpf_stab, map); in sock_map_delete_from_link()
442 static long sock_map_delete_elem(struct bpf_map *map, void *key) in sock_map_delete_elem() argument
444 struct bpf_stab *stab = container_of(map, struct bpf_stab, map); in sock_map_delete_elem()
448 if (unlikely(i >= map->max_entries)) in sock_map_delete_elem()
455 static int sock_map_get_next_key(struct bpf_map *map, void *key, void *next) in sock_map_get_next_key() argument
457 struct bpf_stab *stab = container_of(map, struct bpf_stab, map); in sock_map_get_next_key()
461 if (i == stab->map.max_entries - 1) in sock_map_get_next_key()
463 if (i >= stab->map.max_entries) in sock_map_get_next_key()
470 static int sock_map_update_common(struct bpf_map *map, u32 idx, in sock_map_update_common() argument
473 struct bpf_stab *stab = container_of(map, struct bpf_stab, map); in sock_map_update_common()
482 if (unlikely(idx >= map->max_entries)) in sock_map_update_common()
489 ret = sock_map_link(map, sk); in sock_map_update_common()
506 sock_map_add_link(psock, link, map, &stab->sks[idx]); in sock_map_update_common()
553 static int sock_hash_update_common(struct bpf_map *map, void *key,
556 int sock_map_update_elem_sys(struct bpf_map *map, void *key, void *value, in sock_map_update_elem_sys() argument
564 if (map->value_size == sizeof(u64)) in sock_map_update_elem_sys()
587 else if (map->map_type == BPF_MAP_TYPE_SOCKMAP) in sock_map_update_elem_sys()
588 ret = sock_map_update_common(map, *(u32 *)key, sk, flags); in sock_map_update_elem_sys()
590 ret = sock_hash_update_common(map, key, sk, flags); in sock_map_update_elem_sys()
597 static long sock_map_update_elem(struct bpf_map *map, void *key, in sock_map_update_elem() argument
613 else if (map->map_type == BPF_MAP_TYPE_SOCKMAP) in sock_map_update_elem()
614 ret = sock_map_update_common(map, *(u32 *)key, sk, flags); in sock_map_update_elem()
616 ret = sock_hash_update_common(map, key, sk, flags); in sock_map_update_elem()
623 struct bpf_map *, map, void *, key, u64, flags) in BPF_CALL_4()
629 return sock_map_update_common(map, *(u32 *)key, sops->sk, in BPF_CALL_4()
646 struct bpf_map *, map, u32, key, u64, flags) in BPF_CALL_4()
653 sk = __sock_map_lookup_elem(map, key); in BPF_CALL_4()
674 struct bpf_map *, map, u32, key, u64, flags) in BPF_CALL_4()
681 sk = __sock_map_lookup_elem(map, key); in BPF_CALL_4()
705 struct bpf_map *map; member
712 __bpf_md_ptr(struct bpf_map *, map);
718 struct bpf_map *map, void *key, in DEFINE_BPF_ITER_FUNC() argument
723 if (unlikely(info->index >= info->map->max_entries)) in DEFINE_BPF_ITER_FUNC()
726 info->sk = __sock_map_lookup_elem(info->map, info->index); in DEFINE_BPF_ITER_FUNC()
770 ctx.map = info->map; in sock_map_seq_show()
801 bpf_map_inc_with_uref(aux->map); in sock_map_init_seq_private()
802 info->map = aux->map; in sock_map_init_seq_private()
810 bpf_map_put_with_uref(info->map); in sock_map_fini_seq_private()
813 static u64 sock_map_mem_usage(const struct bpf_map *map) in sock_map_mem_usage() argument
817 usage += (u64)map->max_entries * sizeof(struct sock *); in sock_map_mem_usage()
859 struct bpf_map map; member
893 static struct sock *__sock_hash_lookup_elem(struct bpf_map *map, void *key) in __sock_hash_lookup_elem() argument
895 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in __sock_hash_lookup_elem()
896 u32 key_size = map->key_size, hash; in __sock_hash_lookup_elem()
916 static void sock_hash_delete_from_link(struct bpf_map *map, struct sock *sk, in sock_hash_delete_from_link() argument
919 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in sock_hash_delete_from_link()
932 elem->key, map->key_size); in sock_hash_delete_from_link()
941 static long sock_hash_delete_elem(struct bpf_map *map, void *key) in sock_hash_delete_elem() argument
943 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in sock_hash_delete_elem()
944 u32 hash, key_size = map->key_size; in sock_hash_delete_elem()
971 if (atomic_inc_return(&htab->count) > htab->map.max_entries) { in sock_hash_alloc_elem()
978 new = bpf_map_kmalloc_node(&htab->map, htab->elem_size, in sock_hash_alloc_elem()
980 htab->map.numa_node); in sock_hash_alloc_elem()
991 static int sock_hash_update_common(struct bpf_map *map, void *key, in sock_hash_update_common() argument
994 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in sock_hash_update_common()
995 u32 key_size = map->key_size, hash; in sock_hash_update_common()
1010 ret = sock_map_link(map, sk); in sock_hash_update_common()
1036 sock_map_add_link(psock, link, map, elem_new); in sock_hash_update_common()
1056 static int sock_hash_get_next_key(struct bpf_map *map, void *key, in sock_hash_get_next_key() argument
1059 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in sock_hash_get_next_key()
1061 u32 hash, key_size = map->key_size; in sock_hash_get_next_key()
1114 bpf_map_init_from_attr(&htab->map, attr); in sock_hash_alloc()
1116 htab->buckets_num = roundup_pow_of_two(htab->map.max_entries); in sock_hash_alloc()
1118 round_up(htab->map.key_size, 8); in sock_hash_alloc()
1127 htab->map.numa_node); in sock_hash_alloc()
1138 return &htab->map; in sock_hash_alloc()
1144 static void sock_hash_free(struct bpf_map *map) in sock_hash_free() argument
1146 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in sock_hash_free()
1197 static void *sock_hash_lookup_sys(struct bpf_map *map, void *key) in sock_hash_lookup_sys() argument
1201 if (map->value_size != sizeof(u64)) in sock_hash_lookup_sys()
1204 sk = __sock_hash_lookup_elem(map, key); in sock_hash_lookup_sys()
1212 static void *sock_hash_lookup(struct bpf_map *map, void *key) in sock_hash_lookup() argument
1216 sk = __sock_hash_lookup_elem(map, key); in sock_hash_lookup()
1224 static void sock_hash_release_progs(struct bpf_map *map) in sock_hash_release_progs() argument
1226 psock_progs_drop(&container_of(map, struct bpf_shtab, map)->progs); in sock_hash_release_progs()
1230 struct bpf_map *, map, void *, key, u64, flags) in BPF_CALL_4() argument
1236 return sock_hash_update_common(map, key, sops->sk, flags); in BPF_CALL_4()
1252 struct bpf_map *, map, void *, key, u64, flags) in BPF_CALL_4() argument
1259 sk = __sock_hash_lookup_elem(map, key); in BPF_CALL_4()
1280 struct bpf_map *, map, void *, key, u64, flags) in BPF_CALL_4() argument
1287 sk = __sock_hash_lookup_elem(map, key); in BPF_CALL_4()
1311 struct bpf_map *map; member
1383 ctx.map = info->map; in sock_hash_seq_show()
1414 bpf_map_inc_with_uref(aux->map); in sock_hash_init_seq_private()
1415 info->map = aux->map; in sock_hash_init_seq_private()
1416 info->htab = container_of(aux->map, struct bpf_shtab, map); in sock_hash_init_seq_private()
1424 bpf_map_put_with_uref(info->map); in sock_hash_fini_seq_private()
1427 static u64 sock_hash_mem_usage(const struct bpf_map *map) in sock_hash_mem_usage() argument
1429 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in sock_hash_mem_usage()
1461 static struct sk_psock_progs *sock_map_progs(struct bpf_map *map) in sock_map_progs() argument
1463 switch (map->map_type) { in sock_map_progs()
1465 return &container_of(map, struct bpf_stab, map)->progs; in sock_map_progs()
1467 return &container_of(map, struct bpf_shtab, map)->progs; in sock_map_progs()
1475 static int sock_map_prog_link_lookup(struct bpf_map *map, struct bpf_prog ***pprog, in sock_map_prog_link_lookup() argument
1478 struct sk_psock_progs *progs = sock_map_progs(map); in sock_map_prog_link_lookup()
1524 static int sock_map_prog_update(struct bpf_map *map, struct bpf_prog *prog, in sock_map_prog_update() argument
1532 ret = sock_map_prog_link_lookup(map, &pprog, &plink, which); in sock_map_prog_update()
1562 struct bpf_map *map; in sock_map_bpf_prog_query() local
1570 map = __bpf_map_get(f); in sock_map_bpf_prog_query()
1571 if (IS_ERR(map)) in sock_map_bpf_prog_query()
1572 return PTR_ERR(map); in sock_map_bpf_prog_query()
1576 ret = sock_map_prog_link_lookup(map, &pprog, NULL, attr->query.attach_type); in sock_map_bpf_prog_query()
1606 switch (link->map->map_type) { in sock_map_unlink()
1608 return sock_map_delete_from_link(link->map, sk, in sock_map_unlink()
1611 return sock_hash_delete_from_link(link->map, sk, in sock_map_unlink()
1711 struct bpf_map *map; member
1719 if (!sockmap_link->map) in sock_map_link_release()
1722 WARN_ON_ONCE(sock_map_prog_update(sockmap_link->map, NULL, link->prog, link, in sock_map_link_release()
1725 bpf_map_put_with_uref(sockmap_link->map); in sock_map_link_release()
1726 sockmap_link->map = NULL; in sock_map_link_release()
1768 if (!sockmap_link->map) { in sock_map_link_update_prog()
1773 ret = sock_map_prog_link_lookup(sockmap_link->map, &pprog, &plink, in sock_map_link_update_prog()
1806 if (sockmap_link->map) in sock_map_link_get_map_id()
1807 map_id = sockmap_link->map->id; in sock_map_link_get_map_id()
1847 struct bpf_map *map; in sock_map_link_create() local
1853 map = bpf_map_get_with_uref(attr->link_create.target_fd); in sock_map_link_create()
1854 if (IS_ERR(map)) in sock_map_link_create()
1855 return PTR_ERR(map); in sock_map_link_create()
1856 if (map->map_type != BPF_MAP_TYPE_SOCKMAP && map->map_type != BPF_MAP_TYPE_SOCKHASH) { in sock_map_link_create()
1870 sockmap_link->map = map; in sock_map_link_create()
1879 ret = sock_map_prog_update(map, prog, NULL, &sockmap_link->link, attach_type); in sock_map_link_create()
1898 bpf_map_put_with_uref(map); in sock_map_link_create()
1906 struct bpf_map *map; in sock_map_iter_attach_target() local
1909 if (!linfo->map.map_fd) in sock_map_iter_attach_target()
1912 map = bpf_map_get_with_uref(linfo->map.map_fd); in sock_map_iter_attach_target()
1913 if (IS_ERR(map)) in sock_map_iter_attach_target()
1914 return PTR_ERR(map); in sock_map_iter_attach_target()
1916 if (map->map_type != BPF_MAP_TYPE_SOCKMAP && in sock_map_iter_attach_target()
1917 map->map_type != BPF_MAP_TYPE_SOCKHASH) in sock_map_iter_attach_target()
1920 if (prog->aux->max_rdonly_access > map->key_size) { in sock_map_iter_attach_target()
1925 aux->map = map; in sock_map_iter_attach_target()
1929 bpf_map_put_with_uref(map); in sock_map_iter_attach_target()
1935 bpf_map_put_with_uref(aux->map); in sock_map_iter_detach_target()