@@ -330,35 +330,34 @@ static void cache_btf_id(struct bpf_iter_target_info *tinfo,
330
330
bool bpf_iter_prog_supported (struct bpf_prog * prog )
331
331
{
332
332
const char * attach_fname = prog -> aux -> attach_func_name ;
333
+ struct bpf_iter_target_info * tinfo = NULL , * iter ;
333
334
u32 prog_btf_id = prog -> aux -> attach_btf_id ;
334
335
const char * prefix = BPF_ITER_FUNC_PREFIX ;
335
- struct bpf_iter_target_info * tinfo ;
336
336
int prefix_len = strlen (prefix );
337
- bool supported = false;
338
337
339
338
if (strncmp (attach_fname , prefix , prefix_len ))
340
339
return false;
341
340
342
341
mutex_lock (& targets_mutex );
343
- list_for_each_entry (tinfo , & targets , list ) {
344
- if (tinfo -> btf_id && tinfo -> btf_id == prog_btf_id ) {
345
- supported = true ;
342
+ list_for_each_entry (iter , & targets , list ) {
343
+ if (iter -> btf_id && iter -> btf_id == prog_btf_id ) {
344
+ tinfo = iter ;
346
345
break ;
347
346
}
348
- if (!strcmp (attach_fname + prefix_len , tinfo -> reg_info -> target )) {
349
- cache_btf_id (tinfo , prog );
350
- supported = true ;
347
+ if (!strcmp (attach_fname + prefix_len , iter -> reg_info -> target )) {
348
+ cache_btf_id (iter , prog );
349
+ tinfo = iter ;
351
350
break ;
352
351
}
353
352
}
354
353
mutex_unlock (& targets_mutex );
355
354
356
- if (supported ) {
355
+ if (tinfo ) {
357
356
prog -> aux -> ctx_arg_info_size = tinfo -> reg_info -> ctx_arg_info_size ;
358
357
prog -> aux -> ctx_arg_info = tinfo -> reg_info -> ctx_arg_info ;
359
358
}
360
359
361
- return supported ;
360
+ return tinfo != NULL ;
362
361
}
363
362
364
363
const struct bpf_func_proto *
@@ -499,12 +498,11 @@ bool bpf_link_is_iter(struct bpf_link *link)
499
498
int bpf_iter_link_attach (const union bpf_attr * attr , bpfptr_t uattr ,
500
499
struct bpf_prog * prog )
501
500
{
501
+ struct bpf_iter_target_info * tinfo = NULL , * iter ;
502
502
struct bpf_link_primer link_primer ;
503
- struct bpf_iter_target_info * tinfo ;
504
503
union bpf_iter_link_info linfo ;
505
504
struct bpf_iter_link * link ;
506
505
u32 prog_btf_id , linfo_len ;
507
- bool existed = false;
508
506
bpfptr_t ulinfo ;
509
507
int err ;
510
508
@@ -530,14 +528,14 @@ int bpf_iter_link_attach(const union bpf_attr *attr, bpfptr_t uattr,
530
528
531
529
prog_btf_id = prog -> aux -> attach_btf_id ;
532
530
mutex_lock (& targets_mutex );
533
- list_for_each_entry (tinfo , & targets , list ) {
534
- if (tinfo -> btf_id == prog_btf_id ) {
535
- existed = true ;
531
+ list_for_each_entry (iter , & targets , list ) {
532
+ if (iter -> btf_id == prog_btf_id ) {
533
+ tinfo = iter ;
536
534
break ;
537
535
}
538
536
}
539
537
mutex_unlock (& targets_mutex );
540
- if (!existed )
538
+ if (!tinfo )
541
539
return - ENOENT ;
542
540
543
541
link = kzalloc (sizeof (* link ), GFP_USER | __GFP_NOWARN );
0 commit comments