• Home
  • Raw
  • Download

Lines Matching refs:map

18 	struct bpf_map map;  member
27 static int sock_map_prog_update(struct bpf_map *map, struct bpf_prog *prog,
29 static struct sk_psock_progs *sock_map_progs(struct bpf_map *map);
48 bpf_map_init_from_attr(&stab->map, attr); in sock_map_alloc()
51 stab->sks = bpf_map_area_alloc((u64) stab->map.max_entries * in sock_map_alloc()
53 stab->map.numa_node); in sock_map_alloc()
59 return &stab->map; in sock_map_alloc()
65 struct bpf_map *map; in sock_map_get_from_fd() local
73 map = __bpf_map_get(f); in sock_map_get_from_fd()
74 if (IS_ERR(map)) in sock_map_get_from_fd()
75 return PTR_ERR(map); in sock_map_get_from_fd()
76 ret = sock_map_prog_update(map, prog, NULL, attr->attach_type); in sock_map_get_from_fd()
85 struct bpf_map *map; in sock_map_prog_detach() local
93 map = __bpf_map_get(f); in sock_map_prog_detach()
94 if (IS_ERR(map)) in sock_map_prog_detach()
95 return PTR_ERR(map); in sock_map_prog_detach()
108 ret = sock_map_prog_update(map, NULL, prog, attr->attach_type); in sock_map_prog_detach()
132 struct bpf_map *map, void *link_raw) in sock_map_add_link() argument
135 link->map = map; in sock_map_add_link()
150 struct bpf_map *map = link->map; in sock_map_del_link() local
151 struct sk_psock_progs *progs = sock_map_progs(map); in sock_map_del_link()
215 static int sock_map_link(struct bpf_map *map, struct sock *sk) in sock_map_link() argument
217 struct sk_psock_progs *progs = sock_map_progs(map); in sock_map_link()
277 psock = sk_psock_init(sk, map->numa_node); in sock_map_link()
334 static void sock_map_free(struct bpf_map *map) in sock_map_free() argument
336 struct bpf_stab *stab = container_of(map, struct bpf_stab, map); in sock_map_free()
344 for (i = 0; i < stab->map.max_entries; i++) { in sock_map_free()
367 static void sock_map_release_progs(struct bpf_map *map) in sock_map_release_progs() argument
369 psock_progs_drop(&container_of(map, struct bpf_stab, map)->progs); in sock_map_release_progs()
372 static struct sock *__sock_map_lookup_elem(struct bpf_map *map, u32 key) in __sock_map_lookup_elem() argument
374 struct bpf_stab *stab = container_of(map, struct bpf_stab, map); in __sock_map_lookup_elem()
378 if (unlikely(key >= map->max_entries)) in __sock_map_lookup_elem()
383 static void *sock_map_lookup(struct bpf_map *map, void *key) in sock_map_lookup() argument
387 sk = __sock_map_lookup_elem(map, *(u32 *)key); in sock_map_lookup()
395 static void *sock_map_lookup_sys(struct bpf_map *map, void *key) in sock_map_lookup_sys() argument
399 if (map->value_size != sizeof(u64)) in sock_map_lookup_sys()
402 sk = __sock_map_lookup_elem(map, *(u32 *)key); in sock_map_lookup_sys()
430 static void sock_map_delete_from_link(struct bpf_map *map, struct sock *sk, in sock_map_delete_from_link() argument
433 struct bpf_stab *stab = container_of(map, struct bpf_stab, map); in sock_map_delete_from_link()
438 static int sock_map_delete_elem(struct bpf_map *map, void *key) in sock_map_delete_elem() argument
440 struct bpf_stab *stab = container_of(map, struct bpf_stab, map); in sock_map_delete_elem()
444 if (unlikely(i >= map->max_entries)) in sock_map_delete_elem()
451 static int sock_map_get_next_key(struct bpf_map *map, void *key, void *next) in sock_map_get_next_key() argument
453 struct bpf_stab *stab = container_of(map, struct bpf_stab, map); in sock_map_get_next_key()
457 if (i == stab->map.max_entries - 1) in sock_map_get_next_key()
459 if (i >= stab->map.max_entries) in sock_map_get_next_key()
466 static int sock_map_update_common(struct bpf_map *map, u32 idx, in sock_map_update_common() argument
469 struct bpf_stab *stab = container_of(map, struct bpf_stab, map); in sock_map_update_common()
478 if (unlikely(idx >= map->max_entries)) in sock_map_update_common()
485 ret = sock_map_link(map, sk); in sock_map_update_common()
502 sock_map_add_link(psock, link, map, &stab->sks[idx]); in sock_map_update_common()
550 static int sock_hash_update_common(struct bpf_map *map, void *key,
553 int sock_map_update_elem_sys(struct bpf_map *map, void *key, void *value, in sock_map_update_elem_sys() argument
561 if (map->value_size == sizeof(u64)) in sock_map_update_elem_sys()
584 else if (map->map_type == BPF_MAP_TYPE_SOCKMAP) in sock_map_update_elem_sys()
585 ret = sock_map_update_common(map, *(u32 *)key, sk, flags); in sock_map_update_elem_sys()
587 ret = sock_hash_update_common(map, key, sk, flags); in sock_map_update_elem_sys()
594 static int sock_map_update_elem(struct bpf_map *map, void *key, in sock_map_update_elem() argument
610 else if (map->map_type == BPF_MAP_TYPE_SOCKMAP) in sock_map_update_elem()
611 ret = sock_map_update_common(map, *(u32 *)key, sk, flags); in sock_map_update_elem()
613 ret = sock_hash_update_common(map, key, sk, flags); in sock_map_update_elem()
620 struct bpf_map *, map, void *, key, u64, flags) in BPF_CALL_4()
626 return sock_map_update_common(map, *(u32 *)key, sops->sk, in BPF_CALL_4()
643 struct bpf_map *, map, u32, key, u64, flags) in BPF_CALL_4()
650 sk = __sock_map_lookup_elem(map, key); in BPF_CALL_4()
669 struct bpf_map *, map, u32, key, u64, flags) in BPF_CALL_4()
676 sk = __sock_map_lookup_elem(map, key); in BPF_CALL_4()
698 struct bpf_map *map; member
705 __bpf_md_ptr(struct bpf_map *, map);
711 struct bpf_map *map, void *key, in DEFINE_BPF_ITER_FUNC() argument
716 if (unlikely(info->index >= info->map->max_entries)) in DEFINE_BPF_ITER_FUNC()
719 info->sk = __sock_map_lookup_elem(info->map, info->index); in DEFINE_BPF_ITER_FUNC()
763 ctx.map = info->map; in sock_map_seq_show()
794 bpf_map_inc_with_uref(aux->map); in sock_map_init_seq_private()
795 info->map = aux->map; in sock_map_init_seq_private()
803 bpf_map_put_with_uref(info->map); in sock_map_fini_seq_private()
844 struct bpf_map map; member
878 static struct sock *__sock_hash_lookup_elem(struct bpf_map *map, void *key) in __sock_hash_lookup_elem() argument
880 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in __sock_hash_lookup_elem()
881 u32 key_size = map->key_size, hash; in __sock_hash_lookup_elem()
901 static void sock_hash_delete_from_link(struct bpf_map *map, struct sock *sk, in sock_hash_delete_from_link() argument
904 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in sock_hash_delete_from_link()
917 elem->key, map->key_size); in sock_hash_delete_from_link()
926 static int sock_hash_delete_elem(struct bpf_map *map, void *key) in sock_hash_delete_elem() argument
928 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in sock_hash_delete_elem()
929 u32 hash, key_size = map->key_size; in sock_hash_delete_elem()
956 if (atomic_inc_return(&htab->count) > htab->map.max_entries) { in sock_hash_alloc_elem()
963 new = bpf_map_kmalloc_node(&htab->map, htab->elem_size, in sock_hash_alloc_elem()
965 htab->map.numa_node); in sock_hash_alloc_elem()
976 static int sock_hash_update_common(struct bpf_map *map, void *key, in sock_hash_update_common() argument
979 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in sock_hash_update_common()
980 u32 key_size = map->key_size, hash; in sock_hash_update_common()
995 ret = sock_map_link(map, sk); in sock_hash_update_common()
1021 sock_map_add_link(psock, link, map, elem_new); in sock_hash_update_common()
1041 static int sock_hash_get_next_key(struct bpf_map *map, void *key, in sock_hash_get_next_key() argument
1044 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in sock_hash_get_next_key()
1046 u32 hash, key_size = map->key_size; in sock_hash_get_next_key()
1101 bpf_map_init_from_attr(&htab->map, attr); in sock_hash_alloc()
1103 htab->buckets_num = roundup_pow_of_two(htab->map.max_entries); in sock_hash_alloc()
1105 round_up(htab->map.key_size, 8); in sock_hash_alloc()
1114 htab->map.numa_node); in sock_hash_alloc()
1125 return &htab->map; in sock_hash_alloc()
1131 static void sock_hash_free(struct bpf_map *map) in sock_hash_free() argument
1133 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in sock_hash_free()
1183 static void *sock_hash_lookup_sys(struct bpf_map *map, void *key) in sock_hash_lookup_sys() argument
1187 if (map->value_size != sizeof(u64)) in sock_hash_lookup_sys()
1190 sk = __sock_hash_lookup_elem(map, key); in sock_hash_lookup_sys()
1198 static void *sock_hash_lookup(struct bpf_map *map, void *key) in sock_hash_lookup() argument
1202 sk = __sock_hash_lookup_elem(map, key); in sock_hash_lookup()
1210 static void sock_hash_release_progs(struct bpf_map *map) in sock_hash_release_progs() argument
1212 psock_progs_drop(&container_of(map, struct bpf_shtab, map)->progs); in sock_hash_release_progs()
1216 struct bpf_map *, map, void *, key, u64, flags) in BPF_CALL_4() argument
1222 return sock_hash_update_common(map, key, sops->sk, flags); in BPF_CALL_4()
1238 struct bpf_map *, map, void *, key, u64, flags) in BPF_CALL_4() argument
1245 sk = __sock_hash_lookup_elem(map, key); in BPF_CALL_4()
1264 struct bpf_map *, map, void *, key, u64, flags) in BPF_CALL_4() argument
1271 sk = __sock_hash_lookup_elem(map, key); in BPF_CALL_4()
1293 struct bpf_map *map; member
1365 ctx.map = info->map; in sock_hash_seq_show()
1396 bpf_map_inc_with_uref(aux->map); in sock_hash_init_seq_private()
1397 info->map = aux->map; in sock_hash_init_seq_private()
1398 info->htab = container_of(aux->map, struct bpf_shtab, map); in sock_hash_init_seq_private()
1406 bpf_map_put_with_uref(info->map); in sock_hash_fini_seq_private()
1433 static struct sk_psock_progs *sock_map_progs(struct bpf_map *map) in sock_map_progs() argument
1435 switch (map->map_type) { in sock_map_progs()
1437 return &container_of(map, struct bpf_stab, map)->progs; in sock_map_progs()
1439 return &container_of(map, struct bpf_shtab, map)->progs; in sock_map_progs()
1447 static int sock_map_prog_update(struct bpf_map *map, struct bpf_prog *prog, in sock_map_prog_update() argument
1450 struct sk_psock_progs *progs = sock_map_progs(map); in sock_map_prog_update()
1488 switch (link->map->map_type) { in sock_map_unlink()
1490 return sock_map_delete_from_link(link->map, sk, in sock_map_unlink()
1493 return sock_hash_delete_from_link(link->map, sk, in sock_map_unlink()
1566 struct bpf_map *map; in sock_map_iter_attach_target() local
1569 if (!linfo->map.map_fd) in sock_map_iter_attach_target()
1572 map = bpf_map_get_with_uref(linfo->map.map_fd); in sock_map_iter_attach_target()
1573 if (IS_ERR(map)) in sock_map_iter_attach_target()
1574 return PTR_ERR(map); in sock_map_iter_attach_target()
1576 if (map->map_type != BPF_MAP_TYPE_SOCKMAP && in sock_map_iter_attach_target()
1577 map->map_type != BPF_MAP_TYPE_SOCKHASH) in sock_map_iter_attach_target()
1580 if (prog->aux->max_rdonly_access > map->key_size) { in sock_map_iter_attach_target()
1585 aux->map = map; in sock_map_iter_attach_target()
1589 bpf_map_put_with_uref(map); in sock_map_iter_attach_target()
1595 bpf_map_put_with_uref(aux->map); in sock_map_iter_detach_target()