From 6fcf0c5669489c3d443ca18d76c591fb28f43e8b Mon Sep 17 00:00:00 2001 From: Kenjiro Nakayama Date: Wed, 9 Feb 2022 13:38:36 +0900 Subject: [PATCH] Add `attach` attribute for cgroup SKB When cgroup SKB is generated via template, the `attach` attribute is always missing and the program does not work by default. This patch fixes it. --- {{project-name}}-ebpf/src/main.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/{{project-name}}-ebpf/src/main.rs b/{{project-name}}-ebpf/src/main.rs index f676e99..546722d 100644 --- a/{{project-name}}-ebpf/src/main.rs +++ b/{{project-name}}-ebpf/src/main.rs @@ -183,7 +183,11 @@ use aya_bpf::{ programs::SkBuffContext, }; -#[cgroup_skb(name="{{crate_name}}")] +{% if direction == "Ingress" -%} +#[cgroup_skb(name="{{crate_name}}",attach="ingress")] +{%- else -%} +#[cgroup_skb(name="{{crate_name}}",attach="egress")] +{%- endif %} pub fn {{crate_name}}(ctx: SkBuffContext) -> i32 { match unsafe { try_{{crate_name}}(ctx) } { Ok(ret) => ret,