From 4ef077dd93d0e63f63fba2a8d57eee77a98aa5ff Mon Sep 17 00:00:00 2001 From: Daniel Noland Date: Fri, 5 Apr 2024 20:32:46 -0600 Subject: [PATCH] Support tc flower ip tos --- src/tc/filters/cls_flower.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/tc/filters/cls_flower.rs b/src/tc/filters/cls_flower.rs index 62738fc1..585ac0b7 100644 --- a/src/tc/filters/cls_flower.rs +++ b/src/tc/filters/cls_flower.rs @@ -211,6 +211,7 @@ pub type MplsBos = u8; pub type MplsTc = u8; pub type MplsLabel = u32; pub type TcpFlagsMask = u8; +pub type IpTos = u8; bitflags! { // TcpFlags _ARE_ exactly 8 bits. @@ -1370,6 +1371,7 @@ pub enum TcFilterFlowerOption { KeyMplsLabel(MplsLabel), KeyTcpFlags(TcpFlags), KeyTcpFlagsMask(TcpFlagsMask), + KeyIpTos(IpTos), } impl Nla for TcFilterFlowerOption { @@ -1445,6 +1447,7 @@ impl Nla for TcFilterFlowerOption { Self::KeyMplsLabel(_) => 4, Self::KeyTcpFlags(_) => 2, Self::KeyTcpFlagsMask(_) => 2, + Self::KeyIpTos(_) => 1, Self::Other(attr) => attr.value_len(), } } @@ -1525,6 +1528,7 @@ impl Nla for TcFilterFlowerOption { Self::KeyMplsLabel(_) => TCA_FLOWER_KEY_MPLS_LABEL, Self::KeyTcpFlags(_) => TCA_FLOWER_KEY_TCP_FLAGS, Self::KeyTcpFlagsMask(_) => TCA_FLOWER_KEY_TCP_FLAGS_MASK, + Self::KeyIpTos(_) => TCA_FLOWER_KEY_IP_TOS, Self::Other(attr) => attr.kind(), } } @@ -1676,6 +1680,7 @@ impl Nla for TcFilterFlowerOption { Self::KeyTcpFlagsMask(flags) => { buffer.copy_from_slice((*flags as u16).to_be_bytes().as_slice()) } + Self::KeyIpTos(tos) => buffer.copy_from_slice(&[*tos].as_slice()), Self::Other(attr) => attr.emit_value(buffer), } }