@@ -40,7 +40,7 @@ static u32 hash(struct bpf_bloom_filter *bloom, void *value,
40
40
return h & bloom -> bitset_mask ;
41
41
}
42
42
43
- static int peek_elem (struct bpf_map * map , void * value )
43
+ static int bloom_map_peek_elem (struct bpf_map * map , void * value )
44
44
{
45
45
struct bpf_bloom_filter * bloom =
46
46
container_of (map , struct bpf_bloom_filter , map );
@@ -55,7 +55,7 @@ static int peek_elem(struct bpf_map *map, void *value)
55
55
return 0 ;
56
56
}
57
57
58
- static int push_elem (struct bpf_map * map , void * value , u64 flags )
58
+ static int bloom_map_push_elem (struct bpf_map * map , void * value , u64 flags )
59
59
{
60
60
struct bpf_bloom_filter * bloom =
61
61
container_of (map , struct bpf_bloom_filter , map );
@@ -72,12 +72,12 @@ static int push_elem(struct bpf_map *map, void *value, u64 flags)
72
72
return 0 ;
73
73
}
74
74
75
- static int pop_elem (struct bpf_map * map , void * value )
75
+ static int bloom_map_pop_elem (struct bpf_map * map , void * value )
76
76
{
77
77
return - EOPNOTSUPP ;
78
78
}
79
79
80
- static struct bpf_map * map_alloc (union bpf_attr * attr )
80
+ static struct bpf_map * bloom_map_alloc (union bpf_attr * attr )
81
81
{
82
82
u32 bitset_bytes , bitset_mask , nr_hash_funcs , nr_bits ;
83
83
int numa_node = bpf_map_attr_numa_node (attr );
@@ -90,11 +90,13 @@ static struct bpf_map *map_alloc(union bpf_attr *attr)
90
90
attr -> max_entries == 0 ||
91
91
attr -> map_flags & ~BLOOM_CREATE_FLAG_MASK ||
92
92
!bpf_map_flags_access_ok (attr -> map_flags ) ||
93
+ /* The lower 4 bits of map_extra (0xF) specify the number
94
+ * of hash functions
95
+ */
93
96
(attr -> map_extra & ~0xF ))
94
97
return ERR_PTR (- EINVAL );
95
98
96
- /* The lower 4 bits of map_extra specify the number of hash functions */
97
- nr_hash_funcs = attr -> map_extra & 0xF ;
99
+ nr_hash_funcs = attr -> map_extra ;
98
100
if (nr_hash_funcs == 0 )
99
101
/* Default to using 5 hash functions if unspecified */
100
102
nr_hash_funcs = 5 ;
@@ -150,46 +152,47 @@ static struct bpf_map *map_alloc(union bpf_attr *attr)
150
152
return & bloom -> map ;
151
153
}
152
154
153
- static void map_free (struct bpf_map * map )
155
+ static void bloom_map_free (struct bpf_map * map )
154
156
{
155
157
struct bpf_bloom_filter * bloom =
156
158
container_of (map , struct bpf_bloom_filter , map );
157
159
158
160
bpf_map_area_free (bloom );
159
161
}
160
162
161
- static void * lookup_elem (struct bpf_map * map , void * key )
163
+ static void * bloom_map_lookup_elem (struct bpf_map * map , void * key )
162
164
{
163
165
/* The eBPF program should use map_peek_elem instead */
164
166
return ERR_PTR (- EINVAL );
165
167
}
166
168
167
- static int update_elem (struct bpf_map * map , void * key ,
168
- void * value , u64 flags )
169
+ static int bloom_map_update_elem (struct bpf_map * map , void * key ,
170
+ void * value , u64 flags )
169
171
{
170
172
/* The eBPF program should use map_push_elem instead */
171
173
return - EINVAL ;
172
174
}
173
175
174
- static int check_btf (const struct bpf_map * map , const struct btf * btf ,
175
- const struct btf_type * key_type ,
176
- const struct btf_type * value_type )
176
+ static int bloom_map_check_btf (const struct bpf_map * map ,
177
+ const struct btf * btf ,
178
+ const struct btf_type * key_type ,
179
+ const struct btf_type * value_type )
177
180
{
178
181
/* Bloom filter maps are keyless */
179
182
return btf_type_is_void (key_type ) ? 0 : - EINVAL ;
180
183
}
181
184
182
- static int bpf_bloom_btf_id ;
185
+ static int bpf_bloom_map_btf_id ;
183
186
const struct bpf_map_ops bloom_filter_map_ops = {
184
187
.map_meta_equal = bpf_map_meta_equal ,
185
- .map_alloc = map_alloc ,
186
- .map_free = map_free ,
187
- .map_push_elem = push_elem ,
188
- .map_peek_elem = peek_elem ,
189
- .map_pop_elem = pop_elem ,
190
- .map_lookup_elem = lookup_elem ,
191
- .map_update_elem = update_elem ,
192
- .map_check_btf = check_btf ,
188
+ .map_alloc = bloom_map_alloc ,
189
+ .map_free = bloom_map_free ,
190
+ .map_push_elem = bloom_map_push_elem ,
191
+ .map_peek_elem = bloom_map_peek_elem ,
192
+ .map_pop_elem = bloom_map_pop_elem ,
193
+ .map_lookup_elem = bloom_map_lookup_elem ,
194
+ .map_update_elem = bloom_map_update_elem ,
195
+ .map_check_btf = bloom_map_check_btf ,
193
196
.map_btf_name = "bpf_bloom_filter" ,
194
- .map_btf_id = & bpf_bloom_btf_id ,
197
+ .map_btf_id = & bpf_bloom_map_btf_id ,
195
198
};
0 commit comments