Skip to content

Commit

Permalink
runtime-rs: fix tc filter setup failed
Browse files Browse the repository at this point in the history
Fix bug using tc filter and protocol needs to use network byte order.

Fixes: #4726
Signed-off-by: Quanwei Zhou <quanweiZhou@linux.alibaba.com>
  • Loading branch information
quanweiZhou authored and quanwei.zqw committed Jul 25, 2022
1 parent e0194dc commit c825065
Showing 1 changed file with 10 additions and 6 deletions.
Expand Up @@ -20,6 +20,7 @@ impl TcFilterModel {
Ok(Self {})
}
}

#[async_trait]
impl NetworkModel for TcFilterModel {
fn model_type(&self) -> NetworkModelType {
Expand Down Expand Up @@ -60,22 +61,25 @@ impl NetworkModel for TcFilterModel {
handle
.traffic_filter(tap_index as i32)
.add()
.protocol(0x0003)
.egress()
.parent(0xffff0000)
// get protocol with network byte order
.protocol(0x0003_u16.to_be())
.redirect(virt_index)
.execute()
.await
.context("add tap egress")?;
.context("add redirect for tap")?;

handle
.traffic_filter(virt_index as i32)
.add()
.protocol(0x0003)
.egress()
.parent(0xffff0000)
// get protocol with network byte order
.protocol(0x0003_u16.to_be())
.redirect(tap_index)
.execute()
.await
.context("add virt egress")?;
.context("add redirect for virt")?;

Ok(())
}

Expand Down

0 comments on commit c825065

Please sign in to comment.