-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathstruct_ops_simple.ks
More file actions
44 lines (34 loc) · 1.43 KB
/
struct_ops_simple.ks
File metadata and controls
44 lines (34 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Test file with impl block struct_ops declarations using the new syntax
// This demonstrates the clean, intuitive impl block approach (Option 1)
include "tcp_congestion_ops.kh"
@struct_ops("tcp_congestion_ops")
impl minimal_congestion_control {
// Function implementations are directly defined in the impl block
// These automatically become eBPF functions with SEC("struct_ops/function_name")
fn ssthresh(sk: *u8) -> u32 {
return 16
}
fn undo_cwnd(sk: *u8) -> u32 {
return ssthresh(sk)
}
fn cong_avoid(sk: *u8, ack: u32, acked: u32) -> void {
// Minimal TCP congestion avoidance implementation
// In a real implementation, this would adjust the congestion window
}
fn set_state(sk: *u8, new_state: u8) -> void {
// Minimal state change handler
// In a real implementation, this would handle TCP state transitions
}
fn cwnd_event(sk: *u8, ev: u32) -> void {
// Minimal congestion window event handler
// In a real implementation, this would handle events like slow start, recovery, etc.
}
// Optional function implementations (can be omitted for minimal testing)
// These would be null in the generated struct_ops map
}
// Userspace main function
fn main() -> i32 {
// Register the impl block directly - much cleaner than struct initialization!
var result = register(minimal_congestion_control)
return result
}