From 1ecc829b4fdb7570fae381e089eb7467a19235bc Mon Sep 17 00:00:00 2001 From: Michal Rostecki Date: Thu, 28 Jul 2022 11:02:50 +0200 Subject: [PATCH] classifier: Use the new `TcContext` struct That new context type exposes `data` and `data_end` fields for direct access to the packet payload. Signed-off-by: Michal Rostecki --- {{project-name}}-ebpf/src/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/{{project-name}}-ebpf/src/main.rs b/{{project-name}}-ebpf/src/main.rs index 9774bf9..a70053a 100644 --- a/{{project-name}}-ebpf/src/main.rs +++ b/{{project-name}}-ebpf/src/main.rs @@ -182,19 +182,19 @@ unsafe fn try_{{crate_name}}(ctx: XdpContext) -> Result { {%- when "classifier" %} use aya_bpf::{ macros::classifier, - programs::SkBuffContext, + programs::TcContext, }; use aya_log_ebpf::info; #[classifier(name="{{crate_name}}")] -pub fn {{crate_name}}(ctx: SkBuffContext) -> i32 { +pub fn {{crate_name}}(ctx: TcContext) -> i32 { match unsafe { try_{{crate_name}}(ctx) } { Ok(ret) => ret, Err(ret) => ret, } } -unsafe fn try_{{crate_name}}(ctx: SkBuffContext) -> Result { +unsafe fn try_{{crate_name}}(ctx: TcContext) -> Result { info!(&ctx, "received a packet"); Ok(0) }