Skip to content

Commit 19ba54e

Browse files
committed
Refactor SPEC.md to remove unsupported program types and update attribute definitions.
1 parent 9badaf7 commit 19ba54e

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

SPEC.md

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ ebpf_program = attribute_list "fn" identifier "(" parameter_list ")" "->" return
174174
175175
attribute_list = attribute { attribute }
176176
attribute = "@" attribute_name [ "(" attribute_args ")" ]
177-
attribute_name = "xdp" | "tc" | "kprobe" | "uprobe" | "tracepoint" |
178-
"lsm" | "cgroup_skb" | "socket_filter" | "sk_lookup" | "struct_ops" | "kfunc" | "private" | "helper" | "test"
177+
attribute_name = "xdp" | "tc" | "kprobe" | "tracepoint" |
178+
"struct_ops" | "kfunc" | "private" | "helper" | "test"
179179
attribute_args = string_literal | identifier
180180
181181
parameter_list = parameter { "," parameter }
@@ -872,9 +872,6 @@ fn ingress_monitor(ctx: *xdp_md) -> xdp_action { return XDP_PASS }
872872
@tc
873873
fn egress_monitor(ctx: *__sk_buff) -> int { return 0 } // TC_ACT_OK
874874
875-
@lsm("socket_connect")
876-
fn security_check(ctx: LsmContext) -> i32 { return 0 }
877-
878875
// Struct_ops example using impl block approach
879876
struct tcp_congestion_ops {
880877
init: fn(sk: *TcpSock) -> void,
@@ -3292,11 +3289,11 @@ pin var global_config : array<ConfigKey, ConfigValue>(64)
32923289
// Multiple eBPF programs working together
32933290
@xdp fn network_monitor(ctx: *xdp_md) -> xdp_action {
32943291
// Access global maps directly
3295-
var flow_key = extract_flow_key(ctx)?
3292+
var flow_key = extract_flow_key(ctx)
32963293
global_flows[flow_key] += 1
32973294
32983295
// Use named config for decisions
3299-
if monitoring.enable_stats {
3296+
if (monitoring.enable_stats) {
33003297
monitoring.packets_processed += 1
33013298
}
33023299
@@ -3306,21 +3303,20 @@ pin var global_config : array<ConfigKey, ConfigValue>(64)
33063303
return XDP_PASS
33073304
}
33083305
3309-
program security_filter : lsm("socket_connect") {
3310-
fn main(ctx: LsmContext) -> i32 {
3311-
var flow_key = extract_flow_key_from_socket(ctx)?
3306+
@lsm("socket_connect")
3307+
fn security_filter(ctx: LsmContext) -> i32 {
3308+
var flow_key = extract_flow_key_from_socket(ctx)
33123309
3313-
// Check global flow statistics for threat detection
3314-
if (global_flows[flow_key] != null) {
3315-
var flow_stats = global_flows[flow_key]
3316-
if (flow_stats.is_suspicious()) {
3317-
global_events.submit(EVENT_THREAT_DETECTED { flow_key })
3318-
return -EPERM // Block connection
3319-
}
3310+
// Check global flow statistics for threat detection
3311+
if (global_flows[flow_key] != none) {
3312+
var flow_stats = global_flows[flow_key]
3313+
if (flow_stats.is_suspicious()) {
3314+
global_events.submit(EVENT_THREAT_DETECTED { flow_key })
3315+
return -EPERM // Block connection
33203316
}
3321-
3322-
return 0 // Allow connection
33233317
}
3318+
3319+
return 0 // Allow connection
33243320
}
33253321
33263322
struct SystemCoordinator {
@@ -4406,8 +4402,8 @@ flag_expression = identifier | ( identifier { "|" identifier } )
44064402
(* eBPF program function attributes *)
44074403
attribute_list = attribute { attribute }
44084404
attribute = "@" attribute_name [ "(" attribute_args ")" ]
4409-
attribute_name = "xdp" | "tc" | "kprobe" | "uprobe" | "tracepoint" | "lsm" |
4410-
"cgroup_skb" | "socket_filter" | "sk_lookup" | "raw_tracepoint" | "struct_ops" | "kfunc" | "helper" | "private" | "test"
4405+
attribute_name = "xdp" | "tc" | "kprobe" | "tracepoint" |
4406+
"struct_ops" | "kfunc" | "helper" | "private" | "test"
44114407
attribute_args = string_literal | identifier
44124408
44134409
(* Named configuration declarations *)

0 commit comments

Comments
 (0)