Skip to content

Commit 7044b5f

Browse files
committed
fix: opts
1 parent 6012e7c commit 7044b5f

2 files changed

Lines changed: 23 additions & 15 deletions

File tree

include/uapi/linux/bpf.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1413,7 +1413,9 @@ union bpf_attr {
14131413
__u32 insn_cnt;
14141414
__aligned_u64 insns;
14151415
__aligned_u64 license;
1416-
__aligned_u64 ir_data;
1416+
__u32 enable_epass;
1417+
__aligned_u64 epass_gopt;
1418+
__aligned_u64 epass_popt;
14171419
__u32 log_level; /* verbosity level of verifier */
14181420
__u32 log_size; /* size of user buffer */
14191421
__aligned_u64 log_buf; /* user supplied buffer */

kernel/bpf/syscall.c

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2594,7 +2594,9 @@ static int bpf_prog_load(union bpf_attr *attr, bpfptr_t uattr, u32 uattr_size)
25942594
struct btf *attach_btf = NULL;
25952595
int err;
25962596
char license[128];
2597-
char ir_data[128];
2597+
2598+
char epass_gopt[128];
2599+
char epass_popt[128];
25982600

25992601
if (CHECK_ATTR(BPF_PROG_LOAD))
26002602
return -EINVAL;
@@ -2709,14 +2711,23 @@ static int bpf_prog_load(union bpf_attr *attr, bpfptr_t uattr, u32 uattr_size)
27092711
goto free_prog_sec;
27102712
license[sizeof(license) - 1] = 0;
27112713

2712-
printk("HERE %llx", attr->ir_data);
27132714
/* copy epass options from user space */
2714-
if (attr->ir_data) {
2715-
if (strncpy_from_bpfptr(ir_data,
2716-
make_bpfptr(attr->ir_data,
2715+
if (attr->enable_epass) {
2716+
printk("ePass enabled");
2717+
if (strncpy_from_bpfptr(epass_gopt,
2718+
make_bpfptr(attr->epass_gopt,
2719+
uattr.is_kernel),
2720+
sizeof(epass_gopt) - 1) < 0)
2721+
goto free_prog_sec;
2722+
2723+
if (strncpy_from_bpfptr(epass_popt,
2724+
make_bpfptr(attr->epass_popt,
27172725
uattr.is_kernel),
2718-
sizeof(ir_data) - 1) < 0)
2726+
sizeof(epass_popt) - 1) < 0)
27192727
goto free_prog_sec;
2728+
2729+
printk("epass gopt: %s", epass_gopt);
2730+
printk("epass popt: %s", epass_popt);
27202731
}
27212732

27222733
/* eBPF programs must be GPL compatible to use GPL-ed functions */
@@ -2751,15 +2762,10 @@ static int bpf_prog_load(union bpf_attr *attr, bpfptr_t uattr, u32 uattr_size)
27512762
if (err < 0)
27522763
goto free_prog_sec;
27532764

2754-
// printk("enable: %d", ir_opts->enable_bpf_ir);
2755-
// printk("pass conf: %s", ir_opts->pass_opt);
2756-
// printk("global conf: %s", ir_opts->global_opt);
2757-
// printk("conf: %s", ir_data);
2758-
2759-
bool ENABLE_IR = false; // Should be changed to an option
2760-
if (ENABLE_IR) {
2765+
if (attr->enable_epass) {
27612766
// Run the framework
2762-
err = bpf_ir_kern_run(&prog, attr, uattr, uattr_size, "", "");
2767+
err = bpf_ir_kern_run(&prog, attr, uattr, uattr_size,
2768+
epass_popt, epass_gopt);
27632769
if (err < 0)
27642770
goto free_used_maps;
27652771
} else {

0 commit comments

Comments
 (0)