@@ -326,20 +326,14 @@ static int map_create(__u32 type, const char *name, struct bpf_map_create_opts *
326
326
327
327
static int create_hash (void )
328
328
{
329
- struct bpf_map_create_opts map_opts = {
330
- .sz = sizeof (map_opts ),
331
- .map_flags = BPF_F_NO_PREALLOC ,
332
- };
329
+ LIBBPF_OPTS (bpf_map_create_opts , map_opts , .map_flags = BPF_F_NO_PREALLOC );
333
330
334
331
return map_create (BPF_MAP_TYPE_HASH , "hash" , & map_opts );
335
332
}
336
333
337
334
static int create_percpu_hash (void )
338
335
{
339
- struct bpf_map_create_opts map_opts = {
340
- .sz = sizeof (map_opts ),
341
- .map_flags = BPF_F_NO_PREALLOC ,
342
- };
336
+ LIBBPF_OPTS (bpf_map_create_opts , map_opts , .map_flags = BPF_F_NO_PREALLOC );
343
337
344
338
return map_create (BPF_MAP_TYPE_PERCPU_HASH , "percpu_hash" , & map_opts );
345
339
}
@@ -356,21 +350,17 @@ static int create_percpu_hash_prealloc(void)
356
350
357
351
static int create_lru_hash (__u32 type , __u32 map_flags )
358
352
{
359
- struct bpf_map_create_opts map_opts = {
360
- .sz = sizeof (map_opts ),
361
- .map_flags = map_flags ,
362
- };
353
+ LIBBPF_OPTS (bpf_map_create_opts , map_opts , .map_flags = map_flags );
363
354
364
355
return map_create (type , "lru_hash" , & map_opts );
365
356
}
366
357
367
358
static int create_hash_of_maps (void )
368
359
{
369
- struct bpf_map_create_opts map_opts = {
370
- .sz = sizeof (map_opts ),
360
+ LIBBPF_OPTS (bpf_map_create_opts , map_opts ,
371
361
.map_flags = BPF_F_NO_PREALLOC ,
372
362
.inner_map_fd = create_small_hash (),
373
- } ;
363
+ ) ;
374
364
int ret ;
375
365
376
366
ret = map_create_opts (BPF_MAP_TYPE_HASH_OF_MAPS , "hash_of_maps" ,
0 commit comments