@@ -468,6 +468,7 @@ static void test_bpf_hash_map(void)
468468 DECLARE_LIBBPF_OPTS (bpf_iter_attach_opts , opts );
469469 struct bpf_iter_bpf_hash_map * skel ;
470470 int err , i , len , map_fd , iter_fd ;
471+ union bpf_iter_link_info linfo ;
471472 __u64 val , expected_val = 0 ;
472473 struct bpf_link * link ;
473474 struct key_t {
@@ -490,13 +491,16 @@ static void test_bpf_hash_map(void)
490491 goto out ;
491492
492493 /* iterator with hashmap2 and hashmap3 should fail */
493- opts .map_fd = bpf_map__fd (skel -> maps .hashmap2 );
494+ memset (& linfo , 0 , sizeof (linfo ));
495+ linfo .map .map_fd = bpf_map__fd (skel -> maps .hashmap2 );
496+ opts .link_info = & linfo ;
497+ opts .link_info_len = sizeof (linfo );
494498 link = bpf_program__attach_iter (skel -> progs .dump_bpf_hash_map , & opts );
495499 if (CHECK (!IS_ERR (link ), "attach_iter" ,
496500 "attach_iter for hashmap2 unexpected succeeded\n" ))
497501 goto out ;
498502
499- opts .map_fd = bpf_map__fd (skel -> maps .hashmap3 );
503+ linfo . map .map_fd = bpf_map__fd (skel -> maps .hashmap3 );
500504 link = bpf_program__attach_iter (skel -> progs .dump_bpf_hash_map , & opts );
501505 if (CHECK (!IS_ERR (link ), "attach_iter" ,
502506 "attach_iter for hashmap3 unexpected succeeded\n" ))
@@ -519,7 +523,7 @@ static void test_bpf_hash_map(void)
519523 goto out ;
520524 }
521525
522- opts .map_fd = map_fd ;
526+ linfo . map .map_fd = map_fd ;
523527 link = bpf_program__attach_iter (skel -> progs .dump_bpf_hash_map , & opts );
524528 if (CHECK (IS_ERR (link ), "attach_iter" , "attach_iter failed\n" ))
525529 goto out ;
@@ -562,6 +566,7 @@ static void test_bpf_percpu_hash_map(void)
562566 DECLARE_LIBBPF_OPTS (bpf_iter_attach_opts , opts );
563567 struct bpf_iter_bpf_percpu_hash_map * skel ;
564568 int err , i , j , len , map_fd , iter_fd ;
569+ union bpf_iter_link_info linfo ;
565570 __u32 expected_val = 0 ;
566571 struct bpf_link * link ;
567572 struct key_t {
@@ -606,7 +611,10 @@ static void test_bpf_percpu_hash_map(void)
606611 goto out ;
607612 }
608613
609- opts .map_fd = map_fd ;
614+ memset (& linfo , 0 , sizeof (linfo ));
615+ linfo .map .map_fd = map_fd ;
616+ opts .link_info = & linfo ;
617+ opts .link_info_len = sizeof (linfo );
610618 link = bpf_program__attach_iter (skel -> progs .dump_bpf_percpu_hash_map , & opts );
611619 if (CHECK (IS_ERR (link ), "attach_iter" , "attach_iter failed\n" ))
612620 goto out ;
@@ -649,6 +657,7 @@ static void test_bpf_array_map(void)
649657 DECLARE_LIBBPF_OPTS (bpf_iter_attach_opts , opts );
650658 __u32 expected_key = 0 , res_first_key ;
651659 struct bpf_iter_bpf_array_map * skel ;
660+ union bpf_iter_link_info linfo ;
652661 int err , i , map_fd , iter_fd ;
653662 struct bpf_link * link ;
654663 char buf [64 ] = {};
@@ -673,7 +682,10 @@ static void test_bpf_array_map(void)
673682 goto out ;
674683 }
675684
676- opts .map_fd = map_fd ;
685+ memset (& linfo , 0 , sizeof (linfo ));
686+ linfo .map .map_fd = map_fd ;
687+ opts .link_info = & linfo ;
688+ opts .link_info_len = sizeof (linfo );
677689 link = bpf_program__attach_iter (skel -> progs .dump_bpf_array_map , & opts );
678690 if (CHECK (IS_ERR (link ), "attach_iter" , "attach_iter failed\n" ))
679691 goto out ;
@@ -730,6 +742,7 @@ static void test_bpf_percpu_array_map(void)
730742 DECLARE_LIBBPF_OPTS (bpf_iter_attach_opts , opts );
731743 struct bpf_iter_bpf_percpu_array_map * skel ;
732744 __u32 expected_key = 0 , expected_val = 0 ;
745+ union bpf_iter_link_info linfo ;
733746 int err , i , j , map_fd , iter_fd ;
734747 struct bpf_link * link ;
735748 char buf [64 ];
@@ -765,7 +778,10 @@ static void test_bpf_percpu_array_map(void)
765778 goto out ;
766779 }
767780
768- opts .map_fd = map_fd ;
781+ memset (& linfo , 0 , sizeof (linfo ));
782+ linfo .map .map_fd = map_fd ;
783+ opts .link_info = & linfo ;
784+ opts .link_info_len = sizeof (linfo );
769785 link = bpf_program__attach_iter (skel -> progs .dump_bpf_percpu_array_map , & opts );
770786 if (CHECK (IS_ERR (link ), "attach_iter" , "attach_iter failed\n" ))
771787 goto out ;
@@ -803,6 +819,7 @@ static void test_bpf_sk_storage_map(void)
803819 DECLARE_LIBBPF_OPTS (bpf_iter_attach_opts , opts );
804820 int err , i , len , map_fd , iter_fd , num_sockets ;
805821 struct bpf_iter_bpf_sk_storage_map * skel ;
822+ union bpf_iter_link_info linfo ;
806823 int sock_fd [3 ] = {-1 , -1 , -1 };
807824 __u32 val , expected_val = 0 ;
808825 struct bpf_link * link ;
@@ -829,7 +846,10 @@ static void test_bpf_sk_storage_map(void)
829846 goto out ;
830847 }
831848
832- opts .map_fd = map_fd ;
849+ memset (& linfo , 0 , sizeof (linfo ));
850+ linfo .map .map_fd = map_fd ;
851+ opts .link_info = & linfo ;
852+ opts .link_info_len = sizeof (linfo );
833853 link = bpf_program__attach_iter (skel -> progs .dump_bpf_sk_storage_map , & opts );
834854 if (CHECK (IS_ERR (link ), "attach_iter" , "attach_iter failed\n" ))
835855 goto out ;
@@ -871,14 +891,18 @@ static void test_rdonly_buf_out_of_bound(void)
871891{
872892 DECLARE_LIBBPF_OPTS (bpf_iter_attach_opts , opts );
873893 struct bpf_iter_test_kern5 * skel ;
894+ union bpf_iter_link_info linfo ;
874895 struct bpf_link * link ;
875896
876897 skel = bpf_iter_test_kern5__open_and_load ();
877898 if (CHECK (!skel , "bpf_iter_test_kern5__open_and_load" ,
878899 "skeleton open_and_load failed\n" ))
879900 return ;
880901
881- opts .map_fd = bpf_map__fd (skel -> maps .hashmap1 );
902+ memset (& linfo , 0 , sizeof (linfo ));
903+ linfo .map .map_fd = bpf_map__fd (skel -> maps .hashmap1 );
904+ opts .link_info = & linfo ;
905+ opts .link_info_len = sizeof (linfo );
882906 link = bpf_program__attach_iter (skel -> progs .dump_bpf_hash_map , & opts );
883907 if (CHECK (!IS_ERR (link ), "attach_iter" , "unexpected success\n" ))
884908 bpf_link__destroy (link );
0 commit comments