@@ -69,7 +69,7 @@ fn monitor(ctx: *xdp_md) -> xdp_action {
6969}
7070
7171@tc("ingress")
72- fn analyzer(ctx: *__sk_buff) -> int {
72+ fn analyzer(ctx: *__sk_buff) -> i32 {
7373 update_counters(1) // Same kernel-shared function
7474 return 0 // TC_ACT_OK
7575}
@@ -256,7 +256,7 @@ TC programs must specify traffic direction for proper kernel attachment point se
256256``` kernelscript
257257// Ingress traffic control (packets entering the interface)
258258@tc("ingress")
259- fn ingress_filter(ctx: *__sk_buff) -> int {
259+ fn ingress_filter(ctx: *__sk_buff) -> i32 {
260260 var packet_size = ctx->len
261261
262262 // Drop oversized packets at ingress
@@ -269,7 +269,7 @@ fn ingress_filter(ctx: *__sk_buff) -> int {
269269
270270// Egress traffic control (packets leaving the interface)
271271@tc("egress")
272- fn egress_shaper(ctx: *__sk_buff) -> int {
272+ fn egress_shaper(ctx: *__sk_buff) -> i32 {
273273 var protocol = ctx->protocol
274274
275275 // Shape traffic based on protocol at egress
@@ -798,7 +798,7 @@ fn packet_analyzer(ctx: *xdp_md) -> xdp_action {
798798}
799799
800800@tc("ingress")
801- fn flow_tracker(ctx: *__sk_buff) -> int {
801+ fn flow_tracker(ctx: *__sk_buff) -> i32 {
802802 // Track flow information using shared config
803803 if (monitoring.enable_stats && (ctx.hash() % monitoring.sample_rate == 0)) {
804804 // Sample this flow
@@ -867,7 +867,7 @@ fn packet_filter(ctx: *xdp_md) -> xdp_action {
867867}
868868
869869@tc("ingress")
870- fn flow_monitor(ctx: *__sk_buff) -> int {
870+ fn flow_monitor(ctx: *__sk_buff) -> i32 {
871871 return 0 // TC_ACT_OK
872872}
873873
@@ -1021,7 +1021,7 @@ fn main(args: Args) -> i32 {
10211021fn ingress_monitor(ctx: *xdp_md) -> xdp_action { return XDP_PASS }
10221022
10231023@tc("egress")
1024- fn egress_monitor(ctx: *__sk_buff) -> int { return 0 } // TC_ACT_OK
1024+ fn egress_monitor(ctx: *__sk_buff) -> i32 { return 0 } // TC_ACT_OK
10251025
10261026// Struct_ops example using impl block approach
10271027struct tcp_congestion_ops {
@@ -1419,7 +1419,7 @@ fn packet_filter(ctx: *xdp_md) -> xdp_action {
14191419}
14201420
14211421@tc("ingress")
1422- fn traffic_shaper(ctx: *__sk_buff) -> int {
1422+ fn traffic_shaper(ctx: *__sk_buff) -> i32 {
14231423 var packet = ctx.packet()
14241424
14251425 // Reuse the same helpers
@@ -1475,7 +1475,7 @@ fn ddos_protection(ctx: *xdp_md) -> xdp_action {
14751475}
14761476
14771477@tc("ingress")
1478- fn connection_tracker(ctx: *__sk_buff) -> int {
1478+ fn connection_tracker(ctx: *__sk_buff) -> i32 {
14791479 var tcp_info = extract_tcp_info(ctx) // Reuse same helper
14801480 if (tcp_info != null) {
14811481 track_connection(tcp_info.src_port, tcp_info.dst_port)
@@ -1609,7 +1609,7 @@ fn high_level_filter(packet: *u8, len: u32) -> i32 {
16091609
16101610// eBPF usage
16111611@tc("ingress")
1612- fn traffic_analyzer(ctx: *__sk_buff) -> int {
1612+ fn traffic_analyzer(ctx: *__sk_buff) -> i32 {
16131613 var packet = ctx.packet()
16141614
16151615 // Can only call the public kfunc
@@ -2516,7 +2516,7 @@ fn ingress_monitor(ctx: *xdp_md) -> xdp_action {
25162516
25172517// Program 2: Automatically has access to the same global maps
25182518@tc("egress")
2519- fn egress_monitor(ctx: *__sk_buff) -> int {
2519+ fn egress_monitor(ctx: *__sk_buff) -> i32 {
25202520 var flow_key = extract_flow_key(ctx)?
25212521
25222522 // Same global map, no import needed - compound assignments work everywhere
@@ -2976,7 +2976,7 @@ fn packet_filter(ctx: *xdp_md) -> xdp_action {
29762976}
29772977
29782978@tc("ingress")
2979- fn flow_monitor(ctx: *__sk_buff) -> int {
2979+ fn flow_monitor(ctx: *__sk_buff) -> i32 {
29802980 // Can call the same kernel-shared functions
29812981 if (!validate_packet(ctx.packet())) {
29822982 return 2 // TC_ACT_SHOT
@@ -3081,7 +3081,7 @@ fn main_filter(ctx: *xdp_md) -> xdp_action {
30813081}
30823082
30833083@tc("ingress")
3084- fn ingress_handler(ctx: *__sk_buff) -> int {
3084+ fn ingress_handler(ctx: *__sk_buff) -> i32 {
30853085 return security_check(ctx) // ✅ Same type (@tc), return position
30863086}
30873087```
@@ -3670,7 +3670,7 @@ program network_monitor : xdp {
36703670}
36713671
36723672program flow_analyzer : tc {
3673- fn main(ctx: *__sk_buff) -> int {
3673+ fn main(ctx: *__sk_buff) -> i32 {
36743674 return 0 // TC_ACT_OK
36753675 }
36763676}
0 commit comments