Skip to content

Commit 949bd99

Browse files
committed
Refactor program template handling by removing unused program types and updating context type references for 'xdp' and 'tc'. Ensure unsupported program types raise an error for better clarity.
1 parent 9c0a2ff commit 949bd99

File tree

2 files changed

+4
-19
lines changed

2 files changed

+4
-19
lines changed

src/btf_parser.ml

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -63,28 +63,13 @@ let create_hardcoded_tc_action_enum () = {
6363
(** Get program template based on eBPF program type *)
6464
let get_program_template prog_type btf_path =
6565
let (context_type, return_type, common_types) = match prog_type with
66-
| "xdp" -> ("xdp_md", "xdp_action", [
66+
| "xdp" -> ("*xdp_md", "xdp_action", [
6767
"xdp_md"; "xdp_action"
6868
])
69-
| "tc" -> ("__sk_buff", "i32", [
69+
| "tc" -> ("*__sk_buff", "i32", [
7070
"__sk_buff"
7171
])
72-
| "kprobe" -> ("pt_regs", "i32", [
73-
"pt_regs"
74-
])
75-
| "uprobe" -> ("pt_regs", "i32", [
76-
"pt_regs"
77-
])
78-
| "tracepoint" -> ("trace_entry", "i32", [
79-
"trace_entry"
80-
])
81-
| "lsm" -> ("task_struct", "i32", [
82-
"task_struct"; "file"; "inode"
83-
])
84-
| "cgroup_skb" -> ("__sk_buff", "i32", [
85-
"__sk_buff"
86-
])
87-
| _ -> ("GenericContext", "i32", [])
72+
| _ -> failwith (sprintf "Unsupported program type '%s' for generic template. Use specific template functions for kprobe/tracepoint." prog_type)
8873
in
8974

9075
(* Extract types from BTF - BTF file is required *)

src/main.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ let init_project prog_type_or_struct_ops project_name btf_path =
143143
in
144144

145145
(* Check if this is a struct_ops or a regular program type *)
146-
let valid_program_types = ["xdp"; "tc"; "kprobe"; "uprobe"; "tracepoint"; "lsm"; "cgroup_skb"] in
146+
let valid_program_types = ["xdp"; "tc"; "kprobe"; "tracepoint"] in
147147
let is_struct_ops = Struct_ops_registry.is_known_struct_ops prog_type in
148148
let is_program_type = List.mem prog_type valid_program_types in
149149

0 commit comments

Comments
 (0)