@@ -447,12 +447,15 @@ LIBBPF_API struct bpf_link *
447
447
bpf_program__attach (const struct bpf_program * prog );
448
448
449
449
struct bpf_perf_event_opts {
450
- /* size of this struct, for forward/backward compatiblity */
450
+ /* size of this struct, for forward/backward compatibility */
451
451
size_t sz ;
452
452
/* custom user-provided value fetchable through bpf_get_attach_cookie() */
453
453
__u64 bpf_cookie ;
454
+ /* don't use BPF link when attach BPF program */
455
+ bool force_ioctl_attach ;
456
+ size_t :0 ;
454
457
};
455
- #define bpf_perf_event_opts__last_field bpf_cookie
458
+ #define bpf_perf_event_opts__last_field force_ioctl_attach
456
459
457
460
LIBBPF_API struct bpf_link *
458
461
bpf_program__attach_perf_event (const struct bpf_program * prog , int pfd );
@@ -461,18 +464,37 @@ LIBBPF_API struct bpf_link *
461
464
bpf_program__attach_perf_event_opts (const struct bpf_program * prog , int pfd ,
462
465
const struct bpf_perf_event_opts * opts );
463
466
467
+ /**
468
+ * enum probe_attach_mode - the mode to attach kprobe/uprobe
469
+ *
470
+ * force libbpf to attach kprobe/uprobe in specific mode, -ENOTSUP will
471
+ * be returned if it is not supported by the kernel.
472
+ */
473
+ enum probe_attach_mode {
474
+ /* attach probe in latest supported mode by kernel */
475
+ PROBE_ATTACH_MODE_DEFAULT = 0 ,
476
+ /* attach probe in legacy mode, using debugfs/tracefs */
477
+ PROBE_ATTACH_MODE_LEGACY ,
478
+ /* create perf event with perf_event_open() syscall */
479
+ PROBE_ATTACH_MODE_PERF ,
480
+ /* attach probe with BPF link */
481
+ PROBE_ATTACH_MODE_LINK ,
482
+ };
483
+
464
484
struct bpf_kprobe_opts {
465
- /* size of this struct, for forward/backward compatiblity */
485
+ /* size of this struct, for forward/backward compatibility */
466
486
size_t sz ;
467
487
/* custom user-provided value fetchable through bpf_get_attach_cookie() */
468
488
__u64 bpf_cookie ;
469
489
/* function's offset to install kprobe to */
470
490
size_t offset ;
471
491
/* kprobe is return probe */
472
492
bool retprobe ;
493
+ /* kprobe attach mode */
494
+ enum probe_attach_mode attach_mode ;
473
495
size_t :0 ;
474
496
};
475
- #define bpf_kprobe_opts__last_field retprobe
497
+ #define bpf_kprobe_opts__last_field attach_mode
476
498
477
499
LIBBPF_API struct bpf_link *
478
500
bpf_program__attach_kprobe (const struct bpf_program * prog , bool retprobe ,
@@ -506,7 +528,7 @@ bpf_program__attach_kprobe_multi_opts(const struct bpf_program *prog,
506
528
const struct bpf_kprobe_multi_opts * opts );
507
529
508
530
struct bpf_ksyscall_opts {
509
- /* size of this struct, for forward/backward compatiblity */
531
+ /* size of this struct, for forward/backward compatibility */
510
532
size_t sz ;
511
533
/* custom user-provided value fetchable through bpf_get_attach_cookie() */
512
534
__u64 bpf_cookie ;
@@ -552,7 +574,7 @@ bpf_program__attach_ksyscall(const struct bpf_program *prog,
552
574
const struct bpf_ksyscall_opts * opts );
553
575
554
576
struct bpf_uprobe_opts {
555
- /* size of this struct, for forward/backward compatiblity */
577
+ /* size of this struct, for forward/backward compatibility */
556
578
size_t sz ;
557
579
/* offset of kernel reference counted USDT semaphore, added in
558
580
* a6ca88b241d5 ("trace_uprobe: support reference counter in fd-based uprobe")
@@ -570,9 +592,11 @@ struct bpf_uprobe_opts {
570
592
* binary_path.
571
593
*/
572
594
const char * func_name ;
595
+ /* uprobe attach mode */
596
+ enum probe_attach_mode attach_mode ;
573
597
size_t :0 ;
574
598
};
575
- #define bpf_uprobe_opts__last_field func_name
599
+ #define bpf_uprobe_opts__last_field attach_mode
576
600
577
601
/**
578
602
* @brief **bpf_program__attach_uprobe()** attaches a BPF program
@@ -646,7 +670,7 @@ bpf_program__attach_usdt(const struct bpf_program *prog,
646
670
const struct bpf_usdt_opts * opts );
647
671
648
672
struct bpf_tracepoint_opts {
649
- /* size of this struct, for forward/backward compatiblity */
673
+ /* size of this struct, for forward/backward compatibility */
650
674
size_t sz ;
651
675
/* custom user-provided value fetchable through bpf_get_attach_cookie() */
652
676
__u64 bpf_cookie ;
@@ -1110,7 +1134,7 @@ struct user_ring_buffer;
1110
1134
typedef int (* ring_buffer_sample_fn )(void * ctx , void * data , size_t size );
1111
1135
1112
1136
struct ring_buffer_opts {
1113
- size_t sz ; /* size of this struct, for forward/backward compatiblity */
1137
+ size_t sz ; /* size of this struct, for forward/backward compatibility */
1114
1138
};
1115
1139
1116
1140
#define ring_buffer_opts__last_field sz
@@ -1475,7 +1499,7 @@ LIBBPF_API void
1475
1499
bpf_object__destroy_subskeleton (struct bpf_object_subskeleton * s );
1476
1500
1477
1501
struct gen_loader_opts {
1478
- size_t sz ; /* size of this struct, for forward/backward compatiblity */
1502
+ size_t sz ; /* size of this struct, for forward/backward compatibility */
1479
1503
const char * data ;
1480
1504
const char * insns ;
1481
1505
__u32 data_sz ;
@@ -1493,13 +1517,13 @@ enum libbpf_tristate {
1493
1517
};
1494
1518
1495
1519
struct bpf_linker_opts {
1496
- /* size of this struct, for forward/backward compatiblity */
1520
+ /* size of this struct, for forward/backward compatibility */
1497
1521
size_t sz ;
1498
1522
};
1499
1523
#define bpf_linker_opts__last_field sz
1500
1524
1501
1525
struct bpf_linker_file_opts {
1502
- /* size of this struct, for forward/backward compatiblity */
1526
+ /* size of this struct, for forward/backward compatibility */
1503
1527
size_t sz ;
1504
1528
};
1505
1529
#define bpf_linker_file_opts__last_field sz
@@ -1542,7 +1566,7 @@ typedef int (*libbpf_prog_attach_fn_t)(const struct bpf_program *prog, long cook
1542
1566
struct bpf_link * * link );
1543
1567
1544
1568
struct libbpf_prog_handler_opts {
1545
- /* size of this struct, for forward/backward compatiblity */
1569
+ /* size of this struct, for forward/backward compatibility */
1546
1570
size_t sz ;
1547
1571
/* User-provided value that is passed to prog_setup_fn,
1548
1572
* prog_prepare_load_fn, and prog_attach_fn callbacks. Allows user to
0 commit comments