adjust spacing to avoid VSCode changes on save

Signed-off-by: Dmitry Savintsev <dsavints@gmail.com>
pull/75/head
Dmitry Savintsev 2 years ago
parent 999d98cc3d
commit 8cd95c42ea

@ -2,10 +2,7 @@
#![no_main] #![no_main]
{% case program_type -%} {% case program_type -%}
{%- when "kprobe" %} {%- when "kprobe" %}
use aya_bpf::{ use aya_bpf::{macros::kprobe, programs::ProbeContext};
macros::kprobe,
programs::ProbeContext,
};
use aya_log_ebpf::info; use aya_log_ebpf::info;
#[kprobe(name = "{{crate_name}}")] #[kprobe(name = "{{crate_name}}")]
@ -21,10 +18,7 @@ fn try_{{crate_name}}(ctx: ProbeContext) -> Result<u32, u32> {
Ok(0) Ok(0)
} }
{%- when "kretprobe" %} {%- when "kretprobe" %}
use aya_bpf::{ use aya_bpf::{macros::kretprobe, programs::ProbeContext};
macros::kretprobe,
programs::ProbeContext,
};
use aya_log_ebpf::info; use aya_log_ebpf::info;
#[kretprobe(name = "{{crate_name}}")] #[kretprobe(name = "{{crate_name}}")]
@ -160,11 +154,7 @@ fn try_{{crate_name}}(ctx: SkMsgContext) -> Result<u32, u32> {
Ok(0) Ok(0)
} }
{%- when "xdp" %} {%- when "xdp" %}
use aya_bpf::{ use aya_bpf::{bindings::xdp_action, macros::xdp, programs::XdpContext};
bindings::xdp_action,
macros::xdp,
programs::XdpContext,
};
use aya_log_ebpf::info; use aya_log_ebpf::info;
#[xdp(name = "{{crate_name}}")] #[xdp(name = "{{crate_name}}")]
@ -180,10 +170,7 @@ fn try_{{crate_name}}(ctx: XdpContext) -> Result<u32, u32> {
Ok(xdp_action::XDP_PASS) Ok(xdp_action::XDP_PASS)
} }
{%- when "classifier" %} {%- when "classifier" %}
use aya_bpf::{ use aya_bpf::{macros::classifier, programs::TcContext};
macros::classifier,
programs::TcContext,
};
use aya_log_ebpf::info; use aya_log_ebpf::info;
#[classifier(name = "{{crate_name}}")] #[classifier(name = "{{crate_name}}")]
@ -304,10 +291,7 @@ fn try_{{crate_name}}(ctx: SysctlContext) -> Result<i32, i32> {
Ok(0) Ok(0)
} }
{%- when "cgroup_sockopt" %} {%- when "cgroup_sockopt" %}
use aya_bpf::{ use aya_bpf::{macros::cgroup_sockopt, programs::SockoptContext};
macros::cgroup_sockopt,
programs::SockoptContext,
};
use aya_log_ebpf::info; use aya_log_ebpf::info;
#[cgroup_sockopt({{sockopt_target}}, name = "{{crate_name}}")] #[cgroup_sockopt({{sockopt_target}}, name = "{{crate_name}}")]
@ -323,10 +307,7 @@ fn try_{{crate_name}}(ctx: SockoptContext) -> Result<i32, i32> {
Ok(0) Ok(0)
} }
{%- when "raw_tracepoint" %} {%- when "raw_tracepoint" %}
use aya_bpf::{ use aya_bpf::{macros::raw_tracepoint, programs::RawTracePointContext};
macros::raw_tracepoint,
programs::RawTracePointContext,
};
use aya_log_ebpf::info; use aya_log_ebpf::info;
#[raw_tracepoint(name = "{{crate_name}}")] #[raw_tracepoint(name = "{{crate_name}}")]
@ -343,10 +324,7 @@ fn try_{{crate_name}}(ctx: RawTracePointContext) -> Result<i32, i32> {
} }
{%- when "perf_event" %} {%- when "perf_event" %}
use aya_bpf::{ use aya_bpf::{
helpers::bpf_get_smp_processor_id, helpers::bpf_get_smp_processor_id, macros::perf_event, programs::PerfEventContext, BpfContext,
macros::perf_event,
programs::PerfEventContext,
BpfContext,
}; };
use aya_log_ebpf::info; use aya_log_ebpf::info;
@ -361,8 +339,14 @@ pub fn {{crate_name}}(ctx: PerfEventContext) -> u32 {
fn try_{{crate_name}}(ctx: PerfEventContext) -> Result<u32, u32> { fn try_{{crate_name}}(ctx: PerfEventContext) -> Result<u32, u32> {
let cpu = unsafe { bpf_get_smp_processor_id() }; let cpu = unsafe { bpf_get_smp_processor_id() };
match ctx.pid() { match ctx.pid() {
0 => info!(&ctx, "perf_event '{{crate_name}}' triggered on CPU {}, running a kernel task", cpu), 0 => info!(
pid => info!(&ctx, "perf_event '{{crate_name}}' triggered on CPU {}, running PID {}", cpu, pid), &ctx,
"perf_event 'perftest' triggered on CPU {}, running a kernel task", cpu
),
pid => info!(
&ctx,
"perf_event 'perftest' triggered on CPU {}, running PID {}", cpu, pid
),
} }
Ok(0) Ok(0)

@ -6,16 +6,14 @@ publish = false
[dependencies] [dependencies]
aya = { version = ">=0.11", features=["async_tokio"] } aya = { version = ">=0.11", features=["async_tokio"] }
aya-log = "0.1"
{% if program_types_with_opts contains program_type -%} {% if program_types_with_opts contains program_type -%}
clap = { version = "4.1", features = ["derive"] } clap = { version = "4.1", features = ["derive"] }
{% endif -%} {% endif -%}
aya-log = "0.1"
{{project-name}}-common = { path = "../{{project-name}}-common", features = ["user"] } {{project-name}}-common = { path = "../{{project-name}}-common", features = ["user"] }
anyhow = "1.0.68" anyhow = "1.0.68"
env_logger = "0.10" env_logger = "0.10"
{%- if program_type == "uprobe" %}
libc = "0.2" libc = "0.2"
{%- endif %}
log = "0.4" log = "0.4"
tokio = { version = "1.24", features = ["macros", "rt", "rt-multi-thread", "net", "signal"] } tokio = { version = "1.24", features = ["macros", "rt", "rt-multi-thread", "net", "signal"] }

Loading…
Cancel
Save