From 21803634d73ad213a14e818174c1e97f4cd288e3 Mon Sep 17 00:00:00 2001 From: Dmitry S Date: Fri, 14 Jan 2022 15:50:10 +0100 Subject: [PATCH] xdp - suggest SKB_MODE on attach failure --- {{project-name}}/src/main.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/{{project-name}}/src/main.rs b/{{project-name}}/src/main.rs index 9e1ccf1..342cdc6 100644 --- a/{{project-name}}/src/main.rs +++ b/{{project-name}}/src/main.rs @@ -16,6 +16,7 @@ use aya::programs::SkMsg; use {{crate_name}}_common::SockKey; use std::convert::TryFrom; {%- when "xdp" -%} +use anyhow::Context; use aya::programs::{Xdp, XdpFlags}; {%- when "classifier" -%} use aya::programs::{tc, SchedClassifier, TcAttachType}; @@ -104,7 +105,8 @@ fn try_main() -> Result<(), anyhow::Error> { {%- when "xdp" -%} let program: &mut Xdp = bpf.program_mut("{{crate_name}}").unwrap().try_into()?; program.load()?; - program.attach(&opt.iface, XdpFlags::default())?; + program.attach(&opt.iface, XdpFlags::default()) + .context("failed to attach the XDP program with default flags - try changing XdpFlags::default() to XdpFlags::SKB_MODE")?; {%- when "classifier" -%} tc::qdisc_add_clsact(&opt.iface)?; let program: &mut SchedClassifier = bpf.program_mut("{{crate_name}}").unwrap().try_into()?;