From 4d22913931a65001a10ffaf2460bddc7187e0010 Mon Sep 17 00:00:00 2001 From: Dmitry Savintsev Date: Sun, 23 Jan 2022 22:15:47 +0100 Subject: [PATCH] classifier: don't bail on qdisc_add_clsact error --- {{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 06c8641..10ca1b2 100644 --- a/{{project-name}}/src/main.rs +++ b/{{project-name}}/src/main.rs @@ -111,7 +111,9 @@ async fn main() -> Result<(), anyhow::Error> { 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)?; + // error adding clsact to the interface if it is already added is harmless + // the full cleanup can be done with 'sudo tc qdisc del dev eth0 clsact'. + let _ = tc::qdisc_add_clsact(&opt.iface); let program: &mut SchedClassifier = bpf.program_mut("{{crate_name}}").unwrap().try_into()?; program.load()?; program.attach(&opt.iface, TcAttachType::{{direction}})?;