runtime-rs: fix tc filter setup failed

Fix bug using tc filter and protocol needs to use network byte order.

Fixes: #4726
Signed-off-by: Quanwei Zhou <quanweiZhou@linux.alibaba.com>
This commit is contained in:
Quanwei Zhou 2022-07-24 20:44:24 +08:00 committed by quanwei.zqw
parent e0194dcb5e
commit c825065b27

View File

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