@@ -140,14 +140,14 @@ static void test_kprobe_fill_link_info(struct test_fill_link_info *skel,
140
140
.retprobe = type == BPF_PERF_EVENT_KRETPROBE ,
141
141
);
142
142
ssize_t entry_offset = 0 ;
143
+ struct bpf_link * link ;
143
144
int link_fd , err ;
144
145
145
- skel -> links .kprobe_run = bpf_program__attach_kprobe_opts (skel -> progs .kprobe_run ,
146
- KPROBE_FUNC , & opts );
147
- if (!ASSERT_OK_PTR (skel -> links .kprobe_run , "attach_kprobe" ))
146
+ link = bpf_program__attach_kprobe_opts (skel -> progs .kprobe_run , KPROBE_FUNC , & opts );
147
+ if (!ASSERT_OK_PTR (link , "attach_kprobe" ))
148
148
return ;
149
149
150
- link_fd = bpf_link__fd (skel -> links . kprobe_run );
150
+ link_fd = bpf_link__fd (link );
151
151
if (!invalid ) {
152
152
/* See also arch_adjust_kprobe_addr(). */
153
153
if (skel -> kconfig -> CONFIG_X86_KERNEL_IBT )
@@ -157,39 +157,41 @@ static void test_kprobe_fill_link_info(struct test_fill_link_info *skel,
157
157
} else {
158
158
kprobe_fill_invalid_user_buffer (link_fd );
159
159
}
160
- bpf_link__detach ( skel -> links . kprobe_run );
160
+ bpf_link__destroy ( link );
161
161
}
162
162
163
163
static void test_tp_fill_link_info (struct test_fill_link_info * skel )
164
164
{
165
+ struct bpf_link * link ;
165
166
int link_fd , err ;
166
167
167
- skel -> links . tp_run = bpf_program__attach_tracepoint (skel -> progs .tp_run , TP_CAT , TP_NAME );
168
- if (!ASSERT_OK_PTR (skel -> links . tp_run , "attach_tp" ))
168
+ link = bpf_program__attach_tracepoint (skel -> progs .tp_run , TP_CAT , TP_NAME );
169
+ if (!ASSERT_OK_PTR (link , "attach_tp" ))
169
170
return ;
170
171
171
- link_fd = bpf_link__fd (skel -> links . tp_run );
172
+ link_fd = bpf_link__fd (link );
172
173
err = verify_perf_link_info (link_fd , BPF_PERF_EVENT_TRACEPOINT , 0 , 0 , 0 );
173
174
ASSERT_OK (err , "verify_perf_link_info" );
174
- bpf_link__detach ( skel -> links . tp_run );
175
+ bpf_link__destroy ( link );
175
176
}
176
177
177
178
static void test_uprobe_fill_link_info (struct test_fill_link_info * skel ,
178
179
enum bpf_perf_event_type type )
179
180
{
181
+ struct bpf_link * link ;
180
182
int link_fd , err ;
181
183
182
- skel -> links . uprobe_run = bpf_program__attach_uprobe (skel -> progs .uprobe_run ,
183
- type == BPF_PERF_EVENT_URETPROBE ,
184
- 0 , /* self pid */
185
- UPROBE_FILE , uprobe_offset );
186
- if (!ASSERT_OK_PTR (skel -> links . uprobe_run , "attach_uprobe" ))
184
+ link = bpf_program__attach_uprobe (skel -> progs .uprobe_run ,
185
+ type == BPF_PERF_EVENT_URETPROBE ,
186
+ 0 , /* self pid */
187
+ UPROBE_FILE , uprobe_offset );
188
+ if (!ASSERT_OK_PTR (link , "attach_uprobe" ))
187
189
return ;
188
190
189
- link_fd = bpf_link__fd (skel -> links . uprobe_run );
191
+ link_fd = bpf_link__fd (link );
190
192
err = verify_perf_link_info (link_fd , type , 0 , uprobe_offset , 0 );
191
193
ASSERT_OK (err , "verify_perf_link_info" );
192
- bpf_link__detach ( skel -> links . uprobe_run );
194
+ bpf_link__destroy ( link );
193
195
}
194
196
195
197
static int verify_kmulti_link_info (int fd , bool retprobe )
@@ -278,24 +280,24 @@ static void test_kprobe_multi_fill_link_info(struct test_fill_link_info *skel,
278
280
bool retprobe , bool invalid )
279
281
{
280
282
LIBBPF_OPTS (bpf_kprobe_multi_opts , opts );
283
+ struct bpf_link * link ;
281
284
int link_fd , err ;
282
285
283
286
opts .syms = kmulti_syms ;
284
287
opts .cnt = KMULTI_CNT ;
285
288
opts .retprobe = retprobe ;
286
- skel -> links .kmulti_run = bpf_program__attach_kprobe_multi_opts (skel -> progs .kmulti_run ,
287
- NULL , & opts );
288
- if (!ASSERT_OK_PTR (skel -> links .kmulti_run , "attach_kprobe_multi" ))
289
+ link = bpf_program__attach_kprobe_multi_opts (skel -> progs .kmulti_run , NULL , & opts );
290
+ if (!ASSERT_OK_PTR (link , "attach_kprobe_multi" ))
289
291
return ;
290
292
291
- link_fd = bpf_link__fd (skel -> links . kmulti_run );
293
+ link_fd = bpf_link__fd (link );
292
294
if (!invalid ) {
293
295
err = verify_kmulti_link_info (link_fd , retprobe );
294
296
ASSERT_OK (err , "verify_kmulti_link_info" );
295
297
} else {
296
298
verify_kmulti_invalid_user_buffer (link_fd );
297
299
}
298
- bpf_link__detach ( skel -> links . kmulti_run );
300
+ bpf_link__destroy ( link );
299
301
}
300
302
301
303
void test_fill_link_info (void )
0 commit comments