|
|
@ -22,7 +22,9 @@ use aya::programs::{tc, SchedClassifier, TcAttachType};
|
|
|
|
{%- when "cgroup_skb" -%}
|
|
|
|
{%- when "cgroup_skb" -%}
|
|
|
|
use aya::programs::{CgroupSkb, CgroupSkbAttachType};
|
|
|
|
use aya::programs::{CgroupSkb, CgroupSkbAttachType};
|
|
|
|
{%- when "cgroup_sysctl" -%}
|
|
|
|
{%- when "cgroup_sysctl" -%}
|
|
|
|
use aya::programs::{CgroupSysctl};
|
|
|
|
use aya::programs::CgroupSysctl;
|
|
|
|
|
|
|
|
{%- when "cgroup_sockopt" -%}
|
|
|
|
|
|
|
|
use aya::programs::CgroupSockopt;
|
|
|
|
{%- when "tracepoint" -%}
|
|
|
|
{%- when "tracepoint" -%}
|
|
|
|
use aya::programs::TracePoint;
|
|
|
|
use aya::programs::TracePoint;
|
|
|
|
{%- when "lsm" -%}
|
|
|
|
{%- when "lsm" -%}
|
|
|
@ -45,7 +47,7 @@ struct Opt {
|
|
|
|
{% if program_type == "xdp" or program_type == "classifier" -%}
|
|
|
|
{% if program_type == "xdp" or program_type == "classifier" -%}
|
|
|
|
#[clap(short, long, default_value = "eth0")]
|
|
|
|
#[clap(short, long, default_value = "eth0")]
|
|
|
|
iface: String,
|
|
|
|
iface: String,
|
|
|
|
{%- elsif program_type == "sock_ops" or program_type == "cgroup_skb" or program_type == "cgroup_sysctl" -%}
|
|
|
|
{%- elsif program_type == "sock_ops" or program_type == "cgroup_skb" or program_type == "cgroup_sysctl" or "cgroup_sockopt" -%}
|
|
|
|
#[clap(short, long, default_value = "/sys/fs/cgroup/unified")]
|
|
|
|
#[clap(short, long, default_value = "/sys/fs/cgroup/unified")]
|
|
|
|
cgroup_path: String,
|
|
|
|
cgroup_path: String,
|
|
|
|
{%- elsif program_type == "uprobe" or program_type == "uretprobe" -%}
|
|
|
|
{%- elsif program_type == "uprobe" or program_type == "uretprobe" -%}
|
|
|
@ -152,6 +154,11 @@ async fn main() -> Result<(), anyhow::Error> {
|
|
|
|
let cgroup = std::fs::File::open(opt.cgroup_path)?;
|
|
|
|
let cgroup = std::fs::File::open(opt.cgroup_path)?;
|
|
|
|
program.load()?;
|
|
|
|
program.load()?;
|
|
|
|
program.attach(cgroup)?;
|
|
|
|
program.attach(cgroup)?;
|
|
|
|
|
|
|
|
{%- when "cgroup_sockopt" -%}
|
|
|
|
|
|
|
|
let program: &mut CgroupSockopt = bpf.program_mut("{{crate_name}}").unwrap().try_into()?;
|
|
|
|
|
|
|
|
let cgroup = std::fs::File::open(opt.cgroup_path)?;
|
|
|
|
|
|
|
|
program.load()?;
|
|
|
|
|
|
|
|
program.attach(cgroup)?;
|
|
|
|
{%- endcase %}
|
|
|
|
{%- endcase %}
|
|
|
|
|
|
|
|
|
|
|
|
info!("Waiting for Ctrl-C...");
|
|
|
|
info!("Waiting for Ctrl-C...");
|
|
|
|